Gio.ListStore.find_with_equal_func is broken
Sorry for the not very descriptive title, but it's just difficult to explain. When using Gio.ListStore.find_with_equal_func, the equal_func gets passed weird values: a is always None, and b is always some big integer (possibly a pointer?). This function is obviously unusable.
Here's some code to replicate the issue:
from gi.repository import Gio, GObject
class Wrapper(GObject.Object):
def __init__(self, val):
super().__init__()
self.val = val
raw_data = [1,2,3,4]
data = [Wrapper(i) for i in raw_data]
list_store = Gio.ListStore()
for d in data:
list_store.append(d)
def equal_func(a, b):
print(a, b)
a.val == b.val
print(list_store.find_with_equal_func(
data[1], equal_func
))
And here's the output I'm getting:
None 94456437775488
Traceback (most recent call last):
File "/home/gabmus/replicate_gliststore_find/test.py", line 17, in equal_func
a.val == b.val
AttributeError: 'NoneType' object has no attribute 'val'
None 94456437775488
Traceback (most recent call last):
File "/home/gabmus/replicate_gliststore_find/test.py", line 17, in equal_func
a.val == b.val
AttributeError: 'NoneType' object has no attribute 'val'
None 94456437775488
Traceback (most recent call last):
File "/home/gabmus/replicate_gliststore_find/test.py", line 17, in equal_func
a.val == b.val
AttributeError: 'NoneType' object has no attribute 'val'
None 94456437775488
Traceback (most recent call last):
File "/home/gabmus/replicate_gliststore_find/test.py", line 17, in equal_func
a.val == b.val
AttributeError: 'NoneType' object has no attribute 'val'
(False, position=0)
Update: related issue in glib
Edited by Gabriele Musco