mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
fix: cross-thread parenting failure
Cannot create a child in another thread. Do not use object tree, use QScopedPointer to manage life scope. Log: fix cross-thread parenting failure
This commit is contained in:
parent
bce2a49971
commit
12d346a2c9
@ -29,7 +29,7 @@ Notification::Notification(QWidget *parent)
|
|||||||
setMinimumSize(PLUGIN_BACKGROUND_MIN_SIZE, PLUGIN_BACKGROUND_MIN_SIZE);
|
setMinimumSize(PLUGIN_BACKGROUND_MIN_SIZE, PLUGIN_BACKGROUND_MIN_SIZE);
|
||||||
connect(this, &Notification::dndModeChanged, this, &Notification::refreshIcon);
|
connect(this, &Notification::dndModeChanged, this, &Notification::refreshIcon);
|
||||||
QtConcurrent::run([this](){
|
QtConcurrent::run([this](){
|
||||||
m_dbus = new QDBusInterface("org.deepin.dde.Notification1", "/org/deepin/dde/Notification1", "org.deepin.dde.Notification1", QDBusConnection::sessionBus(), this);
|
m_dbus.reset(new QDBusInterface("org.deepin.dde.Notification1", "/org/deepin/dde/Notification1", "org.deepin.dde.Notification1"));
|
||||||
// Refresh icon for the first time, cause org.deepin.dde.Notification1 might depend on dock's DBus,
|
// Refresh icon for the first time, cause org.deepin.dde.Notification1 might depend on dock's DBus,
|
||||||
// we should not call org.deepin.dde.Notification1 in the main thread before dock's dbus is initialized.
|
// we should not call org.deepin.dde.Notification1 in the main thread before dock's dbus is initialized.
|
||||||
// Just refresh icon in the other thread.
|
// Just refresh icon in the other thread.
|
||||||
|
@ -37,7 +37,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
QDBusInterface *m_dbus;
|
QScopedPointer<QDBusInterface> m_dbus;
|
||||||
bool m_dndMode;
|
bool m_dndMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user