Closed cdepillabout closed 4 years ago
Curious, every tree sortable must be a tree model so that should work.
Any chance you can try to produce a testcase for this so we can reproduce it and analyze it in more detail? What is the type of this
in the line that explodes?
I have the exact same problem. I wanted to implement a case-insensitive string sort for my column. It happens for the sortable TreeView of my log viewer tool https://github.com/BenjaminRi/Sherlog
(note, the current sort function contains other problems because I've been messing with it), and even if I remove pretty much all the code from the comparison closure and add a println!
in the beginning, it crashes before that println!
is shown. I just stumbled across this issue and it's late now, but I may be able to construct a minimal reproducing case in the coming days.
@BenjaminRi That'd be super useful! :)
You can find the minimal repro in the following repository: https://github.com/BenjaminRi/sort_func_panic The panic happens as soon as you click the column header to trigger the sort operation. I hope it's the same problem, the stack trace looks pretty much the same.
I can confirm the crash here
And I have a fix
@BenjaminRi In your code you write
// https://github.com/gtk-rs/gtk/issues/701
// Must insert at least one entry, or else it crashes on startup (different bug)
Commenting that code so that the model stays empty does not result in a crash here. Can you provide some more details for that separate bug?
@sdroege The information is all in the issue that I linked in the comment. It looks like it's caused by an underlying bug in the C implementation of GTK:
https://github.com/gtk-rs/gtk/issues/701
And if we follow down that line into the GTK bug tracker, we see that it's a Cairo bug:
https://gitlab.gnome.org/GNOME/gtk/issues/1333
and if we go into that bugtracker, we see that the issue is still open
Ah, so it's Windows-specific. Makes sense that it doesn't happen for me then. Thanks :)
@sdroege Thank you for your good work. I did not expect such a fast reaction and fix.
If there's a minimal testcase then these problems are usually easy to fix when you know where to look :)
I'm trying to use
gtk::TreeSortableExtManual::set_sort_func
on aTreeModelSort
, but the callback appears to always panic at runtime.I don't have a minimally reproducible error, but I do have a small change to my own code base that triggers this error:
https://github.com/cdepillabout/nix-query-tree-viewer/commit/fa5b6ed7557bd9b4c20dd9fafac8207a0f6b678b#diff-781f3944d3debcae5a68e2d54ca2f098R192
In my actual code base, I've worked around this by just coding up my own wrapper to
gtk_sys::gtk_tree_sortable_set_sort_func
based on the code forgtk::ListBoxExt::set_sort_func
(which I had assumed was working correctly, because it is automatically generated):https://github.com/cdepillabout/nix-query-tree-viewer/blob/d93a85929704b03deebb96c25dd3926aa50c0ccd/src/ui/stack/tree.rs#L40
Here is where I call it from:
https://github.com/cdepillabout/nix-query-tree-viewer/blob/d93a85929704b03deebb96c25dd3926aa50c0ccd/src/ui/stack/tree.rs#L188
Here's the backtrace when this error happens:
Let me know if you need a backtrace in gdb or anything else.
The line that is actually causing the problem is the following:
https://github.com/gtk-rs/gtk/blob/54e0a9bc2593e6d83515602ff4625d154a733107/src/tree_sortable.rs#L180
I'm not sure what could be going on here. It seems reasonable to get a
gtk::TreeModelSort
from agtk::TreeModel
.