Do not attempt to unregister an unregistered dbus service
If a QSystemTrayIcon is created but never shown, it will trigger a warning on exit when it fails to unregister. This patch ensures we only try to unregister if the service was registered in the first place. Change-Id: I0e245d19be55c58aea180dbcbe5215e738d05280 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
parent
bc20d794cf
commit
9bf8b2a412
@ -77,6 +77,7 @@ QDBusTrayIcon::QDBusTrayIcon()
|
|||||||
, m_status(m_defaultStatus)
|
, m_status(m_defaultStatus)
|
||||||
, m_tempIcon(Q_NULLPTR)
|
, m_tempIcon(Q_NULLPTR)
|
||||||
, m_tempAttentionIcon(Q_NULLPTR)
|
, m_tempAttentionIcon(Q_NULLPTR)
|
||||||
|
, m_registered(false)
|
||||||
{
|
{
|
||||||
qCDebug(qLcTray);
|
qCDebug(qLcTray);
|
||||||
if (instanceCount == 1) {
|
if (instanceCount == 1) {
|
||||||
@ -101,15 +102,17 @@ QDBusTrayIcon::~QDBusTrayIcon()
|
|||||||
void QDBusTrayIcon::init()
|
void QDBusTrayIcon::init()
|
||||||
{
|
{
|
||||||
qCDebug(qLcTray) << "registering" << m_instanceId;
|
qCDebug(qLcTray) << "registering" << m_instanceId;
|
||||||
dBusConnection()->registerTrayIcon(this);
|
m_registered = dBusConnection()->registerTrayIcon(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QDBusTrayIcon::cleanup()
|
void QDBusTrayIcon::cleanup()
|
||||||
{
|
{
|
||||||
qCDebug(qLcTray) << "unregistering" << m_instanceId;
|
qCDebug(qLcTray) << "unregistering" << m_instanceId;
|
||||||
|
if (m_registered)
|
||||||
dBusConnection()->unregisterTrayIcon(this);
|
dBusConnection()->unregisterTrayIcon(this);
|
||||||
delete m_dbusConnection;
|
delete m_dbusConnection;
|
||||||
m_dbusConnection = Q_NULLPTR;
|
m_dbusConnection = Q_NULLPTR;
|
||||||
|
m_registered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QDBusTrayIcon::activate(int x, int y)
|
void QDBusTrayIcon::activate(int x, int y)
|
||||||
|
@ -156,6 +156,7 @@ private:
|
|||||||
QTimer m_attentionTimer;
|
QTimer m_attentionTimer;
|
||||||
bool m_isRequestingAttention;
|
bool m_isRequestingAttention;
|
||||||
bool m_hasMenu;
|
bool m_hasMenu;
|
||||||
|
bool m_registered;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user