Commit 2ab4c2f1 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Gracefully replace outputModel

This patch has it signal the disappearance of the outputModel and only then deletes it.
This gives the QML side of things a chance to clean up, specifically QQuickComboBox stores the model in a QVariant
and crashes if you just delete its backing model and then assign a new one.
Ideally the model instance itself would never be replaced but just reset and populated with new outputs.

Differential Revision: https://phabricator.kde.org/D24735
parent 7811411c
......@@ -265,6 +265,16 @@ void KCMKScreen::load()
}
fetchGlobalScale();
// Don't pull away the outputModel under QML's feet
// signal its disappearance first before deleting and replacing it.
// We take the m_config pointer so outputModel() will return null,
// gracefully cleaning up the QML side and only then we will delete it.
auto *oldConfig = m_config.release();
if (oldConfig) {
emit outputModelChanged();
delete oldConfig;
}
m_config.reset(new ConfigHandler(this));
Q_EMIT perOutputScalingChanged();
connect (m_config.get(), &ConfigHandler::outputModelChanged,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment