From f27d440bb39be201451d6066401e7c993c8223fa Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 31 Aug 2019 15:05:11 +0200 Subject: Dive site: don't emit divesChanged signals when editing dive site When editing the dive site, for certain fields a divesChanged signal was emitted so that the dive-list can be updated. Arguably it is wrong to decide which fields are relevant to the dive list in the undo-command code. Therefore, let the list catch the dive-site-edited signal and decide itself. But the actual reason for this commit is that if the dive-site field of a dive changes, we might have to reload the dive-location-model because suddenly a new dive site appears. Now if this is done in QML context on some Qt version (notably 5.9) we get crashes later on. But that can happen if the user moves a flag. So in that case only send a diveSiteChanged signal. Signed-off-by: Berthold Stoeger --- desktop-widgets/command_divesite.cpp | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/command_divesite.cpp b/desktop-widgets/command_divesite.cpp index 8c31959eb..3ef4231f8 100644 --- a/desktop-widgets/command_divesite.cpp +++ b/desktop-widgets/command_divesite.cpp @@ -186,19 +186,6 @@ static void swap(char *&c, QString &q) q = s; } -// Helper function: collect the dives that are at the given dive site -static QVector getDivesForSite(struct dive_site *ds) -{ - QVector diveSiteDives; - diveSiteDives.reserve(ds->dives.nr); - - for (int i = 0; i < ds->dives.nr; ++i) - diveSiteDives.push_back(ds->dives.dives[i]); - - return diveSiteDives; -} - - EditDiveSiteName::EditDiveSiteName(dive_site *dsIn, const QString &name) : ds(dsIn), value(name) { @@ -214,7 +201,6 @@ void EditDiveSiteName::redo() { swap(ds->name, value); emit diveListNotifier.diveSiteChanged(ds, LocationInformationModel::NAME); // Inform frontend of changed dive site. - emit diveListNotifier.divesChanged(getDivesForSite(ds), DiveField::DIVESITE); // dive site name can be shown in the dive list } void EditDiveSiteName::undo() @@ -286,8 +272,6 @@ void EditDiveSiteCountry::redo() taxonomy_set_country(&ds->taxonomy, copy_qstring(value), taxonomy_origin::GEOMANUAL); value = old; emit diveListNotifier.diveSiteChanged(ds, LocationInformationModel::TAXONOMY); // Inform frontend of changed dive site. - emit diveListNotifier.divesChanged(getDivesForSite(ds), DiveField::DIVESITE); // Country can be shown in the dive list - } void EditDiveSiteCountry::undo() @@ -315,7 +299,6 @@ void EditDiveSiteLocation::redo() { std::swap(value, ds->location); emit diveListNotifier.diveSiteChanged(ds, LocationInformationModel::LOCATION); // Inform frontend of changed dive site. - emit diveListNotifier.divesChanged(getDivesForSite(ds), DiveField::DIVESITE); // the globe icon in the dive list shows whether we have coordinates } void EditDiveSiteLocation::undo() -- cgit v1.2.3-70-g09d2