Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly discard edit commands when calling QgsVectorLayer::destroyEd…
…itCommand() Since it's not directly possible to pop the last command off an QUndoStack (the command which is destroyed/discard by calling this method), we add a dummy obsolete command to force this to occur. Pushing the new command deletes the destroyed one, and since the new command is obsolete it's automatically deleted by the undo stack.
- Loading branch information
1 parent
0a269aa
commit f4d38d4
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
#include <QDomNode> | ||
#include <QVector> | ||
#include <QStringBuilder> | ||
#include <QUndoCommand> | ||
|
||
#include "qgssettings.h" | ||
#include "qgsvectorlayer.h" | ||
|
@@ -3005,6 +3006,15 @@ void QgsVectorLayer::destroyEditCommand() | |
} | ||
undoStack()->endMacro(); | ||
undoStack()->undo(); | ||
|
||
// it's not directly possible to pop the last command off the stack (the destroyed one) | ||
// and delete, so we add a dummy obsolete command to force this to occur. | ||
// Pushing the new command deletes the destroyed one, and since the new | ||
// command is obsolete it's automatically deleted by the undo stack. | ||
std::unique_ptr< QUndoCommand > command = qgis::make_unique< QUndoCommand >(); | ||
command->setObsolete( true ); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
pblottiere
Member
|
||
undoStack()->push( command.release() ); | ||
|
||
mEditCommandActive = false; | ||
mDeletedFids.clear(); | ||
emit editCommandDestroyed(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This breaks builds with Qt < 5.9.0 as
setObsolete()
was added in Qt 5.9.0. We still have minimal Qt version set to 5.2 for builds without 3D support.