From c871a0d800a97d0b2fab6af02f7c8d167ec19c2d Mon Sep 17 00:00:00 2001 From: rnv Date: Fri, 17 Sep 2010 05:58:36 +0000 Subject: [PATCH] Fix for the bug 21947 WinTC5.1.4: Wrong error management of "Salome NoteBook". --- src/PyConsole/PyConsole_Console.cxx | 24 ++++++++++++++++++++ src/PyConsole/PyConsole_Console.h | 4 ++++ src/PyConsole/PyConsole_Editor.cxx | 30 +++++++++++++++++++++++-- src/PyConsole/PyConsole_Editor.h | 4 ++++ src/SalomeApp/SalomeApp_NoteBookDlg.cxx | 13 ++++++++++- 5 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/PyConsole/PyConsole_Console.cxx b/src/PyConsole/PyConsole_Console.cxx index fe29cafdb..565731b2b 100644 --- a/src/PyConsole/PyConsole_Console.cxx +++ b/src/PyConsole/PyConsole_Console.cxx @@ -128,6 +128,30 @@ void PyConsole_Console::setIsSync( const bool on ) myEditor->setIsSync( on ); } +/*! + \brief Get suppress output flag value. + + \sa setIsSuppressOutput() + \return True if python console output is suppressed. +*/ +bool PyConsole_Console::isSuppressOutput() const +{ + return myEditor->isSuppressOutput(); +} + +/*! + \brief Set suppress output flag value. + + In case if suppress output flag is true, the python + console output suppressed. + + \param on suppress output flag +*/ +void PyConsole_Console::setIsSuppressOutput( const bool on ) +{ + myEditor->setIsSuppressOutput(on); +} + /*! \brief Change the python console's font. \param f new font diff --git a/src/PyConsole/PyConsole_Console.h b/src/PyConsole/PyConsole_Console.h index 71dbf58a4..917f1af98 100644 --- a/src/PyConsole/PyConsole_Console.h +++ b/src/PyConsole/PyConsole_Console.h @@ -62,6 +62,10 @@ public: bool isSync() const; void setIsSync( const bool ); + bool isSuppressOutput() const; + void setIsSuppressOutput( const bool ); + + void exec( const QString& ); void execAndWait( const QString& ); diff --git a/src/PyConsole/PyConsole_Editor.cxx b/src/PyConsole/PyConsole_Editor.cxx index 6e0f9c9c5..141d560b2 100644 --- a/src/PyConsole/PyConsole_Editor.cxx +++ b/src/PyConsole/PyConsole_Editor.cxx @@ -201,7 +201,8 @@ private: void staticCallback( void* data, char* c ) { - QApplication::postEvent( (PyConsole_Editor*)data, new PrintEvent( c ) ); + if(!((PyConsole_Editor*)data)->isSuppressOutput()) + QApplication::postEvent( (PyConsole_Editor*)data, new PrintEvent( c ) ); } /*! @@ -217,7 +218,8 @@ PyConsole_Editor::PyConsole_Editor( PyConsole_Interp* theInterp, myInterp( 0 ), myCmdInHistory( -1 ), myEventLoop( 0 ), - myIsSync( false ) + myIsSync( false ), + myIsSuppressOutput(false) { QString fntSet( "" ); QFont aFont = SUIT_Tools::stringToFont( fntSet ); @@ -271,6 +273,30 @@ void PyConsole_Editor::setIsSync( const bool on ) myIsSync = on; } +/*! + \brief Get suppress output flag value. + + \sa setIsSuppressOutput() + \return True if python console output is suppressed. +*/ +bool PyConsole_Editor::isSuppressOutput() const +{ + return myIsSuppressOutput; +} + +/*! + \brief Set suppress output flag value. + + In case if suppress output flag is true, the python + console output suppressed. + + \param on suppress output flag +*/ +void PyConsole_Editor::setIsSuppressOutput( const bool on ) +{ + myIsSuppressOutput = on; +} + /*! \brief Put the string \a str to the python editor. \param str string to be put in the command line of the editor diff --git a/src/PyConsole/PyConsole_Editor.h b/src/PyConsole/PyConsole_Editor.h index e07b86179..a65cf5310 100644 --- a/src/PyConsole/PyConsole_Editor.h +++ b/src/PyConsole/PyConsole_Editor.h @@ -52,6 +52,9 @@ public: bool isSync() const; void setIsSync( const bool ); + bool isSuppressOutput() const; + void setIsSuppressOutput(const bool); + protected: virtual void dropEvent( QDropEvent* event ); virtual void mouseReleaseEvent( QMouseEvent* event ); @@ -79,6 +82,7 @@ private: QString myBanner; //!< current banner QStringList myQueue; //!< python commands queue bool myIsSync; //!< synchronous mode flag + bool myIsSuppressOutput; //!< suppress output flag }; #endif // PYCONSOLE_EDITOR_H diff --git a/src/SalomeApp/SalomeApp_NoteBookDlg.cxx b/src/SalomeApp/SalomeApp_NoteBookDlg.cxx index 061976175..9ab2640d2 100644 --- a/src/SalomeApp/SalomeApp_NoteBookDlg.cxx +++ b/src/SalomeApp/SalomeApp_NoteBookDlg.cxx @@ -301,7 +301,12 @@ bool NoteBook_TableRow::IsValidStringValue(const QString theValue) command += "\", "; } command += ") "; + + //rnv: fix for bug 21947 WinTC5.1.4: Wrong error management of "Salome NoteBook" + bool oldSuppressValue = pyConsole->isSuppressOutput(); + pyConsole->setIsSuppressOutput(true); bool aResult = pyInterp->run(command.c_str()); + pyConsole->setIsSuppressOutput(oldSuppressValue); return !aResult; } @@ -472,7 +477,13 @@ bool NoteBook_Table::IsValid() const command += "\","; } command += ")"; + + //rnv: fix for bug 21947 WinTC5.1.4: Wrong error management of "Salome NoteBook" + bool oldSuppressValue = pyConsole->isSuppressOutput(); + pyConsole->setIsSuppressOutput(true); bool aResult = pyInterp->run(command.c_str()); + pyConsole->setIsSuppressOutput(oldSuppressValue); + return !aResult; } @@ -481,7 +492,7 @@ bool NoteBook_Table::IsValid() const * Purpose : renumber row items */ //============================================================================ -void NoteBook_Table::RenamberRowItems(){ +void NoteBook_Table::RenamberRowItems() { for(int i=0; iGetHeaderItem()->setText(QString::number(i+1)); } -- 2.39.2