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_tempIcon(Q_NULLPTR)
|
||||
, m_tempAttentionIcon(Q_NULLPTR)
|
||||
, m_registered(false)
|
||||
{
|
||||
qCDebug(qLcTray);
|
||||
if (instanceCount == 1) {
|
||||
@ -101,15 +102,17 @@ QDBusTrayIcon::~QDBusTrayIcon()
|
||||
void QDBusTrayIcon::init()
|
||||
{
|
||||
qCDebug(qLcTray) << "registering" << m_instanceId;
|
||||
dBusConnection()->registerTrayIcon(this);
|
||||
m_registered = dBusConnection()->registerTrayIcon(this);
|
||||
}
|
||||
|
||||
void QDBusTrayIcon::cleanup()
|
||||
{
|
||||
qCDebug(qLcTray) << "unregistering" << m_instanceId;
|
||||
dBusConnection()->unregisterTrayIcon(this);
|
||||
if (m_registered)
|
||||
dBusConnection()->unregisterTrayIcon(this);
|
||||
delete m_dbusConnection;
|
||||
m_dbusConnection = Q_NULLPTR;
|
||||
m_registered = false;
|
||||
}
|
||||
|
||||
void QDBusTrayIcon::activate(int x, int y)
|
||||
|
@ -156,6 +156,7 @@ private:
|
||||
QTimer m_attentionTimer;
|
||||
bool m_isRequestingAttention;
|
||||
bool m_hasMenu;
|
||||
bool m_registered;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user