From 8ca27ef3933691e072c290793198132b1734a843 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 31 Aug 2017 00:10:50 +0200 Subject: [PATCH] Fix crash when closing Unregister the part dbus object when it gets destroyed Also fixes a crash if you try to inspect okular with qdbusviewer after having closed the a part/tab BUGS: 384142 --- part.cpp | 7 +++++-- part.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/part.cpp b/part.cpp index df38e85e9..7ac55d133 100644 --- a/part.cpp +++ b/part.cpp @@ -349,10 +349,11 @@ m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentW numberOfParts++; if (numberOfParts == 1) { - QDBusConnection::sessionBus().registerObject(QStringLiteral("/okular"), this, QDBusConnection::ExportScriptableSlots); + m_registerDbusName = QStringLiteral("/okular"); } else { - QDBusConnection::sessionBus().registerObject(QStringLiteral("/okular%1").arg(numberOfParts), this, QDBusConnection::ExportScriptableSlots); + m_registerDbusName = QStringLiteral("/okular%1").arg(numberOfParts); } + QDBusConnection::sessionBus().registerObject(m_registerDbusName, this, QDBusConnection::ExportScriptableSlots); // connect the started signal to tell the job the mimetypes we like, // and get some more information from it @@ -882,6 +883,8 @@ void Part::setupActions() Part::~Part() { + QDBusConnection::sessionBus().unregisterObject(m_registerDbusName); + GuiUtils::removeIconLoader( iconLoader() ); m_document->removeObserver( this ); diff --git a/part.h b/part.h index 714039a20..34a6806e6 100644 --- a/part.h +++ b/part.h @@ -359,6 +359,8 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu // Timer for m_infoMessage QTimer *m_infoTimer; + QString m_registerDbusName; + private Q_SLOTS: void slotAnnotationPreferences(); void slotHandleActivatedSourceReference(const QString& absFileName, int line, int col, bool *handled);