Commit Graph

1367 Commits

Author SHA1 Message Date
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