So I'm wxWidgeting since about 2 weeks and although this library is amazing, I have some problems. Since I haven't got my answer from IRC today, I'll try here.
I've created sample code with simple ribbon and button event handler, which should spawn some simple dialog. When I click the ribbon button, the app crashes hard. Code is compiled using newest TDM and self-built wxWidgets 3.0.3 in static, release mode.
Code: Select all
#include <wx/wx.h>
#include <wx/ribbon/bar.h>
#include <wx/ribbon/buttonbar.h>
#include <wx/artprov.h>
typedef enum {
idRibbonOnlineConnect = wxID_HIGHEST + 1,
idRibbon,
idRibbonControlPage,
idConnectDlg,
} windowId;
class cRibbon: public wxRibbonBar {
public:
cRibbon(wxWindow *pParent);
};
cRibbon::cRibbon(wxWindow *pParent):
wxRibbonBar(
pParent, idRibbon, wxDefaultPosition, wxDefaultSize,
wxRIBBON_BAR_FLOW_HORIZONTAL | wxRIBBON_BAR_SHOW_PAGE_LABELS |
wxRIBBON_BAR_SHOW_PANEL_EXT_BUTTONS | wxRIBBON_BAR_SHOW_TOGGLE_BUTTON
)
{
// 'Control' page general layout
wxRibbonPage *pPageControl = new wxRibbonPage(this, idRibbonControlPage, "Control");
wxRibbonPanel *pPanelOnline = new wxRibbonPanel(
pPageControl, wxID_ANY, "On-line mode", wxNullBitmap,
wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_NO_AUTO_MINIMISE
);
wxRibbonButtonBar *pOnlineBar = new wxRibbonButtonBar(pPanelOnline);
pOnlineBar->AddButton(
idRibbonOnlineConnect, "Connect",
wxArtProvider::GetBitmap(wxART_QUESTION, wxART_TOOLBAR, wxSize(48,48))
);
Realize();
}
class MyApp: public wxApp
{
public:
virtual bool OnInit();
};
extern class MyApp *g_pApp;
class MyFrame: public wxFrame
{
public:
MyFrame();
wxPanel *m_pCont; ///< Main widget container.
cRibbon *m_pRibbon;
void onTestBtn(wxRibbonButtonBarEvent &evt);
};
class tExampleDlg: public wxDialog {
public:
tExampleDlg(wxWindow *pParent):
wxDialog(pParent, idConnectDlg, "Select port", wxDefaultPosition, wxSize(400, 200))
{
new wxButton(this, wxID_ANY, "dupa");
Centre();
}
};
MyApp *g_pApp;
wxIMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
g_pApp = this;
MyFrame *frame = new MyFrame();
frame->Show(true);
return true;
}
MyFrame::MyFrame():
wxFrame(NULL, wxID_ANY, "test", wxDefaultPosition, wxSize(800, 450))
{
m_pCont = new wxPanel(this, wxID_ANY);
m_pRibbon = new cRibbon(m_pCont);
wxBoxSizer *pMainSizer = new wxBoxSizer(wxVERTICAL);
pMainSizer->Add(m_pRibbon, 0, wxEXPAND);
m_pCont->SetSizer(pMainSizer);
Bind(wxEVT_RIBBONBUTTONBAR_CLICKED, onTestBtn, this, idRibbonOnlineConnect);
this->Center();
}
void MyFrame::onTestBtn(wxRibbonButtonBarEvent &WXUNUSED(evt))
{
tExampleDlg *pDlg = new tExampleDlg(this);
pDlg->ShowModal(); // Blocking, returns stuff
pDlg->Destroy();
}
Code: Select all
GNU gdb (GDB) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from D:\prg\wx_test\bin/wxtest.exe...done.
(gdb) run
Starting program: D:\prg\wx_test\bin/wxtest.exe
[New Thread 10332.0x1bec]
[New Thread 10332.0x86c]
[New Thread 10332.0x15d0]
[New Thread 10332.0x1218]
Program received signal SIGSEGV, Segmentation fault.
0x009244f0 in wxCheckDynamicCast(wxObject*, wxClassInfo*) ()
(gdb) bt
#0 0x009244f0 in wxCheckDynamicCast(wxObject*, wxClassInfo*) ()
#1 0x00000000 in ?? ()