Reuse a single dialog instance attached to ``parent``. Storing the dialog on the main window avoids accidental garbage collection and prevents opening a pile of duplicate windows.
(
*,
parent: QWidget,
title: str,
text_provider: Callable[[], str],
text_hint: str,
attr_name: str = "_dlc_debug_dialog",
)
| 202 | |
| 203 | |
| 204 | def _get_or_create_debug_dialog( |
| 205 | *, |
| 206 | parent: QWidget, |
| 207 | title: str, |
| 208 | text_provider: Callable[[], str], |
| 209 | text_hint: str, |
| 210 | attr_name: str = "_dlc_debug_dialog", |
| 211 | ) -> DebugTextDialog: |
| 212 | """ |
| 213 | Reuse a single dialog instance attached to ``parent``. |
| 214 | |
| 215 | Storing the dialog on the main window avoids accidental garbage collection |
| 216 | and prevents opening a pile of duplicate windows. |
| 217 | """ |
| 218 | dlg = getattr(parent, attr_name, None) |
| 219 | if isinstance(dlg, DebugTextDialog): |
| 220 | dlg.update_content( |
| 221 | title=title, |
| 222 | text_provider=text_provider, |
| 223 | hint=text_hint, |
| 224 | ) |
| 225 | return dlg |
| 226 | |
| 227 | dlg = DebugTextDialog( |
| 228 | title=title, |
| 229 | text_provider=text_provider, |
| 230 | parent=parent, |
| 231 | initial_hint=text_hint, |
| 232 | ) |
| 233 | setattr(parent, attr_name, dlg) |
| 234 | return dlg |
| 235 | |
| 236 | |
| 237 | def show_debug_report_dialog( |
no test coverage detected