delay command execution until call to Object::apply has finished (avoids cutting off the branch we are sitting on)

move
Marc Zinnschlag 9 years ago
parent 6a2fe564ef
commit fa9689c5e7

@ -268,7 +268,7 @@ void CSVRender::InstanceMode::dragCompleted()
{ {
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (iter->get())) if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (iter->get()))
{ {
objectTag->mObject->apply (undoStack); objectTag->mObject->apply (macro);
} }
} }

@ -19,6 +19,7 @@
#include "../../model/world/refidcollection.hpp" #include "../../model/world/refidcollection.hpp"
#include "../../model/world/commands.hpp" #include "../../model/world/commands.hpp"
#include "../../model/world/universalid.hpp" #include "../../model/world/universalid.hpp"
#include "../../model/world/commandmacro.hpp"
#include <components/resource/scenemanager.hpp> #include <components/resource/scenemanager.hpp>
#include <components/sceneutil/lightutil.hpp> #include <components/sceneutil/lightutil.hpp>
@ -524,7 +525,7 @@ void CSVRender::Object::setScale (float scale)
adjustTransform(); adjustTransform();
} }
void CSVRender::Object::apply (QUndoStack& undoStack) void CSVRender::Object::apply (CSMWorld::CommandMacro& commands)
{ {
const CSMWorld::RefCollection& collection = mData.getReferences(); const CSMWorld::RefCollection& collection = mData.getReferences();
QAbstractItemModel *model = mData.getTableModel (CSMWorld::UniversalId::Type_References); 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> ( int column = collection.findColumnIndex (static_cast<CSMWorld::Columns::ColumnId> (
CSMWorld::Columns::ColumnId_PositionXPos+i)); CSMWorld::Columns::ColumnId_PositionXPos+i));
undoStack.push (new CSMWorld::ModifyCommand (*model, commands.push (new CSMWorld::ModifyCommand (*model,
model->index (recordIndex, column), mPositionOverride.pos[i])); 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> ( int column = collection.findColumnIndex (static_cast<CSMWorld::Columns::ColumnId> (
CSMWorld::Columns::ColumnId_PositionXRot+i)); CSMWorld::Columns::ColumnId_PositionXRot+i));
undoStack.push (new CSMWorld::ModifyCommand (*model, commands.push (new CSMWorld::ModifyCommand (*model,
model->index (recordIndex, column), mPositionOverride.rot[i])); 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); 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)); model->index (recordIndex, column), mScaleOverride));
} }

@ -37,6 +37,7 @@ namespace CSMWorld
{ {
class Data; class Data;
struct CellRef; struct CellRef;
class CommandMacro;
} }
namespace CSVRender namespace CSVRender
@ -172,7 +173,7 @@ namespace CSVRender
void setScale (float scale); void setScale (float scale);
/// Apply override changes via command and end edit mode /// Apply override changes via command and end edit mode
void apply (QUndoStack& undoStack); void apply (CSMWorld::CommandMacro& commands);
void setSubMode (int subMode); void setSubMode (int subMode);

Loading…
Cancel
Save