chart2/source/controller/sidebar/ChartColorPaletteControl.cxx    |    2 
 chart2/source/controller/sidebar/ChartGradientPaletteControl.cxx |    2 
 chart2/source/controller/sidebar/ChartThemeControl.cxx           |    2 
 chart2/source/tools/ChartColorPalettes.cxx                       |    2 
 chart2/source/tools/ChartGradientPalettes.cxx                    |    2 
 cui/source/dialogs/screenshotannotationdlg.cxx                   |    2 
 cui/source/inc/cuitabarea.hxx                                    |    2 
 cui/source/tabpages/tppattern.cxx                                |    8 +-
 desktop/source/lib/init.cxx                                      |    4 -
 filter/source/msfilter/msdffimp.cxx                              |    2 
 sc/source/ui/attrdlg/scdlgfact.cxx                               |   28 
++++----
 sd/source/ui/dlg/sddlgfact.cxx                                   |   34 
+++++-----
 sfx2/source/dialog/tabdlg.cxx                                    |    2 
 starmath/inc/dialog.hxx                                          |    2 
 14 files changed, 47 insertions(+), 47 deletions(-)

New commits:
commit 2087252b45eefd4bfe81fd71ec59f106a26d48a6
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sat Feb 21 18:37:35 2026 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sat Feb 21 16:12:20 2026 +0100

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

diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx
index 521b6fe93dfd..b681b1943138 100644
--- a/starmath/inc/dialog.hxx
+++ b/starmath/inc/dialog.hxx
@@ -403,7 +403,7 @@ public:
 
 class SmSymDefineDialog final : public weld::GenericDialogController
 {
-    VclPtr<VirtualDevice> m_xVirDev;
+    ScopedVclPtr<VirtualDevice> m_xVirDev;
     SmSymbolManager m_aSymbolMgrCopy;
     SmSymbolManager& m_rSymbolMgr;
     SmShowChar m_aOldSymbolDisplay;
commit 94950ce4b72ec60fc6307255b55817a6422e832e
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sat Feb 21 17:59:16 2026 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sat Feb 21 16:12:12 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]>

diff --git a/chart2/source/controller/sidebar/ChartColorPaletteControl.cxx 
b/chart2/source/controller/sidebar/ChartColorPaletteControl.cxx
index 6203c852a744..1e20f855a4e1 100644
--- a/chart2/source/controller/sidebar/ChartColorPaletteControl.cxx
+++ b/chart2/source/controller/sidebar/ChartColorPaletteControl.cxx
@@ -114,7 +114,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->GetBitmapEx(Point(), 
pDev->GetOutputSizePixel()));
         if (m_pToolbar)
diff --git a/chart2/source/controller/sidebar/ChartGradientPaletteControl.cxx 
b/chart2/source/controller/sidebar/ChartGradientPaletteControl.cxx
index 1b7aa33509fc..14e70bd77a17 100644
--- a/chart2/source/controller/sidebar/ChartGradientPaletteControl.cxx
+++ b/chart2/source/controller/sidebar/ChartGradientPaletteControl.cxx
@@ -105,7 +105,7 @@ void ChartGradientPaletteControl::updateStatus(bool bForce)
         if (!getToolboxId(nId, &pToolBox) && !m_pToolbar)
             return;
 
-        auto pDev = VclPtr<VirtualDevice>::Create();
+        ScopedVclPtrInstance<VirtualDevice> pDev;
         renderSelectedGradientPalette(pDev);
         auto aSelItemImg(pDev->GetBitmapEx(Point(), 
pDev->GetOutputSizePixel()));
         if (m_pToolbar)
diff --git a/chart2/source/controller/sidebar/ChartThemeControl.cxx 
b/chart2/source/controller/sidebar/ChartThemeControl.cxx
index 84627f1ba15c..531fe569f631 100644
--- a/chart2/source/controller/sidebar/ChartThemeControl.cxx
+++ b/chart2/source/controller/sidebar/ChartThemeControl.cxx
@@ -105,7 +105,7 @@ void ChartThemeControl::updateStatus(bool bForce)
         if (!getToolboxId(nId, &pToolBox) && !m_pToolbar)
             return;
 
-        auto pDev = VclPtr<VirtualDevice>::Create();
+        ScopedVclPtrInstance<VirtualDevice> pDev;
         // render the actual chart into pDev
         auto aSelItemImg(pDev->GetBitmapEx(Point(), 
pDev->GetOutputSizePixel()));
         if (m_pToolbar)
diff --git a/chart2/source/tools/ChartColorPalettes.cxx 
b/chart2/source/tools/ChartColorPalettes.cxx
index 48fa01d4860c..39150b8ab9b7 100644
--- a/chart2/source/tools/ChartColorPalettes.cxx
+++ b/chart2/source/tools/ChartColorPalettes.cxx
@@ -81,7 +81,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/chart2/source/tools/ChartGradientPalettes.cxx 
b/chart2/source/tools/ChartGradientPalettes.cxx
index 824b6a6a835d..f2c5a2728265 100644
--- a/chart2/source/tools/ChartGradientPalettes.cxx
+++ b/chart2/source/tools/ChartGradientPalettes.cxx
@@ -87,7 +87,7 @@ void ChartGradientPalettes::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 4fc295f84286..52e70a6f3c02 100644
--- a/cui/source/dialogs/screenshotannotationdlg.cxx
+++ b/cui/source/dialogs/screenshotannotationdlg.cxx
@@ -204,7 +204,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->GetBitmapEx(Point(), 
maParentDialogSize);
     maDimmedDialogBitmap = maParentDialogBitmap;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6ec3cd5688b9..6a6b3751b986 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -6597,7 +6597,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);
@@ -7307,7 +7307,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 b208cbcb015e..5e9406ddf3f1 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -4534,7 +4534,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 550121729521..8f0b9ce11d2e 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -155,7 +155,7 @@ short AbstractScDataFormDlg_Impl::Execute()
 
 BitmapEx AbstractScDataFormDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -236,7 +236,7 @@ bool 
AbstractScMoveTableDlg_Impl::StartExecuteAsync(VclAbstractDialog::AsyncCont
 
 BitmapEx AbstractScMoveTableDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -366,7 +366,7 @@ void AbstractScImportAsciiDlg_Impl::SaveParameters()
 
 BitmapEx AbstractScImportAsciiDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -397,7 +397,7 @@ bool AbstractScColRowLabelDlg_Impl::IsRow()
 
 BitmapEx AbstractScColRowLabelDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -413,7 +413,7 @@ void AbstractScDataPilotDatabaseDlg_Impl::GetValues( 
ScImportSourceDesc& rDesc )
 
 BitmapEx AbstractScDataPilotDatabaseDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -449,7 +449,7 @@ void 
AbstractScDataPilotSourceTypeDlg_Impl::AppendNamedRange(const OUString& rNa
 
 BitmapEx AbstractScDataPilotSourceTypeDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -490,7 +490,7 @@ DelCellCmd AbstractScDeleteCellDlg_Impl::GetDelCellCmd() 
const
 
 BitmapEx AbstractScDeleteCellDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -511,7 +511,7 @@ InsertDeleteFlags 
AbstractScDeleteContentsDlg_Impl::GetDelContentsCmdBits() cons
 
 BitmapEx AbstractScDeleteContentsDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -632,7 +632,7 @@ InsCellCmd  AbstractScInsertContentsDlg_Impl::GetMoveMode()
 
 BitmapEx AbstractScInsertContentsDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -678,7 +678,7 @@ const OUString* 
AbstractScInsertTableDlg_Impl::GetNextTable( sal_uInt16* pN )
 
 BitmapEx AbstractScInsertTableDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -791,7 +791,7 @@ CreateNameFlags AbstractScNameCreateDlg_Impl::GetFlags() 
const
 
 BitmapEx AbstractScNameCreateDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -928,7 +928,7 @@ OUString AbstractScStringInputDlg_Impl::GetInputString() 
const
 
 BitmapEx AbstractScStringInputDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -944,7 +944,7 @@ void AbstractScTabBgColorDlg_Impl::GetSelectedColor( Color& 
rColor ) const
 
 BitmapEx AbstractScTabBgColorDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -985,7 +985,7 @@ bool AbstractScTextImportOptionsDlg_Impl::IsKeepAskingSet() 
const
 
 BitmapEx AbstractScTextImportOptionsDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx
index 921bcba1f88f..a2fd67bae7d5 100644
--- a/sd/source/ui/dlg/sddlgfact.cxx
+++ b/sd/source/ui/dlg/sddlgfact.cxx
@@ -56,7 +56,7 @@ short SdAbstractGenericDialog_Impl::Execute()
 
 BitmapEx SdAbstractGenericDialog_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -157,7 +157,7 @@ bool 
AbstractHeaderFooterDialog_Impl::StartExecuteAsync(AsyncContext &rCtx)
 
 BitmapEx AbstractHeaderFooterDialog_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -188,7 +188,7 @@ short AbstractBreakDlg_Impl::Execute()
 
 BitmapEx AbstractBreakDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -209,7 +209,7 @@ short AbstractMasterLayoutDialog_Impl::Execute()
 
 BitmapEx AbstractMasterLayoutDialog_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -225,7 +225,7 @@ void AbstractCopyDlg_Impl::GetAttr( SfxItemSet& rOutAttrs )
 
 BitmapEx AbstractCopyDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -241,7 +241,7 @@ bool AbstractSdCustomShowDlg_Impl::IsCustomShow() const
 
 BitmapEx AbstractSdCustomShowDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -288,7 +288,7 @@ void SdAbstractTabController_Impl::SetText( const OUString& 
rStr )
 
 BitmapEx SdAbstractTabController_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -324,7 +324,7 @@ void AbstractBulletDialog_Impl::SetText( const OUString& 
rStr )
 
 BitmapEx AbstractBulletDialog_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -360,7 +360,7 @@ void SdPresLayoutTemplateDlg_Impl::SetText( const OUString& 
rStr )
 
 BitmapEx SdPresLayoutTemplateDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -381,7 +381,7 @@ SfxItemSet AbstractSdModifyFieldDlg_Impl::GetItemSet()
 
 BitmapEx AbstractSdModifyFieldDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -417,7 +417,7 @@ void AbstractSdSnapLineDlg_Impl::SetText( const OUString& 
rStr )
 
 BitmapEx AbstractSdSnapLineDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -438,7 +438,7 @@ void AbstractSdInsertLayerDlg_Impl::SetHelpId( const 
OUString& rHelpId )
 
 BitmapEx AbstractSdInsertLayerDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -464,7 +464,7 @@ bool 
AbstractSdInsertPagesObjsDlg_Impl::IsRemoveUnnecessaryMasterPages() const
 
 BitmapEx AbstractSdInsertPagesObjsDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -495,7 +495,7 @@ bool AbstractMorphDlg_Impl::IsOrientationFade() const
 
 BitmapEx AbstractMorphDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -511,7 +511,7 @@ void AbstractSdStartPresDlg_Impl::GetAttr( SfxItemSet& 
rOutAttrs )
 
 BitmapEx AbstractSdStartPresDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -527,7 +527,7 @@ void AbstractSdPresLayoutDlg_Impl::GetAttr( SfxItemSet& 
rOutAttrs )
 
 BitmapEx AbstractSdPresLayoutDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
@@ -558,7 +558,7 @@ const GDIMetaFile& 
AbstractSdVectorizeDlg_Impl::GetGDIMetaFile() const
 
 BitmapEx AbstractSdVectorizeDlg_Impl::createScreenshot() const
 {
-    VclPtr<VirtualDevice> xDialogSurface(m_xDlg->getDialog()->screenshot());
+    ScopedVclPtr<VirtualDevice> 
xDialogSurface(m_xDlg->getDialog()->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 9320146c9fe6..06f26372ac3f 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -1164,7 +1164,7 @@ BitmapEx SfxTabDialogController::createScreenshot() const
         const_cast<SfxTabDialogController*>(this)->Start_Impl();
     }
 
-    VclPtr<VirtualDevice> xDialogSurface(m_xDialog->screenshot());
+    ScopedVclPtr<VirtualDevice> xDialogSurface(m_xDialog->screenshot());
     return xDialogSurface->GetBitmapEx(Point(), 
xDialogSurface->GetOutputSizePixel());
 }
 
commit d83b9136def80ba8d4d7e2291e25fba6be549bbf
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sat Feb 21 17:54:14 2026 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sat Feb 21 16:12:05 2026 +0100

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

diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index 229615f56ec0..b1adcfc42171 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -659,7 +659,7 @@ private:
 
     sal_Int32 SearchPatternList(std::u16string_view rPatternName);
 
-    static VclPtr<VirtualDevice> GetVirtualDevice(BitmapEx aBitmap);
+    static ScopedVclPtr<VirtualDevice> GetVirtualDevice(BitmapEx aBitmap);
     void FillPresetListBox();
     void ShowContextMenu(const Point& pPos);
     void MenuSelect(const OUString& rIdent);
diff --git a/cui/source/tabpages/tppattern.cxx 
b/cui/source/tabpages/tppattern.cxx
index aa4407c11fb0..cbd7dd9a5999 100644
--- a/cui/source/tabpages/tppattern.cxx
+++ b/cui/source/tabpages/tppattern.cxx
@@ -153,7 +153,7 @@ void SvxPatternTabPage::FillPresetListBox()
 
         OUString sId = OUString::number(nId);
         BitmapEx aBitmap = m_pPatternList->GetBitmapForPreview(nId, aIconSize);
-        VclPtr<VirtualDevice> aVDev = GetVirtualDevice(aBitmap);
+        auto aVDev = GetVirtualDevice(aBitmap);
 
         if (!m_xPatternLB->get_id(nId).isEmpty())
         {
@@ -425,7 +425,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickAddHdl_Impl, 
weld::Button&, void)
             OUString sId = nCount > 0 ? m_xPatternLB->get_id( nCount - 1 ) : 
OUString();
             sal_Int32 nId = !sId.isEmpty() ? sId.toInt32() : -1;
             BitmapEx aBitmap = m_pPatternList->GetBitmapForPreview( nCount, 
aIconSize );
-            VclPtr<VirtualDevice> pVDev = GetVirtualDevice(aBitmap);
+            auto pVDev = GetVirtualDevice(aBitmap);
 
             m_xPatternLB->insert( nId + 1, &aName, &sId, pVDev, nullptr);
             FillPresetListBox();
@@ -460,7 +460,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickModifyHdl_Impl, 
weld::Button&, void)
     m_pPatternList->Replace(std::make_unique<XBitmapEntry>(Graphic(aBitmapEx), 
aName), nPos);
 
     BitmapEx aBitmap = m_pPatternList->GetBitmapForPreview( 
static_cast<sal_uInt16>(nPos), aIconSize );
-    VclPtr<VirtualDevice> pVDev = GetVirtualDevice(aBitmap);
+    auto pVDev = GetVirtualDevice(aBitmap);
 
     m_xPatternLB->remove( nPos );
     m_xPatternLB->insert( nPos, &aName, &sId, pVDev, nullptr);
@@ -470,7 +470,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickModifyHdl_Impl, 
weld::Button&, void)
     m_nPatternListState |= ChangeType::MODIFIED;
 }
 
-VclPtr<VirtualDevice> SvxPatternTabPage::GetVirtualDevice(BitmapEx aBitmap)
+ScopedVclPtr<VirtualDevice> SvxPatternTabPage::GetVirtualDevice(BitmapEx 
aBitmap)
 {
     VclPtr<VirtualDevice> pVDev = VclPtr<VirtualDevice>::Create();
     const Point aNull(0, 0);

Reply via email to