简体   繁体   中英

Gtkmm-app crashes on windows 8.1 when resizing window

I developed an app with gtkmm in visual studio about 1 year ago. No problem when I had Windows XP and Visual Studio 2010. Now when I run it one year later on windows 8.1 and compiled in Visual Studio 2012 - I can launch it BUT as soon as I try to resize the window or press the OK-button it crashes.

I can see in the debugger that it crashes in the callback-functions here when resizing the window:

cr = window->create_cairo_context();

and here when pressing ok-button:

} 

that is at the end of the callback-function when it returns.

here are the source code (callback-functions)

 void MyWindow::on_button_clicked(Glib::ustring data) {

Glib::RefPtr<Gdk::Window> window = myDrawingArea.get_window();

if(window)
{

    Gtk::Allocation allocation = myDrawingArea.get_allocation();
    const int width = allocation.get_width();
    const int height = allocation.get_height();
    std::cout << "w = " << width << std::endl;

    // coordinates for the center of the window
    int xc, yc;
    xc = width / 2;
    yc = height / 2;

    Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();

    cr->set_line_width(1.0);
    std::cout << "hello in on_button_clicked!!!\n";

    a = 0;
    b = 300;
    c = 200;
    d = 150;
    e = 350;
    f = 400;
    // draw red lines out from the center of the window
    cr->set_source_rgb(0.8, 0.5, 0.0);
    cr->move_to(a, b);
    cr->line_to(c, d);
    cr->move_to(c, d);
    cr->line_to(e, f);

    cr->stroke();
    std::cout << "here comes crasch!!!\n";
}

and the other (resizing)

 bool MyWindow::on_drawing_expose_event(GdkEventExpose* event) {

Glib::RefPtr<Gdk::Window> window = myDrawingArea.get_window();
if(window)
{
    std::cout << "here comes crasch!!!\n";
        cr = window->create_cairo_context();

and the debugger gives me this info

    sigc::trackable <Unable to read memory> 
    Glib::ObjectBase    <Unable to read memory> 

and the callstack

 >  ConsoleApplication4.exe!MyWindow::on_drawing_expose_event(_GdkEventExpose * event) Line 173 C++
ConsoleApplication4.exe!sigc::internal::slot_call1<sigc::bound_mem_functor1<bool,MyWindow,_GdkEventExpose *>,bool,_GdkEventExpose *>::call_it(sigc::internal::slot_rep * rep, _GdkEventExpose * const & a_1) Line 137   C++
gtkmm-vc100-2_4.dll!100a549b()  Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for gtkmm-vc100-2_4.dll]   
libgtk-win32-2.0-0.dll!61859f1e()   Unknown
libgobject-2.0-0.dll!63a45aca() Unknown
libgobject-2.0-0.dll!63a567e4() Unknown
libgobject-2.0-0.dll!63a5dafe() Unknown
libgobject-2.0-0.dll!63a5de66() Unknown
libgtk-win32-2.0-0.dll!6197a0f7()   Unknown
libgdk-win32-2.0-0.dll!6c363fe9()   Unknown
libgdk-win32-2.0-0.dll!6c363f9d()   Unknown
msvcrt.dll!_free() Unknown
msvcrt.dll!_free() Unknown
000000a8()  Unknown
msvcrt.dll!_free() Unknown
libglib-2.0-0.dll!685f6947()    Unknown
gtkmm-vc100-2_4.dll!10011723()  Unknown
gtkmm-vc100-2_4.dll!10024836()  Unknown
libgobject-2.0-0.dll!63a45aca() Unknown
libgobject-2.0-0.dll!63a56438() Unknown
libgobject-2.0-0.dll!63a5dcd6() Unknown
KernelBase.dll!_WaitForMultipleObjectsEx@20()  Unknown
libgdk-win32-2.0-0.dll!6c34137c()   Unknown
libglib-2.0-0.dll!685f09eb()    Unknown
libglib-2.0-0.dll!685f1205()    Unknown
libglib-2.0-0.dll!685f13f5()    Unknown
user32.dll!__InternalCallWinProc@20()  Unknown
user32.dll!UserCallWinProcCheckWow()    Unknown
user32.dll!DispatchClientMessage()  Unknown
user32.dll!___fnDWORD@4()  Unknown
ntdll.dll!_KiUserCallbackDispatcher@12()   Unknown
user32.dll!RealDefWindowProcWorker()    Unknown
user32.dll!RealDefWindowProcW() Unknown
uxtheme.dll!DoMsgDefault(struct _THEME_MSG const *) Unknown
uxtheme.dll!OnDwpSysCommand()   Unknown
uxtheme.dll!_ThemeDefWindowProc()   Unknown
uxtheme.dll!_ThemeDefWindowProcW@16()  Unknown
user32.dll!DefWindowProcW() Unknown
libgdk-win32-2.0-0.dll!6c37db18()   Unknown
user32.dll!__InternalCallWinProc@20()  Unknown
user32.dll!UserCallWinProcCheckWow()    Unknown
user32.dll!DispatchClientMessage()  Unknown
user32.dll!___fnDWORD@4()  Unknown
ntdll.dll!_KiUserCallbackDispatcher@12()   Unknown
user32.dll!RealDefWindowProcWorker()    Unknown
user32.dll!RealDefWindowProcW() Unknown
uxtheme.dll!DoMsgDefault(struct _THEME_MSG const *) Unknown
uxtheme.dll!OnDwpNcLButtonDown()    Unknown
uxtheme.dll!_ThemeDefWindowProc()   Unknown
uxtheme.dll!_ThemeDefWindowProcW@16()  Unknown
user32.dll!DefWindowProcW() Unknown
libgdk-win32-2.0-0.dll!6c37db18()   Unknown
user32.dll!__InternalCallWinProc@20()  Unknown
user32.dll!UserCallWinProcCheckWow()    Unknown
user32.dll!DispatchMessageWorker()  Unknown
user32.dll!_DispatchMessageW@4()   Unknown
libgdk-win32-2.0-0.dll!6c37dbe4()   Unknown
libgdk-win32-2.0-0.dll!6c37dc16()   Unknown
libglib-2.0-0.dll!685f09eb()    Unknown
libglib-2.0-0.dll!685f1205()    Unknown
libglib-2.0-0.dll!685efb1c()    Unknown
libgtk-win32-2.0-0.dll!61857694()   Unknown
msvcr100.dll!_free()   Unknown
msvcr100.dll!_free()   Unknown
sigc-vc100-2_0.dll!00092516()   Unknown
gtkmm-vc100-2_4.dll!10045a4f()  Unknown
ConsoleApplication4.exe!main(int argc, char * * argv) Line 10   C++
ConsoleApplication4.exe!__tmainCRTStartup() Line 536    C
kernel32.dll!@BaseThreadInitThunk@12() Unknown
ntdll.dll!__RtlUserThreadStart()    Unknown
ntdll.dll!__RtlUserThreadStart@8() Unknown

So I wonder whats wrong - since it used to run without problem on the other platform?

Greatful for help. If someone wants to see the whole source and try it I can post it.

Your problem is compiler version, you either need to compile fresh gtkmm from source by using Visual Studio 2013 and then rebuild your application.

Second option is to install older version of Visual Studio and rebuild your app and target XP.

If you decide to compile latest gtkmm (3.14) with Visual Studio 2013 I made a tutorial link1 link2 on how to do that. anyway on my GitHub page you can also find prebult gtkmm 3.14 for Visual Studio 2013 debug for Windows x64

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM