Commit Graph

13829 Commits

Author SHA1 Message Date
Matthias Clasen
83e74d5e3e Updates 2013-05-01 00:15:06 -04:00
Tim Lunn
daf7f56491 gio: fix small leak
https://bugzilla.gnome.org/show_bug.cgi?id=699361
2013-05-01 11:15:13 +10:00
Ryan Lortie
0646e00e25 GApplication: don't leak 'hint' on remote Open
We were using format string "s" to deconstruct the open hint into a
'const gchar *' which, of course, we never freed.  Fix that.
2013-04-29 13:39:55 -07:00
Cosimo Cecchi
706e636ab8 bytesicon: don't use g_object_unref() on GBytes
We need to use g_bytes_unref()

https://bugzilla.gnome.org/show_bug.cgi?id=699001
2013-04-26 17:12:39 -04:00
Cosimo Cecchi
463022cc09 bytesicon: fix a memory leak
https://bugzilla.gnome.org/show_bug.cgi?id=698999
2013-04-26 17:08:06 -04:00
Colin Walters
518e3104bf configure: Assume C90 compatible malloc() prototype
This ancient code was attempting to cope with (unknown) systems whose
malloc() prototype was incompatible with the standard.  This test was
fragile; it would break if the build environment provided -Wall in
CFLAGS.

Now that it's 2013, let's assume that target systems have a sane
malloc().  If someone complains, we can revisit this.

https://bugzilla.gnome.org/698716
2013-04-26 16:23:42 -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
Shantha kumar
c98c65fffc Tamil Translation Updated 2013-04-26 11:40:25 +05:30
Mike Ruprecht
c027e88a30 gio/tests: Find "true" in PATH opposed to hardcoding the location
Not all systems have /usr/bin/true. Some have it in /bin/true.
Instead of trying to guess a hardcoded path to find it, let
g_app_info_create_from_commandline() internally search PATH
to find the program.

https://bugzilla.gnome.org/show_bug.cgi?id=698655
2013-04-25 02:54:14 -05:00
Milo Casagrande
8a6ae995ee [l10n] Updated Italian translation. 2013-04-25 09:01:21 +02:00
Cosimo Cecchi
03dd6cf1b5 docs: fix docs for g_icon_[de]serialize() 2013-04-24 11:58:47 -04:00
Piotr Drąg
755f4f0bf6 Updated Polish translation 2013-04-24 00:03:37 +02: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
eb860fd898 Partially revert "Merge waitpid() from g_spawn_sync into gmain()"
This partially reverts commit ce0022933c.

It used to be safe to use g_spawn_sync() from processes that had their
own SIGCHLD handler because it simply called wait().  When it was
changed to depend on the GLib child watching infrastructure this meant
that GLib had to own the SIGCHLD handler.

This caused hangs in at least Pidgin.

The patch contained two other improvements to the child watch code which
we want to keep, so only revert the changes to gspawn itself.

https://bugzilla.gnome.org/show_bug.cgi?id=698081
2013-04-23 14:39:09 -04:00
Ryan Lortie
c91af2ab44 Test GUnixSocketAddress construction
This test fails without the previous fix and works properly with it.

https://bugzilla.gnome.org/show_bug.cgi?id=698686
2013-04-23 14:36:07 -04:00
Ryan Lortie
9c243beea2 GUnixSocketAddress: fix construct parameter issue
GUnixSocketAddress has some very strange logic for interpreting its
construct paramters.  This logic behaves differently in these two cases:

  g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
                "abstract", FALSE,
                "address-type", ...,
                NULL);

and

  g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
                "address-type", ...,
                NULL);

even though the default value for "abstract" is already FALSE.

Change the way the code works so that it is not sensitive to people
merely setting a property to its default value.

https://bugzilla.gnome.org/show_bug.cgi?id=698686
2013-04-23 14:36:07 -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
00fbc2f0ce gslice: disable by default under valgrind
All experienced GLib hackers know that G_SLICE=always-malloc is
absolutely essential when valgrinding but many users of GLib don't know
about this and get hit pretty hard when valgrinding their programs.

When initialising gslice, add a check to see if we are running under
valgrind and disable ourselves if we are.

We only do the check in the case that G_SLICE= was not specified in the
environment, so setting it to an empty string will prevent this default
behaviour.

I considered modifying gslice to use the VALGRIND_MALLOCLIKE_BLOCK
client request in all cases in order to just mark the blocks properly
but these calls are not free and gslice is pretty hyper-optimised.  It's
easier to just disable gslice completely and this way we only have to do
one check during startup.  It's also theoretically possible that someone
might want to use valgrind to debug gslice, in which case the extra
annotations would probably cause quite a lot of difficulty.

https://bugzilla.gnome.org/show_bug.cgi?id=698595
2013-04-22 16:15:31 -04:00
Ryan Lortie
c8d56d7cf7 Add a copy of valgrind.h to glib/
This is a BSD-licenced header file that is designed to be copy-pasted
into programs.  It will allow us to detect if we are running under
Valgrind and send "client requests" to it.

We will use this for a couple of reasons in upcoming patches.

https://bugzilla.gnome.org/show_bug.cgi?id=698595
2013-04-22 16:15:16 -04:00
Ryan Lortie
c1c1b33f88 GMenu: add g_menu_item_set_icon() convenience
This function takes a GIcon, serialises it and sets the resulting
GVariant as the "icon" attribute on the menu item.  We will need to add
a patch to Gtk to actually consume this icon.

Also add G_MENU_ATTRIBUTE_ICON.

https://bugzilla.gnome.org/show_bug.cgi?id=688820
2013-04-22 16:12:42 -04:00
Jasper St. Pierre
63a0cc3f8d tests: Fix appinfo test 2013-04-22 13:12:20 -04:00
Daniel Mustieles
709ade0e45 Updated Spanish translation 2013-04-22 17:49:06 +02:00
Sweta Kothari
93349e6ea3 Updated gujarati file 2013-04-22 15:54:09 +05:30
Piotr Drąg
454691a4b4 Updated POTFILES.in 2013-04-22 00:37:20 +02:00
Ryan Lortie
c16f914b40 GIcon: add g_icon_[de]serialize()
Add support for serialising a GIcon to a GVariant and deserialising the
result back to a GIcon.

This solves a number of problems suffered by the existing to_string()
API, primarily these:

 - not forcing the icon to be a utf8 string means that we can
   efficiently encode a PNG (ie: just give the array of bytes)

 - there is no need to ensure that proper types are loaded before using
   the deserialisation interface.  'Foreign' icon types will probably
   emit a serialised format the deserialises to a GBytesIcon.

We additionally clearly document what is required for being a consumer
or implementation of #GIcon.

Further patches will be required to GdkPixbuf and GVfsIcon to bring
their implementations in line with the new rules (essentially: introduce
implementations of the new serialize() API).

https://bugzilla.gnome.org/show_bug.cgi?id=688820
2013-04-21 16:31:14 -04:00
Ryan Lortie
9cc222c0bf Introduce GBytesIcon
GBytesIcon is an icon that has a GBytes inside of it where the GBytes
contains some sort of encoded image in a widely-recognised file format.
Ideally this will be a PNG.

It implements GLoadableIcon, so GTK will already understand how to use
it, but we will add another patch there to make things more efficient.

https://bugzilla.gnome.org/show_bug.cgi?id=688820
2013-04-21 16:25:15 -04:00
Ryan Lortie
519e989ea8 GIcon: pure re-factor of _from_string()
Split out the 'simple string format' cases of URIs, file paths and
themed icons to a separate function.

This function will be shared by g_icon_deserialize().

https://bugzilla.gnome.org/show_bug.cgi?id=688820
2013-04-21 16:25:13 -04:00
Jasper St. Pierre
c0af442909 gdesktopappinfo: Allow getting the desktop ID from the filename 2013-04-21 00:09:47 -04:00
Lars Uebernickel
390115f385 gactionmap: don't require GActionGroup
https://bugzilla.gnome.org/show_bug.cgi?id=698478
2013-04-20 22:10:36 -04:00
Lars Uebernickel
ac1379e22c g_variant_get_data_as_bytes: return a sub-bytes if necessary
https://bugzilla.gnome.org/show_bug.cgi?id=698457
2013-04-20 19:24:47 -04:00
Ryan Lortie
dbb65b5465 GVariant: add new g_variant_new_take_string() API
Lots of people have variously asked for APIs like
g_variant_new_string_printf() in order to avoid having to use
g_strdup_printf(), create a GVariant using g_variant_new_string(), then
free the temporary string.

Instead of supporting that, plus a million other potential cases,
introduce g_variant_new_take_string() as a compromise.

It's not possible to write:

 v = g_variant_new_take_string (g_strdup_printf (....));

to get the desired result and avoid the extra copies.  In addition, it
works with many other functions.

https://bugzilla.gnome.org/show_bug.cgi?id=698455
2013-04-20 18:58:24 -04:00
Sébastien Wilmet
a2a44a9617 Add async version of g_file_make_directory()
https://bugzilla.gnome.org/show_bug.cgi?id=548353
2013-04-19 21:38:13 +02:00
Sébastien Wilmet
bd57c3f171 GFile: fix the *_async_thread()
In the *_async_thread() functions, call the corresponding synchronous
function instead of calling the interface vfunc, which can be NULL.

In some cases the check for the vfunc == NULL was done, but to be
consistent it is better to always call the synchronous version (and the
code is simpler).

https://bugzilla.gnome.org/show_bug.cgi?id=548353
2013-04-19 21:38:13 +02:00
Ryan Lortie
1de0625103 GMenu: add g_menu_remove_all() API
Removes all of the items from a GMenu.  The keyboard indicator wants to
do this as part of refreshing the layout list, as an example.

https://bugzilla.gnome.org/show_bug.cgi?id=697601
2013-04-19 14:52:51 -04:00
Ryan Lortie
57cd876321 GVariant parser: tweak lexer for format strings
Tweak the lexer so that '[%s]' gets parsed as three separate tokens,
instead of the closing bracket getting sucked into the format string.
2013-04-19 11:40:04 -04:00
Ryan Lortie
1d87c6c7f8 GVariant parser: turn two asserts into soft errors
Parsing wrongly-typed GVariant text format data is a well-defined
operation and it ought to result in a GError.  We do that for most
cases, but 'v' and 'ay' were being treated differently.  Fix those as
well.
2013-04-19 11:40:04 -04:00
Robert Bragg
c70b497859 utils: avoid redundant set/endpwent around getpwuid
set/endpwent are only required for iterating through passwd entries
using getpwent(). Since we are explicitly requesting a passwd entry
for a uid then the set/endpwent calls are redundant.

Removing these redundant calls is required for building on Android
since their C library doesn't implement these.

https://bugzilla.gnome.org/show_bug.cgi?id=645881
2013-04-17 04:36:24 -04:00
Giovanni Campagna
d171e83347 GVariant: fix transfer annotation
g_variant_new_from_bytes() returns a floating reference, so it
must be annotated (transfer none)

https://bugzilla.gnome.org/show_bug.cgi?id=697887
2013-04-16 15:57:19 +02:00
Emilio Pozuelo Monfort
ad12142943 check-abis.sh: allow _ftext as that's leaked on mips
https://bugzilla.gnome.org/show_bug.cgi?id=697942
2013-04-16 15:44:27 +02:00
Sebastian Dröge
bcbaf1bef0 Fix compilation on Android with the bionic C library
https://bugzilla.gnome.org/show_bug.cgi?id=689223
2013-04-16 13:24:26 +02:00
Jasper St. Pierre
5e2cad9de9 bookmarkfile: Fix annotations on GBookmarkFile 2013-04-12 16:41:57 -04:00
Marek Kasik
3c614be04a tests: Add test for disabled help options
Test whether help options are hidden when they are disabled
by g_option_context_set_help_enabled(.., FALSE).

https://bugzilla.gnome.org/show_bug.cgi?id=697652
2013-04-12 17:04:06 +02:00
Marek Kasik
d20336130d Don't show help options when help is disabled
Check whether help is enabled when creating help text
in g_option_context_get_help().

https://bugzilla.gnome.org/show_bug.cgi?id=697652
2013-04-12 17:04:02 +02:00
Jason Quinn
a12157b1f8 building.xml: Fix a typo of "fo" to "of"
https://bugzilla.gnome.org/show_bug.cgi?id=697771
2013-04-11 05:00:59 -04:00
Balázs Úr
f5806a208c Updated Hungarian translation 2013-04-10 23:33:20 +02:00