diff --git a/qrenderdoc/Windows/ShaderViewer.cpp b/qrenderdoc/Windows/ShaderViewer.cpp index 50221bbcd..05278df3c 100644 --- a/qrenderdoc/Windows/ShaderViewer.cpp +++ b/qrenderdoc/Windows/ShaderViewer.cpp @@ -1574,6 +1574,8 @@ void ShaderViewer::applyBackwardsChange() { if(!IsFirstState()) { + rdcarray newVariables; + for(const ShaderVariableChange &c : GetCurrentState().changes) { // if the before name is empty, this is a variable that came into scope/was created @@ -1604,10 +1606,12 @@ void ShaderViewer::applyBackwardsChange() if(v) *v = c.before; else - m_Variables.push_back(c.before); + newVariables.push_back(c.before); } } + m_Variables.insert(0, newVariables); + m_CurrentStateIdx--; } } @@ -1618,6 +1622,8 @@ void ShaderViewer::applyForwardsChange() { m_CurrentStateIdx++; + rdcarray newVariables; + for(const ShaderVariableChange &c : GetCurrentState().changes) { // if the after name is empty, this is a variable going out of scope/being deleted @@ -1648,9 +1654,11 @@ void ShaderViewer::applyForwardsChange() if(v) *v = c.after; else - m_Variables.push_back(c.after); + newVariables.push_back(c.after); } } + + m_Variables.insert(0, newVariables); } } @@ -1866,7 +1874,7 @@ void ShaderViewer::combineStructures(RDTreeWidgetItem *root, int skipPrefixLengt // move all the children back from the temp object into the parameter while(temp.childCount() > 0) - root->addChild(temp.takeChild(temp.childCount() - 1)); + root->addChild(temp.takeChild(0)); } RDTreeWidgetItem *ShaderViewer::findVarInTree(RDTreeWidgetItem *root, QString name, bool fullmatch,