Skip to content

app crash after reported : GLib-GObject-WARNING **: g_object_remove_toggle_ref: couldn't find toggle ref  #239

@dangbinghoo

Description

@dangbinghoo

I think it's a related issue as the #220

I wrote a small program which read some data from database, and listed them on a gtk listview. the program need to refresh the list every time when it's container tab is closed. so I have a very simple logic, just clear the datastore before I read out data from database, then for each data row, create a iter and set value.

The program may crash after several clicking for loading the list data before I was using gtkd 3.7.x , but today I upgraded to gtkd 3.8.0, it crashed immediately when I did a second click for loading the data.

here is the code

void uiLoadTabToolCatalog(ref UI ui)
{
    writeln("Loading All Tool type and spec info from DB....");
     ui.listToolCatalogStore.clear();
    auto em = DBM.getEntityManager();
    CriteriaBuilder criteria = em.createCriteriaBuilder!DBMToolCatalog;
    DBMToolCatalog[] tools = em.getResultList!DBMToolCatalog(criteria);

    auto em2 = DBM.getEntityManager();
    CriteriaBuilder cb = em2.createCriteriaBuilder!DBMToolType;
    DBMToolType[] types = em2.getResultList!DBMToolType(cb);

    ToolID toolID;

    foreach (t; tools) {
        if (t is null) {
            continue;
        }
        TreeIter iter = ui.listToolCatalogStore.createIter();
        ui.listToolCatalogStore.setValue(iter, TOOLCATALOG_COL1, t.date);
        ui.listToolCatalogStore.setValue(iter, TOOLCATALOG_COL2, t.currepc);
        //writefln("toolepc %s tool %s --> ", t.currepc, t.typestr);
        
        if (strToToolID(t.currepc, toolID) == 0) {
            string tooltypeHex = format("%04X", toolID.types);
            //writefln("tool type hexstr %s", tooltypeHex);
            if (types.length > 0) {
                foreach (ty; types) {
                    if (ty.typehex == tooltypeHex) {
                        //writefln("tool icon = %s", ty.iconid);
                        // if (!(ty.iconid is null)) {
                        //     ui.listToolCatalogStore.setValue(iter, TOOLCATALOG_COL3, new Pixbuf("./res/" ~ ty.iconid ~ ".png", 30, 30));
                        // }   
                    }
                }
            }
        }

        ui.listToolCatalogStore.setValue(iter, TOOLCATALOG_COL4, t.typestr);
        ui.listToolCatalogStore.setValue(iter, TOOLCATALOG_COL5, t.specstr);
        ui.listToolCatalogStore.setValue(iter, TOOLCATALOG_COL6, t.customer);
        ui.listToolCatalogStore.setValue(iter, TOOLCATALOG_COL7, t.annote);
        ui.listToolCatalogStore.setValue(iter, TOOLCATALOG_COL8, t.tid);
    }
}

ui is a ref to the gtk application class.

/**
 * All ui elements.
 */
class UI 
{
    // UI elements.
    private ApplicationWindow parent;
    private Builder builder;

    //main Notebook
    public Notebook mainTabs;


    // tool catalog list
    public TreeView listToolCatalogBox;    //tool_catalog_list;
    public ListStore listToolCatalogStore;

    this (ApplicationWindow parent)
    {
        this.parent = parent;
    }

    auto getParent()
    {
        return this.parent;
    }

    auto el(T) (string idstr) {
        return cast(T) builder.getObject(idstr);
    }

    void setBuilder(Builder build){
        this.builder = build;
    }

    UI getSelf()
    {
        return this;
    }
}

and the crash happend after the following console output:

(RfidPCTool.exe:43156): GLib-GObject-WARNING **: g_object_remove_toggle_ref: couldn't find toggle ref 00007ff7a19804a0(000001f1d6663a40)

(RfidPCTool.exe:43156): GLib-GObject-WARNING **: g_object_remove_toggle_ref: couldn't find toggle ref 00007ff7a19804a0(000001f1d6663a80)

(RfidPCTool.exe:43156): GLib-GObject-WARNING **: g_object_remove_toggle_ref: couldn't find toggle ref 00007ff7a19804a0(000001f1d6663ac0)

(RfidPCTool.exe:43156): GLib-GObject-WARNING **: g_object_remove_toggle_ref: couldn't find toggle ref 00007ff7a19804a0(000001f1d6663b00)

(RfidPCTool.exe:43156): GLib-GObject-WARNING **: g_object_remove_toggle_ref: couldn't find toggle ref 00007ff7a19804a0(000001f1d6663b40)

(RfidPCTool.exe:43156): GLib-GObject-WARNING **: g_object_remove_toggle_ref: couldn't find toggle ref 00007ff7a19804a0(000001f1d6663b60)

(RfidPCTool.exe:43156): GLib-GObject-WARNING **: g_object_remove_toggle_ref: couldn't find toggle ref 00007ff7a19804a0(000001f1d6663ba0)

(RfidPCTool.exe:43156): GLib-GObject-WARNING **: g_object_remove_toggle_ref: couldn't find toggle ref 00007ff7a19804a0(000001f1d6663be0)

(RfidPCTool.exe:43156): GLib-GObject-WARNING **: g_object_remove_toggle_ref: couldn't find toggle ref 00007ff7a19804a0(000001f1d6663c20)

(RfidPCTool.exe:43156): GLib-GObject-WARNING **: g_object_remove_toggle_ref: couldn't find toggle ref 00007ff7a19804a0(000001f1d6663c40)

........

and in another tab in my app, a single line data store item remove will cause the application some time crash too.

    for (ui.listTagStore.getIterFirst(iter), iter.setModel(ui.listTagStore);
         ui.listTagStore.iterIsValid(iter); 
         ui.listTagStore.iterNext(iter)) {
        if (iter.getValueInt(TAGLIST_COL3)) {

                //some other code not related to the ui.

                //ui.listTagBox.select();
                ui.listTagStore.remove(iter);
        }
   }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions