Skip to content

Commit

Permalink
Make Program Updater choose the same build for download
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sledgehammer999 committed Aug 26, 2024
1 parent 9a9c375 commit 1ca6db0
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions src/gui/programupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@

#include "programupdater.h"

#include <QtCore/qconfig.h>
#include <QtSystemDetection>
#include <QDebug>
#include <QDesktopServices>
#include <QRegularExpression>
#include <QXmlStreamReader>

#include <libtorrent/version.hpp>

#include "base/global.h"
#include "base/net/downloadmanager.h"
#include "base/preferences.h"
Expand Down Expand Up @@ -98,11 +101,41 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
};

#ifdef Q_OS_MACOS
const QString OS_TYPE = u"Mac OS X"_s;
#define BASE_OS "Mac OS X"
#elif defined(Q_OS_WIN)
const QString OS_TYPE = u"Windows x64"_s;
#define BASE_OS "Windows x64"
#endif

#define CONCAT_(a, b) a ## b
#define CONCAT(a, b) CONCAT_(a, b)
#define STRINGIFY(s) #s

#if (QT_VERSION_MAJOR == 6) && (LIBTORRENT_VERSION_MAJOR == 1)
#define _TYPE() BASE_OS
#define TYPE CONCAT(u, _TYPE())

#elif (QT_VERSION_MAJOR == 6) && (LIBTORRENT_VERSION_MAJOR > 1)
#define _TYPE(lt_major, lt_minor) BASE_OS " (lt" STRINGIFY(lt_major) STRINGIFY(lt_minor) ")"
#define TYPE CONCAT(u, _TYPE(LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR))

#elif (QT_VERSION_MAJOR > 6)
#define _TYPE(qt_major, lt_major, lt_minor) BASE_OS " (qt" STRINGIFY(qt_major) " lt" STRINGIFY(lt_major) STRINGIFY(lt_minor) ")"
#define TYPE CONCAT(u, _TYPE(QT_VERSION_MAJOR, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR))

#else
#error "OS_TYPE is undefined for the current Qt/libtorrent combination"
#endif

const QString OS_TYPE = TYPE""_s;

#undef TYPE
#undef _TYPE
#undef STRINGIFY
#undef CONCAT
#undef CONCAT_
#undef BASE_OS


bool inItem = false;
QString version;
QString updateLink;
Expand Down

0 comments on commit 1ca6db0

Please sign in to comment.