Re: Treeview CRITICAL Error

Carlos Pereira wrote:
dhk wrote:
only seems to compile when the -O (Optimization) option is present. However the options is set as -O0 (that's Dash-Oh-Zero) which should turn optimization off. I'd like to be able to compile the program without optimization, but so far this has just been an annoyance.
In my opinion every application should try to compile without warnings AND run fine with -O0, -O2, -O3. If your app does not compile AND run fine with -O0 to -O3 then you should stop and try to understand why. Think about it as an opportunity to know better your application!

Sometime ago, my app was behaving in a strange way when compiling with -O3, although it worked fine with -O2. I tracked down the problem to just 2, 3 lines of complex, cheesy code, separated by commas. Replacing these 2, 3 lines by 4, 5 lines of simple, robust code, solved the issue.
Third - the problem. The application window has a notebook with a handful of tabs, each with different tree views on them. The program seems to run fine. However, when the second tab is selected, no matter what the previous tab was, the following three error lines get printed about three times.
I use a lot of notebooks and treeviews myself and they work fine. Probably this is a problem of compatibility between your TreeViews and TreeStores.

Are you sure the number of columns and their type is right? the treeviews are visible? the tree stores are visible? there is no confusion between them when you change from one Treeview to another? do you understand well the Treeview/TreeStore model?
Now the strange part. The functions that call gtk_tree_store_prepend() and gtk_tree_view_set_cursor() get a tree view pasted in as a gpointer and then it's cast to a GtkWidget. In the debugger when the tree view is printed it says "<value optimized out>" and when printed with a star '*' preceding the tree view it displays 0x0: NULL.
You can print the memory address of your treeviews, when you create them, and then in a few selected places, for example:

printf ("treeview in callback: %d\n", my_tree_view); /* ignore the warning */
fflush (stdout);

to assert if you get always the memory address you expect. Otherwise something is wrong.

If you get NULL when you expected your treeview address, this is usually an error easy to track down.


gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

Finally, I found the error. I've gone through the treeviews and tree stores many times already. I had it isolated to a specific function, but still couldn't find. After revisiting the the treeview many times the problem was the column with the check box. The enum being used in gtk_tree_view_insert_column_with_attributes() was CHECK_BOX when it should have been TIP_CHECK_BOX both are valid but have different values. I stared at this many times and didn't notice the error.

This was a change made a few weeks ago before I put the program down to do taxes. It cost a lot of time.



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