Merge pull request #10155 from Chocobo1/exception

Remove exception handling
This commit is contained in:
Mike Tzou 2019-01-23 13:44:34 +08:00 committed by GitHub
commit fc534e88a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 45 deletions

View file

@ -29,19 +29,20 @@
#include "application.h"
#include <QtGlobal>
#include <algorithm>
#ifdef Q_OS_WIN
#include <memory>
#include <Windows.h>
#include <Shellapi.h>
#endif
#include <QAtomicInt>
#include <QDebug>
#include <QLibraryInfo>
#include <QLocale>
#include <QProcess>
#include <QSysInfo>
#ifdef Q_OS_WIN
#include <memory>
#include <Shellapi.h>
#endif
#ifndef DISABLE_GUI
#include <QMessageBox>
@ -615,19 +616,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()

View file

@ -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
@ -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 &params);
@ -110,7 +110,6 @@ protected:
#ifdef Q_OS_MAC
bool event(QEvent *) override;
#endif
bool notify(QObject *receiver, QEvent *event) override;
#endif
private slots:

View file

@ -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(
"<p align=center><b><font size=7 color=red>"
"qBittorrent has crashed"
"</font></b></p>"
@ -61,21 +61,18 @@ public:
"</p></font>"
"<br/><hr><br/>"
"<p align=center><font size=4>"
#if defined(__x86_64__) || defined(_M_X64)
"qBittorrent version: " QBT_VERSION " (64-bit)<br/>"
#else
"qBittorrent version: " QBT_VERSION " (32-bit)<br/>"
#endif
"Libtorrent version: %1<br/>"
"qBittorrent version: " QBT_VERSION " (%1-bit)<br/>"
"Libtorrent version: %2<br/>"
"Qt version: " QT_VERSION_STR "<br/>"
"Boost version: %2<br/>"
"OpenSSL version: %3<br/>"
"OS version: %4<br/><br/>"
"Caught signal: %5"
"Boost version: %3<br/>"
"OpenSSL version: %4<br/>"
"OS version: %5<br/><br/>"
"Caught signal: %6"
"</font></p>"
"<pre><code>%6</code></pre>"
"<pre><code>%7</code></pre>"
"<br/><hr><br/><br/>")
.arg(Utils::Misc::libtorrentVersionString()
.arg(QString::number(QT_POINTER_SIZE * 8)
, Utils::Misc::libtorrentVersionString()
, Utils::Misc::boostVersionString()
, Utils::Misc::opensslVersionString()
, Utils::Misc::osName()

View file

@ -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

View file

@ -31,6 +31,10 @@
#include <type_traits>
#include <QtGlobal>
#if (QT_POINTER_SIZE == 8)
#define QBT_APP_64BIT
#endif
const char C_TORRENT_FILE_EXTENSION[] = ".torrent";
template <typename T>

View file

@ -48,11 +48,7 @@ public:
setAttribute(Qt::WA_DeleteOnClose);
// Title
#if defined(__x86_64__) || defined(_M_X64)
labelName->setText("<b><h2>qBittorrent " QBT_VERSION " (64-bit)</h2></b>");
#else
labelName->setText("<b><h2>qBittorrent " QBT_VERSION " (32-bit)</h2></b>");
#endif
labelName->setText(QString("<b><h2>qBittorrent " QBT_VERSION " (%1-bit)</h2></b>").arg(QT_POINTER_SIZE * 8));
logo->setPixmap(Utils::Gui::scaledPixmapSvg(":/icons/skin/qbittorrent-tray.svg", this, 32));

View file

@ -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