Add null pointer checks for find dialog, get rid of some unintentional segfaults
This commit is contained in:
parent
bc0f97dd0b
commit
4f649b73a7
@ -203,7 +203,10 @@ void MainFrame::BindEvents()
|
||||
Bind(wxEVT_FIND_NEXT, &MainFrame::OnFindDialog, this, wxID_ANY);
|
||||
Bind(wxEVT_FIND_REPLACE, &MainFrame::OnFindDialog, this, wxID_ANY);
|
||||
Bind(wxEVT_FIND_REPLACE_ALL, &MainFrame::OnFindDialog, this, wxID_ANY);
|
||||
Bind(wxEVT_FIND_CLOSE, &MainFrame::OnFindDialog, this, wxID_ANY);
|
||||
this->Bind(wxEVT_FIND_CLOSE, [=](wxFindDialogEvent &event) {
|
||||
wxLogDebug("wxEVT_FIND_CLOSE");
|
||||
event.GetDialog()->Hide();
|
||||
});
|
||||
|
||||
// Language Selection
|
||||
Bind(wxEVT_MENU, &MainFrame::OnLangSelect, this, wxID_ANY);
|
||||
@ -422,9 +425,10 @@ void MainFrame::OnToggleWhitespace(wxCommandEvent& event)
|
||||
*/
|
||||
void MainFrame::OnEditFind(wxCommandEvent &WXUNUSED(event))
|
||||
{
|
||||
if (findDlg)
|
||||
if (this->findDlg != nullptr)
|
||||
{
|
||||
wxDELETE(findDlg);
|
||||
wxDELETE(this->findDlg);
|
||||
wxDELETE(this->findData);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -441,9 +445,10 @@ void MainFrame::OnEditFind(wxCommandEvent &WXUNUSED(event))
|
||||
*/
|
||||
void MainFrame::OnEditReplace(wxCommandEvent &WXUNUSED(event))
|
||||
{
|
||||
if (replaceDlg)
|
||||
if (this->replaceDlg != nullptr)
|
||||
{
|
||||
wxDELETE(replaceDlg);
|
||||
wxDELETE(this->replaceDlg);
|
||||
wxDELETE(this->findReplaceData);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -483,10 +488,10 @@ void MainFrame::OnFindDialog(wxFindDialogEvent &event)
|
||||
{
|
||||
wxLogDebug("wxEVT_FIND");
|
||||
|
||||
/*if (editor->GetCurrentPos() < 1)
|
||||
if (editor->GetCurrentPos() < 0 || editor->GetCurrentPos() > editor->GetLastPosition())
|
||||
{
|
||||
editor->GotoPos(1);
|
||||
}*/
|
||||
}
|
||||
|
||||
editor->SearchAnchor();
|
||||
}
|
||||
@ -534,11 +539,6 @@ void MainFrame::OnFindDialog(wxFindDialogEvent &event)
|
||||
{
|
||||
wxLogDebug("wxEVT_FIND_REPLACE_ALL");
|
||||
}
|
||||
else if (type == wxEVT_FIND_CLOSE)
|
||||
{
|
||||
wxLogDebug("wxEVT_FIND_CLOSE");
|
||||
event.GetDialog()->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,10 +18,10 @@ class MainFrame: public wxFrame
|
||||
private:
|
||||
wxAuiManager *manager;
|
||||
wxAuiToolBar *toolBar;
|
||||
wxFindReplaceData *findReplaceData;
|
||||
wxFindReplaceData *findData;
|
||||
wxFindReplaceDialog *findDlg;
|
||||
wxFindReplaceDialog *replaceDlg;
|
||||
wxFindReplaceData *findReplaceData = nullptr;
|
||||
wxFindReplaceData *findData = nullptr;
|
||||
wxFindReplaceDialog *findDlg = nullptr;
|
||||
wxFindReplaceDialog *replaceDlg = nullptr;
|
||||
void SetupToolbar();
|
||||
void SetupStatusBar();
|
||||
void BindEvents();
|
||||
|
Loading…
Reference in New Issue
Block a user