After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 152486 - GtkIconView crashes when the navigation keys are pressed...
GtkIconView crashes when the navigation keys are pressed...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkIconView
2.5.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2004-09-13 11:03 UTC by santhosh
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
This file contains the real source code that produces this problem (10.77 KB, text/x-csrc)
2004-09-13 11:08 UTC, santhosh
Details

Description santhosh 2004-09-13 11:03:56 UTC
I have set the icon view Model to NULL and the text column and the pixbuf column to -1 using 
the following code.. 
... 
gtk_icon_view_set_model (icon_view, NULL); 
gtk_icon_view_set_text_column (icon_view, -1); 
gtk_icon_view_set_pixbuf_column (icon_view, -1); 
... 
 
After this, the GtkIconView will be empty and I don't get any problem If I operate using mouse. 
But If I use the Navigation keys (Up, Down, Left, Right, PgUp and PgDn), my application 
crashes. 
 
When I debugged my app using  gdb.. I got problems with the following fns... 
 
gtk_icon_view_move_cursor_up_down (icon_view, count=1) 
gtk_icon_view_move_cursor_page_up_down (icon_view, count=1) 
gtk_icon_view_move_cursor_left_right (icon_view, count=1) 
 
It references to some NULL pointer...so I get Segmentation Fault.. 
 
I will attach the real source code soon... 
 
(you can also check out the code from sourceforge.net server 
cvs -z3 -d :pserver:anonymous@cvs.sourceforge.net:/cvsroot/eccvs co eccvs 
You have to look into "src/wc-browser.c" file...)
Comment 1 santhosh 2004-09-13 11:08:30 UTC
Created attachment 31526 [details]
This file contains the real source code that produces this problem
Comment 2 santhosh 2004-09-28 14:12:12 UTC
HOW TO REPRODUCE?
--------------------

Today, I have found some more information on this problem. If you want to exactly 
reproduce this problem, please follow the procedure...

1. create an empty directory named "bug-exposed" in your home folder.
2. Just execute the "gtk-demo".
3. Double click the "icon-view" in the left pane of "gtk-demo".
[Now you can be able to see the mini file browser in action]
4. click the "home icon" in the toolbar of the browser(mini-browser)
[Now you will be able to see your home folder contents... it also contains the 
newly created "bug-exposed" folder]
5. Now double click the "bug-exposed" folder..
[Since the folder contains no files/dirs... the  mini-browser window will be 
empty..]
6. Now focus the browser by clicking on the icon-view widget in the mini-browser
7. Just press the "Home" key..

That's it. Now you can be able to see that "gtk-demo" crashes and displays 
"SEGMENTATION FAULT"...

(If you are not getting it, please press the Navigation keys as many times as 
possible until you get the error..)

Comment 3 santhosh 2004-09-28 14:36:41 UTC
POSSIBLE SOLUTION:
--------------------

The main reason for the "Segmentation Fault" is that /"icon_view->priv->items"/ 
is NULL. This is because we have no elements in the GtkTreeModel  of IconView.

we use /"gtk_icon_view_build_items()"/ to create a g_list of "items"
(icon_view->priv->items) from the "icon_view->priv->model". Since the model is 
empty (empty folder in the above case) "items" will be set to NULL and it remains 
there after..

When Home key is pressed the "gtk_icon_view_move_cursor_start_end" will be 
called.. In that fn we have the follg code which causes the problem..

...
if (count < 0)
    list = icon_view->priv->items; <== this gives NULL (we have no elements)
  else
    list = g_list_last (icon_view->priv->items);
  
  item = list->data;
...

Since icon_view->priv->items is NULL, "list->data" dereferences NULL ptr and we 
get segmentation fault...

CAN WE USE THE FOLLOWING CODE TO OVERCOME THIS PROBLEM?

--------------------------
if (count < 0)
    list = icon_view->priv->items; <== this gives NULL (we have no elements)
else
    list = g_list_last (icon_view->priv->items);

if (list == NULL) //new code
    return;
  
item = list->data;
---------------------

We also have to insert this small piece of code in the follg fns..

1. gtk_icon_view_move_cursor_up_down
2. gtk_icon_view_move_cursor_page_up_down
3. gtk_icon_view_move_cursor_left_right
4. gtk_icon_view_move_cursor_start_end

I don't know whether this soln works or not... but I believe that the description 
about the cause for this problem can help somebody to provide the correct patch..
.
Comment 4 Matthias Clasen 2004-09-29 05:31:02 UTC
2004-09-29  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkiconview.c (gtk_icon_view_move_cursor_left_right) 
	(gtk_icon_view_move_cursor_start_end) 
	(gtk_icon_view_move_cursor_page_up_down) 
	(gtk_icon_view_move_cursor_up_down): Handle an empty icon
	view gracefully.  (#152486)