interacting with dropdowns spills a lot of gtk-criticals in the console
MichaelSchloesser opened this issue · 3 comments
Running the code snippet below (on Ubuntu or Window 10) and interacting with the dropdowns results in a lot of Gtk-criticals messages like:
(julia:8820): Gtk-CRITICAL **: 13:15:58.498: gtk_list_item_set_child: assertion 'child == NULL || gtk_widget_get_parent (child) == NULL' failed
main() do app::Application
window = Window(app)
dropdown_1 = DropDown()
item_01_id = push_back!(dropdown_1, "Item #01")
item_02_id = push_back!(dropdown_1, "Item #02")
item_03_id = push_back!(dropdown_1, "Item #03")
dropdown_2 = DropDown()
item_04_id = push_back!(dropdown_2, "Item #04")
item_05_id = push_back!(dropdown_2, "Item #05")
item_06_id = push_back!(dropdown_2, "Item #06")
box = vbox(dropdown_1, dropdown_2)
set_spacing!(box, 10)
set_margin!(box, 10)
set_child!(window, box)
present!(window)
end
Addtionally on Ubuntu the window opening when clicking a dropdown behaves as desribed in #79 and sometimes appears behind the main window making it impossible to further interact with it.
This may be related to this.
I can reproduce the warnings, MWE:
using Mousetrap
main() do app::Application
window = Window(app)
dropdown = DropDown()
push_back!(dropdown, "Test")
push_back!(dropdown, "Test")
set_child!(window, dropdown)
present!(window)
end
I will investigate what could be causing this, I think it is most likely something in the C++ component
I can't reproduce the window issue but I have an ubuntu machine to try it there
Error messages seemed to be fixed when I wrapped the widgets in a check to see if the parent has been assigned or not. I suppose that this means the method is being called more than once?
{
auto* item = GTK_LIST_ITEM(object);
auto* dropdown_item = detail::G_DROP_DOWN_ITEM(gtk_list_item_get_item(item));
if(gtk_widget_get_parent(dropdown_item->list_widget) == NULL)
gtk_list_item_set_child(item, dropdown_item->list_widget);
}
void DropDown::on_list_factory_teardown(GtkSignalListItemFactory* self, void* object, detail::DropDownInternal* internal)
{
// noop
}
void DropDown::on_label_factory_bind(GtkSignalListItemFactory* self, void* object, detail::DropDownInternal* internal)
{
auto* item = GTK_LIST_ITEM(object);
auto* dropdown_item = detail::G_DROP_DOWN_ITEM(gtk_list_item_get_item(item));
if(gtk_widget_get_parent(dropdown_item->label_widget) == NULL)
gtk_list_item_set_child(item, dropdown_item->label_widget);
}