diff options
author | Aleks Kissinger <aleks0@gmail.com> | 2018-04-15 12:11:19 +0300 |
---|---|---|
committer | Aleks Kissinger <aleks0@gmail.com> | 2018-04-15 12:11:19 +0300 |
commit | 34b60b77d3f9830ddb6a0107bd65aa3c79701305 (patch) | |
tree | 9a3bf10d31c199017249437e0f6880b3803addb9 /src | |
parent | 10d739ce2ac904501a6f78b127f91c944a774a18 (diff) |
fixed crash on paste
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/tikzscene.h | 7 | ||||
-rw-r--r-- | src/gui/undocommands.cpp | 5 | ||||
-rw-r--r-- | src/gui/undocommands.h | 4 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/gui/tikzscene.h b/src/gui/tikzscene.h index 634a848..9d90c4f 100644 --- a/src/gui/tikzscene.h +++ b/src/gui/tikzscene.h @@ -49,6 +49,10 @@ public: void setEnabled(bool enabled); int lineNumberForSelection(); + + void getSelection(QSet<Node*> &selNodes, QSet<Edge*> &selEdges); + QSet<Node*> getSelectedNodes(); + public slots: void graphReplaced(); @@ -80,9 +84,6 @@ private: int _oldInAngle; int _oldOutAngle; bool _enabled; - - void getSelection(QSet<Node*> &selNodes, QSet<Edge*> &selEdges); - QSet<Node*> getSelectedNodes(); }; #endif // TIKZSCENE_H diff --git a/src/gui/undocommands.cpp b/src/gui/undocommands.cpp index 6d3162c..daa2fee 100644 --- a/src/gui/undocommands.cpp +++ b/src/gui/undocommands.cpp @@ -279,7 +279,7 @@ void ApplyStyleToNodesCommand::redo() PasteCommand::PasteCommand(TikzScene *scene, Graph *graph, QUndoCommand *parent) : GraphUpdateCommand(scene, parent), _graph(graph) { - _oldSelection = scene->selectedItems(); + scene->getSelection(_oldSelectedNodes, _oldSelectedEdges); } void PasteCommand::undo() @@ -304,7 +304,8 @@ void PasteCommand::undo() _scene->graph()->removeNode(n); } - foreach (auto it, _oldSelection) it->setSelected(true); + foreach(Node *n, _oldSelectedNodes) _scene->nodeItems()[n]->setSelected(true); + foreach(Edge *e, _oldSelectedEdges) _scene->edgeItems()[e]->setSelected(true); GraphUpdateCommand::undo(); } diff --git a/src/gui/undocommands.h b/src/gui/undocommands.h index a0abb26..3f74afb 100644 --- a/src/gui/undocommands.h +++ b/src/gui/undocommands.h @@ -13,6 +13,7 @@ #include "tikzscene.h" #include <QUndoCommand> +#include <QSet> class GraphUpdateCommand : public QUndoCommand { public: @@ -127,7 +128,8 @@ public: void redo() override; private: Graph *_graph; - QList<QGraphicsItem*> _oldSelection; + QSet<Node*> _oldSelectedNodes; + QSet<Edge*> _oldSelectedEdges; }; class ChangeLabelCommand : public GraphUpdateCommand |