Gui: fixes #10617: Ctrl+C only stop python running in console not from macros

This commit handles the execution from the Python editor
This commit is contained in:
wmayer
2023-09-09 14:19:00 +02:00
parent ab3878ad97
commit ccfda42dfb
2 changed files with 11 additions and 1 deletions

View File

@@ -50,6 +50,8 @@
#include "Macro.h"
#include "MainWindow.h"
#include "PythonEditor.h"
#include "PythonTracing.h"
#include "WaitCursor.h"
#include <Base/Exception.h>
#include <Base/Interpreter.h>
@@ -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&) {

View File

@@ -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