[virt-tools-list] [PATCH v3 3/5] Port to GtkApplication API's

Eduardo Lima (Etrunko) etrunko at redhat.com
Fri Feb 12 19:48:07 UTC 2016


On 02/12/2016 03:26 PM, Eduardo Lima (Etrunko) wrote:
> On 02/12/2016 10:09 AM, Eduardo Lima (Etrunko) wrote:
>> Running remote-viewer will throw some warnings:
>>
>> (remote-viewer:546): Gtk-CRITICAL **: gtk_application_get_app_menu:
>> assertion 'GTK_IS_APPLICATION (application)' failed
>>
>> (remote-viewer:546): Gtk-CRITICAL **: gtk_application_get_menubar:
>> assertion 'GTK_IS_APPLICATION (application)' failed
>>
>> This does not happen with virt-viewer. I attached the gdb backtrace to
>> this mail.
>>
> 
> Fidencio just pointed out that these warnings won't happen with recent
> versions of glib/gtk as for instance the ones shipped with fedora, and I
> can confirm it. Also, I have some minor additions to this patch that I
> just added:

Following up, I tracked down to this gtk+ commit which makes the
warnings disappear. In this case I think they can be ignored.

commit 1bb880af36d4dfbda743a6fa3c68815963549a49
Author: Matthias Clasen <mclasen at redhat.com>
Date:   Sat Jun 7 14:04:57 2014 -0400

    GtkApplicationWindow: Avoid a crash

    In several places, we were not correctly dealing with the
    possibility of application not being set.

diff --git a/gtk/gtkapplicationwindow.c b/gtk/gtkapplicationwindow.c
index bf037ff..aba45a7 100644
--- a/gtk/gtkapplicationwindow.c
+++ b/gtk/gtkapplicationwindow.c
@@ -298,9 +298,10 @@ gtk_application_window_update_shell_shows_app_menu
(GtkApplicationWindow *window
       /* the shell does not show it, so make sure we show it */
       if (g_menu_model_get_n_items (G_MENU_MODEL
(window->priv->app_menu_section)) == 0)
         {
-          GMenuModel *app_menu;
+          GMenuModel *app_menu = NULL;

-          app_menu = gtk_application_get_app_menu
(gtk_window_get_application (GTK_WINDOW (window)));
+          if (gtk_window_get_application (GTK_WINDOW (window)) != NULL)
+            app_menu = gtk_application_get_app_menu
(gtk_window_get_application (GTK_WINDOW (window)));

           if (app_menu != NULL)
             {
@@ -347,9 +348,10 @@ gtk_application_window_update_shell_shows_menubar
(GtkApplicationWindow *window,
       /* the shell does not show it, so make sure we show it */
       if (g_menu_model_get_n_items (G_MENU_MODEL
(window->priv->menubar_section)) == 0)
         {
-          GMenuModel *menubar;
+          GMenuModel *menubar = NULL;

-          menubar = gtk_application_get_menubar
(gtk_window_get_application (GTK_WINDOW (window)));
+          if (gtk_window_get_application (GTK_WINDOW (window)) != NULL)
+            menubar = gtk_application_get_menubar
(gtk_window_get_application (GTK_WINDOW (window)));

           if (menubar != NULL)
             g_menu_append_section (window->priv->menubar_section, NULL,
menubar);



-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etrunko at redhat.com




More information about the virt-tools-list mailing list