Posted: Thu May 15, 2008 1:07 am Post subject: gtk_dialog_run call crashes program
Hello there. I have a small dialog window i have created with two labels, two entries, and an OK and Cancel button. I have gotten this window to work fine on one machine but when I moved the code over to another machine, it compiles fine, but then my program crashes when i call gtk_dialog_run() to bring up the window. All the machines I am using are running Redhat linux and I am developing in C++.
Does anyone have any ideas on what I should try to fix this? I am very confused as to why this is happening since these two machines are very similar. They are both Dell laptops running Red Hat linux and they both are running the same version of GTK.
Joined: 21 Sep 2005 Posts: 495 Location: Portland, OR USA
Posted: Thu May 15, 2008 3:26 pm Post subject:
Do you know exactly where it is crashing? Is it a segmentation fault?
Try running it through gdb with a breakpoint in the function that calls the dialog. Let's assume 'on_button_click' opens the dialog.
Code: (Plaintext)
1 2 3
gdb myprogram
b on_button_click
r
Then your program will run like normal, But when you click the button your application will halt at on_button_click shown in the terminal where you can step through it by pressing the 'n' key. When your program crashes, you'll have more info to work off of.
So I have narrowed down the problem somewhat. If I create the Dialog Window without any buttons, the window opens up fine. However, when I add the buttons to the window, that is when it crashes. I am using the gtk_dialog_new_with_buttons() call to create the window and I am trying to create it using just the GTK_STOCK_OK and GTK_STOCK_CANCEL buttons. The program crashes on the call to gtk_dialog_run().
It looks like there is a problem with using the GTK_STOCK buttons. I created my dialog window without adding buttons with the gtk_dialog_new_with_buttons() call. Instead, I added a button separately to the dialog with the gtk_button_new_from_stock() function. Adding a STOCK button this way caused the program to crash as well. When I added a button to the dialog window using the gtk_button_new() function, the button was added and the dialog opened fine.
Is there a chance these STOCK buttons are corrupt or something? Is there any easy way to reinstall this portion of GTK?