GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Jul 30, 2014 7:04 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Problem Repopulating Listview [SOLVED]
PostPosted: Sun Aug 12, 2007 6:52 pm 
Offline
Familiar Face

Joined: Mon Jul 02, 2007 6:32 pm
Posts: 6
I've been working at this for several days now and I'm hoping someone can guide me down the right path. Let me say TIA now.

I have one treeview that displays system information. Clicking a row in this treeview causes a second listview to be populated with the components that comprise the selected system assembly. For example, if Motherboard were selected in treeview 'sys_tree', then the listview 'part_tree' would be populated with microprocessor, etc.

The first time I select an item in the 'sys_tree' treeview, the 'part_tree' listview populates and all is well. The second, and subsequent, selections in the 'sys_tree' treeview don't populate the 'part_tree' listview.

The following is thrown in the terminal.

Quote:
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_row_reference_new_proxy: assertion `GTK_IS_TREE_MODEL (model)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_value: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_set_property: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_value_unset: assertion `G_IS_VALUE (value)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_unref_node: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_iter_next: assertion `GTK_IS_TREE_MODEL (tree_model)' failed
(reliafree:32523): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer
(reliafree:32523): GLib-GObject-CRITICAL **: g_signal_handlers_disconnect_matched: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
(reliafree:32523): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer
(reliafree:32523): GLib-GObject-CRITICAL **: g_signal_handlers_disconnect_matched: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
(reliafree:32523): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer
(reliafree:32523): GLib-GObject-CRITICAL **: g_signal_handlers_disconnect_matched: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
(reliafree:32523): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer
(reliafree:32523): GLib-GObject-CRITICAL **: g_signal_handlers_disconnect_matched: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
(reliafree:32523): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer
(reliafree:32523): GLib-GObject-CRITICAL **: g_signal_handlers_disconnect_matched: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
(reliafree:32523): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed


Using gdb, I've found that they're not being thrown until the program returns to the main loop function g_main_loop_run in gmain.c at (lines 2880-2881)
Code:
  while (loop->is_running)
    g_main_context_iterate (loop->context, TRUE, TRUE, self);

and then only after 2 or 3 dozen loops.

This is the callback function for the system treeview:
Code:
void system_tree_clicked_cb( GtkTreeView *tree, GdkEventButton *butt )
{

    GtkTreeIter iter;
    GtkTreePath *path;
    GtkTreeSelection *selection;

    SELECTED_TREE = 1;

    switch ( butt->button )
    {
        /* Left mouse button was clicked. */
        case (1):

            /* Get the selected system item. */
            selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( sys_tree ) );

            if (gtk_tree_selection_get_selected( selection, NULL, &iter ))
            {
                path = gtk_tree_model_get_path( GTK_TREE_MODEL( sys_store ), &iter );

                /* Get the selected item's information from the tree. */
                if (gtk_tree_model_get_iter( GTK_TREE_MODEL( sys_store ), &iter, path ) )
                {
                    read_system_tree( GTK_TREE_MODEL( sys_store ),
                                                      &path, &iter, NULL );

                    if ( ! populate_system_general_tab( pSystemItem ) )
                    {
                        printf("Error populating the general tab for Assembly %d.\n", pSystemItem.assemblyID );
                    }

                    if ( ! populate_part_tree( pSystemItem.assemblyID ) )
                    {
                        printf("Error populating the parts list for Assembly %d.\n", pSystemItem.assemblyID );
                    }
                }
                /*if ( gtk_tree_view_row_expanded ( GTK_TREE_VIEW( sys_tree ), path ) )
                {
                    gtk_tree_view_collapse_row ( GTK_TREE_VIEW( sys_tree ), path );
                }
                else
                {
                    gtk_tree_view_expand_row ( GTK_TREE_VIEW( sys_tree ), path, FALSE );
                }*/
            }
            break;

<SNIP> (Just the other three buttons that are unused ATM)

    }

    return;

}


This is the function that retrieves the components from the MySQL database and populates the listview:
Code:
gboolean populate_part_tree( gint id )
{

    GtkTreeIter iter;

    gchar query[60];

    MYSQL_RES *result;
    MYSQL_ROW row=NULL;

    /* Clear the previous tree_store then retrieve the system indenture structure
     * information.  Almost every field is displayed, so we select them all.  There's
     * nothing top secret in this table. */
    gtk_list_store_clear( GTK_LIST_STORE ( part_store ) );

    switch ( SELECTED_TREE )
    {
        case (1):
            sprintf( query,"SELECT * FROM PARTS WHERE AssemblyID=%u \
                                     ORDER BY PartID", id );
            break;

        default:
            printf( "Error: Unknown tree selected!\n" );
            break;
    }

    mysql_real_query( &mysqlconn, query, (unsigned int)strlen( query ) );
    result = mysql_store_result( &mysqlconn );

    /* Do some error checking on the returned results. */
    if( result )
    {
        printf( "Selected %lu rows for parts list.\n",
                   (unsigned long)mysql_affected_rows( &mysqlconn ) );
    }
    else
    {
        fprintf( stderr, "Error %d: %s\n", mysql_errno( &mysqlconn ),
                    mysql_error( &mysqlconn ) );
        return FALSE;
    }

    /* If there are no records returned, then set some default values as
     * placeholders; it's probably a brand new database.  Otherwise append a
     * row for each record returned and display the associated data. */
    if( mysql_num_rows( result ) == 0 )
    {

          gtk_list_store_append( GTK_LIST_STORE( part_store ), &iter );
          gtk_list_store_set( GTK_LIST_STORE( part_store ), &iter,
                                           COLUMN_PN, "Part Num",
                                           COLUMN_REFDES, "Ref Des",
                                           COLUMN_CLASS, "Class",
                                           COLUMN_SUBCLASS, "Subclass",
                                           COLUMN_QUANT, (gint) 1,
                                           COLUMN_HR, (gdouble) 0.0,
                                           COLUMN_ID, (gint) 0,
                                           -1);
     }
    else
    {
        while ( ( row = mysql_fetch_row( result ) ) )
        {
            gtk_list_store_append ( GTK_LIST_STORE( part_store ), &iter );
            gtk_list_store_set( GTK_LIST_STORE( part_store ), &iter,
                                             COLUMN_PN, row[6],
                                             COLUMN_REFDES, row[7],
                                             COLUMN_CLASS, row[3],
                                             COLUMN_SUBCLASS, row[4],
                                             COLUMN_QUANT, atoi( row[19] ),
                                             COLUMN_HR, atof( row[34] ),
                                             COLUMN_ID, atoi( row[0] ),
                                             -1);
        }
    }

    mysql_free_result( result );
    part_model = GTK_TREE_MODEL( part_store );
    gtk_tree_view_set_model( GTK_TREE_VIEW( part_tree ), part_model );
    g_object_unref( part_model );

    /* Expand all rows of the tree as the default view. */
    gtk_tree_view_expand_all( GTK_TREE_VIEW( part_tree ) );

    return TRUE;


These are the applicable sections from the Glade file for the two treeviews. Let me know if you need more.
Code:
<SNIP>

                  <widget class="GtkScrolledWindow" id="system_tree_scroll_window">
                    <property name="width_request">600</property>
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="shadow_type">GTK_SHADOW_IN</property>
                    <child>
                      <widget class="GtkTreeView" id="tree_System">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="tooltip" translatable="yes">Indentured display of the currently selected system tree...</property>
                        <property name="enable_tree_lines">True</property>
                      </widget>
                    </child>
                  </widget>

<SNIP>

                  <widget class="GtkScrolledWindow" id="part_list_scroll_window">
                    <property name="width_request">250</property>
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="shadow_type">GTK_SHADOW_IN</property>
                    <child>
                      <widget class="GtkTreeView" id="tree_Parts">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="tooltip" translatable="yes">List of parts for the currently selected assembly in the system tree ...</property>
                        <property name="enable_grid_lines">GTK_TREE_VIEW_GRID_LINES_HORIZONTAL</property>
                      </widget>


Last edited by weibullguy on Mon Aug 13, 2007 9:34 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 13, 2007 9:34 pm 
Offline
Familiar Face

Joined: Mon Jul 02, 2007 6:32 pm
Posts: 6
It was this section at the end of the populate_part_tree function:
Code:
part_model = GTK_TREE_MODEL( part_store );
gtk_tree_view_set_model( GTK_TREE_VIEW( part_tree ), part_model );
g_object_unref( part_model );
I was releasing the reference to part_model and throwing everything into a tizzy. Removing the last line
Code:
g_object_unref( part_model );
solved the problem.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group