fixed:tray error

托盘加载插件时,插件对应的dbus服务有时候还没启动,这时会绑定一个QDBusConnectionInterface::serviceOwnerChanged,当事件触发时,调用插件的init方法。托盘里每次init都会重新创建所有widget,导致托盘内的插件图标全部消失。
This commit is contained in:
shaojun 2019-11-22 13:09:58 +08:00
parent 1b8aa5fa44
commit e6a106fe24
2 changed files with 8 additions and 0 deletions

View File

@ -43,6 +43,7 @@ using org::kde::StatusNotifierWatcher;
TrayPlugin::TrayPlugin(QObject *parent)
: QObject(parent)
, m_pluginLoaded(false)
{
}
@ -68,6 +69,12 @@ void TrayPlugin::init(PluginProxyInterface *proxyInter)
return;
}
if (m_pluginLoaded) {
return;
}
m_pluginLoaded = true;
m_trayInter = new DBusTrayManager(this);
m_sniWatcher = new StatusNotifierWatcher(SNI_WATCHER_SERVICE, SNI_WATCHER_PATH, QDBusConnection::sessionBus(), this);
m_fashionItem = new FashionTrayItem(this);

View File

@ -99,6 +99,7 @@ private:
QMap<QString, IndicatorTray*> m_indicatorMap;
TipsWidget *m_tipsLabel;
bool m_pluginLoaded;
};
#endif // TRAYPLUGIN_H