From 548d6a0dff71854b0c6f68a3dbecf98da37b798d Mon Sep 17 00:00:00 2001 From: Teemu Katajisto Date: Wed, 29 Aug 2012 16:58:47 +0300 Subject: [PATCH] assistant: don't crash when run as non-gui in mac/linux Also don't use obsolete QApplication constructor. Change-Id: Ibe172e13caeccb08a388b0fe8ebbddf25c5ca0ec Reviewed-by: Karsten Heimrich --- src/assistant/assistant/main.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/assistant/assistant/main.cpp b/src/assistant/assistant/main.cpp index 5e80979..0ddefff 100644 --- a/src/assistant/assistant/main.cpp +++ b/src/assistant/assistant/main.cpp @@ -230,10 +230,10 @@ bool rebuildSearchIndex(QCoreApplication &app, const QString &collectionFile, return app.exec() == 0; } -bool useGui(int argc, char *argv[]) +QApplication::Type useGui(int argc, char *argv[]) { TRACE_OBJ - bool gui = true; + QApplication::Type appType = QApplication::GuiClient; #ifndef Q_OS_WIN // Look for arguments that imply command-line mode. const char * cmdModeArgs[] = { @@ -243,7 +243,7 @@ bool useGui(int argc, char *argv[]) for (int i = 1; i < argc; ++i) { for (size_t j = 0; j < sizeof cmdModeArgs/sizeof *cmdModeArgs; ++j) { if(strcmp(argv[i], cmdModeArgs[j]) == 0) { - gui = false; + appType = QApplication::Tty; break; } } @@ -252,7 +252,7 @@ bool useGui(int argc, char *argv[]) Q_UNUSED(argc) Q_UNUSED(argv) #endif - return gui; + return appType; } bool registerDocumentation(QHelpEngineCore &collection, CmdLineParser &cmd, @@ -320,14 +320,17 @@ void setupTranslations() int main(int argc, char *argv[]) { TRACE_OBJ - QApplication a(argc, argv, useGui(argc, argv)); + QApplication::Type appType = useGui(argc, argv); + QApplication a(argc, argv, appType); a.addLibraryPath(a.applicationDirPath() + QLatin1String("/plugins")); setupTranslations(); #if !defined(QT_NO_WEBKIT) - QFont f; - f.setStyleHint(QFont::SansSerif); - QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont, f.defaultFamily()); + if (appType != QApplication::Tty) { + QFont f; + f.setStyleHint(QFont::SansSerif); + QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont, f.defaultFamily()); + } #endif // Parse arguments. -- 2.7.4