logic: Fixed crash when start screen was closed while checking for update

This commit is contained in:
Eberhard Graether
2017-12-10 23:06:37 +01:00
parent 0dcd343026
commit 0d30132cc4
3 changed files with 27 additions and 10 deletions
@@ -58,19 +58,31 @@ QtUpdateCheckerWidget::QtUpdateCheckerWidget(QWidget* parent)
}
}
QtUpdateCheckerWidget::~QtUpdateCheckerWidget()
{
if (m_deleteCheck)
{
*m_deleteCheck.get() = true;
}
}
void QtUpdateCheckerWidget::checkUpdate(bool force)
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
appSettings->setUpdateVersion(Version::getApplicationVersion());
appSettings->setUpdateDownloadUrl("");
appSettings->save();
m_button->setText("checking for update...");
m_button->setEnabled(false);
std::shared_ptr<bool> deleteCheck = std::make_shared<bool>(false);
m_deleteCheck = deleteCheck;
QtUpdateChecker::check(force,
[this, appSettings](QtUpdateChecker::Result result)
[deleteCheck, this](QtUpdateChecker::Result result)
{
bool deleted = *deleteCheck.get();
if (deleted)
{
return;
}
if (!result.success)
{
m_button->setText("update check failed");
@@ -82,10 +94,6 @@ void QtUpdateCheckerWidget::checkUpdate(bool force)
else
{
setDownloadUrl(result.url);
appSettings->setUpdateVersion(result.version);
appSettings->setUpdateDownloadUrl(result.url.toStdString());
appSettings->save();
}
}
);