Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/main.cpp b/src/main.cpp
- index 888e6cfa4..e556e56e9 100644
- --- a/src/main.cpp
- +++ b/src/main.cpp
- @@ -40,175 +40,169 @@
- using namespace Otter;
- #if !defined(Q_OS_WIN32)
- -void otterMessageHander(QtMsgType type, const QMessageLogContext &context, const QString &message)
- -{
- - if (message.trimmed().startsWith(QLatin1String("OpenType support missing")) || message.startsWith(QLatin1String("libpng warning: iCCP:")) || message.startsWith(QLatin1String("OpenType support missing for script")) || message.startsWith(QLatin1String("QCoreApplication::postEvent: Unexpected null receiver")) || message.startsWith(QLatin1String("QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once")) || message.startsWith(QLatin1String("QBasicTimer::start: QBasicTimer can only be used with threads started with QThread")) || message.startsWith(QLatin1String("QFSFileEngine::open")) || message.contains(QLatin1String("::_q_startOperation was called more than once")))
- - {
- - return;
- - }
- -
- - fputs(qFormatLogMessage(type, context, message).toLocal8Bit().constData(), stderr);
- -
- - if (type == QtFatalMsg)
- - {
- - abort();
- - }
- +void otterMessageHander(QtMsgType type,
- + const QMessageLogContext & context,
- + const QString & message) {
- + if (message.trimmed().startsWith(QLatin1String("OpenType support missing")) || message.startsWith(QLatin1String("libpng warning: iCCP:")) || message.startsWith(QLatin1String("OpenType support missing for script")) || message.startsWith(QLatin1String("QCoreApplication::postEvent: Unexpected null receiver")) || message.startsWith(QLatin1String("QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once")) || message.startsWith(QLatin1String("QBasicTimer::start: QBasicTimer can only be used with threads started with QThread")) || message.startsWith(QLatin1String("QFSFileEngine::open")) || message.contains(QLatin1String("::_q_startOperation was called more than once"))) {
- + return;
- + }
- +
- + fputs(qFormatLogMessage(type, context, message).toLocal8Bit().constData(), stderr);
- +
- + if (type == QtFatalMsg) {
- + abort();
- + }
- }
- #endif
- -#ifdef OTTER_ENABLE_CRASHREPORTS
- -#ifdef Q_OS_WIN32
- -bool otterCrashDumpHandler(const wchar_t *dumpDirectory, const wchar_t *dumpIdentifier, void *context, EXCEPTION_POINTERS *exceptionInformation, MDRawAssertionInfo *assertionInformation, bool succeeded)
- -{
- - Q_UNUSED(context)
- - Q_UNUSED(exceptionInformation)
- - Q_UNUSED(assertionInformation)
- +# ifdef OTTER_ENABLE_CRASHREPORTS# ifdef Q_OS_WIN32
- +bool otterCrashDumpHandler(const wchar_t * dumpDirectory,
- + const wchar_t * dumpIdentifier, void * context, EXCEPTION_POINTERS * exceptionInformation, MDRawAssertionInfo * assertionInformation, bool succeeded) {
- + Q_UNUSED(context)
- + Q_UNUSED(exceptionInformation)
- + Q_UNUSED(assertionInformation)
- - if (succeeded)
- - {
- - const QString dumpPath(QDir::toNativeSeparators(QString::fromWCharArray(dumpDirectory) + QDir::separator() + QString::fromWCharArray(dumpIdentifier) + QLatin1String(".dmp")));
- + if (succeeded) {
- + const QString dumpPath(QDir::toNativeSeparators(QString::fromWCharArray(dumpDirectory) + QDir::separator() + QString::fromWCharArray(dumpIdentifier) + QLatin1String(".dmp")));
- - qDebug("Crash dump saved to: %s", dumpPath.toLocal8Bit().constData());
- + qDebug("Crash dump saved to: %s", dumpPath.toLocal8Bit().constData());
- - const MainWindow *mainWindow(Application::getActiveWindow());
- + const MainWindow * mainWindow(Application::getActiveWindow());
- - QProcess::startDetached(QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QDir::separator() + QLatin1String("crash-reporter.exe")), {dumpPath, (mainWindow ? mainWindow->getUrl().toDisplayString() : QString())});
- - }
- + QProcess::startDetached(QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QDir::separator() + QLatin1String("crash-reporter.exe")), {
- + dumpPath,
- + (mainWindow ? mainWindow - > getUrl().toDisplayString() : QString())
- + });
- + }
- - return succeeded;
- + return succeeded;
- }
- #elif defined(Q_OS_LINUX)
- -bool otterCrashDumpHandler(const google_breakpad::MinidumpDescriptor &descriptor, void *context, bool succeeded)
- -{
- - Q_UNUSED(context)
- +bool otterCrashDumpHandler(const google_breakpad::MinidumpDescriptor & descriptor, void * context, bool succeeded) {
- + Q_UNUSED(context)
- - if (succeeded)
- - {
- - qDebug("Crash dump saved to: %s", descriptor.path());
- + if (succeeded) {
- + qDebug("Crash dump saved to: %s", descriptor.path());
- - const MainWindow *mainWindow(Application::getActiveWindow());
- + const MainWindow * mainWindow(Application::getActiveWindow());
- - QProcess::startDetached(QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QDir::separator() + QLatin1String("crash-reporter")), {descriptor.path(), (mainWindow ? mainWindow->getUrl().toDisplayString() : QString())});
- - }
- + QProcess::startDetached(QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QDir::separator() + QLatin1String("crash-reporter")), {
- + descriptor.path(),
- + (mainWindow ? mainWindow - > getUrl().toDisplayString() : QString())
- + });
- + }
- - return succeeded;
- + return succeeded;
- }
- #endif
- #endif
- -int main(int argc, char *argv[])
- -{
- - QT_REQUIRE_VERSION(argc, argv, QT_VERSION_STR)
- +int main(int argc, char * argv[]) {
- + QT_REQUIRE_VERSION(argc, argv, QT_VERSION_STR)
- #if !defined(Q_OS_WIN32)
- - qSetMessagePattern(QLatin1String("%{if-category}%{category}: %{endif}%{message}\n"));
- - qInstallMessageHandler(otterMessageHander);
- -#endif
- + qSetMessagePattern(QLatin1String("%{if-category}%{category}: %{endif}%{message}\n"));
- + qInstallMessageHandler(otterMessageHander);#
- + endif
- -#ifdef OTTER_ENABLE_CRASHREPORTS
- -#ifdef Q_OS_WIN32
- - new google_breakpad::ExceptionHandler(reinterpret_cast<const wchar_t*>(QStandardPaths::writableLocation(QStandardPaths::TempLocation).utf16()), 0, otterCrashDumpHandler, 0, true);
- +#ifdef OTTER_ENABLE_CRASHREPORTS# ifdef Q_OS_WIN32
- + new google_breakpad::ExceptionHandler(reinterpret_cast <
- + const wchar_t * > (QStandardPaths::writableLocation(QStandardPaths::TempLocation).utf16()), 0, otterCrashDumpHandler, 0, true);
- #elif defined(Q_OS_LINUX)
- - new google_breakpad::ExceptionHandler(google_breakpad::MinidumpDescriptor(QStandardPaths::writableLocation(QStandardPaths::TempLocation).toStdString()), 0, otterCrashDumpHandler, 0, true, -1);
- + new google_breakpad::ExceptionHandler(google_breakpad::MinidumpDescriptor(QStandardPaths::writableLocation(QStandardPaths::TempLocation).toStdString()), 0, otterCrashDumpHandler, 0, true, -1);
- +
- #endif
- #endif
- #if QT_VERSION >= 0x050900
- - // Enable automatic High-DPI scaling support. This could be done with earlier Qt
- - // versions as well (down to 5.6), but it was rather buggy before 5.9, so we
- - // restrict to 5.9 and higher.
- - // Users can force-enable this on olde Qt versions by setting the environment
- - // variable `QT_AUTO_SCREEN_SCALE_FACTOR=1`.
- - // Note that this attribute must be enabled before the QApplication is
- - // constructed, hence the use of the static version of setAttribute().
- -// Application::setAttribute(Qt::AA_EnableHighDpiScaling, true);
- + // Enable automatic High-DPI scaling support. This could be done with earlier Qt
- + // versions as well (down to 5.6), but it was rather buggy before 5.9, so we
- + // restrict to 5.9 and higher.
- + // Users can force-enable this on olde Qt versions by setting the environment
- + // variable `QT_AUTO_SCREEN_SCALE_FACTOR=1`.
- + // Note that this attribute must be enabled before the QApplication is
- + // constructed, hence the use of the static version of setAttribute().
- + // Application::setAttribute(Qt::AA_EnableHighDpiScaling, true);
- #endif
- - // Use static version for this attribute too, for consistency with the above.
- - Application::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
- -
- - Application application(argc, argv);
- -
- - if (Application::isAboutToQuit() || Application::isRunning() || Application::isUpdating() || Application::getCommandLineParser()->isSet(QLatin1String("report")))
- - {
- - return 0;
- - }
- -
- - const QString session(Application::getCommandLineParser()->value(QLatin1String("session")).isEmpty() ? QLatin1String("default") : Application::getCommandLineParser()->value(QLatin1String("session")));
- - const QString startupBehavior(SettingsManager::getOption(SettingsManager::Browser_StartupBehaviorOption).toString());
- - const bool isPrivate(Application::getCommandLineParser()->isSet(QLatin1String("private-session")));
- -
- - if (!Application::getCommandLineParser()->value(QLatin1String("session")).isEmpty() && SessionsManager::getSession(session).isClean)
- - {
- - SessionsManager::restoreSession(SessionsManager::getSession(session), nullptr, isPrivate);
- - }
- - else if (startupBehavior == QLatin1String("showDialog") || Application::getCommandLineParser()->isSet(QLatin1String("session-chooser")) || !SessionsManager::getSession(session).isClean)
- - {
- - StartupDialog dialog(session);
- -
- - if (dialog.exec() == QDialog::Rejected)
- - {
- - return 0;
- - }
- -
- - SessionsManager::restoreSession(dialog.getSession(), nullptr, isPrivate);
- - }
- - else if (startupBehavior == QLatin1String("continuePrevious"))
- - {
- - SessionsManager::restoreSession(SessionsManager::getSession(QLatin1String("default")), nullptr, isPrivate);
- - }
- - else
- - {
- - SessionInformation sessionData(SessionsManager::getSession(QLatin1String("default")));
- - sessionData.path = QLatin1String("default");
- - sessionData.title = QCoreApplication::translate("main", "Default");
- -
- - Session::MainWindow window;
- -
- - if (sessionData.isValid())
- - {
- - window.geometry = sessionData.windows.value(0).geometry;
- - }
- -
- - if (startupBehavior != QLatin1String("startEmpty"))
- - {
- - Session::Window::History::Entry entry;
- -
- - if (startupBehavior == QLatin1String("startHomePage"))
- - {
- - entry.url = SettingsManager::getOption(SettingsManager::Browser_HomePageOption).toString();
- - }
- - else if (startupBehavior == QLatin1String("startStartPage"))
- - {
- - entry.url = QLatin1String("about:start");
- - }
- - else
- - {
- - entry.url = QLatin1String("about:blank");
- - }
- -
- - Session::Window::History history;
- - history.entries = {entry};
- - history.index = 0;
- -
- - Session::Window tab;
- - tab.history = history;
- -
- - window.windows = {tab};
- - window.index = 0;
- - }
- -
- - sessionData.windows = {window};
- - sessionData.index = 0;
- -
- - SessionsManager::restoreSession(sessionData, nullptr, isPrivate);
- - }
- -
- - Application::handlePositionalArguments(Application::getCommandLineParser());
- -
- - if (Application::getWindows().isEmpty())
- - {
- - Application::createWindow({{QLatin1String("hints"), (isPrivate ? SessionsManager::PrivateOpen : SessionsManager::DefaultOpen)}});
- - }
- -
- - return Application::exec();
- + // Use static version for this attribute too, for consistency with the above.
- + Application::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
- +
- + Application application(argc, argv);
- +
- + if (Application::isAboutToQuit() || Application::isRunning() || Application::isUpdating() || Application::getCommandLineParser() - > isSet(QLatin1String("report"))) {
- + return 0;
- + }
- +
- + const QString session(Application::getCommandLineParser() - > value(QLatin1String("session")).isEmpty() ? QLatin1String("default") : Application::getCommandLineParser() - > value(QLatin1String("session")));
- + const QString startupBehavior(SettingsManager::getOption(SettingsManager::Browser_StartupBehaviorOption).toString());
- + const bool isPrivate(Application::getCommandLineParser() - > isSet(QLatin1String("private-session")));
- +
- + if (!Application::getCommandLineParser() - > value(QLatin1String("session")).isEmpty() && SessionsManager::getSession(session).isClean) {
- + SessionsManager::restoreSession(SessionsManager::getSession(session), nullptr, isPrivate);
- + } else if (startupBehavior == QLatin1String("showDialog") || Application::getCommandLineParser() - > isSet(QLatin1String("session-chooser")) || !SessionsManager::getSession(session).isClean) {
- + StartupDialog dialog(session);
- +
- + if (dialog.exec() == QDialog::Rejected) {
- + return 0;
- + }
- +
- + SessionsManager::restoreSession(dialog.getSession(), nullptr, isPrivate);
- + } else if (startupBehavior == QLatin1String("continuePrevious")) {
- + SessionsManager::restoreSession(SessionsManager::getSession(QLatin1String("default")), nullptr, isPrivate);
- + } else {
- + SessionInformation sessionData(SessionsManager::getSession(QLatin1String("default")));
- + sessionData.path = QLatin1String("default");
- + sessionData.title = QCoreApplication::translate("main", "Default");
- +
- + Session::MainWindow window;
- +
- + if (sessionData.isValid()) {
- + window.geometry = sessionData.windows.value(0).geometry;
- + }
- +
- + if (startupBehavior != QLatin1String("startEmpty")) {
- + Session::Window::History::Entry entry;
- +
- + if (startupBehavior == QLatin1String("startHomePage")) {
- + entry.url = SettingsManager::getOption(SettingsManager::Browser_HomePageOption).toString();
- + } else if (startupBehavior == QLatin1String("startStartPage")) {
- + entry.url = QLatin1String("about:start");
- + } else {
- + entry.url = QLatin1String("about:blank");
- + }
- +
- + Session::Window::History history;
- + history.entries = {
- + entry
- + };
- + history.index = 0;
- +
- + Session::Window tab;
- + tab.history = history;
- +
- + window.windows = {
- + tab
- + };
- + window.index = 0;
- + }
- +
- + sessionData.windows = {
- + window
- + };
- + sessionData.index = 0;
- +
- + SessionsManager::restoreSession(sessionData, nullptr, isPrivate);
- + }
- +
- + Application::handlePositionalArguments(Application::getCommandLineParser());
- +
- + if (Application::getWindows().isEmpty()) {
- + Application::createWindow({
- + {
- + QLatin1String("hints"), (isPrivate ? SessionsManager::PrivateOpen : SessionsManager::DefaultOpen)
- + }
- + });
- + }
- +
- + return Application::exec();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement