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_NEXT, &MainFrame::OnFindDialog, this, wxID_ANY);
|
||||||
Bind(wxEVT_FIND_REPLACE, &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_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
|
// Language Selection
|
||||||
Bind(wxEVT_MENU, &MainFrame::OnLangSelect, this, wxID_ANY);
|
Bind(wxEVT_MENU, &MainFrame::OnLangSelect, this, wxID_ANY);
|
||||||
@ -422,9 +425,10 @@ void MainFrame::OnToggleWhitespace(wxCommandEvent& event)
|
|||||||
*/
|
*/
|
||||||
void MainFrame::OnEditFind(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnEditFind(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (findDlg)
|
if (this->findDlg != nullptr)
|
||||||
{
|
{
|
||||||
wxDELETE(findDlg);
|
wxDELETE(this->findDlg);
|
||||||
|
wxDELETE(this->findData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -441,9 +445,10 @@ void MainFrame::OnEditFind(wxCommandEvent &WXUNUSED(event))
|
|||||||
*/
|
*/
|
||||||
void MainFrame::OnEditReplace(wxCommandEvent &WXUNUSED(event))
|
void MainFrame::OnEditReplace(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (replaceDlg)
|
if (this->replaceDlg != nullptr)
|
||||||
{
|
{
|
||||||
wxDELETE(replaceDlg);
|
wxDELETE(this->replaceDlg);
|
||||||
|
wxDELETE(this->findReplaceData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -483,10 +488,10 @@ void MainFrame::OnFindDialog(wxFindDialogEvent &event)
|
|||||||
{
|
{
|
||||||
wxLogDebug("wxEVT_FIND");
|
wxLogDebug("wxEVT_FIND");
|
||||||
|
|
||||||
/*if (editor->GetCurrentPos() < 1)
|
if (editor->GetCurrentPos() < 0 || editor->GetCurrentPos() > editor->GetLastPosition())
|
||||||
{
|
{
|
||||||
editor->GotoPos(1);
|
editor->GotoPos(1);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
editor->SearchAnchor();
|
editor->SearchAnchor();
|
||||||
}
|
}
|
||||||
@ -534,11 +539,6 @@ void MainFrame::OnFindDialog(wxFindDialogEvent &event)
|
|||||||
{
|
{
|
||||||
wxLogDebug("wxEVT_FIND_REPLACE_ALL");
|
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:
|
private:
|
||||||
wxAuiManager *manager;
|
wxAuiManager *manager;
|
||||||
wxAuiToolBar *toolBar;
|
wxAuiToolBar *toolBar;
|
||||||
wxFindReplaceData *findReplaceData;
|
wxFindReplaceData *findReplaceData = nullptr;
|
||||||
wxFindReplaceData *findData;
|
wxFindReplaceData *findData = nullptr;
|
||||||
wxFindReplaceDialog *findDlg;
|
wxFindReplaceDialog *findDlg = nullptr;
|
||||||
wxFindReplaceDialog *replaceDlg;
|
wxFindReplaceDialog *replaceDlg = nullptr;
|
||||||
void SetupToolbar();
|
void SetupToolbar();
|
||||||
void SetupStatusBar();
|
void SetupStatusBar();
|
||||||
void BindEvents();
|
void BindEvents();
|
||||||
|
Loading…
Reference in New Issue
Block a user