I'd like to filter Treeview data according to user input. But when I execute this program it gives this error:

Gtk-CRITICAL **: gtktreemodelfiltergetvalue: assertion `GTKTREEMODELFILTER (model)->priv->stamp == iter->stamp' failed
(Segmentation fault)

What should I pass exactly to setVisibleFunc? I was expecting to pass filtered data and an iterator.

Also is cast(GtkTreeModelFilterVisibleFunc) part really needed?

Here is the complete example program.

import gtk.Main;
import gtk.MainWindow;
import gtk.Box;
import gtk.Entry;
import gtk.EditableIF;
import gtk.TreeModelFilter;
import gtk.TreeView;
import gtk.HBox;
import gtk.VBox;
import gtk.Label;
import gtk.ListStore;
import gtk.TreeViewColumn;
import gtk.CellRendererText;
import gtk.TreeModel;
import gtk.TreeIter;

import std.conv;
import std.stdio;

class MyWindow: MainWindow
{
    Box mainBox;
    Entry filterEntry;
    TreeModelFilter filter;
    TreeIter iter;

    this()
    {
        super("TreeView Example");
        setSizeRequest(500, 200);
        filterEntry = new Entry();
        auto filterLabel= new Label("Artist search");
        auto tree = new TreeView();
        auto box = new VBox(false, 0);

        auto dataModel = new ListStore([GType.STRING, GType.STRING]);
                
        auto artistColumn = new TreeViewColumn("Artist", new CellRendererText(), "text", 0);
        tree.appendColumn(artistColumn);
        auto songColumn = new TreeViewColumn("Song title", new CellRendererText(), "text", 1);
        tree.appendColumn(songColumn);

        iter = dataModel.createIter();
        dataModel.setValue(iter, 0, "This is a test");
        dataModel.setValue(iter, 1, "Sample song");

        iter = dataModel.createIter();
        dataModel.setValue(iter, 0, "This is a test");
        dataModel.setValue(iter, 1, "Another song");

        iter = dataModel.createIter();
        dataModel.setValue(iter, 0, "Another artist");
        dataModel.setValue(iter, 1, "Test song");

        filter = new TreeModelFilter(dataModel, null);
        filter.setVisibleFunc(cast(GtkTreeModelFilterVisibleFunc) filterTree(filter, iter), null, null);

        tree.setModel(filter);

        auto mainBox = new HBox(false, 0);
        mainBox.packStart(filterLabel, false, false, 5);
        mainBox.packStart(filterEntry, true, true, 5);
        box.packStart(mainBox, false, false, 5);
        box.packStart(tree, true, true, 5);

        add(box);

        showAll();
    }

    bool filterTree(TreeModelFilter model1, TreeIter it1)
    {
        string artistName = to!string(model1.getValue(it1, 0));
        return true;
    }
    void onFilterEntryTextChanged(EditableIF filterEntry)
    {
        filter.refilter();
    }

    // void onFilterEntryTextChanged(ParamSpec param, ObjectG object)
    // {
    //     filter.refilter();
    // }
}

void main(string[] args)
{
    Main.init(args);
    new MyWindow();
    Main.run();
}