summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop-widgets/command.cpp5
-rw-r--r--desktop-widgets/command_base.cpp9
-rw-r--r--desktop-widgets/command_base.h4
3 files changed, 10 insertions, 8 deletions
diff --git a/desktop-widgets/command.cpp b/desktop-widgets/command.cpp
index 35010b3c3..78f849651 100644
--- a/desktop-widgets/command.cpp
+++ b/desktop-widgets/command.cpp
@@ -148,9 +148,8 @@ void purgeUnusedDiveSites()
// Execute an edit-command and return number of edited dives
static int execute_edit(EditDivesBase *cmd)
{
- int res = cmd->numDives();
- execute(cmd);
- return res;
+ int count = cmd->numDives();
+ return execute(cmd) ? count : 0;
}
// Dive editing related commands
diff --git a/desktop-widgets/command_base.cpp b/desktop-widgets/command_base.cpp
index 26a587f7c..9316135dd 100644
--- a/desktop-widgets/command_base.cpp
+++ b/desktop-widgets/command_base.cpp
@@ -38,12 +38,15 @@ QAction *redoAction(QObject *parent)
return undoStack.createRedoAction(parent, QCoreApplication::translate("Command", "&Redo"));
}
-void execute(Base *cmd)
+bool execute(Base *cmd)
{
- if (cmd->workToBeDone())
+ if (cmd->workToBeDone()) {
undoStack.push(cmd);
- else
+ return true;
+ } else {
delete cmd;
+ return false;
+ }
}
} // namespace Command
diff --git a/desktop-widgets/command_base.h b/desktop-widgets/command_base.h
index cf8f248d2..85ca6f8de 100644
--- a/desktop-widgets/command_base.h
+++ b/desktop-widgets/command_base.h
@@ -168,8 +168,8 @@ public:
// Put a command on the undoStack (and take ownership), but test whether there
// is something to be done beforehand by calling the workToBeDone() function.
-// If nothing is to be done, the command will be deleted.
-void execute(Base *cmd);
+// If nothing is to be done, the command will be deleted and false is returned.
+bool execute(Base *cmd);
} // namespace Command