Skip to content

Commit 1cc4de2

Browse files
Make Program Updater choose the same build for download
We're probably stuck offering the duo of RC_1_2 and RC_2_0 for some time in the future. So hardcode the choices and make the Program Updater choose the variant the user currently uses.
1 parent 9a9c375 commit 1cc4de2

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

src/gui/programupdater.cpp

+21-7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
#include "programupdater.h"
3131

32+
#include <libtorrent/version.hpp>
33+
34+
#include <QtCore/qconfig.h>
3235
#include <QtSystemDetection>
3336
#include <QDebug>
3437
#include <QDesktopServices>
@@ -61,6 +64,22 @@ namespace
6164
}
6265
return (newVersion > currentVersion);
6366
}
67+
68+
QString buildVariant()
69+
{
70+
#if defined(Q_OS_MACOS)
71+
const auto BASE_OS = u"Mac OS X"_s;
72+
#elif defined(Q_OS_WIN)
73+
const auto BASE_OS = u"Windows x64"_s;
74+
#endif
75+
76+
if constexpr ((QT_VERSION_MAJOR == 6) && (LIBTORRENT_VERSION_MAJOR == 1))
77+
return BASE_OS;
78+
else
79+
return u"%1 (qt%2 lt%3%4)"_s.arg(BASE_OS, QString::number(QT_VERSION_MAJOR), QString::number(LIBTORRENT_VERSION_MAJOR), QString::number(LIBTORRENT_VERSION_MINOR));
80+
81+
return {};
82+
}
6483
}
6584

6685
void ProgramUpdater::checkForUpdates() const
@@ -97,12 +116,7 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
97116
: QString {};
98117
};
99118

100-
#ifdef Q_OS_MACOS
101-
const QString OS_TYPE = u"Mac OS X"_s;
102-
#elif defined(Q_OS_WIN)
103-
const QString OS_TYPE = u"Windows x64"_s;
104-
#endif
105-
119+
const QString variant = buildVariant();
106120
bool inItem = false;
107121
QString version;
108122
QString updateLink;
@@ -128,7 +142,7 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
128142
{
129143
if (inItem && (xml.name() == u"item"))
130144
{
131-
if (type.compare(OS_TYPE, Qt::CaseInsensitive) == 0)
145+
if (type.compare(variant, Qt::CaseInsensitive) == 0)
132146
{
133147
qDebug("The last update available is %s", qUtf8Printable(version));
134148
if (!version.isEmpty())

0 commit comments

Comments
 (0)