Commit ccaeea48 authored by Robert Knight's avatar Robert Knight

Fix bug where multiple Konsole KParts within one application would not work. ...

Fix bug where multiple Konsole KParts within one application would not work.  Part::activeSession() was always returning the first session from the shared SessionManager.  In the second KPart, activeSession()->isRunning() would always return true even when the session for that part was not actually running, so the session was never started.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=754194
parent afd172c5
......@@ -118,27 +118,13 @@ void Part::newTab()
}
Session* Part::activeSession() const
{
if ( _pluggedController )
{
qDebug() << k_funcinfo << " - have plugged controller";
return _pluggedController->session();
}
else
{
// for now, just return the first available session
QList<Session*> list = SessionManager::instance()->sessions();
qDebug() << k_funcinfo << " - no plugged controller, selectin first from" << list.count() << "sessions";
Q_ASSERT( !list.isEmpty() );
return list.first();
}
return _viewManager->activeViewController()->session();
}
void Part::startProgram( const QString& program,
const QStringList& arguments )
{
Q_ASSERT( activeSession() );
if ( !activeSession()->isRunning() )
{
if ( !program.isEmpty() && !arguments.isEmpty() )
......@@ -152,6 +138,8 @@ void Part::startProgram( const QString& program,
}
void Part::showShellInDir( const QString& dir )
{
Q_ASSERT( activeSession() );
if ( !activeSession()->isRunning() )
{
if ( !dir.isEmpty() )
......
......@@ -458,7 +458,7 @@ SessionController* ViewManager::createController(Session* session , TerminalDisp
// create a new controller for the session, and ensure that this view manager
// is notified when the view gains the focus
SessionController* controller = new SessionController(session,view,this);
connect( controller , SIGNAL(focused(SessionController*)) , this , SIGNAL(activeViewChanged(SessionController*)) );
connect( controller , SIGNAL(focused(SessionController*)) , this , SLOT(controllerChanged(SessionController*)) );
connect( session , SIGNAL(destroyed()) , controller , SLOT(deleteLater()) );
connect( view , SIGNAL(destroyed()) , controller , SLOT(deleteLater()) );
connect( controller , SIGNAL(sendInputToAll(bool)) , this , SLOT(sendInputToAll()) );
......@@ -466,6 +466,17 @@ SessionController* ViewManager::createController(Session* session , TerminalDisp
return controller;
}
void ViewManager::controllerChanged(SessionController* controller)
{
_pluggedController = controller;
emit activeViewChanged(controller);
}
SessionController* ViewManager::activeViewController() const
{
return _pluggedController;
}
void ViewManager::createView(Session* session)
{
// create the default container
......
......@@ -137,6 +137,12 @@ public:
*/
NavigationMethod navigationMethod() const;
/**
* Returns the controller for the active view. activeViewChanged() is
* emitted when this changes.
*/
SessionController* activeViewController() const;
signals:
/** Emitted when the last view is removed from the view manager */
void empty();
......@@ -232,6 +238,9 @@ private slots:
// moves active view to the right
void moveActiveViewRight();
// called when a SessionController gains focus
void controllerChanged(SessionController* controller);
private:
const ColorScheme* colorSchemeForProfile(const QString& key) const;
......
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