From fb44f5347fec6950463a8e13671fbe1ff891fde5 Mon Sep 17 00:00:00 2001 From: joranv1 Date: Mon, 31 Aug 2026 15:51:42 +0200 Subject: [PATCH] FIX: filament vendor submenu never opens when each group has one preset Hovering a category row (Custom, Bambu, Generic, ...) in the Project Filaments dropdown is supposed to open a submenu listing that vendor's presets. Often it does nothing at all. DropDown::hoverIndex() short-circuits on `count == items.size()` and returns the row index unchanged, assuming equal counts mean nothing is grouped. That does not hold when every group contains exactly one item: each group still collapses to a single row, so the counts match while grouping is present. The -i-2 group-row encoding is then never produced and mouseMove() cannot open the submenu. This is why it looks intermittent. It depends only on the preset list -- as soon as one vendor has two or more compatible presets the counts differ, the shortcut is skipped, and every submenu works again. Track has_groups in messureSize() next to count and require it to be false before taking the shortcut. selectedItem() had the same flaw, mispositioning the check mark in the affected lists. Also guard the subDropDown dereference in mouseMove(), which this makes reachable. --- src/slic3r/GUI/Widgets/DropDown.cpp | 8 +++++--- src/slic3r/GUI/Widgets/DropDown.hpp | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/Widgets/DropDown.cpp b/src/slic3r/GUI/Widgets/DropDown.cpp index d905b8a8eaf..8f1d30b6b53 100644 --- a/src/slic3r/GUI/Widgets/DropDown.cpp +++ b/src/slic3r/GUI/Widgets/DropDown.cpp @@ -418,7 +418,8 @@ int DropDown::hoverIndex() { if (hover_item < 0) return -1; - if (count == items.size()) + // Counts also match when every group holds one item, so check has_groups too + if (count == items.size() && !has_groups) return hover_item; int index = -1; std::set groups; @@ -446,7 +447,7 @@ int DropDown::selectedItem() { if (selection < 0) return -1; - if (count == items.size()) + if (count == items.size() && !has_groups) return selection; auto & sel = items[selection]; if (group.IsEmpty() ? !sel.group.IsEmpty() : sel.group != group) @@ -559,6 +560,7 @@ void DropDown::messureSize() // Gtk has a wrapper window for popup widget gtk_window_resize (GTK_WINDOW (m_widget), szContent.x, szContent.y); #endif + has_groups = !groups.empty(); if (!groups.empty() && subDropDown == nullptr) { subDropDown = new DropDown(items); subDropDown->mainDropDown = this; @@ -715,7 +717,7 @@ void DropDown::mouseMove(wxMouseEvent &event) if (hover == hover_item) return; hover_item = hover; int index = hoverIndex(); - if (index < -1) { + if (index < -1 && subDropDown) { auto & drop = *subDropDown; drop.group = items[-index - 2].group; drop.need_sync = true; diff --git a/src/slic3r/GUI/Widgets/DropDown.hpp b/src/slic3r/GUI/Widgets/DropDown.hpp index ac3ea717211..10da61d7e20 100644 --- a/src/slic3r/GUI/Widgets/DropDown.hpp +++ b/src/slic3r/GUI/Widgets/DropDown.hpp @@ -37,6 +37,7 @@ class DropDown : public PopupWindow private: std::vector &items; size_t count = 0; + bool has_groups = false; // set by messureSize() wxString group; bool need_sync = false; int selection = -1;