diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp
index c725c915c9e37692fb39507ca46d6881511714e3..e6732387424c2832b804bd5e37d9b4b26419f1c2 100644
--- a/src/plugins/projectexplorer/projectwindow.cpp
+++ b/src/plugins/projectexplorer/projectwindow.cpp
@@ -45,6 +45,7 @@
 #include <coreplugin/icore.h>
 
 #include <QtCore/QDebug>
+#include <QtGui/QApplication>
 #include <QtGui/QBoxLayout>
 #include <QtGui/QComboBox>
 #include <QtGui/QTabWidget>
@@ -190,7 +191,14 @@ void ProjectWindow::updateTreeWidget()
     // That one runs fully thorough and deletes all widgets, even that one that we are currently removing
     // from m_panelsTabWidget.
     // To prevent that, we simply prevent the focus switching....
-    m_treeWidget->setFocus();
+    QWidget *focusWidget = qApp->focusWidget();
+    while (focusWidget) {
+        if (focusWidget == this) {
+            m_treeWidget->setFocus();
+            break;
+        }
+        focusWidget = focusWidget->parentWidget();
+    }
     m_treeWidget->clear();
 
     foreach(Project *project, m_session->projects()) {
diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp
index a9bded02c61ec0ba57ef1701041f957b8afc4c8a..89716ce3f68ab22a905a51f71ce7e5913e2e45be 100644
--- a/src/plugins/projectexplorer/session.cpp
+++ b/src/plugins/projectexplorer/session.cpp
@@ -628,8 +628,10 @@ bool SessionManager::loadImpl(const QString &fileName)
     if (success) {
         // restore the active mode
         const QString &modeIdentifier = value(QLatin1String("ActiveMode")).toString();
-        if (!modeIdentifier.isEmpty())
+        if (!modeIdentifier.isEmpty()) {
             m_core->modeManager()->activateMode(modeIdentifier);
+            m_core->modeManager()->setFocusToCurrentMode();
+        }
     }
 
     if (debug)