]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
fix bug abort on import image, several random cases related to using already deleted...
authorPaul RASCLE <paul.rascle@openfields.fr>
Mon, 12 Oct 2020 07:43:08 +0000 (09:43 +0200)
committerYOANN AUDOUIN <B61570@dsp0851742.postes.calibre.edf.fr>
Fri, 30 Oct 2020 16:09:38 +0000 (17:09 +0100)
src/HYDROGUI/HYDROGUI_Displayer.cxx
src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx
src/HYDROGUI/HYDROGUI_ImportImageOp.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_PrsImage.cxx

index c869d87c2c33e5b6796a4a7ba6a9dbaa7e0bebca..adf3c87d2e44791b2d23b45511192d5537e22bb2 100644 (file)
@@ -42,6 +42,9 @@
 #include <GraphicsView_Viewer.h>
 #include <GraphicsView_ViewPort.h>
 
+#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
+
 const double LOCAL_SELECTION_TOLERANCE = 0.0001;
 
 HYDROGUI_Displayer::HYDROGUI_Displayer( HYDROGUI_Module* theModule )
@@ -156,7 +159,10 @@ void HYDROGUI_Displayer::Display( const HYDROData_SequenceOfObjects& theObjs,
       if( HYDROGUI_PrsDriver* aDriver = getDriver( anObj ) )
       {
         if( aDriver->Update( anObj, aPrs ) && aPrs && !anIsInserted )
+        {
+          DEBTRACE("Display, addItem");
           aViewPort->addItem( aPrs );
+        }
       }
     }
 
@@ -176,6 +182,7 @@ void HYDROGUI_Displayer::Display( const HYDROData_SequenceOfObjects& theObjs,
 
 void HYDROGUI_Displayer::purgeObjects( const size_t theViewerId )
 {
+  DEBTRACE("purgeObjects");
   GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
   if( !aViewer )
     return;
@@ -192,6 +199,7 @@ void HYDROGUI_Displayer::purgeObjects( const size_t theViewerId )
       Handle(HYDROData_Entity) anObject = aPrs->getObject();
       if( !anObject.IsNull() && anObject->IsRemoved() )
       {
+        DEBTRACE("removeItem");
         aViewPort->removeItem( aPrs );
         delete aPrs;
       }
index e238f569d7ca9a023e561c7cbe652399b6dd93d2..4922ee13fd3bda04ffb4ebb060f3681ab38f5356 100644 (file)
@@ -1042,7 +1042,7 @@ void HYDROGUI_ImportImageDlg::clearSpins( QAbstractSpinBox* theSpin )
     QtxIntSpinBox* aSpin = dynamic_cast<QtxIntSpinBox*>( theSpin );
     aSpin->setValue( aSpin->minimum() );
   }
-  else if ( dynamic_cast<QtxIntSpinBox*>( theSpin ) )
+  else if ( dynamic_cast<QtxDoubleSpinBox*>( theSpin ) )
   {
     QtxDoubleSpinBox* aDblSpin = dynamic_cast<QtxDoubleSpinBox*>( theSpin );
     aDblSpin->setValue( aDblSpin->minimum() );
index eef9bd9a7a4dc810fff8fbc9e7962e50ea98dd41..5b16a0e4dccdabd3f069ad3902a71fcfe92bae4c 100644 (file)
@@ -43,6 +43,9 @@
 #include <QApplication>
 #include <QFileInfo>
 
+#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
+
 HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule,
                                                 const bool theIsEdit )
 : HYDROGUI_Operation( theModule ),
@@ -55,17 +58,27 @@ HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule,
   myRefPreviewPrs( 0 ),
   myPointType( HYDROGUI_PrsImage::None )
 {
+  DEBTRACE("HYDROGUI_ImportImageOp");
   setName( theIsEdit ? tr( "EDIT_IMPORTED_IMAGE" ) : tr( "IMPORT_IMAGE" ) );
 }
 
 HYDROGUI_ImportImageOp::~HYDROGUI_ImportImageOp()
 {
+  DEBTRACE("~HYDROGUI_ImportImageOp");
 }
 
 void HYDROGUI_ImportImageOp::startOperation()
 {
+  DEBTRACE("startOperation");
   HYDROGUI_Operation::startOperation();
 
+  myEditedObject = 0;
+  myActiveViewManager = 0;
+  myPreviewViewManager = 0;
+  myRefViewManager = 0;
+  myPreviewPrs = 0;
+  myRefPreviewPrs = 0;
+  myPointType = HYDROGUI_PrsImage::None;
   HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
   aPanel->reset();
   aPanel->setIsEdit( myIsEdit );
@@ -177,6 +190,7 @@ void HYDROGUI_ImportImageOp::setPresentationTrsfPoints( HYDROGUI_PrsImage* thePr
                                                         const QPoint theLocalPointB, 
                                                         const QPoint theLocalPointC )
 {
+  DEBTRACE("setPresentationTrsfPoints");
   // Set transformation points A,B,C to the image presentation
   if( thePrs )
   {
@@ -198,6 +212,7 @@ void HYDROGUI_ImportImageOp::setPresentationTrsfPoints( HYDROGUI_PrsImage* thePr
 void HYDROGUI_ImportImageOp::getReferenceDataList(
                         HYDROGUI_ImportImageDlg::PrsPointDataList& theList ) const
 {
+  DEBTRACE("getReferenceDataList");
   // Collect information about existing images and initialize the combobox 
   // reference image selector in the dialog.
   HYDROData_Iterator anIterator( doc(), KIND_IMAGE );
@@ -237,6 +252,7 @@ void HYDROGUI_ImportImageOp::computeTrsfData( HYDROData_Image::TransformationMod
                                               const QPointF& theGlobalPointC,
                                               HYDROGUI_ImportImageDlg::TransformationDataMap& theDataMap ) const
 {
+  DEBTRACE("computeTrsfData");
   // Build the local-global points map
   HYDROGUI_ImportImageDlg::TransformationDataMap aDataMap;
   theDataMap[ HYDROGUI_PrsImage::PointA ] = 
@@ -252,13 +268,14 @@ void HYDROGUI_ImportImageOp::computeTrsfData( HYDROData_Image::TransformationMod
 
 void HYDROGUI_ImportImageOp::abortOperation()
 {
+  DEBTRACE("abortOperation");
   closePreview();
-
   HYDROGUI_Operation::abortOperation();
 }
 
 void HYDROGUI_ImportImageOp::commitOperation()
 {
+  DEBTRACE("commitOperation");
   if ( isApplyAndClose() )
     closePreview();
 
@@ -267,6 +284,7 @@ void HYDROGUI_ImportImageOp::commitOperation()
 
 HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const
 {
+  DEBTRACE("createInputPanel");
   HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportImageDlg( module(), getName() );
   connect( aPanel, SIGNAL( createPreview( QImage, HYDROData_Image::ECW_FileInfo* ) ), 
     SLOT( onCreatePreview( QImage, HYDROData_Image::ECW_FileInfo* ) ) );
@@ -284,6 +302,7 @@ HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const
 
 void HYDROGUI_ImportImageOp::onSetCIsUsed( bool theCIsUsed )
 {
+  DEBTRACE("onSetCIsUsed");
   if ( myPreviewPrs )
   {
     myPreviewPrs->setIsByTwoPoints( !theCIsUsed );
@@ -303,6 +322,7 @@ bool HYDROGUI_ImportImageOp::checkPoints( const QPointF& thePointA,
                                           QString&       theErrorMsg,
                                           const bool     theIsToCheckInvertibles ) const
 {
+  DEBTRACE("checkPoints");
   double xa = thePointA.x();
   double ya = thePointA.y();
   double xb = thePointB.x();
@@ -349,6 +369,7 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags,
                                            QString& theErrorMsg,
                                            QStringList& theBrowseObjectsEntries )
 {
+  DEBTRACE("processApply");
   HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
 
   if( !myIsEdit )
@@ -512,7 +533,10 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags,
    
   // must be done after all checks and before calling SetVisible() method below
   if ( isApplyAndClose() )
+  {
+    DEBTRACE("closePreview");
     closePreview();
+  }
 
   if( !myIsEdit )
     module()->setObjectVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), anImageObj, true );
@@ -545,6 +569,7 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags,
 
 bool HYDROGUI_ImportImageOp::isReferenceCorrect() const
 {
+  DEBTRACE("isReferenceCorrect");
   bool isCorrect = true;
 
   if( myIsEdit && !myEditedObject.IsNull() )
@@ -569,6 +594,7 @@ bool HYDROGUI_ImportImageOp::isReferenceCorrect() const
 
 void HYDROGUI_ImportImageOp::apply()
 {
+  DEBTRACE("apply");
   HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
 
   bool aCanApply = isReferenceCorrect();
@@ -592,6 +618,7 @@ void HYDROGUI_ImportImageOp::apply()
 
 void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage, HYDROData_Image::ECW_FileInfo* theFileInfo )
 {
+  DEBTRACE("onCreatePreview");
   HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
 
   myImage = theImage;
@@ -699,6 +726,7 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage, HYDROData_Image::
 
 void HYDROGUI_ImportImageOp::onActivatePointSelection( int thePointType )
 {
+  DEBTRACE("onActivatePointSelection");
   myPointType = thePointType;
   if( myPreviewPrs )
     myPreviewPrs->setTransformationPointType( thePointType );
@@ -711,6 +739,7 @@ void HYDROGUI_ImportImageOp::onPointCoordChanged( bool theIsRef,
                                                   bool theIsY,
                                                   int theValue )
 {
+  DEBTRACE("onPointCoordChanged");
   if( !theIsRef && myPreviewPrs )
     myPreviewPrs->updateTransformationPoint( thePointType, theIsY, theValue );
   else if( theIsRef && myRefPreviewPrs )
@@ -719,6 +748,7 @@ void HYDROGUI_ImportImageOp::onPointCoordChanged( bool theIsRef,
 
 void HYDROGUI_ImportImageOp::onModeActivated( int theMode )
 {
+  DEBTRACE("onModeActivated");
   HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel();
 
   QString aRefImageName;
@@ -740,6 +770,7 @@ void HYDROGUI_ImportImageOp::onModeActivated( int theMode )
 
 void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName )
 {
+  DEBTRACE("onRefImageActivated");
   if( theName.isEmpty() ) {
     if( myRefViewManager )
       closeView( myRefViewManager );
@@ -842,21 +873,25 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName )
 
 void HYDROGUI_ImportImageOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
 {
+  DEBTRACE("onLastViewClosed");
   closePreview();
 }
 
 void HYDROGUI_ImportImageOp::onPointSelected()
 {
+  DEBTRACE("onPointSelected");
   onPointSelected( myRefPreviewPrs && myRefPreviewPrs->isSelected() );
 }
 
 void HYDROGUI_ImportImageOp::onRefPointSelected()
 {
+  DEBTRACE("onRefPointSelected");
   onPointSelected( true );
 }
 
 void HYDROGUI_ImportImageOp::onPointSelected( bool theIsRefImage )
 {
+  DEBTRACE("onPointSelected");
   HYDROGUI_PrsImage* aPrs = theIsRefImage ? myRefPreviewPrs : myPreviewPrs;
   if( !aPrs )
     return;
@@ -882,6 +917,7 @@ void HYDROGUI_ImportImageOp::onPointSelected( bool theIsRefImage )
 
 void HYDROGUI_ImportImageOp::closePreview()
 {
+  DEBTRACE("closePreview");
   closeView( myPreviewViewManager );
   closeView( myRefViewManager );
 
@@ -891,6 +927,7 @@ void HYDROGUI_ImportImageOp::closePreview()
 
 void HYDROGUI_ImportImageOp::closeView( GraphicsView_ViewManager* &aViewMgr )
 {
+  DEBTRACE("closeView");
   if( aViewMgr )
   {
     GraphicsView_ViewPort* aViewPort = 0;
@@ -915,9 +952,12 @@ void HYDROGUI_ImportImageOp::closeView( GraphicsView_ViewManager* &aViewMgr )
     }
 
     // Remove the appropriate presentation from the view
-    if( aPrs && aViewPort )
+    if( aPrs )
     {
-      aViewPort->removeItem( aPrs );
+      if( aViewPort )
+      {
+        aViewPort->removeItem( aPrs );
+      }
       delete aPrs;
     }
 
@@ -929,6 +969,7 @@ void HYDROGUI_ImportImageOp::closeView( GraphicsView_ViewManager* &aViewMgr )
 
 void HYDROGUI_ImportImageOp::onFilesSelected( const QStringList& theFileNames )
 {
+  DEBTRACE("onFilesSelected");
   myFiles = theFileNames;
   myFileIndex = -1;
   SetNextFile();
@@ -936,6 +977,7 @@ void HYDROGUI_ImportImageOp::onFilesSelected( const QStringList& theFileNames )
 
 bool HYDROGUI_ImportImageOp::SetNextFile()
 {
+  DEBTRACE("SetNextFile");
   myFileIndex++;
   bool isEnabledEdit = myFiles.count()==1 || myFileIndex==myFiles.count();
   bool isValid = ( myFileIndex>=0 && myFileIndex<myFiles.count() );
index df571a98642342c27b48c2f627638087ca18641f..de2759598dbbeae50e8addd67b9ef23f7d431e5d 100755 (executable)
 #include <QStatusBar>
 #include <QCursor>
 
-//#define _DEVDEBUG_
+#define _DEVDEBUG_
 #include "HYDRO_trace.hxx"
 
 static size_t ViewManagerId = 1;
index a146d2546623de999c861b0680b62181e5f2fd8b..6a5fe4a12534e72d6a9d58d0b2cd3a9e86fa931d 100644 (file)
@@ -25,6 +25,9 @@
 #include <QCursor>
 #include <QApplication>
 
+#define _DEVDEBUG_
+#include "HYDRO_trace.hxx"
+
 //=======================================================================
 // name    : HYDROGUI_PrsImage
 // Purpose : Constructor
@@ -38,6 +41,7 @@ HYDROGUI_PrsImage::HYDROGUI_PrsImage( const Handle(HYDROData_Entity)& theObject
   myIsByTwoPoints( true ),
   myTransformationPointType( None )
 {
+  DEBTRACE("HYDROGUI_PrsImage");
   myTransformationPointCursor = new QCursor( Qt::CrossCursor );
 }
 
@@ -47,6 +51,7 @@ HYDROGUI_PrsImage::HYDROGUI_PrsImage( const Handle(HYDROData_Entity)& theObject
 //=======================================================================
 HYDROGUI_PrsImage::~HYDROGUI_PrsImage()
 {
+  DEBTRACE("~HYDROGUI_PrsImage");
   if( myTransformationPointCursor )
   {
     delete myTransformationPointCursor;