]> cloud.milkyroute.net Git - dolphin.git/commitdiff
lessons learned from the column view: never invoke KDirModel::expandToUrl() when...
authorPeter Penz <peter.penz19@gmail.com>
Wed, 26 Sep 2007 09:11:40 +0000 (09:11 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 26 Sep 2007 09:11:40 +0000 (09:11 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=717203

src/treeviewsidebarpage.cpp
src/treeviewsidebarpage.h

index eac1e6cf43273d94f7b7742d464b04e90748e442..8096b966a4b72d455c340875a5219cc1dc87680c 100644 (file)
@@ -38,6 +38,7 @@
 
 TreeViewSidebarPage::TreeViewSidebarPage(QWidget* parent) :
     SidebarPage(parent),
+    m_dirListerCompleted(false),
     m_dirLister(0),
     m_dolphinModel(0),
     m_proxyModel(0),
@@ -89,6 +90,12 @@ void TreeViewSidebarPage::showEvent(QShowEvent* event)
         m_dirLister->setDelayedMimeTypes(true);
         m_dirLister->setAutoErrorHandlingEnabled(false, this);
 
+        m_dirListerCompleted = true;
+        connect(m_dirLister, SIGNAL(started(const KUrl&)),
+                this, SLOT(slotDirListerStarted(const KUrl&)));
+        connect(m_dirLister, SIGNAL(completed()),
+                this, SLOT(slotDirListerCompleted()));
+
         Q_ASSERT(m_dolphinModel == 0);
         m_dolphinModel = new DolphinModel(this);
         m_dolphinModel->setDirLister(m_dirLister);
@@ -237,10 +244,23 @@ void TreeViewSidebarPage::loadSubTree()
         // Load all sub directories that need to get expanded for making
         // the leaf directory visible. The slot triggerExpanding() will
         // get invoked if the expanding has been finished.
+        Q_ASSERT(m_dirListerCompleted);
         m_dolphinModel->expandToUrl(m_leafDir);
     }
 }
 
+void TreeViewSidebarPage::slotDirListerStarted(const KUrl& url)
+{
+    Q_UNUSED(url);
+    m_dirListerCompleted = false;
+}
+
+void TreeViewSidebarPage::slotDirListerCompleted()
+{
+    m_dirListerCompleted = true;
+}
+
+
 void TreeViewSidebarPage::loadTree(const KUrl& url)
 {
     Q_ASSERT(m_dirLister != 0);
@@ -257,7 +277,7 @@ void TreeViewSidebarPage::loadTree(const KUrl& url)
 
     connect(m_dirLister, SIGNAL(completed()),
             this, SLOT(loadSubTree()));
-    if (m_dirLister->url() != baseUrl) {
+    if ((m_dirLister->url() != baseUrl) || !m_dirListerCompleted) {
         m_dirLister->stop();
         m_dirLister->openUrl(baseUrl);
     } else {
index 1124dcf3feb510083246e30dcb80e2867a9ca87d..ec0907ac256bd20ce6fd3f480c71a7ffa6415e97 100644 (file)
@@ -100,6 +100,19 @@ private slots:
      */
     void loadSubTree();
 
+    /**
+     * Is invoked when the directory lister has started the loading
+     * of the URL \a url and sets the internal m_dirListerCompleted
+     * state to false.
+     */
+    void slotDirListerStarted(const KUrl& url);
+
+    /**
+     * Is invoked when the directory lister has completed the loading
+     * and sets the internal m_dirListerCompleted state to true.
+     */
+    void slotDirListerCompleted();
+
 private:
     /**
      * Initializes the base URL of the tree and expands all
@@ -109,6 +122,7 @@ private:
     void loadTree(const KUrl& url);
 
 private:
+    bool m_dirListerCompleted;
     KDirLister* m_dirLister;
     DolphinModel* m_dolphinModel;
     DolphinSortFilterProxyModel* m_proxyModel;