From 49be1f497226825fee0de3d48108e73a8c18914d Mon Sep 17 00:00:00 2001 From: ouv Date: Tue, 1 Apr 2008 13:06:41 +0000 Subject: [PATCH] Bug IPAL19397 - Qt4 porting: the first string is incorrect after import in GUI python --- src/PyConsole/PyConsole_Editor.cxx | 21 ++++++++++++++------- src/PyInterp/PyInterp_Dispatcher.h | 5 +++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/PyConsole/PyConsole_Editor.cxx b/src/PyConsole/PyConsole_Editor.cxx index 5a4003178..fea5d6804 100644 --- a/src/PyConsole/PyConsole_Editor.cxx +++ b/src/PyConsole/PyConsole_Editor.cxx @@ -113,6 +113,8 @@ static QString READY_PROMPT = ">>> "; static QString DOTS_PROMPT = "... "; #define PROMPT_SIZE myPrompt.length() +#define PRINT_EVENT 65432 + /*! \class ExecCommand \brief Python command execution request. @@ -162,6 +164,8 @@ protected: */ virtual QEvent* createEvent() const { + if ( IsSync() ) + QCoreApplication::sendPostedEvents( listener(), PRINT_EVENT ); return new PyInterp_Event( myState, (PyInterp_Request*)this ); } @@ -176,8 +180,6 @@ private: \internal */ -#define PRINT_EVENT 65432 - class PrintEvent : public QEvent { public: @@ -377,6 +379,9 @@ void PyConsole_Editor::handleReturn() // add command to the history if ( !cmd.trimmed().isEmpty() ) myHistory.push_back( cmd ); + + // IPAL19397 + addText( "", true ); // set read-only mode setReadOnly( true ); @@ -910,8 +915,9 @@ void PyConsole_Editor::customEvent( QEvent* event ) QTextBlock par = document()->end().previous(); QString txt = par.text(); txt.truncate( txt.length() - 1 ); - if ( !txt.isEmpty() ) - addText( "", true ); + // IPAL19397 : addText moved to handleReturn() method + //if ( !txt.isEmpty() ) + // addText( "", true ); // set "ready" prompt myPrompt = READY_PROMPT; addText( myPrompt ); @@ -930,11 +936,12 @@ void PyConsole_Editor::customEvent( QEvent* event ) QTextBlock par = document()->end().previous(); QString txt = par.text(); txt.truncate( txt.length() - 1 ); - if ( !txt.isEmpty() ) - addText( "", true ); + // IPAL19397 : addText moved to handleReturn() method + //if ( !txt.isEmpty() ) + // addText( "", true ); // set "dot" prompt myPrompt = DOTS_PROMPT; - addText( myPrompt, true ); + addText( myPrompt/*, true*/ ); // IPAL19397 // unset busy cursor unsetCursor(); // stop event loop (if running) diff --git a/src/PyInterp/PyInterp_Dispatcher.h b/src/PyInterp/PyInterp_Dispatcher.h index 511fbbdb4..cf46694e4 100755 --- a/src/PyInterp/PyInterp_Dispatcher.h +++ b/src/PyInterp/PyInterp_Dispatcher.h @@ -69,11 +69,12 @@ protected: virtual void processEvent( QObject* ); -private: - void process(); QObject* listener() const { return myListener; } void setListener( QObject* ); +private: + void process(); + private: QMutex myMutex; bool myIsSync; -- 2.39.2