Added more pointer error checking to the wxvbam build.

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1260 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
wowzaman12 2015-03-28 01:33:12 +00:00
parent d54845210f
commit a262024135
3 changed files with 16 additions and 1 deletions

View File

@ -474,7 +474,7 @@ class PrintDialog : public wxEvtHandler, public wxPrintout
public: public:
PrintDialog(const u16 *data, int lines, bool cont); PrintDialog(const u16 *data, int lines, bool cont);
~PrintDialog(); ~PrintDialog();
int ShowModal() { return wxGetApp().frame->ShowModal(dlg); } int ShowModal() {CheckPointer(wxGetApp().frame); return wxGetApp().frame->ShowModal(dlg); }
private: private:
void DoSave(wxCommandEvent&); void DoSave(wxCommandEvent&);
void DoPrint(wxCommandEvent&); void DoPrint(wxCommandEvent&);

View File

@ -616,6 +616,7 @@ void MainFrame::MenuPopped(wxMenuEvent &evt)
// uses dialog_opened as a nesting counter // uses dialog_opened as a nesting counter
int MainFrame::ShowModal(wxDialog *dlg) int MainFrame::ShowModal(wxDialog *dlg)
{ {
CheckPointer(dlg);
StartModal(); StartModal();
int ret = dlg->ShowModal(); int ret = dlg->ShowModal();
StopModal(); StopModal();

View File

@ -2,6 +2,8 @@
#define WX_WXVBAM_H #define WX_WXVBAM_H
#include <list> #include <list>
#include <typeinfo>
#include <stdexcept>
#include <wx/propdlg.h> #include <wx/propdlg.h>
#include "wxhead.h" #include "wxhead.h"
@ -25,6 +27,18 @@
#include "../gb/gbCheats.h" #include "../gb/gbCheats.h"
#include "../gba/Cheats.h" #include "../gba/Cheats.h"
template <typename T>
void CheckPointer(T pointer)
{
if(pointer == NULL)
{
std::string errormessage = "Pointer of type \"";
errormessage+=typeid(pointer).name();
errormessage+="\" was not correctly created.";
throw std::runtime_error(errormessage);
}
}
class MainFrame; class MainFrame;
class wxvbamApp : public wxApp class wxvbamApp : public wxApp