From ccfda42dfb4f6f8b0c30b6d46270cbaca40b6707 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 9 Sep 2023 14:19:00 +0200 Subject: [PATCH] Gui: fixes #10617: Ctrl+C only stop python running in console not from macros This commit handles the execution from the Python editor --- src/Gui/EditorView.cpp | 10 +++++++++- src/Gui/EditorView.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Gui/EditorView.cpp b/src/Gui/EditorView.cpp index 3fc09cf801..cf031d0f61 100644 --- a/src/Gui/EditorView.cpp +++ b/src/Gui/EditorView.cpp @@ -50,6 +50,8 @@ #include "Macro.h" #include "MainWindow.h" #include "PythonEditor.h" +#include "PythonTracing.h" +#include "WaitCursor.h" #include #include @@ -596,9 +598,13 @@ PythonEditorView::PythonEditorView(PythonEditor* editor, QWidget* parent) { connect(this, &PythonEditorView::changeFileName, editor, &PythonEditor::setFileName); + watcher = new PythonTracingWatcher(this); } -PythonEditorView::~PythonEditorView() = default; +PythonEditorView::~PythonEditorView() +{ + delete watcher; +} /** * Runs the action specified by \a pMsg. @@ -644,6 +650,8 @@ void PythonEditorView::executeScript() if (EditorView::onHasMsg("Save")) EditorView::onMsg("Save", nullptr); try { + WaitCursor wc; + PythonTracingLocker tracelock(watcher->getTrace()); Application::Instance->macroManager()->run(Gui::MacroManager::File,fileName().toUtf8()); } catch (const Base::SystemExitException&) { diff --git a/src/Gui/EditorView.h b/src/Gui/EditorView.h index 3a09321fb0..8546a94397 100644 --- a/src/Gui/EditorView.h +++ b/src/Gui/EditorView.h @@ -41,6 +41,7 @@ namespace Gui { class EditorViewP; class TextEdit; +class PythonTracingWatcher; /** * A special view class which sends the messages from the application to @@ -140,6 +141,7 @@ public Q_SLOTS: private: PythonEditor* _pye; + PythonTracingWatcher* watcher; }; class SearchBar : public QWidget