diff --git a/changelog/next.md b/changelog/next.md index 589d7c327..db163aa45 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -15,3 +15,4 @@ - Fixed a crash when quitting or reloading while a `Loader` was still loading asynchronously. - Fixed future `Socket` connection attempts after a failed connection attempt. - Fixed Open wifi networks showing as Unknown security. +- Fixed a crash when capturing screencopy with a null 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 39bc3fc7f..87274129a 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 37ef038aa..9413c9f48 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 927da8dc4..dd61c22f9 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); }