From 8f7ab9d4b7ecc71083e2d7e03863857b1cfdea54 Mon Sep 17 00:00:00 2001 From: Sebastian Englbrecht Date: Sat, 23 May 2026 17:38:44 +0200 Subject: dolphinplacesmodelsingleton,trash: destroy owned objects before KIO cache teardown Both singletons start KIO list jobs on construction. Register qAddPostRoutine to destroy the owned objects during QCoreApplication teardown, while KIO's KCoreDirListerCache can still cancel in-flight jobs. --- src/dolphinplacesmodelsingleton.cpp | 5 +++++ src/trash/dolphintrash.cpp | 9 +++++++++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/dolphinplacesmodelsingleton.cpp b/src/dolphinplacesmodelsingleton.cpp index 301150394..40fb930e4 100644 --- a/src/dolphinplacesmodelsingleton.cpp +++ b/src/dolphinplacesmodelsingleton.cpp @@ -10,6 +10,7 @@ #include +#include #include #include @@ -120,6 +121,10 @@ bool DolphinPlacesModel::isTrash(const QModelIndex &index) const DolphinPlacesModelSingleton::DolphinPlacesModelSingleton() : m_placesModel(new DolphinPlacesModel()) { + // Destroy during QCoreApplication teardown, while KIO's KCoreDirListerCache is still alive. + qAddPostRoutine([] { + instance().m_placesModel.reset(); + }); } DolphinPlacesModelSingleton &DolphinPlacesModelSingleton::instance() diff --git a/src/trash/dolphintrash.cpp b/src/trash/dolphintrash.cpp index ae3f1e20c..66d69254a 100644 --- a/src/trash/dolphintrash.cpp +++ b/src/trash/dolphintrash.cpp @@ -16,6 +16,7 @@ #include #include +#include #include Trash::Trash() @@ -53,6 +54,14 @@ Trash::Trash() }); m_trashDirLister->openUrl(QUrl(QStringLiteral("trash:/"))); + + // Destroy during QCoreApplication teardown, while KIO's KCoreDirListerCache is still alive. + // The singleton destructor fires later, but m_trashDirLister is already nullptr by then. + qAddPostRoutine([] { + auto &t = instance(); + delete t.m_trashDirLister; + t.m_trashDirLister = nullptr; + }); } Trash::~Trash() -- cgit v1.3.1