Skip to content

Commit 1085b52

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 1085b52

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/gui/programupdater.cpp

+23-7
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@
2929

3030
#include "programupdater.h"
3131

32+
#include <QtCore/qconfig.h>
3233
#include <QtSystemDetection>
3334
#include <QDebug>
3435
#include <QDesktopServices>
3536
#include <QRegularExpression>
3637
#include <QXmlStreamReader>
3738

39+
#include <libtorrent/version.hpp>
40+
3841
#include "base/global.h"
3942
#include "base/net/downloadmanager.h"
4043
#include "base/preferences.h"
@@ -61,6 +64,24 @@ namespace
6164
}
6265
return (newVersion > currentVersion);
6366
}
67+
68+
QString buildVariant()
69+
{
70+
#if defined(Q_OS_MACOS)
71+
constexpr auto BASE_OS = "Mac OS X"_L1;
72+
#elif defined(Q_OS_WIN)
73+
constexpr auto BASE_OS = "Windows x64"_L1;
74+
#endif
75+
76+
if constexpr ((QT_VERSION_MAJOR == 6) && (LIBTORRENT_VERSION_MAJOR == 1))
77+
return BASE_OS;
78+
else if constexpr ((QT_VERSION_MAJOR == 6) && (LIBTORRENT_VERSION_MAJOR > 1))
79+
return u"%1 (lt%2%3)"_s.arg(BASE_OS).arg(LIBTORRENT_VERSION_MAJOR).arg(LIBTORRENT_VERSION_MINOR);
80+
else if constexpr (QT_VERSION_MAJOR > 6)
81+
return u"%1 (qt%2 lt%3%4)"_s.arg(BASE_OS).arg(QT_VERSION_MAJOR).arg(LIBTORRENT_VERSION_MAJOR).arg(LIBTORRENT_VERSION_MINOR);
82+
83+
return {};
84+
}
6485
}
6586

6687
void ProgramUpdater::checkForUpdates() const
@@ -97,12 +118,7 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
97118
: QString {};
98119
};
99120

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-
121+
const QString variant = buildVariant();
106122
bool inItem = false;
107123
QString version;
108124
QString updateLink;
@@ -128,7 +144,7 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
128144
{
129145
if (inItem && (xml.name() == u"item"))
130146
{
131-
if (type.compare(OS_TYPE, Qt::CaseInsensitive) == 0)
147+
if (type.compare(variant, Qt::CaseInsensitive) == 0)
132148
{
133149
qDebug("The last update available is %s", qUtf8Printable(version));
134150
if (!version.isEmpty())

0 commit comments

Comments
 (0)