From 932c0db65e54d24cbc9131e00412a7f0a8f2bcd2 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 6 Oct 2024 17:00:07 -0400 Subject: Reduce variable scopes --- .suppress.cppcheck | 1 - src/gui/ConnectWindow.cpp | 19 +++++++++---------- src/gui/GraphBox.cpp | 6 +++--- src/runtime_paths.cpp | 3 ++- src/server/events/Delta.cpp | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.suppress.cppcheck b/.suppress.cppcheck index 44f9e760..55309381 100644 --- a/.suppress.cppcheck +++ b/.suppress.cppcheck @@ -18,5 +18,4 @@ shadowFunction unsafeClassCanLeak useStlAlgorithm uselessOverride -variableScope virtualCallInConstructor diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index b33c3b81..3c9f7e89 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -440,18 +440,17 @@ ConnectWindow::internal_toggled() void ConnectWindow::next_stage() { - static const char* labels[] = { - "Connecting...", - "Pinging engine...", - "Attaching to engine...", - "Requesting root graph...", - "Waiting for root graph...", - "Connected" - }; - - ++_connect_stage; if (_widgets_loaded) { + static const char* labels[] = { + "Connecting...", + "Pinging engine...", + "Attaching to engine...", + "Requesting root graph...", + "Waiting for root graph...", + "Connected" + }; + _progress_label->set_text(labels[_connect_stage]); } } diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index 0764e4ed..4c3ff50d 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -885,10 +885,10 @@ GraphBox::event_refresh_activated() void GraphBox::event_fullscreen_toggled() { - // FIXME: ugh, use GTK signals to track state and know for sure - static bool is_fullscreen = false; - if (_window) { + // FIXME: ugh, use GTK signals to track state and know for sure + static bool is_fullscreen = false; + if (!is_fullscreen) { _window->fullscreen(); is_fullscreen = true; diff --git a/src/runtime_paths.cpp b/src/runtime_paths.cpp index b876ebd4..cca9490d 100644 --- a/src/runtime_paths.cpp +++ b/src/runtime_paths.cpp @@ -44,7 +44,8 @@ static const char* const library_suffix = ".so"; #endif static std::vector -parse_search_path(const char* search_path, std::vector defaults) +parse_search_path(const char* search_path, + const std::vector& defaults) { if (!search_path) { return defaults; diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index 3f9e3b9d..96f13ee5 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -316,8 +316,8 @@ Delta::pre_process(PreProcessContext& ctx) const Property& value = p.second; SpecialType op = SpecialType::NONE; if (obj) { - Resource& resource = *obj; if (value != uris.patch_wildcard) { + Resource& resource = *obj; if (resource.add_property(key, value, value.context())) { _added.emplace(key, value); } -- cgit v1.2.1