mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
gquark: Document that some functions can’t initialise C++ globals
Any function which requires g_quark_init() to have been called first cannot be called before the library constructors have finished running. In particular, this means that g_quark_from_static_string() or g_intern_static_string() can’t be used to initialize C++ globals. Do this, rather than adding a conditional call to g_quark_init() to all these functions, because such a call was previously removed from the functions to improve performance (quarks are used a lot in the implementation of GObject for properties and signals). That’s the reason why g_quark_init() was originally moved out to a library constructor. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #1177
This commit is contained in:
parent
c9c88a4b22
commit
a66ae5cda3
@ -126,6 +126,9 @@ g_quark_init (void)
|
||||
* If you want the GQuark to be created if it doesn't already exist,
|
||||
* use g_quark_from_string() or g_quark_from_static_string().
|
||||
*
|
||||
* This function must not be used before library constructors have finished
|
||||
* running.
|
||||
*
|
||||
* Returns: the #GQuark associated with the string, or 0 if @string is
|
||||
* %NULL or there is no #GQuark associated with it
|
||||
*/
|
||||
@ -214,6 +217,10 @@ quark_from_string_locked (const gchar *string,
|
||||
* not currently have an associated #GQuark, a new #GQuark is created,
|
||||
* using a copy of the string.
|
||||
*
|
||||
* This function must not be used before library constructors have finished
|
||||
* running. In particular, this means it cannot be used to initialize global
|
||||
* variables in C++.
|
||||
*
|
||||
* Returns: the #GQuark identifying the string, or 0 if @string is %NULL
|
||||
*/
|
||||
GQuark
|
||||
@ -239,6 +246,10 @@ g_quark_from_string (const gchar *string)
|
||||
* expect to ever unload the module again (e.g. do not use this
|
||||
* function in GTK+ theme engines).
|
||||
*
|
||||
* This function must not be used before library constructors have finished
|
||||
* running. In particular, this means it cannot be used to initialize global
|
||||
* variables in C++.
|
||||
*
|
||||
* Returns: the #GQuark identifying the string, or 0 if @string is %NULL
|
||||
*/
|
||||
GQuark
|
||||
@ -325,6 +336,10 @@ quark_intern_string_locked (const gchar *string,
|
||||
* can be compared for equality by comparing the pointers, instead of
|
||||
* using strcmp().
|
||||
*
|
||||
* This function must not be used before library constructors have finished
|
||||
* running. In particular, this means it cannot be used to initialize global
|
||||
* variables in C++.
|
||||
*
|
||||
* Returns: a canonical representation for the string
|
||||
*
|
||||
* Since: 2.10
|
||||
@ -344,6 +359,10 @@ g_intern_string (const gchar *string)
|
||||
* using strcmp(). g_intern_static_string() does not copy the string,
|
||||
* therefore @string must not be freed or modified.
|
||||
*
|
||||
* This function must not be used before library constructors have finished
|
||||
* running. In particular, this means it cannot be used to initialize global
|
||||
* variables in C++.
|
||||
*
|
||||
* Returns: a canonical representation for the string
|
||||
*
|
||||
* Since: 2.10
|
||||
|
Loading…
Reference in New Issue
Block a user