Commit 394546f1 authored by Robert Knight's avatar Robert Knight

Use a guarded pointer to reference active controller in main window - fixes...

Use a guarded pointer to reference active controller in main window - fixes crash in case there is no active view/session.  Make the view manager responsible for setting up the destruction of the controller instead of the controller itself.

svn path=/branches/work/konsole-split-view/; revision=657026
parent f6fa6fc0
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#ifndef KONSOLEMAINWINDOW_H #ifndef KONSOLEMAINWINDOW_H
#define KONSOLEMAINWINDOW_H #define KONSOLEMAINWINDOW_H
// Qt
#include <QPointer>
// KDE
#include <KXmlGuiWindow> #include <KXmlGuiWindow>
namespace Konsole namespace Konsole
...@@ -111,7 +115,7 @@ class MainWindow : public KXmlGuiWindow ...@@ -111,7 +115,7 @@ class MainWindow : public KXmlGuiWindow
ViewManager* _viewManager; ViewManager* _viewManager;
BookmarkHandler* _bookmarkHandler; BookmarkHandler* _bookmarkHandler;
IncrementalSearchBar* _searchBar; IncrementalSearchBar* _searchBar;
SessionController* _pluggedController; QPointer<SessionController> _pluggedController;
}; };
}; };
......
...@@ -55,10 +55,6 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q ...@@ -55,10 +55,6 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q
view->installEventFilter(this); view->installEventFilter(this);
// destroy session controller if either the view or the session are destroyed
connect( _session , SIGNAL(destroyed()) , this , SLOT(deleteLater()) );
connect( _view , SIGNAL(destroyed()) , this , SLOT(deleteLater()) );
// listen for popup menu requests // listen for popup menu requests
connect( _view , SIGNAL(configureRequest(TerminalDisplay*,int,int,int)) , this, connect( _view , SIGNAL(configureRequest(TerminalDisplay*,int,int,int)) , this,
SLOT(showDisplayContextMenu(TerminalDisplay*,int,int,int)) ); SLOT(showDisplayContextMenu(TerminalDisplay*,int,int,int)) );
......
...@@ -52,7 +52,6 @@ using namespace Konsole; ...@@ -52,7 +52,6 @@ using namespace Konsole;
ViewContainer::~ViewContainer() ViewContainer::~ViewContainer()
{ {
emit destroyed(this); emit destroyed(this);
} }
void ViewContainer::addView(QWidget* view , ViewProperties* item) void ViewContainer::addView(QWidget* view , ViewProperties* item)
{ {
......
...@@ -313,8 +313,11 @@ void ViewManager::splitView(Qt::Orientation orientation) ...@@ -313,8 +313,11 @@ void ViewManager::splitView(Qt::Orientation orientation)
void ViewManager::closeActiveView() void ViewManager::closeActiveView()
{ {
ViewContainer* container = _viewSplitter->activeContainer(); ViewContainer* container = _viewSplitter->activeContainer();
delete container; delete container;
// focus next container so that user can continue typing
// without having to manually focus it themselves
nextContainer();
} }
void ViewManager::closeOtherViews() void ViewManager::closeOtherViews()
{ {
...@@ -335,7 +338,9 @@ SessionController* ViewManager::createController(Session* session , TerminalDisp ...@@ -335,7 +338,9 @@ SessionController* ViewManager::createController(Session* session , TerminalDisp
// is notified when the view gains the focus // is notified when the view gains the focus
SessionController* controller = new SessionController(session,view,this); SessionController* controller = new SessionController(session,view,this);
connect( controller , SIGNAL(focused(SessionController*)) , this , SIGNAL(activeViewChanged(SessionController*)) ); connect( controller , SIGNAL(focused(SessionController*)) , this , SIGNAL(activeViewChanged(SessionController*)) );
connect( session , SIGNAL(destroyed()) , controller , SLOT(deleteLater()) );
connect( view , SIGNAL(destroyed()) , controller , SLOT(deleteLater()) );
return controller; return controller;
} }
...@@ -387,8 +392,8 @@ ViewContainer* ViewManager::createContainer() ...@@ -387,8 +392,8 @@ ViewContainer* ViewManager::createContainer()
SLOT(map()) ); SLOT(map()) );
_containerSignalMapper->setMapping(container,container); _containerSignalMapper->setMapping(container,container);
connect( container , SIGNAL(viewRemoved(QWidget*)) , this , SLOT(viewCloseRequest(QWidget*)) );
connect( container , SIGNAL(closeRequest(QWidget*)) , this , SLOT(viewCloseRequest(QWidget*)) ); connect( container , SIGNAL(closeRequest(QWidget*)) , this , SLOT(viewCloseRequest(QWidget*)) );
connect( container , SIGNAL(activeViewChanged(QWidget*)) , this , SLOT(viewActivated(QWidget*))); connect( container , SIGNAL(activeViewChanged(QWidget*)) , this , SLOT(viewActivated(QWidget*)));
return container; return container;
...@@ -422,6 +427,9 @@ void ViewManager::viewCloseRequest(QWidget* view) ...@@ -422,6 +427,9 @@ void ViewManager::viewCloseRequest(QWidget* view)
{ {
kDebug() << __FILE__ << __LINE__ << ": received close request from unknown view." << endl; kDebug() << __FILE__ << __LINE__ << ": received close request from unknown view." << endl;
} }
qDebug() << "Closing view";
focusActiveView();
} }
void ViewManager::merge(ViewManager* otherManager) void ViewManager::merge(ViewManager* otherManager)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment