diff options
author | Noel Grandin <noel@peralex.com> | 2015-01-07 10:42:07 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-09 19:58:50 +0100 |
commit | 3ad9d2550f922ae7f555ca0753c57907d4d78ab6 (patch) | |
tree | e4c49fb42eca8566d9ab56600f4d372f4c2eb748 | |
parent | 09b4246c6aa5e75c89df2961816b0124fea7fd78 (diff) |
vcl: make VclPtr<T>(T*) constructor explicit
to make it obvious in the code when we are translating between the
reference-counted type and raw pointers, since that is the danger-point
Change-Id: I32822432325fa34969e78cccf937e2ccbe1bfb70
-rw-r--r-- | dbaccess/source/ui/control/curledit.cxx | 4 | ||||
-rw-r--r-- | extensions/source/propctrlr/standardcontrol.cxx | 2 | ||||
-rw-r--r-- | include/vcl/spinfld.hxx | 4 | ||||
-rw-r--r-- | include/vcl/vclptr.hxx | 7 | ||||
-rw-r--r-- | sd/source/ui/animations/CustomAnimationDialog.cxx | 18 | ||||
-rw-r--r-- | vcl/source/control/combobox.cxx | 4 | ||||
-rw-r--r-- | vcl/source/control/spinfld.cxx | 14 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 21 |
10 files changed, 48 insertions, 34 deletions
diff --git a/dbaccess/source/ui/control/curledit.cxx b/dbaccess/source/ui/control/curledit.cxx index 0c967bd34ef3..95e8234af5dc 100644 --- a/dbaccess/source/ui/control/curledit.cxx +++ b/dbaccess/source/ui/control/curledit.cxx @@ -40,7 +40,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeConnectionURLEdit(vcl: OConnectionURLEdit::~OConnectionURLEdit() { - SetSubEdit(NULL); + SetSubEdit(VclPtr<Edit>()); delete m_pForcedPrefix; } @@ -83,7 +83,7 @@ void OConnectionURLEdit::SetText(const OUString& _rStr, const Selection& /*_rNew { // create new sub controls, if necessary if (!GetSubEdit()) - SetSubEdit(EditRef(new Edit(this, 0))); + SetSubEdit(VclPtr<Edit>(new Edit(this, 0))); if ( !m_pForcedPrefix ) { m_pForcedPrefix = new FixedText(this, WB_VCENTER); diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx index 9bab3502e305..bd923405eadd 100644 --- a/extensions/source/propctrlr/standardcontrol.cxx +++ b/extensions/source/propctrlr/standardcontrol.cxx @@ -1030,7 +1030,7 @@ namespace pcr SetCompoundControl( true ); m_pImplEdit = VclPtr<MultiLineEdit>( new MultiLineEdit( this, WB_TABSTOP | WB_IGNORETAB | WB_NOBORDER | (_nStyle & WB_READONLY) ) ); - SetSubEdit( m_pImplEdit.get() ); + SetSubEdit( m_pImplEdit ); m_pImplEdit->Show(); if ( _nStyle & WB_DROPDOWN ) diff --git a/include/vcl/spinfld.hxx b/include/vcl/spinfld.hxx index fe5431be04b6..493dcf897873 100644 --- a/include/vcl/spinfld.hxx +++ b/include/vcl/spinfld.hxx @@ -32,7 +32,7 @@ class VCL_DLLPUBLIC SpinField : public Edit { protected: - Edit* mpEdit; + VclPtr<Edit> mpEdit; AutoTimer maRepeatTimer; Rectangle maUpperRect; Rectangle maLowerRect; @@ -69,6 +69,8 @@ protected: virtual void FillLayoutData() const SAL_OVERRIDE; Rectangle * ImplFindPartRect( const Point& rPt ); + virtual void dispose() SAL_OVERRIDE; + public: explicit SpinField( vcl::Window* pParent, WinBits nWinStyle = 0 ); explicit SpinField( vcl::Window* pParent, const ResId& ); diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx index 5aa0c6959497..c32dbcc6691d 100644 --- a/include/vcl/vclptr.hxx +++ b/include/vcl/vclptr.hxx @@ -88,7 +88,7 @@ public: /** Constructor... */ - inline VclPtr (reference_type * pBody) + explicit inline VclPtr (reference_type * pBody) : m_rInnerRef(pBody) {} @@ -131,6 +131,11 @@ public: return m_rInnerRef.get(); } + inline void SAL_CALL set(reference_type *pBody) + { + m_rInnerRef.set(pBody); + } + inline SAL_CALL operator reference_type * () const { return m_rInnerRef.get(); diff --git a/sd/source/ui/animations/CustomAnimationDialog.cxx b/sd/source/ui/animations/CustomAnimationDialog.cxx index db14887a5bef..891bef9270fe 100644 --- a/sd/source/ui/animations/CustomAnimationDialog.cxx +++ b/sd/source/ui/animations/CustomAnimationDialog.cxx @@ -412,13 +412,13 @@ private: CharHeightPropertyBox::CharHeightPropertyBox( sal_Int32 nControlType, vcl::Window* pParent, const Any& rValue, const Link& rModifyHdl ) : PropertySubControl( nControlType ) { - mpMetric = new MetricField( pParent, WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER); + mpMetric.set( new MetricField( pParent, WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER) ); mpMetric->SetUnit( FUNIT_PERCENT ); mpMetric->SetMin( 0 ); mpMetric->SetMax( 1000 ); mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_FONTSIZE_POPUP ) ); - mpControl = new DropdownMenuBox( pParent, mpMetric.get(), mpMenu ); + mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu ); mpControl->SetMenuSelectHdl( LINK( this, CharHeightPropertyBox, implMenuSelectHdl )); mpControl->SetModifyHdl( rModifyHdl ); mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_CHARHEIGHTPROPERTYBOX ); @@ -494,7 +494,7 @@ TransparencyPropertyBox::TransparencyPropertyBox( sal_Int32 nControlType, vcl::W : PropertySubControl( nControlType ) , maModifyHdl( rModifyHdl ) { - mpMetric = new MetricField( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER); + mpMetric.set( new MetricField( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER) ); mpMetric->SetUnit( FUNIT_PERCENT ); mpMetric->SetMin( 0 ); mpMetric->SetMax( 100 ); @@ -507,7 +507,7 @@ TransparencyPropertyBox::TransparencyPropertyBox( sal_Int32 nControlType, vcl::W mpMenu->InsertItem( i, aStr ); } - mpControl = new DropdownMenuBox( pParent, mpMetric.get(), mpMenu ); + mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu ); mpControl->SetMenuSelectHdl( LINK( this, TransparencyPropertyBox, implMenuSelectHdl )); mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_TRANSPARENCYPROPERTYBOX ); @@ -598,14 +598,14 @@ RotationPropertyBox::RotationPropertyBox( sal_Int32 nControlType, vcl::Window* p : PropertySubControl( nControlType ) , maModifyHdl( rModifyHdl ) { - mpMetric = new MetricField( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER); + mpMetric.set( new MetricField( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER) ); mpMetric->SetUnit( FUNIT_CUSTOM ); mpMetric->SetCustomUnitText( OUString( sal_Unicode(0xb0)) ); // degree sign mpMetric->SetMin( -10000 ); mpMetric->SetMax( 10000 ); mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_ROTATION_POPUP ) ); - mpControl = new DropdownMenuBox( pParent, mpMetric.get(), mpMenu ); + mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu ); mpControl->SetMenuSelectHdl( LINK( this, RotationPropertyBox, implMenuSelectHdl )); mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_ROTATIONPROPERTYBOX ); @@ -724,13 +724,13 @@ ScalePropertyBox::ScalePropertyBox( sal_Int32 nControlType, vcl::Window* pParent : PropertySubControl( nControlType ) , maModifyHdl( rModifyHdl ) { - mpMetric = new MetricField( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER); + mpMetric.set( new MetricField( pParent ,WB_TABSTOP|WB_IGNORETAB| WB_NOBORDER) ); mpMetric->SetUnit( FUNIT_PERCENT ); mpMetric->SetMin( 0 ); mpMetric->SetMax( 10000 ); mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_SCALE_POPUP ) ); - mpControl = new DropdownMenuBox( pParent, mpMetric.get(), mpMenu ); + mpControl = new DropdownMenuBox( pParent, mpMetric, mpMenu ); mpControl->SetMenuSelectHdl( LINK( this, ScalePropertyBox, implMenuSelectHdl )); mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_SCALEPROPERTYBOX ); @@ -889,7 +889,7 @@ FontStylePropertyBox::FontStylePropertyBox( sal_Int32 nControlType, vcl::Window* : PropertySubControl( nControlType ) , maModifyHdl( rModifyHdl ) { - mpEdit = new Edit( pParent, WB_TABSTOP|WB_IGNORETAB|WB_NOBORDER|WB_READONLY); + mpEdit.set( new Edit( pParent, WB_TABSTOP|WB_IGNORETAB|WB_NOBORDER|WB_READONLY) ); mpEdit->SetText( SD_RESSTR(STR_CUSTOMANIMATION_SAMPLE) ); mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_FONTSTYLE_POPUP ) ); diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 4a4de5cd842d..d84797564a68 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -80,7 +80,7 @@ ComboBox::~ComboBox() void ComboBox::ImplInitComboBoxData() { - mpSubEdit = NULL; + mpSubEdit.disposeAndClear(); mpBtn = NULL; mpImplLB = NULL; mpFloatWin = NULL; @@ -164,7 +164,7 @@ void ComboBox::ImplInit( vcl::Window* pParent, WinBits nStyle ) } } - mpSubEdit = new Edit( this, nEditStyle ); + mpSubEdit.set( new Edit( this, nEditStyle ) ); mpSubEdit->EnableRTL( false ); SetSubEdit( mpSubEdit ); mpSubEdit->SetPosPixel( Point() ); diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx index 85aa37b07769..048f2f4f281c 100644 --- a/vcl/source/control/spinfld.cxx +++ b/vcl/source/control/spinfld.cxx @@ -286,7 +286,7 @@ void ImplDrawSpinButton( OutputDevice* pOutDev, void SpinField::ImplInitSpinFieldData() { - mpEdit = NULL; + mpEdit.disposeAndClear(); mbSpin = false; mbRepeat = false; mbUpperIn = false; @@ -311,11 +311,11 @@ void SpinField::ImplInit( vcl::Window* pParent, WinBits nWinStyle ) if ( (nWinStyle & WB_SPIN) && ImplUseNativeBorder( nWinStyle ) ) { SetBackground(); - mpEdit = new Edit( this, WB_NOBORDER ); + mpEdit.set( new Edit( this, WB_NOBORDER ) ); mpEdit->SetBackground(); } else - mpEdit = new Edit( this, WB_NOBORDER ); + mpEdit.set( new Edit( this, WB_NOBORDER ) ); mpEdit->EnableRTL( false ); mpEdit->SetPosPixel( Point() ); @@ -359,7 +359,13 @@ SpinField::SpinField( vcl::Window* pParent, const ResId& rResId ) : SpinField::~SpinField() { - delete mpEdit; + dispose(); +} + +void SpinField::dispose() +{ + mpEdit.disposeAndClear(); + Edit::dispose(); } void SpinField::Up() diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index f7de2d12130a..7efe07eefbe7 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -2093,14 +2093,14 @@ void VclBuilder::handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader) if (sInternalChild.startsWith("vbox") || sInternalChild.startsWith("messagedialog-vbox")) { if (Dialog *pBoxParent = dynamic_cast<Dialog*>(pParent)) - pBoxParent->set_content_area(static_cast<VclBox*>(pCurrentChild)); + pBoxParent->set_content_area(VclPtr<VclBox>(static_cast<VclBox*>(pCurrentChild))); // FIXME-VCLPTR } else if (sInternalChild.startsWith("action_area") || sInternalChild.startsWith("messagedialog-action_area")) { vcl::Window *pContentArea = pCurrentChild->GetParent(); if (Dialog *pBoxParent = dynamic_cast<Dialog*>(pContentArea ? pContentArea->GetParent() : NULL)) { - pBoxParent->set_action_area(static_cast<VclButtonBox*>(pCurrentChild)); + pBoxParent->set_action_area(VclPtr<VclButtonBox>(static_cast<VclButtonBox*>(pCurrentChild))); // FIXME-VCLPTR } } diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 771563f1a536..b5f7b5361f12 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -347,8 +347,8 @@ void Dialog::ImplInitDialogData() mbOldSaveBack = false; mbInClose = false; mbModalMode = false; - mpContentArea = NULL; - mpActionArea = NULL; + mpContentArea.disposeAndClear(); + mpActionArea.disposeAndClear(); mnMousePositioned = 0; mpDialogImpl = new DialogImpl; } diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index d79abdee7575..ad2cb670a9ed 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -1939,10 +1939,10 @@ bool VclSizeGroup::set_property(const OString &rKey, const OString &rValue) void MessageDialog::create_owned_areas() { set_border_width(12); - m_pOwnedContentArea = new VclVBox(this, false, 24); + m_pOwnedContentArea.set(new VclVBox(this, false, 24)); set_content_area(m_pOwnedContentArea); m_pOwnedContentArea->Show(); - m_pOwnedActionArea = new VclHButtonBox(m_pOwnedContentArea); + m_pOwnedActionArea.set( new VclHButtonBox(m_pOwnedContentArea) ); set_action_area(m_pOwnedActionArea); m_pOwnedActionArea->Show(); } @@ -2105,7 +2105,7 @@ short MessageDialog::Execute() VclContainer *pContainer = get_content_area(); assert(pContainer); - m_pGrid = new VclGrid(pContainer); + m_pGrid.set( new VclGrid(pContainer) ); m_pGrid->reorderWithinParent(0); m_pGrid->set_column_spacing(12); m_pGrid->set_row_spacing(GetTextHeight()); @@ -2165,32 +2165,33 @@ short MessageDialog::Execute() case VCL_BUTTONS_NONE: break; case VCL_BUTTONS_OK: - pBtn = new OKButton(pButtonBox); + pBtn.set( new OKButton(pButtonBox) ); pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON); pBtn->Show(); m_aOwnedButtons.push_back(pBtn); m_aResponses[pBtn] = RET_OK; break; case VCL_BUTTONS_CLOSE: - pBtn = new CloseButton(pButtonBox); + pBtn.set( new CloseButton(pButtonBox) ); pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON); pBtn->Show(); m_aOwnedButtons.push_back(pBtn); m_aResponses[pBtn] = RET_CLOSE; break; case VCL_BUTTONS_CANCEL: - pBtn = new CancelButton(pButtonBox); + pBtn.set( new CancelButton(pButtonBox) ); pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON); m_aOwnedButtons.push_back(pBtn); m_aResponses[pBtn] = RET_CANCEL; break; case VCL_BUTTONS_YES_NO: pBtn = new PushButton(pButtonBox); - pBtn->SetText(Button::GetStandardText(StandardButtonType::Yes) pBtn->Show(); + pBtn->SetText(Button::GetStandardText(StandardButtonType::Yes)); + pBtn->Show(); m_aOwnedButtons.push_back(pBtn); m_aResponses[pBtn] = RET_YES; - pBtn = new PushButton(pButtonBox); + pBtn.set( new PushButton(pButtonBox) ); pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON); pBtn->SetText(Button::GetStandardText(StandardButtonType::No)); pBtn->Show(); @@ -2198,12 +2199,12 @@ short MessageDialog::Execute() m_aResponses[pBtn] = RET_NO; break; case VCL_BUTTONS_OK_CANCEL: - pBtn = new OKButton(pButtonBox); + pBtn.set( new OKButton(pButtonBox) ); pBtn->Show(); m_aOwnedButtons.push_back(pBtn); m_aResponses[pBtn] = RET_OK; - pBtn = new CancelButton(pButtonBox); + pBtn.set( new CancelButton(pButtonBox) ); pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON); pBtn->Show(); m_aOwnedButtons.push_back(pBtn); |