From: Zack Rusin Date: Fri, 6 Jul 2012 19:53:29 +0000 (-0400) Subject: gui: Fix editing of the shaders X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=c65f6ddf6e16d18b117f541cbc8ac291c5db16eb;hp=9cb30bec22c1c277a0bfb45628a0a59c36b1cfc5;p=apitrace gui: Fix editing of the shaders 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. --- diff --git a/gui/saverthread.cpp b/gui/saverthread.cpp index fc6a023..4ad83c5 100644 --- a/gui/saverthread.cpp +++ b/gui/saverthread.cpp @@ -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; }