mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
codeql: fixed warnings
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
37590c8ffe
commit
47f4b85435
1 changed files with 19 additions and 13 deletions
|
|
@ -44,29 +44,30 @@ class PrismExternalUpdater::Private {
|
|||
QDir appDir;
|
||||
QDir dataDir;
|
||||
QTimer updateTimer;
|
||||
bool allowBeta;
|
||||
bool autoCheck;
|
||||
double updateInterval;
|
||||
bool allowBeta{};
|
||||
bool autoCheck{};
|
||||
double updateInterval{};
|
||||
QDateTime lastCheck;
|
||||
std::unique_ptr<QSettings> settings;
|
||||
|
||||
QWidget* parent;
|
||||
QWidget* parent{};
|
||||
};
|
||||
|
||||
PrismExternalUpdater::PrismExternalUpdater(QWidget* parent, const QString& appDir, const QString& dataDir)
|
||||
: priv(new PrismExternalUpdater::Private())
|
||||
{
|
||||
priv = new PrismExternalUpdater::Private();
|
||||
priv->appDir = QDir(appDir);
|
||||
priv->dataDir = QDir(dataDir);
|
||||
auto settings_file = priv->dataDir.absoluteFilePath("prismlauncher_update.cfg");
|
||||
priv->settings = std::make_unique<QSettings>(settings_file, QSettings::Format::IniFormat);
|
||||
priv->allowBeta = priv->settings->value("allow_beta", false).toBool();
|
||||
priv->autoCheck = priv->settings->value("auto_check", false).toBool();
|
||||
bool interval_ok;
|
||||
bool interval_ok = false;
|
||||
// default once per day
|
||||
priv->updateInterval = priv->settings->value("update_interval", 86400).toInt(&interval_ok);
|
||||
if (!interval_ok)
|
||||
if (!interval_ok) {
|
||||
priv->updateInterval = 86400;
|
||||
}
|
||||
auto last_check = priv->settings->value("last_check");
|
||||
if (!last_check.isNull() && last_check.isValid()) {
|
||||
priv->lastCheck = QDateTime::fromString(last_check.toString(), Qt::ISODate);
|
||||
|
|
@ -74,15 +75,16 @@ PrismExternalUpdater::PrismExternalUpdater(QWidget* parent, const QString& appDi
|
|||
priv->parent = parent;
|
||||
connectTimer();
|
||||
resetAutoCheckTimer();
|
||||
if (priv->updateInterval == 0) { // "On Launch"
|
||||
if (priv->updateInterval == 0) { // "On Launch"
|
||||
checkForUpdates(false);
|
||||
}
|
||||
}
|
||||
|
||||
PrismExternalUpdater::~PrismExternalUpdater()
|
||||
{
|
||||
if (priv->updateTimer.isActive())
|
||||
if (priv->updateTimer.isActive()) {
|
||||
priv->updateTimer.stop();
|
||||
}
|
||||
disconnectTimer();
|
||||
priv->settings->sync();
|
||||
delete priv;
|
||||
|
|
@ -116,8 +118,9 @@ void PrismExternalUpdater::checkForUpdates(bool triggeredByUser)
|
|||
#endif
|
||||
|
||||
QStringList args = { "--check-only", "--dir", priv->dataDir.absolutePath(), "--debug" };
|
||||
if (priv->allowBeta)
|
||||
if (priv->allowBeta) {
|
||||
args.append("--pre-release");
|
||||
}
|
||||
|
||||
proc.start(priv->appDir.absoluteFilePath(exe_name), args);
|
||||
auto result_start = proc.waitForStarted(5000);
|
||||
|
|
@ -337,7 +340,7 @@ void PrismExternalUpdater::offerUpdate(const QString& version_name, const QStrin
|
|||
priv->settings->sync();
|
||||
return;
|
||||
}
|
||||
case UpdateAvailableDialog::DontInstall: {
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -358,10 +361,13 @@ void PrismExternalUpdater::performUpdate(const QString& version_tag)
|
|||
#endif
|
||||
|
||||
QStringList args = { "--dir", priv->dataDir.absolutePath(), "--install-version", version_tag };
|
||||
if (priv->allowBeta)
|
||||
if (priv->allowBeta) {
|
||||
args.append("--pre-release");
|
||||
}
|
||||
|
||||
auto result = proc.startDetached(priv->appDir.absoluteFilePath(exe_name), args);
|
||||
proc.setProgram(priv->appDir.absoluteFilePath(exe_name));
|
||||
proc.setArguments(args);
|
||||
auto result = proc.startDetached();
|
||||
if (!result) {
|
||||
qDebug() << "Failed to start updater:" << proc.error() << proc.errorString();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue