]> git.cworth.org Git - apitrace/commitdiff
gui: Fix editing of the shaders
authorZack Rusin <zack@kde.org>
Fri, 6 Jul 2012 19:53:29 +0000 (15:53 -0400)
committerZack Rusin <zack@kde.org>
Fri, 6 Jul 2012 19:53:29 +0000 (15:53 -0400)
Editing shaders was broken because we were adding extra values to
the arguments array. This fixes it, meaning that if you right click
on glShaderSource you can edit the shader source and the rest of the
trace will properly catch the changes. An incredibly useful feature.

gui/saverthread.cpp

index fc6a023ef908ac6b5375dce2e173d98b86491000..4ad83c5876c5caf1267d80cc8c8029bdc18b7c93 100644 (file)
@@ -247,7 +247,10 @@ public:
     virtual void visit(trace::String *node)
     {
         QString str = m_variant.toString();
-        m_editedValue = new trace::String(str.toLocal8Bit().constData());
+        char *newString = new char[str.length() + 1];
+        QByteArray ba = str.toLocal8Bit();
+        strcpy(newString, ba.constData());
+        m_editedValue = new trace::String(newString);
     }
 
     virtual void visit(trace::Enum *e)
@@ -273,7 +276,6 @@ public:
         trace::Array *newArray = new trace::Array(vals.count());
         for (int i = 0; i < vals.count(); ++i) {
             EditVisitor visitor(vals[i]);
-
             array->values[i]->visit(visitor);
             if (array->values[i] == visitor.value()) {
                 //non-editabled
@@ -282,7 +284,7 @@ public:
                 return;
             }
 
-            newArray->values.push_back(visitor.value());
+            newArray->values[i] = visitor.value();
         }
         m_editedValue = newArray;
     }