diff --git a/changelog/next.md b/changelog/next.md index 40da6fe..c2cf52a 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -4,3 +4,4 @@ - Fixed Hyprland workspaces keeping their old id after Hyprland changes it. - Fixed desktop entries being parsed incorrectly with trailing whitespace or CRLF line endings. - Fixed `WlSessionLock.locked` changes not being emitted on unlock. +- Fixed a crash when unplugging a screen being captured by ScreencopyView or trying to capture the fallback screen. diff --git a/src/wayland/screencopy/image_copy_capture/image_copy_capture.cpp b/src/wayland/screencopy/image_copy_capture/image_copy_capture.cpp index 39bc3fc..8727412 100644 --- a/src/wayland/screencopy/image_copy_capture/image_copy_capture.cpp +++ b/src/wayland/screencopy/image_copy_capture/image_copy_capture.cpp @@ -220,6 +220,8 @@ IccOutputSourceManager* IccOutputSourceManager::instance() { } ScreencopyContext* IccOutputSourceManager::captureOutput(QScreen* screen, bool paintCursors) { + if (screen == nullptr) return nullptr; + auto* waylandScreen = dynamic_cast(screen->handle()); if (!waylandScreen) return nullptr; diff --git a/src/wayland/screencopy/manager.cpp b/src/wayland/screencopy/manager.cpp index 37ef038..9413c9f 100644 --- a/src/wayland/screencopy/manager.cpp +++ b/src/wayland/screencopy/manager.cpp @@ -25,6 +25,8 @@ namespace qs::wayland::screencopy { ScreencopyContext* ScreencopyManager::createContext(QObject* object, bool paintCursors) { if (auto* screen = qobject_cast(object)) { + if (screen->screen == nullptr) return nullptr; + #if SCREENCOPY_ICC { auto* manager = icc::IccOutputSourceManager::instance(); diff --git a/src/wayland/screencopy/wlr_screencopy/wlr_screencopy.cpp b/src/wayland/screencopy/wlr_screencopy/wlr_screencopy.cpp index 927da8d..dd61c22 100644 --- a/src/wayland/screencopy/wlr_screencopy/wlr_screencopy.cpp +++ b/src/wayland/screencopy/wlr_screencopy/wlr_screencopy.cpp @@ -34,6 +34,7 @@ WlrScreencopyManager* WlrScreencopyManager::instance() { ScreencopyContext* WlrScreencopyManager::captureOutput(QScreen* screen, bool paintCursors, QRect region) { + if (screen == nullptr) return nullptr; if (!dynamic_cast(screen->handle())) return nullptr; return new WlrScreencopyContext(this, screen, paintCursors, region); }