GNOME Bugzilla – Bug 537120
Windows ListViewText crash
Last modified: 2008-11-14 09:19:10 UTC
Please describe the problem: I tried adding a ListViewText widget to my window. Everything works great except when the application quits. When I close the window, the program crashes. Crash location is a code block in gtkmm-2.4.dll. If I comment out the ListViewText lines it works fine but as soon as I add ListViewText, it'd crash on exit. Steps to reproduce: Hers is my code: #include <gtkmm.h> #pragma comment(lib, "glibmm-2.4.lib") #pragma comment(lib, "gtkmm-2.4.lib") #pragma comment(lib, "sigc-2.0.lib") #pragma comment(lib, "atkmm-1.6.lib") #include <windows.h> using namespace Gtk; #define LABELCTRL(N, L) class N##Label: public Label { public: N##Label():Label(L) {}} N; #define TABLEATTACHSPAN(ROW, COL, ROWSPAN, COLSPAN, ITEM) attach(ITEM, ROW-1, ROW - 1 + ROWSPAN, COL-1, COL - 1 + COLSPAN); #define TABLEATTACH(ROW, COL, ITEM) TABLEATTACHSPAN(ROW, COL, 1, 1, ITEM) class MainWindow: public Window { public: class MainLayout: public Table { public: LABELCTRL(lblUsername, "User name"); LABELCTRL(lblIP, "IP"); LABELCTRL(lblQuitMessage, "Quit Message"); LABELCTRL(lblConnectionSetting, "Connection setting"); LABELCTRL(lblPort, "Port"); LABELCTRL(lblOptions, "Option"); Entry entUsername; ComboBox cmbConnectionSetting; Entry entQuitMessage; Entry entPort; ComboBox cmbOptions; class IPEntryHbox: public HBox { public: Entry entIP; class btnConnectButton: public Button { public: btnConnectButton() : Button("Connect") { //set_size_request(1, 1); } bool on_button_press_event(GdkEventButton*) { return true; } } btnConnect; IPEntryHbox() : HBox(false) { pack_start(entIP); pack_end(btnConnect); } } ipInput; class serversListListViewText : public ListViewText { public: serversListListViewText() : ListViewText(2, false) { //set_column_title(0, "Server"); //set_column_title(1, "IP"); //set_size_request(400, 250); //insert_text(0, "asdf"); //set_text(0, 1, "asdasdasda"); } ~serversListListViewText(){ MessageBox(0,0,0,0); } } serversList; public: LABELCTRL(lblStored, "Stored"); MainLayout():Table(10, 2, false) { TABLEATTACH(1, 1, lblUsername); TABLEATTACH(1, 2, lblIP); TABLEATTACH(1, 3, lblStored); TABLEATTACH(1, 4, lblQuitMessage); TABLEATTACH(1, 5, lblConnectionSetting); TABLEATTACH(1, 6, lblPort); TABLEATTACH(1, 7, lblOptions); TABLEATTACH(2, 1, entUsername); TABLEATTACH(2, 2, ipInput); TABLEATTACH(2, 3, serversList); TABLEATTACH(2, 4, entQuitMessage); TABLEATTACH(2, 5, cmbConnectionSetting); TABLEATTACH(2, 6, entPort); TABLEATTACH(2, 7, cmbOptions); //lblIP.set_size_request(100, 20); } } controls; //class: public Button {bool on_button_press_event(GdkEventButton * ) {Main::quit(); return false;}} btnExit; MainWindow() { //set_size_request(750, 550); add(controls); show_all(); } }; ... Main kit(&argc, (char ***) &args); MainWindow mainWindow; Main::run(mainWindow); Actual results: crashes on exit Expected results: expected it to quit peacefully Does this happen every time? yes Other information:
as you can see, I've put in a destructor for ListViewText child class and the message box does show up. it crashes after the messagebox is gone. It'd crash even if I have something like: ListViewText serversList(2); in a function
> It'd crash even if I have something like: > ListViewText serversList(2); So please do provide a simpler test case.
something like this I guess?: #include <gtkmm.h> #pragma comment(lib, "glibmm-2.4.lib") #pragma comment(lib, "gtkmm-2.4.lib") #pragma comment(lib, "sigc-2.0.lib") #pragma comment(lib, "atkmm-1.6.lib") int main( int argc, char *args[]) { Main kit(&argc, &args); ListViewText serversList(2); return 0; }
You guess? Are you sure? Please try that test case.
Yes I'm sure it crashed when I tried. Some of have time constraints for our projects to be held back by one stupid bug and we've moved onto other packages. Thanks for your time. Good luck with gtkmm.
I guess there is "using namespace Gtk;" missing in your test, otherwise it does not compile. Anyway, I could not reproduce the problem with neither gcc nor MSVC. When using MSVC, make sure you link against the correct libraries and use the correct Run-Time: For a debug build, use "Multi-Threaded Debug" as "Runtime Library", and link against the libraries ending on "d", such as "gtkmm-2.4d.lib". For the release build, use "Multi-Threaded", and link against the libraries without "d" (gtkmm-2.4.lib). I don't know whether that's the problem here, but doing it wrong can result in seemingly random crashes.
K Civilian, please respond, and please provide a compileable test case if you still have this problem.
Please respond.
Closing due to lack of response.