subsurface/commands
Berthold Stoeger 152e6966c9 fix copy/paste of dive-site
The copy/pasting of dive-sites was fundamentally broken in at least two
ways:

1) The dive-site pointer in struct dive was simply overwritten, which
   breaks internal consistency. Also, no dive-site changed signals where
   sent.

2) The copied dive-site was stored as a pointer in a struct dive. Thus,
   the user could copy a dive, then delete the dive-site and paste.
   This would lead to a dangling pointer and ultimately crash the
   application.

Fix this by storing the UUID of the dive-site, not a pointer.
To do that, don't store a copy of the dive, but collect all
the data in a `dive_paste_data` structure.
If the dive site has been deleted on paste, do nothing.
Send the appropriate signals on pasting.

The mobile version had an additional bug: It kept a pointer to the
dive to be copied, which might become stale by undo.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-08-17 23:34:16 +12:00
..
CMakeLists.txt undo: add device related undo commands 2020-10-25 13:59:04 -07:00
command.cpp fix copy/paste of dive-site 2024-08-17 23:34:16 +12:00
command.h fix copy/paste of dive-site 2024-08-17 23:34:16 +12:00
command_base.cpp core: turn C dive-table into an owning table 2024-08-13 19:28:30 +02:00
command_base.h core: turn dive-trip location and notes into std::string 2024-08-13 19:28:30 +02:00
command_device.cpp core: remove device C access code 2024-08-13 19:28:30 +02:00
command_device.h undo/device: adjust device management infrastructure 2021-08-18 13:22:02 -07:00
command_divelist.cpp core: move number_of_divecomputers to struct dive 2024-08-13 19:28:30 +02:00
command_divelist.h undo: pass dive as unique_ptr to addDive() 2024-08-13 19:28:30 +02:00
command_divesite.cpp core: include divesite table directly in divelog 2024-08-13 19:28:30 +02:00
command_divesite.h core: replace divesite_table_t by a vector of std::unique_ptr<>s 2024-08-13 19:28:30 +02:00
command_edit.cpp fix copy/paste of dive-site 2024-08-17 23:34:16 +12:00
command_edit.h fix copy/paste of dive-site 2024-08-17 23:34:16 +12:00
command_edit_trip.cpp core: turn dive-trip location and notes into std::string 2024-08-13 19:28:30 +02:00
command_edit_trip.h core: turn dive-trip location and notes into std::string 2024-08-13 19:28:30 +02:00
command_event.cpp core: move get_dive_dc() to struct dive 2024-08-13 19:28:30 +02:00
command_event.h core: turn event-list of divecomputer into std::vector<> 2024-08-13 19:28:30 +02:00
command_filter.cpp core: remove filterconstraint C boilerplate code 2024-08-13 19:28:30 +02:00
command_filter.h core: port filterpreset.cpp to std::string 2024-03-10 11:01:42 +13:00
command_pictures.cpp core: move divesite_has_gps_information() to struct dive_site 2024-08-13 19:28:30 +02:00
command_pictures.h core: convert taxonomy.c to C++ 2024-08-13 19:28:30 +02:00