Skip to content

Commit 2e7ee7e

Browse files
committed
mapper device: defer rescanning of roots as the callback can be called after device has been deleted
1 parent c1ca912 commit 2e7ee7e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/plugins/score-plugin-protocols/Protocols/Mapper/MapperDevice.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class observable_device_roots final : public QObject
6868
if(auto dev = d->getDevice())
6969
m_devices.push_back(dev);
7070

71-
rootsChanged(roots());
71+
QTimer::singleShot(1, this, [this] { rootsChanged(roots()); });
7272
}
7373

7474
void
@@ -77,7 +77,8 @@ class observable_device_roots final : public QObject
7777
ossia::remove_erase(m_devices, oldd);
7878
if(newd)
7979
m_devices.push_back(newd);
80-
rootsChanged(roots());
80+
81+
QTimer::singleShot(1, this, [this] { rootsChanged(roots()); });
8182
}
8283

8384
void on_deviceRemoved(const Device::DeviceInterface* d)
@@ -86,7 +87,8 @@ class observable_device_roots final : public QObject
8687
d, &Device::DeviceInterface::deviceChanged, this,
8788
&observable_device_roots::on_deviceAddedCallback);
8889
ossia::remove_erase(m_devices, d->getDevice());
89-
rootsChanged(roots());
90+
91+
QTimer::singleShot(1, this, [this] { rootsChanged(roots()); });
9092
}
9193

9294
void rootsChanged(std::vector<ossia::net::node_base*> a) W_SIGNAL(rootsChanged, a);
@@ -397,7 +399,7 @@ class mapper_protocol final
397399
obj->devices = cache;
398400
m_roots = std::move(r);
399401
reset_tree();
400-
});
402+
}, Qt::QueuedConnection);
401403

402404
QObject::connect(
403405
m_component, &QQmlComponent::statusChanged, this,

0 commit comments

Comments
 (0)