I'm currently working on a streaming application that necessitates the use of certain buttons below where the stream appears. While the stream is buffering I would like to disable certain buttons. However, when I try to disable the buttons, Visual Studios throws an exception in window.h:
Code: Select all
Exception thrown at 0x0184B4F6 in myApp.exe: 0xC0000005: Access violation reading location 0xCDCDCDCD.
Code: Select all
Exception thrown at 0x015349E1 in myApp.exe: 0xC0000005: Access violation reading location 0xCDCDCE11.
EDIT: devicePanel is the main panel that contains deviceContentPanel, a panel that itself contains within it vidStreamPanel and controlPanel, both of which are obviously children of deviceContentPanel.
Code: Select all
//view.h ============================================
//this is the panel that contains the panel containing the button named buttonSettings
class DevicePanel : public wxPanel
{
public:
wxPanel* deviceContentPanel;
wxPanel* vidStreamPanel;
wxPanel* controlPanel;
wxBitmapButton* buttonSettings;
};
//device_view.cpp ===========================================
void DevicePanel::Init()
{
drawControlPanel();
}
//this is the panel that contains the button named buttonSettings
void DevicePanel::drawControlPanel()
{
controlPanel = new wxPanel(bla bla bla);
controlPanel->SetSizer(exampleSizer);
buttonSettings = createButton(controlPanel, "res/images/ic_settings.png", _("settings"), 101);
buttonSettings->Connect(101, wxEVT_BUTTON, wxCommandEventHandler(DevicePanel::onSettingsClick), NULL, this);
}
void DevicePanel::onPlayStreamClick(wxCommandEvent &event)
{
wxWindowBase * const parent = buttonSettings->GetParent(); //this line throws the second exception I mentioned in window.h
if (parent->IsEnabled())
parent->Disable();
//the following line doesn't work but was a potential workaround I tried
//buttonSettings->Disconnect(101, wxEVT_BUTTON, wxCommandEventHandler(DevicePanel::onSettingsClick), NULL, NULL);
buttonSettings->Disable(); // this line on its own throws the first exception I mentioned in window.h
}