mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: clearing dive data should clear undo stack
If we clear out our dive data, we also need to clear out the undo stack because it otherwise will refer to dives that no longer exist. The cleanest way to do that would be to do it in the same function used to clear the dive data. Which causes us to call C++ code from C code and really is a bit of a mess with a circular dependency between our libraries. But this does seem better than relying on people to remember to call into a second function after clearing the data. Suggested-by: Michael Andreen <michael@andreen.dev> Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f1c1e0ccee
commit
ae12000063
3 changed files with 16 additions and 1 deletions
|
|
@ -23,6 +23,9 @@ void init()
|
|||
|
||||
void clear()
|
||||
{
|
||||
// this can get called from C code even if the Command code was never initialized
|
||||
// (really only in the case of tests like TestParse)
|
||||
if (undoStack)
|
||||
undoStack->clear();
|
||||
}
|
||||
|
||||
|
|
@ -113,3 +116,9 @@ bool placingCommand()
|
|||
}
|
||||
|
||||
} // namespace Command
|
||||
|
||||
extern "C" {
|
||||
void command_clear_from_C() {
|
||||
Command::clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "trip.h"
|
||||
|
||||
bool autogroup = false;
|
||||
extern void command_clear_from_C();
|
||||
|
||||
void set_autogroup(bool value)
|
||||
{
|
||||
|
|
@ -1391,6 +1392,7 @@ void clear_dive_file_data()
|
|||
clear_git_id();
|
||||
|
||||
reset_tank_info_table(&tank_info_table);
|
||||
command_clear_from_C();
|
||||
|
||||
/* Inform frontend of reset data. This should reset all the models. */
|
||||
emit_reset_signal();
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ function(TEST NAME FILE)
|
|||
subsurface_backend_shared
|
||||
${TEST_SPECIFIC_LIBRARIES}
|
||||
subsurface_corelib
|
||||
subsurface_commands
|
||||
subsurface_corelib # annoying circular references
|
||||
RESOURCE_LIBRARY
|
||||
${QT_TEST_LIBRARIES}
|
||||
${SUBSURFACE_LINK_LIBRARIES}
|
||||
|
|
@ -99,6 +101,8 @@ add_executable(TestQML testqml.cpp)
|
|||
target_link_libraries(
|
||||
TestQML
|
||||
subsurface_corelib
|
||||
subsurface_commands
|
||||
subsurface_corelib # annoying circular references
|
||||
RESOURCE_LIBRARY
|
||||
${QT_TEST_LIBRARIES}
|
||||
${SUBSURFACE_LINK_LIBRARIES}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue