From c023be897bbf7ddae9c968a71bc36972e398ff4d Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Fri, 15 Nov 2019 12:44:01 +0100 Subject: [PATCH] fix abort on exex python script with progress indicator. Qt display was sometimes invoqued from a different thread than the main thread --- src/HYDROData/HYDROData_CalculationCase.cxx | 8 ++++++-- src/HYDROGUI/HYDROGUI_SIProgressIndicator.cxx | 7 ++++--- src/HYDROGUI/HYDROGUI_ZIProgressIndicator.cxx | 7 ++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 9e79b797..adaeee14 100755 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -1080,7 +1080,7 @@ NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( NCollection_Sequence aResSeq; Handle(Message_ProgressIndicator) aZIProgress = HYDROData_Tool::GetZIProgress(); - //DEBTRACE("aZIProgress=" << aZIProgress); + DEBTRACE("aZIProgress before running"); if ( aZIProgress ) { aZIProgress->Reset(); } @@ -1104,7 +1104,7 @@ NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( QThread::msleep(200); } } - //DEBTRACE("aZIProgress=" << aZIProgress); + DEBTRACE("ZI running finished"); if ( aZIProgress ) aZIProgress->Show( Standard_True ); @@ -1155,6 +1155,7 @@ std::vector HYDROData_CalculationCase::GetStricklerCoefficientForPoints( return theCoeffs; Handle(Message_ProgressIndicator) aSIProgress = HYDROData_Tool::GetSIProgress(); + DEBTRACE("aSIProgress before running"); if ( aSIProgress ) { aSIProgress->Reset(); } @@ -1169,6 +1170,9 @@ std::vector HYDROData_CalculationCase::GetStricklerCoefficientForPoints( QThread::msleep(200); } } + DEBTRACE("SI running finished"); + if ( aSIProgress ) + aSIProgress->Show( Standard_True ); return theCoeffs; } diff --git a/src/HYDROGUI/HYDROGUI_SIProgressIndicator.cxx b/src/HYDROGUI/HYDROGUI_SIProgressIndicator.cxx index 2a85c663..f5ce6109 100755 --- a/src/HYDROGUI/HYDROGUI_SIProgressIndicator.cxx +++ b/src/HYDROGUI/HYDROGUI_SIProgressIndicator.cxx @@ -21,7 +21,7 @@ #include #include #include -#define _DEVDEBUG_ +//#define _DEVDEBUG_ #include "HYDRO_trace.hxx" IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_SIProgressIndicator, Message_ProgressIndicator) @@ -50,6 +50,7 @@ HYDROGUI_SIProgressIndicator::~HYDROGUI_SIProgressIndicator() Standard_Boolean HYDROGUI_SIProgressIndicator::Show(const Standard_Boolean theForce) { + //DEBTRACE("..."); Standard_Real aPosition = GetPosition(); myCount++; if (theForce) @@ -57,11 +58,11 @@ Standard_Boolean HYDROGUI_SIProgressIndicator::Show(const Standard_Boolean theFo Standard_Boolean isUserBreak = UserBreak(); bool isFinished = aPosition >= 1 || ( isUserBreak && GetNbScopes() < 2 ); - if ( isFinished ) { + if ( isFinished && theForce ) { // theForce == true : call from main thread, Qt display safe if ( result() != Accepted ) { QDialog::accept(); } - } else if (!isVisible()) { + } else if (!isVisible() && theForce) { // theForce == true : call from main thread, Qt display safe open(); } diff --git a/src/HYDROGUI/HYDROGUI_ZIProgressIndicator.cxx b/src/HYDROGUI/HYDROGUI_ZIProgressIndicator.cxx index b19674e3..0b90ff6f 100755 --- a/src/HYDROGUI/HYDROGUI_ZIProgressIndicator.cxx +++ b/src/HYDROGUI/HYDROGUI_ZIProgressIndicator.cxx @@ -25,7 +25,7 @@ #include #include #include -#define _DEVDEBUG_ +//#define _DEVDEBUG_ #include "HYDRO_trace.hxx" IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_ZIProgressIndicator, Message_ProgressIndicator) @@ -66,6 +66,7 @@ HYDROGUI_ZIProgressIndicator::~HYDROGUI_ZIProgressIndicator() Standard_Boolean HYDROGUI_ZIProgressIndicator::Show(const Standard_Boolean theForce) { + //DEBTRACE("..."); Standard_Boolean isUserBreak = UserBreak(); Standard_Real aPosition = GetPosition(); myCount++; @@ -100,11 +101,11 @@ Standard_Boolean HYDROGUI_ZIProgressIndicator::Show(const Standard_Boolean theFo } bool isFinished = aPosition >= 1 || ( isUserBreak && GetNbScopes() < 2 ); - if ( isFinished ) { + if ( isFinished && theForce ) { // theForce == true : call from main thread, Qt display safe if ( result() != Accepted ) { QDialog::accept(); } - } else if ( !isVisible() ) { + } else if ( !isVisible() && theForce ) { // theForce == true : call from main thread, Qt display safe open(); } -- 2.39.2