Ubuntu 上的 wxWidgets2.9.3 出现错误

发布于 2024-12-29 20:48:02 字数 2603 浏览 1 评论 0原文

我已经在 Ubuntu 10.10 上安装了 wxWidgets 2.9.3 ../configure --with-gtk
我正在使用 Codeblocks IDE,并在其上轻松运行示例对话框程序。

但是,当我尝试在 Windows VS2010 (wxWidgets 2.9.2) 上运行我的工作代码时,我遇到了几个错误和运行时失败,如下所示

  1. 错误:'class wxBitmap'没有名为'UseAlpha'的成员
  2. 错误:“class wxPanel”没有名为“SetBackgroundBitmap”的成员
  3. 以下代码,也会引发错误 assert “m_menuItem”在 Enable() 中失败:无效的菜单项

    <块引用>
    wxMenuItem *undoMenuItem;
    wxMenu* editMenu = new wxMenu(_(""));
    undoMenuItem = new wxMenuItem(editMenu, idMenuUndo, _("&Undo\tCtrl+Z"), _("撤消上一个操作"));
    撤消菜单项->启用(假);
    编辑菜单->追加(undoMenuItem);
    
  4. 如果我注释掉上面的代码,编译并运行,我会得到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

  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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

假装爱人 2025-01-05 20:48:02

在 wxWidgets 开发人员的帮助下,我解决了上述问题。

  1. UseAlpha 是 MSW 特定的,所以我无法在 Linux 上使用它
  2. docs/changes.txt suggest
    wxPanel::SetBackgroundBitmap() 已删除,派生您的类
    wxCustomBackgroundWindow 并使用其同名方法。
  3. 首先将该项目附加到菜单中,然后再禁用它,可以解决该问题。
  4. 此问题的解决方案引发了更多问题,但运行时错误消失了。
    我通过调用克服了运行时错误,
    bitmap.Create(kWidth, kHeight, 32);
    在访问位图对象的函数之前。在使用位图后调用此行,重新排序行解决了问题。
    但是我现在无法通过 wxGCDC 获得透明度。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文