From 3ef1aee9864f7f11fe7e6d4313fcfd2aea005a48 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Thu, 1 Feb 2024 20:39:23 -0500 Subject: [PATCH] Fix WebView sample when there are blank title pages in history Otherwise, the wxMenu code asserts due to an empty item. --- samples/webview/webview.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/samples/webview/webview.cpp b/samples/webview/webview.cpp index e0d08c3c17..eec43c479b 100644 --- a/samples/webview/webview.cpp +++ b/samples/webview/webview.cpp @@ -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()); }