mirror of
https://github.com/lubosz/overte.git
synced 2025-04-25 12:33:04 +02:00
Merge pull request #10872 from jherico/fix_laggy_overlays
Don't use a blocking connection for a high-frequency script function
This commit is contained in:
commit
1f7d2b283a
1 changed files with 9 additions and 6 deletions
|
@ -231,9 +231,12 @@ OverlayID Overlays::cloneOverlay(OverlayID id) {
|
||||||
|
|
||||||
bool Overlays::editOverlay(OverlayID id, const QVariant& properties) {
|
bool Overlays::editOverlay(OverlayID id, const QVariant& properties) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
bool result;
|
// NOTE editOverlay can be called very frequently in scripts and can't afford to
|
||||||
BLOCKING_INVOKE_METHOD(this, "editOverlay", Q_RETURN_ARG(bool, result), Q_ARG(OverlayID, id), Q_ARG(QVariant, properties));
|
// block waiting on the main thread. Additionally, no script actually
|
||||||
return result;
|
// examines the return value and does something useful with it, so use a non-blocking
|
||||||
|
// invoke and just always return true
|
||||||
|
QMetaObject::invokeMethod(this, "editOverlay", Q_ARG(OverlayID, id), Q_ARG(QVariant, properties));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Overlay::Pointer thisOverlay = getOverlay(id);
|
Overlay::Pointer thisOverlay = getOverlay(id);
|
||||||
|
@ -246,9 +249,9 @@ bool Overlays::editOverlay(OverlayID id, const QVariant& properties) {
|
||||||
|
|
||||||
bool Overlays::editOverlays(const QVariant& propertiesById) {
|
bool Overlays::editOverlays(const QVariant& propertiesById) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
bool result;
|
// NOTE see comment on editOverlay for why this is not a blocking call
|
||||||
BLOCKING_INVOKE_METHOD(this, "editOverlays", Q_RETURN_ARG(bool, result), Q_ARG(QVariant, propertiesById));
|
QMetaObject::invokeMethod(this, "editOverlays", Q_ARG(QVariant, propertiesById));
|
||||||
return result;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap map = propertiesById.toMap();
|
QVariantMap map = propertiesById.toMap();
|
||||||
|
|
Loading…
Reference in a new issue