From 6558cb9ebe3eae7a64d427002a1755ee4fcce222 Mon Sep 17 00:00:00 2001 From: ruevs Date: Fri, 16 Oct 2020 23:35:40 +0300 Subject: [PATCH] Fix crash in solvespace-cli `window` is a `nullptr` with guinone.cpp - avoid dereferencing it. Fixes: https://github.com/solvespace/solvespace/issues/567 --- src/draw.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/draw.cpp b/src/draw.cpp index db2f33e5..1dabd75b 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -305,9 +305,16 @@ void GraphicsWindow::GroupSelection() { Camera GraphicsWindow::GetCamera() const { Camera camera = {}; - window->GetContentSize(&camera.width, &camera.height); - camera.pixelRatio = window->GetDevicePixelRatio(); - camera.gridFit = (window->GetDevicePixelRatio() == 1); + if(window) { + window->GetContentSize(&camera.width, &camera.height); + camera.pixelRatio = window->GetDevicePixelRatio(); + camera.gridFit = (window->GetDevicePixelRatio() == 1); + } else { // solvespace-cli + camera.width = 297.0; // A4? Whatever... + camera.height = 210.0; + camera.pixelRatio = 1.0; + camera.gridFit = camera.pixelRatio == 1.0; + } camera.offset = offset; camera.projUp = projUp; camera.projRight = projRight;