aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <[email protected]>2016-06-11 21:18:51 +0200
committerMartin T. H. Sandsmark <[email protected]>2016-06-11 21:18:51 +0200
commitb3d6b5f39294ae98b66e38e541cd77d7038cb02e (patch)
tree3255641c647ab3a22db9e8e5c3adb3714d9f8751
parent00562e39c8839b2c318f66ee5d18cd08f96463f3 (diff)
Fix memory leak in remote listener
-rw-r--r--src/part/remoteLister.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/part/remoteLister.cpp b/src/part/remoteLister.cpp
index 3631369..76f7ccc 100644
--- a/src/part/remoteLister.cpp
+++ b/src/part/remoteLister.cpp
@@ -51,7 +51,7 @@ struct Store {
List stores;
Store(const QUrl &u, const QString &name, Store *s)
- : url(u), folder(new Folder(name.toUtf8() + '/')), parent(s) {}
+ : url(u), folder(new Folder(name.toUtf8() + '/')), parent(s) { }
Store* propagate()
@@ -135,10 +135,17 @@ RemoteLister::_completed()
}
- if (m_store->stores.isEmpty())
+ if (m_store->stores.isEmpty()) {
//no directories to scan, so we need to append ourselves to the parent folder
- //propagate() will return the next ancestor that has stores left to be scanned, or root if we are done
- m_store = m_store->propagate();
+ //propagate() will return the next ancestor that has stores left to be
+ //scanned, or root if we are done
+ Store *newStore = m_store->propagate();
+ if (newStore != m_store) {
+ // We need to clean up old stores
+ delete m_store;
+ m_store = newStore;
+ }
+ }
if (!m_store->stores.isEmpty())
{
@@ -157,7 +164,7 @@ RemoteLister::_completed()
openUrl(url);
}
else {
- qDebug() << "I think we're done\n";
+ qDebug() << "I think we're done";
Q_ASSERT(m_root == m_store);