Skip to content

Commit e1492ca

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 e1492ca

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/gui/programupdater.cpp

+19-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,20 @@ 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+
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+
}
6481
}
6582

6683
void ProgramUpdater::checkForUpdates() const
@@ -97,12 +114,7 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
97114
: QString {};
98115
};
99116

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-
117+
const QString variant = buildVariant();
106118
bool inItem = false;
107119
QString version;
108120
QString updateLink;
@@ -128,7 +140,7 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
128140
{
129141
if (inItem && (xml.name() == u"item"))
130142
{
131-
if (type.compare(OS_TYPE, Qt::CaseInsensitive) == 0)
143+
if (type.compare(variant, Qt::CaseInsensitive) == 0)
132144
{
133145
qDebug("The last update available is %s", qUtf8Printable(version));
134146
if (!version.isEmpty())

0 commit comments

Comments
 (0)