Commit Graph

1652 Commits

Author SHA1 Message Date
Emmanuele Bassi
e5ba5845a1 Revert "headers: Add various missing G_DISABLE_DEPRECATED guards"
This reverts commit 80fcb1bc26.

G_DISABLE_DEPRECATED should never be used by anybody, least of all by
GLib. We have deprecation annotations for the compiler, these days, and
they are much better suited than a macro that makes symbols appear and
disappear. The fact that gtk-doc doesn't understand the deprecation
annotations is a limitation of gtk-doc, and it's gtk-doc that ought to be
fixed.

Commit 80fcb1bc broke GStreamer, which disables old API that was
deprecated before the introduction of the deprecation annotations, but
still uses newly deprecated one, and relies on the deprecation
annotations to do their thing. It also broke libsoup, as it uses
GValueArray in its own API.
2019-03-16 11:30:13 +00:00
Philip Withnall
ba09fa8500 gvaluearray: Mark the whole of GValueArray as deprecated
This is not new; all of its methods have been deprecated for a long
time. Make the deprecation more obvious, however, by marking the whole
section as deprecated.

Note that GArray can’t *quite* do everything that GValueArray could.
See #1069 for work to fix this. This documentation block can be updated
again once that’s fixed.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:36 +00:00
Philip Withnall
80fcb1bc26 headers: Add various missing G_DISABLE_DEPRECATED guards
As pointed out by gtk-doc, these are all symbols which have been marked
as deprecated, but which aren’t protected by a deprecation guard. We
can’t use G_DEPRECATED_IN_* for them, as they are all non-function
symbols. Instead, wrap them in #ifndef G_DISABLE_DEPRECATED.

In some cases, we also need to wrap one or two functions which use the
deprecated types in G_DISABLE_DEPRECATED too.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-15 11:09:32 +00:00
Philip Withnall
3d3ca9f1fe gobject: Fix various compiler warnings when compiling with G_DISABLE_ASSERT
Mostly unused variables which are only used in a g_assert() call
otherwise.

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

Helps: #1708
2019-03-08 19:46:21 +00:00
Philip Withnall
d89f18bb22 build: Add -UG_DISABLE_ASSERT when building tests
In order to allow GLib itself to be built with G_DISABLE_ASSERT defined,
we need to explicitly undefine it when building the tests, otherwise
g_test_init() turns into an abort.

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

Fixes: #1708
2019-03-08 19:46:20 +00:00
Philip Withnall
2a570dc5af gobject: Mention quark memory usage for g_object_set_data()
g_object_set_data() should only ever be used with a small, bounded set
of keys, or the memory usage of the quark lookup table will grow
unbounded. Document that.

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

Fixes: #682
2019-03-07 10:56:47 +00:00
Philip Withnall
aeb7dbad30 Merge branch 'tsan' into 'master'
Fix thread safety issues

See merge request GNOME/glib!690
2019-03-05 11:46:33 +00:00
Christoph Reiter
7fa9a2a5da Merge branch 'gi-267-rename-header' into 'master'
Rename gobjectenumtypes.[ch] to glib-enumtypes.[ch]

See merge request GNOME/glib!702
2019-03-04 15:03:40 +00:00
Philip Withnall
ab93f3f86a gmarshal: Move marshaller documentation comments to above functions
Grouping things together makes them easier to find and keep up to date.
This doesn’t modify any of the comments or make any functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-04 12:33:17 +00:00
Philip Withnall
23f042d284 gmarshal: Drop trailing whitespace from gmarshal.c
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-04 12:33:17 +00:00
Philip Withnall
251430d467 gmarshal: Add copyright headers to gmarshal.[ch]
They were originally generated by glib-genmarshal, which documents its
output as being under the same license as the containing project. In
this case, that’s LGPL.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-04 12:33:17 +00:00
Philip Withnall
1a8e84c540 gmarshal: Drop references to gmarshal.list
It was removed in commit 9c66e65b29.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-04 12:33:17 +00:00
Philip Withnall
c3ac761a18 build: Rename gobjectenumtypes.[ch] to glib-enumtypes.[ch]
To reflect the fact that they contain the GObject types for various
enums defined in libglib.

See https://gitlab.gnome.org/GNOME/glib/merge_requests/481#note_451086.

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

Helps: GNOME/gobject-introspection#267
2019-03-04 11:12:59 +00:00
Krzesimir Nowak
d687a45704 tests: Fix closure-refcount to preserve old semantics
The threads used to iterate at least 10000 times before setting the
"seen thread" flag to true. After porting they inadvertently did that
in the first iteration.
2019-02-28 07:05:29 +01:00
Philip Withnall
1ae54da69b tests: Continue closure-refcount test until all three threads are seen
Previously, the test assumed that thread1 and thread2 would be scheduled
enough to set seen_thread{1,2} by the fact that the test runs for a high
number of iterations. On some platforms/schedulers, that’s not true,
which causes the test to spuriously fail.

Fix that by forcing the test to continue iterating until both threads
are seen. If this takes too long, the Meson test runner timeout will be
hit and the test will be terminated.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
86f4a02b65 tests: Fix thread safety in closure-refcount test
Previously, all three threads would access several global variables
without locking.

Fix that by using atomic accesses to data stored within the
test_closure_refcount() function, which also eliminates the global state
(which would confuse further tests if they were added to this file).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
5a2a7f7db1 tests: Port closure-refcount from g_thread_create() to g_thread_new()
g_thread_create() has been deprecated for a long time.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
85c02df04e tests: Use g_assert_*() in closure-refcount, rather than g_assert()
g_assert() can be compiled out if G_DISABLE_ASSERT is defined; and
g_assert_*() provide more specific error messages on failure.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
d6e9111986 tests: Fix some code formatting in closure-refcount
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
31664e62f9 tests: Remove unnecessary static attributes from variables
These functions are not run more than once, so the variables don’t need
to be static to save state between runs.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
3aec6a3976 tests: Minor GObject cleanup in closure-refcount
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
b4aadf6557 tests: Port closure-refcount to g_test_message() from g_print()
This allows more structured test output.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 11:59:24 +00:00
Philip Withnall
15958c3ba9 tests: Port closure-refcount to use g_test_run()
This allows more structured test running and output.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 11:59:23 +00:00
Philip Withnall
c96bfd57af build: Move tests/refcount/closures to gobject/tests/closure-refcount
One step towards removing the top-level tests/ directory.

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

Helps: #1434
2019-02-27 11:48:29 +00:00
Tomasz Miąsko
c4cb27d844 gobject: Use atomic operations to read object reference count 2019-02-22 18:09:32 +01:00
Tomasz Miąsko
fba7f7e097 gparam: Remove unsynchronized write to g_type field
GValue g_type field is used for synchronization with g_once_init_enter,
and so it should be written to only with g_once_init_leave.

Replace structure copy with memcpy that copies the one remaining field
of GValue, i.e., data array.
2019-02-22 17:53:18 +01:00
Tomasz Miąsko
d72192f69b gobject: Remove unsynchronized read of freeze_count
There is no need to preserve the check, since check is performed again
while holding the notify_locks that protects freeze_count.
2019-02-22 17:51:48 +01:00
Iain Lane
07a1a8031d
installed tests: Allow tests to set environment variables
It's necessary sometimes for installed tests to be able to run with a
custom environment. For example, the gsocketclient-slow test requires an
LD_PRELOADed library to provide a slow connect() (this is to be added in
a followup commit).

Introduce a variable `@env@` into the installed test template, which we
can override as necessary when generating `.test` files, to run tests
prefixed with `/usr/bin/env <LIST OF VARIABLES>`.

As the only test that requires this currently lives in `gio/tests/`, we
are only hooking this up for that directory right now. If other tests in
future require this treatment, then the support can be extended at that
point.
2019-02-13 09:43:49 +00:00
Philip Withnall
5d719c782c Merge branch 'script-enum' into 'master'
Define enum types for Unicode enums

See merge request GNOME/glib!481
2019-02-04 12:28:02 +00:00
Matthias Clasen
fc6044a4b1 Define enum types for Unicode enums
We want to stop shipping PangoScript in pango, so
we need a replacement for the type that used to
be provided by pango.
2019-01-31 19:38:26 -05:00
Colin Walters
4631cd892d gobject: Change assertions to read values via atomics
I'm trying to use `-fsanitize=thread` for OSTree, and some of
these issues seem to go into GLib.  Also, the sanitizers work better if
the userspace libraries are built with them too.

This fix is similar to
b6814bb37c

Mixing atomic and non-atomic reads trips TSAN, so let's change the
assertions to operate on the local values returned from atomic
read/writes.

Without this change I couldn't even *build* GLib with TSAN, since we
use gresources during compilation, which uses GSubprocess, which hits
this code.

(Minor review fixes made by Philip Withnall <withnall@endlessm.com>.)

https://gitlab.gnome.org/GNOME/glib/issues/1224
2019-01-31 13:18:40 +00:00
Philip Withnall
a8af2862ab gtypemodule: Cast *_init functions to void(*)(void) first
This is an analogous commit to c1f5e528. The original fix only touched
gtype.h and not gtypemodule.h.

The *_init() functions have prototypes incompatible with *InitFunc types they
are being cast to. This upsets GCC 8's -Wcast-function-type that's enabled by
default with -Wextra.

Let's not have the public header files emit a warning and neutralize it by
doing a void(*)(void) cast first.

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

https://gitlab.gnome.org/GNOME/glib/issues/1666
2019-01-25 11:29:05 +00:00
Philip Withnall
b3efef5b6f build: Drop autotools support
So long, and thanks for everything. We’re a Meson-only shop now.

glib-2-58 will remain the last stable GLib release series which is
buildable using autotools.

We continue to install autoconf macros for autotools-using projects
which depend on GLib; they are stable API.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-15 15:11:43 +00:00
Emmanuele Bassi
4f5f34689f Merge branch 'interface-docs' into 'master'
gtype: Clarify type of GInterfaceInitFunc

See merge request GNOME/glib!512
2019-01-07 14:40:44 +00:00
Philip Withnall
154b24c055 gtype: Document type for iface_default_init() function
And mention why it’s not a GInterfaceInitFunc as people who have read
the GObject docs cover-to-cover might expect.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-27 23:46:42 +00:00
Kouhei Sutou
b8ac6e146a Suppress -Wint-in-bool-context warning with G_DEFINE_INTERFACE and g++
Note that it's not reported with gcc. It's only reported with g++.

C++ code to reproduce this warning:

    #include <glib-object.h>

    G_BEGIN_DECLS

    #define GARROW_TYPE_FILE (garrow_file_get_type())
    G_DECLARE_INTERFACE(GArrowFile,
                        garrow_file,
                        GARROW,
                        FILE,
                        GObject)

    struct _GArrowFileInterface {
      GTypeInterface g_iface;
    };

    G_DEFINE_INTERFACE(GArrowFile,
                       garrow_file,
                       G_TYPE_OBJECT)

    static void
    garrow_file_default_init(GArrowFileInterface *iface)
    {
    }

    G_END_DECLS

Build command line:

    % g++ -Wall -shared -o liba.so a.cpp $(pkg-config --cflags --libs gobject-2.0)

Message:

    In file included from /tmp/local.glib/include/glib-2.0/gobject/gobject.h:24,
                     from /tmp/local.glib/include/glib-2.0/gobject/gbinding.h:29,
                     from /tmp/local.glib/include/glib-2.0/glib-object.h:23,
                     from a.cpp:1:
    a.cpp: In function 'GType garrow_file_get_type()':
    /tmp/local.glib/include/glib-2.0/gobject/gtype.h:219:50: warning: '<<' in boolean context, did you mean '<' ? [-Wint-in-bool-context]
     #define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
                                                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /tmp/local.glib/include/glib-2.0/gobject/gtype.h:2026:11: note: in definition of macro '_G_DEFINE_INTERFACE_EXTENDED_BEGIN'
           if (TYPE_PREREQ) \
               ^~~~~~~~~~~
    /tmp/local.glib/include/glib-2.0/gobject/gtype.h:1758:47: note: in expansion of macro 'G_DEFINE_INTERFACE_WITH_CODE'
     #define G_DEFINE_INTERFACE(TN, t_n, T_P)      G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, ;)
                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    a.cpp:16:1: note: in expansion of macro 'G_DEFINE_INTERFACE'
     G_DEFINE_INTERFACE(GArrowFile,
     ^~~~~~~~~~~~~~~~~~
    /tmp/local.glib/include/glib-2.0/gobject/gtype.h:178:25: note: in expansion of macro 'G_TYPE_MAKE_FUNDAMENTAL'
     #define G_TYPE_OBJECT   G_TYPE_MAKE_FUNDAMENTAL (20)
                             ^~~~~~~~~~~~~~~~~~~~~~~
    a.cpp:18:20: note: in expansion of macro 'G_TYPE_OBJECT'
                        G_TYPE_OBJECT)
                        ^~~~~~~~~~~~~
2018-12-20 11:24:53 +09:00
Benjamin Berg
f5e1e169d0 binding: Clarify the use of g_object_unref() to remove a binding
Conceptually the binding is kept alive as long as both the source and
target exist. This means that an API user needs to take some care to
either hold a reference or only use a pointer to the binding as long as
also holding references to both objects.

Clarify the documentation a bit.
2018-12-17 11:01:07 +01:00
Tomasz Miąsko
6b0ad94fb4 tests: s/assertEquals/assertEqual/
Assert assertEquals is deprecated alias of assertEqual.
2018-12-12 12:57:51 +01:00
Tomasz Miąsko
c69a98057f tests: Avoid writing ever increasing sequence of null bytes to test logs 2018-12-12 12:57:51 +01:00
Tomasz Miąsko
3b7f7a4ed9 tests: Drop compatibility with python 2 from TAP test runner 2018-12-12 12:57:51 +01:00
Xavier Claessens
bdc9328bdf Merge branch 'meson-dep' into 'master'
Meson: Fix declare_dependency() calls

See merge request GNOME/glib!518
2018-12-10 22:39:32 +00:00
Xavier Claessens
475f0a9b67 Meson: Fix deprecation warning with 0.49.0 release
http://mesonbuild.com/Release-notes-for-0-49-0.html#deprecation-warning-in-pkgconfig-generator
2018-12-10 09:08:28 -05:00
Xavier Claessens
afd3f3beda Meson: Fix declare_dependency() calls
Turns out the fix in commit 93555577c wasn't enough, when using glib as
subproject and the parent project uses only libgio_dep, and include
<gi18n.h>, it won't find libintl.h because it's in the
include_directories of libglib_dep. Fix that by declaring dependencies
explicitly, which is the right thing to do since glib and gobject are
public dependencies of gio. That reflects what we do for the pkg-config
file as well.
2018-12-10 09:06:17 -05:00
Philip Withnall
21adb30a83 gtype: Clarify type of GInterfaceInitFunc
When passing a function to G_IMPLEMENT_INTERFACE, it actually has to
take two arguments. Who knew?

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-12-05 14:09:35 +00:00
Nirbheek Chauhan
17316b2c16 glib-mkenums: Support reading @rspfiles for arguments
This is needed on Windows where the argument list can exceed the
maximum command-line length when lots of sources are passed to
glib-mkenums.
2018-12-04 16:16:00 +05:30
Philip Withnall
051c9ada8e Merge branch 'glib-as-subproject' into 'master'
Meson: Add missing include_directories when using glib as subproject

See merge request GNOME/glib!491
2018-11-26 14:29:24 +00:00
Christoph Reiter
f73b9e29e1 g_value_get_variant: return value is transfer-none not transfer-full
It defaulted to transfer-full.
2018-11-25 13:05:54 +01:00
Xavier Claessens
93555577c5 Meson: Add missing include_directories when using glib as subproject
When using glib as subproject we are forced to pass glib_dep,
gobject_dep and gio_dep to any build target. If we pass only gio_dep it
will missing include directory for glib and gobject.
2018-11-24 20:52:01 -05:00
Marco Trevisan (Treviño)
8d42b0246b gobject, tests: add tests for autoptr (and lists) with declared
Add tests using an object declared with G_DECLARE_FINAL_TYPE, that is derived
from another, declared using G_DECLARE_DERIVABLE_TYPE, and that
thus uses _GLIB_DEFINE_AUTOPTR_CHAINUP to define cleanup functions.

And verify that both g_autoptr(Type) and g_auto(s)list(Type) work
2018-11-14 22:47:39 -06:00
Simon McVittie
13e206aaeb meson: Centralize test timeout values
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-01 19:13:21 +00:00