From 3624a663d8e94c57cdabca774962a2995c8f79f3 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 24 Apr 2017 17:01:10 +0200 Subject: [PATCH] Reduce usage of qApp in favor of static function calls Q*Application classes have unusually many static functions. In many cases in our code, these functions are unnecessarily called as instance functions, using the qApp helper. This patch replaces many occurencies of qApp with the according Q*Application classname. Change-Id: I6099a419fa7bf969891269c37ed7a9e817ef5124 Reviewed-by: hjk --- src/libs/utils/detailswidget.cpp | 2 +- src/libs/utils/execmenu.cpp | 2 +- src/libs/utils/stylehelper.cpp | 3 +- src/libs/utils/tooltip/tooltip.cpp | 6 +-- src/plugins/bineditor/bineditorplugin.cpp | 2 +- .../cmakeprojectmanager/cmakeprojectnodes.cpp | 2 +- .../coreplugin/dialogs/settingsdialog.cpp | 2 +- .../coreplugin/dialogs/shortcutsettings.cpp | 4 +- .../editormanager/editormanager.cpp | 10 ++-- src/plugins/coreplugin/fileiconprovider.cpp | 4 +- src/plugins/coreplugin/find/findtoolbar.cpp | 2 +- src/plugins/coreplugin/mainwindow.cpp | 4 +- src/plugins/coreplugin/variablechooser.cpp | 2 +- src/plugins/cpaster/cpasterplugin.cpp | 2 +- src/plugins/cpaster/frontend/main.cpp | 6 +-- src/plugins/cppeditor/cppeditorplugin.cpp | 2 +- src/plugins/debugger/watchhandler.cpp | 4 +- src/plugins/designer/formeditorfactory.cpp | 2 +- src/plugins/designer/formeditorplugin.cpp | 4 +- src/plugins/diffeditor/diffeditorfactory.cpp | 2 +- .../genericprojectwizard.cpp | 2 +- src/plugins/glsleditor/glsleditor.cpp | 2 +- src/plugins/help/helpplugin.cpp | 8 ++-- src/plugins/help/helpviewer.cpp | 6 +-- src/plugins/help/searchwidget.cpp | 4 +- .../imageviewer/imageviewerfactory.cpp | 2 +- .../modeleditor/modeleditorfactory.cpp | 4 +- src/plugins/perforce/perforceplugin.cpp | 4 +- .../desktopprocesssignaloperation.cpp | 2 +- .../jsonwizard/jsonfieldpage.cpp | 2 +- .../projectexplorer/windebuginterface.cpp | 4 +- .../qmakeprojectmanager/profileeditor.cpp | 2 +- .../qmakenodetreebuilder.cpp | 2 +- .../wizards/simpleprojectwizard.cpp | 2 +- src/plugins/qmljseditor/qmljseditor.cpp | 2 +- .../qmlprofiler/tests/flamegraphview_test.cpp | 4 +- .../tests/localqmlprofilerrunner_test.cpp | 2 +- .../resourceeditor/resourceeditorfactory.cpp | 2 +- .../codeassist/genericproposalwidget.cpp | 2 +- .../texteditor/plaintexteditorfactory.cpp | 2 +- src/plugins/texteditor/texteditor.cpp | 2 +- src/plugins/texteditor/texteditor_test.cpp | 4 +- .../buildoutputparser/outputprocessor.cpp | 2 +- .../cplusplus-ast2png/cplusplus-ast2png.cpp | 4 +- .../cplusplus-frontend/cplusplus-frontend.cpp | 2 +- .../cplusplus-mkvisitor.cpp | 2 +- .../cplusplus-update-frontend.cpp | 2 +- .../crashhandlerdialog.cpp | 2 +- .../crashhandlersetup.cpp | 2 +- src/tools/sdktool/main.cpp | 2 +- .../tst_timelinezoomcontrol.cpp | 4 +- tests/auto/valgrind/callgrind/modeltest.cpp | 2 +- tests/manual/ssh/errorhandling/main.cpp | 14 +++--- .../ssh/remoteprocess/remoteprocesstest.cpp | 46 +++++++++---------- tests/manual/ssh/sftp/sftptest.cpp | 4 +- tests/manual/ssh/sftpfsmodel/window.cpp | 2 +- tests/manual/ssh/shell/shell.cpp | 6 +-- 57 files changed, 114 insertions(+), 115 deletions(-) diff --git a/src/libs/utils/detailswidget.cpp b/src/libs/utils/detailswidget.cpp index 754f30b4c52..ff03150af4d 100644 --- a/src/libs/utils/detailswidget.cpp +++ b/src/libs/utils/detailswidget.cpp @@ -142,7 +142,7 @@ QPixmap DetailsWidget::createBackground(const QSize &size, int topHeight, QWidge QRect topRect(0, 0, size.width(), topHeight); QRect fullRect(0, 0, size.width(), size.height()); if (HostOsInfo::isMacHost()) - p.fillRect(fullRect, qApp->palette().window().color()); + p.fillRect(fullRect, QApplication::palette().window().color()); else p.fillRect(fullRect, creatorTheme()->color(Theme::DetailsWidgetBackgroundColor)); diff --git a/src/libs/utils/execmenu.cpp b/src/libs/utils/execmenu.cpp index db09fc7ab72..b9d7b536160 100644 --- a/src/libs/utils/execmenu.cpp +++ b/src/libs/utils/execmenu.cpp @@ -43,7 +43,7 @@ namespace Utils { QAction *execMenuAtWidget(QMenu *menu, QWidget *widget) { QPoint p; - QRect screen = qApp->desktop()->availableGeometry(widget); + QRect screen = QApplication::desktop()->availableGeometry(widget); QSize sh = menu->sizeHint(); QRect rect = widget->rect(); if (widget->isRightToLeft()) { diff --git a/src/libs/utils/stylehelper.cpp b/src/libs/utils/stylehelper.cpp index 93c7125e055..fd270a5a860 100644 --- a/src/libs/utils/stylehelper.cpp +++ b/src/libs/utils/stylehelper.cpp @@ -83,7 +83,7 @@ qreal StyleHelper::sidebarFontSize() QColor StyleHelper::notTooBrightHighlightColor() { - QColor highlightColor = qApp->palette().highlight().color(); + QColor highlightColor = QApplication::palette().highlight().color(); if (0.5 * highlightColor.saturationF() + 0.75 - highlightColor.valueF() < 0) highlightColor.setHsvF(highlightColor.hsvHueF(), 0.1 + highlightColor.saturationF() * 2.0, highlightColor.valueF()); return highlightColor; @@ -101,7 +101,6 @@ QPalette StyleHelper::sidebarFontPalette(const QPalette &original) QColor StyleHelper::panelTextColor(bool lightColored) { - //qApp->palette().highlightedText().color(); if (!lightColored) return Qt::white; else diff --git a/src/libs/utils/tooltip/tooltip.cpp b/src/libs/utils/tooltip/tooltip.cpp index c9be1f99f35..47799b75a90 100644 --- a/src/libs/utils/tooltip/tooltip.cpp +++ b/src/libs/utils/tooltip/tooltip.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include #include @@ -296,7 +296,7 @@ void ToolTip::placeTip(const QPoint &pos, QWidget *w) bool ToolTip::eventFilter(QObject *o, QEvent *event) { if (m_tip && event->type() == QEvent::ApplicationStateChange - && qApp->applicationState() != Qt::ApplicationActive) { + && QGuiApplication::applicationState() != Qt::ApplicationActive) { hideTipImmediately(); } @@ -316,7 +316,7 @@ bool ToolTip::eventFilter(QObject *o, QEvent *event) } break; case QEvent::Leave: - if (o == m_tip && !m_tip->isAncestorOf(qApp->focusWidget())) + if (o == m_tip && !m_tip->isAncestorOf(QApplication::focusWidget())) hideTipWithDelay(); break; case QEvent::Enter: diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 5fcccd78386..61b35220265 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -434,7 +434,7 @@ BinEditorFactory::BinEditorFactory(BinEditorPlugin *owner) : m_owner(owner) { setId(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID); - setDisplayName(qApp->translate("OpenWith::Editors", Constants::C_BINEDITOR_DISPLAY_NAME)); + setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::C_BINEDITOR_DISPLAY_NAME)); addMimeType(Constants::C_BINEDITOR_MIMETYPE); } diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp index 79337e04401..88f519cd7d8 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp @@ -62,7 +62,7 @@ CMakeListsNode::CMakeListsNode(const Utils::FileName &cmakeListPath) : static QIcon folderIcon; if (folderIcon.isNull()) { const QIcon overlayIcon(Constants::FILEOVERLAY_CMAKE); - QPixmap dirPixmap = qApp->style()->standardIcon(QStyle::SP_DirIcon).pixmap(QSize(16, 16)); + QPixmap dirPixmap = QApplication::style()->standardIcon(QStyle::SP_DirIcon).pixmap(QSize(16, 16)); folderIcon.addPixmap(Core::FileIconProvider::overlayIcon(dirPixmap, overlayIcon)); } diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp index 2322a2486d4..1d1ac06ac3b 100644 --- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp +++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp @@ -505,7 +505,7 @@ void SettingsDialog::createGui() m_headerLabel->setFont(headerLabelFont); QHBoxLayout *headerHLayout = new QHBoxLayout; - const int leftMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin); + const int leftMargin = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin); headerHLayout->addSpacerItem(new QSpacerItem(leftMargin, 0, QSizePolicy::Fixed, QSizePolicy::Ignored)); headerHLayout->addWidget(m_headerLabel); diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp index dc71e446dc2..c87ef057291 100644 --- a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp +++ b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp @@ -200,8 +200,8 @@ void ShortcutButton::handleToggleChange(bool toogleState) updateText(); m_keyNum = m_key[0] = m_key[1] = m_key[2] = m_key[3] = 0; if (toogleState) { - if (qApp->focusWidget()) - qApp->focusWidget()->clearFocus(); // funny things happen otherwise + if (QApplication::focusWidget()) + QApplication::focusWidget()->clearFocus(); // funny things happen otherwise qApp->installEventFilter(this); } else { qApp->removeEventFilter(this); diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 1bfb5face41..9b2bd61748e 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -822,10 +822,10 @@ void EditorManagerPrivate::doEscapeKeyFocusMoveMagic() // otherwise (i.e. mode is edit mode) // hide extra views (find, help, output) - QWidget *activeWindow = qApp->activeWindow(); + QWidget *activeWindow = QApplication::activeWindow(); if (!activeWindow) return; - QWidget *focus = qApp->focusWidget(); + QWidget *focus = QApplication::focusWidget(); EditorView *editorView = currentEditorView(); bool editorViewActive = (focus && focus == editorView->focusWidget()); bool editorViewVisible = editorView->isVisible(); @@ -886,7 +886,7 @@ void EditorManagerPrivate::showPopupOrSelectDocument() if (QApplication::keyboardModifiers() == Qt::NoModifier) { windowPopup()->selectAndHide(); } else { - QWidget *activeWindow = qApp->activeWindow(); + QWidget *activeWindow = QApplication::activeWindow(); // decide where to show the popup // if the active window has editors, we want that editor area as a reference // TODO: this does not work correctly with multiple editor areas in the same window @@ -1388,7 +1388,7 @@ bool EditorManagerPrivate::closeEditors(const QList &editors, CloseFla removeEditor(editor, flag != CloseFlag::Suspend); if (EditorView *view = viewForEditor(editor)) { - if (qApp->focusWidget() && qApp->focusWidget() == editor->widget()->focusWidget()) + if (QApplication::focusWidget() && QApplication::focusWidget() == editor->widget()->focusWidget()) focusView = view; if (editor == view->currentEditor()) closedViews += view; @@ -1930,7 +1930,7 @@ void EditorManagerPrivate::handleDocumentStateChange() void EditorManagerPrivate::editorAreaDestroyed(QObject *area) { - QWidget *activeWin = qApp->activeWindow(); + QWidget *activeWin = QApplication::activeWindow(); EditorArea *newActiveArea = 0; for (int i = 0; i < d->m_editorAreas.size(); ++i) { EditorArea *r = d->m_editorAreas.at(i); diff --git a/src/plugins/coreplugin/fileiconprovider.cpp b/src/plugins/coreplugin/fileiconprovider.cpp index 0c6af1a4d29..4d6cf5ea489 100644 --- a/src/plugins/coreplugin/fileiconprovider.cpp +++ b/src/plugins/coreplugin/fileiconprovider.cpp @@ -68,7 +68,7 @@ class FileIconProviderImplementation : public QFileIconProvider { public: FileIconProviderImplementation() - : m_unknownFileIcon(qApp->style()->standardIcon(QStyle::SP_FileIcon)) + : m_unknownFileIcon(QApplication::style()->standardIcon(QStyle::SP_FileIcon)) {} QIcon icon(const QFileInfo &info) const override; @@ -184,7 +184,7 @@ QPixmap overlayIcon(const QPixmap &baseIcon, const QIcon &overlayIcon) */ QPixmap overlayIcon(QStyle::StandardPixmap baseIcon, const QIcon &overlay, const QSize &size) { - return overlayIcon(qApp->style()->standardIcon(baseIcon).pixmap(size), overlay); + return overlayIcon(QApplication::style()->standardIcon(baseIcon).pixmap(size), overlay); } /*! diff --git a/src/plugins/coreplugin/find/findtoolbar.cpp b/src/plugins/coreplugin/find/findtoolbar.cpp index 443c757e97d..c4cfe718cfb 100644 --- a/src/plugins/coreplugin/find/findtoolbar.cpp +++ b/src/plugins/coreplugin/find/findtoolbar.cpp @@ -742,7 +742,7 @@ FindToolBarPlaceHolder *FindToolBar::findToolBarPlaceHolder() const bool FindToolBar::toolBarHasFocus() const { - return qApp->focusWidget() == focusWidget(); + return QApplication::focusWidget() == focusWidget(); } bool FindToolBar::canShowAllControls(bool replaceIsVisible) const diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index d2928e28830..17fed47e85c 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -916,7 +916,7 @@ void MainWindow::updateFocusWidget(QWidget *old, QWidget *now) return; QList newContext; - if (QWidget *p = qApp->focusWidget()) { + if (QWidget *p = QApplication::focusWidget()) { IContext *context = nullptr; while (p) { context = m_contextWidgets.value(p); @@ -927,7 +927,7 @@ void MainWindow::updateFocusWidget(QWidget *old, QWidget *now) } // ignore toplevels that define no context, like popups without parent - if (!newContext.isEmpty() || qApp->focusWidget() == focusWidget()) + if (!newContext.isEmpty() || QApplication::focusWidget() == focusWidget()) updateContextObject(newContext); } diff --git a/src/plugins/coreplugin/variablechooser.cpp b/src/plugins/coreplugin/variablechooser.cpp index dc595b61d91..109b81a8d89 100644 --- a/src/plugins/coreplugin/variablechooser.cpp +++ b/src/plugins/coreplugin/variablechooser.cpp @@ -309,7 +309,7 @@ VariableChooserPrivate::VariableChooserPrivate(VariableChooser *parent) this, &VariableChooserPrivate::handleItemActivated); connect(qobject_cast(qApp), &QApplication::focusChanged, this, &VariableChooserPrivate::updateCurrentEditor); - updateCurrentEditor(0, qApp->focusWidget()); + updateCurrentEditor(0, QApplication::focusWidget()); } void VariableGroupItem::populateGroup(MacroExpander *expander) diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index c30be1c95bd..c97e89ae5be 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -241,7 +241,7 @@ void CodepasterPlugin::post(PasteSources pasteSources) textFromCurrentEditor(&data, &mimeType); if (data.isEmpty() && (pasteSources & PasteClipboard)) { QString subType = QStringLiteral("plain"); - data = qApp->clipboard()->text(subType, QClipboard::Clipboard); + data = QGuiApplication::clipboard()->text(subType, QClipboard::Clipboard); } post(data, mimeType); } diff --git a/src/plugins/cpaster/frontend/main.cpp b/src/plugins/cpaster/frontend/main.cpp index 65c9c9e6b12..2789ebdb510 100644 --- a/src/plugins/cpaster/frontend/main.cpp +++ b/src/plugins/cpaster/frontend/main.cpp @@ -63,13 +63,13 @@ public: ? file.open(stdin, QIODevice::ReadOnly) : file.open(QIODevice::ReadOnly); if (!success) { std::cerr << "Error: Failed to open file to paste from." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } const QString content = QString::fromLocal8Bit(file.readAll()); if (content.isEmpty()) { std::cerr << "Empty input, aborting." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } connect(m_protocol.data(), &Protocol::pasteDone, this, &PasteReceiver::handlePasteDone); @@ -80,7 +80,7 @@ private: void handlePasteDone(const QString &link) { std::cout << qPrintable(link) << std::endl; - qApp->quit(); + QCoreApplication::quit(); } const QString m_filePath; diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index 0febf579a69..f2be8a29560 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -83,7 +83,7 @@ public: CppEditorFactory() { setId(Constants::CPPEDITOR_ID); - setDisplayName(qApp->translate("OpenWith::Editors", Constants::CPPEDITOR_DISPLAY_NAME)); + setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::CPPEDITOR_DISPLAY_NAME)); addMimeType(CppTools::Constants::C_SOURCE_MIMETYPE); addMimeType(CppTools::Constants::C_HEADER_MIMETYPE); addMimeType(CppTools::Constants::CPP_SOURCE_MIMETYPE); diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index f14d82e8caa..2a46f95eff3 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -1269,7 +1269,7 @@ static QString variableToolTip(const QString &name, const QString &type, quint64 void WatchModel::grabWidget() { - qApp->setOverrideCursor(Qt::CrossCursor); + QGuiApplication::setOverrideCursor(Qt::CrossCursor); m_grabWidgetTimerId = startTimer(30); ICore::mainWindow()->grabMouse(); } @@ -1302,7 +1302,7 @@ void WatchModel::timerEvent(QTimerEvent *event) void WatchModel::ungrabWidget() { ICore::mainWindow()->releaseMouse(); - qApp->restoreOverrideCursor(); + QGuiApplication::restoreOverrideCursor(); killTimer(m_grabWidgetTimerId); m_grabWidgetTimerId = -1; } diff --git a/src/plugins/designer/formeditorfactory.cpp b/src/plugins/designer/formeditorfactory.cpp index 1fa9bc648d4..ae4d38c3ac1 100644 --- a/src/plugins/designer/formeditorfactory.cpp +++ b/src/plugins/designer/formeditorfactory.cpp @@ -43,7 +43,7 @@ namespace Internal { FormEditorFactory::FormEditorFactory() { setId(K_DESIGNER_XML_EDITOR_ID); - setDisplayName(qApp->translate("Designer", C_DESIGNER_XML_DISPLAY_NAME)); + setDisplayName(QCoreApplication::translate("Designer", C_DESIGNER_XML_DISPLAY_NAME)); addMimeType(FORM_MIMETYPE); FileIconProvider::registerIconOverlayForSuffix(ProjectExplorer::Constants::FILEOVERLAY_UI, "ui"); diff --git a/src/plugins/designer/formeditorplugin.cpp b/src/plugins/designer/formeditorplugin.cpp index 4fe5fa0d30f..1abc12a8032 100644 --- a/src/plugins/designer/formeditorplugin.cpp +++ b/src/plugins/designer/formeditorplugin.cpp @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include #include @@ -108,7 +108,7 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error) const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); const QString &trFile = QLatin1String("designer_") + locale; if (qtr->load(trFile, qtTrPath) || qtr->load(trFile, creatorTrPath)) - qApp->installTranslator(qtr); + QCoreApplication::installTranslator(qtr); } error->clear(); return true; diff --git a/src/plugins/diffeditor/diffeditorfactory.cpp b/src/plugins/diffeditor/diffeditorfactory.cpp index 5e4cf226141..714b0d25ca5 100644 --- a/src/plugins/diffeditor/diffeditorfactory.cpp +++ b/src/plugins/diffeditor/diffeditorfactory.cpp @@ -38,7 +38,7 @@ DiffEditorFactory::DiffEditorFactory(QObject *parent) : IEditorFactory(parent) { setId(Constants::DIFF_EDITOR_ID); - setDisplayName(qApp->translate("DiffEditorFactory", Constants::DIFF_EDITOR_DISPLAY_NAME)); + setDisplayName(QCoreApplication::translate("DiffEditorFactory", Constants::DIFF_EDITOR_DISPLAY_NAME)); addMimeType(Constants::DIFF_EDITOR_MIMETYPE); } diff --git a/src/plugins/genericprojectmanager/genericprojectwizard.cpp b/src/plugins/genericprojectmanager/genericprojectwizard.cpp index f35eda0a9c7..1ec8785e08f 100644 --- a/src/plugins/genericprojectmanager/genericprojectwizard.cpp +++ b/src/plugins/genericprojectmanager/genericprojectwizard.cpp @@ -116,7 +116,7 @@ GenericProjectWizard::GenericProjectWizard() QPixmap icon(22, 22); icon.fill(Qt::transparent); QPainter p(&icon); - p.drawPixmap(3, 3, 16, 16, qApp->style()->standardIcon(QStyle::SP_DirIcon).pixmap(16)); + p.drawPixmap(3, 3, 16, 16, QApplication::style()->standardIcon(QStyle::SP_DirIcon).pixmap(16)); setIcon(icon); } setDisplayName(tr("Import Existing Project")); diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp index a0871bd1b1e..47cf9e2a496 100644 --- a/src/plugins/glsleditor/glsleditor.cpp +++ b/src/plugins/glsleditor/glsleditor.cpp @@ -312,7 +312,7 @@ AssistInterface *GlslEditorWidget::createAssistInterface( GlslEditorFactory::GlslEditorFactory() { setId(Constants::C_GLSLEDITOR_ID); - setDisplayName(qApp->translate("OpenWith::Editors", Constants::C_GLSLEDITOR_DISPLAY_NAME)); + setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::C_GLSLEDITOR_DISPLAY_NAME)); addMimeType(Constants::GLSL_MIMETYPE); addMimeType(Constants::GLSL_MIMETYPE_VERT); addMimeType(Constants::GLSL_MIMETYPE_FRAG); diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 29d654cab08..45765dacaad 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -136,9 +136,9 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) const QString &trFile = QLatin1String("assistant_") + locale; const QString &helpTrFile = QLatin1String("qt_help_") + locale; if (qtr->load(trFile, qtTrPath) || qtr->load(trFile, creatorTrPath)) - qApp->installTranslator(qtr); + QCoreApplication::installTranslator(qtr); if (qhelptr->load(helpTrFile, qtTrPath) || qhelptr->load(helpTrFile, creatorTrPath)) - qApp->installTranslator(qhelptr); + QCoreApplication::installTranslator(qhelptr); } m_helpManager = new LocalHelpManager(this); @@ -448,9 +448,9 @@ void HelpPlugin::modeChanged(Core::Id mode, Core::Id old) { Q_UNUSED(old) if (mode == m_mode->id()) { - qApp->setOverrideCursor(Qt::WaitCursor); + QGuiApplication::setOverrideCursor(Qt::WaitCursor); doSetupIfNeeded(); - qApp->restoreOverrideCursor(); + QGuiApplication::restoreOverrideCursor(); } } diff --git a/src/plugins/help/helpviewer.cpp b/src/plugins/help/helpviewer.cpp index 3549d9ad20e..ebd4ae44c08 100644 --- a/src/plugins/help/helpviewer.cpp +++ b/src/plugins/help/helpviewer.cpp @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include @@ -156,12 +156,12 @@ void HelpViewer::home() void HelpViewer::slotLoadStarted() { - qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); + QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); } void HelpViewer::slotLoadFinished() { - qApp->restoreOverrideCursor(); + QGuiApplication::restoreOverrideCursor(); emit sourceChanged(source()); emit loadFinished(); } diff --git a/src/plugins/help/searchwidget.cpp b/src/plugins/help/searchwidget.cpp index 27e21a9ff88..7d275fa0d54 100644 --- a/src/plugins/help/searchwidget.cpp +++ b/src/plugins/help/searchwidget.cpp @@ -184,13 +184,13 @@ void SearchWidget::search() const void SearchWidget::searchingStarted() { - qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); + QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); } void SearchWidget::searchingFinished(int hits) { Q_UNUSED(hits) - qApp->restoreOverrideCursor(); + QGuiApplication::restoreOverrideCursor(); } void SearchWidget::indexingStarted() diff --git a/src/plugins/imageviewer/imageviewerfactory.cpp b/src/plugins/imageviewer/imageviewerfactory.cpp index c04733555f7..ef8414ee629 100644 --- a/src/plugins/imageviewer/imageviewerfactory.cpp +++ b/src/plugins/imageviewer/imageviewerfactory.cpp @@ -40,7 +40,7 @@ ImageViewerFactory::ImageViewerFactory(QObject *parent) : Core::IEditorFactory(parent) { setId(Constants::IMAGEVIEWER_ID); - setDisplayName(qApp->translate("OpenWith::Editors", Constants::IMAGEVIEWER_DISPLAY_NAME)); + setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::IMAGEVIEWER_DISPLAY_NAME)); const QList supportedMimeTypes = QImageReader::supportedMimeTypes(); foreach (const QByteArray &format, supportedMimeTypes) diff --git a/src/plugins/modeleditor/modeleditorfactory.cpp b/src/plugins/modeleditor/modeleditorfactory.cpp index 04be9c440ef..ab6bf6746ea 100644 --- a/src/plugins/modeleditor/modeleditorfactory.cpp +++ b/src/plugins/modeleditor/modeleditorfactory.cpp @@ -29,7 +29,7 @@ #include "actionhandler.h" #include "modeleditor.h" -#include +#include namespace ModelEditor { namespace Internal { @@ -46,7 +46,7 @@ ModelEditorFactory::ModelEditorFactory(UiController *uiController, QObject *pare d(new ModelEditorFactoryPrivate()) { setId(Constants::MODEL_EDITOR_ID); - setDisplayName(qApp->translate("OpenWith::Editors", Constants::MODEL_EDITOR_DISPLAY_NAME)); + setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::MODEL_EDITOR_DISPLAY_NAME)); addMimeType(Constants::MIME_TYPE_MODEL); d->uiController = uiController; d->actionHandler = new ActionHandler(Core::Context(Constants::MODEL_EDITOR_ID), this); diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index f4b4004ee56..7bae8aa2c10 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -631,9 +631,9 @@ IEditor *PerforcePlugin::openPerforceSubmitEditor(const QString &fileName, const void PerforcePlugin::printPendingChanges() { - qApp->setOverrideCursor(Qt::WaitCursor); + QGuiApplication::setOverrideCursor(Qt::WaitCursor); PendingChangesDialog dia(pendingChangesData(), ICore::mainWindow()); - qApp->restoreOverrideCursor(); + QGuiApplication::restoreOverrideCursor(); if (dia.exec() == QDialog::Accepted) { const int i = dia.changeNumber(); QStringList args(QLatin1String("submit")); diff --git a/src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.cpp b/src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.cpp index 35b71549a21..b2cf328e143 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.cpp +++ b/src/plugins/projectexplorer/devicesupport/desktopprocesssignaloperation.cpp @@ -165,7 +165,7 @@ GDB 32bit | Api | Api | N/A | Win32 + Utils::winErrorMessage(GetLastError())); break; } - bool creatorIs64Bit = Utils::is64BitWindowsBinary(qApp->applicationFilePath()); + bool creatorIs64Bit = Utils::is64BitWindowsBinary(QCoreApplication::applicationFilePath()); if (!is64BitSystem || si == NoSpecialInterrupt || (si == Win64Interrupt && creatorIs64Bit) diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp index fe49ff41292..f71bdd19e2e 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp @@ -369,7 +369,7 @@ QWidget *SpacerField::createWidget(const QString &displayName, JsonFieldPage *pa { Q_UNUSED(displayName); Q_UNUSED(page); - int size = qApp->style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing) * m_factor; + int size = QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing) * m_factor; auto w = new QWidget(); w->setMinimumSize(size, size); diff --git a/src/plugins/projectexplorer/windebuginterface.cpp b/src/plugins/projectexplorer/windebuginterface.cpp index a4d0bac9fa5..45b6f13c6c1 100644 --- a/src/plugins/projectexplorer/windebuginterface.cpp +++ b/src/plugins/projectexplorer/windebuginterface.cpp @@ -28,7 +28,7 @@ #ifdef Q_OS_WIN #include -#include +#include #include /*! @@ -64,7 +64,7 @@ WinDebugInterface::WinDebugInterface(QObject *parent) : QThread(parent) { m_instance = this; - m_creatorPid = qApp->applicationPid(); + m_creatorPid = QCoreApplication::applicationPid(); setObjectName(QLatin1String("WinDebugInterfaceThread")); } diff --git a/src/plugins/qmakeprojectmanager/profileeditor.cpp b/src/plugins/qmakeprojectmanager/profileeditor.cpp index d9e12423598..1535848d802 100644 --- a/src/plugins/qmakeprojectmanager/profileeditor.cpp +++ b/src/plugins/qmakeprojectmanager/profileeditor.cpp @@ -171,7 +171,7 @@ static TextDocument *createProFileDocument() ProFileEditorFactory::ProFileEditorFactory() { setId(Constants::PROFILE_EDITOR_ID); - setDisplayName(qApp->translate("OpenWith::Editors", Constants::PROFILE_EDITOR_DISPLAY_NAME)); + setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::PROFILE_EDITOR_DISPLAY_NAME)); addMimeType(Constants::PROFILE_MIMETYPE); addMimeType(Constants::PROINCLUDEFILE_MIMETYPE); addMimeType(Constants::PROFEATUREFILE_MIMETYPE); diff --git a/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp b/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp index 2bc3b23682f..3115a0c52e2 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp @@ -105,7 +105,7 @@ QmakeStaticData::QmakeStaticData() // Overlay the SP_DirIcon with the custom icons const QSize desiredSize = QSize(16, 16); - const QPixmap dirPixmap = qApp->style()->standardIcon(QStyle::SP_DirIcon).pixmap(desiredSize); + const QPixmap dirPixmap = QApplication::style()->standardIcon(QStyle::SP_DirIcon).pixmap(desiredSize); for (unsigned i = 0 ; i < count; ++i) { const QIcon overlayIcon(QLatin1String(fileTypeDataStorage[i].icon)); QIcon folderIcon; diff --git a/src/plugins/qmakeprojectmanager/wizards/simpleprojectwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/simpleprojectwizard.cpp index 7dc6f129f13..4206ef45ab7 100644 --- a/src/plugins/qmakeprojectmanager/wizards/simpleprojectwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/simpleprojectwizard.cpp @@ -135,7 +135,7 @@ SimpleProjectWizard::SimpleProjectWizard() QPixmap icon(22, 22); icon.fill(Qt::transparent); QPainter p(&icon); - p.drawPixmap(3, 3, 16, 16, qApp->style()->standardIcon(QStyle::SP_DirIcon).pixmap(16)); + p.drawPixmap(3, 3, 16, 16, QApplication::style()->standardIcon(QStyle::SP_DirIcon).pixmap(16)); setIcon(icon); } setDisplayName(tr("Import as qmake Project (Limited Functionality)")); diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index cf84adfae4d..67624c4cfa5 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -1030,7 +1030,7 @@ bool QmlJSEditor::isDesignModePreferred() const QmlJSEditorFactory::QmlJSEditorFactory() { setId(Constants::C_QMLJSEDITOR_ID); - setDisplayName(qApp->translate("OpenWith::Editors", Constants::C_QMLJSEDITOR_DISPLAY_NAME)); + setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::C_QMLJSEDITOR_DISPLAY_NAME)); addMimeType(QmlJSTools::Constants::QML_MIMETYPE); addMimeType(QmlJSTools::Constants::QMLPROJECT_MIMETYPE); diff --git a/src/plugins/qmlprofiler/tests/flamegraphview_test.cpp b/src/plugins/qmlprofiler/tests/flamegraphview_test.cpp index 5d94a1a8b13..56a2a859f2b 100644 --- a/src/plugins/qmlprofiler/tests/flamegraphview_test.cpp +++ b/src/plugins/qmlprofiler/tests/flamegraphview_test.cpp @@ -124,11 +124,11 @@ void FlameGraphViewTest::testContextMenu() int menuClicks = 0; connect(&timer, &QTimer::timeout, this, [&]() { - auto activePopup = qApp->activePopupWidget(); + auto activePopup = QApplication::activePopupWidget(); if (!activePopup || !activePopup->windowHandle()->isExposed()) { QContextMenuEvent *event = new QContextMenuEvent(QContextMenuEvent::Mouse, QPoint(250, 250)); - qApp->postEvent(&view, event); + QCoreApplication::postEvent(&view, event); return; } diff --git a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp index 4859e292371..c7ef5f1b4ec 100644 --- a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp +++ b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp @@ -73,7 +73,7 @@ void LocalQmlProfilerRunnerTest::testRunner1() QTRY_VERIFY_WITH_TIMEOUT(!running, 10000); configuration.socket = connection.analyzerSocket = LocalQmlProfilerRunner::findFreeSocket(); - configuration.debuggee.executable = qApp->applicationFilePath(); + configuration.debuggee.executable = QCoreApplication::applicationFilePath(); // comma is used to specify a test function. In this case, an invalid one. configuration.debuggee.commandLineArguments = QString("-test QmlProfiler,"); diff --git a/src/plugins/resourceeditor/resourceeditorfactory.cpp b/src/plugins/resourceeditor/resourceeditorfactory.cpp index d4707e3f694..3b81616328a 100644 --- a/src/plugins/resourceeditor/resourceeditorfactory.cpp +++ b/src/plugins/resourceeditor/resourceeditorfactory.cpp @@ -45,7 +45,7 @@ ResourceEditorFactory::ResourceEditorFactory(ResourceEditorPlugin *plugin) : { setId(RESOURCEEDITOR_ID); setMimeTypes(QStringList(QLatin1String(C_RESOURCE_MIMETYPE))); - setDisplayName(qApp->translate("OpenWith::Editors", C_RESOURCEEDITOR_DISPLAY_NAME)); + setDisplayName(QCoreApplication::translate("OpenWith::Editors", C_RESOURCEEDITOR_DISPLAY_NAME)); Core::FileIconProvider::registerIconOverlayForSuffix( ProjectExplorer::Constants::FILEOVERLAY_QRC, "qrc"); diff --git a/src/plugins/texteditor/codeassist/genericproposalwidget.cpp b/src/plugins/texteditor/codeassist/genericproposalwidget.cpp index 1ce01ffa18d..d5a7b62ad89 100644 --- a/src/plugins/texteditor/codeassist/genericproposalwidget.cpp +++ b/src/plugins/texteditor/codeassist/genericproposalwidget.cpp @@ -621,7 +621,7 @@ bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e) if (ke->text().length() == 1 && d->m_completionListView->currentIndex().isValid() - && qApp->focusWidget() == o) { + && QApplication::focusWidget() == o) { const QChar &typedChar = ke->text().at(0); AssistProposalItemInterface *item = d->m_model->proposalItem(d->m_completionListView->currentIndex().row()); diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index 4f728971405..b0932bf3b55 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -58,7 +58,7 @@ PlainTextEditorFactory::PlainTextEditorFactory() QTC_CHECK(!m_instance); m_instance = this; setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); - setDisplayName(qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME)); + setDisplayName(QCoreApplication::translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME)); addMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT)); addMimeType(QLatin1String("text/css")); // for some reason freedesktop thinks css is text/x-csrc addHoverHandler(new BaseHoverHandler); diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 7d1cc859e9b..1f51309c054 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -3488,7 +3488,7 @@ void TextEditorWidgetPrivate::disableBlockSelection(BlockSelectionUpdateKind kin void TextEditorWidgetPrivate::resetCursorFlashTimer() { m_cursorVisible = true; - const int flashTime = qApp->cursorFlashTime(); + const int flashTime = QApplication::cursorFlashTime(); if (flashTime > 0) { m_cursorFlashTimer.stop(); m_cursorFlashTimer.start(flashTime / 2, q); diff --git a/src/plugins/texteditor/texteditor_test.cpp b/src/plugins/texteditor/texteditor_test.cpp index 786235d3608..c5e81ec3af4 100644 --- a/src/plugins/texteditor/texteditor_test.cpp +++ b/src/plugins/texteditor/texteditor_test.cpp @@ -25,7 +25,7 @@ #ifdef WITH_TESTS -#include +#include #include #include #include @@ -493,7 +493,7 @@ void Internal::TextEditorPlugin::testBlockSelectionCopy() editorWidget->update(); editorWidget->copy(); - QCOMPARE(qApp->clipboard()->text(), copiedText); + QCOMPARE(QGuiApplication::clipboard()->text(), copiedText); } Core::EditorManager::closeDocument(editor->document(), false); } diff --git a/src/tools/buildoutputparser/outputprocessor.cpp b/src/tools/buildoutputparser/outputprocessor.cpp index e738cfeb4cb..103a2d6b1fc 100644 --- a/src/tools/buildoutputparser/outputprocessor.cpp +++ b/src/tools/buildoutputparser/outputprocessor.cpp @@ -78,7 +78,7 @@ void CompilerOutputProcessor::start() this, &CompilerOutputProcessor::handleTask); while (!m_source.atEnd()) parser.stdError(QString::fromLocal8Bit(m_source.readLine().trimmed())); - qApp->quit(); + QCoreApplication::quit(); } void CompilerOutputProcessor::handleTask(const ProjectExplorer::Task &task) diff --git a/src/tools/cplusplus-ast2png/cplusplus-ast2png.cpp b/src/tools/cplusplus-ast2png/cplusplus-ast2png.cpp index 6e7fb20e62e..59aab237ec1 100644 --- a/src/tools/cplusplus-ast2png/cplusplus-ast2png.cpp +++ b/src/tools/cplusplus-ast2png/cplusplus-ast2png.cpp @@ -378,7 +378,7 @@ static QString example() #else QString::fromLatin1("$ echo \"int foo() {}\" | ./%1 && xdg-open %2.ast.png") #endif - .arg(QFileInfo(qApp->arguments().at(0)).fileName(), QLatin1String(PATH_STDIN_FILE)); + .arg(QFileInfo(QCoreApplication::arguments().at(0)).fileName(), QLatin1String(PATH_STDIN_FILE)); } static QString parseModeToString(Document::ParseMode parseMode) @@ -474,7 +474,7 @@ static Document::Ptr parse(const QString &fileName, const QByteArray &source, static void printUsage() { - std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName()) + std::cout << "Usage: " << qPrintable(QFileInfo(QCoreApplication::arguments().at(0)).fileName()) << " [-v] [-p ast] ...\n\n"; std::cout diff --git a/src/tools/cplusplus-frontend/cplusplus-frontend.cpp b/src/tools/cplusplus-frontend/cplusplus-frontend.cpp index 4fc58beed78..3701a1759c0 100644 --- a/src/tools/cplusplus-frontend/cplusplus-frontend.cpp +++ b/src/tools/cplusplus-frontend/cplusplus-frontend.cpp @@ -54,7 +54,7 @@ using namespace CPlusPlus; void printUsage() { - std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName()) + std::cout << "Usage: " << qPrintable(QFileInfo(QCoreApplication::arguments().at(0)).fileName()) << " [-v] ...\n\n" << "Run the parser with the given files.\n"; } diff --git a/src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor.cpp b/src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor.cpp index 50c39ebf4db..14e858cfcda 100644 --- a/src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor.cpp +++ b/src/tools/cplusplus-mkvisitor/cplusplus-mkvisitor.cpp @@ -422,7 +422,7 @@ protected: void printUsage() { - std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName()) + std::cout << "Usage: " << qPrintable(QFileInfo(QCoreApplication::arguments().at(0)).fileName()) << " [-v] [path to AST.h]\n\n" << "Print a visitor class based on AST.h to stdout.\n\n"; const QString defaulPath = QFileInfo(QLatin1String(PATH_AST_H)).canonicalFilePath(); diff --git a/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp b/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp index e51355826fa..9a5b7c67007 100644 --- a/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp +++ b/src/tools/cplusplus-update-frontend/cplusplus-update-frontend.cpp @@ -1692,7 +1692,7 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir) void printUsage() { - const QByteArray executable = QFileInfo(qApp->arguments().first()).fileName().toLatin1(); + const QByteArray executable = QFileInfo(QCoreApplication::arguments().first()).fileName().toLatin1(); std::cout << "Usage: " << executable.constData() << "\n" << " " << executable.constData() << " " << "\n\n" diff --git a/src/tools/qtcreatorcrashhandler/crashhandlerdialog.cpp b/src/tools/qtcreatorcrashhandler/crashhandlerdialog.cpp index 524a1f5177d..83a25c9c388 100644 --- a/src/tools/qtcreatorcrashhandler/crashhandlerdialog.cpp +++ b/src/tools/qtcreatorcrashhandler/crashhandlerdialog.cpp @@ -177,5 +177,5 @@ void CrashHandlerDialog::close() { if (m_ui->restartAppCheckBox->isEnabled() && m_ui->restartAppCheckBox->isChecked()) m_crashHandler->restartApplication(); - qApp->quit(); + QCoreApplication::quit(); } diff --git a/src/tools/qtcreatorcrashhandler/crashhandlersetup.cpp b/src/tools/qtcreatorcrashhandler/crashhandlersetup.cpp index 69301dc1abf..6f1baff4c77 100644 --- a/src/tools/qtcreatorcrashhandler/crashhandlersetup.cpp +++ b/src/tools/qtcreatorcrashhandler/crashhandlersetup.cpp @@ -104,7 +104,7 @@ CrashHandlerSetup::CrashHandlerSetup(const QString &appName, disableRestartOptionC = "--disable-restart"; const QString execDirPath = executableDirPath.isEmpty() - ? qApp->applicationDirPath() + ? QCoreApplication::applicationDirPath() : executableDirPath; const QString crashHandlerPath = execDirPath + QLatin1String("/qtcreator_crash_handler"); crashHandlerPathC = qstrdup(qPrintable(crashHandlerPath)); diff --git a/src/tools/sdktool/main.cpp b/src/tools/sdktool/main.cpp index bf8e51972bc..0e5b4320fa6 100644 --- a/src/tools/sdktool/main.cpp +++ b/src/tools/sdktool/main.cpp @@ -69,7 +69,7 @@ const QString tabular(const Operation *o) void printHelp(const QList &operations) { std::cout << "Qt Creator SDK setup tool." << std::endl; - std::cout << " Usage: " << qPrintable(qApp->arguments().at(0)) + std::cout << " Usage: " << qPrintable(QCoreApplication::arguments().at(0)) << " " << std::endl << std::endl; std::cout << "ARGS:" << std::endl; std::cout << " --help|-h Print this help text" << std::endl; diff --git a/tests/auto/timeline/timelinezoomcontrol/tst_timelinezoomcontrol.cpp b/tests/auto/timeline/timelinezoomcontrol/tst_timelinezoomcontrol.cpp index d0844371542..9f35da6ada3 100644 --- a/tests/auto/timeline/timelinezoomcontrol/tst_timelinezoomcontrol.cpp +++ b/tests/auto/timeline/timelinezoomcontrol/tst_timelinezoomcontrol.cpp @@ -131,7 +131,7 @@ void tst_TimelineZoomControl::window() verifyWindow(zoomControl); zoomControl.setRange(102005, 102010); // make sure it doesn't overrun trace start } else if (zoomControl.windowStart() == zoomControl.traceStart()) { - qApp->exit(); + QCoreApplication::exit(); } else { QVERIFY(zoomControl.rangeStart() - zoomControl.windowStart() == zoomControl.windowEnd() - zoomControl.rangeEnd()); @@ -146,7 +146,7 @@ void tst_TimelineZoomControl::window() verifyWindow(zoomControl); }); - qApp->exec(); + QGuiApplication::exec(); disconnect(connection); diff --git a/tests/auto/valgrind/callgrind/modeltest.cpp b/tests/auto/valgrind/callgrind/modeltest.cpp index 94c0fd2dde3..c02b23bf6d6 100644 --- a/tests/auto/valgrind/callgrind/modeltest.cpp +++ b/tests/auto/valgrind/callgrind/modeltest.cpp @@ -103,7 +103,7 @@ ModelTestWidget::ModelTestWidget(CallgrindWidgetHandler *handler) connect(m_handler->flatView(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showViewContextMenu(QPoint))); - resize(qMin(qApp->desktop()->width(), 1024), 600); + resize(qMin(QApplication::desktop()->width(), 1024), 600); } ModelTestWidget::~ModelTestWidget() diff --git a/tests/manual/ssh/errorhandling/main.cpp b/tests/manual/ssh/errorhandling/main.cpp index 7aab5d0bc18..6f8c1f4bb4d 100644 --- a/tests/manual/ssh/errorhandling/main.cpp +++ b/tests/manual/ssh/errorhandling/main.cpp @@ -114,27 +114,27 @@ private: void handleConnected() { qDebug("Error: Received unexpected connected() signal."); - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } void handleDisconnected() { qDebug("Error: Received unexpected disconnected() signal."); - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } void handleDataAvailable(const QString &msg) { qDebug("Error: Received unexpected dataAvailable() signal. " "Message was: '%s'.", qPrintable(msg)); - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } void handleError(QSsh::SshError error) { if (m_testSet.isEmpty()) { qDebug("Error: Received error %d, but no test was running.", error); - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } const TestItem testItem = m_testSet.takeFirst(); @@ -142,13 +142,13 @@ private: qDebug("Received error %d, as expected.", error); if (m_testSet.isEmpty()) { qDebug("All tests finished successfully."); - qApp->quit(); + QCoreApplication::quit(); } else { runNextTest(); } } else { qDebug("Received unexpected error %d.", error); - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } } @@ -156,7 +156,7 @@ private: { if (m_testSet.isEmpty()) { qDebug("Error: timeout, but no test was running."); - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } const TestItem testItem = m_testSet.takeFirst(); qDebug("Error: The following test timed out: %s", testItem.description); diff --git a/tests/manual/ssh/remoteprocess/remoteprocesstest.cpp b/tests/manual/ssh/remoteprocess/remoteprocesstest.cpp index 062a974282b..28540768b8c 100644 --- a/tests/manual/ssh/remoteprocess/remoteprocesstest.cpp +++ b/tests/manual/ssh/remoteprocess/remoteprocesstest.cpp @@ -79,14 +79,14 @@ void RemoteProcessTest::handleConnectionError() ? m_sshConnection->errorString() : m_remoteRunner->lastConnectionErrorString(); std::cerr << "Error: Connection failure (" << qPrintable(error) << ")." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } void RemoteProcessTest::handleProcessStarted() { if (m_started) { std::cerr << "Error: Received started() signal again." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } else { m_started = true; if (m_state == TestingCrash) { @@ -107,11 +107,11 @@ void RemoteProcessTest::handleProcessStdout() if (!m_started) { std::cerr << "Error: Remote output from non-started process." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } else if (m_state != TestingSuccess && m_state != TestingTerminal) { std::cerr << "Error: Got remote standard output in state " << m_state << "." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } else { m_remoteStdout += m_remoteRunner->readAllStandardOutput(); } @@ -122,11 +122,11 @@ void RemoteProcessTest::handleProcessStderr() if (!m_started) { std::cerr << "Error: Remote error output from non-started process." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } else if (m_state == TestingSuccess) { std::cerr << "Error: Unexpected remote standard error output." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } else { m_remoteStderr += m_remoteRunner->readAllStandardError(); } @@ -138,7 +138,7 @@ void RemoteProcessTest::handleProcessClosed(int exitStatus) case SshRemoteProcess::NormalExit: if (!m_started) { std::cerr << "Error: Process exited without starting." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } switch (m_state) { @@ -147,13 +147,13 @@ void RemoteProcessTest::handleProcessClosed(int exitStatus) if (exitCode != 0) { std::cerr << "Error: exit code is " << exitCode << ", expected zero." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } if (m_remoteStdout.isEmpty()) { std::cerr << "Error: Command did not produce output." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } @@ -169,12 +169,12 @@ void RemoteProcessTest::handleProcessClosed(int exitStatus) if (exitCode == 0) { std::cerr << "Error: exit code is zero, expected non-zero." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } if (m_remoteStderr.isEmpty()) { std::cerr << "Error: Command did not produce error output." << std::flush; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } @@ -189,7 +189,7 @@ void RemoteProcessTest::handleProcessClosed(int exitStatus) if (m_remoteRunner->processExitCode() == 0) { std::cerr << "Error: Successful exit from process that was " "supposed to crash." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } else { // Some shells (e.g. mksh) don't report "killed", but just a non-zero exit code. handleSuccessfulCrashTest(); @@ -200,13 +200,13 @@ void RemoteProcessTest::handleProcessClosed(int exitStatus) if (exitCode != 0) { std::cerr << "Error: exit code is " << exitCode << ", expected zero." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } if (m_remoteStdout.isEmpty()) { std::cerr << "Error: Command did not produce output." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } std::cout << "Ok.\nTesting I/O device functionality... " << std::flush; @@ -224,7 +224,7 @@ void RemoteProcessTest::handleProcessClosed(int exitStatus) if (m_catProcess->exitCode() == 0) { std::cerr << "Error: Successful exit from process that was supposed to crash." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } else { handleSuccessfulIoTest(); } @@ -232,17 +232,17 @@ void RemoteProcessTest::handleProcessClosed(int exitStatus) case TestingProcessChannels: if (m_remoteStderr.isEmpty()) { std::cerr << "Error: Did not receive readyReadStderr()." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } if (m_remoteData != StderrOutput) { std::cerr << "Error: Expected output '" << StderrOutput.data() << "', received '" << m_remoteData.data() << "'." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } std::cout << "Ok.\nAll tests succeeded." << std::endl; - qApp->quit(); + QCoreApplication::quit(); break; case Inactive: Q_ASSERT(false); @@ -255,7 +255,7 @@ void RemoteProcessTest::handleProcessClosed(int exitStatus) } else { std::cerr << "Error: Process failed to start." << std::endl; } - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); break; case SshRemoteProcess::CrashExit: switch (m_state) { @@ -267,7 +267,7 @@ void RemoteProcessTest::handleProcessClosed(int exitStatus) break; default: std::cerr << "Error: Unexpected crash." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } } @@ -276,7 +276,7 @@ void RemoteProcessTest::handleProcessClosed(int exitStatus) void RemoteProcessTest::handleTimeout() { std::cerr << "Error: Timeout waiting for progress." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } void RemoteProcessTest::handleConnected() @@ -306,7 +306,7 @@ void RemoteProcessTest::handleReadyRead() if (data != testString()) { std::cerr << "Testing of QIODevice functionality failed: Expected '" << qPrintable(testString()) << "', got '" << qPrintable(data) << "'." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } SshRemoteProcessRunner * const killer = new SshRemoteProcessRunner(this); killer->run("pkill -9 cat", m_sshParams); @@ -326,7 +326,7 @@ void RemoteProcessTest::handleReadyReadStdout() Q_ASSERT(m_state == TestingProcessChannels); std::cerr << "Error: Received unexpected stdout data." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } void RemoteProcessTest::handleReadyReadStderr() diff --git a/tests/manual/ssh/sftp/sftptest.cpp b/tests/manual/ssh/sftp/sftptest.cpp index 40c3157fd0d..4b6b3133d34 100644 --- a/tests/manual/ssh/sftp/sftptest.cpp +++ b/tests/manual/ssh/sftp/sftptest.cpp @@ -105,7 +105,7 @@ void SftpTest::handleDisconnected() else std::cout << "No errors encountered."; std::cout << std::endl; - qApp->exit(m_error ? EXIT_FAILURE : EXIT_SUCCESS); + QCoreApplication::exit(m_error ? EXIT_FAILURE : EXIT_SUCCESS); } void SftpTest::handleError() @@ -114,7 +114,7 @@ void SftpTest::handleError() << qPrintable(m_connection->errorString()) << "." << std::endl; m_error = true; m_state = Disconnecting; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } void SftpTest::handleChannelInitialized() diff --git a/tests/manual/ssh/sftpfsmodel/window.cpp b/tests/manual/ssh/sftpfsmodel/window.cpp index 90e9906b14a..97f15974fef 100644 --- a/tests/manual/ssh/sftpfsmodel/window.cpp +++ b/tests/manual/ssh/sftpfsmodel/window.cpp @@ -114,5 +114,5 @@ void SftpFsWindow::handleConnectionError(const QString &errorMessage) { QMessageBox::warning(this, tr("Connection Error"), tr("Fatal SSH error: %1").arg(errorMessage)); - qApp->quit(); + QCoreApplication::quit(); } diff --git a/tests/manual/ssh/shell/shell.cpp b/tests/manual/ssh/shell/shell.cpp index c3997eed647..0bc30210541 100644 --- a/tests/manual/ssh/shell/shell.cpp +++ b/tests/manual/ssh/shell/shell.cpp @@ -56,7 +56,7 @@ void Shell::run() { if (!m_stdin->open(stdin, QIODevice::ReadOnly | QIODevice::Unbuffered)) { std::cerr << "Error: Cannot read from standard input." << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); return; } @@ -66,7 +66,7 @@ void Shell::run() void Shell::handleConnectionError() { std::cerr << "SSH connection error: " << qPrintable(m_connection->errorString()) << std::endl; - qApp->exit(EXIT_FAILURE); + QCoreApplication::exit(EXIT_FAILURE); } void Shell::handleShellMessage(const QString &message) @@ -106,7 +106,7 @@ void Shell::handleChannelClosed(int exitStatus) { std::cerr << "Shell closed. Exit status was " << exitStatus << ", exit code was " << m_shell->exitCode() << "." << std::endl; - qApp->exit(exitStatus == SshRemoteProcess::NormalExit && m_shell->exitCode() == 0 + QCoreApplication::exit(exitStatus == SshRemoteProcess::NormalExit && m_shell->exitCode() == 0 ? EXIT_SUCCESS : EXIT_FAILURE); }