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
This commit is contained in:
Albert Astals Cid 2017-08-31 00:10:50 +02:00
parent 9a25ea41dc
commit 8ca27ef393
2 changed files with 7 additions and 2 deletions

View File

@ -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 );

2
part.h
View File

@ -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);