Skip to content

Commit 0506449

Browse files
Merge pull request #34570 from RomanPudashkin/crash_on_close_score_with_selected_chord_symbol_47
[4.7.5] Fix #34566: Crash when closing score with selected chord symbol
2 parents 99709d9 + 32796f1 commit 0506449

5 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎src/inspector/qml/MuseScore/Inspector/abstractinspectormodel.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,11 @@ void AbstractInspectorModel::requestElements()
540540
}
541541
}
542542

543+
void AbstractInspectorModel::disconnectAll()
544+
{
545+
async_disconnectAll();
546+
}
547+
543548
void AbstractInspectorModel::onCurrentNotationChanged()
544549
{
545550
}

‎src/inspector/qml/MuseScore/Inspector/abstractinspectormodel.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ class AbstractInspectorModel : public QObject, public muse::async::Asyncable, pu
185185

186186
virtual void requestElements();
187187

188+
virtual void disconnectAll();
189+
188190
virtual void onCurrentNotationChanged();
189191

190192
virtual void onNotationChanged(const mu::engraving::PropertyIdSet& changedPropertyIdSet,

‎src/inspector/qml/MuseScore/Inspector/abstractinspectorproxymodel.cpp‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ void AbstractInspectorProxyModel::requestResetToDefaults()
9191
}
9292
}
9393

94+
void AbstractInspectorProxyModel::disconnectAll()
95+
{
96+
for (AbstractInspectorModel* model : modelList()) {
97+
model->disconnectAll();
98+
}
99+
100+
AbstractInspectorModel::disconnectAll();
101+
}
102+
94103
bool AbstractInspectorProxyModel::isEmpty() const
95104
{
96105
for (const AbstractInspectorModel* model : modelList()) {
@@ -114,7 +123,10 @@ void AbstractInspectorProxyModel::setModels(const QList<AbstractInspectorModel*>
114123
auto oldModel = m_models.take(model->modelType());
115124

116125
//! NOTE: may run synchronously from a model's own property-change callback;
117-
//! deleting immediately would destroy "this" mid-call, so defer it
126+
//! deleting immediately would destroy "this" mid-call, so defer it.
127+
//! Disconnect now so it (and its submodels) doesn't react to further updates
128+
//! while it awaits destruction
129+
oldModel->disconnectAll();
118130
oldModel->deleteLater();
119131
}
120132

‎src/inspector/qml/MuseScore/Inspector/abstractinspectorproxymodel.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class AbstractInspectorProxyModel : public AbstractInspectorModel
6161

6262
void requestElements() override;
6363
void requestResetToDefaults() override;
64+
void disconnectAll() override;
6465
bool isEmpty() const override;
6566

6667
void updateModels(const ElementKeySet& newElementKeySet);

‎src/inspector/qml/MuseScore/Inspector/inspectorlistmodel.cpp‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ void InspectorListModel::removeUnusedModels(const ElementKeySet& newElementKeySe
285285
m_modelList.removeAt(index);
286286

287287
//! NOTE: may run synchronously from a model's own property-change callback;
288-
//! deleting immediately would destroy "this" mid-call, so defer it
288+
//! deleting immediately would destroy "this" mid-call, so defer it.
289+
//! Disconnect now so it (and its submodels) doesn't react to further updates
290+
//! while it awaits destruction
291+
model->disconnectAll();
289292
model->deleteLater();
290293

291294
endRemoveRows();

0 commit comments

Comments
 (0)