Commit Graph

6 Commits

Author SHA1 Message Date
Peter Bloomfield
54d319bc32 gtkimagedefinition: Extend commit b38266c0
Similarly, uses casts in `gtk_image_definition_unref()`. Compilation
succeeds without them, unlike in `gtk_image_definition_ref()`, because
`gtk_image_definition_unref()` is not called internally, unlike
`gtk_image_definition_ref()`. But the build would fail if some function
defined in the module were changed in the future to call
`gtk_image_definition_unref()`, and we can future-proof it now. This
also removes an inconsistency in how we access the members of the union.
2022-04-30 13:09:04 -04:00
Peter Bloomfield
a5d208adaf gtkimagedefinition: Check array bounds
`jhbuild build gtk+-3` with GCC 12 fails with:
```
In function ‘gtk_image_definition_ref’,
    inlined from ‘gtk_image_definition_new_empty’
    at ../../../../jhbuild/checkout/gtk+-3/gtk/gtkimagedefinition.c:107:10:
../../../../jhbuild/checkout/gtk+-3/gtk/gtkimagedefinition.c:241:13: error:
    array subscript ‘GtkImageDefinition {aka union _GtkImageDefinition}[0]’
    is partly outside array bounds of ‘GtkImageDefinitionEmpty[1]’
    {aka ‘struct _GtkImageDefinitionEmpty[1]’} [-Werror=array-bounds]
  241 |   def->empty.ref_count++;
      |   ~~~~~~~~~~^~~~~~~~~~
../../../../jhbuild/checkout/gtk+-3/gtk/gtkimagedefinition.c:
    In function ‘gtk_image_definition_new_empty’:
../../../../jhbuild/checkout/gtk+-3/gtk/gtkimagedefinition.c:105:34: note:
object ‘empty’ of size 8
  105 |   static GtkImageDefinitionEmpty empty = { GTK_IMAGE_EMPTY, 1 };
      |                                  ^~~~~
```
and many similar errors.

Fix it by casting `GtkImageDefinition` to `GtkImageDefinitionEmpty` or
similar, as appropriate.

Essentially backports 4dcd02e85315f487310e2e01fe9412706a77dc35 from main to gtk-3-24.
2022-04-30 13:08:32 -04:00
Christoph Reiter
47325a827b imagedefinition: The storage type is not a boolean 2015-12-19 06:13:56 +01:00
Krzesimir Nowak
cbbaad4135 imagedefinition: Assert when trying to free empty definition
Empty definitions are not allocated on a heap, so doing a g_free() on
it would crash anyway.
2015-12-02 12:46:21 +01:00
Benjamin Otte
4a42aa5229 imagedefinition: Remove icon-size
The size of icons is a property that is relevant to who is rendering the
icon, not to the icon itself.

Example: Starting a DND operation from an entry icon should cause the
icon to resize (from the entr icon's size to the DND icon size).
2015-12-02 00:29:30 +01:00
Benjamin Otte
e666106a43 imagedefinition: Split out from icon helper
The image definition is supposed to hold the description about the image
to be displayed. The icon helper actually does caching and tracks
changes.
2015-12-02 00:29:29 +01:00