logic: Fixed crash when start screen was closed while checking for update
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -10,12 +10,15 @@ class QtUpdateCheckerWidget
|
||||
{
|
||||
public:
|
||||
QtUpdateCheckerWidget(QWidget* parent = nullptr);
|
||||
virtual ~QtUpdateCheckerWidget();
|
||||
|
||||
private:
|
||||
void checkUpdate(bool force);
|
||||
void setDownloadUrl(QString url);
|
||||
|
||||
QPushButton* m_button;
|
||||
|
||||
std::shared_ptr<bool> m_deleteCheck;
|
||||
};
|
||||
|
||||
#endif // QT_UPDATE_CHECKER_WIDGET_H
|
||||
|
||||
@@ -32,6 +32,8 @@ void QtUpdateChecker::check(bool force, std::function<void(Result)> callback)
|
||||
|
||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||
appSettings->setLastUpdateCheck(TimeStamp::now());
|
||||
appSettings->setUpdateVersion(Version::getApplicationVersion());
|
||||
appSettings->setUpdateDownloadUrl("");
|
||||
appSettings->save();
|
||||
|
||||
QString urlString = "https://www.sourcetrail.com/api/v1/versions/latest";
|
||||
@@ -128,6 +130,10 @@ void QtUpdateChecker::check(bool force, std::function<void(Result)> callback)
|
||||
result.url = url;
|
||||
|
||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||
appSettings->setUpdateVersion(updateVersion);
|
||||
appSettings->setUpdateDownloadUrl(url.toStdString());
|
||||
appSettings->save();
|
||||
|
||||
if (!force && appSettings->getSkipUpdateForVersion() == updateVersion)
|
||||
{
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user