[Fix] Screenshot: null-check presenter before use (fixes F12 crash)
TakeScreenshot() called GetGraphicsSystemPresenter()->CaptureGuestOutput() and only tested the pointer for null AFTER dereferencing it, so taking a screenshot with no live presenter dereferenced null and crashed. Check for null first, and re-enable notifications on the capture-failure path too. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1134,10 +1134,20 @@ void EmulatorWindow::OnMouseUp(const ui::MouseEvent& e) {
|
|||||||
void EmulatorWindow::TakeScreenshot() {
|
void EmulatorWindow::TakeScreenshot() {
|
||||||
xe::ui::RawImage image;
|
xe::ui::RawImage image;
|
||||||
|
|
||||||
|
// Null-check the presenter BEFORE dereferencing it. The original condition
|
||||||
|
// called CaptureGuestOutput() on the pointer and only tested it for null
|
||||||
|
// afterwards, so pressing the screenshot key before/without a live presenter
|
||||||
|
// dereferenced a null pointer and crashed.
|
||||||
|
auto* presenter = GetGraphicsSystemPresenter();
|
||||||
|
if (presenter == nullptr) {
|
||||||
|
XELOGE("No graphics presenter available for screenshot");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
imgui_drawer_->EnableNotifications(false);
|
imgui_drawer_->EnableNotifications(false);
|
||||||
|
|
||||||
if (!GetGraphicsSystemPresenter()->CaptureGuestOutput(image) ||
|
if (!presenter->CaptureGuestOutput(image)) {
|
||||||
GetGraphicsSystemPresenter() == nullptr) {
|
imgui_drawer_->EnableNotifications(true);
|
||||||
XELOGE("Failed to capture guest output for screenshot");
|
XELOGE("Failed to capture guest output for screenshot");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user