From fa9689c5e7121acbda5e17371191b33f13c9d14f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 11 Mar 2016 14:04:47 +0100 Subject: [PATCH] delay command execution until call to Object::apply has finished (avoids cutting off the branch we are sitting on) --- apps/opencs/view/render/instancemode.cpp | 2 +- apps/opencs/view/render/object.cpp | 9 +++++---- apps/opencs/view/render/object.hpp | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index 12bc77105..32373c395 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -268,7 +268,7 @@ void CSVRender::InstanceMode::dragCompleted() { if (CSVRender::ObjectTag *objectTag = dynamic_cast (iter->get())) { - objectTag->mObject->apply (undoStack); + objectTag->mObject->apply (macro); } } diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index 6ca751ba5..f7bb338cd 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -19,6 +19,7 @@ #include "../../model/world/refidcollection.hpp" #include "../../model/world/commands.hpp" #include "../../model/world/universalid.hpp" +#include "../../model/world/commandmacro.hpp" #include #include @@ -524,7 +525,7 @@ void CSVRender::Object::setScale (float scale) adjustTransform(); } -void CSVRender::Object::apply (QUndoStack& undoStack) +void CSVRender::Object::apply (CSMWorld::CommandMacro& commands) { const CSMWorld::RefCollection& collection = mData.getReferences(); QAbstractItemModel *model = mData.getTableModel (CSMWorld::UniversalId::Type_References); @@ -538,7 +539,7 @@ void CSVRender::Object::apply (QUndoStack& undoStack) int column = collection.findColumnIndex (static_cast ( CSMWorld::Columns::ColumnId_PositionXPos+i)); - undoStack.push (new CSMWorld::ModifyCommand (*model, + commands.push (new CSMWorld::ModifyCommand (*model, model->index (recordIndex, column), mPositionOverride.pos[i])); } } @@ -550,7 +551,7 @@ void CSVRender::Object::apply (QUndoStack& undoStack) int column = collection.findColumnIndex (static_cast ( CSMWorld::Columns::ColumnId_PositionXRot+i)); - undoStack.push (new CSMWorld::ModifyCommand (*model, + commands.push (new CSMWorld::ModifyCommand (*model, model->index (recordIndex, column), mPositionOverride.rot[i])); } } @@ -559,7 +560,7 @@ void CSVRender::Object::apply (QUndoStack& undoStack) { int column = collection.findColumnIndex (CSMWorld::Columns::ColumnId_Scale); - undoStack.push (new CSMWorld::ModifyCommand (*model, + commands.push (new CSMWorld::ModifyCommand (*model, model->index (recordIndex, column), mScaleOverride)); } diff --git a/apps/opencs/view/render/object.hpp b/apps/opencs/view/render/object.hpp index a5cc141a0..54a284fa3 100644 --- a/apps/opencs/view/render/object.hpp +++ b/apps/opencs/view/render/object.hpp @@ -37,6 +37,7 @@ namespace CSMWorld { class Data; struct CellRef; + class CommandMacro; } namespace CSVRender @@ -172,7 +173,7 @@ namespace CSVRender void setScale (float scale); /// Apply override changes via command and end edit mode - void apply (QUndoStack& undoStack); + void apply (CSMWorld::CommandMacro& commands); void setSubMode (int subMode);