mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-25 00:43:39 +08:00
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:
@@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user