Qt: Fix a rare crash when rapidly changing settings

This commit is contained in:
Connor McLaughlin 2020-08-12 02:27:06 +10:00
parent 17a1719450
commit ba5458c1c3

View file

@ -244,18 +244,14 @@ void QtHostInterface::RemoveSettingValue(const char* section, const char* key)
void QtHostInterface::queueSettingsSave()
{
if (!m_settings_save_timer)
{
if (m_settings_save_timer)
return;
m_settings_save_timer = std::make_unique<QTimer>();
connect(m_settings_save_timer.get(), &QTimer::timeout, this, &QtHostInterface::doSaveSettings);
m_settings_save_timer->setSingleShot(true);
}
else
{
m_settings_save_timer->stop();
}
m_settings_save_timer->start(SETTINGS_SAVE_DELAY);
m_settings_save_timer->moveToThread(m_worker_thread);
}
void QtHostInterface::doSaveSettings()
@ -1104,6 +1100,11 @@ void QtHostInterface::threadEntryPoint()
delete m_worker_thread_event_loop;
m_worker_thread_event_loop = nullptr;
if (m_settings_save_timer)
{
m_settings_save_timer.reset();
doSaveSettings();
}
// move back to UI thread
moveToThread(m_original_thread);