chart2/source/controller/sidebar/ChartColorPaletteControl.cxx |    2 +-
 chart2/source/tools/ChartColorPalettes.cxx                    |    2 +-
 cui/source/dialogs/screenshotannotationdlg.cxx                |    2 +-
 desktop/source/lib/init.cxx                                   |    4 ++--
 filter/source/msfilter/msdffimp.cxx                           |    2 +-
 sc/source/ui/attrdlg/scdlgfact.cxx                            |    2 +-
 sd/source/ui/dlg/sddlgfact.cxx                                |    2 +-
 sfx2/source/dialog/tabdlg.cxx                                 |    2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

New commits:
commit d8bf4ddc6dabceb35a9b860c2e3b0801edc38665
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sat Feb 21 17:59:16 2026 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sat Feb 21 18:51:04 2026 +0100

    fix assorted VirtualDevice GDI handle leaks
    
    Similar to commit e9392c0c86fcf373e00ede92f8ceeee2c7efd233 (fix
    VirtualDevice GDI handle leaks across IconView callers, 2026-02-21).
    
    Change-Id: Idae4f9e5fba0d5c46d32e35da5f84716616f59ba
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199936
    Reviewed-by: Andras Timar <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199948
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/chart2/source/controller/sidebar/ChartColorPaletteControl.cxx 
b/chart2/source/controller/sidebar/ChartColorPaletteControl.cxx
index c261d05cbc31..bd953d7d79bd 100644
--- a/chart2/source/controller/sidebar/ChartColorPaletteControl.cxx
+++ b/chart2/source/controller/sidebar/ChartColorPaletteControl.cxx
@@ -111,7 +111,7 @@ void ChartColorPaletteControl::updateStatus(bool bForce)
         if (!getToolboxId(nId, &pToolBox) && !m_pToolbar)
             return;
 
-        auto pDev = VclPtr<VirtualDevice>::Create();
+        ScopedVclPtrInstance<VirtualDevice> pDev;
         renderSelectedColorPalette(pDev);
         auto aSelItemImg(pDev->GetBitmap(Point(), pDev->GetOutputSizePixel()));
         if (m_pToolbar)
diff --git a/chart2/source/tools/ChartColorPalettes.cxx 
b/chart2/source/tools/ChartColorPalettes.cxx
index c66a1d07bac3..ce77d7268f52 100644
--- a/chart2/source/tools/ChartColorPalettes.cxx
+++ b/chart2/source/tools/ChartColorPalettes.cxx
@@ -80,7 +80,7 @@ void ChartColorPalettes::Fill()
 
     mxIconView->freeze();
 
-    VclPtr<VirtualDevice> pVDev = VclPtr<VirtualDevice>::Create();
+    ScopedVclPtrInstance<VirtualDevice> pVDev;
     pVDev->SetOutputSizePixel(aSize);
 
     tools::Rectangle aDrawArea(0, 0, aSize.getWidth(), aSize.getHeight());
diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx 
b/cui/source/dialogs/screenshotannotationdlg.cxx
index e2763c95cd8e..3842ef0d108b 100644
--- a/cui/source/dialogs/screenshotannotationdlg.cxx
+++ b/cui/source/dialogs/screenshotannotationdlg.cxx
@@ -257,7 +257,7 @@ ScreenshotAnnotationDlg_Impl::ScreenshotAnnotationDlg_Impl(
     maPicture(this),
     maSaveAsText(CuiResId(RID_CUISTR_SAVE_SCREENSHOT_AS))
 {
-    VclPtr<VirtualDevice> xParentDialogSurface(rParentDialog.screenshot());
+    ScopedVclPtr<VirtualDevice> 
xParentDialogSurface(rParentDialog.screenshot());
     maParentDialogSize = xParentDialogSurface->GetOutputSizePixel();
     maParentDialogBitmap = xParentDialogSurface->GetBitmap(Point(), 
maParentDialogSize);
     maDimmedDialogBitmap = maParentDialogBitmap;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 85b8cc574a86..9c54b4d43aa9 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -6575,7 +6575,7 @@ static char* getFontSubset (std::string_view aFontName)
     if (const vcl::Font* pFont = FindFont(aFoundFont))
     {
         FontCharMapRef xFontCharMap (new FontCharMap());
-        auto 
aDevice(VclPtr<VirtualDevice>::Create(DeviceFormat::WITHOUT_ALPHA));
+        ScopedVclPtrInstance<VirtualDevice> 
aDevice(DeviceFormat::WITHOUT_ALPHA);
 
         aDevice->SetFont(*pFont);
         aDevice->GetFontCharMap(xFontCharMap);
@@ -7268,7 +7268,7 @@ unsigned char* 
doc_renderFontOrientation(SAL_UNUSED_PARAMETER LibreOfficeKitDocu
     if (aText.isEmpty())
         aText = aFont.GetFamilyName();
 
-    auto aDevice(VclPtr<VirtualDevice>::Create(DeviceFormat::WITHOUT_ALPHA));
+    ScopedVclPtrInstance<VirtualDevice> aDevice(DeviceFormat::WITHOUT_ALPHA);
     ::tools::Rectangle aRect;
     aFont.SetFontSize(Size(0, nDefaultFontSize));
     aFont.SetOrientation(Degree10(pOrientation));
diff --git a/filter/source/msfilter/msdffimp.cxx 
b/filter/source/msfilter/msdffimp.cxx
index 3e027ebf5faf..e51a3d200236 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -4524,7 +4524,7 @@ rtl::Reference<SdrObject> SvxMSDffManager::ImportShape( 
const DffRecordHeader& r
                         if ( bWithPadding )
                         {
                             // trim, remove additional space
-                            VclPtr<VirtualDevice> pDevice = 
VclPtr<VirtualDevice>::Create();
+                            ScopedVclPtrInstance<VirtualDevice> pDevice;
                             vcl::Font aFont = pDevice->GetFont();
                             aFont.SetFamilyName( aFontName );
                             aFont.SetFontSize( Size( 0, 96 ) );
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx 
b/sc/source/ui/attrdlg/scdlgfact.cxx
index d87d1af47eef..d2fa109d8266 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -85,7 +85,7 @@ public:
     // screenshotting
     Bitmap createScreenshot() const override
     {
-        VclPtr<VirtualDevice> 
xDialogSurface(this->m_pDlg->getDialog()->screenshot());
+        ScopedVclPtr<VirtualDevice> 
xDialogSurface(this->m_pDlg->getDialog()->screenshot());
         return xDialogSurface->GetBitmap(Point(), 
xDialogSurface->GetOutputSizePixel());
     }
     OUString GetScreenshotId() const override { return 
this->m_pDlg->get_help_id(); }
diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx
index 2553ae906edb..b0f599e1a810 100644
--- a/sd/source/ui/dlg/sddlgfact.cxx
+++ b/sd/source/ui/dlg/sddlgfact.cxx
@@ -58,7 +58,7 @@ public:
     // screenshotting
     Bitmap createScreenshot() const override
     {
-        VclPtr<VirtualDevice> 
xDialogSurface(this->m_pDlg->getDialog()->screenshot());
+        ScopedVclPtr<VirtualDevice> 
xDialogSurface(this->m_pDlg->getDialog()->screenshot());
         return xDialogSurface->GetBitmap(Point(), 
xDialogSurface->GetOutputSizePixel());
     }
     OUString GetScreenshotId() const override { return 
this->m_pDlg->get_help_id(); }
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index e31f00ad6a0e..fc4ee36d5cb0 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -1199,7 +1199,7 @@ Bitmap SfxTabDialogController::createScreenshot() const
         const_cast<SfxTabDialogController*>(this)->Start_Impl();
     }
 
-    VclPtr<VirtualDevice> xDialogSurface(m_xDialog->screenshot());
+    ScopedVclPtr<VirtualDevice> xDialogSurface(m_xDialog->screenshot());
     return xDialogSurface->GetBitmap(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 

Reply via email to