Skip to content

Commit 1ca6db0

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 1ca6db0

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

src/gui/programupdater.cpp

+35-2
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"
@@ -98,11 +101,41 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
98101
};
99102

100103
#ifdef Q_OS_MACOS
101-
const QString OS_TYPE = u"Mac OS X"_s;
104+
#define BASE_OS "Mac OS X"
102105
#elif defined(Q_OS_WIN)
103-
const QString OS_TYPE = u"Windows x64"_s;
106+
#define BASE_OS "Windows x64"
107+
#endif
108+
109+
#define CONCAT_(a, b) a ## b
110+
#define CONCAT(a, b) CONCAT_(a, b)
111+
#define STRINGIFY(s) #s
112+
113+
#if (QT_VERSION_MAJOR == 6) && (LIBTORRENT_VERSION_MAJOR == 1)
114+
#define _TYPE() BASE_OS
115+
#define TYPE CONCAT(u, _TYPE())
116+
117+
#elif (QT_VERSION_MAJOR == 6) && (LIBTORRENT_VERSION_MAJOR > 1)
118+
#define _TYPE(lt_major, lt_minor) BASE_OS " (lt" STRINGIFY(lt_major) STRINGIFY(lt_minor) ")"
119+
#define TYPE CONCAT(u, _TYPE(LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR))
120+
121+
#elif (QT_VERSION_MAJOR > 6)
122+
#define _TYPE(qt_major, lt_major, lt_minor) BASE_OS " (qt" STRINGIFY(qt_major) " lt" STRINGIFY(lt_major) STRINGIFY(lt_minor) ")"
123+
#define TYPE CONCAT(u, _TYPE(QT_VERSION_MAJOR, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR))
124+
125+
#else
126+
#error "OS_TYPE is undefined for the current Qt/libtorrent combination"
104127
#endif
105128

129+
const QString OS_TYPE = TYPE""_s;
130+
131+
#undef TYPE
132+
#undef _TYPE
133+
#undef STRINGIFY
134+
#undef CONCAT
135+
#undef CONCAT_
136+
#undef BASE_OS
137+
138+
106139
bool inItem = false;
107140
QString version;
108141
QString updateLink;

0 commit comments

Comments
 (0)