Commit Graph

1495 Commits

Author SHA1 Message Date
Ryan Lortie
8ea414c8c6 G_DECLARE_*_TYPE: add auto cleanup support
Automatically add support for the new cleanup macros to the type
declaration macros.

This is an API break because now your parent class needs to support
cleanup if you want to use G_DECLARE_*_TYPE.  These macros are only 1
day old, however, so that's probably not a big problem (and we are
already busy adding the macros all over GLib and Gtk+).

https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-01-30 16:52:36 +01:00
Ryan Lortie
3d5de34def gobject: add support for g_auto() and g_autoptr()
Add support to libgobject types for the new cleanup macros.

https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-01-30 16:52:36 +01:00
Ryan Lortie
b5e1ea6fee DECLARE_TYPE: ignore deprecations in inlines
Prevent complaints about deprecations in the inline functions emitted by
the new G_DECLARE_*_TYPE macros.
2015-01-30 16:49:53 +01:00
Ryan Lortie
9d0389b3b5 G_DECLARE_FINAL_TYPE: trivial fix in docs comment
https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-01-30 16:49:53 +01:00
Christian Hergert
f3c604d273 G_DECLARE_DERIVED_TYPE: allow forward declarations
This allows multiple declarations such as:

 typedef struct _Foo Foo;

as is needed when you have systems with circular referencing.

https://bugzilla.gnome.org/show_bug.cgi?id=743596
2015-01-28 13:22:23 +00:00
Ryan Lortie
3b4cb28e17 gtype: add type declaration macros for headers
Add G_DECLARE_DERIVABLE_TYPE() and G_DECLARE_FINAL_TYPE() to allow
skipping almost all of the typical GObject boilerplate code.

These macros make some assumptions about GObject best practice that mean
that they may not be usable with older classes that have to preserve
API/ABI compatibility with a time before these practices existed.

https://bugzilla.gnome.org/show_bug.cgi?id=389585
2015-01-27 11:07:52 +00:00
Philip Withnall
1cf7f5a240 gobject: Fix a typo in a documentation comment 2015-01-25 17:09:35 +00:00
Thomas Haller
c447bc7f93 gobject: don't use G_STRLOC in G_OBJECT_WARN_INVALID_PSPEC() macro
Using G_STRLOC ends up embedding unique strings of the form
__FILE__:__LINE__ in the compiled binary. We can avoid these
by passing __FILE__ and __LINE__ separately when constructing
the warning text.
This probably reduces the size of the binary as __FILE__ is
likely already contained as string otherwise.

Note that for GCC 2.x this changes behavior because G_STRLOC
also contained __PRETTY_FUNCTION__.

https://bugzilla.gnome.org/show_bug.cgi?id=741654
2014-12-18 15:02:16 +01:00
Philip Withnall
d951db4236 gobject: Add g_set_object() convenience function to set GObject pointers
Along the same lines as g_clear_object(), g_set_object() is a
convenience function to update a GObject pointer, handling reference
counting transparently and correctly.

Specifically, it handles the case where a pointer is set to its current
value. If handled naïvely, that could result in the object instance
being finalised. In the following code, that happens when
(my_obj == new_value) and the object has a single reference:
    g_clear_object (&my_obj);
    my_obj = g_object_ref (new_value);

It also simplifies boilerplate code such as set_property()
implementations, which are otherwise long and boring.

Test cases included.

https://bugzilla.gnome.org/show_bug.cgi?id=741589
2014-12-18 11:32:56 +00:00
Ryan Lortie
c476f7cd26 gsignal: add a clarification to the docs
As evidenced by a mistake that I made recently, this documentation could
use a little bit of clarification.
2014-11-28 16:22:16 -05:00
Jasper St. Pierre
91802bbf2b gparam: Make the documentation clearer for CONSTRUCT_ONLY properties
It's not that the properly will only be set on construction, it's that
it *can* only be set upon construction.
2014-11-22 19:47:43 -08:00
Volker Sobek
1edd463137 docs: Update GParamFlags docs.
Remove reference to G_PARAM_READWRITE from GParamFlags' description,
since commit 6c395244a5 added G_PARAM_READWRITE to GParamFlags.

https://bugzilla.gnome.org/show_bug.cgi?id=726037
2014-11-10 23:25:23 +01:00
Benjamin Otte
36d8b941d4 signal: Keep only one list of emissions
There is no need to keep 2 lists.

This simplifies the code and gets rid of the only user inside glib of
G_HAVE_GROWING_STACK.

https://bugzilla.gnome.org/show_bug.cgi?id=736284
2014-10-12 00:27:06 +02:00
Matthias Clasen
58ec89ea7c Fix a return_if_fail confusion
This slipped through my editing of the patch.
2014-10-11 15:53:13 -04:00
Owen W. Taylor
011bf876e7 Add simple instance count facility
Add GOBJECT_DEBUG=instance-count which enables internal accounting
of the number of instances of each GType, and g_type_get_instance_count()
to retrieve the result.

https://bugzilla.gnome.org/show_bug.cgi?id=354457
2014-10-11 13:54:29 -04:00
Edward Hervey
3e2735f468 gtype: Fast-path for g_type_is_a
Do I really need to explain why ?

https://bugzilla.gnome.org/show_bug.cgi?id=732085
2014-08-08 11:13:38 +02:00
Andre Moreira Magalhaes (andrunko)
4b5bdf6ceb Do not crash when checking whether an instance type is of a given fundamental.
Not all instances have a TypeNode associated (e.g. GstEvent), so lets check if node is available
before trying to use it.

This crash can be easily reproduced by creating an event with gst_event_new_eos and using
G_IS_OBJECT on the event instance.

https://bugzilla.gnome.org/show_bug.cgi?id=733982
2014-08-08 11:13:01 +02:00
Alexander Larsson
b1dd594a22 Remove atomics from g_clear_object/g_clear_pointer
Practically no caller of these functions require atomic behaviour,
but the atomics are much slower than normal operations, which makes
it desirable to get rid of them. We have not done this before because
that would be a break of the ABI.

However, I recently looked into this and it seems that even if the
atomics *are* used for g_clear_* it is not ever safe to use this.  The
atomics protects two threads that are racing to free a global/shared
object from freeing the object twice. However, any *user* of the global
object have no protection from the object being freed while in use,
because there is no paired operation the reads and refs the object
as an atomic unit (nor can such an operation be implemented using
purely atomic ops).

So, since nothing could safely have used the atomic aspects of these
functions I consider it acceptable to just remove it.

https://bugzilla.gnome.org/show_bug.cgi?id=733969
2014-07-30 15:11:01 +02:00
Javier Jardón
60fe7b46d2 docs: Use "Returns:" instead "Return:" 2014-07-10 17:09:30 +01:00
Michael Catanzaro
29c48f623f Fix typo 2014-07-05 20:27:58 -05:00
Kang Hu
baef9d1811 gobject: move _g_type_debug_flags from gtype.h to gtype-private.h
_g_type_debug_flags is used internally to suport GOBJECT_DEBUG
environment variable. it should never be exposed to the outside.

https://bugzilla.gnome.org/show_bug.cgi?id=729914
2014-06-28 14:00:32 -04:00
Ryan Lortie
dce88768dc all: remove use of 'register' keyword
We should have done this a decade ago...

https://bugzilla.gnome.org/show_bug.cgi?id=730293
2014-06-28 13:07:52 -04:00
Ryan Lortie
6677906436 GObject: tweak property deprecation warnings
Don't emit property deprecation warnings for construct properties that
are being set to their default value during construction, but _do_ emit
them in all cases when the property was explicitly given to
g_object_new().

https://bugzilla.gnome.org/show_bug.cgi?id=732184
2014-06-27 14:44:36 -04:00
Emmanuele Bassi
f948a71483 gtype: Remove unused header
GType does not use GBSearchArray any more.
2014-06-25 11:56:12 +01:00
Ryan Lortie
d0e7061785 GObject: warn on use of deprecated properties
By default G_PARAM_DEPRECATED means absolutely nothing.  We only emit a
warning if G_ENABLE_DIAGNOSTIC is set to '1' and then, only on sets.

Turn the logic on its head: emit the warning by default, unless
G_ENABLE_DIAGNOSTIC is set to 0.  In order to avoid a torrent of output, only
emit a warning once per property name.

https://bugzilla.gnome.org/show_bug.cgi?id=732184
2014-06-24 16:18:30 -04:00
Edward Hervey
c5c3c320a2 gvalue: New g_value_init_from_instance
Used for the commonly used case (in signal emission) where we
initialize and set a GValue for an instance

Includes a fast-path for GObject

Overall makes it 6 times faster than the previous combination
of g_value_init + g_value_set_instance

Makes signal emission around 10% faster

https://bugzilla.gnome.org/show_bug.cgi?id=731950
2014-06-24 14:21:10 -04:00
Philip Withnall
248ca72782 gsignal: Add an example to the g_signal_connect_swapped() documentation
The precise behaviour of and motivation behind swapping parameters was
not entirely clear before.

https://bugzilla.gnome.org/show_bug.cgi?id=732068
2014-06-23 12:30:51 +01:00
Philip Withnall
0950369899 gclosure: Remove an unused alloca() and assignment
Coverity issue: #1159511

https://bugzilla.gnome.org/show_bug.cgi?id=732005
2014-06-22 12:57:57 +01:00
Matthias Clasen
7991178a75 Try to make gobject.py work with both pythons
This change was suggested on the fedora test list, and has been
reported to work.
2014-06-16 15:25:42 -04:00
Colin Walters
09498e52bb gparam: Remove unnecessary conditionals around preconditions
These cause a static analyzer to think we're trying to actually handle
them being NULL, which is not the case.  They both must not be NULL,
period.

No idea why the code was like this originally.

Reviewed by mclasen on IRC.
2014-06-12 13:38:27 -04:00
Ryan Lortie
fcdd25a96e gparam: change value of G_PARAM_EXPLICIT_NOTIFY
GParamSpec has a possibility of user-introduced flags, and we didn't
respect that with the addition of _EXPLICIT_NOTIFY.

Change the documentation for the maximum number of user flags to 10,
just to pick a somewhat random number.  The documentation here was never
correct anyway -- it previously claimed that as many as 38 flags were
possible.

Meanwhile, move G_PARAM_EXPLICIT_NOTIFY next to _DEPRECATED in order to
avoid conflicts with low-numbered user flags (which are in use by at
least evolution-data-server).

https://bugzilla.gnome.org/show_bug.cgi?id=731341
2014-06-10 19:04:35 -04:00
Ryan Lortie
545b44444b gtype: remove interface-after-init exceptions
A year ago, we tried to remove support for adding interfaces on
already-initialised types.  There were problems with the C++ and C#
bindings at the time, so we added exceptions to give them a bit more
time to catch up.

It's already one cycle after when these exceptions were planned to be
removed, so let's take them out now.

https://bugzilla.gnome.org/show_bug.cgi?id=697229
2014-06-09 14:18:15 -04:00
Ryan Lortie
f2f66bfe45 docs: warn about installing properties after init
Leave ourselves a little wiggle room: if people install properties after
initialisation then we reserve the right to handle that in a way that
may not be threadsafe.

https://bugzilla.gnome.org/show_bug.cgi?id=698614
2014-06-06 16:44:47 -04:00
Ryan Lortie
85e9455f68 Revert "GObject: prevent installing properties after init"
This reverts commit ddb0ce1421.

Conflicts:
	gobject/gobject.c

https://bugzilla.gnome.org/show_bug.cgi?id=698614
2014-06-06 16:44:47 -04:00
Ryan Lortie
d558e87c65 gtype: guard uses of new fundamental type check
g_type_is_fundamentally_a (see bug 730984) is a new API/ABI and is
marked with a version macro.  We should therefore avoid its
unconditional use from G_IS_OBJECT() and G_IS_PARAM_SPEC() which are
APIs that have been around for a long time.

This prevents deprecation warnings from being emitted when these
functions are used with an older GLIB_VERSION_MAX_ALLOWED and also
prevents linking to the new ABI in that case (so that it's possible to
use the resulting binary with an older version of GLib).

https://bugzilla.gnome.org/show_bug.cgi?id=731335
2014-06-06 10:49:29 -04:00
Ryan Lortie
0208861a13 test: add test for explicit-notify properties
https://bugzilla.gnome.org/show_bug.cgi?id=731200
2014-06-06 10:25:48 -04:00
Ryan Lortie
bbdb2345fc gobject: add 'explicit notify' GParamSpec flag
Add a flag to prevent the automatic emission of the "notify" signal
during g_object_set_property().

If this flag is set then the class must explicitly emit the notify
for themselves.  This is already standard practice on most classes, but
we cannot simply remove the existing behaviour because there are surely
many cases where it is needed.

https://bugzilla.gnome.org/show_bug.cgi?id=731200
2014-06-06 10:25:48 -04:00
Matthias Clasen
adfaf0e456 docs: GType documentation cleanup
Still some markup left.
2014-05-31 20:55:00 -04:00
Emmanuele Bassi
24ab95582b docs: Replace <function> XML tag with back ticks
https://bugzilla.gnome.org/show_bug.cgi?id=731050
2014-05-31 19:22:15 +01:00
Matthias Clasen
ab18d71e6f Minor documentation additions and corrections
Going for 100%.
2014-05-31 10:54:02 -04:00
Matthias Clasen
ad5b4bf92e Document g_signal_handlers_destroy 2014-05-31 10:54:02 -04:00
Edward Hervey
f8595a490f GParamSpec: Use new fundamental instance check
https://bugzilla.gnome.org/show_bug.cgi?id=730984
2014-05-31 15:46:21 +02:00
Edward Hervey
faceb8960b gobject: Use fast fundamental instance type check
Speeds up g_object_ref/_unref by 50%-65% (i.e. takes 60-65% of the time
it used to take).

https://bugzilla.gnome.org/show_bug.cgi?id=730984
2014-05-31 15:46:21 +02:00
Edward Hervey
6072e3650f gtype: Add check for fundamental instance type
When checking whether an instance is of a given fundamental type (such
as G_TYPE_OBJECT), we can avoid over 60%+ of the cost of checking types.

https://bugzilla.gnome.org/show_bug.cgi?id=730984
2014-05-31 15:45:29 +02:00
Matthias Clasen
03a48e1ade Fix the closure test in continuous
This test has the same problem as the mapping-test - it uses
SIGUSR1 without checking the signal mask. Apply the same fix
here.
2014-05-30 10:22:35 -04:00
Marek Kasik
6a8c2685be gobject: unref unused class
If g_type_class_ref() returns a class which is not
a GObjectClass we need to unref it before return in
object_interface_check_properties().

https://bugzilla.gnome.org/show_bug.cgi?id=706983
2014-05-22 11:00:14 +02:00
Matthias Clasen
4360756c69 Avoid overeager warning about deprecated properties
Construct properties are always set during construction.
It makes no sense to warn about this even if the property
is marked as deprecated; the deprecation warning should
only be issues for explicit uses of the property after
construction.

https://bugzilla.gnome.org/show_bug.cgi?id=730045
2014-05-13 08:08:38 -04:00
Matthias Clasen
4dba2eb486 Remove some markup from docs 2014-05-13 08:08:37 -04:00
Tom Tromey
20cda557e5 gobject.py: Port to gdb 7.7 frame filter API
https://bugzilla.gnome.org/show_bug.cgi?id=623552
2014-05-10 19:49:22 +10:00
Sébastien Wilmet
430e6fd6ad doc: various improvements
- GSubprocessLauncher exists since 2.40, not 2.36
- more logical order for g_markup functions
- fix short description of GMarkup
- GMarkupParser: specify that some parameters are NULL-terminated.
- g_string_new (NULL); is possible.
- other trivial fixes.

https://bugzilla.gnome.org/show_bug.cgi?id=728983
2014-05-09 18:47:42 +02:00
Mathieu Bridon
24fdee7a78 Fix some typos in documentation 2014-05-05 18:30:56 +08:00
Philip Withnall
704852ff09 gobject: Document that classes/objects/interfaces are zero-filled
On initialisation, GObject guarantees to zero-fill
class/object/interface structures. Document this so people don’t spend
forever writing:
    my_object->priv->some_member = NULL;
    my_object->priv->some_other_member = NULL;

https://bugzilla.gnome.org/show_bug.cgi?id=729167
2014-04-29 10:40:20 +01:00
Volker Sobek
4441595378 docs: Remove <!-- --> comment before plural s
These did show up in the html. Since symbol names are checked for a
trailing plural s when generating the docs, the links stay functional
after removing these comments.

https://bugzilla.gnome.org/show_bug.cgi?id=728380
2014-04-24 13:42:37 +02:00
Volker Sobek
9f0ad54c80 docs: Use markdown links in all .c and .h files
Commit e7fd3de86d already did most of this.

https://bugzilla.gnome.org/show_bug.cgi?id=728285
2014-04-15 22:19:07 +02:00
Emmanuele Bassi
6c395244a5 gparam: Add G_PARAM_READWRITE to GParamFlags
Using a #define for an enumeration value buys us nothing, and it's
mostly historical baggage that makes binding GObject needlessly
complicated.

https://bugzilla.gnome.org/show_bug.cgi?id=726037
2014-04-10 20:00:23 +01:00
Alexandre Rostovtsev
2b178c762f gobject: try to link with -Wl,-z,nodelete
Since the type system does not support reloading its data and assumes
that libgobject remains loaded for the lifetime of the process, we
should link libgobject with a flag indicating that it can't be unloaded.

https://bugzilla.gnome.org/show_bug.cgi?id=707298
2014-04-10 01:38:41 -04:00
Paolo Borelli
4a4b044321 Add a small note to g_cclosure_marshal_generic docs
reviewed-by: Emmanuele Bassi
2014-04-03 11:37:32 +02:00
Dan Winship
d8c14f1378 gbinding: warn on failed value transformation
GBinding warned if g_value_transform() returned FALSE, but it didn't
warn if there was no transformation available at all. Fix that and
test it.

https://bugzilla.gnome.org/show_bug.cgi?id=726574
2014-03-17 17:43:19 -04:00
Sebastian Dröge
012011538f gtype – Mark _get_instance_private() function as G_GNUC_UNUSED
clang likes to complain about it being unused.

https://bugzilla.gnome.org/show_bug.cgi?id=723899
2014-03-08 09:01:52 -05:00
Matthias Clasen
7a6dfd75d6 GObject: Remove more leftover markup from headers 2014-03-07 06:10:36 -05:00
Matthias Clasen
49cc207e35 docs: Ditch more markup
Some markup was hiding in docs in headers. Drop it there, too.
2014-03-02 18:23:43 -05:00
William Jon McCann
20f4d1820b docs: use "Returns:" consistently
Instead of "Return value:".
2014-02-19 19:41:52 -05:00
Ryan Lortie
7cbff954b9 win32: fixup lib.exe invocation
We have a configure.ac check for lib.exe that attempts to enable
creation of .lib files for our 5 public libraries.  That has been broken
for a long time for two reasons:

 1) the Makefiles hardcode 'lib' instead of 'lib.exe'

 2) we dropped generation of .def files quite some time ago (except for
    in gthread where we have the two-symbol file under version control)

Add new rules for creating .def files from dumpbin.exe (which you should
have if you have lib.exe) and fix the .lib rules to use lib.exe.

Add a bit of $(AM_V_GEN) all around, as well.

https://bugzilla.gnome.org/show_bug.cgi?id=722033
2014-02-15 16:55:25 -05:00
Dan Winship
5cab3fcec1 gobject: re-allow finalization from constructor()
Although returning NULL from constructor is strongly discouraged, some
old libraries need to keep doing it for ABI-compatibility reasons.
Given this, it's rude to forbid finalization from within
constructor(), since it would otherwise work correctly now anyway (and
the critical when returning NULL should discourage any new uses of
returning NULL from constructor()).

https://bugzilla.gnome.org/show_bug.cgi?id=661576
2014-02-15 10:20:53 -05:00
Matthias Clasen
bc6ee788b4 docs: let go of &ast;
Since we are no longer using sgml mode, using /&ast; &ast;/ to
escape block comments inside examples does not work anymore.
Switch to using line comments with //
2014-02-14 21:33:36 -05:00
Matthias Clasen
35066ed6c6 Docs: Drop entities, switch away from sgml mode
Since all element markup is now gone from the doc comments,
we can turn off the gtk-doc sgml mode, which means that from
now on, docbook markup is no longer allowed in doc comments.

To make this possible, we have to replace all remaining
entities in doc comments by their replacement text, &amp; -> &
and so on.
2014-02-09 02:07:26 -05:00
Matthias Clasen
e7fd3de86d Eradicate links and xrefs
These are all replaced by markdown ref links.
2014-02-08 12:26:56 -05:00
Matthias Clasen
5baa0f2af5 Stop using <para> for ids
Instead, use the id support in markdown headings.
2014-02-06 16:48:49 -05:00
Matthias Clasen
3232425785 Docs: replace <literal> by ` 2014-02-06 08:07:16 -05:00
Matthias Clasen
a35d8a4c77 Docs: use quotes instead of firstterm 2014-02-06 08:07:16 -05:00
Matthias Clasen
cb588d4532 Convert external links to markdown syntax 2014-02-05 21:23:28 -05:00
Ryan Lortie
78ec35f7ab gobject: box GVariantDict
We will want to use this in GApplication for a signal and a property.

https://bugzilla.gnome.org/show_bug.cgi?id=625408
2014-02-04 12:24:19 +00:00
Matthias Clasen
adf892e96a Annotate all examples with their language
The C ones, at least.
2014-02-01 15:11:49 -05:00
Matthias Clasen
42cf80780b Docs: Big entity cleanup
Strip lots of entity use from |[ ]| examples (which are now
implicit CDATA). Also remove many redundant uses of <!-- -->.
2014-02-01 12:00:30 -05:00
Matthias Clasen
60b623d3fb GObject: Convert docs to markdown
In particular, convert lists to markdown syntax.
2014-02-01 10:22:45 -05:00
Matthias Clasen
a4c33c6f8b Docs: Don't use the code tag 2014-01-31 22:05:04 -05:00
Matthias Clasen
17f51583a8 Docs: Convert examples to |[ ]| 2014-01-31 21:56:33 -05:00
Matthias Clasen
4d12e0d66f Docs: Don't use the emphasis tag
Most of the time, the text read just as well without the extra
boldness.
2014-01-31 20:34:33 -05:00
Matthias Clasen
c575d24dfb Docs: Don't use the note tag
More markup avoidance.
2014-01-31 18:20:06 -05:00
Daniel Mustieles
078dbda148 Updated FSF's address 2014-01-31 14:31:55 +01:00
Matthias Clasen
3d42934b71 Docs: don't use the structname tag
Just avoid explicit docbook markup.
2014-01-31 00:29:14 -05:00
Matthias Clasen
6f3c465535 Docs: don't use structfield tags
They don't add anything over @foo, and we want to avoid explicit
docbook markup as far as possible.
2014-01-30 23:59:06 -05:00
Matthias Clasen
acfb76afe2 Docs: don't use <footnote>
It basically does not work in the HTML output.
2014-01-30 23:52:58 -05:00
Rico Tzschichholz
ee38a1af80 gobject: Add missing transfer annotation to g_boxed_copy 2014-01-23 17:22:19 +01:00
A. Walton
deb8a9325b Clarify type transformability and comparability
If two GValues are transformable, it implies they are compatible,
so you do not need to check for compatibility yourself. Bump the
documentation to reflect this fact.

https://bugzilla.gnome.org/show_bug.cgi?id=707111
2014-01-19 23:51:51 -05:00
Jasper St. Pierre
243bec9d0d gobject.py: Simplify or_join_array 2013-12-31 15:40:40 -05:00
Jasper St. Pierre
bfbe7127d5 gobject.py: Simplify and reduce code a bit 2013-12-31 15:40:40 -05:00
Jasper St. Pierre
4e512a1af8 gobject.py: Remove old hack for stripping IA__ symbols
We don't use IA__ symbols anymore; they've been replaced with -Bsymbolic
2013-12-31 15:40:10 -05:00
Jasper St. Pierre
b4af2d685e gobject.py: Fix indentation 2013-12-31 15:40:10 -05:00
Tim Lunn
d33f72097f Make gdb pretty-printers compatible with Python3
On some systems gdb is linked against python3 where "long" no longer
exists. In this case should be using int.

https://bugzilla.gnome.org/show_bug.cgi?id=720635
2013-12-18 07:22:16 +11:00
Damien Lespiau
91d4659bbf gobject.py: Don't install frame filters when GDB does not support them
Stock GDB (both versions 7.0 and 7.1) does not come with the new
backtrace code and python API. To prevent an ugly python backtrace when
auto-loading gobject.py, let's catch the exception and not register the
FrameWrapper and the FrameFilter.

https://bugzilla.gnome.org/show_bug.cgi?id=613732
2013-12-17 10:51:48 -05:00
Matthias Clasen
c34cc2348c Simplify subprocesses in tests
Use the new way of running tests in a subprocess without
registering extra 'subprocess' test cases where appropriate.
2013-12-15 11:50:00 -05:00
Colin Walters
8f4dc7012e gsignal: Signal connection ids are always > 0 if successful
Note this explicitly so that people can rely on doing:

if (mystruct->sigid > 0)
  g_signal_disconnect (mystruct->object, mystruct->sigid);

https://bugzilla.gnome.org/show_bug.cgi?id=719809
2013-12-03 19:23:49 -05:00
Matthias Clasen
2baa50ee4f Remove g_trap_instance_signals as well
This is another crude conditional breakpoint mechanism and can
be done better with actual conditional breakpoints or with systemtap
tracepoints.

https://bugzilla.gnome.org/show_bug.cgi?id=719687
2013-12-03 06:00:47 -05:00
Matthias Clasen
28c2706da7 Drop g_trap_object_ref debugging mechanism
This is really just a very crude and limited conditional breakpoint.
Update the documentation to explain conditional breakpoints in
gdb instead. Also, remove the link to refdbg, which appears dead.

https://bugzilla.gnome.org/show_bug.cgi?id=719687
2013-12-02 21:48:03 -05:00
Matthias Clasen
4c3b009992 Improve GType test coverage
Add a test for g_type_class_get_instance_private_offset
2013-11-28 21:58:48 -05:00
Ryan Lortie
30e1ab3262 tests: move /param/implement to -m slow
Take this test out of 'make check'.  It's causing problems for a lot of people
due to fact that it's essentially a forkbomb.  It's causing failures for Debian
on ARM and it's DoSing coredumps to system crash collectors.

The conditional only covers registration of the master, not the
subprocess parts.  This is because g_test_slow() always return FALSE in
the subprocesses, so they would fail to run if we didn't register them
unconditionally.
2013-11-27 10:17:15 -05:00
Matthias Clasen
e81e33b35d Add a test for g_signal_get_invocation_hint
This is the sole piece of code in GLib where we make use of the
stack growing direction. And this test proves that we have been
getting the direction wrong all these years...
2013-11-23 20:06:07 -05:00
Matthias Clasen
f16045c9cf Add a test for notify emission ordering
This tests the ordering that was just documented.
See

https://bugzilla.gnome.org/show_bug.cgi?id=607016
2013-11-23 16:58:51 -05:00
Matthias Clasen
429010b15c Document details of GObject::notify
The signals queued while notify is frozen are emitted in
reverse order, while omitting duplicates. The lack of documentation
for this was pointed out in

https://bugzilla.gnome.org/show_bug.cgi?id=607016
2013-11-23 16:44:31 -05:00
Gergely POLONKAI
047d9ce6f2 GObject: Introspection annotations for enums
This commit adds a few missing annotations to g_enum and
g_flags functions.

https://bugzilla.gnome.org/show_bug.cgi?id=708274
2013-11-23 13:36:55 -05:00
Dan Winship
158dde0507 Replace #ifdef HAVE_UNISTD_H checks with #ifdef G_OS_UNIX
In Windows development environments that have it, <unistd.h> is mostly
just a wrapper around several other native headers (in particular,
<io.h>, which contains read(), close(), etc, and <process.h>, which
contains getpid()). But given that some Windows dev environments don't
have <unistd.h>, everything that uses those functions on Windows
already needed to include the correct Windows header as well, and so
there is never any point to including <unistd.h> on Windows.

Also, remove some <unistd.h> includes (and a few others) that were
unnecessary even on unix.

https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-11-20 09:25:39 -05:00
Dan Winship
6e4a7fca43 Require C90 compliance
Assume all supported platforms implement C90, and therefore they
(correctly) implement atexit(), memmove(), setlocale(), strerror(),
and vprintf(), and have <float.h> and <limits.h>.

(Also remove the configure check testing that "do ... while (0)" works
correctly; the non-do/while-based version of G_STMT_START and
G_STMT_END was removed years ago, but the check remained. Also, remove
some checks that configure.ac claimed were needed for libcharset, but
aren't actually used.)

Note that removing the g_memmove() function is not an ABI break even
on systems where g_memmove() was previously not a macro, because it
was never marked GLIB_AVAILABLE_IN_ALL or listed in glib.symbols, so
it would have been glib-internal since 2004.

https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-11-20 09:16:16 -05:00
Ray Strode
cfc8215fc1 gobject: Box GMappedFile
GMappedFile is current unintrospectable, because it's not a registered
box type.  It already has reference counting functions, so there's
little reason not to box it.

This commit adds GMappedFile to the hoard of other boxes types handled
by gboxed.c

https://bugzilla.gnome.org/show_bug.cgi?id=712393
2013-11-15 15:56:26 -05:00
Chun-wei Fan
c58a7b8c74 tests: Fix for non-GCC
Remove uses of using empty arrays in initialization and structs, and build
tests that rely on GCCisms on GCC only.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
2013-11-11 22:39:57 +08:00
Stef Walter
5339950e25 threadtests: Fix leaks in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711779
2013-11-11 07:26:04 +01:00
Stef Walter
ac6d35b4df enums: Fix leaks in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711779
2013-11-11 07:25:53 +01:00
Stef Walter
b88f992c6e boxed: Fix double free in boxed unit tests
https://bugzilla.gnome.org/show_bug.cgi?id=711782
2013-11-11 07:20:09 +01:00
Stef Walter
27da0799b8 signals: Fix memory leaks in signals unit tests
https://bugzilla.gnome.org/show_bug.cgi?id=627423
2013-11-06 10:14:57 +01:00
Stef Walter
b49344c1d3 qdata: Fix leak in qdata unit tests
https://bugzilla.gnome.org/show_bug.cgi?id=627423
2013-11-06 10:14:30 +01:00
Chun-wei Fan
e08ef9c367 gobject/gvaluetransform.c: Cleanup #ifndef _MSC_VER
The two casts that were unsupported with Visual Studio is now properly
supported, so build this code like how the other compilers build the code.
2013-10-29 12:46:32 +08:00
Dan Winship
efecfe0fac gobject: simplify object-in-construction handling
Rather than keeping a global list of objects that are being
constructed, use qdata on the object itself like we do with several
other properties now.

https://bugzilla.gnome.org/show_bug.cgi?id=661576
2013-10-22 11:01:15 -04:00
Dan Winship
0d62eb467f gobject: forbid finalization-during-construction
If a constructor() implementation created an object but then unreffed
it rather than returning it, that object would get left on the
construction_objects list, which would cause problems later when that
memory location got reused by another object.

"Fix" this by making it fail intentionally, and add a test for it (and
for the normal, working singleton case).

https://bugzilla.gnome.org/show_bug.cgi?id=661576
2013-10-22 11:01:15 -04:00
Dan Winship
8e17040c15 Fix overloading of "source" and "target" terminology in GBinding
GBindingTransformFunc called its arguments "source_value" and
"target_value", but in the transform_from function of a bidirectional
binding, "source_value" comes from the target object, and
"target_value" comes from the source object, which quickly gets
confusing if you need to use g_binding_get_source(), etc, in the
function.

Of course developers can call their transform function arguments
whatever they want, but many will copy from the headers/docs to start
out, so use less confusing names here ("from_value" and "to_value").

Also, fix the documentation to describe the bidirectional case
correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=709440
2013-10-06 14:24:43 -04:00
Simon Feltman
2f57139b28 Fix crashes in various GParamSpec creation functions
Add NULL check and return after calls to g_param_spec_internal in GParamSpec
creation functions. This avoids glib crashing due to things like badly named
properties.

https://bugzilla.gnome.org/show_bug.cgi?id=707887
2013-10-01 18:31:17 -07:00
Misty De Meo
54e79d7dcb gobject: Fix compilation on OS X/ppc64
Apple's GCC compilers cannot deal well with 64-bit pointers in
transparent unions on ppc64, so compilation of
_G_DEFINE_BOXED_TYPE_BEGIN was failing. Fortunately glib already
provides a fallback for compilers that can't deal with it; this adds
this specific case to the check.

https://bugzilla.gnome.org/show_bug.cgi?id=647145
2013-09-19 08:39:18 -04:00
Martin Pitt
ed1e3816ad gobject-2.0: Annotate another GSignal function taking instances
As a followup to commit a72983a, annotate g_signal_handlers_destroy() as well.
2013-09-02 12:04:43 +02:00
Emmanuele Bassi
a72983a5db gobject-2.0: Annotate GSignal functions taking instances
Unbreak the GSignal API at least for GObject sub-classes.

https://bugzilla.gnome.org/show_bug.cgi?id=685387
2013-09-02 08:25:56 +02:00
Dan Winship
34e1a53795 gtype: fix a no-op assertion
g_type_class_add_private() was doing

    g_assert (node->data->instance.private_size <= 0xffff);

but that field is a guint16, so the check was a no-op. (Noticed by
clang, but not gcc for some reason.) Fix it to do the math in a gssize
variable and do the bounds checking there before updating the struct
field.

https://bugzilla.gnome.org/show_bug.cgi?id=706888
2013-08-27 09:42:14 -04:00
Dieter Verfaillie
9bcb6d3f00 Fix G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE documentation
https://bugzilla.gnome.org/show_bug.cgi?id=706469
2013-08-22 20:52:17 +02:00
Matthias Clasen
0e9f9867fa Start using TAP
Convert {glib,gobject,gio}/tests to use the automake TAP driver
and test harness instead of gtester. To do so, we add a glib-tap.mk
that provides the same interface as glib.mk, except for the
reporting and coverage testing functionality. Eventually, we may
want to replace glib.mk with it. I've not yet converted the
toplevel tests/ directory, since it mixes gtestutils tests with
other binaries.

https://bugzilla.gnome.org/show_bug.cgi?id=692125
2013-08-17 17:25:58 -04:00
Dan Winship
f550c0dc9d update .gitignores 2013-08-17 10:35:13 -04:00
Dan Winship
fd5b1939bd build: fix dtrace-related warnings
Fix the warnings when compiling and linking the probes files by
calling dtrace with all the -W flags removed from CFLAGS (since dtrace
generates bad C code), and with CC set to "libtool --mode=compile ..."
(so that it will output a proper .lo file and libtool won't warn when
linking it into the .la).

https://bugzilla.gnome.org/show_bug.cgi?id=693335
2013-08-17 10:34:32 -04:00
Nick Schermer
4b334ef8f1 gobject: Handle ref_count==0 in notify_by_pspec
Just like g_object_notify, check for a zero ref_count in
g_object_notify_by_pspec and leave if it is 0.

This allows using functions in ->finalize() that possibly also
notify a property change on the object.  Previously,
this resulted in an error from g_object_ref.

https://bugzilla.gnome.org/show_bug.cgi?id=705570
2013-08-14 18:11:05 +01:00
Emanuele Aina
66233f1d1b gtype: Fix typo in g_type_class_add_private() error message
https://bugzilla.gnome.org/show_bug.cgi?id=705398
2013-08-04 08:15:30 +02:00
Sébastien Wilmet
9551a81198 Fix G_ADD_PRIVATE_DYNAMIC() 2013-07-29 17:29:05 +02:00
Matthias Clasen
90da4ed628 Trivial typo fix 2013-07-28 22:06:57 -04:00
Rico Tzschichholz
023e3b31a5 Fix a typo
Introduced by 3b01cbe8a8
2013-07-27 09:02:58 +02:00
Emmanuele Bassi
ca6b93d093 Add macros and symbols for private data on dynamic types
We need a TypeName_private_offset variable defined by the macros used to
register dynamic types. We also need to call the adjust_private_offset()
function inside class_init(). G_ADD_PRIVATE_DYNAMIC only sets the size
of the private data structure, and relies on the behaviour of the
g_type_class_adjuset_private_offset() function to register the private
data structure at class init time if passed a value greater than zero.

This allows using G_PRIVATE_OFFSET with dynamic types.
2013-07-26 20:56:54 -04:00
Matthias Clasen
3b01cbe8a8 Document restrictions on private names
With the new machinery, private structs must be named
TypeNamePrivate if TypeName is the name of the instance
struct.
2013-07-26 14:42:22 -04:00
Colin Walters
d9e01e0c37 tests/closure: Send SIGUSR1 only to our pid
Otherwise in e.g. the gnome-ostree integrationtest system, we
end up sending SIGUSR1 to the *entire session*, which triggers
various badness in untested debugging paths from gnome-session.
2013-07-22 15:14:34 +01:00
Colin Walters
00f5c63621 tests/closure: Use correct prototype for signal callback
This test worked when compiled without optimization, but fails with
-O2.  Presumably we just happened to find the GMainLoop off the stack
somewhere.

https://bugzilla.gnome.org/show_bug.cgi?id=704267
2013-07-22 09:34:24 -04:00
Chun-wei Fan
114b1ccf78 gsourceclosure.c: Fix build on Windows
GPid is a HANDLE (aka void *) on Windows, not an int, so treat pid
accordingly on Windows, as using pid as a gulong directly would likely be
undesirable on Windows

https://bugzilla.gnome.org/show_bug.cgi?id=704447
2013-07-21 20:50:34 +01:00
Dan Winship
88ab63155d gobject/tests/closure: fix on win32
(The g_closure_unref() was wrong, but was not causing errors on linux
for some reason.)

https://bugzilla.gnome.org/show_bug.cgi?id=704447
2013-07-21 20:50:11 +01:00
Colin Walters
35e331b869 tests/closure: Fix invalid unref
The closure is floating, g_source_set_closure() will claim the
ref, so we do not need to unref it.
2013-07-21 19:42:34 +01:00
Sébastien Wilmet
b3968fb150 Improve documentation
- Mention G_SOURCE_CONTINUE and G_SOURCE_REMOVE in the GSourceFunc doc;
- Mention G_PARAM_READWRITE and G_PARAM_STATIC_STRINGS in the
  GParamFlags doc;
- Fix "Since:" version for G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE;
- Fix typo.

https://bugzilla.gnome.org/show_bug.cgi?id=704250
2013-07-20 11:07:46 +02:00
Dan Winship
72a7e824d6 gsourceclosure: fix idle/timeout/signal closures, add child watch support
And add a test for all source types.

https://bugzilla.gnome.org/show_bug.cgi?id=704267
2013-07-17 21:41:45 -04:00
Dan Winship
8a89926532 gsourceclosure: Add support for GUnixSignalWatchSource and GUnixFDSource
https://bugzilla.gnome.org/show_bug.cgi?id=701511
2013-07-13 16:38:55 -04:00
Dan Winship
1da47d5ede gsourceclosure: use g_cclosure_marshal_generic
For the glib-defined source types, and any source type that defines a
closure callback but not a closure marshal, use
g_cclosure_marshal_generic. And then remove all the other remaining
source closure marshals.

https://bugzilla.gnome.org/show_bug.cgi?id=701511
2013-07-13 16:38:55 -04:00
Emmanuele Bassi
a4c352cd99 Ensure that MAX_ALLOWED keeps working with the type macros
When using the GLIB_VERSION_MAX_ALLOWED macro to define the upper bound
of allowed API the G_DEFINE_TYPE_EXTENDED starts warning about the newly
added g_type_class_adjust_private_offset() function; this effectively
introduces a run-time dependency on GLib 2.38 even if we don't use its
API explicitly.

https://bugzilla.gnome.org/show_bug.cgi?id=703191
2013-07-03 09:37:03 -04:00
Emmanuele Bassi
54cc43630d Rename the generated private data getter function
As it turns out, we have examples of internal functions called
type_name_get_private() in the wild (especially among older libraries),
so we need to use a name for the per-instance private data getter
function that hopefully won't conflict with anything.
2013-06-24 15:43:04 +01:00
Emmanuele Bassi
aba80eea6c gparam: Use the new private instance data API
https://bugzilla.gnome.org/show_bug.cgi?id=700035
2013-06-24 14:18:01 +01:00
Emmanuele Bassi
39ba7c8142 gobject: Add private field access macros
Similar to G_STRUCT_MEMBER and G_STRUCT_MEMBER_P, but automatically using
the G_PRIVATE_OFFSET macro.

https://bugzilla.gnome.org/show_bug.cgi?id=700035
2013-06-24 14:18:01 +01:00
Emmanuele Bassi
d91d114a54 Add G_PRIVATE_OFFSET
A macro that evaluates to the offset of a field inside an instance
private data structure.

https://bugzilla.gnome.org/show_bug.cgi?id=700035
2013-06-24 14:18:01 +01:00
Emmanuele Bassi
d3dec6ec80 Allow registering instance private data during get_type()
For static types, it should be possible to register a private data
structure right when we are registering the type, i.e. from the
get_type() implementation. By allowing this, we can take advantage of
the existing type definition macros to cut down the amount of code
necessary (as well as the knowledge baggage) when creating a new type.

The main issue with this new feature is that it cannot be mixed with the
old idiomatic way of adding private instance data by calling a function
in the middle of the class_init() implementation, as that imposes the
additional constraint of initializing the whole type hierarchy in order
to retrieve the offset of the private data in the GTypeInstance
allocation.

For this reason we are going to follow a two-step process; in the first
step, we are going to introduce the new (semi-private) API to register
the intent to add private instance data from within the get_type()
implementation, and hide it behind a macro; at the same time, the
G_DEFINE_TYPE_EXTENDED macro is going to be modified so that it will
register the private instance data if the macro was used, using a new
(semi-private) function as well. Once we have migrated all our code, we
will make the first new function perform the actual private data
registration, and turn the second new function into a no-op. This should
guarantee a transparent migration of existing code to the new idiomatic
form.

https://bugzilla.gnome.org/show_bug.cgi?id=700035
2013-06-24 14:18:01 +01:00
Colin Walters
18702168e1 gobject/tests: Add missing build dependency 2013-06-17 13:05:11 -04:00
Emmanuele Bassi
910732ea7e tests/binding: Ensure that the binding goes away
Use weak pointers so that we can check that the GBinding instance goes
away when it should.

https://bugzilla.gnome.org/show_bug.cgi?id=698018
2013-06-12 11:24:55 +01:00
Emmanuele Bassi
d1959e4faa binding: Use hash table as a set 2013-06-12 11:24:55 +01:00
Emmanuele Bassi
25a3c8720c binding: Make unbind() release the reference on GBinding
The automatic memory management of GBinding is not optimal for high
order languages with garbage collectors semantics. If we leave the
binding instance inert but still referenced it will be leaked, so one
solution that does not throw away the baby of C convenience with the
bathwater of language bindability is to have unbind() perform an
implicit unref().

Hopefully, C developers will read the documentation and especially the
note that says that after calling unbind() the reference count on the
GBinding instance is decreased.

https://bugzilla.gnome.org/show_bug.cgi?id=698018
2013-06-12 11:24:55 +01:00
Ryan Lortie
c1e32a5c59 GObject: turn add-property-after-init to a warning
We have turned up enough cases of this being done (including GTK API
allowing apps to do this to GtkSettings well after it has been
instantiated) that it is clear that we cannot really break this feature
while claiming to be backwards compatible.

For that reason, it becomes a warning rather than a critical (ie: it is
still well-defined behaviour, but you are discouraged from doing it).

The intention is to keep this feature for at least the next while.
A given GObjectClass will be able to avoid using GParamSpec pool for as
long as you don't install properties after init.  If you do that, you
will get a warning and we will devolve to using GParamSpecPool.

https://bugzilla.gnome.org/show_bug.cgi?id=698614
2013-06-10 11:18:06 -04:00
Ryan Lortie
f9eb9eed10 Rework the build system for a new tests approach
Perform a substantial cleanup of the build system with respect to
building and installing testcases.

First, Makefile.decl has been renamed glib.mk and substantially
expanded.  We intend to add more stuff here in the future, like canned
rules for mkenums, marshallers, resources, etc.

By default, tests are no longer compiled as part of 'make'.  They will
be built when 'make check' is run.  The old behaviour can be obtained
with --enable-always-build-tests.

--disable-modular-tests is gone (because tests are no longer built by
default).  There is no longer any way to cause 'make check' to be a
no-op, but that's not very useful anyway.

A new glibtests.m4 file is introduced.  Along with glib.mk, this
provides for consistent handling of --enable-installed-tests and
--enable-always-build-tests (mentioned above).

Port our various test-installing Makefiles to the new framework.

This patch substantially improves the situation in the toplevel tests/
directory.  Things are now somewhat under control there.  There were
some tests being built that weren't even being run and we run those now.
The long-running GObject performance tests in this directory have been
removed from 'make check' because they take too long.

As an experiment, 'make check' now runs the testcases on win32 builds,
by default.  We can't run them under gtester (since it uses a pipe to
communicate with the subprocess) so just toss them in TESTS.  Most of
them are passing on win32.

Things are not quite done here, but this patch is already a substantial
improvement.  More to come.
2013-05-31 23:12:15 -04:00
Ryan Lortie
a8a9afe17c GObject: prevent installing properties after init
GObject has previously allowed installing properties after class_init
has finished running.  This means that you could install some of your
own properties on G_TYPE_OBJECT, for example, although they wouldn't
have worked properly.

A previous patch asserted that this was not true and we had to revert it
because it broke the shell.  Instead of reverting, we should have used a
critical, so do that now.

Complaints go to this bug:

https://bugzilla.gnome.org/show_bug.cgi?id=698614
2013-05-29 09:25:25 -04:00
Ryan Lortie
da478acd3c Remove G_TEST_DATA= from installed .test files
This is no longer needed with the new test data file finding stuff.

https://bugzilla.gnome.org/show_bug.cgi?id=549783
2013-05-29 09:03:32 -04:00
Matthias Clasen
2afd39a90d Trivial doc typo fix 2013-05-29 08:38:03 -04:00
Matthias Clasen
2349635ebe Trivial documentation typos 2013-05-29 08:37:57 -04:00
Matthias Clasen
07168724d7 Improve signal test coverage 2013-05-29 08:37:19 -04:00
Matthias Clasen
a9abbb3192 Improve test coverage in gobject/
Lines:          6631    8862    74.8 %
Functions:      747     893     83.7 %
2013-05-29 08:37:08 -04:00
Colin Walters
0b167b0ae9 build: Fix usage of %.test again
We actually need the first dependency because it includes the
final executable name.  Rather, fix the original bug by using
the variable $(EXEEXT).
2013-05-24 22:16:44 +01:00
Colin Walters
5088c705ac tests: Drop unnecessary % from .test pattern match rule
On Windows, the executables will have .exe, so this won't
match.  Furthermore, they aren't actually dependent on the
executable to build.
2013-05-24 16:30:21 -04:00
Ryan Lortie
3d1d49177b gsignal: remove some pointless locking
We previously hold a lock in the loop that collects the arguments for
g_signal_emit(), which we drop before calling into the argument
collection functions and reacquire again at the bottom of the loop (ie:
one release/acquire pair for each argument collected).  To make matters
worse, the lock is just released again after the loop.

Presumably that was done to protect the access to the parameter array,
but it's pretty unlikely that this is needed because the only way it
changes is if the signal is unloaded.  That only happens when unloading
types which is quite unlikely to happen while we are emitting on an
instance of that type (and, as an aside, never happens anymore anyway).

If we move the unlock below the loop up above it and remove the
acquire/release pair from the loop, we improve performance in the new
arg-collecting performance tests by ~15% (more like ~18% in the case
where we only emit to one handler -- where argument collection dominates
more).

https://bugzilla.gnome.org/show_bug.cgi?id=694380
2013-05-23 21:50:54 -04:00
Dan Winship
4b94c0831e Use 'dumb quotes' rather than `really dumb quotes'
Back in the far-off twentieth century, it was normal on unix
workstations for U+0060 GRAVE ACCENT to be drawn as "‛" and for U+0027
APOSTROPHE to be drawn as "’". This led to the convention of using
them as poor-man's ‛smart quotes’ in ASCII-only text.

However, "'" is now universally drawn as a vertical line, and "`" at a
45-degree angle, making them an `odd couple' when used together.

Unfortunately, there are lots of very old strings in glib, and also
lots of new strings in which people have kept up the old tradition,
perhaps entirely unaware that it used to not look stupid.

Fix this by just using 'dumb quotes' everywhere.

https://bugzilla.gnome.org/show_bug.cgi?id=700746
2013-05-21 11:23:22 -03:00
Matthias Clasen
f66016261a Make gobject tests installable
This makes the gobject tests run as part of the ostree integration
tests.
2013-05-19 21:49:51 -04:00
Dan Winship
e3d1869ee3 tests: port from g_test_trap_subprocess() to g_test_trap_fork()
https://bugzilla.gnome.org/show_bug.cgi?id=679683
2013-05-13 12:10:52 -04:00
Matthias Clasen
6fe6b0300b Clarify GValueArray docs
Don't refer to Quicksort in the documentation of
g_value_array_sort, but just to qsort().
2013-05-09 16:04:54 -04:00
Emmanuele Bassi
a360b314aa binding: Add an explicit unbind()
Higher order languages with garbage collection can have issues releasing
a binding, as they do not control the last reference being dropped on
the binding, source, or target instances.

https://bugzilla.gnome.org/show_bug.cgi?id=698018
2013-05-02 15:50:21 -07:00
Dan Winship
c0e0c6a420 gobject: rename an unused parameter to make AIX happy 2013-05-02 13:58:25 -04:00
Ryan Lortie
7d61da0c07 g_object_new: check for NULL from _constructor()
There is some code in the wild (like in gnome-session) that does this
from its custom _constructor() implementation:

{
  GObject *obj;

  obj = ((chain up));

  if (!object_is_viable (obj))
    {
      g_object_unref (obj);
      return NULL;
    }
  else
    return obj;
}

This has never been a valid use of GObject and this code has always
caused memory to be leaked[1] by growing the construction_objects list.
The ability to legitimately return NULL from a constructor was exactly
the reason that we created GInitable, in fact.

That doesn't change the fact that the g_object_new() rewrite will crash
in this case, so instead of doing that, let's emit a critical and avoid
the crash.  This will allow people to upgrade their GLib without also
upgrading their gnome-session.  Meanwhile, people can fix their broken
code.

[1] not in the strictest sense of the word, because it's still reachable
2013-04-26 11:34:27 -04:00
Ryan Lortie
bfa8bef7b9 GObject: substantially rework g_object_new()
Make a number of improvements to g_object_new():

 - instead of looking up the GParamSpec for the named property once in
   g_object_new() (in order to collect) and then again in g_object_newv
   (when actually setting the property), g_object_new_internal() is a
   new function that takes the GParamSpec on the interface to avoid the
   second lookup

 - in the case that ->constructor() is not set, we need not waste time
   creating an array of GObjectConstructParam to pass in.  Just directly
   iterate the list of parameters, calling set_property() on each.

 - instead of playing with linked lists to keep track of the construct
   properties, realise that the number of construct properties that we
   will set is exactly equal to the length of the construct_properties
   list on GObjectClass and the only thing that may change is where the
   value comes from (in the case that it was passed in)

   This assumption was already implicit in the existing code and can be
   seen from the sizing of the array used to hold the construct
   properties, but it wasn't taken advantage of to make things simpler.

 - instead of allocating and filling a separate array of the
   non-construct properties just re-iterate the passed-in list and set
   all properties that were not marked G_PARAM_CONSTRUCT (since the ones
   that were construct params were already used during construction)

 - use the new g_param_spec_get_default_value() API instead of
   allocating and setting the GValue for each construct property that
   wasn't passed from the user

Because we are now iterating the linked list of properties in-order we
need to append to that list during class initialising instead of
prepending.

These changes show a very small improvement on the simple-construction
performance testcase (probably just noise) and they improve the
complex-construction case by ~30%.

Thanks to Alex Larsson for reviews and fixes.

https://bugzilla.gnome.org/show_bug.cgi?id=698056
2013-04-23 14:39:09 -04:00
Ryan Lortie
c18462b580 GParamSpec: add g_param_spec_get_default_value()
The way of getting the default value out of a GParamSpec is to allocate
a GValue, initialise it, then call g_param_spec_set_default() to set the
default value into that GValue.

This is exactly how we handle setting the default value for all of the
construct properties that were not explicitly passed to g_object_new().

Instead of doing the alloc/init/store on all construct properties on
every call to g_object_new(), we can cache those GValues in the private
data of the GParamSpec itself and reuse them.

This patch does not actually make that change to g_object_new() yet, but
it adds the API to GParamSpec so that a future patch to GObject can make
the change.

https://bugzilla.gnome.org/show_bug.cgi?id=698056
2013-04-23 14:39:09 -04:00
Ryan Lortie
c30c0bb34d GType: add accessor for instance private offset
Since instance private data is now always at a constant offset to the
instance pointer, we can add an accessor for it that doesn't also
require an instance.

The idea is that classes can call this from their class_init and store
it in a file-scoped static variable and use that to find their private
data on instances very quickly, without a priv pointer.

https://bugzilla.gnome.org/show_bug.cgi?id=698056
2013-04-23 14:39:09 -04:00
Ryan Lortie
7409ac0d14 gtype: tweak valgrind hints
The valgrind client requests were not producing the intended result in
some cases, so step up our game a bit.
2013-04-23 12:01:17 -04:00
Ryan Lortie
e8438f98e2 Revert "GObject: prevent installing properties after init"
This reverts commit ddb0ce1421.

Colin's smoke testing has found issues in at least gjs and
gnome-settings-daemon.  We'll need to see if we can address those.
2013-04-22 18:32:49 -04:00
Ryan Lortie
ddb0ce1421 GObject: prevent installing properties after init
GObject has previously allowed installing properties after class_init
has finished running.  This means that you could install some of your
own properties on G_TYPE_OBJECT, for example, although they wouldn't
have worked properly.

Prevent this from happening.  Require that all properties are installed by
the time class_init has finished.

Complaints go to this bug:

https://bugzilla.gnome.org/show_bug.cgi?id=698614
2013-04-22 17:40:51 -04:00
Ryan Lortie
31fde567a9 gtype: put private data before the instance
Classically, a GTypeInstance has had the following layout:

 [[[[GTypeInstance] GObject] TypeA] TypeB] [TypeAPrivate] [TypeBPrivate]

where TypeB is a subclass of TypeA which is a GObject.  Both TypeA and
TypeB use pivate data.

The main problem with this approach is that the offset between a pointer
to an instance of TypeA and the TypeAPrivate is not constant: it changes
depending on the depth of derivation and the size of the instance
structures of the derived types.  For example, changing the size of the
TypeB structure in the above example would push the TypeAPrivate further
along.

This complicates the implementation of g_type_instance_get_private().
In particular, during object construction when the class pointer to the
'complete type' of the object is not yet stored in the header of the
GTypeInstance, we need a lookup table in order to be able to implement
g_type_instance_get_private() accurately.

We can avoid this problem by storing the private data before the
structures, in reverse order, like so:

  [TypeBPrivate] [TypeAPrivate] [[[[GTypeInstance] GObject] TypeA] TypeB]

Now the distance between TypeA and TypeAPrivate depends only on the size
of GObject and GTypeInstance, which are static.  Even in the case of
TypeB, the distance is not statically known but can be determined at
runtime and is constant (because we will know the size of TypeAPrivate
by the time we initialise TypeB and it won't change).

This approach requires a slighty dirty trick: allocating extra memory
_before_ the pointer we return from g_type_create_instance().  The main
problem with this is that it will cause valgrind to behave very badly,
reporting almost everything as "possibly lost".

We can correct for this by including a few valgrind client requests in
order to inform it that the start of the GTypeInstance should be
considered a block of memory and that pointers to it should mean that
this block is reachable.  In order to make the private data reachable,
we also declare it as a block and include an extra pointer from the end
of the primary block pointing back at it.  All of this is only done if
we are running under Valgrind.

https://bugzilla.gnome.org/show_bug.cgi?id=698595
2013-04-22 16:16:23 -04:00
Ryan Lortie
96f7e6d70b gtype: interface-after-init exception for gtk#
gtk# also has a problem with the new interface-after-init restriction
that nobody noticed until now.  Add an exception for them as well so
that they have a cycle or so to sort things out.

https://bugzilla.gnome.org/show_bug.cgi?id=687659
2013-04-04 11:41:19 -04:00
Ryan Lortie
c5307e4cba gtype: interface-after-init exception for glibmm
glibmm has a pretty difficult-to-solve problem caused by our recent
change to deny addition of interfaces to classes after initialisation.

They're looking for a long-term workaround for the problem, but in the
meantime we can allow the registration to succeed (with warning) if the
class looks like it's being defined by gtkmm.

https://bugzilla.gnome.org/show_bug.cgi?id=697229
2013-04-04 11:10:17 -04:00
Andres G. Aragoneses
859e4239c5 gobject: fix G_DEFINE_TYPE_EXTENDED docs so code snippet actually compiles
Flags being used in the G_DEFINE_TYPE_EXTENDED sample was "0", so it
should expand to 0 as well, otherwise the compiler would bark with:
maman-bar.c: In function ‘maman_bar_get_type’:
maman-bar.c:36:53: error: ‘flags’ undeclared (first use in this function)
maman-bar.c:36:53: note: each undeclared identifier is reported only once for each function it appears in

https://bugzilla.gnome.org/show_bug.cgi?id=697250
2013-04-04 12:11:06 +01:00
Sébastien Wilmet
e3c2d03092 Doc: clarify set_property() vfunc
Implementations "don't need to ...". It was not clear what happen
if they do it all the same.

https://bugzilla.gnome.org/show_bug.cgi?id=695887
2013-03-15 09:07:30 +01:00
Sébastien Wilmet
e569079414 Doc: clarify a bit g_signal_connect_object()
"the object" can be a bit confusing for a beginner, he can think it is
the @instance.

https://bugzilla.gnome.org/show_bug.cgi?id=695887
2013-03-15 09:07:29 +01:00
Colin Walters
156b14cde5 build: Add --disable-compile-warnings
Some (broken) toolchains for example trip up
-Werror=missing-prototypes in system headers.  This patch allows
people to skip the formerly hardcoded "baseline" warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=694757
2013-02-27 08:34:01 -05:00
Ryan Lortie
f5d40bd813 gsignal: improve warning output
When looking up signals by name (to connect, for example) and the named
signal cannot be found on the given instance, report the type of the
instance.

This is quite a lot more useful as a diagnostic message than only a
memory address.

https://bugzilla.gnome.org/show_bug.cgi?id=694350
2013-02-22 00:54:50 +00:00
Alexander Larsson
aede774642 signals: Ensure we ref handler in emission fast path
We need to keep a reference to the handler in the fast path, just like
in the slow path, otherwise if another thread disconnects the handler
we may destroy the closure while we're using it without the lock held.

We also move the freeing of the instance to after the emission is totally
done as the handler_unref_R (and the tracepoint) reference it.

https://bugzilla.gnome.org/show_bug.cgi?id=694253
2013-02-21 16:54:44 +01:00
Alexander Larsson
3e274423ba signals: No need to use atomics for Handler refcount
handler_ref and handler_unref_R are always called with the signal
lock held. This is obvious for handler_unref_R as it even sometimes
drops this lock, and can be verified quickly for handler_ref by looking
at all call sites.

This improves the performace about 6% on the emit-handled and the
emit-handled-generic tests.

https://bugzilla.gnome.org/show_bug.cgi?id=694253
2013-02-21 16:54:44 +01:00
Ryan Lortie
72df62600d disable support for unloading of dynamic types
Experimentally disable the ability to unload dynamic types by refusing
to drop the last reference on types (effectively turning the type
unloading into dead code).

The plan is to leave things like this for a stable cycle and only
proceed with removing the code if we are sure that there are no
unforeseen problems.

https://bugzilla.gnome.org/show_bug.cgi?id=693351
2013-02-07 14:15:45 -05:00
Matthias Clasen
ab328469f5 Silence automake
automake doesn't like INCLUDES anymore.
2013-02-02 22:54:15 -05:00
Giovanni Campagna
1ce415b45b Install an invalidation notifier for GClosure in g_source_set_closure()
The point of g_source_set_closure() is getting memory management right,
including handling closures disappearing from the outside (for example
because a runtime they refer to is being shutdown). This means that
sources with an associated closure should remove themselves from the
main loop and free memory when the closure is invalidated.

https://bugzilla.gnome.org/show_bug.cgi?id=692034
2013-01-20 16:23:32 +01:00
Ryan Lortie
00ee6de4e2 gobject/: Remove abicheck.sh from DIST_EXTRA 2013-01-18 14:33:16 -05:00
Ryan Lortie
dbf447292d Remove ABI checking scripts
Before this commit, the only difference between the expected and actual
ABI were the addition of _init and _fini symbols in each module (now
that regexp-based export control is not catching those).
2013-01-17 10:50:18 -05:00
Ryan Lortie
304950a7ac Remove regexp-based export control 2013-01-17 10:49:37 -05:00
Ryan Lortie
d89fb7bf10 gsignal: fix closure invalidation code
This is the bug that has been causing segfaults and criticals when accel
keys are used to close windows via GtkUIManager.

The main cause of this problem was a mistake made in the original patch
when modifying the handler_lookup() to take the extra 'closure'
parameter.  The original check used was:

    if (handler->sequential_number == handler_id ||
       (closure && handler->closure == closure))

It was called to find a particular closure like so:

    handler_lookup (instance, 0, closure, &signal_id);

The problem is that the check will return if either the signal ID or
closure matches (if a closure was given).  The calling code assumes 0 to
be an invalid signal ID which will match no handlers, but unfortunately
the rest of gsignal code uses this to denote a signal that has already
been disconnected.  The result is that this function was searching for a
matching closure _or_ the first already-disconnected handler.  When it
found the already-disconnected handler, we'd get criticals and crashes.

The condition has been corrected; it now ignores the handler_id
parameter if the closure parameter is non-NULL.

While we're in here, change the lifecycle of the invalidation notify to
be easier to understand.

Before, the notify was removed when the last reference on the handler
dropped.  This could happen in very many situations; often at the end of
an emission.  Instead, we now tie the registration of the notifier to
the lifecycle of the signal connection.  When the signal is disconnected
we remove the notification, even if other references are held (eg:
because it is currently being dispatched).

https://bugzilla.gnome.org/show_bug.cgi?id=690118
2013-01-16 23:04:11 -05:00
Chun-wei Fan
38229d47d1 Revert "Improvde #include order consistency"
This reverts commit f2e00a07f4.

Moving the block up would prevent G_OS_WIN32 being checked correctly as
it is a macro that is defined by including the GLib header(s), at least for
Visual C++ builds.

https://bugzilla.gnome.org/show_bug.cgi?id=691769
2013-01-15 19:35:52 +08:00
Ryan Lortie
5d42fdd068 visibility: Use a separate CFLAGS variable
We only want to control the default visibility for our five main
installable libraries: libglib, libgthread, libgmodule, libgobject,
libgio.  We should therefore only set -fvisibility=hidden when building
those.

Use a separate substitution variable for this purpose.

Using CFLAGS directly leads to some modules built in testcases not
exporting their symbols (and then the tests fail).  It also affects the
fam file monitoring module.

Colin had originally done it this way in his visibility patch series but
I failed to understand why so I didn't copy it.  Now I do.

Also: revert changes made to two testcases in an attempt to work around
this issue.

https://bugzilla.gnome.org/show_bug.cgi?id=691756
2013-01-14 23:31:59 -05:00
Matthias Clasen
57041baf58 Make the build more quiet 2013-01-14 16:14:28 -05:00
Martin Pitt
aac8267233 GParamSpec: Make constructors introspectable
Commit 282366c326 unnecessarily (skip)ed all the GParamSpec constructors like
g_param_spec_bool(). Make those introspectable by dropping the (skip) and
adding proper transfer annotations.

Keep g_param_spec_value_array() skipped as GValueArray is deprecated.
2013-01-14 11:36:14 +01:00
Ryan Lortie
068a119f74 win32: build: stop using .def files
With visibility now under the control of __declspec(dllexport) we no
longer need to build .def files or use them for building our various
.dll files.

.def files used to be installed (even though it is only really useful
when creating the .dll or .lib file).  Don't do that anymore either.

The Makefiles still contain rules to create a .lib file for use with
Visual Studio and these rules require .def files.  There are special
requirements to using these rules (like having installed and setup
Microsoft tools for use during the build) and therefore the problem of
creating a .def file for use with them is left open to anyone willing to
make the effort.  Many options are available depending on which
toolchain is in use (dlltool, pexport, gendef, dumpbin.exe, just to name
a few).

If we can find a free tool for creating .lib files in the future, we
should probably revisit this issue and add proper support back to our
build system.
2013-01-13 22:59:40 -05:00
Ryan Lortie
3bd09b5fa6 gmarshal.h: replace "extern" with GLIB_AVAILABLE_IN_ALL
This was one of the few public header files that was properly declaring
functions as "extern".  Switch it to use GLIB_AVAILABLE_IN_ALL instead.

https://bugzilla.gnome.org/show_bug.cgi?id=688681
2013-01-13 13:13:55 -05:00
Ryan Lortie
b91c476827 Add a new _GLIB_EXTERN macro for "extern"
This macro simply evaluates the "extern" unless it has been explicitly
defined to something else.

All of the version macros (including the unversioned deprecation markers
and GLIB_AVAILABLE_IN_ALL) now include _GLIB_EXTERN as part of their
definition.

G_INLINE has also been modified to use _GLIB_EXTERN where appropriate.

This macro should never be used outside of the gmacros.h/gversonmacros.h
headers.

The effect of this patch is that "extern" has now been added to all
functions declared in installed headers.  Strictly speaking, this is
something we should have had all along...

GLIB_VAR and GOBJECT_VAR have also been modified to use _GLIB_EXTERN on
non-Windows, instead of "extern" which they were using before.  The
eventual goal is to use the normal version/deprecation macros on
exported variables and drop GLIB_VAR but we need to see how this will
work on Windows before we go ahead with that.

https://bugzilla.gnome.org/show_bug.cgi?id=688681
2013-01-13 13:13:36 -05:00
Ryan Lortie
0156092a42 various: add GLIB_AVAILABLE_IN_ALL everywhere else
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
2013-01-13 13:11:57 -05:00
Ryan Lortie
c2055f22f4 gtype: disallow adding interfaces after the fact
Add a check to prevent adding an interface to a class that has already
had its class_init done.

This is an incompatible change but it is suspected that there are not
many users of this functionality.  Two known exceptions are pygobject
(fixed in bug 686149) and our own testsuite (affected tests have been
temporarily disabled by this patch).

Once we confirm that nobody else is using this functionality we can
remove a rather large amount of code for dealing with this case.

https://bugzilla.gnome.org/show_bug.cgi?id=687659
2013-01-04 21:20:04 +01:00
Rico Tzschichholz
efa7b5f1e7 Revert "gtype: disallow adding interfaces after the fact"
This reverts commit d6a075b0d8.
2013-01-04 20:25:46 +01:00
Dan Winship
03e84f936f GValueArray: clarify the deprecation warnings
GValueArray as a whole is deprecated in favor of GArray (with GValue
elements); warnings like "'g_value_array_get_nth' is deprecated: Use
'g_array_index' instead" are confusing because they suggest that the
GArray functions can be used with GValueArrays. Make them say "Use
'GArray' instead" instead.

https://bugzilla.gnome.org/show_bug.cgi?id=690970
2013-01-02 13:02:51 -05:00
Matthias Clasen
86610b0594 Move testgobject to tests/
And fix it to actually check the right things.
2013-01-01 14:06:20 -05:00
Matthias Clasen
f2e00a07f4 Improvde #include order consistency
This was mostly fixed already, just re-fix a few details here.
https://bugzilla.gnome.org/show_bug.cgi?id=71704
2013-01-01 13:54:54 -05:00
Jasper St. Pierre
5e62827efd gmarkup: Make GMarkupParseContext a boxed type
At the same time, add a refcount and public ref/unref methods.
This makes it usable from introspectable.

https://bugzilla.gnome.org/show_bug.cgi?id=690084
2013-01-01 11:03:19 -05:00
Matthias Clasen
e1b99b2ddc Move single-include guards inside include guards
gcc has optimizations for include guards that only work
if they are outermost in the the header.
https://bugzilla.gnome.org/show_bug.cgi?id=689810
2012-12-27 23:43:14 -05:00
Matthias Clasen
0178402c6d Revert "tests: port from g_test_trap_subprocess() to g_test_trap_fork()"
This reverts commit ea06ec8063.
2012-12-19 15:20:37 -05:00
Dan Winship
ea06ec8063 tests: port from g_test_trap_subprocess() to g_test_trap_fork()
(or, in a few cases, to g_test_expect_message())

https://bugzilla.gnome.org/show_bug.cgi?id=679683
2012-12-19 14:35:10 -05:00
Ryan Lortie
5df1edaf70 gtype: disallow adding interfaces after the fact
Add a check to prevent adding an interface to a class that has already
had its class_init done.

This is an incompatible change but it is suspected that there are not
many users of this functionality.  Two known exceptions are pygobject
(fixed in bug 686149) and our own testsuite (affected tests have been
temporarily disabled by this patch).

Once we confirm that nobody else is using this functionality we can
remove a rather large amount of code for dealing with this case.

https://bugzilla.gnome.org/show_bug.cgi?id=687659
2012-12-18 21:37:07 +01:00
Rico Tzschichholz
d1ab41c940 Revert "gtype: disallow adding interfaces after the fact"
This reverts commit d6a075b0d8.
2012-12-18 21:23:13 +01:00
Christophe Fergeau
b055c82815 Fix g_type_add_class_private() name in g_warning
When g_type_class_get_private is called without calling
g_type_add_class_private first, a g_warning is issued, but
the name of the function to call is wrong:
g_type_class_add_class_private.

https://bugzilla.gnome.org/show_bug.cgi?id=690348
2012-12-17 15:51:07 +01:00
Colin Walters
5baa26be72 gobject.symbols: Update for g_checksum_get_type()
See previous commit.
2012-12-10 20:30:44 -05:00
Colin Walters
bf1e63c2aa Make GChecksum more fully introspectable
In 2.34, g_compute_checksum_for_bytes() was added, but this patch
allows binding users to use the incremental update API; this is
significantly more efficient than reading entire files into memory.

https://bugzilla.gnome.org/show_bug.cgi?id=689982
2012-12-10 20:08:09 -05:00
Alexander Larsson
e218b96a6b Add g_type_get_type_registration_serial()
This lets you cache type lookup information and then know when
the cache information is out of date. In particular, we want this
in order to be able to cache g_type_from_name() lookups in the Gtk+
theme machinery.

https://bugzilla.gnome.org/show_bug.cgi?id=689847
2012-12-10 12:55:28 +01:00
Colin Walters
33de093b5a gobject: Use local variable names in macros less likely to clash
At least GDBus had code that had "_object" as a parameter to one of
its functions, but this clashes with the GObject macro
G_OBJECT_WARN_INVALID_PROPERTY_ID() which created a local "_object".

Since many of us cargo cult around copies of objects, let's be
defensive here and use local variable names less likely to clash with
application code.

https://bugzilla.gnome.org/show_bug.cgi?id=689377
2012-12-05 13:30:14 -05:00
Ryan Lortie
37f369a41e stop using libgthread internally
The gobject tools (glib-genmarshal and gobject-query) were linking
against libgthread.  Stop that.

Also, remove the gthread_INCLUDES internal automake substitution.
2012-11-25 14:51:04 -05:00
Kjell Ahlstedt
269f890474 GObject: Fix code snippet in description of floating reference.
https://bugzilla.gnome.org/show_bug.cgi?id=688180
2012-11-21 18:09:46 -05:00
Sebastian Dröge
46a92a760b Add boxed GType for GThread
https://bugzilla.gnome.org/show_bug.cgi?id=688704
2012-11-20 15:03:06 +01:00
Ryan Lortie
5272bc4d67 Revert "[gobject] set all properties before constructed()"
This reverts commit 028d4a03f2.

I thought that we would be able to get away with this incompatible
change but it appears to impact far too much existing code.  The only
thing we can do is revert.

https://bugzilla.gnome.org/show_bug.cgi?id=688596
2012-11-19 10:30:47 -05:00
Paul Menzel
834e6e96b3 docs: Fix spelling of "exceed" in gobject/gtype.c
https://bugzilla.gnome.org/show_bug.cgi?id=688338
2012-11-16 08:44:23 +00:00
Ryan Lortie
d6a075b0d8 gtype: disallow adding interfaces after the fact
Add a check to prevent adding an interface to a class that has already
had its class_init done.

This is an incompatible change but it is suspected that there are not
many users of this functionality.  Two known exceptions are pygobject
(fixed in bug 686149) and our own testsuite (affected tests have been
temporarily disabled by this patch).

Once we confirm that nobody else is using this functionality we can
remove a rather large amount of code for dealing with this case.

https://bugzilla.gnome.org/show_bug.cgi?id=687659
2012-11-05 13:20:28 -05:00
Martin Pitt
1af1b2b2bb Box GPollFD to make it introspectable
https://bugzilla.gnome.org/show_bug.cgi?id=686797
2012-11-05 14:41:31 +01:00
Simon Feltman
8e92798612 Add array length annotation to GSignalQuery param_types field
https://bugzilla.gnome.org/show_bug.cgi?id=687541
2012-11-04 13:51:15 +01:00
Colin Walters
8e59d8602c Use (void) for no parameters, not ()
This ensures we build with -Werror=missing-parameter-type.

https://bugzilla.gnome.org/show_bug.cgi?id=687385
2012-11-01 20:12:02 -04:00
Colin Walters
84475e4320 build: Prototype GType accessors for private classes
Otherwise we fail to build with -Werror=missing-prototypes.

https://bugzilla.gnome.org/show_bug.cgi?id=687385
2012-11-01 20:12:02 -04:00
Colin Walters
f6da43f56c build: Ensure we #include header files for glib-genmarshal code
Otherwise we fail with -Werror=missing-prototypes.

https://bugzilla.gnome.org/show_bug.cgi?id=687385
2012-11-01 20:12:01 -04:00
Colin Walters
4447d5ce11 tests/signals: Disable large enumeration value test that is failing on PPC64
Basically due to a combination of va_args semantics around
signed/unsigned ints, this test case fails on ppc64.  At the moment,
we have as yet to find any real-world consumer with such a large
enumeration value.

Unfortunately, the possible fixes for this are extremely invasive;
we would have to define a new enum API.

Given both of these facts, we believe it makes the most sense at the
current time to simply not test this. If we at a later time determine
there is such a real-world consumer, we can look at doing the
necessary fixes.

https://bugzilla.gnome.org/show_bug.cgi?id=686662
2012-10-31 17:45:21 -04:00
Martin Pitt
a5c5730085 Revert "Box GPollFD to make it introspectable"
This reverts commit 932f4250b8.

This got pushed accidentally and has not been accepted yet. It's also not clear
whether we want this in the first place.

https://bugzilla.gnome.org/show_bug.cgi?id=686797
2012-10-25 11:27:39 +02:00
Martin Pitt
932f4250b8 Box GPollFD to make it introspectable
https://bugzilla.gnome.org/show_bug.cgi?id=686797
2012-10-25 07:58:09 +02:00
Ryan Lortie
df02fa1e4c Properly deprecate g_type_init()
Now that all internal users of it are gone.

https://bugzilla.gnome.org/show_bug.cgi?id=686161
2012-10-16 09:39:24 -04:00
Ryan Lortie
1dc774a653 Remove g_type_init() calls
Very many testcases, some GLib tools (resource compiler, etc) and
GApplication were calling g_type_init().

Remove those uses, as they are no longer required.

https://bugzilla.gnome.org/show_bug.cgi?id=686161
2012-10-16 09:39:24 -04:00
Ryan Lortie
7c42ab23b5 Convert g_type_init() to a ctor
Move the guts of g_type_init() into a ctor and turn g_type_init() itself
into a do-nothing function.

g_type_init_with_debug_flags() now ignores its arguments, but it has
always been possible to achieve the same effect via environment
variables.

https://bugzilla.gnome.org/show_bug.cgi?id=686161
2012-10-16 09:39:24 -04:00
Matthias Clasen
691c0b053e Add missing semicolons to gobject_probes.d
Pointed out in
https://bugzilla.gnome.org/show_bug.cgi?id=686119
2012-10-15 19:48:44 -04:00
Ryan Lortie
a36028f386 gsignal: really fix closure invalidation
Commit 66b0d95f0b missed this part of the
patch.
2012-10-13 12:16:32 -04:00
Ryan Lortie
66b0d95f0b [gsignal] Fix closure invalidation
If the closure is invalidated we drop the ref on the signal handler
node, but if the signal is currently being dispatched, the ref could be
held elsewhere.

Flag that we no longer have an outstanding invalidation handler so that
we don't try to unregister ourselves when the other ref drops.

Add a testcase that catches this situation.
2012-10-09 11:40:45 -04:00
Ryan Lortie
028d4a03f2 [gobject] set all properties before constructed()
Move the constructed() call to happen after all of the properties are
set (not just the construct properties).

This is an incompatible change but we are making it under the belief
that it should be safe.  If this change impacts you in a negative way
please comment on the bug.

https://bugzilla.gnome.org/show_bug.cgi?id=685733
2012-10-08 11:40:00 -04:00
Ryan Lortie
8fd75705f4 fix g_signal_connect_object() documentation
g_signal_connect_object() now works properly, so we can remove the note
in the docs about it being broken.

https://bugzilla.gnome.org/show_bug.cgi?id=118536
2012-10-08 11:22:04 -04:00
Ryan Lortie
c15769d304 [gsignal] fix up a crasher in previous commit
The previous commit introduced a new variable in the Handler struct but
didn't initialise it.  This was causing some tests to crash.

https://bugzilla.gnome.org/show_bug.cgi?id=118536
2012-10-08 11:21:58 -04:00
Matthias Clasen
d03d26feab [gsignal] disconnect invalidated closures
Modify gsignal to automatically disconnect a GClosure that becomes
invalid (in the g_closure_invalidate() sense).

Previously, when g_signal_connect_object() was used with a GObject as
the user_data and that object was destroyed, the handler would no longer
be called but the signal handler was itself was not disconnected (ie:
the bookkeeping data was kept around).

The main effect of this patch is that these signal handlers will now
be automatically disconnected (and fully freed).

The documentation for g_signal_connect_object() has anticipated this
change for over 10 years and has advised the following workaround when
disconnecting signal handlers connected with g_signal_connect_object():

 if (g_signal_handler_is_connected (instance, id))
   g_signal_handler_disconnect (instance, id);

If your code follows this practice then it will continue to work.

If your code never disconnects the signal handler then it was wasting
memory before (and this commit fixes that).

If your code unconditionally disconnects the signal handler then you
will start to see (harmless) g_critical() warnings about this and you
should fix them.

https://bugzilla.gnome.org/show_bug.cgi?id=118536
2012-10-08 11:21:48 -04:00
Matthias Clasen
26ecc52073 Clarify g_type_init docs
Mention that there's no way to undo it.
https://bugzilla.gnome.org/show_bug.cgi?id=654239
2012-09-23 11:13:57 -04:00
Martin Pitt
02f143c2d9 Box GTimeZone to make it introspectable
https://bugzilla.gnome.org/show_bug.cgi?id=683167
2012-09-06 06:18:42 +02:00
Dan Winship
4d1b0d46db update .gitignore 2012-09-03 08:56:10 -04:00
Dan Winship
03be681e08 gobject/tests: plug leaks
https://bugzilla.gnome.org/show_bug.cgi?id=682560
2012-09-03 08:36:10 -04:00
Dan Winship
e0cba35d41 gobject/tests: use g_test_expect_messages()
https://bugzilla.gnome.org/show_bug.cgi?id=682560
2012-09-03 08:36:10 -04:00
Matthias Clasen
a30f6a6eb8 Add new api to symbol lists and docs
https://bugzilla.gnome.org/show_bug.cgi?id=682849
2012-09-02 15:10:20 -04:00
Matthias Clasen
d80d70458a Add a threaded test for g_object_replace_data
This is the threaded atomic add test from glib/tests/atomic.c,
redone using qdata instead of an atomic int to store the values.
2012-09-02 15:10:20 -04:00
Matthias Clasen
2fa77fb76c Add some tests for new object data api
These are non-threaded, but the do test dup and destroy somewhat.

https://bugzilla.gnome.org/show_bug.cgi?id=682849
2012-09-02 15:09:13 -04:00
Matthias Clasen
1254ca716b Add an atomic compare-and-exchange operation for object data
This is useful when using object data in thread-safe libraries.

https://bugzilla.gnome.org/show_bug.cgi?id=682849
2012-09-02 15:09:13 -04:00
Colin Walters
6e64ba58b9 Switch all open() calls to use g_open()
Because it now handles EINTR.  And we should do so.  While most people
use Linux, which tries very hard to avoid propagating EINTR back up
into userspace, it can still happen.

https://bugzilla.gnome.org/show_bug.cgi?id=682833
2012-08-28 13:56:59 -04:00
Matthias Clasen
4a8740d0d2 It is 'registered', not 'registred' 2012-08-18 23:17:47 -04:00
Matthias Clasen
e27367f341 Exterminate 'the the' 2012-08-18 23:15:58 -04:00