From: rkv Date: Thu, 24 Oct 2013 12:55:20 +0000 (+0000) Subject: Import image dialog is fixed: selection point in the reference image and crashes... X-Git-Tag: BR_hydro_v_0_3~87 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=41d3a5f489e8ec606523394f435e356fc607719b;p=modules%2Fhydro.git Import image dialog is fixed: selection point in the reference image and crashes on apply. --- diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx index 4251a04c..f326790d 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx @@ -54,7 +54,7 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); // Import image from file - myFileNameGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) ); + myFileNameGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ), this ); QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup ); @@ -72,7 +72,7 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co aFileNameLayout->addWidget( aBrowseBtn ); // Image name - myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ) ); + myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ), this ); QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), myImageNameGroup ); myImageName = new QLineEdit( myImageNameGroup ); @@ -84,7 +84,7 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co anImageNameLayout->addWidget( myImageName ); // Transform image - myTransformGroup = new QGroupBox( tr( "TRANSFORM_IMAGE" ) ); + myTransformGroup = new QGroupBox( tr( "TRANSFORM_IMAGE" ), this ); // Make a pixmap for arrow QPixmap anArrowPixmap = aResMgr->loadPixmap( "HYDRO", tr( "ARROW_RIGHT_ICO" ) ); @@ -108,7 +108,11 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co myRefImage = new QComboBox( myTransformGroup ); - QGridLayout* aModeLayout = new QGridLayout(); + QGridLayout* aTransformLayout = new QGridLayout( myTransformGroup ); + aTransformLayout->setMargin( 5 ); + aTransformLayout->setSpacing( 5 ); + + QGridLayout* aModeLayout = new QGridLayout( myTransformGroup ); aModeLayout->setMargin( 0 ); aModeLayout->setSpacing( 5 ); aModeLayout->addWidget( aManualCartesianBtn, 0, 0 ); @@ -117,15 +121,12 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co aModeLayout->addWidget( myRefImage, 2, 1 ); aModeLayout->setColumnStretch( 1, 1 ); - QGridLayout* aTransformLayout = new QGridLayout( myTransformGroup ); - aTransformLayout->setMargin( 5 ); - aTransformLayout->setSpacing( 5 ); aTransformLayout->addLayout( aModeLayout, 0, 0, 1, 9 ); QLabel* aImageCSLabel = new QLabel( tr( "IMAGE_CS" ), myTransformGroup ); - QLabel* aGeodesicLabel = new QLabel( "GEODESIC", myTransformGroup ); - QLabel* aLambertLabel = new QLabel( "LAMBERT93", myTransformGroup ); - QLabel* aRefImageLabel = new QLabel( "REFERENCE_IMAGE_CS", myTransformGroup ); + QLabel* aGeodesicLabel = new QLabel( tr( "GEODESIC" ), myTransformGroup ); + QLabel* aLambertLabel = new QLabel( tr( "LAMBERT93" ), myTransformGroup ); + QLabel* aRefImageLabel = new QLabel( tr( "REFERENCE_IMAGE_CS" ), myTransformGroup ); aTransformLayout->addWidget( aImageCSLabel, 2, 1 ); aTransformLayout->addWidget( aGeodesicLabel, 2, 3, 1, 6 ); @@ -308,9 +309,6 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co HYDROGUI_ImportImageDlg::~HYDROGUI_ImportImageDlg() { - delete myFileNameGroup; - delete myImageNameGroup; - delete myTransformGroup; } void HYDROGUI_ImportImageDlg::setIsEdit( const bool theIsEdit ) diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 6db63021..dabeaad1 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -496,7 +496,7 @@ void HYDROGUI_ImportImageOp::onRefImageActivated( const QString& theName ) { aViewPort = aViewer->getActiveViewPort(); connect( aViewer, SIGNAL( selectionChanged( GV_SelectionChangeStatus ) ), - this, SLOT( onPointSelected() ) ); + this, SLOT( onRefPointSelected() ) ); } } } @@ -564,6 +564,11 @@ void HYDROGUI_ImportImageOp::onPointSelected() onPointSelected( myRefPreviewPrs && myRefPreviewPrs->isSelected() ); } +void HYDROGUI_ImportImageOp::onRefPointSelected() +{ + onPointSelected( true ); +} + void HYDROGUI_ImportImageOp::onPointSelected( bool theIsRefImage ) { HYDROGUI_PrsImage* aPrs = theIsRefImage ? myRefPreviewPrs : myPreviewPrs; @@ -599,32 +604,37 @@ void HYDROGUI_ImportImageOp::closePreview() void HYDROGUI_ImportImageOp::closeView( GraphicsView_ViewManager* &aViewMgr ) { - // It's very strange, but without calling this method (it's quite safe) a crash is stably reproduced. - // Scenario: create any non-Graphics view, activate import op, click apply. - // Result: a few SIGSEGVs coming from processEvents(), then crash. if( aViewMgr ) { + GraphicsView_ViewPort* aViewPort = 0; if( GraphicsView_Viewer* aViewer = aViewMgr->getViewer() ) { - if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() ) - { - aViewPort->onBoundingRectChanged(); - } + aViewPort = aViewer->getActiveViewPort(); } disconnect( aViewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); // Nullify appropriate presentation pointer + HYDROGUI_PrsImage* aPrs; switch ( module()->getViewManagerRole( aViewMgr ) ) { case HYDROGUI_Module::VMR_ReferenceImage: + aPrs = myRefPreviewPrs; myRefPreviewPrs = 0; break; case HYDROGUI_Module::VMR_TransformImage: + aPrs = myPreviewPrs; myPreviewPrs = 0; } - // Delete the view and all its presentations + // Remove the appropriate presentation from the view + if( aPrs && aViewPort ) + { + aViewPort->removeItem( aPrs ); + delete aPrs; + } + + // Delete the view module()->getApp()->removeViewManager( aViewMgr ); // aViewMgr is deleted here aViewMgr = 0; } diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.h b/src/HYDROGUI/HYDROGUI_ImportImageOp.h index c931a9da..2a3ada8f 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.h @@ -62,6 +62,7 @@ protected slots: void onLastViewClosed( SUIT_ViewManager* ); void onPointSelected(); + void onRefPointSelected(); void onPointSelected( bool theIsRefImage ); private: diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 986dce2d..32edca35 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -396,7 +396,7 @@ void HYDROGUI_Module::update( const int flags ) // the selection in the object browser. // Note: processEvents() should be called after updateGV(), // otherwise the application crashes from time to time. - qApp->processEvents(); + //RKV: qApp->processEvents(); getApp()->updateObjectBrowser( true ); } diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index 0ab14c6b..d1655f3c 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -202,7 +202,7 @@ void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs, ::qobject_cast( aViewManager->getActiveView() ); if ( aViewWindow ) { - QApplication::processEvents(); //Process the draw events for viewer + //RKV: QApplication::processEvents(); //Process the draw events for viewer aViewWindow->onFitAll(); } }