From 07ceea48cead8293e85623e4e0825fad5b0d3993 Mon Sep 17 00:00:00 2001 From: Aleksei Nikiforov Date: Mon, 20 Sep 2021 11:25:45 +0300 Subject: [PATCH 1/3] tdf#144624 Prevent infinite recursion when loading SVG icon When Generic/X11 VCL backend plugin loads SVG icon, it creates virtual device for rasterizing an SVG icon, which in turn tries to load an SVG icon, and thus infinite recursion happens. Change-Id: I7559b6255e6718e64ef4a6e7c79d597375e5823a --- include/tools/wintypes.hxx | 2 ++ include/vcl/svapp.hxx | 2 +- vcl/inc/salframe.hxx | 4 +++- vcl/inc/svdata.hxx | 4 ++-- vcl/source/app/svapp.cxx | 4 ++-- vcl/source/app/svdata.cxx | 8 ++++---- vcl/source/gdi/virdev.cxx | 2 +- vcl/source/window/brdwin.cxx | 2 +- vcl/source/window/window.cxx | 3 +++ vcl/unx/generic/window/salframe.cxx | 2 +- 10 files changed, 20 insertions(+), 13 deletions(-) diff --git a/include/tools/wintypes.hxx b/include/tools/wintypes.hxx index fcccd9a0d0fa..1bc51788a572 100644 --- a/include/tools/wintypes.hxx +++ b/include/tools/wintypes.hxx @@ -229,6 +229,8 @@ WinBits const WB_NOINITIALSELECTION = SAL_CONST_INT64(0x001000000000); WinBits const WB_HIDESELECTION = SAL_CONST_INT64(0x002000000000); // DO NOT USE: 0x008000000000, that's WB_SYSTEMCHILDWINDOW +// tdf#144624: special bit used to skip assigning icon to virtual window +WinBits const WB_NOICON = SAL_CONST_INT64(0x200000000000); enum class WindowAlign { Left, Top, Right, Bottom }; diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index ab2af42dc41c..f5b6cc704faf 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -824,7 +824,7 @@ public: @see GetFocusWindow */ - static OutputDevice* GetDefaultDevice(); + static OutputDevice* GetDefaultDevice(bool bUseIcon = true); /** Get the first top-level window of the application. diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index 105fe8f91cfc..511a25934676 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -426,8 +426,8 @@ css::uno::Reference const& ImplGetCharClass void ImplDeInitSVData(); VCL_PLUGIN_PUBLIC basegfx::SystemDependentDataManager& ImplGetSystemDependentDataManager(); -VCL_PLUGIN_PUBLIC vcl::Window* ImplGetDefaultWindow(); -vcl::Window* ImplGetDefaultContextWindow(); +VCL_PLUGIN_PUBLIC vcl::Window* ImplGetDefaultWindow(bool bUseIcon = true); +vcl::Window* ImplGetDefaultContextWindow(bool bUseIcon = true); const std::locale& ImplGetResLocale(); VCL_PLUGIN_PUBLIC OUString VclResId(const char* pId); DockingManager* ImplGetDockingManager(); diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 79d6dfa9c146..33a4b9536a05 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -1066,9 +1066,9 @@ vcl::Window* Application::GetFocusWindow() return ImplGetSVData()->mpWinData->mpFocusWin; } -OutputDevice* Application::GetDefaultDevice() +OutputDevice* Application::GetDefaultDevice(bool bUseIcon) { - return ImplGetDefaultWindow()->GetOutDev(); + return ImplGetDefaultWindow(bUseIcon)->GetOutDev(); } vcl::Window* Application::GetFirstTopLevelWindow() diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx index ba5fce26278a..20d4e6889f81 100644 --- a/vcl/source/app/svdata.cxx +++ b/vcl/source/app/svdata.cxx @@ -207,17 +207,17 @@ basegfx::SystemDependentDataManager& ImplGetSystemDependentDataManager() } /// Returns either the application window, or the default GL context window -vcl::Window* ImplGetDefaultWindow() +vcl::Window* ImplGetDefaultWindow(bool bUseIcon) { ImplSVData* pSVData = ImplGetSVData(); if (pSVData->maFrameData.mpAppWin) return pSVData->maFrameData.mpAppWin; else - return ImplGetDefaultContextWindow(); + return ImplGetDefaultContextWindow(bUseIcon); } /// returns the default window created to hold the persistent VCL GL context. -vcl::Window *ImplGetDefaultContextWindow() +vcl::Window *ImplGetDefaultContextWindow(bool bUseIcon) { ImplSVData* pSVData = ImplGetSVData(); @@ -232,7 +232,7 @@ vcl::Window *ImplGetDefaultContextWindow() { SAL_INFO( "vcl", "ImplGetDefaultWindow(): No AppWindow" ); - pSVData->mpDefaultWin = VclPtr::Create(nullptr, WB_DEFAULTWIN); + pSVData->mpDefaultWin = VclPtr::Create(nullptr, bUseIcon ? WB_DEFAULTWIN : WB_DEFAULTWIN | WB_NOICON); pSVData->mpDefaultWin->SetText( "VCL ImplGetDefaultWindow" ); } catch (const css::uno::Exception&) diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index f6b7d443b307..81b92be9b715 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -202,7 +202,7 @@ VirtualDevice::VirtualDevice(const OutputDevice* pCompDev, DeviceFormat eFormat, << ", " << static_cast(eAlphaFormat) << ", " << static_cast(eOutDevType) << " )" ); - ImplInitVirDev(pCompDev ? pCompDev : Application::GetDefaultDevice(), 0, 0); + ImplInitVirDev(pCompDev ? pCompDev : Application::GetDefaultDevice(false), 0, 0); } VirtualDevice::VirtualDevice(const SystemGraphicsData& rData, const Size &rSize, diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx index 3fd3503dab80..0f7330ee1331 100644 --- a/vcl/source/window/brdwin.cxx +++ b/vcl/source/window/brdwin.cxx @@ -1499,7 +1499,7 @@ void ImplBorderWindow::ImplInit( vcl::Window* pParent, { // remove all unwanted WindowBits WinBits nOrgStyle = nStyle; - WinBits nTestStyle = (WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE | WB_STANDALONE | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_SYSTEMFLOATWIN | WB_INTROWIN | WB_DEFAULTWIN | WB_TOOLTIPWIN | WB_NOSHADOW | WB_OWNERDRAWDECORATION | WB_SYSTEMCHILDWINDOW | WB_POPUP); + WinBits nTestStyle = (WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE | WB_STANDALONE | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_SYSTEMFLOATWIN | WB_INTROWIN | WB_DEFAULTWIN | WB_TOOLTIPWIN | WB_NOSHADOW | WB_OWNERDRAWDECORATION | WB_SYSTEMCHILDWINDOW | WB_POPUP | WB_NOICON); if ( nTypeStyle & BorderWindowStyle::App ) nTestStyle |= WB_APP; nStyle &= nTestStyle; diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index fa029f89400f..732449a9423e 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -1032,6 +1032,9 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p break; } + if( nStyle & WB_NOICON ) + nFrameStyle |= SalFrameStyleFlags::NOICON; + SalFrame* pParentFrame = nullptr; if ( pParent ) pParentFrame = pParent->mpWindowImpl->mpFrame;