summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElvis Angelaccio <elvis.angelaccio@kde.org>2016-11-02 11:05:04 (GMT)
committerElvis Angelaccio <elvis.angelaccio@kde.org>2016-11-02 11:05:04 (GMT)
commit04d8a98133ff611cfcb042753c6bca8ef24f9ddb (patch)
treeed52c43c00fa9c70f9edbfd8b59377b0c240dd7d
parente68ab2f61fbd09f7ba98a0182bd13cbbeb4bde48 (diff)
Fix crash when aborting LoadJobs
LoadJob::onNewEntry() receives an Entry pointer. When we kill a LoadJob, the libarchive plugin deletes all the emitted entries, so onNewEntry() (which is queued in the events) gets a pointer that points to already free'ed memory. This patch just delays the deletion of entries by using deleteLater(). This ensures that all the pending slots are executed first. Differential Revision: D3143
-rw-r--r--plugins/libarchive/libarchiveplugin.cpp8
-rw-r--r--plugins/libarchive/libarchiveplugin.h2
2 files changed, 7 insertions, 3 deletions
diff --git a/plugins/libarchive/libarchiveplugin.cpp b/plugins/libarchive/libarchiveplugin.cpp
index 338fc9b..b5d0333 100644
--- a/plugins/libarchive/libarchiveplugin.cpp
+++ b/plugins/libarchive/libarchiveplugin.cpp
@@ -47,6 +47,10 @@ LibarchivePlugin::LibarchivePlugin(QObject *parent, const QVariantList &args)
LibarchivePlugin::~LibarchivePlugin()
{
+ foreach (const auto e, m_emittedEntries) {
+ // Entries might be passed to pending slots, so we just schedule their deletion.
+ e->deleteLater();
+ }
}
bool LibarchivePlugin::list()
@@ -434,7 +438,7 @@ bool LibarchivePlugin::initializeReader()
void LibarchivePlugin::emitEntryFromArchiveEntry(struct archive_entry *aentry)
{
- auto e = QSharedPointer<Archive::Entry>(new Archive::Entry());
+ auto e = new Archive::Entry();
#ifdef _MSC_VER
e->setProperty("fullPath", QDir::fromNativeSeparators(QString::fromUtf16((ushort*)archive_entry_pathname_w(aentry))));
@@ -462,7 +466,7 @@ void LibarchivePlugin::emitEntryFromArchiveEntry(struct archive_entry *aentry)
e->setProperty("timestamp", QDateTime::fromTime_t(archive_entry_mtime(aentry)));
- emit entry(e.data());
+ emit entry(e);
m_emittedEntries << e;
}
diff --git a/plugins/libarchive/libarchiveplugin.h b/plugins/libarchive/libarchiveplugin.h
index 7ee00fa..85a5ec4 100644
--- a/plugins/libarchive/libarchiveplugin.h
+++ b/plugins/libarchive/libarchiveplugin.h
@@ -96,7 +96,7 @@ private:
qlonglong m_currentExtractedFilesSize;
bool m_emitNoEntries;
qlonglong m_extractedFilesSize;
- QVector<QSharedPointer<Archive::Entry>> m_emittedEntries;
+ QVector<Archive::Entry*> m_emittedEntries;
};
#endif // LIBARCHIVEPLUGIN_H