wxWidgets: Crash with wxGLCanvas/wxGLContext

1

This happens at least with wxWidgets 2.8.9 and 2.8.10 on Windows XP, did not test on other patforms:

I have two dlls, a.dll and b.dll, which are VST plugins running in a host sequencer. They make use of wxWidgets and OpenGL. On initialization, I call this in both plugins (but with different m_width and m_height):

MyControl(..)
{
    ..
    m_canvas = new wxGLCanvas(this, wxID_ANY, 0, wxPoint(0, 0), wxSize(m_width, m_height));
    m_context = new wxGLContext(m_canvas);
    ..
    m_canvas->SetCurrent(*m_context);
}

void MyControl::onPaint(wxPaintEvent& event)
{
    m_canvas->SetCurrent(*m_context);
    wxPaintDC dc(m_canvas);
    ..
    m_canvas->SwapBuffers();
}

This works fine as long as I only open a.dll or b.dll. Also, opening multiple instances of either a.dll or b.dll works fine. However, as soon as I open a.dll and b.dll at the same time, the host sequencer immediately shuts down after calling this line (even while debugging):

m_canvas->SetCurrent(*m_context);

That is what I can see on the output:

"host.exe": "D:\something\b.dll" geladen, Symbole wurden geladen.
14:49:02: ..\..\src\msw\app.cpp(364): 'RegisterClass(frame)' failed with error 0x00000582 (klasse ist bereits vorhanden).
14:49:03: ..\..\src\msw\app.cpp(373): 'RegisterClass(no redraw frame)' failed with error 0x00000582 (klasse ist bereits vorhanden).
14:49:03: ..\..\src\msw\app.cpp(383): 'RegisterClass(MDI parent)' failed with error 0x00000582 (klasse ist bereits vorhanden).
14:49:03: ..\..\src\msw\app.cpp(392): 'RegisterClass(no redraw MDI parent frame)' failed with error 0x00000582 (klasse ist bereits vorhanden).
....
c++
wxwidgets
asked on Stack Overflow Mar 18, 2009 by Jakob • edited Mar 18, 2009 by Jakob

1 Answer

2

The error messages in the output seem to indicate that you have linked wxWidgets statically into both plugins. This will work as long as you only load one plugin, even multiple times, as the wxWidgets library will then be initialized only once.

If you however try to load the second plugin while the first is still loaded, then the initialization of wxWidgets in the second plugin will fail, and consequently there will be a crash sooner or later.

You should link both plugins dynamically with wxWidgets. Google for wxWidgets and plugins / loadable modules, and you should be able to find more information on this issue.

answered on Stack Overflow Mar 18, 2009 by mghie

User contributions licensed under CC BY-SA 3.0