Fix WebView sample when there are blank title pages in history

Otherwise, the wxMenu code asserts due to an empty item.
This commit is contained in:
Scott Talbert 2024-02-01 20:39:23 -05:00
parent 1622a5c9c2
commit 3ef1aee986

View file

@ -1215,7 +1215,10 @@ void WebFrame::OnToolsClicked(wxCommandEvent& WXUNUSED(evt))
unsigned int i;
for(i = 0; i < back.size(); i++)
{
item = m_tools_history_menu->AppendRadioItem(wxID_ANY, back[i]->GetTitle());
wxString title = back[i]->GetTitle();
if ( title.empty() )
title = "(untitled)";
item = m_tools_history_menu->AppendRadioItem(wxID_ANY, title);
m_histMenuItems[item->GetId()] = back[i];
Bind(wxEVT_MENU, &WebFrame::OnHistory, this, item->GetId());
}
@ -1231,7 +1234,10 @@ void WebFrame::OnToolsClicked(wxCommandEvent& WXUNUSED(evt))
for(i = 0; i < forward.size(); i++)
{
item = m_tools_history_menu->AppendRadioItem(wxID_ANY, forward[i]->GetTitle());
wxString title = forward[i]->GetTitle();
if ( title.empty() )
title = "(untitled)";
item = m_tools_history_menu->AppendRadioItem(wxID_ANY, title);
m_histMenuItems[item->GetId()] = forward[i];
Bind(wxEVT_TOOL, &WebFrame::OnHistory, this, item->GetId());
}