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
Add the GLIB_AVAILABLE_IN_ALL annotation to all old functions (that
haven't already been annotated with the GLIB_AVAILABLE_IN_* macros or a
deprecation macro).
If we discover in the future that we cannot use only one macro on
Windows, it will be an easy sed patch to fix that.
https://bugzilla.gnome.org/show_bug.cgi?id=688681
This lets you set a va_marshaller on your signal which will be
propagated to all closures for the signal. Also, automatically
uses the generica va_marshaller if you specify a NULL c_marshaller.
https://bugzilla.gnome.org/show_bug.cgi?id=661140
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
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.
In some cases, signal arguments have to be collected, even if there are i
no signal handlers connected (e.g. for GVariant parameters, where collection
consumes a floating variant).
Based on a patch by Christian Persch.
Bug #643624.
2008-07-04 Michael Natterer <mitch@imendio.com>
Bug 541208 – Functions to easily install and use signals without
class struct slot
* gobject.symbols
* gsignal.[ch] (g_signal_new_class_handler): the same as
_gtk_binding_signal_new(), to install signals with a callback
instead of a class struct slot as class closure.
The next two functions are C convenience and much easier to use
than the generic overriding and chaining APIs which are intended
primarily for language bindings:
(g_signal_override_class_handler): to override a signal with a
callback instead of a class struct slot.
(g_signal_chain_from_overridden_handler): to chain up from a
signal without class struct slot. The API is similar to
g_signal_emit().
svn path=/trunk/; revision=7157
Thu Sep 22 12:42:12 2005 Tim Janik <timj@gtk.org>
* gparam.c (g_param_spec_internal): fix pspec->name assignment which
needs to be strdup()ed for non G_PARAM_STATIC_NAME pspecs. this fixes
recently introduced crashes during plugin unloading.
also, ensure that static pspec names are canonicalized.
* gsignal.h: reverted last change from matthias, we don't guarantee
that type ids aren't mangled with G_SIGNAL_TYPE_STATIC_SCOPE anywhere.
2005-09-20 Matthias Clasen <mclasen@redhat.com>
* gsignal.h (struct _GSignalQuery): Remove the misleading comment
about G_SIGNAL_TYPE_STATIC_SCOPE, since we don't allow that
on return types.
Fri Sep 12 16:31:40 2003 Owen Taylor <otaylor@redhat.com>
* gsignal.[ch]: Add g_signal_accumulator_true_handled(), to
do TRUE-stops-emit signals.
* Makefile.am: Move testoverride.c and testifaceinit.c to
tests/gobject.
Tue Mar 26 15:21:47 2002 Owen Taylor <otaylor@redhat.com>
* gsignal.h (g_signal_handlers_*_by_func): Add explicit
cast of G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA to
GSignalMatchType so that these macros work for C++.
(#76454, Damien Sandras)
Tue Dec 18 21:39:57 2001 Tim Janik <timj@gtk.org>
* testoverride.c: added some assertions to test
g_signal_get_invocation_hint().
* gsignal.[hc]: remove signal_id argument from
g_signal_chain_from_overridden(), the parameters are assumed to match
the innermost signal currently in emission for this instance.
added g_signal_get_invocation_hint() to figure the invocation hint
of the innermost signal emission of an instance.
* gsignal.c (g_signal_list_ids): fix G_BSEARCH_ARRAY_NODES() to
access a bsearch array and not a pointer to it (discovered by
Sven Neumann).
2001-12-08 Christopher Blizzard <blizzard@redhat.com>
* gsignal.h (g_signal_connect): Explicitly add a cast to the last
argument so that the macro will work from C++.
Mon Nov 19 14:35:56 2001 Owen Taylor <otaylor@redhat.com>
* *.h: Improve the detection of invalid includes by moving
the test outside the duplicate include guards.
* gsourceclosure.c (g_source_set_closure): Doc fix.
Sat Nov 17 14:10:35 2001 Owen Taylor <otaylor@redhat.com>
* glib/gbsearcharray.h: Include gtypes.h not gobject/gtype.h
* glib/glib-object.h gobject/*.h: Prevent headers from
being included directly except when compiling GObject.
* gobject/gvaluecollector.h: Include glib-object.h so that
this file can be included directly, since we don't
include it _from_ glib-object.h.
* gobject/gtype.c: Remove struct _GValue hack since we
now include glib/gvaluecollector.h which simply pulls in
glib-object.h.
Tue Nov 13 23:18:10 2001 Tim Janik <timj@gtk.org>
* gsignal.[hc]: add API for chaining:
g_signal_chain_from_overridden() and g_signal_override_class_closure(),
implementation yet to come.
* gtype.[hc], Makefile.am: provide G_LOG_DOMAIN as compile flag.
* gparam.[hc]: s/g_param_get/g_param_spec_get/ for get_nick,
get_name and get_blurb, to be consistent with the rest of the
g_param_spec_*() functions.
* gparamspecs.[hc]: got rid of bogus GClosure paramspec.
G_TYPE_CLOSURE is a boxed type already.
Sat Jun 30 23:14:32 2001 Tim Janik <timj@gtk.org>
* glib/glist.[hc]: added g_list_insert_before().
* glib/gslist.c (g_slist_insert_before): provide an implementation,
prototype was already present...
Sat Jun 30 11:07:00 2001 Tim Janik <timj@gtk.org>
* gobject.[hc]: provide weak_ref/weak_unref functions,
invoked from ->dispose. renamed ->shutdown() to ->dispose(),
provide "public" API entry here: g_object_run_dispose(), this
fucntion should _only_ be called from object system implementations
(e.g. gtkobject.c) if at all.
* gtypemodule.c (g_type_module_dispose): s/shutdown/dispose/
* gsignal.h: removed compat aliases.
* gobject.c (g_object_connect): support data objects.
Thu Jun 28 16:57:44 2001 Tim Janik <timj@gtk.org>
* configure.in (GLIB_MICRO_VERSION): up version number to 1.3.7,
interface age 0, binary age 0.
Thu Jun 28 16:42:49 2001 Tim Janik <timj@gtk.org>
* gsignal.c (g_signal_lookup):
(g_signal_list_ids): give elaborate warnings about invalid types,
non-instantiatable types and unloaded types that we can't operate on.
* gparam.[hc]: g_param_spec_pool_belongings() ->
g_param_spec_pool_list_owned().
* gsignal.[hc]: renamed:
g_signal_newc -> g_signal_new
g_signal_disconnect_by_func -> g_signal_handlers_disconnect_by_func
g_signal_block_by_func -> g_signal_handlers_block_by_func
g_signal_unblock_by_func -> g_signal_handlers_unblock_by_func
added GConnectType to simplify (..gboolean swapped, gboolean after)
args.
* gobject.[hc]: changed prototypes accordingly.
Mon Jun 11 17:07:06 2001 Tim Janik <timj@gtk.org>
* gboxed.[hc]: remove left-over usages of an anonymous GBoxed typedef.
* gobjectnotifyqueue.c: moved property notify queue implementation
bits into this function.
* gparam.[hc]: added g_param_spec_pool_belongings(), completed
g_param_spec_pool_list(). added GParameter for _setv() functions.
* gobject.[hc]: use gobjectnotifyqueue.h implementation now.
got rid of properties_changed signal.
new functions g_object_newv(), g_object_class_list_properties().
removed "properties_changed" signal.
* gtype.[hc]: added g_type_depth() to figure number of parent
types + 1 for a type.
* gsignal.h: add g_signal_connect() (as per owen's request) and
g_signal_connect_swapped().
Sun May 27 05:09:18 2001 Tim Janik <timj@gtk.org>
* gmain.c (g_main_context_prepare): unlock context when bailing
out with a warning.
(g_main_context_check): same here.
* gmain.c (g_main_context_check): before returning due to
changed pollfds, unlock context.
Sun May 27 04:52:28 2001 Tim Janik <timj@gtk.org>
* gsignal.[hc] (g_signal_stop_emission_by_name): added variant
to stop signal emissions through a detailed_signal string.
* gsignal.c (signal_emit_R) (g_signal_emit_valist): account for
the fact that g_value_* functions may cause signal emissons by
unlocking the global signal system lock around g_value_* functions.
(signal_emit_unlocked_R): renamed this from signal_emit_R() to reflect
that this functions acquires the lock on its own now.
Mon May 14 01:49:01 2001 Tim Janik <timj@gtk.org>
* gsignal.[hc] (g_signal_handler_is_connected): new function
to check whether a handler is still connected to an instance
(by handler id).
Thu May 10 15:19:01 2001 Tim Janik <timj@gtk.org>
* gscanner.c (g_scanner_key_hash): use g_str_hash() algorithm
to generate hashes.
* gmem.c (standard_calloc): free() doesn't return a value
(Mark Murnane).
Thu May 10 14:00:48 2001 Tim Janik <timj@gtk.org>
* gparamspecs.[hc]: removed g_param_spec_stringc() in lack of
evidence of public need.
* gsignal.h: added g_signal_disconnect_by_func(),
g_signal_block_by_func() and g_signal_unblock_by_func() convenience
macros as per owen's request.
* gtype.c (SIZEOF_FUNDAMENTAL_INFO): align sizeof (GTypeFundamentalInfo)
to size of longs and pointers.
Sun Apr 29 00:37:34 2001 Tim Janik <timj@gtk.org>
* ghook.[hc]: made hook ids a gulong.
Sat Apr 28 23:39:42 2001 Tim Janik <timj@gtk.org>
* gsignal.[hc]: made signal handler and emission hook ids gulongs.
(signal_handlers_foreach_matched_R): only invoke callback for handlers
that are not disconnected (id>0).
(signal_emit_R): prevent invocation of signal handlers during the
emission they were connected within.
* glib-mkenums: publically installed perl-script to parse C code
enums and generate descriptions thereof.
* glib-mkenums.1: assorted man page.
2001-02-21 Tor Lillqvist <tml@iki.fi>
* *.h: Use G_BEGIN_DECLS and G_END_DECLS.
* Makefile.am: Use libglib-1.3.la from top_builddir. Invoke
libtool with -no-undefined for Win32 and Cygwin.
Thu Mar 8 16:23:34 2001 Tim Janik <timj@gtk.org>
* ghook.[hc]: destruction cleanup. there's one
->finalize_hook member in the hooklist now that gets
called when a hook should be destroyed, that's it.
that function is guarranteed to be called only when
all ref_counts to the hook vanished, thus also when
the hook is not in call.
Thu Mar 8 16:35:48 2001 Tim Janik <timj@gtk.org>
* gparamspecs.[hc]: s/g_param_spec_string_c/g_param_spec_stringc/.
* gsignal.[hc]: fixed accumulator invocation, implemented emission
hooks. and no, neither of these callbacks are called via a closure,
language bindings can wrap the accumulator and emission hook
interface, they already get parameters marshalled into a GValue array.
(g_signal_connect): removed this function as its C specific, doesn't
cover the swapped argument, is too close to its broken original
gtk_signal_connect() and creates demand for _swapped, _after and
_swapped_after variants <brrr>.
(g_signal_connectc): convenience macro to connect a C handler
func with data, like the old g_signal_connect() plus swapped
argument.
* gtype.h:
* gboxed.c: added G_TYPE_VALUE boxed type.
Wed Mar 7 09:36:33 2001 Tim Janik <timj@gtk.org>
* gboxed.[hc]: changed prototype of g_boxed_type_register_static()
to contain an optional init function and a hint at whether the
boxed structure uses ref counting internally.
added g_value_set_boxed_take_ownership().
made G_TYPE_BOXED an abstract value type.
* genums.[hc]: made G_TYPE_ENUM and G_TYPE_FLAGS abstract value
types.
* glib-genmarshal.c: argument type changes, preparation for third-party
arg specification.
* gobject.[hc]: cleaned up get/set property code.
added g_strdup_value_contents() to improve warnings.
* gparam.[hc]: added g_param_value_convert(), taking over responsibility
of the old g_value_convert(). added G_PARAM_LAX_VALIDATION flag so
validation alterations may be valid a part of the property setting
process.
* gparamspecs.[hc]: made value comparisons stable (for sort applications).
added GParamSpecValueArray, a param spec for value arrays and
GParamSpecClosure. nuked the value exchange functions and
GParamSpecCCallback.
* gtype.[hc]: catch unintialized usages of the type system with
g_return_val_if_uninitialized(). introduced G_TYPE_FLAG_VALUE_ABSTRACT
to flag types that introduce a value table, but can't be used for
g_value_init(). cleaned up reserved type ids.
* gvalue.[hc]: code cleanups and saner checking.
nuked the value exchange API. implemented value transformations, we
can't really "convert" values, rather transforms are an anylogy to
C casts, real conversions need a param spec for validation, which is
why g_param_value_convert() does real conversions now.
* gvaluearray.[hc]: new files that implement a GValueArray, a struct
that can hold inhomogeneous arrays of value (to that extend that it
also allowes undefined values, i.e. G_VALUE_TYPE(value)==0).
this is exposed to the type system as a boxed type.
* gvaluetransform.c: new file implementing most of the former value
exchange functions as single-sided transformations.
* gvaluetypes.[hc]: nuked G_TYPE_CCALLBACK, added
g_value_set_string_take_ownership().
* *.h: s/G_IS_VALUE_/G_VALUE_HOLDS_/.
* *.[hc]: many fixes and cleanups.
* many warning improvements.
Tue Feb 27 18:35:15 2001 Tim Janik <timj@gtk.org>
* gobject.c (g_object_get_valist): urg, pass G_VALUE_NOCOPY_CONTENTS
into G_VALUE_LCOPY(), this needs proper documenting.
* gparam.c: fixed G_PARAM_USER_MASK.
* gtype.c (type_data_make_W):
(type_data_last_unref_Wm): fixed invalid memory freeing.
* gobject.c (g_object_last_unref): destroy signal handlers associated
with object, right before finalization.
* gsignal.c (g_signal_parse_name): catch destroyed nodes or signals
that don't actually support details.
* gobject.[hc]: got rid of property trailers. nuked GObject
properties "data" and the "signal" variants.
(g_object_connect): new convenience function to do multiple
signal connections at once.
(g_object_disconnect): likewise, for disconnections.
* gparam.[hc] (g_param_spec_pool_lookup): took out trailer support.
* gvalue.[hc]: marked g_value_fits_pointer() and g_value_peek_pointer()
as private (the latter got renamed from g_value_get_as_pointer()).
Wed Mar 7 09:32:06 2001 Tim Janik <timj@gtk.org>
* glib-object.h: add gvaluearray.h.
* gstring.[hc]: fixup naming of g_string_sprint*.
* gtypes.h: fixed GCompareDataFunc naming.
Wed Mar 7 09:33:27 2001 Tim Janik <timj@gtk.org>
* gobject/Makefile.am: shuffled rules to avoid excessive
rebuilds.
* gobject/gobject-sections.txt: updates.
* gobject/tmpl/*: bunch of updates, added another patch
from Eric Lemings <eric.b.lemings@lmco.com>.
Sat Feb 17 04:55:35 2001 Tim Janik <timj@gtk.org>
* gtype.[hc]: changed collect_format, collect_value() and lcopy_format,
lcopy_value() in the GTypeValueTable. the collect functions are now
called only once per value, collect_format/lcopy_format are strings
that enlist all necessary GTypeCValues to be varargs-collected.
* gvalue.h: ranamed STATIC_TAG to G_VALUE_NOCOPY_CONTENTS to indicate that
a value shouldn't copy its contents.
* gvaluecollector.h: changed G_VALUE_COLLECT() and G_VALUE_LCOPY()
macros to carry an additional argument (flags) that can be used
to pass G_VALUE_NOCOPY_CONTENTS along to the collection functions.
* *.c: adapted collect_value() and lcopy_value() functions to the new
prototypes, support G_VALUE_NOCOPY_CONTENTS where apropriate.
* gsignal.[hc]: introduced a G_SIGNAL_TYPE_STATIC_SCOPE flag that can
be passed along (ORed) with the parameter types, indicating that the
emission arguments are to be considered static for the scope of the
emission. should be used with care and only if the caller knows that
a parameter cannot be destroyed/freed from signal handlers connected
to an emission.