Ubuntu 上的 wxWidgets2.9.3 出现错误
我已经在 Ubuntu 10.10 上安装了 wxWidgets 2.9.3 ../configure --with-gtk
我正在使用 Codeblocks IDE,并在其上轻松运行示例对话框程序。
但是,当我尝试在 Windows VS2010 (wxWidgets 2.9.2) 上运行我的工作代码时,我遇到了几个错误和运行时失败,如下所示
错误:'class wxBitmap'没有名为'UseAlpha'的成员
错误:“class wxPanel”没有名为“SetBackgroundBitmap”的成员
以下代码,也会引发错误
<块引用>assert “m_menuItem”在 Enable() 中失败:无效的菜单项
wxMenuItem *undoMenuItem; wxMenu* editMenu = new wxMenu(_("")); undoMenuItem = new wxMenuItem(editMenu, idMenuUndo, _("&Undo\tCtrl+Z"), _("撤消上一个操作")); 撤消菜单项->启用(假); 编辑菜单->追加(undoMenuItem);
如果我注释掉上面的代码,编译并运行,我会得到
SIGSEGV
并且调用堆栈是
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 面包板::重置(this=0x81713c0) (/home/vinayak/codes/IConBread/breadboard.cpp:79)
9 0x8054e57 面包板::面包板(this=0x81713c0) (/home/vinayak/codes/IConBread/breadboard.cpp:17)
10 0x805d7c5 接口::接口(本=0x8171200,父=0x81703e0,宽度=900,高度=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 应用程序::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)
导致这些错误的可能原因是什么?请记住,在 Windows (VS2010) 上,这是一个完美工作的代码。
谢谢!
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
error: ‘class wxBitmap’ has no member named ‘UseAlpha’
error: ‘class wxPanel’ has no member named ‘SetBackgroundBitmap’
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);
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 wxWidgets 开发人员的帮助下,我解决了上述问题。
UseAlpha
是 MSW 特定的,所以我无法在 Linux 上使用它wxPanel::SetBackgroundBitmap()
已删除,派生您的类wxCustomBackgroundWindow
并使用其同名方法。我通过调用克服了运行时错误,
bitmap.Create(kWidth, kHeight, 32);
在访问位图对象的函数之前。在使用位图后调用此行,重新排序行解决了问题。
但是我现在无法通过
wxGCDC
获得透明度。I solved above problems, with help from wxWidgets developers.
UseAlpha
is MSW specific, so I can't use it on LinuxwxPanel::SetBackgroundBitmap()
was removed, derive your class fromwxCustomBackgroundWindow
and use its method with the same name instead.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.