diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-12-08 18:57:32 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-12-09 07:16:34 +0000 |
commit | 4754afddc3030347ef49b401a9b798cea8fe523c (patch) | |
tree | a7505da2dae9b8eae70ed463309521c11780d4c4 /sd | |
parent | 6fd3f3caad1a559165dc9332249cbd0d84930775 (diff) |
Use unique_ptr out-arg to in SfxBindings::QueryState to avoid mem leaks
Change-Id: I35df02de675068478a36ef05266ffc2d3054b07f
Reviewed-on: https://gerrit.libreoffice.org/20477
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/view/drviewsf.cxx | 20 | ||||
-rw-r--r-- | sd/source/ui/view/outlnvsh.cxx | 5 |
2 files changed, 10 insertions, 15 deletions
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx index d3e8276e70ef..15bb40e9aa6c 100644 --- a/sd/source/ui/view/drviewsf.cxx +++ b/sd/source/ui/view/drviewsf.cxx @@ -488,9 +488,9 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) case SID_STYLE_WATERCAN: { - SfxPoolItem* pItem = nullptr; + std::unique_ptr<SfxPoolItem> pItem; GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem); + SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); if (pFamilyItem && SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO) rSet.Put(SfxBoolItem(nWhich,false)); else @@ -498,31 +498,28 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) SfxBoolItem aItem(nWhich, SD_MOD()->GetWaterCan()); aAllSet.Put( aItem, aItem.Which()); } - delete pItem; } break; case SID_STYLE_NEW: { - SfxPoolItem* pItem = nullptr; + std::unique_ptr<SfxPoolItem> pItem; GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem); + SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); if (pFamilyItem && SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO) { rSet.DisableItem(nWhich); } - delete pItem; } break; case SID_STYLE_DRAGHIERARCHIE: { - SfxPoolItem* pItem = nullptr; + std::unique_ptr<SfxPoolItem> pItem; GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem); + SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); if (pFamilyItem && SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO) rSet.DisableItem(nWhich); - delete pItem; } break; @@ -531,9 +528,9 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) // It is not possible to create PseudoStyleSheets 'by Example'; // normal style sheets need a selected object for that - SfxPoolItem* pItem = nullptr; + std::unique_ptr<SfxPoolItem> pItem; GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem); + SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); if (pFamilyItem) { if (SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO) @@ -557,7 +554,6 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) rSet.DisableItem(nWhich); } } - delete pItem; } break; diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx index 8acacd4459ca..c81906ba648e 100644 --- a/sd/source/ui/view/outlnvsh.cxx +++ b/sd/source/ui/view/outlnvsh.cxx @@ -1481,9 +1481,9 @@ void OutlineViewShell::GetAttrState( SfxItemSet& rSet ) case SID_STYLE_EDIT: { - SfxPoolItem* pItem = nullptr; + std::unique_ptr<SfxPoolItem> pItem; GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem); - SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem); + SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get()); if (pFamilyItem && SfxTemplate::NIdToSfxFamilyId(pFamilyItem->GetValue()) == SD_STYLE_FAMILY_PSEUDO) { SfxItemSet aSet(*rSet.GetPool(), SID_STATUS_LAYOUT, SID_STATUS_LAYOUT); @@ -1495,7 +1495,6 @@ void OutlineViewShell::GetAttrState( SfxItemSet& rSet ) rSet.DisableItem(nWhich); } } - delete pItem; } break; |