logic: Fixed update check still displaying new version after using new version
This commit is contained in:
@@ -86,7 +86,8 @@
|
||||
<automatic><!-- BOOL: whether to check automatically for new software updates --></automatic>
|
||||
<time_stamp><!-- TIME: time of the last update check --></time_stamp>
|
||||
<skip_version><!-- VERSION: version to skip for update --></skip_version>
|
||||
<url><!-- STRING: url to new version download --></url>
|
||||
<update_url><!-- STRING: url to new version download --></update_url>
|
||||
<update_version><!-- VERSION: version of last check --></update_version>
|
||||
</update_check>
|
||||
</user>
|
||||
|
||||
|
||||
@@ -429,12 +429,18 @@ void ApplicationSettings::setAutomaticUpdateCheck(bool automaticUpdates)
|
||||
|
||||
TimeStamp ApplicationSettings::getLastUpdateCheck() const
|
||||
{
|
||||
return TimeStamp(getValue<std::string>("user/update_check/last", ""));
|
||||
std::string val = getValue<std::string>("user/update_check/time_stamp", "");
|
||||
if (!val.size())
|
||||
{
|
||||
val = getValue<std::string>("user/update_check/last", ""); // deprecated key
|
||||
}
|
||||
|
||||
return TimeStamp(val);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setLastUpdateCheck(const TimeStamp& time)
|
||||
{
|
||||
setValue<std::string>("user/update_check/last", time.toString());
|
||||
setValue<std::string>("user/update_check/time_stamp", time.toString());
|
||||
}
|
||||
|
||||
Version ApplicationSettings::getSkipUpdateForVersion() const
|
||||
@@ -452,12 +458,25 @@ void ApplicationSettings::setSkipUpdateForVersion(const Version& version)
|
||||
|
||||
std::string ApplicationSettings::getUpdateDownloadUrl() const
|
||||
{
|
||||
return getValue<std::string>("user/update_check/url", "");
|
||||
return getValue<std::string>("user/update_check/update_url", "");
|
||||
}
|
||||
|
||||
void ApplicationSettings::setUpdateDownloadUrl(const std::string& url)
|
||||
{
|
||||
setValue<std::string>("user/update_check/url", url);
|
||||
setValue<std::string>("user/update_check/update_url", url);
|
||||
}
|
||||
|
||||
Version ApplicationSettings::getUpdateVersion() const
|
||||
{
|
||||
return Version::fromString(getValue<std::string>("user/update_check/update_version", "2017.1.0"));
|
||||
}
|
||||
|
||||
void ApplicationSettings::setUpdateVersion(const Version& version)
|
||||
{
|
||||
if (version.isValid())
|
||||
{
|
||||
setValue<std::string>("user/update_check/update_version", version.toDisplayString());
|
||||
}
|
||||
}
|
||||
|
||||
int ApplicationSettings::getPluginPort() const
|
||||
|
||||
@@ -135,6 +135,9 @@ public:
|
||||
std::string getUpdateDownloadUrl() const;
|
||||
void setUpdateDownloadUrl(const std::string& url);
|
||||
|
||||
Version getUpdateVersion() const;
|
||||
void setUpdateVersion(const Version& version);
|
||||
|
||||
// network
|
||||
int getPluginPort() const;
|
||||
void setPluginPort(const int pluginPort);
|
||||
|
||||
@@ -31,8 +31,9 @@ QtUpdateCheckerWidget::QtUpdateCheckerWidget(QWidget* parent)
|
||||
}
|
||||
else
|
||||
{
|
||||
Version version = appSettings->getUpdateVersion();
|
||||
QString url = QString::fromStdString(appSettings->getUpdateDownloadUrl());
|
||||
if (!url.isEmpty())
|
||||
if (version > Version::getApplicationVersion() && !url.isEmpty())
|
||||
{
|
||||
setDownloadUrl(url);
|
||||
}
|
||||
@@ -52,6 +53,7 @@ QtUpdateCheckerWidget::QtUpdateCheckerWidget(QWidget* parent)
|
||||
void QtUpdateCheckerWidget::checkUpdate(bool force)
|
||||
{
|
||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||
appSettings->setUpdateVersion(Version::getApplicationVersion());
|
||||
appSettings->setUpdateDownloadUrl("");
|
||||
appSettings->save();
|
||||
|
||||
@@ -73,6 +75,7 @@ void QtUpdateCheckerWidget::checkUpdate(bool force)
|
||||
{
|
||||
setDownloadUrl(result.url);
|
||||
|
||||
appSettings->setUpdateVersion(result.version);
|
||||
appSettings->setUpdateDownloadUrl(result.url.toStdString());
|
||||
appSettings->save();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ void QtUpdateChecker::check(bool force, std::function<void(Result)> callback)
|
||||
urlString += ("&platform=" + platformString + "bit").c_str();
|
||||
|
||||
// version
|
||||
// Version::setApplicationVersion(Version::fromString("2017.3.10")); // for debugging
|
||||
// Version::setApplicationVersion(Version::fromString("2017.3.48")); // for debugging
|
||||
urlString += ("&version=" + Version::getApplicationVersion().toDisplayString()).c_str();
|
||||
|
||||
// license
|
||||
@@ -126,6 +126,7 @@ void QtUpdateChecker::check(bool force, std::function<void(Result)> callback)
|
||||
|
||||
if (updateVersion > Version::getApplicationVersion())
|
||||
{
|
||||
result.version = updateVersion;
|
||||
result.url = url;
|
||||
|
||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
#include "UpdateChecker.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
class QtUpdateChecker
|
||||
: public UpdateChecker
|
||||
@@ -11,6 +12,7 @@ public:
|
||||
struct Result
|
||||
{
|
||||
bool success = false;
|
||||
Version version;
|
||||
QString url;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user