Skip to content

Commit

Permalink
UI: Add deferred function to update context bar
Browse files Browse the repository at this point in the history
With the queued connection in d68484e, the "Deselect" signal for
sources which are being deleted is never fired, as the object is gone by
the time the queued signal is processed. This results in the context bar
not updating.

This commit adds a new UpdateContextBarDeferred function, allowing
queuing of only the context bar update instead of the whole signal
handler.
  • Loading branch information
notr1ch authored and jp9000 committed Dec 14, 2020
1 parent 580eecd commit 38ad3ba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 4 additions & 6 deletions UI/source-tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ void SourceTreeItem::ReconnectSignals()
(obs_sceneitem_t *)calldata_ptr(cd, "item");

if (curItem == this_->sceneitem)
QMetaObject::invokeMethod(this_, "Select",
Qt::QueuedConnection);
QMetaObject::invokeMethod(this_, "Select");
};

auto itemDeselect = [](void *data, calldata_t *cd) {
Expand All @@ -238,8 +237,7 @@ void SourceTreeItem::ReconnectSignals()
(obs_sceneitem_t *)calldata_ptr(cd, "item");

if (curItem == this_->sceneitem)
QMetaObject::invokeMethod(this_, "Deselect",
Qt::QueuedConnection);
QMetaObject::invokeMethod(this_, "Deselect");
};

auto reorderGroup = [](void *data, calldata_t *) {
Expand Down Expand Up @@ -538,13 +536,13 @@ void SourceTreeItem::ExpandClicked(bool checked)
void SourceTreeItem::Select()
{
tree->SelectItem(sceneitem, true);
OBSBasic::Get()->UpdateContextBar();
OBSBasic::Get()->UpdateContextBarDeferred();
}

void SourceTreeItem::Deselect()
{
tree->SelectItem(sceneitem, false);
OBSBasic::Get()->UpdateContextBar();
OBSBasic::Get()->UpdateContextBarDeferred();
}

/* ========================================================================= */
Expand Down
6 changes: 6 additions & 0 deletions UI/window-basic-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2948,6 +2948,12 @@ static bool is_network_media_source(obs_source_t *source, const char *id)
return !is_local_file;
}

void OBSBasic::UpdateContextBarDeferred(bool force)
{
QMetaObject::invokeMethod(this, "UpdateContextBar",
Qt::QueuedConnection, Q_ARG(bool, force));
}

void OBSBasic::UpdateContextBar(bool force)
{
if (!ui->contextContainer->isVisible() && !force)
Expand Down
1 change: 1 addition & 0 deletions UI/window-basic-main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ public slots:

void ClearContextBar();
void UpdateContextBar(bool force = false);
void UpdateContextBarDeferred(bool force = false);

public:
explicit OBSBasic(QWidget *parent = 0);
Expand Down

0 comments on commit 38ad3ba

Please sign in to comment.