diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-06-22 18:37:26 +0100 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-06-22 18:37:26 +0100 |
commit | 10ba1c82bd6f58ccab99eda85416ec5600ac015d (patch) | |
tree | c6838fee72ad84abe695eb93cd7dcf00e80c8eee /tests | |
parent | 280a1083ac061e72bcd170e369d6785641f5cae6 (diff) |
gsignal: Add support for G_CONNECT_SWAPPED
It was mysteriously missing before, because it is actually a hard
problem than it looks to check correctly. This adds support for
g_signal_connect_swapped() and g_signal_connect_data() with the
G_CONNECT_SWAPPED flag.
Currently, the user_data parameter is validated as being any kind of
pointer. This could potentially be tightened up in future to check that
it is a subtype of the closure variable passed into g_signal_connect()
(even in the non-G_CONNECT_SWAPPED case). However, this is best left to
a separate checker which examines closure types.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gsignal-connect.c | 88 | ||||
-rw-r--r-- | tests/gsignal.head.c | 14 |
2 files changed, 102 insertions, 0 deletions
diff --git a/tests/gsignal-connect.c b/tests/gsignal-connect.c index 6d34bd6..f60520a 100644 --- a/tests/gsignal-connect.c +++ b/tests/gsignal-connect.c @@ -196,3 +196,91 @@ g_signal_connect (settings, "changed", (GCallback) settings_changed_const_cb, NULL); } + +/* + * No error + */ +{ + GSettings *settings = g_malloc (5); // only checking the type + g_signal_connect_swapped (settings, "changed", + (GCallback) settings_changed_swapped_cb, + NULL); +} + +/* + * No error + */ +{ + GSettings *settings = g_malloc (5); // only checking the type + gint some_thing[] = { 0, 1, 2 }; // subtype of gpointer, so valid + g_signal_connect_swapped (settings, "changed", + (GCallback) settings_changed_swapped_cb, + some_thing); +} + +/* + * No error + */ +{ + GSettings *settings = g_malloc (5); // only checking the type + gint some_thing[] = { 0, 1, 2 }; // subtype of gpointer, so valid + g_signal_connect_swapped (settings, "changed", + (GCallback) settings_changed_swapped_cb, + some_thing); +} + +/* + * No error + */ +{ + GSettings *settings = g_malloc (5); // only checking the type + gint some_thing[] = { 0, 1, 2 }; // not a GInputStream; FIXME: might be marked as invalid in future + g_signal_connect_swapped (settings, "changed", + (GCallback) settings_changed_swapped_stream_cb, + some_thing); +} + +/* + * No error + */ +{ + GSettings *settings = g_malloc (5); // only checking the type + GFilterInputStream *stream = g_malloc (5); // GInputStream subtype; valid + g_signal_connect_swapped (settings, "changed", + (GCallback) settings_changed_swapped_stream_cb, + stream); +} + +/* + * No error + */ +{ + GSettings *settings = g_malloc (5); // only checking the type + GObject *stream = g_malloc (5); // GInputStream supertype; FIXME: might be marked as invalid in future + g_signal_connect_swapped (settings, "changed", + (GCallback) settings_changed_swapped_stream_cb, + stream); +} + +/* + * No error + */ +{ + GSettings *settings = g_malloc (5); // only checking the type + gint some_thing[] = { 0, 1, 2 }; // subtype of gpointer, so valid + g_signal_connect_data (settings, "changed", + (GCallback) settings_changed_swapped_cb, + some_thing, NULL, G_CONNECT_SWAPPED); +} + +/* + * No error + */ +{ + GSettings *settings = g_malloc (5); // only checking the type + gint some_thing[] = { 0, 1, 2 }; // subtype of gpointer, so valid + g_signal_connect_data (settings, "changed", + (GCallback) settings_changed_swapped_cb, + some_thing, NULL, + G_CONNECT_SWAPPED | G_CONNECT_AFTER); +} diff --git a/tests/gsignal.head.c b/tests/gsignal.head.c index e4f3026..f651e4f 100644 --- a/tests/gsignal.head.c +++ b/tests/gsignal.head.c @@ -90,6 +90,20 @@ settings_changed_const_cb (GSettings *settings, const gchar *key, /* Something */ } +static void +settings_changed_swapped_cb (gpointer user_data, const gchar *key, + GSettings *settings) +{ + /* Something */ +} + +static void +settings_changed_swapped_stream_cb (GInputStream *stream, const gchar *key, + GSettings *settings) +{ + /* Something */ +} + int main (void) { |