[pygobject] pygobject-object: Avoid checking whether NULL is floating
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] pygobject-object: Avoid checking whether NULL is floating
- Date: Mon, 20 Jan 2020 20:44:41 +0000 (UTC)
commit c10c9856e4121b048f55a2c7b98a6fd8e8683c23
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Mon Jan 20 21:30:14 2020 +0100
pygobject-object: Avoid checking whether NULL is floating
This issue was introduced in a102f046a178472278522e3e9d7c0b40ecd52ade.
gi/pygobject-object.c | 4 +++-
tests/regressextra.c | 20 ++++++++++++++++++++
tests/test_signal.py | 2 ++
3 files changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/gi/pygobject-object.c b/gi/pygobject-object.c
index d411afbd..76b18ccc 100644
--- a/gi/pygobject-object.c
+++ b/gi/pygobject-object.c
@@ -1947,7 +1947,9 @@ pygobject_emit(PyGObject *self, PyObject *args)
if (G_VALUE_HOLDS_OBJECT (&ret)) {
GObject *obj = g_value_get_object (&ret);
- was_floating = g_object_is_floating (obj);
+ if (obj != NULL && G_IS_OBJECT(obj)) {
+ was_floating = g_object_is_floating (obj);
+ }
}
py_ret = pyg_value_as_pyobject(&ret, TRUE);
if (!was_floating)
diff --git a/tests/regressextra.c b/tests/regressextra.c
index 7e53373a..e0ad3938 100644
--- a/tests/regressextra.c
+++ b/tests/regressextra.c
@@ -343,6 +343,7 @@ enum
{
SIGNAL_0,
ACTION_SIGNAL,
+ ACTION2_SIGNAL,
LAST_SIGNAL
};
@@ -356,6 +357,12 @@ regress_test_action_do_action (RegressTestAction *self)
return ret;
}
+static RegressTestAction *
+regress_test_action_do_action2 (RegressTestAction *self)
+{
+ return NULL;
+}
+
static void
regress_test_action_init (RegressTestAction *self)
{
@@ -375,4 +382,17 @@ static void regress_test_action_class_init (RegressTestActionClass *klass)
G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_CALLBACK (regress_test_action_do_action), NULL, NULL,
NULL, regress_test_action_get_type (), 0);
+
+ /**
+ * RegressTestAction::action2:
+ *
+ * Another action signal.
+ *
+ * Returns: (transfer full): another #RegressTestAction
+ */
+ regress_test_action_signals[ACTION2_SIGNAL] =
+ g_signal_new_class_handler ("action2",
+ G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_CALLBACK (regress_test_action_do_action2), NULL, NULL,
+ NULL, regress_test_action_get_type (), 0);
}
diff --git a/tests/test_signal.py b/tests/test_signal.py
index edc970fc..68592c5d 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -1247,6 +1247,8 @@ class TestIntrospectedSignals(unittest.TestCase):
obj = Regress.TestAction()
other_obj = obj.emit('action')
self.assertEqual(other_obj.__grefcount__, 1)
+ other_obj2 = obj.emit('action2')
+ self.assertIsNone(other_obj2)
class TestIntrospectedSignalsIssue158(unittest.TestCase):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]