Avoid modal HTML help after missing topic

Only make wxHtmlHelpController window modal after a display operation
succeeds, so a failed topic lookup can fall through to a fallback topic
without showing a modal help frame.

Add a regression test covering a modal help dialog display request for a
missing topic.

Fixes #3219.

Closes #26860.
This commit is contained in:
Richard
2026-08-17 19:40:50 +02:00
committed by Vadim Zeitlin
parent 269024aa54
commit 255d7ef061
2 changed files with 49 additions and 5 deletions
+10 -5
View File
@@ -405,7 +405,8 @@ bool wxHtmlHelpController::Display(const wxString& x)
{
CreateHelpWindow();
bool success = m_helpWindow->Display(x);
MakeModalIfNeeded();
if ( success )
MakeModalIfNeeded();
return success;
}
@@ -413,7 +414,8 @@ bool wxHtmlHelpController::Display(int id)
{
CreateHelpWindow();
bool success = m_helpWindow->Display(id);
MakeModalIfNeeded();
if ( success )
MakeModalIfNeeded();
return success;
}
@@ -421,7 +423,8 @@ bool wxHtmlHelpController::DisplayContents()
{
CreateHelpWindow();
bool success = m_helpWindow->DisplayContents();
MakeModalIfNeeded();
if ( success )
MakeModalIfNeeded();
return success;
}
@@ -429,7 +432,8 @@ bool wxHtmlHelpController::DisplayIndex()
{
CreateHelpWindow();
bool success = m_helpWindow->DisplayIndex();
MakeModalIfNeeded();
if ( success )
MakeModalIfNeeded();
return success;
}
@@ -438,7 +442,8 @@ bool wxHtmlHelpController::KeywordSearch(const wxString& keyword,
{
CreateHelpWindow();
bool success = m_helpWindow->KeywordSearch(keyword, mode);
MakeModalIfNeeded();
if ( success )
MakeModalIfNeeded();
return success;
}
+39
View File
@@ -17,8 +17,11 @@
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/timer.h"
#endif // WX_PRECOMP
#include "wx/html/helpctrl.h"
#include "wx/html/helpdlg.h"
#include "wx/html/htmlwin.h"
#include "wx/uiaction.h"
#include "testableframe.h"
@@ -43,6 +46,9 @@ private:
WXUISIM_TEST( CellClick );
WXUISIM_TEST( LinkClick );
#endif // wxUSE_UIACTIONSIMULATOR
#if wxUSE_WXHTML_HELP
CPPUNIT_TEST( DisplayMissingHelpTopic );
#endif // wxUSE_WXHTML_HELP
CPPUNIT_TEST( ImageMapCoordinates );
CPPUNIT_TEST( AppendToPage );
CPPUNIT_TEST_SUITE_END();
@@ -51,6 +57,9 @@ private:
void Title();
void CellClick();
void LinkClick();
#if wxUSE_WXHTML_HELP
void DisplayMissingHelpTopic();
#endif // wxUSE_WXHTML_HELP
void ImageMapCoordinates();
void AppendToPage();
@@ -110,6 +119,36 @@ static const char *TEST_MARKUP_IMAGEMAP =
"</map>"
"</body></html>";
#if wxUSE_WXHTML_HELP
class CloseModalHelpDialogTimer : public wxTimer
{
public:
CloseModalHelpDialogTimer(wxHtmlHelpController& controller)
: m_controller(controller),
m_modalShown(false)
{
}
bool WasModalShown() const { return m_modalShown; }
private:
virtual void Notify() override
{
wxHtmlHelpDialog *dialog = m_controller.GetDialog();
if ( dialog && dialog->IsModal() )
{
m_modalShown = true;
dialog->EndModal(wxID_CANCEL);
}
}
wxHtmlHelpController& m_controller;
bool m_modalShown;
};
#endif // wxUSE_WXHTML_HELP
static wxHtmlCell *FindCellWithLink(wxHtmlCell *cell, wxPoint *pos)
{
if ( !cell->GetFirstChild() )