3
votes

I have installed wxWidgets 2.9.3 on Ubuntu 10.10 using ../configure --with-gtk
I am using Codeblocks IDE, and ran a sample Dialogs program easily on it.

But when I tried to run my working code on Windows, VS2010 (wxWidgets 2.9.2), I am getting several errors, and runtime failure, listed below

  1. error: ‘class wxBitmap’ has no member named ‘UseAlpha’
  2. error: ‘class wxPanel’ has no member named ‘SetBackgroundBitmap’
  3. Following code, also raises error assert "m_menuItem" failed in Enable(): invalid menu item

    wxMenuItem *undoMenuItem;
    wxMenu* editMenu = new wxMenu(_(""));
    undoMenuItem = new wxMenuItem(editMenu, idMenuUndo, _("&Undo\tCtrl+Z"), _("Undo the last action"));
    undoMenuItem->Enable(false);
    editMenu->Append(undoMenuItem);
    
  4. If I comment out above code, compile and run, I get SIGSEGV and the call stack is

0 0x168f07a cairo_save() (/usr/lib/libcairo.so.2:??)
1 0x806520 wxCairoContext::PushState() () (/usr/local/lib/libwx_gtk2u_core-2.9.so.3:??)
2 0x805b38 wxCairoContext::Init(_cairo*) () (/usr/local/lib/libwx_gtk2u_core-2.9.so.3:??)
3 0x80736a wxCairoContext::wxCairoContext(wxGraphicsRenderer*, wxMemoryDC const&) () (/usr/local/lib/libwx_gtk2u_core-2.9.so.3:??)
4 0x807401 wxCairoRenderer::CreateContext(wxMemoryDC const&) () (/usr/local/lib/libwx_gtk2u_core-2.9.so.3:??)
5 0x822f06 wxGraphicsContext::Create(wxMemoryDC const&) () (/usr/local/lib/libwx_gtk2u_core-2.9.so.3:??)
6 0x7c54b7 wxGCDCImpl::wxGCDCImpl(wxDC*, wxMemoryDC const&) () (/usr/local/lib/libwx_gtk2u_core-2.9.so.3:??)
7 0x7c554e wxGCDC::wxGCDC(wxMemoryDC const&) () (/usr/local/lib/libwx_gtk2u_core-2.9.so.3:??)
8 0x80555fd Breadboard::reset(this=0x81713c0) (/home/vinayak/codes/IConBread/breadboard.cpp:79)
9 0x8054e57 Breadboard::Breadboard(this=0x81713c0) (/home/vinayak/codes/IConBread/breadboard.cpp:17)
10 0x805d7c5 Interface::Interface(this=0x8171200, parent=0x81703e0, width=900, height=570) (/home/vinayak/codes/IConBread/interface.cpp:24)
11 0x8069db4 MainFrame::MainFrame(this=0x8108af8, frame=0x0, title=...) (/home/vinayak/codes/IConBread/mainframe.cpp:127)
12 0x80525a8 Application::OnInit(this=0x80ab228) (/home/vinayak/codes/IConBread/application.cpp:27)
13 0x8053194 wxAppConsoleBase::CallOnInit(this=0x80ab228) (/usr/local/include/wx-2.9/wx/app.h:94)
14 0xc53000 wxEntry(int&, wchar_t**) () (/usr/local/lib/libwx_baseu-2.9.so.3:??)
15 0xc530d7 wxEntry(int&, char**) () (/usr/local/lib/libwx_baseu-2.9.so.3:??)
16 0x805245f main(argc=1, argv=0xbffff924) (/home/vinayak/codes/IConBread/application.cpp:19)

What can be the possible cause of these errors? Remember, on windows (VS2010) this is a perfectly working code.
Thanks!

1

1 Answers

2
votes

I solved above problems, with help from wxWidgets developers.

  1. UseAlpha is MSW specific, so I can't use it on Linux
  2. docs/changes.txt suggest
    wxPanel::SetBackgroundBitmap() was removed, derive your class from wxCustomBackgroundWindow and use its method with the same name instead.
  3. Appending the item to the menu first, before disabling it, solves the issue.
  4. This issue's solution has raised more issues, but runtime error is gone.
    I got over the runtime fault, by calling, bitmap.Create(kWidth, kHeight, 32); before the function which was accessing bitmap object. This line was being called after bitmap was being used, reordering lines solved the problem.
    However I am unable to get transparency with wxGCDC now.