ui: read the signal count under the lock in the badge bar; validate the drop payload

This commit is contained in:
Martino Ferrari committed 2026-11-03 01:53:09 +01:00
1 parent 5242babf99
commit dad424f1de
3 files changed
+20 -5

No files matched your search

+8 -2
View File
@@ -4654,10 +4654,16 @@ void run_app_action(App& app, AppAction action) {
toggle(app.cursors_toggle);
break;
case AppAction::ShowMeasure: dock_show_section(app, "measure"); break;
case AppAction::ShowSignals:
case AppAction::ShowSignals: {
// The `+` badge is insensitive without signals; so is its shortcut.
if (!app.model->signals().empty()) slideover_toggle(app, "signals");
bool have_signals = false;
{
std::lock_guard<std::mutex> lock(app.model->mutex());
have_signals = !app.model->signals().empty();
}
if (have_signals) slideover_toggle(app, "signals");
break;
}
case AppAction::LayoutEditor:
toggle(app.layout_toggle);
break;
+7 -2
View File
@@ -256,12 +256,17 @@ void sync_badge_bar(App& app) {
set_text_if_changed(bb.trigger.state, trigger_badge_state(enabled, armed, pending, has_event));
set_open(bb.trigger.button, slideover_page(app) == bb.trigger.page);
bool have_signals = false;
{
std::lock_guard<std::mutex> lock(app.model->mutex());
have_signals = !app.model->signals().empty();
}
if (bb.plus.button != nullptr) {
gtk_widget_set_sensitive(bb.plus.button, !app.model->signals().empty());
gtk_widget_set_sensitive(bb.plus.button, have_signals);
set_open(bb.plus.button, slideover_page(app) == "signals");
}
if (bb.overflow.button != nullptr) {
gtk_widget_set_sensitive(bb.overflow.button, !app.model->signals().empty());
gtk_widget_set_sensitive(bb.overflow.button, have_signals);
// The overflow stands for every signal's badge too: a signal page opened from a list row marks it.
set_open(bb.overflow.button,
slideover_page(app) == bb.overflow.page || slideover_page(app).rfind("signal:", 0) == 0);
+5 -1
View File
@@ -557,7 +557,11 @@ gboolean on_drop_channel(GtkDropTarget*, const GValue* value, double x, double y
// Where the drop landed decides the row: one area covers them all.
const int row = row_at(*app, x, y);
const char* text = g_value_get_string(value);
const std::size_t signal = static_cast<std::size_t>(std::atoll(text ? text : "0"));
if (text == nullptr || *text == '\0') return FALSE;
char* end = nullptr;
const unsigned long long parsed = std::strtoull(text, &end, 10);
if (end == nullptr || *end != '\0') return FALSE;
const std::size_t signal = static_cast<std::size_t>(parsed);
if (!assign_signal_to_row(*app, signal, row)) return FALSE;
cancel_drag_on(*app, row);
return TRUE;