Hi 👋
Here's a minimal test case showcasing the error:
private val strings = listOf(
"plip",
"plap",
"plop",
)
private val listModel = ListStore<StringObject>().apply {
strings.forEach {
append(StringObject(it))
}
}
private val treeModel = TreeListModel<StringObject>(listModel, false, false) { parent ->
return@TreeListModel null
}
fun main(args: Array<String>) {
// runs ok
val listItem = listModel.getItem(0)
println("list item #0: $listItem")
// crashes at runtime with a class cast exception:
// compile-time type is StringObject, runtime type is TreeListRow
val treeItem = treeModel.getItem(0)
println("tree item #0: $treeItem")
}
I'm assuming the issue derives from the fact that TreeListModel<T> extends ListModel<T>, when it should instead derive from ListModel<TreeListRow>. Less handy in terms of generics, but I guess that's what the API allows for now (unless I miss something).
Note: the GTK doc mentions that it extends ListModel, but not the type of the items
Hi 👋
Here's a minimal test case showcasing the error:
I'm assuming the issue derives from the fact that
TreeListModel<T>extendsListModel<T>, when it should instead derive fromListModel<TreeListRow>. Less handy in terms of generics, but I guess that's what the API allows for now (unless I miss something).Note: the GTK doc mentions that it extends ListModel, but not the type of the items