antoyo / relm

Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust
MIT License
2.44k stars 78 forks source link

unexpected behavior of nested views in embedded separated component #279

Open emmanueltouzery opened 3 years ago

emmanueltouzery commented 3 years ago

relm 21 nested views are amazing!

I've used them in a greenfield project to add titlebar menus without any imperative code. in that project I have the titlebar directly in the main window component. This works without problems.

I now wanted to use the same pattern also in another project where the titlebar component is split from the window component, and it does not work well.

I made a repro github: https://github.com/emmanueltouzery/relm11issue

This is the main thing:

        gtk::Window {
            titlebar: Some(self.model.titlebar.widget())
        }

In the project where this works fine, I have directly the titlebar component nested within the window view, as is now possible with relm 21. But in this legacy project the titlebar component is so large that I'll keep it separate from the window component. But in this configuration I have trouble with nested views in the separate titlebar component.

If I run the project from this github, the titlebar is translucent, and I get the following GTK errors on the command-line:

(relm11issue:55675): Gtk-CRITICAL **: 22:03:03.630: gtk_window_get_default_widget: assertion 'GTK_IS_WINDOW (window)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:03.630: gtk_window_set_default: assertion 'GTK_IS_WINDOW (window)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:03.648: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:03.648: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:03.648: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:03.649: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:03.649: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:03.650: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:03.651: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:03.651: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.557: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.557: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.557: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.572: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.572: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.572: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.589: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.589: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.589: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.606: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.606: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.606: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.623: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.623: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.623: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.638: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.638: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.638: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.655: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.655: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.655: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.671: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.672: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.672: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.689: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.689: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.689: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.706: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.706: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.706: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.722: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.722: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.722: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.738: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.738: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.738: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.754: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.754: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.754: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.771: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.771: gtk_render_frame_gap: assertion 'xy1_gap <= height' failed

(relm11issue:55675): Gtk-CRITICAL **: 22:03:04.771: gtk_widget_translate_coordinates: assertion 'GTK_IS_WIDGET (dest_widget)' failed

emmanueltouzery commented 3 years ago

and so in this sample project, just commenting this in the titlebar file fixes all the errors:

                // popover: view! {
                //     gtk:: Popover {
                //         gtk::Box {}
                //     }
                // }
antoyo commented 3 years ago

I don't understand right now what's happening. I'll have to take a deeper look.

I wonder if there's something weird with Popover, because there's another weird issues that is related to Popover:

266