Fixed the core issue (nil was not working as return value of a factory method)

This commit is contained in:
Matthias Koefferlein
2026-08-25 20:36:29 +02:00
parent 3c669eb5eb
commit a6900e091e
4 changed files with 26 additions and 1 deletions
+11
View File
@@ -146,6 +146,13 @@ class PyGFactory(pya.GFactory):
def f(self, z):
return PyGObject(z)
class PyNilGFactory(pya.GFactory):
def __init__(self):
super(PyNilGFactory, self).__init__()
# reimplementation of "virtual GObject *f(int)"
def f(self, z):
return None
class BasicTest(unittest.TestCase):
def test_00(self):
@@ -3255,6 +3262,10 @@ class BasicTest(unittest.TestCase):
go = None
self.assertEqual(pya.GObject.g_inst_count(), gc)
gf = PyNilGFactory()
go = pya.GFactory.create_f(gf, 17)
self.assertEqual(go is None, True)
# fallback to __rmul__ for not implemented __mul__
def test_90(self):
+4
View File
@@ -3252,6 +3252,10 @@ class Basic_TestClass < TestBase
GC.start
assert_equal(RBA::GObject.g_inst_count, gc)
gf = RBANilGFactory::new
go = RBA::GFactory.create_f(gf, 17)
assert_equal(go, nil)
end
# keyword arguments, enums and error messages
+10
View File
@@ -76,3 +76,13 @@ class RBAGFactory < RBA::GFactory
end
end
class RBANilGFactory < RBA::GFactory
def initialize
super()
end
# reimplementation of "virtual GObject *f(int)"
def f(z)
return nil
end
end