From 26fbde67a7c708d6be84473f8fda9b696acc644c Mon Sep 17 00:00:00 2001 From: stv Date: Thu, 25 May 2006 09:17:00 +0000 Subject: [PATCH] no message --- src/STD/STD_Application.cxx | 6 +++++- src/SUIT/SUIT_ViewManager.cxx | 39 ++++++++++++++++++++++------------- src/SUIT/SUIT_ViewManager.h | 9 +++++--- src/SUIT/SUIT_ViewWindow.cxx | 2 +- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index 3e955e6c9..0b449d185 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -676,7 +676,8 @@ void STD_Application::removeViewManager( SUIT_ViewManager* vm ) emit viewManagerRemoved( vm ); vm->disconnectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); - vm->disconnect(); + disconnect( vm, SIGNAL( activated( SUIT_ViewManager* ) ), + this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) ); myViewMgrs.removeRef( vm ); if ( myActiveViewMgr == vm ) @@ -690,7 +691,10 @@ void STD_Application::clearViewManagers() viewManagers( lst ); for ( QPtrListIterator it( lst ); it.current(); ++it ) + { removeViewManager( it.current() ); + delete it.current(); + } } /*!\retval TRUE, if view manager \a vm, already in view manager list (\a myViewMgrs).*/ diff --git a/src/SUIT/SUIT_ViewManager.cxx b/src/SUIT/SUIT_ViewManager.cxx index 69288994b..6e7f58d41 100755 --- a/src/SUIT/SUIT_ViewManager.cxx +++ b/src/SUIT/SUIT_ViewManager.cxx @@ -131,7 +131,7 @@ bool SUIT_ViewManager::insertView(SUIT_ViewWindow* theView) } connect(theView, SIGNAL(closing(SUIT_ViewWindow*)), - this, SLOT(onDeleteView(SUIT_ViewWindow*))); + this, SLOT(onClosingView(SUIT_ViewWindow*))); connect(theView, SIGNAL(mousePressed(SUIT_ViewWindow*, QMouseEvent*)), this, SLOT(onMousePressed(SUIT_ViewWindow*, QMouseEvent*))); @@ -168,24 +168,37 @@ bool SUIT_ViewManager::insertView(SUIT_ViewWindow* theView) /*!Emit delete view. Remove view window \a theView from view manager. */ -void SUIT_ViewManager::onDeleteView(SUIT_ViewWindow* theView) +void SUIT_ViewManager::onClosingView( SUIT_ViewWindow* theView ) { - emit deleteView(theView); - removeView(theView); + closeView( theView ); +} + +/*! + Remove the view window \a theView from view manager and destroy it. +*/ +void SUIT_ViewManager::closeView( SUIT_ViewWindow* theView ) +{ + QGuardedPtr view( theView ); + + emit deleteView( view ); + removeView( view ); + + if ( view ) + delete view; } /*!Remove view window \a theView from view manager. *And close the last view, if it has \a theView. */ -void SUIT_ViewManager::removeView(SUIT_ViewWindow* theView) +void SUIT_ViewManager::removeView( SUIT_ViewWindow* theView ) { theView->disconnect(this); - myViews.remove(myViews.find(theView)); - if (myActiveView == theView) + myViews.remove( myViews.find( theView ) ); + if ( myActiveView == theView ) myActiveView = 0; int aNumItems = myViews.count(); - if (aNumItems == 0) - emit lastViewClosed(this); + if ( aNumItems == 0 ) + emit lastViewClosed( this ); } /*! @@ -223,11 +236,9 @@ void SUIT_ViewManager::onWindowActivated(SUIT_ViewWindow* view) */ void SUIT_ViewManager::closeAllViews() { - unsigned int aSize = myViews.size(); - for (uint i = 0; i < aSize; i++) { - if (myViews[i]) - myViews[i]->close(); - } + for ( uint i = 0; i < myViews.size(); i++ ) + delete myViews[i]; + myViews.clear(); } /*! diff --git a/src/SUIT/SUIT_ViewManager.h b/src/SUIT/SUIT_ViewManager.h index e0ca57fb2..915d7d28f 100755 --- a/src/SUIT/SUIT_ViewManager.h +++ b/src/SUIT/SUIT_ViewManager.h @@ -84,9 +84,9 @@ signals: void activated(SUIT_ViewManager*); protected slots: - void onWindowActivated(SUIT_ViewWindow*); - void onDeleteView(SUIT_ViewWindow* theView); - void onMousePressed(SUIT_ViewWindow* theView, QMouseEvent* theEvent); + void onWindowActivated( SUIT_ViewWindow* ); + void onClosingView( SUIT_ViewWindow* ); + void onMousePressed(SUIT_ViewWindow*, QMouseEvent* ); void onDeleteStudy(); private slots: @@ -100,6 +100,9 @@ protected: /*! Removes the View from internal Views Vector.*/ virtual void removeView(SUIT_ViewWindow* theView); + + /*! Close the specified View.*/ + virtual void closeView(SUIT_ViewWindow* theView); /*! Used to set unique name for the view.*/ virtual void setViewName(SUIT_ViewWindow* theView); diff --git a/src/SUIT/SUIT_ViewWindow.cxx b/src/SUIT/SUIT_ViewWindow.cxx index bd4c32e69..6496668d1 100755 --- a/src/SUIT/SUIT_ViewWindow.cxx +++ b/src/SUIT/SUIT_ViewWindow.cxx @@ -91,7 +91,7 @@ bool SUIT_ViewWindow::dumpViewToFormat( const QString& fileName, const QString& */ void SUIT_ViewWindow::closeEvent(QCloseEvent* theEvent) { - QMainWindow::closeEvent( theEvent ); +// QMainWindow::closeEvent( theEvent ); emit closing( this ); } -- 2.39.2