Segfault when adding new row to tree view


My program crashes in this function (I removed error handling, to make
listings shorter):

void add_file_button_clicked  (GtkButton *button, PrepareSendDialog *object)
    PrepareSendFileChooserDialog  dialog;
    gint                          return_value;

    return_value = dialog.run_dialog ();
    if (return_value == GTK_RESPONSE_OK)
        GObject      *tmp_object;
        GtkListStore *list_store;
        GtkTreeIter   iter;
        GFile        *selected_file;
        GFileInfo    *selected_file_info;
        GIcon        *selected_file_icon;
        GError       *error = NULL;
        gint          return_value;
        gchar        *selected_file_name = NULL;
        gchar        *selected_file_size_text = NULL;
        guint64       selected_file_size;

        // Obtain selectd file information
        tmp_object = dialog.get_object ("prepare_send_file_chooser_dialog");
        selected_file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER
        selected_file_icon = g_file_icon_new (selected_file);
        selected_file_info = g_file_query_info (selected_file,
"standard::size,standard::display-name", G_FILE_QUERY_INFO_NONE, NULL,
        if (selected_file_info != NULL)
            selected_file_name = (gchar *) g_file_info_get_attribute_string
(selected_file_info, "standard::display-name");
            selected_file_size = g_file_info_get_attribute_uint64
(selected_file_info, "standard::size");
            selected_file_size_text = (gchar *) g_format_size_for_display
            // Add file to list
            tmp_object = object->get_object ("files_tree_view");
            list_store = GTK_LIST_STORE (gtk_tree_view_get_model
(GTK_TREE_VIEW (tmp_object)));
            gtk_list_store_append (list_store, &iter);
            gtk_list_store_set (list_store, &iter, 0, selected_file_icon, 1,
selected_file_name, 2, selected_file_size_text, NULL);

            // Free resources
            g_free (selected_file_size_text);

        // Free resources
        g_object_unref (selected_file);
        g_object_unref (selected_file_icon);
        g_object_unref (selected_file_info);

This is how I created "files_tree_view" tree view:

list_store = gtk_list_store_new (3, G_TYPE_ICON, G_TYPE_STRING,
    gtk_tree_view_set_model (GTK_TREE_VIEW (tmp_object), GTK_TREE_MODEL
    // File icon column
    renderer = gtk_cell_renderer_pixbuf_new ();
    column = gtk_tree_view_column_new_with_attributes (NULL, renderer,
"gicon", 0, NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (tmp_object), column);
    // File name column
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes (_("File name"),
renderer, "text", 1, NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (tmp_object), column);
    // File icon column
    renderer = gtk_cell_renderer_text_new ();
    column = gtk_tree_view_column_new_with_attributes (_("Size"), renderer,
"text", 2, NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (tmp_object), column);

I cant find bug in this code, however I have never used tree view to display
something other, then pure text, so I may be doing something wrong...

I use Ubuntu 9.0 with GTK+ 2.16.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]