[kdevplatform] shell: Fix a possible crash when working with split-views and when the working-set is active in multiple areas.

David Nolden david.nolden.kde at art-master.de
Tue Jul 19 12:55:10 UTC 2011


Git commit 3e8ee920d901e4bb11eebe398728054f7c9126f1 by David Nolden.
Committed on 19/07/2011 at 14:53.
Pushed by zwabel into branch 'master'.

Fix a possible crash when working with split-views and when the working-set is active in multiple areas.

It doesn't seem to be safe to clear one whole area while working on another one, so bring back the old updating code which only selectively closes views.
Clear the whole area on a higher level while switching working-sets, to make sure we sublime doesn't break while updating the views.
CCMAIL: kdevelop-devel at barney.cs.uni-potsdam.de
BUG: 277961

M  +4    -2    shell/workingsetcontroller.cpp
M  +7    -2    shell/workingsets/workingset.cpp

http://commits.kde.org/kdevplatform/3e8ee920d901e4bb11eebe398728054f7c9126f1

diff --git a/shell/workingsetcontroller.cpp b/shell/workingsetcontroller.cpp
index a6a5b94..457df1c 100644
--- a/shell/workingsetcontroller.cpp
+++ b/shell/workingsetcontroller.cpp
@@ -303,11 +303,13 @@ void WorkingSetController::changedWorkingSet(Sublime::Area* area, const QString&
     if (from == to)
         return;
 
+    // We have to always clear the target area first, because else we cannot perform the switch safely
+    // (sublime doesn't accept all kinds of changes to the area structure)
+    area->clearViews(true);
+    
     if (!to.isEmpty()) {
         WorkingSet* newSet = getWorkingSet(to);
         newSet->loadToArea(area, area->rootIndex(), !from.isEmpty());
-    } else {
-        area->clearViews(true);
     }
 
     emit workingSetSwitched();
diff --git a/shell/workingsets/workingset.cpp b/shell/workingsets/workingset.cpp
index 4399260..9b172e4 100644
--- a/shell/workingsets/workingset.cpp
+++ b/shell/workingsets/workingset.cpp
@@ -179,14 +179,19 @@ void WorkingSet::loadToArea(Sublime::Area* area, Sublime::AreaIndex* areaIndex,
     DisableMainWindowUpdatesFromArea updatesDisabler(area);
 
     kDebug() << "loading working-set" << m_id << "into area" << area;
-
     if(clear) {
         kDebug() << "clearing area with working-set" << area->workingSet();
+        
         // We have to close all views, else we may get serious UI
         // consistency problems when the documents intersect.
         // Clear the views silently, because the user should be batch-asked
         // before changing working sets.
-        area->clearViews(true);
+        QSet< QString > files = fileList().toSet();
+        foreach(Sublime::View* view, area->views()) {
+            Sublime::UrlDocument* doc = dynamic_cast<Sublime::UrlDocument*>(view->document());
+            if(!doc || !files.contains(doc->documentSpecifier()))
+                area->closeView(view);
+        }   
     }
 
     KConfigGroup setConfig(Core::self()->activeSession()->config(), "Working File Sets");




More information about the KDevelop-devel mailing list