After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 742664 - Portabilitiy issues with GTK-Inspector 32-bit and non-gnome3 desktop
Portabilitiy issues with GTK-Inspector 32-bit and non-gnome3 desktop
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
3.14.x
Other Windows
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 742674
 
 
Reported: 2015-01-09 18:55 UTC by Hans Breuer
Modified: 2015-01-11 19:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fake org.gnome.desktop.interface.gschema.xml (663 bytes, text/xml)
2015-01-09 18:55 UTC, Hans Breuer
Details
Screenshow of GTK-Inspector with win32 theme (51.76 KB, image/png)
2015-01-09 18:59 UTC, Hans Breuer
Details

Description Hans Breuer 2015-01-09 18:55:13 UTC
Created attachment 294175 [details]
Fake org.gnome.desktop.interface.gschema.xml 

- during initialization the GTK-Inspector spits a lot of g_warnings, like
  
  Gtk-WARNING **: gtktreestore.c:1042: Invalid column number
  58682896 added to iter (remember to end your list of columns with a -1)

   These are due to size mismatch between resource-list .c and .ui of
   GtkTreeStore::model::column[3] as guint64 vs gsize in code.

 - due to the unforgiveness of GSettings API the following code g_error(s):

  settings = g_settings_new ("org.gnome.desktop.interface");
  current_theme = g_settings_get_string (settings, "gtk-theme");

   without a compiled org.gnome.desktop.interface.gschema.xml file. That code
   is from gtk/inspector/visual.c.

   IMHO the best fix would be a redesign of GSettings API to make all those
   g_error superfluous (or at least much less probable). As a kludge I'm
   attaching the minimal settings file I've used.
Comment 1 Hans Breuer 2015-01-09 18:59:52 UTC
Created attachment 294176 [details]
Screenshow of GTK-Inspector with win32 theme

To create the atached screenshot I hacked on part of Gtk+ 3.16 Roadmap, namely "Include icon theme in builds for other platforms". But that's stuff for another bug report.
Comment 2 Emmanuele Bassi (:ebassi) 2015-01-09 19:25:51 UTC
(In reply to comment #0)

>  - due to the unforgiveness of GSettings API the following code g_error(s):
> 
>   settings = g_settings_new ("org.gnome.desktop.interface");
>   current_theme = g_settings_get_string (settings, "gtk-theme");
> 
>    without a compiled org.gnome.desktop.interface.gschema.xml file. That code
>    is from gtk/inspector/visual.c.
> 
>    IMHO the best fix would be a redesign of GSettings API to make all those
>    g_error superfluous (or at least much less probable).

no, that would not be the best fix at all; and no, it won't happen.

there is API enough in GSettings to discover if a schema is available, and if not, ignore the setting.

> As a kludge I'm attaching the minimal settings file I've used.

the actual fix would be to not get that string out of GSettings on !G_OS_UNIX; alternatively, use GSettingsSchemaSource to check if the "org.gnome.desktop.interface" schema exists, and if it does not, use GtkSettings:gtk-theme-name instead of the GSettings value.
Comment 3 Hans Breuer 2015-01-09 20:14:50 UTC
(In reply to comment #2)
> the actual fix would be to not get that string out of GSettings on !G_OS_UNIX;
So with G_OS_UNIX it's OK to g_error() with missing schema?

> alternatively, use GSettingsSchemaSource to check if the
> "org.gnome.desktop.interface" schema exists, and if it does not, use
> GtkSettings:gtk-theme-name instead of the GSettings value.
So if "org.gnome.desktop.interface" exists it _must_ contain 'monospace-font-name', 'gtk-theme' and 'icon-theme'?

I was looking for something like g_settings_has_key() but could not find anything like that. So for now I'll use the kludge mentioned above.
Comment 4 Emmanuele Bassi (:ebassi) 2015-01-09 20:25:39 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > the actual fix would be to not get that string out of GSettings on !G_OS_UNIX;
> So with G_OS_UNIX it's OK to g_error() with missing schema?

yes, because there's an expectation of settings being properly installed.

> > alternatively, use GSettingsSchemaSource to check if the
> > "org.gnome.desktop.interface" schema exists, and if it does not, use
> > GtkSettings:gtk-theme-name instead of the GSettings value.
> So if "org.gnome.desktop.interface" exists it _must_ contain
> 'monospace-font-name', 'gtk-theme' and 'icon-theme'?

yes: https://git.gnome.org/browse/gsettings-desktop-schemas/tree/schemas/org.gnome.desktop.interface.gschema.xml.in.in

> I was looking for something like g_settings_has_key() but could not find
> anything like that. So for now I'll use the kludge mentioned above.

or you could install gsettings-desktop-schemas instead.
Comment 5 Hans Breuer 2015-01-09 20:45:42 UTC
(In reply to comment #4)
> or you could install gsettings-desktop-schemas instead.
Which kind of contradicts portability (or cross-platform-ness), wouldn't it?
Things like "cursor-blink-timeout" or "toolbar-icons-size" could be got from the real systems desktop settings, not from some compiled Gnome defaults.

Meanwhile this bug is closed as fixed, but I wonder how that could happen without any code change in resource-list.c. Or is some push to origin/gtk-3-14 still pending?
Comment 6 Hans Breuer 2015-01-09 20:50:09 UTC
Something like:

diff --git a/gtk/inspector/resource-list.c b/gtk/inspector/resource-list.c
index 44fb34c..ce0d966 100644
--- a/gtk/inspector/resource-list.c
+++ b/gtk/inspector/resource-list.c
@@ -99,7 +99,7 @@ load_resources_recurse (GtkInspectorResourceList *sl,

       gtk_tree_store_set (sl->priv->model, &iter,
                           COLUMN_COUNT, count,
-                          COLUMN_SIZE, size,
+                          COLUMN_SIZE, (guint64)size,
                           -1);
       *count_out += count;
       *size_out += size;
Comment 7 Emmanuele Bassi (:ebassi) 2015-01-09 21:08:31 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > or you could install gsettings-desktop-schemas instead.
> Which kind of contradicts portability (or cross-platform-ness), wouldn't it?
> Things like "cursor-blink-timeout" or "toolbar-icons-size" could be got from
> the real systems desktop settings, not from some compiled Gnome defaults.

the existence of the default in the schema does not reflect whether those settings get updated using the system's API or not. the schemas only define the type and default value of a setting.
Comment 8 Emmanuele Bassi (:ebassi) 2015-01-09 21:10:41 UTC
the issue has been fixed in Git:

https://git.gnome.org/browse/gtk+/commit/?id=6384167054307ce7af249e40e47973d4761d97ab

inspector: Don't use GSettings directly

It is not necessary here, and using GtkSettings gives us a greater chance to not fail e.g. on Windows.

https://bugzilla.gnome.org/show_bug.cgi?id=742664

it will be backported to 3.14 once a new release of 3.14 is due.
Comment 9 Hans Breuer 2015-01-09 21:29:41 UTC
Thanks for the fast responses, but this is still not fixing the pure 32-bit portability issue from comment 1 and comment 6. The 

  Gtk-WARNING **: gtktreestore.c:1042: Invalid column number
  58682896 added to iter (remember to end your list of columns with a -1)

is also visible on Linux Mint. Only condtion AFAICT sizeof(gsize)<sizeof(guin64).
Comment 10 Emmanuele Bassi (:ebassi) 2015-01-09 21:33:55 UTC
(In reply to comment #9)
> Thanks for the fast responses, but this is still not fixing the pure 32-bit
> portability issue from comment 1 and comment 6. The 
> 
>   Gtk-WARNING **: gtktreestore.c:1042: Invalid column number
>   58682896 added to iter (remember to end your list of columns with a -1)
> 
> is also visible on Linux Mint. Only condtion AFAICT
> sizeof(gsize)<sizeof(guin64).

let's clone this bug and track the other issue separately.
Comment 11 Hans Breuer 2015-01-09 22:18:58 UTC
Looking at the patch and my settings file there is still the same issue with monospace-font-name (inspector/css-editor.c).

Overall there are more unconditional g_settings_get_*() calls, namely in gtkfilechooserwidget.c(settings_load) and gtkcolorchooserwidget.c(gtk_color_chooser_widget_init). But maybe I misinterpret Matthias' commit log "Don't use GSettings directly" ;) But at least these other two are using g_settings_new ("org.gtk.*") settings.
Comment 12 Matthias Clasen 2015-01-10 00:13:14 UTC
there is nothing wrong in principle with using gsettings on windows. the calls in gtk/* are using schemas that are shipped with GTK+. The ones I removed in gtk/inspector/* are a little different, because we can't really guarantee the presence of gnome schemas on windows.