After moving a QRhiWidget between top-level windows, force a fresh initialize() cycle so Metal binds to the new NSView. The backing-store notification is sent before the actual reparent; sending it again here can make QRhiWidget remove a stale cleanup callback from the wrong QRhi during startup floating restore.
| 18 | // before the actual reparent; sending it again here can make QRhiWidget remove a |
| 19 | // stale cleanup callback from the wrong QRhi during startup floating restore. |
| 20 | static void refreshAfterReparent(AetherSDR::SpectrumWidget* sw) |
| 21 | { |
| 22 | if (!sw) return; |
| 23 | #if defined(Q_OS_MAC) && defined(AETHER_GPU_SPECTRUM) |
| 24 | const bool wasVisible = sw->isVisible(); |
| 25 | sw->hide(); |
| 26 | sw->resetGpuResources(); |
| 27 | if (QWindow* windowHandle = sw->windowHandle()) { |
| 28 | windowHandle->destroy(); |
| 29 | } |
| 30 | if (AetherSDR::SpectrumWidget::nativeWindowPreferred()) { |
| 31 | sw->setAttribute(Qt::WA_NativeWindow); |
| 32 | } |
| 33 | if (wasVisible) { |
| 34 | sw->show(); |
| 35 | } |
| 36 | QTimer::singleShot(50, sw, [sw]() { sw->update(); }); |
| 37 | #else |
| 38 | sw->resetGpuResources(); |
| 39 | #endif |
| 40 | } |
| 41 | |
| 42 | namespace AetherSDR { |
| 43 |
no test coverage detected