From 04227f5a418e8855de1ef3a0280cab4b617f0770 Mon Sep 17 00:00:00 2001
From: Chocobo1
Date: Wed, 16 Jan 2019 12:52:41 +0800
Subject: [PATCH] Add QBT_APP_64BIT define
Now we use QT_POINTER_SIZE to detect CPU bitness, it has the advantage of applicable to all CPU
architectures not limiting to x86 arch.
---
src/app/stacktracedialog.h | 23 ++++++++++-------------
src/base/bittorrent/session.cpp | 4 ++--
src/base/global.h | 4 ++++
src/gui/aboutdialog.h | 6 +-----
src/gui/advancedsettings.cpp | 4 ++--
5 files changed, 19 insertions(+), 22 deletions(-)
diff --git a/src/app/stacktracedialog.h b/src/app/stacktracedialog.h
index 3265df657..cf40e73f0 100644
--- a/src/app/stacktracedialog.h
+++ b/src/app/stacktracedialog.h
@@ -50,7 +50,7 @@ public:
void setStacktraceString(const QString &sigName, const QString &trace)
{
// try to call Qt function as less as possible
- QString htmlStr = QString(
+ const QString htmlStr = QString(
""
"qBittorrent has crashed"
"
"
@@ -61,21 +61,18 @@ public:
"
"
"
"
""
-#if defined(__x86_64__) || defined(_M_X64)
- "qBittorrent version: " QBT_VERSION " (64-bit)
"
-#else
- "qBittorrent version: " QBT_VERSION " (32-bit)
"
-#endif
- "Libtorrent version: %1
"
+ "qBittorrent version: " QBT_VERSION " (%1-bit)
"
+ "Libtorrent version: %2
"
"Qt version: " QT_VERSION_STR "
"
- "Boost version: %2
"
- "OpenSSL version: %3
"
- "OS version: %4
"
- "Caught signal: %5"
+ "Boost version: %3
"
+ "OpenSSL version: %4
"
+ "OS version: %5
"
+ "Caught signal: %6"
"
"
- "%6
"
+ "%7
"
"
")
- .arg(Utils::Misc::libtorrentVersionString()
+ .arg(QString::number(QT_POINTER_SIZE * 8)
+ , Utils::Misc::libtorrentVersionString()
, Utils::Misc::boostVersionString()
, Utils::Misc::opensslVersionString()
, Utils::Misc::osName()
diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp
index b3296faad..4799be686 100644
--- a/src/base/bittorrent/session.cpp
+++ b/src/base/bittorrent/session.cpp
@@ -2777,7 +2777,7 @@ int Session::diskCacheSize() const
{
int size = m_diskCacheSize;
// These macros may not be available on compilers other than MSVC and GCC
-#if defined(__x86_64__) || defined(_M_X64)
+#ifdef QBT_APP_64BIT
size = qMin(size, 4096); // 4GiB
#else
// When build as 32bit binary, set the maximum at less than 2GB to prevent crashes
@@ -2789,7 +2789,7 @@ int Session::diskCacheSize() const
void Session::setDiskCacheSize(int size)
{
-#if defined(__x86_64__) || defined(_M_X64)
+#ifdef QBT_APP_64BIT
size = qMin(size, 4096); // 4GiB
#else
// allocate 1536MiB and leave 512MiB to the rest of program data in RAM
diff --git a/src/base/global.h b/src/base/global.h
index 6e0e0370d..d5c5e2298 100644
--- a/src/base/global.h
+++ b/src/base/global.h
@@ -31,6 +31,10 @@
#include
#include
+#if (QT_POINTER_SIZE == 8)
+#define QBT_APP_64BIT
+#endif
+
const char C_TORRENT_FILE_EXTENSION[] = ".torrent";
template
diff --git a/src/gui/aboutdialog.h b/src/gui/aboutdialog.h
index 487f682e9..0881dfa0e 100644
--- a/src/gui/aboutdialog.h
+++ b/src/gui/aboutdialog.h
@@ -48,11 +48,7 @@ public:
setAttribute(Qt::WA_DeleteOnClose);
// Title
-#if defined(__x86_64__) || defined(_M_X64)
- labelName->setText("qBittorrent " QBT_VERSION " (64-bit)
");
-#else
- labelName->setText("qBittorrent " QBT_VERSION " (32-bit)
");
-#endif
+ labelName->setText(QString("qBittorrent " QBT_VERSION " (%1-bit)
").arg(QT_POINTER_SIZE * 8));
logo->setPixmap(Utils::Gui::scaledPixmapSvg(":/icons/skin/qbittorrent-tray.svg", this, 32));
diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp
index 36fcb16e6..b66f2ed39 100644
--- a/src/gui/advancedsettings.cpp
+++ b/src/gui/advancedsettings.cpp
@@ -325,7 +325,7 @@ void AdvancedSettings::loadAdvancedSettings()
// Checking Memory Usage
spinBoxCheckingMemUsage.setMinimum(1);
// When build as 32bit binary, set the maximum value lower to prevent crashes.
-#if (QT_POINTER_SIZE == 8)
+#ifdef QBT_APP_64BIT
spinBoxCheckingMemUsage.setMaximum(1024);
#else
// Allocate at most 128MiB out of the remaining 512MiB (see the cache part below)
@@ -339,7 +339,7 @@ void AdvancedSettings::loadAdvancedSettings()
spinBoxCache.setMinimum(-1);
// When build as 32bit binary, set the maximum at less than 2GB to prevent crashes.
// These macros may not be available on compilers other than MSVC and GCC
-#if defined(__x86_64__) || defined(_M_X64)
+#ifdef QBT_APP_64BIT
spinBoxCache.setMaximum(4096);
#else
// allocate 1536MiB and leave 512MiB to the rest of program data in RAM