Commit Graph

157 Commits

Author SHA1 Message Date
Matthias Clasen
e50d8a11b2 Cosmetic doc change 2011-12-09 08:01:12 -05:00
Nicola Fontana
f24d8247b3 Do not use static GTypeInfo and GInterfaceInfo
Either g_type_register_static_simple (used by G_DEFINE_TYPE_EXTENDED)
and G_IMPLEMENT_INTERFACE use automatic variables for GTypeInfo and
GInterfaceInfo structs, while tutorials and source code often use
static variables. This commit consistently adopts the former method.

https://bugzilla.gnome.org/show_bug.cgi?id=600161
2011-11-29 22:03:25 -05:00
Matthias Clasen
2da24259ab Fix !debug builds
As pointed out by Chun-wei Fan in bug 664455, parts of the merged
gobjectnotifyqueue.c code ended up inside an #ifdef G_ENABLE_DEBUG
section.
2011-11-22 19:25:03 -05:00
Ryan Lortie
877c0ad5b8 [notify] remove some rather bogus 'inline' use 2011-11-16 17:50:13 +00:00
Ryan Lortie
ac0ddcf23f [notify] dispatch 'notify' directly if not frozen
Avoid the notify queue in the case that we're not already frozen.
2011-11-16 17:50:13 +00:00
Ryan Lortie
39458748dd [notify] add 'conditional' to _notify_queue_freeze
When the 'conditional' parameter is TRUE, the queue will only be frozen
(ie: have its freeze count increase by one) if it is already frozen.

This will allow us to avoid a freeze-notify-thaw in the case that we
just want to notify on a single property.

Another approach may have been to add an is_frozen() type call and avoid
even increasing the freeze count at all in this case.  Unfortunately,
I'm not totally sure what is the exact expected semantics of
simultaneous notifications in multiple threads and this may interact
badly with someone freezing or thawing in between our check and
emission.
2011-11-16 17:50:13 +00:00
Ryan Lortie
393d4c28b4 [notify] Remove GObjectNotifyContext indirection
This silly abstraction is causing more trouble than it's worth -- just
use the relevant bits directly.
2011-11-16 17:50:13 +00:00
Ryan Lortie
8215fc5f25 [notify] lift some logic out of _notify_queue_add
Lift the check-if-READABLE and redirect-target logic from out of
g_object_notify_queue_add() into its own function, get_notify_pspec().

Use that function at the site of our two calls to
g_object_notify_queue_add().
2011-11-16 17:50:12 +00:00
Ryan Lortie
760037ec46 [notify] remove an obviously false comment 2011-11-16 17:50:12 +00:00
Ryan Lortie
45d80cf9bd [notify] lift some code outside of critical region 2011-11-16 17:50:12 +00:00
Ryan Lortie
1d98f93194 [notify] drop some unused code 2011-11-16 17:50:12 +00:00
Ryan Lortie
128862eafe [notify] merge gobjectnotifyqueue.c into gobject.c
This was done as a separate file before, and #include brought it into
gobject.c.  That's a bit mad, so stop doing that.

Unfortunately, the insanity steps up a level: gobjectnotifyqueue.c is
installed in the public include dir, so we can't just get rid of it
entirely.
2011-11-16 17:50:12 +00:00
Ryan Lortie
688059cb94 [notify] remove some useless forward declarations
These cause trouble in the next commit.
2011-11-16 17:50:12 +00:00
Marc-André Lureau
fb95c20c96 Add G_SIGNAL_DEPRECATED
Similar to G_PARAM_DEPRECATED. It will warn only for users of the
signals, so a signal can still be emited without warning, for
compatibility reasons.

Apparently, there is no way user flags could have been used before,
so that shouldn't break anyone.

https://bugzilla.gnome.org/show_bug.cgi?id=663581
2011-11-07 23:12:45 +01:00
Javier Jardón
108480b7ba gobject: Use G_VALUE_INIT 2011-10-18 17:12:33 +01:00
Ryan Lortie
9829d04be8 GObject docs: resolve broken links
Some links were broken due to typos, because functionality was removed
in GLib 2.0 or for various other reasons.  Fix up as many of them as is
reasonable.
2011-09-05 18:46:59 -04:00
Matthias Clasen
1b28408b8b Spelling fixes
Spelling fixes in comments and docs, provided by
Kjartan Maraas in bug 657336.
2011-08-29 14:49:32 -04:00
Pavel Holejsovsky
d4c5e3b156 Add (allow-none) annotation for GValue setters.
Assorted g_value_set_xxx() and g_value_take_xxx() functions actually
allow NULL in source parameter.
2011-08-17 12:55:12 +02:00
Ryan Lortie
8f21e8145c gobject: remove -DG_DISABLE_CONST_RETURNS
GObject had a few cases of depending on G_CONST_RETURN not being defined
to 'const'.  Remove those in preparation for deprecation of
G_CONST_RETURN.
2011-06-09 11:11:30 -04:00
Matthias Clasen
d811f0cdc9 Fix a typo
And reword some docs.
2011-06-05 19:07:06 -04:00
Matthias Clasen
3b242bc5e9 Use g_param_spec_ref_sink instead of separate ref, sink 2011-06-04 23:43:05 -04:00
Matthias Clasen
38dc7955e4 No necessary to init qdata atomically 2011-06-04 23:14:32 -04:00
Alexander Larsson
0a918c0d2a Make g_object_get_data use the new faster g_datalist_get_data
https://bugzilla.gnome.org/show_bug.cgi?id=650458
2011-06-03 21:11:26 -04:00
Colin Walters
3bd3067ffc gobject: Use _ prefixing in private headers over G_GNUC_INTERNAL in public headers
This helps out gtk-doc and g-ir-scanner, and also makes much clearer
what's private versus public.

https://bugzilla.gnome.org/show_bug.cgi?id=651745
2011-06-03 12:40:01 -04:00
Ryan Lortie
8382135265 glib: Rewrite gatomic.[ch]
- remove all inline assembly versions

 - implement the atomic operations using either GCC intrinsics, the
   Windows interlocked API or a mutex-based fallback

 - drop gatomic-gcc.c since these are now defined in the header file.
   Adjust Makefile.am accordingly.

 - expand the set of operations: support 'get', 'set', 'compare and
   exchange', 'add', 'or', and 'xor' for both integers and pointers

 - deprecate g_atomic_int_exchange_and_add since g_atomic_int_add (as
   with all the new arithmetic operations) now returns the prior value

 - unify the use of macros: all functions are now wrapped in macros that
   perform the proper casts and checks

 - remove G_GNUC_MAY_ALIAS use; it was never required for the integer
   operations (since casting between pointers that only vary in
   signedness of the target is explicitly permitted) and we avoid the
   need for the pointer operations by using simple 'void *' instead of
   'gpointer *' (which caused the 'type-punned pointer' warning)

 - provide function implementations of g_atomic_int_inc and
   g_atomic_int_dec_and_test: these were strictly macros before

 - improve the documentation to make it very clear exactly which types
   of pointers these operations may be used with

 - remove a few uses of the now-deprecated g_atomic_int_exchange_and_add

 - drop initialisation of gatomic from gthread (by using a GStaticMutex
   instead of a GMutex)

 - update glib.symbols and documentation sections files

Closes #650823 and #650935
2011-05-28 16:10:44 -04:00
Benjamin Otte
02877e2902 gobject: Warn if someone uses the wrong property in g_object_get/set
"Interface::property" was not detected before and led to a crash.
2011-05-02 19:33:51 +02:00
Dan Winship
bdc23c44e8 Fix compiler warnings 2011-05-02 11:50:23 -04:00
Stef Walter
6cd08472b2 Better documentation for g_value_dup_object().
State that NULL is returned when value is NULL.
2011-02-16 00:21:27 -05:00
Will Thompson
c2d98c5609 GObject: correct documentation typos 2011-02-11 15:21:12 +00:00
Michael Natterer
634e9e43cf gobject: add an empty default impl of GObject::constructed()
to allow unconditional upchaining.
2011-01-12 19:45:40 +01:00
Matthias Clasen
068d53358b Make object_interface_check_properties work
As pointed out in bug 637738, it does not currently work, since
g_type_class_peek always returns NULL.
2010-12-27 23:41:10 -05:00
Pavel Holejsovsky
58e36daf29 Add GI annotations to GObject 2010-12-27 22:08:15 +01:00
Pavel Holejsovsky
3264d8d159 Add GI annotations to GClosure and friends. 2010-12-19 22:20:21 +01:00
Pavel Holejsovsky
ea577d60d4 Add GI annotations to GValue and GValueArray. 2010-12-19 10:39:36 +01:00
Will Thompson
ac4722df1c g_object_get_property: document that value must be initialized
I couldn't tell from reading the documentation whether I had to pass in
an uninitialized value, or a value initialized to the exact type, or
something else. It turns out (from reading the source) that you have to
pass in an initialized value, but you can use any type to which the
property's actual type can be transformed.

So, let's document this.
2010-12-17 13:21:07 +00:00
Jonas Holmberg
349f547561 gobject: initialize memory in g_object_new_valist
memset parameters array in g_object_new_valist to zeroes when expanding
the array to avoid acces to uninitialized memory.
2010-11-28 18:27:30 -05:00
Ryan Lortie
1a1fc130ec New function: g_clear_object()
By analogy to g_clear_error, takes a pass-by-reference GObject reference
and, if non-%NULL, unrefs it and sets it equal to %NULL.

Bug #620263.
2010-11-08 18:21:51 -05:00
Florian Müllner
a62b43fd9c Fix deadlock in g_object_remove_toggle_ref()
The code section guarded with toggle_refs_mutex includes a call to
g_object_unref(), which may call toggle_refs_notify(). As the latter
tries to acquire the same mutex, glib locks up.

https://bugzilla.gnome.org/show_bug.cgi?id=632884
2010-10-22 14:52:41 +02:00
Alberto Garcia
b7616114c6 Protect access to closure, weak refs and toggle refs arrays
This fixes https://bugzilla.gnome.org/show_bug.cgi?id=613822
2010-10-21 15:20:55 +02:00
Emmanuele Bassi
44a8ff2f8f gobject: Improve install_properties()
Cache the parent type outside of the loop, and fix a typo in the
documentation.
2010-10-08 16:10:18 +01:00
Johan Dahlin
701ce5d201 [introspection] Add GObject annotations
These were moved in from gobject-introspection
2010-09-24 16:23:31 -03:00
Emmanuele Bassi
9cd43d7a4c gobject: Add install_properties()
Since we added g_object_notify_by_pspec(), an efficient way to install
and notify properties relies on storing the GParamSpec pointers inside
a static arrays, like we do for signal identifiers.

Instead of multiple calls to g_object_class_install_property(), we
should have a single function to take the static array of GParamSpecs
and iterate it.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-09-13 12:34:53 +01:00
Emmanuele Bassi
016cecb179 Revert hack that broke things badly on Windows
This should fix bug #628952.

Don't include glib/gdatasetprivate.h directly. Especially don't define
GLIB_COMPILATION when doing that, as that causes breakage on Windows
because of the variable dllimport/dllexport stuff in gtypes.h that
checks GLIB_COMPILATION. That macro really should be defined only when
compiling code that goes into the libglib DLL. Otherwise the compiler
thinks that variables that should be imported from libglib are
actually defined in the code being compiled.

Just call g_atomic_pointer_get() as such, don't bother with
G_DATALIST_GET_FLAGS.

Signed-off-by: Tor Lillqvist <tml@iki.fi>
2010-09-08 12:06:49 +03:00
Emmanuele Bassi
01a46e5c65 Hack to include glib/gdatasetprivate.h directly
The gdatasetprivate.h header includes gatomic.h directly. It all works
well in GLib, but inside GObject it will trigger the single inclusion
guard.

Since this is a private header, and it's kind of a special case, one way
to fix it is to declare GLIB_COMPILATION around it and fool the single
inclusion guard in gatomic.h into thinking we're compiling GLib and not
GObject.
2010-09-04 17:25:37 +01:00
Olivier Crête
65797f7e54 notify: Remove g_object_notify_queue_from_object()
The function will not be safe with object locking in place, so we remove
it. The workaround is somewhat ugly, but it works.

https://bugzilla.gnome.org/show_bug.cgi?id=166020
2010-07-22 21:56:20 +02:00
Ryan Lortie
0fc50fa5f7 gobject/: fully remove gobjectalias hacks 2010-07-07 19:40:48 -04:00
Christian Dywan
272836936e Introduce G_PARAM_DEPRECATED and G_ENABLE_DIAGNOSTIC
See https://bugzilla.gnome.org/show_bug.cgi?id=601686
2010-06-23 16:45:12 +02:00
Damien Lespiau
f3879a4bdc Introduce g_object_notify_by_pspec()
g_object_notify_by_pspec() will emit the "notify" signal on the given
pspec, short-circuiting the hash table lookup needed by
g_object_notify(). The suggested and documented way of using
g_object_notify_by_pspec() is similar to the way of emitting signals
with their ID.

Emission tests (with no handler attached to the notify signal) show a
10-15% speedup over using g_object_notify().

https://bugzilla.gnome.org/show_bug.cgi?id=615425
2010-06-15 10:51:36 +01:00
Alexander Larsson
8e41be13ef Add dtrace and systemtap support for gobject
This adds static markers and systemtap tapsets for:

* type creation
* object lifetimes (creation, ref, unref, dispose, finalize)
* signal creation and emission

Signal emissions and finalization marker have a corresponding
*_end (or *-end in dtrace) version that is when the corresponding
operation is finished.

https://bugzilla.gnome.org/show_bug.cgi?id=606044
2010-05-27 14:51:41 -04:00
Edward Hervey
cecf61d1c3 gobject: Don't use G_PARAM_SPEC_VALUE_TYPE when we know the pspec is valid
https://bugzilla.gnome.org/show_bug.cgi?id=605667
2010-02-23 18:42:03 +01:00