Fix Gtk-CRITICAL assertions creating noise and occasional lag in Linux/GTK (#11897)

* Fix Gtk-Critical assertion in PresetComboBoxes

Resolve the `gtk_cell_layout_get_cells: assertion GTK_IS_CELL_LAYOUT
failed` error by switching from `gtk_cell_layout_get_cells()` to
`gtk_container_get_children()` with direct PangoLayout ellipsization
on GtkEntry widgets.

Picked from PrusaSlicer:
https://github.com/prusa3d/PrusaSlicer/commit/e855ab5d

* Add defensive guards for GTK widget sizing

Fix Gtk-CRITICAL assertions in TextInput and DropDown widgets that
occur when the widget attempt relative sizing against window size
before GTK completes the window layout.

Changes include:
- TextInput.cpp: Clamp textSize.x >= -1 to prevent
  `gtk_widget_set_size_request` failures.
  - Picked from Prusa Slicer:
    https://github.com/prusa3d/PrusaSlicer/commit/e855ab5d
- DropDown.cpp: Guard against zero/negative dimensions during early
  initialization:
  - Prevent szContent.x = 0 when parent size is unavailable.
    - Unique to OrcaSlicer
    - Triggers during initializing DesignerPanel --> BasicInfo -->
      License DropDown before a parent size is available.
    - Latent bug exists in Bambu Studio, but Bambu does not have
      License field enabled on this panel.
    - Created global guard for future resilience.
  - Clamp szContent.y >= 1 for dropdowns before content initialized.
    - Bug exists in BambuStudio
    - Prusa did not implement the "ENH: ComboBox Second DropDown"
This commit is contained in:
bdunks
2026-01-13 08:13:51 -05:00
committed by GitHub
parent 8c2f3290f2
commit 9561b9e8c0
3 changed files with 26 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
#include "DropDown.hpp"
#include "Label.hpp"
#include <cstdio>
#include <wx/display.h>
#include <wx/dcbuffer.h>
#include <wx/dcgraph.h>
@@ -533,7 +534,7 @@ void DropDown::messureSize()
if (count > 15) szContent.x += 6;
if (GetParent() && group.IsEmpty()) {
auto x = GetParent()->GetSize().x;
if (!use_content_width || x > szContent.x)
if (x > 0 && (!use_content_width || x > szContent.x))
szContent.x = x;
}
rowSize = szContent;
@@ -544,7 +545,7 @@ void DropDown::messureSize()
szContent = rowSize;
}
}
szContent.y *= std::min((size_t) 15, count);
szContent.y *= std::min((size_t) 15, std::max(count, (size_t) 1));
szContent.y += items.size() > 15 ? rowSize.y / 2 : 0;
wxWindow::SetSize(szContent);
#ifdef __WXGTK__