Commit 29247d6d authored by David Edmundson's avatar David Edmundson

Don't modify member variables in another thread

m_connectedEvents is modified in connectNotify which according to the
docs will be called from the thread of the caller, not this.

As it is read from our thread this risks calling a clash.

REVIEW: 125395
BUG: 345862
parent 134f1fa3
......@@ -433,24 +433,38 @@ void KCupsConnection::connectNotify(const QMetaMethod & signal)
{
QString event = eventForSignal(signal);
if (!event.isNull()) {
m_connectedEvents << event;
QMetaObject::invokeMethod(m_subscriptionTimer,
"start",
Qt::QueuedConnection);
QMetaObject::invokeMethod(this,
"connectNotifyQueued",
Qt::QueuedConnection),
Q_ARG(QString, event);
}
}
void KCupsConnection::connectNotifyQueued(const QString& event)
{
m_connectedEvents << event;
m_subscriptionTimer->start();
}
void KCupsConnection::disconnectNotify(const QMetaMethod & signal)
{
QString event = eventForSignal(signal);
if (!event.isNull()) {
m_connectedEvents.removeOne(event);
QMetaObject::invokeMethod(m_subscriptionTimer,
"start",
Qt::QueuedConnection);
QMetaObject::invokeMethod(this,
"disconnectNotifyQueued",
Qt::QueuedConnection),
Q_ARG(QString, event);
}
}
void KCupsConnection::disconnectNotifyQueued(const QString& event)
{
m_connectedEvents.removeOne(event);
m_subscriptionTimer->start();
}
QString KCupsConnection::eventForSignal(const QMetaMethod & signal) const
{
// Server signals
......
......@@ -371,6 +371,10 @@ private slots:
void renewDBusSubscription();
void cancelDBusSubscription();
void connectNotifyQueued(const QString& event);
void disconnectNotifyQueued(const QString &event);
protected:
virtual void connectNotify(const QMetaMethod & signal) Q_DECL_OVERRIDE;
virtual void disconnectNotify(const QMetaMethod & signal) Q_DECL_OVERRIDE;
......
Markdown is supported
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