diff --git a/src/treeviewsidebarpage.cpp b/src/treeviewsidebarpage.cpp index eac1e6cf43..8096b966a4 100644 --- a/src/treeviewsidebarpage.cpp +++ b/src/treeviewsidebarpage.cpp @@ -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 { diff --git a/src/treeviewsidebarpage.h b/src/treeviewsidebarpage.h index 1124dcf3fe..ec0907ac25 100644 --- a/src/treeviewsidebarpage.h +++ b/src/treeviewsidebarpage.h @@ -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;