From cf4db1b418a87df79a8d5eb305f06214a14581b8 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 14 Jan 2019 07:59:34 +0800 Subject: [PATCH 1/3] Remove useless exception handling --- src/app/application.cpp | 13 ------------- src/app/application.h | 3 +-- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 81d576957..8cd4459d4 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -615,19 +615,6 @@ bool Application::event(QEvent *ev) } } #endif // Q_OS_MAC - -bool Application::notify(QObject *receiver, QEvent *event) -{ - try { - return QApplication::notify(receiver, event); - } - catch (const std::exception &e) { - qCritical() << "Exception thrown:" << e.what() << ", receiver: " << receiver->objectName(); - receiver->dumpObjectInfo(); - } - - return false; -} #endif // DISABLE_GUI void Application::initializeTranslation() diff --git a/src/app/application.h b/src/app/application.h index a36d72721..19727d809 100644 --- a/src/app/application.h +++ b/src/app/application.h @@ -77,7 +77,7 @@ public: Application(const QString &id, int &argc, char **argv); ~Application() override; - #if (defined(Q_OS_WIN) && !defined(DISABLE_GUI)) +#if (defined(Q_OS_WIN) && !defined(DISABLE_GUI)) bool isRunning(); #endif int exec(const QStringList ¶ms); @@ -110,7 +110,6 @@ protected: #ifdef Q_OS_MAC bool event(QEvent *) override; #endif - bool notify(QObject *receiver, QEvent *event) override; #endif private slots: From 6d7e5f82ae02861a0e01622ff0974b127365d01a Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 14 Jan 2019 08:04:06 +0800 Subject: [PATCH 2/3] Include the correct header And remove the unused ones --- src/app/application.cpp | 15 ++++++++------- src/app/application.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 8cd4459d4..8e097c8ba 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -29,20 +29,21 @@ #include "application.h" -#include +#include -#include -#include -#include -#include -#include -#include +#include #ifdef Q_OS_WIN #include +#include #include #endif +#include +#include +#include +#include + #ifndef DISABLE_GUI #include #ifdef Q_OS_WIN diff --git a/src/app/application.h b/src/app/application.h index 19727d809..57e83e189 100644 --- a/src/app/application.h +++ b/src/app/application.h @@ -48,7 +48,7 @@ class QSessionManager; typedef QtSingleCoreApplication BaseApplication; #endif // DISABLE_GUI -#include "base/utils/misc.h" +#include "base/types.h" #include "cmdoptions.h" #ifndef DISABLE_WEBUI From 04227f5a418e8855de1ef3a0280cab4b617f0770 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 16 Jan 2019 12:52:41 +0800 Subject: [PATCH 3/3] 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