Provide safe API for detecting closing wxTipWindow

Previous API was ugly and suffered from a race condition as the window
could be closed before the constructor returned.

Provide a safer API using weak-pointer-like wxTipWindow::Ref class that
is guaranteed to stop being valid when the tip window is closed.

Also implement two-stage constructions for this class, as usual.

Closes #26070.

Closes #26071.
This commit is contained in:
Bill Su
2026-01-07 15:29:06 +01:00
committed by Vadim Zeitlin
parent 8bfadeeb76
commit 96eca6412e
7 changed files with 253 additions and 20 deletions
+2 -7
View File
@@ -763,10 +763,6 @@ MyFrame::MyFrame(const wxString& title)
SetOwnBackgroundColour(m_canvas->GetBackgroundColour());
#endif // wxUSE_INFOBAR
#if wxUSE_TIPWINDOW
m_tipWindow = nullptr;
#endif // wxUSE_TIPWINDOW
#ifdef __WXMSW__
// Test MSW-specific function allowing to access the "system" menu.
wxMenu * const menu = MSWGetSystemMenu();
@@ -2858,14 +2854,13 @@ void MyFrame::OnShowTip(wxCommandEvent& WXUNUSED(event))
}
else
{
m_tipWindow = new wxTipWindow
m_tipWindow = wxTipWindow::New
(
this,
"This is just some text to be shown in the tip "
"window, broken into multiple lines, each less "
"than 60 logical pixels wide.",
FromDIP(60),
&m_tipWindow
FromDIP(60)
);
}
}