Commit Graph

1453 Commits

Author SHA1 Message Date
Garrett Regier
6c95cd22e9 gobject: Add to_string() functions for Enum and Flags types
These are useful for debugging.

https://bugzilla.gnome.org/show_bug.cgi?id=447907
2017-03-30 09:52:28 +01:00
Simon McVittie
8686e43058 glib-mkenums: Sort input files for more deterministic output
This should be helpful for reproducible builds
<https://reproducible-builds.org/>.

Perl's sorting is not locale-sensitive unless the lexical scope has
'use locale', which this one does not, so we do not need to force
locale-agnostic sorting.

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=769983
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809152
2017-03-04 22:05:44 +00:00
Simon McVittie
e3f59e482b Install gdb Python helpers as data, not as executable scripts
They do not start with the #!/usr/bin/python that would be necessary
to make them run with Python rather than a shell, and they would
not be useful to run anyway: they are libraries to be imported,
not scripts to be run.

Signed-off-by: Simon McVittie <smcv@debian.org>
2017-03-03 20:08:42 +00:00
Chun-wei Fan
6dfc6fee7b Visual Studio builds: Move project files to win32/
It was suggested that the project files be moved here as we don't actually
need to go two directory layers from $(srcroot), and would help us to
standardize on things in the future across the board.
2017-01-09 14:00:46 +08:00
Philip Withnall
953c182d25 gobject: Document behaviour of GType checking macros on NULL
The macros differ in their handling of NULL values — some macros ignore
them and pass through (e.g. G_TYPE_CHECK_INSTANCE_CAST) while others
will explicitly emit a warning if passed NULL (e.g.
G_TYPE_CHECK_INSTANCE).

Document their behaviour, so people don’t end up putting unnecessary
NULL checks in their code when doing checked type casts.

https://bugzilla.gnome.org/show_bug.cgi?id=735731
2017-01-07 23:43:06 +00:00
Simon McVittie
e5ed410c8c Avoid calling Standard C string/array functions with NULL arguments
glibc string.h declares memcpy() with attribute(nonnull(1,2)), causing
calls with NULL arguments to be treated as undefined behaviour.
This is consistent with ISO C99 and C11, which state that passing 0
to string functions as an array length does not remove the requirement
that the pointer to the array is a valid pointer.
gcc -fsanitize=undefined catches this while running OSTree's test suite.

Similarly, running the GLib test suite reports similar issues for
qsort(), memmove(), memcmp().

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=775510
Reviewed-by: Colin Walters
2016-12-02 19:10:39 +00:00
Simon McVittie
5e7eaaaaee GParam: make G_PARAM_USER_MASK unsigned
UBSan considers left-shifting a negative number to be undefined
behaviour (per
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_081.html> it is
implementation-defined in C89, but according to
<https://llvm.org/bugs/show_bug.cgi?id=17490> it is undefined in C99).

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=775510
Reviewed-by: Colin Walters
2016-12-02 19:10:26 +00:00
Philip Withnall
3e7b5cbef8 glib: Namespace global tapset variables by soname
global variables in SystemTap are shared between all SystemTap scripts;
so if scripts are loaded for two versions of GLib (for example, a stable
and a development version), those global variables will conflict.

Avoid that by including the soname’s version in the global variable
names.

https://bugzilla.gnome.org/show_bug.cgi?id=770646
2016-11-23 10:50:39 +00: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
Philip Withnall
9f4d5e8b91 gsignal: Mention handler ID type in signal connection macro docs
gtk-doc doesn’t make the return type clear, because these are macros
rather than inline functions, so people often have to guess at the
return type (or look it up from g_signal_connect_closure(), but that’s
hard work).

Make it clear that the return type for handler IDs is gulong. While
there, fix the capitalisation of ‘id’ to ‘ID’ in a few places.
2016-11-10 16:12:41 +00:00
Tim-Philipp Müller
932eb87083 glib-mkenums: fix variable declaration
Inconsequential, just sync up declaration with actual
name of variable to avoid confusion.

https://bugzilla.gnome.org/show_bug.cgi?id=770175
2016-11-08 15:21:03 +00:00
Hannes Müller
7470cc902b Avoid warning for G_PARAM_DEPRECATED with GCC 6 [-Wpedantic]
Refer to https://bugzilla.gnome.org/show_bug.cgi?id=767882
Related to GCC https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71803
2016-10-24 06:10:14 -04:00
Tim-Philipp Müller
ac54db2ee2 glib-mkenums: add --output option to write output to a file
https://bugzilla.gnome.org/show_bug.cgi?id=770175
2016-10-12 17:05:07 -04:00
Tim-Philipp Müller
0fbc98097f glib-genmarshal: add --output option to write output to a file
https://bugzilla.gnome.org/show_bug.cgi?id=770175
2016-10-12 15:56:49 -04:00
Matthias Clasen
53d5a9f6fb Fix the signals test
The test setup here is not really independent, so the addition
of the custom-marshaller test was breaking some of the other
tests. Fix things up.
2016-08-27 22:54:39 -04:00
Benjamin Otte
edfbfc1827 tests: Add test showing default marshaller override
https://bugzilla.gnome.org/show_bug.cgi?id=769076
2016-08-25 13:26:58 -04:00
Matthias Clasen
ef16cbee5b Don't set a va marshaller if a marshaller was set
Otherwise we get warnings when the caller later tries to set a
va marshaller with g_signal_set_va_marshaller.

https://bugzilla.gnome.org/show_bug.cgi?id=769076
2016-08-25 13:26:58 -04:00
Philip Withnall
a5044a8e78 build: Fix SystemTap build to disable semaphores as before
At some point, upstream SystemTap changed from using a
STAP_HAS_SEMAPHORES preprocessor variable for this, to using
_SDT_HAS_SEMAPHORES instead. We need to update our build system to
disable that as well.

The original discussion about use of semaphores is here:

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

This was breaking the build with -flto enabled, either because -flto
doesn’t work with semaphores.

https://bugzilla.gnome.org/show_bug.cgi?id=768198
2016-08-13 09:32:12 +02:00
Emmanuele Bassi
5ff8579527 Fix debug builds under MSVC
The C spec leaves conditional evaluation inside a macro expansion as
undefined behaviour. This means we cannot use constructs like:

  GOBJECT_IF_DEBUG(OBJECTS, {
    ...
  #ifdef BLAH
    ...
  #endif
    ...});

Because compilers are entirely justified to ignore the conditional, or,
like in the case of MSVC, error out.

https://bugzilla.gnome.org/show_bug.cgi?id=769504
2016-08-04 10:18:46 +01:00
Alberts Muktupāvels
ad669500a6 gobject: add g_autoptr support for GTypeModule
https://bugzilla.gnome.org/show_bug.cgi?id=769033
2016-07-21 17:03:06 +03:00
Kang Hu
42dad59cc1 gobject: add GOBJECT_IF_DEBUG macro for debugging gobjects and gsignals.
historically, DEBUG_CODE(gtype.c) and IF_DEBUG(gobject.c, gsignal.c)
macros are used to support debugging messages about object bookkeeping
and signal emission.
DEBUG_CODE has never been used in gtype.c. IF_DEBUG, when used, must be
accompanied by an extra #ifdef G_ENABLE_DEBUG. this is cumbersome.

this patch add a new macro GOBJECT_IF_DEBUG based on DEBUG_CODE as
a replacement for both DEBUG_CODE and IF_DEBUG.

https://bugzilla.gnome.org/show_bug.cgi?id=729914
2016-07-16 20:54:44 -04:00
Philip Withnall
c4695f192c build: Rename SystemTap scripts to include the LT version
In a vague attempt at ensuring the .stp scripts can be closely
associated with the .so files which they hard-code references to, rename
the scripts so they include the LT version — so that they are the .so
file name plus .stp.

This does not fix the fact that our .stp scripts will not work on
multiarch systems, as they are installed in an architecture-independent
directory (/usr/share/systemtap/tapset). At the moment, it is
recommended that any distribution who package the .stp files should
install them in the architecture-specific subdirectories of this (for
example, /usr/share/systemtap/tapset/x86-64).

A better long-term solution for this is under discussion upstream:
https://sourceware.org/bugzilla/show_bug.cgi?id=20264

https://bugzilla.gnome.org/show_bug.cgi?id=662802
2016-06-29 14:43:52 +01:00
Ryan Lortie
7563ab4734 build: simplify dtrace configuration
The ability to pass libtool via $(CC) to dtrace and have it respect this
appears to be a feature that is only present in the systemtap version of
the tool.  In particular, FreeBSD (which seems to be using a copy of the
tool from Solaris) doesn't support this.

The result is that, with $(CC) ignored, and a .lo file specified in -o,
we get an ELF written to the .lo.

Instead of trying to have dtrace run libtool we can have libtool run
dtrace.  dtrace is really just a compiler that produces an object file
here, and it even understands -o, so libtool can make the appropriate
adjustments.

There appears to be some prior art for this approach.  A quick search
shows that at least QEMU is using this approach.  It also appears to
work on Linux with systemtap's dtrace and on FreeBSD.

This may regress cross-compilation because the dtrace command will have
no way of knowing which compiler we intend for it to use to produce the
object file.  I say "may" because I don't know if dtrace ever worked in
the first place under cross-compilation.

https://bugzilla.gnome.org/show_bug.cgi?id=725902
2016-06-20 12:35:47 -04:00
Gerald Combs
05d429af9d gsignal: Remove a UTF-8 ellipsis from docs
Some compilers have trouble with such sequences. Visual C++ may or may
not generate a warning in this particular case depending on if the
local code page supports an ellipsis.

https://bugzilla.gnome.org/show_bug.cgi?id=767218
2016-06-03 16:09:43 -04:00
Tom Tromey
b7145a1d72 Rename gdb macros with _gdb suffix to avoid ns clashes
glib installs a gdb helper file named `glib.py`.
Then the "hook" file updates `sys.path` and does `import glib`.

This will fail if glib has already been imported into gdb, say
using `from gi.repository import GLib`.  This is due to a namespace clash.

One fix would be to rename the gdb helper files to not clash with
other Python modules.  This should be done for all such helper files.

https://bugzilla.gnome.org/show_bug.cgi?id=760186
2016-05-23 10:52:10 -04:00
Kjell Ahlstedt
05e5da9a83 gvalue: Fix description of g_value_type_transformable()
Types are transformable if they are compatible *or* a transformation function
is registered.

https://bugzilla.gnome.org/show_bug.cgi?id=742898
2016-04-28 12:05:50 +02:00
Sebastian Dröge
4e3cd88c2b gparamspecs: GTypes are stored in v_pointer, not v_long
v_long is 32 bits on Win64, v_pointer is 64 bits. On most other platforms the
size of long and pointer is the same, so it's usually not a problem.

https://bugzilla.gnome.org/show_bug.cgi?id=758738
2016-04-27 10:28:09 +03:00
Phillip Wood
38c4e31c8a Fix documentation typos
Character entities are not supposed to be supported by gtk-doc¹ and
fix the spelling of ‘optional’

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

https://bugzilla.gnome.org/show_bug.cgi?id=758174
2016-04-11 23:31:38 -04:00
Colin Walters
14885a5b19 build: Also dist Systemtap files always for gobject/
Mirrors
https://git.gnome.org/browse/glib/commit/?id=ad2092bc680e434c3d17600988ec9b20f52eebef
except I didn't also change gobject/.

https://bugzilla.gnome.org/show_bug.cgi?id=763821
2016-03-23 09:02:35 -04:00
Rico Tzschichholz
e3189527dc gio/gobject: Various introspection fixes 2016-02-03 18:13:49 +01:00
Philip Withnall
8c263008bb build: Calculate ABS_GLIB_RUNTIME_LIBDIR at build time
Rather than calculating it at configure time. This means it can expand
$libdir properly, and use the Make $(realpath) function rather than
invoking the non-portable `readlink -f`.

This fixes problems where `readlink` would be called on an invalid path
(due to a variable not being expanded) and would evaluate to "", which
would then cause things to be installed in the wrong place.

https://bugzilla.gnome.org/show_bug.cgi?id=744772
2016-01-24 14:44:44 +00:00
Emmanuele Bassi
85a23529ab Revert "make *_get_instance_private const-compliant"
This reverts commit a3a9664ed2.

Constifying the autogenerated get_instance_private functio makes C++
compilers and GCC with -Wcast-qual warn during compilation of GLib and
projects depending on GLib.

Since using const with GObject instances is not a common coding
practice, it's better to revert than trying to make every sigle GType
function const-safe (and possibly add more compiler warnings in the
process).

https://bugzilla.gnome.org/show_bug.cgi?id=745068
2016-01-18 18:48:42 +00:00
Emmanuele Bassi
617189f28c Revert "G_DECLARE_*: be const-compliant"
This reverts commit 52f23db74a.

Constifying these macros make C++ compilers and GCC with -Wcast-qual
warn during compilation of GLib and projects depending on GLib.

Since using const with GObject instances is not a common coding
practice, it's better to revert than trying to make every sigle GType
function const-safe (and possibly add more compiler warnings in the
process).

https://bugzilla.gnome.org/show_bug.cgi?id=745068
2016-01-18 18:46:12 +00:00
Simon Feltman
1513efc904 Add GParamSpec object ref management annotations
Add ref-func, unref-func, set-value-func, and get-value-func annotations to
GParamSpec so that it can be managed generically as a fundamental type with
introspection.

https://bugzilla.gnome.org/show_bug.cgi?id=710243
2015-12-16 07:47:54 -05:00
Philip Withnall
25a7c817d3 glib: Add missing (nullable) and (optional) annotations
Add various (nullable) and (optional) annotations which were missing
from a variety of functions. Also port a couple of existing (allow-none)
annotations in the same files to use (nullable) and (optional) as
appropriate instead.

Secondly, add various (not nullable) annotations as needed by the new
default in gobject-introspection of marking gpointers as (nullable). See
https://bugzilla.gnome.org/show_bug.cgi?id=729660.

This includes adding some stub documentation comments for the
assertion macro error functions, which weren’t previously documented.
The new comments are purely to allow for annotations, and hence are
marked as (skip) to prevent the symbols appearing in the GIR file.

https://bugzilla.gnome.org/show_bug.cgi?id=719966
2015-11-07 10:48:32 +01:00
Xavier Claessens
2331437df3 Doc: fix some gtk-doc warnings
https://bugzilla.gnome.org/show_bug.cgi?id=755364
2015-10-30 10:30:55 -04:00
Murray Cumming
adfd184776 Fix tiny typo. 2015-10-28 10:50:40 +01:00
Dan Winship
263aac125e .gitignore updates 2015-10-23 11:28:03 -04:00
Matthias Clasen
2ac7c5a6fb Use -Wl,-znodelete for all our libraries
Now that we initialize the quark tables from a constructor,
reloading libglib is just as bad as reloading libgobject,
so add the linker option to the LDFLAGS for all our libraries.

https://bugzilla.gnome.org/show_bug.cgi?id=755609
2015-10-20 08:18:22 -04:00
Ignacio Casal Quinteiro
7a29771a74 gobject: use a DllMain to initialize gobject on windows
It seems that VS 2015 optimizes out the constructor on windows,
so it is better to use a DllMain to initialize the library
and keep using a normal constructor on the other platforms.
This research was done by  Arnav Singh.

https://bugzilla.gnome.org/show_bug.cgi?id=752837
2015-10-11 10:29:10 +02:00
Philip Withnall
144d38fb9d gparamspecs: Mark g_param_spec_string()’s default value as (nullable) 2015-10-08 12:57:33 +01:00
Matthias Clasen
8d83aace10 Call glib_init from the gobject constructor
We are using quarks in the gobject constructor, among other things,
so we need to ensure that glib is being initialized first.

https://bugzilla.gnome.org/show_bug.cgi?id=756139
2015-10-07 23:39:29 -04:00
Philip Withnall
4f6dc30232 glib-genmarshal: Fix memory leak with --prefix
If --prefix is specified, marshaller_prefix is allocated and never
freed. It does not actually have to be allocated — just use the static
string from argv.

Coverity CID: 1325370
2015-10-03 11:33:00 +01:00
Dan Winship
4b2d92a864 Allow passing unset GValues to g_value_unset()
This makes it more useful as an autocleanup func.

Also, add a minimal test of g_value_init/g_value_reset/g_value_unset.

https://bugzilla.gnome.org/show_bug.cgi?id=755766
2015-10-02 10:07:53 -04:00
Dan Winship
b4a3c1bb11 Revert "gvalue: Add g_value_clear method"
This reverts commit 1233962b54.
2015-10-02 10:07:53 -04:00
Dan Winship
4c870904cd Revert "gvalue: Use g_value_clear as clear function"
This reverts commit 3bb2e8dfc9.
2015-10-02 10:07:53 -04:00
Dan Winship
8ed9e8c79f Revert "gvalue: Improve _unset() documentation"
This reverts commit 3c0d38d68b.
2015-10-02 10:07:53 -04:00
Emmanuele Bassi
037991211d Revert "Apply the previous change to gmarshal.c"
This reverts commit 43e8bfca0c.

https://bugzilla.gnome.org/show_bug.cgi?id=755922
2015-10-01 11:58:37 +01:00
Emmanuele Bassi
cc818f5fe4 Revert "glib-genmarshal: Treat all parameters the same"
This reverts commit 8e362161d9.

There is a fundamental difference between g_value_peek_pointer() and
g_value_get_pointer(), and it's not just complexity: the latter checks
if the GValue holds a pointer type, whereas the former doesn't.

https://bugzilla.gnome.org/show_bug.cgi?id=755922
2015-10-01 11:54:11 +01:00
Nicolas Dufresne
3c0d38d68b gvalue: Improve _unset() documentation
g_value_unset() only works with initialized value and will assert
if the GValue is zero-filled (or initialized with G_VALUE_INIT). Document
this behaviour and refer to g_value_clear() for a method that work on
both initialized and zero-filled GValue.

https://bugzilla.gnome.org/show_bug.cgi?id=755766
2015-09-29 08:30:21 -04:00
Nicolas Dufresne
3bb2e8dfc9 gvalue: Use g_value_clear as clear function
This change allow leaving a scope before g_value_init() has been
called. This would happen if you do:

  {
    g_auto(GValue) value = G_VALUE_INIT;
  }

Or have a return statement (due to failure) before the part of
your code where you set this GValue.

https://bugzilla.gnome.org/show_bug.cgi?id=755766
2015-09-29 08:26:14 -04:00
Nicolas Dufresne
1233962b54 gvalue: Add g_value_clear method
This method is similar to g_value_unset() but will accept
an uninitialized (zero-filled) GValue structure.

https://bugzilla.gnome.org/show_bug.cgi?id=755766
2015-09-29 08:26:14 -04:00
Matthias Clasen
43e8bfca0c Apply the previous change to gmarshal.c
Since gmarshal.c is no longer generated, we have to manually
apply this change to the builtin marshallers.
2015-09-29 07:04:36 -04:00
Matthias Clasen
8e362161d9 glib-genmarshal: Treat all parameters the same
There's no need to use a more expensive getter when swapping,
so just use the g_marshal_ getters there too.
2015-09-29 07:04:35 -04:00
Xavier Claessens
b81f3ced71 Move GStrv typedef to glib.h instead of gobject.h
GStrv was historically only needed for the boxed G_TYPE_STRV,
but it is now useful for g_auto(GStrv) as well. This is not
an ABI change.

https://bugzilla.gnome.org/show_bug.cgi?id=755355
2015-09-22 11:18:30 -04:00
Xavier Claessens
32811598f3 doc: clarify that _get_instance_private() is NULL-safe
https://bugzilla.gnome.org/show_bug.cgi?id=755083
2015-09-22 11:15:19 -04:00
Benjamin Otte
58eae7782a tests: Do last commit's fix for enums, too
We don't want to treat enums as ints but as ints.
2015-09-16 18:45:48 +02:00
Benjamin Otte
605ff1efe7 tests: Make testcase not pass 0 as a flags value
This will not catch the case where we fail in libffi and always use 0.
In fact, be a real annoying person and use (1 << 31) as a flags value to
test signedness, too.

Also update the testcase to actually use flags everywhere and ot uint.

https://bugzilla.gnome.org/show_bug.cgi?id=754882
2015-09-16 18:45:48 +02:00
Ray Strode
7b685eab88 ffi: Marshal flags like enums
Flags are enums.
Fixes broken marshalling on BE 64bit architectures.

https://bugzilla.gnome.org/show_bug.cgi?id=754882
2015-09-16 18:45:48 +02:00
Matthias Clasen
3bd1618ea9 Disable deprecation warnings for the stable release again
Keeping these enabled causes too many people to file
bugs against gobject, and not enough people to send
patches to port away from deprecated properties.
2015-09-14 18:42:12 -04:00
Alexander Larsson
69002f726d signal: return TRUE from g_signal_has_handler_pending for custom class closure
This is almost always what you want, because if you're using this you
want to know if any "custom code" (i.e. not the default class closure)
is going to be run if you emit this signal.

I looked at all the existing uses of this and they were all broken in the
presence of g_signal_override_class_closure().

https://bugzilla.gnome.org/show_bug.cgi?id=754986
2015-09-14 13:19:51 +02:00
Nicola Fontana
a51a877d27 GParamSpec: do not use static GParamSpecTypeInfo
g_param_type_register_static() has read-only access the pspec_info
argument: no need to keep the original struct around.

https://bugzilla.gnome.org/show_bug.cgi?id=696426
2015-09-13 02:15:04 -04:00
Michael Catanzaro
ee6740aa78 Fix a typo 2015-09-10 20:46:37 -05:00
Rico Tzschichholz
5a84f84325 gparam: Fix Since tag of g_param_spec_get_name_quark 2015-09-08 14:15:44 +02:00
Matthias Clasen
00933dfc9c Speed up property change notification a bit
Avoid the quark lock and hash table lookup for every
emission of ::notify.
2015-09-07 20:56:10 -04:00
Matthias Clasen
41c0d15a6d Add a method to get the pspec name quark
This lets us avoid the quark lookup in the hot
property change notification path.
2015-09-07 20:54:01 -04:00
Matthias Clasen
a62ad79f5c Clean up locking in g_object_notify_queue_add
Instaed of returning with the lock held, simply assert
that this cannot happen:

https://bugzilla.gnome.org/show_bug.cgi?id=749678#c4
2015-09-07 19:57:53 -04:00
Matthias Clasen
087d75e3c3 Make g_set_object more symmetric
As argued in bug 748633, and order of ref, assign, unref is
preferable.
2015-09-07 19:43:19 -04:00
Matthias Clasen
44af2b1c17 Simplify g_param_spec_get_redirect_target a bit more
It is enough to look for exact matches here, so no need to
dive into g_type_instance_is_a and take locks, etc.
2015-09-07 03:02:11 -04:00
Matthias Clasen
f1f80111c9 Simplify g_param_spec_get_redirect_target
There is no need to do a type check in a g_return_if_fail if the
type check is tne next thing the function does anyway.
2015-09-07 02:33:50 -04:00
Chun-wei Fan
041e77249a Cleanup and Enhance the MSVC Project Generation
Make use of the common autotools module that is used to generate the MSVC
project files from their respective templates so that the main build files
beccome cleaner, and enhance them in a way that the headers that should be
installed can be written to the property sheets during 'make dist', so that
the chances of missing headers for MSVC builds can be greatly reduced.

Also use this autotools module to fill in the projects for
glib-compile-schemas and glib-compile-resources.

https://bugzilla.gnome.org/show_bug.cgi?id=735429
2015-09-03 19:10:06 +08:00
Emmanuele Bassi
5ce70917df Drop binary checks when cross-compiling
We don't need to run binaries we just built in order to successfully
build GLib and friends any more.

Since commit b74e2a7, we don't need to run glib-genmarshal when building
GIO; since commit f9eb9eed, all our tests (including the ones that do
need to run binaries we just built) are only built when running "make
check", instead of unconditionally at every build.

This means that we don't need to check for existing, native binaries
when cross-compiling, and fail the configuration step if they are not
found — which also means that you don't need to natively build GLib for
your toolchain, in order to cross-compile GLib.

We can also use the cross-compilation conditional, and skip those tests
that require a binary we just built in order to build.

https://bugzilla.gnome.org/show_bug.cgi?id=753745
2015-09-01 10:40:24 -04:00
Iain Lane
16721468e5 gsignal: Don't crash when operating on signals on the wrong object 2015-09-01 14:30:43 +01:00
Iain Lane
261250c46e Test that disconnecting from the wrong thing warns and doesn't crash
This broke in 916297be79 (≥ 2.45.3)
2015-09-01 14:30:37 +01:00
Philip Withnall
ef1ba452b3 gsignal: Document memory management best practices for signal handlers
It’s quite common to see naked g_signal_connect() calls without a paired
g_signal_handler_disconnect(). This is commonly a bug which could lead
to uses of the callback user data after it’s been freed.

Document the best practices for avoiding this kind of bug by properly
disconnecting all signal handlers.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-08-19 12:56:38 +01:00
Philip Withnall
c5cd1c5f02 gobject: Add cross-links from GObject reference docs to tutorials
Add some brief links from the GObject reference documentation to the
existing tutorial and overview sections on GObjects.

https://bugzilla.gnome.org/show_bug.cgi?id=743018
2015-08-19 12:54:50 +01:00
Philip Withnall
9874fe3c40 gobject: Cross-link from GType reference docs to GType conventions page
Make it a little easier to find the GType conventions page, which I
guess should be the canonical guide to how to name things.

This adds a brief mention of the valid characters in a type name to the
conventions page.

https://bugzilla.gnome.org/show_bug.cgi?id=743018
2015-08-19 12:54:50 +01:00
Christian Hergert
cb86c222cc gtypemodule: use G_GNUC_UNUSED in G_DEFINE_DYNAMIC_TYPE_EXTENDED
We already do this in the normal case, might as well support it for the
dynamic type module case as well. This prevents seeing a warning when not
using the get_instance_private() in the dynamic type.
2015-06-27 22:41:13 -07:00
Michael Catanzaro
9f90ee5eec genmarshal: silence register storage class warnings
Using the register keyword triggers warnings on noteworthy compilers
(clang), since it's deprecated in C++ and at danger of being removed
from the language. There is no reason to use it since it isn't 1980
anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=750918
2015-06-13 23:09:24 -05:00
Stefan Ekenberg
338741fff5 Prevent race condition in g_io_condition_get_type
Prevents race condition in function g_io_condition_get_type by ensuring
that the initialization section for 'etype' is executed only once
during a program's life time, and that concurrent threads are blocked
until initialization completes. This changes solves the problem that
concurrent threads could execute the check 'etype == 0' before any of
them had initialized it, which in turn meant that multiple threads
would then attempt to register the "GIOCondition" type.

https://bugzilla.gnome.org/show_bug.cgi?id=750386
2015-06-04 22:30:50 -04:00
Garrett Regier
bdc3f149ec binding: Simplify the default transform func
https://bugzilla.gnome.org/show_bug.cgi?id=750369
2015-06-03 17:46:57 -07:00
Garrett Regier
ace7f6861e binding: Remove conditional from the default transform function
Avoiding checking for INVERT_BOOLEAN each and
instead choose the correct function in constructed().

https://bugzilla.gnome.org/show_bug.cgi?id=750369
2015-06-03 17:46:57 -07:00
Garrett Regier
36593a3aba binding: Remove GObject data usage
It isn't actually doing anything, instead it is
being managed without actually being used.
This has the result that GBinding is now more
thread-safe.

https://bugzilla.gnome.org/show_bug.cgi?id=745013
2015-06-03 17:46:57 -07:00
Matthias Clasen
916297be79 Add a global signal handler table
Add a global lookup table for signal handlers. We already give
them a unique ID, so there is no good reason to pay for
non-constant lookups when disconnecting handlers.

https://bugzilla.gnome.org/show_bug.cgi?id=737009
2015-05-27 14:41:19 -04:00
Matthias Clasen
8a97dc5652 Add a performance test for signal connection
This test checks the performance of connecting, disconnecting and
blocking many handlers. Various cases are checked: disconnect in
the same order, in the inverse order, at random. Connect to one
signal on a single object, to two signals on the same object, or
to the same signal on two different objects.

https://bugzilla.gnome.org/show_bug.cgi?id=737009
2015-05-27 14:41:19 -04:00
Emmanuele Bassi
5e7e058a9c docs: Add an example of G_DEFINE_BOXED_TYPE
Mention that the GType of the boxed type is stored inside the
g_define_type_id variable.

See bug: https://bugzilla.gnome.org/show_bug.cgi?id=723394
2015-05-25 14:02:43 +01:00
Garrett Regier
f1c2e70345 Connect to the detailed notify signal in GBinding
This avoids the notify handler being called for each
and every emitted notify.

https://bugzilla.gnome.org/show_bug.cgi?id=749353
2015-05-14 03:58:53 -07:00
Garrett Regier
b07ba8ed3b Fix g_binding_unbind() when the source and target are the same
It tried to remove a weak ref, but it is only taken if the
source and target object are different.

https://bugzilla.gnome.org/show_bug.cgi?id=749352
2015-05-14 03:58:53 -07:00
Garrett Regier
29d380cc5b gtype: Bump allowed number of children
Restricting the number of children to be less than 4095 can
be an issue when generating types. This is also an issue for
the Lua bindings as each Lua state will create a new GType each
time the Lua code is executed.

https://bugzilla.gnome.org/show_bug.cgi?id=747882
2015-05-12 05:30:46 -07:00
Simon McVittie
45dae4b506 tests: replace most g_print() with g_printerr()
I searched all files that mention g_test_run, and replaced most
g_print() calls. This avoids interfering with TAP. Exceptions:

* gio/tests/network-monitor: a manual mode that is run by
  "./network-monitor --watch" is unaffected
* glib/gtester.c: not a test
* glib/gtestutils.c: not a test
* glib/tests/logging.c: specifically exercising g_print()
* glib/tests/markup-parse.c: a manual mode that is run by
  "./markup-parse --cdata-as-text" is unaffected
* glib/tests/testing.c: specifically exercising capture of stdout
  in subprocesses
* glib/tests/utils.c: captures a subprocess's stdout
* glib/tests/testglib.c: exercises an assertion failure in g_print()

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=725981
Reviewed-by: Colin Walters <walters@verbum.org>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-11 20:24:56 +01:00
Philip Withnall
073a81d1da gsignal: Mark the return value of g_signal_emitv() as (inout) (optional)
https://bugzilla.gnome.org/show_bug.cgi?id=719966
2015-04-27 12:35:54 +01:00
Ryan Lortie
69fd1fd1d0 GClosure: add valgrind hints
GClosure has been in the "allocate area before the pointer" game since
before we did this with GTypeInstance.  At the time that this was done
for GClosure, we didn't have valgrind.h in GLib.

Now that we do, we should add similar valgrind hints as the ones we did
for GTypeInstance.  This substantially reduces reports of "possibly
lost" on pretty much any program that makes use of signals.

https://bugzilla.gnome.org/show_bug.cgi?id=739850
2015-03-23 10:54:25 -04:00
Ryan Lortie
d9de830b65 Convert remaining uses of 'Rename to:'
This was replaced by (rename-to) in 2013 (see bug 676133).

They're also causing gtk-doc trouble, so let's get rid of them.
2015-03-12 16:55:22 -04:00
Philip Withnall
6d030ea0ae gobject: Mark a helper variable as const
It’s only used for argv values, which are not modified here.

https://bugzilla.gnome.org/show_bug.cgi?id=614684
2015-03-04 08:55:30 +00:00
Philip Withnall
4aedc85fb3 gobject: Mention g_clear_object() in g_object_unref() documentation
https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-03-03 18:40:33 +00:00
Philip Withnall
c639b628ec gparamspecs: Recommend use of most specific GParamSpec types
It’s quite common to see a g_param_spec_pointer() used for GObject or
boxed types which, while not incorrect, does make memory management
unsafe, since no copying or reference counting can be performed
automatically.

Similarly, people often use g_param_spec_boolean() when an enum would be
more appropriate, cf.
    http://blog.ometer.com/2011/01/20/boolean-parameters-are-wrong/
Using enums also means that the set of allowable values can be extended
in future if needed.

In the hope that people who write code like that read the documentation,
mention the more specific types in the documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-03-03 18:40:33 +00:00
Marc-Antoine Perennou
a3a9664ed2 make *_get_instance_private const-compliant
This is pure read-only access to an external struct
so void warnings for people calling it from const
contexts such as accessors

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

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2015-02-27 08:51:08 +01:00
Marc-Antoine Perennou
52f23db74a G_DECLARE_*: be const-compliant
switching to the old macros boilerplate to G_DECLARE_*
a lot of warnings start to pop when *_IS_A_* or such are
called from a const context.
Fix this by taking const pointers as parameters

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

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2015-02-27 08:51:08 +01:00
David King
d36f6a9633 gobject.h: Use correct format specifier for __LINE__
GCC 5.0, with its new -Wformat-signedness, warns about the sign being
different between a type and the format string in printf-format
messages, leading to compiler warnings with G_OBJECT_WARN_INVALID_PSPEC.
In other uses of __LINE__ inside GLib, %d is used, and GCC seems to
expect a format specifier of %d as well:
https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html

https://bugzilla.gnome.org/show_bug.cgi?id=744263
2015-02-26 12:32:43 +01:00
Emmanuele Bassi
5e994b1e9b gobject: Add missing autocleanup for GInitiallyUnowned
We are missing the auto cleanup function for this type, which means
G_DECLARE_* macros won't work with classes inheriting from
GInitiallyUnowned.
2015-02-20 19:54:07 +00:00