|
|
@ -46,7 +46,7 @@ |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#include <QCoreApplication> |
|
|
|
#include <QCoreApplication> |
|
|
|
#include <QDebug> |
|
|
|
#include <QString> |
|
|
|
#include <QThread> |
|
|
|
#include <QThread> |
|
|
|
|
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
#ifndef DISABLE_GUI |
|
|
@ -86,6 +86,7 @@ using namespace std::chrono_literals; |
|
|
|
void displayVersion(); |
|
|
|
void displayVersion(); |
|
|
|
bool userAgreesWithLegalNotice(); |
|
|
|
bool userAgreesWithLegalNotice(); |
|
|
|
void displayBadArgMessage(const QString &message); |
|
|
|
void displayBadArgMessage(const QString &message); |
|
|
|
|
|
|
|
void displayErrorMessage(const QString &message); |
|
|
|
|
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
#ifndef DISABLE_GUI |
|
|
|
void showSplashScreen(); |
|
|
|
void showSplashScreen(); |
|
|
@ -105,10 +106,12 @@ int main(int argc, char *argv[]) |
|
|
|
// We must save it here because QApplication constructor may change it
|
|
|
|
// We must save it here because QApplication constructor may change it
|
|
|
|
bool isOneArg = (argc == 2); |
|
|
|
bool isOneArg = (argc == 2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// `app` must be declared out of try block to allow display message box in case of exception
|
|
|
|
|
|
|
|
std::unique_ptr<Application> app; |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Create Application
|
|
|
|
// Create Application
|
|
|
|
auto app = std::make_unique<Application>(argc, argv); |
|
|
|
app = std::make_unique<Application>(argc, argv); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN |
|
|
|
#ifdef Q_OS_WIN |
|
|
|
// QCoreApplication::applicationDirPath() needs an Application object instantiated first
|
|
|
|
// QCoreApplication::applicationDirPath() needs an Application object instantiated first
|
|
|
@ -255,7 +258,7 @@ int main(int argc, char *argv[]) |
|
|
|
} |
|
|
|
} |
|
|
|
catch (const RuntimeError &er) |
|
|
|
catch (const RuntimeError &er) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qDebug() << er.message(); |
|
|
|
displayErrorMessage(er.message()); |
|
|
|
return EXIT_FAILURE; |
|
|
|
return EXIT_FAILURE; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -298,6 +301,30 @@ void displayBadArgMessage(const QString &message) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void displayErrorMessage(const QString &message) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
|
|
|
|
if (QApplication::instance()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QMessageBox msgBox; |
|
|
|
|
|
|
|
msgBox.setIcon(QMessageBox::Critical); |
|
|
|
|
|
|
|
msgBox.setText(QCoreApplication::translate("Main", "An unrecoverable error occurred.")); |
|
|
|
|
|
|
|
msgBox.setInformativeText(message); |
|
|
|
|
|
|
|
msgBox.show(); // Need to be shown or to moveToCenter does not work
|
|
|
|
|
|
|
|
msgBox.move(Utils::Gui::screenCenter(&msgBox)); |
|
|
|
|
|
|
|
msgBox.exec(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const QString errMsg = QCoreApplication::translate("Main", "qBittorrent has encountered an unrecoverable error.") + u'\n' + message + u'\n'; |
|
|
|
|
|
|
|
fprintf(stderr, "%s", qUtf8Printable(errMsg)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
const QString errMsg = QCoreApplication::translate("Main", "qBittorrent has encountered an unrecoverable error.") + u'\n' + message + u'\n'; |
|
|
|
|
|
|
|
fprintf(stderr, "%s", qUtf8Printable(errMsg)); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool userAgreesWithLegalNotice() |
|
|
|
bool userAgreesWithLegalNotice() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Preferences *const pref = Preferences::instance(); |
|
|
|
Preferences *const pref = Preferences::instance(); |
|
|
|