summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/Breadcrumbbar.cpp
diff options
context:
space:
mode:
authorJannis Weis <31143295+weisJ@users.noreply.github.com>2022-08-21 21:45:43 +0200
committerAndreas Kling <kling@serenityos.org>2022-08-22 12:48:11 +0200
commit32205495e6362888ad28389d3f9af05925198b12 (patch)
tree01856ad75f22105c4236905bbe5815f8f683268a /Userland/Libraries/LibGUI/Breadcrumbbar.cpp
parent3911758277af1440aa46361e1f6a69f51aae5f8f (diff)
downloadserenity-32205495e6362888ad28389d3f9af05925198b12.zip
LibGUI: Clear selected index of Breadcrumbbar if segment is removed
If the segment corresponding to the selected index is removed the index is no longer valid.
Diffstat (limited to 'Userland/Libraries/LibGUI/Breadcrumbbar.cpp')
-rw-r--r--Userland/Libraries/LibGUI/Breadcrumbbar.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp
index 57366b6e63..5e63b7a2df 100644
--- a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp
+++ b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp
@@ -68,6 +68,7 @@ void Breadcrumbbar::clear_segments()
{
m_segments.clear();
remove_all_children();
+ m_selected_segment = {};
}
void Breadcrumbbar::append_segment(String text, Gfx::Bitmap const* icon, String data, String tooltip)
@@ -120,6 +121,8 @@ void Breadcrumbbar::remove_end_segments(size_t start_segment_index)
auto segment = m_segments.take_last();
remove_child(*segment.button);
}
+ if (m_selected_segment.has_value() && *m_selected_segment >= start_segment_index)
+ m_selected_segment = {};
}
Optional<size_t> Breadcrumbbar::find_segment_with_data(String const& data)