vcl/inc/svdata.hxx | 7 ++++--- vcl/source/app/svmain.cxx | 4 ++-- vcl/source/treelist/transfer2.cxx | 13 +++++-------- vcl/source/window/layout.cxx | 10 +++++----- 4 files changed, 16 insertions(+), 18 deletions(-)
New commits: commit 6c2542306bcc7caaab947664f252265058964fc2 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Mar 6 15:03:18 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Mar 6 15:51:09 2023 +0000 no need to allocate these separately they are all one or two words in size Change-Id: Iec508d917d05b3ca762723bdc99be8c68b974aaf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148336 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index 06d0aeb9b9af..c514df09422c 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -27,6 +27,7 @@ #include <tools/fldunit.hxx> #include <unotools/options.hxx> #include <vcl/bitmapex.hxx> +#include <vcl/image.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <vcl/window.hxx> @@ -42,6 +43,7 @@ #include "displayconnectiondispatch.hxx" #include <mutex> +#include <optional> #include <vector> #include <unordered_map> #include "ControlCacheKey.hxx" @@ -72,7 +74,6 @@ class Timer; class AutoTimer; class Idle; class Help; -class Image; class PopupMenu; class Application; class OutputDevice; @@ -278,8 +279,8 @@ struct ImplSVCtrlData { std::vector<Image> maCheckImgList; // ImageList for CheckBoxes std::vector<Image> maRadioImgList; // ImageList for RadioButtons - std::unique_ptr<Image> mpDisclosurePlus; - std::unique_ptr<Image> mpDisclosureMinus; + std::optional<Image> moDisclosurePlus; + std::optional<Image> moDisclosureMinus; ImplTBDragMgr* mpTBDragMgr = nullptr; // DragMgr for ToolBox sal_uInt16 mnCheckStyle = 0; // CheckBox-Style for ImageList-Update sal_uInt16 mnRadioStyle = 0; // Radio-Style for ImageList-Update diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx index 7c5505f364cb..571be29579bc 100644 --- a/vcl/source/app/svmain.cxx +++ b/vcl/source/app/svmain.cxx @@ -486,8 +486,8 @@ void DeInitVCL() pSVData->mpWinData->maMsgBoxImgList.clear(); pSVData->maCtrlData.maCheckImgList.clear(); pSVData->maCtrlData.maRadioImgList.clear(); - pSVData->maCtrlData.mpDisclosurePlus.reset(); - pSVData->maCtrlData.mpDisclosureMinus.reset(); + pSVData->maCtrlData.moDisclosurePlus.reset(); + pSVData->maCtrlData.moDisclosureMinus.reset(); pSVData->mpDefaultWin.disposeAndClear(); #if defined _WIN32 diff --git a/vcl/source/treelist/transfer2.cxx b/vcl/source/treelist/transfer2.cxx index 05183b9c0485..1c53be66f1c6 100644 --- a/vcl/source/treelist/transfer2.cxx +++ b/vcl/source/treelist/transfer2.cxx @@ -318,7 +318,7 @@ struct TransferDataContainer_Impl { std::vector< TDataCntnrEntry_Impl > aFmtList; Link<sal_Int8,void> aFinishedLnk; - std::unique_ptr<INetBookmark> pBookmk; + std::optional<INetBookmark> moBookmk; TransferDataContainer_Impl() { @@ -368,8 +368,8 @@ bool TransferDataContainer::GetData( case SotClipboardFormatId::FILECONTENT: case SotClipboardFormatId::FILEGRPDESCRIPTOR: case SotClipboardFormatId::UNIFORMRESOURCELOCATOR: - if( pImpl->pBookmk ) - bFnd = SetINetBookmark( *pImpl->pBookmk, rFlavor ); + if( pImpl->moBookmk ) + bFnd = SetINetBookmark( *pImpl->moBookmk, rFlavor ); break; default: break; @@ -381,10 +381,7 @@ bool TransferDataContainer::GetData( void TransferDataContainer::CopyINetBookmark( const INetBookmark& rBkmk ) { - if( !pImpl->pBookmk ) - pImpl->pBookmk.reset( new INetBookmark( rBkmk ) ); - else - *pImpl->pBookmk = rBkmk; + pImpl->moBookmk = rBkmk; AddFormat( SotClipboardFormatId::STRING ); AddFormat( SotClipboardFormatId::SOLK ); @@ -441,7 +438,7 @@ void TransferDataContainer::CopyString( const OUString& rStr ) bool TransferDataContainer::HasAnyData() const { return !pImpl->aFmtList.empty() || - nullptr != pImpl->pBookmk; + pImpl->moBookmk.has_value(); } diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index a650a0bf92ab..881d3e6ed465 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -1594,13 +1594,13 @@ class DisclosureButton final : public CheckBox return; ImplSVCtrlData& rCtrlData(ImplGetSVData()->maCtrlData); - if (!rCtrlData.mpDisclosurePlus) - rCtrlData.mpDisclosurePlus.reset(new Image(StockImage::Yes, SV_DISCLOSURE_PLUS)); - if (!rCtrlData.mpDisclosureMinus) - rCtrlData.mpDisclosureMinus.reset(new Image(StockImage::Yes, SV_DISCLOSURE_MINUS)); + if (!rCtrlData.moDisclosurePlus) + rCtrlData.moDisclosurePlus.emplace(StockImage::Yes, SV_DISCLOSURE_PLUS); + if (!rCtrlData.moDisclosureMinus) + rCtrlData.moDisclosureMinus.emplace(StockImage::Yes, SV_DISCLOSURE_MINUS); Image* pImg - = IsChecked() ? rCtrlData.mpDisclosureMinus.get() : rCtrlData.mpDisclosurePlus.get(); + = IsChecked() ? &*rCtrlData.moDisclosureMinus : &*rCtrlData.moDisclosurePlus; DrawImageFlags nStyle = DrawImageFlags::NONE; if (!IsEnabled())