Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tab-widget): Tab widgets with no callback do not update visibility #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TwentyPast4
Copy link

When no callback is set, the tab widget fails to update visibility of its children due to an erroneous if condition.

@wjakob wjakob force-pushed the master branch 3 times, most recently from 34e97f1 to b94e8a7 Compare September 6, 2020 19:45
@wjakob wjakob force-pushed the master branch 4 times, most recently from f88c1ac to 69464ef Compare July 1, 2021 08:19
@wjakob wjakob force-pushed the master branch 11 times, most recently from e9c6fc9 to 0f47fe0 Compare October 27, 2022 21:06
@fwsGonzo
Copy link

fwsGonzo commented Mar 9, 2024

Just fixed this myself. I suspect there are more:

diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp
index 321f249..0566939 100644
--- a/src/tabwidget.cpp
+++ b/src/tabwidget.cpp
@@ -36,8 +36,9 @@ void TabWidgetBase::remove_tab(int id) {
     TabWidgetBase::perform_layout(screen()->nvg_context());
     if (m_close_callback)
         m_close_callback(id);
-    if (close_active && m_callback) {
-        m_callback(selected_id());
+    if (close_active) {
+        if (m_callback)
+            m_callback(selected_id());
         update_visibility();
     }
 }
@@ -49,9 +50,10 @@ int TabWidgetBase::insert_tab(int index, const std::string &caption) {
     TabWidgetBase::perform_layout(screen()->nvg_context());
     if (index < m_active_tab)
         m_active_tab++;
-    if (m_tab_ids.size() == 1 && m_callback) {
+    if (m_tab_ids.size() == 1) {
         m_active_tab = 0;
-        m_callback(id);
+        if (m_callback)
+            m_callback(id);
         update_visibility();
     }
     return id;
@@ -305,8 +307,9 @@ bool TabWidgetBase::mouse_button_event(const Vector2i &p, int button, bool down,
                     m_tab_drag_min = m_tab_offsets[index];
                     m_tab_drag_max = m_tab_offsets[index + 1];
                     m_close_index_pushed = -1;
-                    if (tab_changed && m_callback) {
-                        m_callback(selected_id());
+                    if (tab_changed) {
+                        if (m_callback)
+                            m_callback(selected_id());
                         update_visibility();
                     }
                 } else if (m_tab_drag_index != -1) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants