mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-20 20:42:12 +02:00
Introduce G_PARAM_DEPRECATED and G_ENABLE_DIAGNOSTIC
See https://bugzilla.gnome.org/show_bug.cgi?id=601686
This commit is contained in:
parent
f587cb57f2
commit
272836936e
@ -1016,11 +1016,27 @@ object_set_property (GObject *object,
|
|||||||
GObjectClass *class = g_type_class_peek (pspec->owner_type);
|
GObjectClass *class = g_type_class_peek (pspec->owner_type);
|
||||||
guint param_id = PARAM_SPEC_PARAM_ID (pspec);
|
guint param_id = PARAM_SPEC_PARAM_ID (pspec);
|
||||||
GParamSpec *redirect;
|
GParamSpec *redirect;
|
||||||
|
static gchar* enable_diagnostic = NULL;
|
||||||
|
|
||||||
redirect = g_param_spec_get_redirect_target (pspec);
|
redirect = g_param_spec_get_redirect_target (pspec);
|
||||||
if (redirect)
|
if (redirect)
|
||||||
pspec = redirect;
|
pspec = redirect;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (!enable_diagnostic))
|
||||||
|
{
|
||||||
|
enable_diagnostic = g_getenv ("G_ENABLE_DIAGNOSTIC");
|
||||||
|
if (!enable_diagnostic)
|
||||||
|
enable_diagnostic = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enable_diagnostic[0] == '1')
|
||||||
|
{
|
||||||
|
if (pspec->flags & G_PARAM_DEPRECATED)
|
||||||
|
g_warning ("The property %s::%s is deprecated and shouldn't be used "
|
||||||
|
"anymore. It will be removed in a future version.",
|
||||||
|
G_OBJECT_TYPE_NAME (object), pspec->name);
|
||||||
|
}
|
||||||
|
|
||||||
/* provide a copy to work from, convert (if necessary) and validate */
|
/* provide a copy to work from, convert (if necessary) and validate */
|
||||||
g_value_init (&tmp_value, pspec->value_type);
|
g_value_init (&tmp_value, pspec->value_type);
|
||||||
if (!g_value_transform (value, &tmp_value))
|
if (!g_value_transform (value, &tmp_value))
|
||||||
|
@ -132,6 +132,10 @@ G_BEGIN_DECLS
|
|||||||
* unmodified for the lifetime of the parameter.
|
* unmodified for the lifetime of the parameter.
|
||||||
* Since 2.8
|
* Since 2.8
|
||||||
* @G_PARAM_PRIVATE: internal
|
* @G_PARAM_PRIVATE: internal
|
||||||
|
* @G_PARAM_DEPRECATED: the parameter is deprecated and will be removed
|
||||||
|
* in a future version. A warning will be generated if it is used
|
||||||
|
* while running with G_ENABLE_DIAGNOSTIC=1.
|
||||||
|
* Since: 2.26
|
||||||
*
|
*
|
||||||
* Through the #GParamFlags flag values, certain aspects of parameters
|
* Through the #GParamFlags flag values, certain aspects of parameters
|
||||||
* can be configured.
|
* can be configured.
|
||||||
@ -148,7 +152,9 @@ typedef enum
|
|||||||
G_PARAM_PRIVATE = G_PARAM_STATIC_NAME,
|
G_PARAM_PRIVATE = G_PARAM_STATIC_NAME,
|
||||||
#endif
|
#endif
|
||||||
G_PARAM_STATIC_NICK = 1 << 6,
|
G_PARAM_STATIC_NICK = 1 << 6,
|
||||||
G_PARAM_STATIC_BLURB = 1 << 7
|
G_PARAM_STATIC_BLURB = 1 << 7,
|
||||||
|
/* User defined flags go up to 30 */
|
||||||
|
G_PARAM_DEPRECATED = 1 << 31
|
||||||
} GParamFlags;
|
} GParamFlags;
|
||||||
/**
|
/**
|
||||||
* G_PARAM_READWRITE:
|
* G_PARAM_READWRITE:
|
||||||
@ -175,11 +181,10 @@ typedef enum
|
|||||||
* G_PARAM_USER_SHIFT:
|
* G_PARAM_USER_SHIFT:
|
||||||
*
|
*
|
||||||
* Minimum shift count to be used for user defined flags, to be stored in
|
* Minimum shift count to be used for user defined flags, to be stored in
|
||||||
* #GParamSpec.flags.
|
* #GParamSpec.flags. The maximum allowed is 30 + G_PARAM_USER_SHIFT.
|
||||||
*/
|
*/
|
||||||
#define G_PARAM_USER_SHIFT (8)
|
#define G_PARAM_USER_SHIFT (8)
|
||||||
|
|
||||||
|
|
||||||
/* --- typedefs & structures --- */
|
/* --- typedefs & structures --- */
|
||||||
typedef struct _GParamSpec GParamSpec;
|
typedef struct _GParamSpec GParamSpec;
|
||||||
typedef struct _GParamSpecClass GParamSpecClass;
|
typedef struct _GParamSpecClass GParamSpecClass;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user