diff --git a/src/plugins/python/pyside.cpp b/src/plugins/python/pyside.cpp index 5dfa1065a15..6965305f2e6 100644 --- a/src/plugins/python/pyside.cpp +++ b/src/plugins/python/pyside.cpp @@ -60,16 +60,16 @@ PySideInstaller *PySideInstaller::instance() return instance; } -void PySideInstaller::checkPySideInstallation(const Utils::FilePath &python, +void PySideInstaller::checkPySideInstallation(const FilePath &python, TextEditor::TextDocument *document) { document->infoBar()->removeInfo(installPySideInfoBarId); const QString pySide = importedPySide(document->plainText()); if (pySide == "PySide2" || pySide == "PySide6") - runPySideChecker(python, pySide, document); + instance()->runPySideChecker(python, pySide, document); } -bool PySideInstaller::missingPySideInstallation(const Utils::FilePath &pythonPath, +bool PySideInstaller::missingPySideInstallation(const FilePath &pythonPath, const QString &pySide) { QTC_ASSERT(!pySide.isEmpty(), return false); @@ -78,8 +78,7 @@ bool PySideInstaller::missingPySideInstallation(const Utils::FilePath &pythonPat return false; QtcProcess pythonProcess; - const CommandLine importPySideCheck(pythonPath, {"-c", "import " + pySide}); - pythonProcess.setCommand(importPySideCheck); + pythonProcess.setCommand({pythonPath, {"-c", "import " + pySide}}); pythonProcess.runBlocking(); const bool missing = pythonProcess.result() != ProcessResult::FinishedWithSuccess; if (!missing) diff --git a/src/plugins/python/pyside.h b/src/plugins/python/pyside.h index c440ca34240..5df33f31bb1 100644 --- a/src/plugins/python/pyside.h +++ b/src/plugins/python/pyside.h @@ -40,9 +40,11 @@ namespace Internal { class PySideInstaller : public QObject { Q_DECLARE_TR_FUNCTIONS(Python::Internal::PySideInstaller) + public: static PySideInstaller *instance(); - void checkPySideInstallation(const Utils::FilePath &python, TextEditor::TextDocument *document); + static void checkPySideInstallation(const Utils::FilePath &python, + TextEditor::TextDocument *document); private: PySideInstaller(); diff --git a/src/plugins/python/pythoneditor.cpp b/src/plugins/python/pythoneditor.cpp index 6344e52f9b0..562f69f5d72 100644 --- a/src/plugins/python/pythoneditor.cpp +++ b/src/plugins/python/pythoneditor.cpp @@ -118,8 +118,8 @@ public: if (!python.exists()) return; - PyLSConfigureAssistant::instance()->openDocumentWithPython(python, this); - PySideInstaller::instance()->checkPySideInstallation(python, this); + PyLSConfigureAssistant::openDocumentWithPython(python, this); + PySideInstaller::checkPySideInstallation(python, this); } }; diff --git a/src/plugins/python/pythonlanguageclient.cpp b/src/plugins/python/pythonlanguageclient.cpp index bf131a73c1f..76e6fc2cb37 100644 --- a/src/plugins/python/pythonlanguageclient.cpp +++ b/src/plugins/python/pythonlanguageclient.cpp @@ -614,7 +614,7 @@ void PyLSConfigureAssistant::openDocumentWithPython(const FilePath &python, QPointer watcher = new CheckPylsWatcher(); // cancel and delete watcher after a 10 second timeout - QTimer::singleShot(10000, this, [watcher]() { + QTimer::singleShot(10000, instance(), [watcher]() { if (watcher) { watcher->cancel(); watcher->deleteLater(); @@ -623,11 +623,11 @@ void PyLSConfigureAssistant::openDocumentWithPython(const FilePath &python, connect(watcher, &CheckPylsWatcher::resultReadyAt, - this, + instance(), [=, document = QPointer(document)]() { if (!document || !watcher) return; - handlePyLSState(python, watcher->result(), document); + instance()->handlePyLSState(python, watcher->result(), document); watcher->deleteLater(); }); watcher->setFuture(Utils::runAsync(&checkPythonLanguageServer, python)); diff --git a/src/plugins/python/pythonlanguageclient.h b/src/plugins/python/pythonlanguageclient.h index 645583a2374..4109fd4a8cd 100644 --- a/src/plugins/python/pythonlanguageclient.h +++ b/src/plugins/python/pythonlanguageclient.h @@ -71,9 +71,11 @@ public: static const LanguageClient::StdIOSettings *languageServerForPython( const Utils::FilePath &python); - static void updateEditorInfoBars(const Utils::FilePath &python, LanguageClient::Client *client); - void openDocumentWithPython(const Utils::FilePath &python, TextEditor::TextDocument *document); + static void updateEditorInfoBars(const Utils::FilePath &python, + LanguageClient::Client *client); + static void openDocumentWithPython(const Utils::FilePath &python, + TextEditor::TextDocument *document); private: explicit PyLSConfigureAssistant(QObject *parent); diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp index 6087ce77d80..e3a100486d6 100644 --- a/src/plugins/python/pythonrunconfiguration.cpp +++ b/src/plugins/python/pythonrunconfiguration.cpp @@ -152,8 +152,8 @@ public: for (FilePath &file : project()->files(Project::AllFiles)) { if (auto document = TextEditor::TextDocument::textDocumentForFilePath(file)) { if (document->mimeType() == Constants::C_PY_MIMETYPE) { - PyLSConfigureAssistant::instance()->openDocumentWithPython(python, document); - PySideInstaller::instance()->checkPySideInstallation(python, document); + PyLSConfigureAssistant::openDocumentWithPython(python, document); + PySideInstaller::checkPySideInstallation(python, document); } } }