Commit Graph

71 Commits

Author SHA1 Message Date
Philip Withnall
b0b5ed8c34 docs: Move the GResource SECTION
Move it to the struct docs.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>

Helps: #3037
2023-10-25 15:10:16 +01:00
Alex Richardson
a1dfecf11f Use g_once_init_{enter,leave}_pointer where appropriate
This should not result in any functional changes, but will eventually
allow glib to be functional on CHERI-enabled systems such as Morello.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
2023-10-04 13:57:16 +01:00
Marco Trevisan (Treviño)
ea904fba1a gresource: Use compare and exchange full to get registered resources 2023-05-30 12:34:41 +01:00
Philip Withnall
28f83c9cf7 gresource: Ensure lazy_register_resources is always accessed atomically
On some platforms, pointer-sized reads are not necessarily atomic, so we
always need to use the correct atomic access primitives.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-30 12:33:48 +01:00
Marco Trevisan (Treviño)
bfd77693ce gresource: Use atomic pointer exchange operations to nullify and check 2022-06-23 20:01:12 +02:00
Philip Withnall
5942cd7984 gio: Add SPDX license headers automatically
Add SPDX license (but not copyright) headers to all files which follow a
certain pattern in their existing non-machine-readable header comment.

This commit was entirely generated using the command:
```
git ls-files gio/*.[ch] | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs'
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1415
2022-05-18 09:18:52 +01:00
Philip Withnall
86927c39e0 gresource: Assert that resource has correct refcount when unregistering
This should fix a scan-build warning that `resource` is
used-after-freeing in the final `g_resource_unref()` call in
`g_static_resource_fini()`, as `g_resources_unregister_unlocked()` has
already unreffed it.

In reality, each resource has two strong refs on it while active, so the
second unref is correct.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-10 15:53:19 +01:00
Loic Le Page
98c1b84617 Fix redefinition of local variable and non-initialized variable in gio/gresource.c 2022-02-18 11:01:41 +01:00
Philip Withnall
e2b5094cdb gresource: Ignore G_RESOURCE_OVERLAYS when running as setuid
It could have been used to load private data which would not normally be
accessible to an unprivileged caller.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2168
2021-01-07 15:02:25 +00:00
Philip Withnall
9716a26ab6 Merge branch '1281-to-pixdata-docs' into 'master'
gresource: Document the `to-pixdata` option as being deprecated

Closes #1281

See merge request GNOME/glib!1826
2021-01-04 12:58:42 +00:00
Timm Bäder
105e44beb5 gresource: Avoid work for NULL errors
Don't go through gettext if the GError** passed is NULL anyway.
2020-12-31 14:58:40 +01:00
Philip Withnall
b63e9889a8 gresource: Document the to-pixdata option as being deprecated
Just embed a PNG instead. gdk-pixbuf deprecated its pixdata support in
version 2.32, in 2015.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #1281
2020-12-22 18:42:05 +00:00
Philip Withnall
7d417f8406 gresource: Fix a pointer mismatch with an atomic load
This squashes a warning when compiling with Clang.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-11-20 14:41:07 +00:00
Philip Withnall
353020928c gresource: Fix handling of zero-sized compressed resource entries
The zlib `GConverter` can’t handle an output buffer of size 0.

Add tests.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #1560
2020-11-14 19:03:18 +00:00
James Westman
2ec4e05733 docs: glib-compile-resources: json-stripblanks
Document the `json-stripblanks` preprocessing option for .gresource.xml files.
2020-08-13 08:07:51 +00:00
Sonny Piers
06f27fc208 doc: fix typo in gio/gresource.c 2019-07-08 10:48:23 +00:00
Руслан Ижбулатов
294d818336 Use OS-dependent separator for G_RESOURCE_OVERLAYS
G_RESOURCE_OVERLAYS is a list of resource-path and filesystem-path pairs.
Since on Windows filesystem paths use ':', this list can't be ':'-separated
there. Fix that by making it ';'-separated on Windows. Make the parser
error clearer (we're not looking for a slash, we're looking for an absolute
path).
2019-02-13 08:49:42 +00:00
Matthias Clasen
68bcb8f048 gresource: Complete the overlay support
Unlike the other g_resources_ functions, g_resources_get_info
was not respecting G_RESOURCE_OVERLAYS. Add this missing
support.

Closes: #1445
2019-01-10 12:31:09 -05:00
Philip Withnall
614adf8a75 gvdb: Fix error handling in gvdb_table_new()
The documentation was unclear about what error codes would be returned
on attempting to open an empty or corrupt GVDB file. Previous versions
of the documentation incorrectly said that corrupt GVDB files were
considered equivalent to empty ones.

A recent commit has clarified the documentation to include its error
handling behaviour.

Update the two users of GVDB within GLib, GResource and GSettingsSource,
to follow this change, and add unit tests for them both.

Other users of the GVDB copylib will need to update their copy and make
appropriate changes if they have bugs in their handling of this
situation. dconf is one example of this. GVDB should be updated from
https://gitlab.gnome.org/GNOME/gvdb.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/1454
2018-08-13 15:38:34 +01:00
Philip Withnall
705dd2b9a9 gresource: Port to new GVDB API
This should introduce no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-13 15:37:05 +01:00
Philip Withnall
ab87af1734 gresource: Fix potential array overflow if using empty paths
Adds tests to cover this case and similar cases for various GResource
methods in future.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/927
2018-07-05 12:03:10 +01:00
Philip Withnall
f62d7c1e2a gresource: Fix wrapping of function return type
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-07-05 11:19:20 +01:00
Christian Hergert
5464461e4c gresource: avoid allocations in enumerate_children()
In the vast majority of cases, we can avoid temporary
allocations for paths in g_resources_enumerate_children().

In the case we need to add a suffix "/", we can usually just
build the path on the stack. In other cases, we can completely
avoid the strdup, which appears to only have been added for
readability. If the path is really long, we fallback to doing
what we did before, and use g_strconcat().

In the case of Builder, this saved 5.3mb of temporary
allocations in the process of showing the first application
window.

https://bugzilla.gnome.org/show_bug.cgi?id=790275
2017-11-15 03:24:29 -08:00
Sebastian Dröge
7b60708204 GResource – Create an internal copy of the GBytes if it is not pointer aligned
https://bugzilla.gnome.org/show_bug.cgi?id=790030
2017-11-14 10:39:45 +02:00
Sebastian Dröge
3c9c01e3ce GResource – Add note to documentation that the memory must be at least pointer aligned
https://bugzilla.gnome.org/show_bug.cgi?id=790030
2017-11-14 10:19:58 +02:00
Bastien Nocera
a95e2a4c64 docs: Fix cut'n'paste error in g_resources_get_info() doc
https://bugzilla.gnome.org/show_bug.cgi?id=784581
2017-07-05 23:50:04 +02:00
Philip Withnall
c7d325733c docs: Mention GtkApplication in the GResource documentation
Since GtkApplication auto-loads some well-known resource paths. Add a
cross-reference to its documentation. (The cross-reference won’t be
linked if the GTK+ documentation isn’t available at build time, but this
is probably good enough. It is likely to be available.)

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=782336
2017-05-31 11:09:51 +01:00
Philip Withnall
678899e87a docs: Mention the alias GResource attribute in the documentation
It was the only part of the XML format which was not documented.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=782336
2017-05-31 11:08:05 +01:00
Philip Withnall
29b4e9b05f docs: Improve formatting and fix typos in GResource documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-05-31 10:55:45 +01:00
Sébastien Wilmet
3bf4a720c3 gio/: LGPLv2+ -> LGPLv2.1+
Sub-directories inside gio/ already processed in a previous commit:
- fam/
- gdbus-2.0/ (which contains only codegen/)
- gvdb/
- inotify/
- tests/
- win32/
- xdgmime/

Other sub-directories inside gio/:
- completion/: no license headers
- kqueue/: not LGPL, BSD-style license

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Christian Hergert
18a33f72db introspection: use (nullable) or (optional) instead of (allow-none)
If we have an input parameter (or return value) we need to use (nullable).
However, if it is an (inout) or (out) parameter, (optional) is sufficient.

It looks like (nullable) could be used for everything according to the
Annotation documentation, but (optional) is more specific.
2016-11-22 14:14:37 -08:00
Piotr Drąg
10c490cdfe Use Unicode in translatable strings
See https://developer.gnome.org/hig/stable/typography.html

https://bugzilla.gnome.org/show_bug.cgi?id=772221
2016-10-12 21:30:42 +02:00
Chun-wei Fan
217b620a7b gresource.c: Use g_file_test()
Use the g_file_test() API instead of the g_stat() + S_ISDIR combo to fix
builds on compilers that do not support S_ISDIR.

https://bugzilla.gnome.org/show_bug.cgi?id=765991
2016-05-04 23:50:18 +08:00
Allison Ryan Lortie
55ab3af098 GResources: add support for resource overlays
When debugging a program or testing a change to an installed version, it
is often useful to be able to replace resources in the program or a
library, without recompiling.

To support this, for debugging and hacking purposes, it's now possible
to define a G_RESOURCE_OVERLAYS environment variable as a
colon-separated list of substitutions to perform when looking up
GResources.

A substitution has the form

  "/org/gtk/libgtk=/home/desrt/gtk-overlay"

The part before the '=' is the resource subpath for which the overlay
applies.  The part after is a filesystem path which contains files and
subdirectories as you would like to be loaded as resources with the
equivalent names.

In the example above, if an application tried to load a resource with
the resource path '/org/gtk/libgtk/ui/gtkdialog.ui' then GResource would
check the filesystem path '/home/desrt/gtk-overlay/ui/gtkdialog.ui'.  If
a file was found there, it would be used instead.

Substitutions must start with a slash, and must not have a trailing
slash before the '='.  It is possible to overlay the location of a
single resource with an individual file.

https://bugzilla.gnome.org/show_bug.cgi?id=765668
2016-04-28 14:36:13 +02:00
Allison Ryan Lortie
3c7c0af1c9 GResources: use g_hash_table_get_keys_as_array()
Replace the hand-written equivalent of this with the call to the
GHashTable built-in version to save a few lines of code.

The GResource code was written a couple of years before this function
existed.

Similarly, replace a set-mode usage of g_hash_table_insert() with a call
to g_hash_table_add().

https://bugzilla.gnome.org/show_bug.cgi?id=765668
2016-04-28 14:36:13 +02:00
c2d0c40bff Fix gettext use
gettext() calls inside library have to use gi18n-lib.h.

https://bugzilla.gnome.org/show_bug.cgi?id=758553
2015-12-16 07:47:53 -05:00
Philip Withnall
7f195ac956 gresource: Clarify error docs for g_resource_enumerate_children()
Document that it returns G_RESOURCE_ERROR_NOT_FOUND if the path doesn’t
exist.
2015-07-28 10:14:17 +01:00
Cosimo Cecchi
0d6e200384 gresource: fix a couple of typos in documentation 2015-06-11 15:56:25 -07:00
Philip Withnall
31496767c7 gresource: Document generated C file function naming
Mention the relationship to the --c-name argument, plus the need to call
some_prefix_get_resource() to get the GResource object.
2015-05-14 08:31:22 +01:00
Philip Withnall
a8c157f92b gresource: Minor capitalisation fixes in documentation 2015-05-14 08:15:46 +01:00
Xavier Claessens
15a4af545e Doc: Mark a few things as private 2015-03-12 16:09:14 -04:00
Xavier Claessens
74c22150cf docs: fix up docs issues in gio/ 2015-02-05 16:20:43 +01:00
Rico Tzschichholz
e0e52b60ea docs: Fix broken gtk-doc formatting 2014-08-18 14:08:41 +02:00
William Jon McCann
20f4d1820b docs: use "Returns:" consistently
Instead of "Return value:".
2014-02-19 19:41:52 -05:00
Matthias Clasen
e7fd3de86d Eradicate links and xrefs
These are all replaced by markdown ref links.
2014-02-08 12:26:56 -05:00
Matthias Clasen
3232425785 Docs: replace <literal> by ` 2014-02-06 08:07:16 -05:00
Matthias Clasen
0cc20b7e0b Don't use <filename> in docs
Switch to simpler markdown, `foo`.
2014-02-05 20:17:46 -05:00
Matthias Clasen
111803030d Don't use <envar> in docs
Switch to simpler markdown, `foo`.
2014-02-05 19:32:41 -05:00
Matthias Clasen
306dfb3292 Drop use of the command tag
It is more useful to link to the included man page, anyway.
2014-02-01 15:26:38 -05:00
Matthias Clasen
17f51583a8 Docs: Convert examples to |[ ]| 2014-01-31 21:56:33 -05:00