Commit 5e87d833 authored by Simeon Bird's avatar Simeon Bird
Browse files

Fix bug 292950 by deleting QCoreApplication only after

Storage->ServerCore.

The bug occurs because Storage->ServerCore may persist after
QCoreApplication is gone. If the socket receives a remote disconnected
message from virtuoso (which it might because this is shutdown and
virtuoso is being killed) it tries to translate it, but can't because
the translators went with QCoreApplication. Thus the crash.

This was made much less likely by Vishesh already with cea2870f
but we can do better.

For most services connect QCoreApplication::quit() to the service
destroyed() signal.
For the storage service, disconnect that slot from the service and
reconnect it to
ServerCore::destroyed() (so that the application is only quit after the
ServerCore destructor runs). We do this in the service dtor, which is
allowed because the
dtor runs before destroyed() is emitted (I checked this).

BUG: 292950
FIXED-IN: 4.10.2
REVIEW: 108997
parent 31410207
......@@ -50,13 +50,20 @@ Nepomuk2::Storage::Storage( QObject* parent, const QList<QVariant>& )
this, SLOT( slotNepomukCoreInitialized(bool) ) );
m_core->init();
connect( QCoreApplication::instance(), SIGNAL(aboutToQuit()),
m_core, SLOT(deleteLater()) );
}
Nepomuk2::Storage::~Storage()
{
// Delete the QApplication after m_core goes,
// so that if the socket receives an error message
// we can handle it without crashing.
// Signal is connected in Nepomuk2::ServiceControl::start, in the servicestub.
disconnect( this, SIGNAL( destroyed() ),
QCoreApplication::instance(), SLOT( quit() ) );
connect( m_core, SIGNAL( destroyed() ),
QCoreApplication::instance(), SLOT( quit() ) );
m_core->deleteLater();
}
......
......@@ -103,6 +103,11 @@ void Nepomuk2::ServiceControl::start()
QDBusConnection::ExportScriptableSlots |
QDBusConnection::ExportScriptableProperties |
QDBusConnection::ExportAdaptors);
// Delete the QApplication after the m_nepomukServiceModule
// Note: if services need QCoreApplication to hang around for
// longer they can disconnect this signal.
connect( m_nepomukServiceModule, SIGNAL( destroyed() ),
QCoreApplication::instance(), SLOT( quit() ) );
}
......@@ -110,10 +115,8 @@ void Nepomuk2::ServiceControl::shutdown()
{
delete m_nepomukServiceModule;
m_nepomukServiceModule = 0;
QCoreApplication::quit();
}
QString Nepomuk2::ServiceControl::dbusServiceName( const QString& serviceName )
{
return QString("org.kde.nepomuk.services.%1").arg(serviceName);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment