vcl/source/app/svapp.cxx           |   10 +++++++++-
 vcl/source/image/ImplImageTree.cxx |    5 +++--
 2 files changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 8f6dd15dce1e6116947b512c89d802fccc0bd6f1
Author:     Tarcísio Ladeia de Oliveira <wyrqu...@gmail.com>
AuthorDate: Sat Nov 26 16:55:27 2022 -0300
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Dec 8 09:51:30 2022 +0000

    vcl: check for null device
    
    The xmloff/draw test series was crashing soon after "testTextBoxLoss"
    finished. Even though it finished successfully, CppUnitTest was crashing
    when popping the protector. From the backtrace, the crash resulted from
    attempts to access null pointers.
    
    I do not know what caused those pointers to be null, but I added the
    checks so that it could at least proceed to the other tests.
    
    Change-Id: Ia0014a273142442a791a43fb9e3f75c2452bbd45
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143332
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 6dfa35c61551..d2c6294917f0 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1165,7 +1165,15 @@ vcl::Window* Application::GetFocusWindow()
 
 OutputDevice* Application::GetDefaultDevice()
 {
-    return ImplGetDefaultWindow()->GetOutDev();
+    vcl::Window* pWindow = ImplGetDefaultWindow();
+    if (pWindow != nullptr)
+    {
+        return pWindow->GetOutDev();
+    }
+    else
+    {
+        return nullptr;
+    }
 }
 
 basegfx::SystemDependentDataManager& 
Application::GetSystemDependentDataManager()
diff --git a/vcl/source/image/ImplImageTree.cxx 
b/vcl/source/image/ImplImageTree.cxx
index 549d0739139b..bdd4fcedfda5 100644
--- a/vcl/source/image/ImplImageTree.cxx
+++ b/vcl/source/image/ImplImageTree.cxx
@@ -75,8 +75,9 @@ bool ImageRequestParameters::convertToDarkTheme()
 sal_Int32 ImageRequestParameters::scalePercentage()
 {
     sal_Int32 aScalePercentage = 100;
-    if (!(meFlags & ImageLoadFlags::IgnoreScalingFactor))
-        aScalePercentage = 
Application::GetDefaultDevice()->GetDPIScalePercentage();
+    OutputDevice* pDevice = Application::GetDefaultDevice();
+    if (!(meFlags & ImageLoadFlags::IgnoreScalingFactor) && pDevice != nullptr)
+        aScalePercentage = pDevice->GetDPIScalePercentage();
     else if (mnScalePercentage > 0)
         aScalePercentage = mnScalePercentage;
     return aScalePercentage;

Reply via email to