diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-25 16:23:17 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-29 06:45:42 +0000 |
commit | e6ffb539ee232ea0c679928ff456c1cf97429f63 (patch) | |
tree | e4b71a9bd49edba1a0f1c95f60f6da81433d1983 /toolkit | |
parent | bbc7ed9c379019f31dc7ac234cf83ea151601465 (diff) |
loplugin:vclwidgets check for assigning from VclPt<T> to T*
Inspired by a recent bug report where we were assigning the result
of VclPtr<T>::Create to a raw pointer.
As a consequence, we also need to change various methods that were
returning newly created Window subclasses via raw pointer, to
instead return those via VclPtr
Change-Id: I8118e0195a5b2b4780e646cfb0e151692e54ae2b
Reviewed-on: https://gerrit.libreoffice.org/31318
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/source/awt/stylesettings.cxx | 10 | ||||
-rw-r--r-- | toolkit/source/awt/vclxtoolkit.cxx | 34 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindow.cxx | 8 | ||||
-rw-r--r-- | toolkit/source/helper/vclunohelper.cxx | 2 |
4 files changed, 27 insertions, 27 deletions
diff --git a/toolkit/source/awt/stylesettings.cxx b/toolkit/source/awt/stylesettings.cxx index 8410554d2612..86ab25ce80bb 100644 --- a/toolkit/source/awt/stylesettings.cxx +++ b/toolkit/source/awt/stylesettings.cxx @@ -134,7 +134,7 @@ namespace toolkit { sal_Int32 lcl_getStyleColor( WindowStyleSettings_Data& i_rData, Color const & (StyleSettings::*i_pGetter)() const ) { - const vcl::Window* pWindow = i_rData.pOwningWindow->GetWindow(); + const VclPtr<vcl::Window>& pWindow = i_rData.pOwningWindow->GetWindow(); const AllSettings aAllSettings = pWindow->GetSettings(); const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); return (aStyleSettings.*i_pGetter)().GetColor(); @@ -152,7 +152,7 @@ namespace toolkit FontDescriptor lcl_getStyleFont( WindowStyleSettings_Data& i_rData, vcl::Font const & (StyleSettings::*i_pGetter)() const ) { - const vcl::Window* pWindow = i_rData.pOwningWindow->GetWindow(); + const VclPtr<vcl::Window>& pWindow = i_rData.pOwningWindow->GetWindow(); const AllSettings aAllSettings = pWindow->GetSettings(); const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); return VCLUnoHelper::CreateFontDescriptor( (aStyleSettings.*i_pGetter)() ); @@ -385,7 +385,7 @@ namespace toolkit ::sal_Int32 SAL_CALL WindowStyleSettings::getFaceGradientColor() throw (RuntimeException, std::exception) { StyleMethodGuard aGuard( *m_pData ); - const vcl::Window* pWindow = m_pData->pOwningWindow->GetWindow(); + const VclPtr<vcl::Window>& pWindow = m_pData->pOwningWindow->GetWindow(); const AllSettings aAllSettings = pWindow->GetSettings(); const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); return aStyleSettings.GetFaceGradientColor().GetColor(); @@ -675,7 +675,7 @@ namespace toolkit ::sal_Int32 SAL_CALL WindowStyleSettings::getSeparatorColor() throw (RuntimeException, std::exception) { StyleMethodGuard aGuard( *m_pData ); - const vcl::Window* pWindow = m_pData->pOwningWindow->GetWindow(); + const VclPtr<vcl::Window>& pWindow = m_pData->pOwningWindow->GetWindow(); const AllSettings aAllSettings = pWindow->GetSettings(); const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); return aStyleSettings.GetSeparatorColor().GetColor(); @@ -741,7 +741,7 @@ namespace toolkit sal_Bool SAL_CALL WindowStyleSettings::getHighContrastMode() throw (RuntimeException, std::exception) { StyleMethodGuard aGuard( *m_pData ); - const vcl::Window* pWindow = m_pData->pOwningWindow->GetWindow(); + const VclPtr<vcl::Window>& pWindow = m_pData->pOwningWindow->GetWindow(); const AllSettings aAllSettings = pWindow->GetSettings(); const StyleSettings& aStyleSettings = aAllSettings.GetStyleSettings(); return aStyleSettings.GetHighContrastMode(); diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 12948c3e8d67..116e77cb68ff 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -831,7 +831,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, OUString aServiceName( rDescriptor.WindowServiceName ); aServiceName = aServiceName.toAsciiLowerCase(); - vcl::Window* pNewWindow = nullptr; + VclPtr<vcl::Window> pNewWindow; sal_uInt16 nType = ImplGetComponentType( aServiceName ); bool bFrameControl = false; if ( aServiceName == "frame" ) @@ -886,7 +886,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_COMBOBOX: pNewWindow = VclPtr<ComboBox>::Create( pParent, nWinBits|WB_AUTOHSCROLL ); - static_cast<ComboBox*>(pNewWindow)->EnableAutoSize( false ); + static_cast<ComboBox*>(pNewWindow.get())->EnableAutoSize( false ); *ppNewComp = new VCLXComboBox; break; case WINDOW_CURRENCYBOX: @@ -894,18 +894,18 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_CURRENCYFIELD: pNewWindow = VclPtr<CurrencyField>::Create( pParent, nWinBits ); - static_cast<CurrencyField*>(pNewWindow)->EnableEmptyFieldValue( true ); + static_cast<CurrencyField*>(pNewWindow.get())->EnableEmptyFieldValue( true ); *ppNewComp = new VCLXNumericField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<CurrencyField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<CurrencyField*>(pNewWindow.get())) ); break; case WINDOW_DATEBOX: pNewWindow = VclPtr<DateBox>::Create( pParent, nWinBits ); break; case WINDOW_DATEFIELD: pNewWindow = VclPtr<DateField>::Create( pParent, nWinBits ); - static_cast<DateField*>(pNewWindow)->EnableEmptyFieldValue( true ); + static_cast<DateField*>(pNewWindow.get())->EnableEmptyFieldValue( true ); *ppNewComp = new VCLXDateField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<DateField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<DateField*>(pNewWindow.get())) ); break; case WINDOW_DOCKINGAREA: pNewWindow = VclPtr<DockingAreaWindow>::Create( pParent ); @@ -940,7 +940,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, pNewWindow = VclPtr<GroupBox>::Create( pParent, nWinBits ); if ( bFrameControl ) { - GroupBox* pGroupBox = static_cast< GroupBox* >( pNewWindow ); + GroupBox* pGroupBox = static_cast< GroupBox* >( pNewWindow.get() ); *ppNewComp = new VCLXFrame; // Frame control needs to receive // Mouse events @@ -961,7 +961,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_LISTBOX: pNewWindow = VclPtr<ListBox>::Create( pParent, nWinBits|WB_SIMPLEMODE|WB_AUTOHSCROLL ); - static_cast<ListBox*>(pNewWindow)->EnableAutoSize( false ); + static_cast<ListBox*>(pNewWindow.get())->EnableAutoSize( false ); *ppNewComp = new VCLXListBox; break; case WINDOW_LONGCURRENCYBOX: @@ -970,7 +970,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, case WINDOW_LONGCURRENCYFIELD: pNewWindow = VclPtr<LongCurrencyField>::Create( pParent, nWinBits ); *ppNewComp = new VCLXCurrencyField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<LongCurrencyField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<LongCurrencyField*>(pNewWindow.get())) ); break; case WINDOW_MENUBUTTON: pNewWindow = VclPtr<MenuButton>::Create( pParent, nWinBits ); @@ -986,7 +986,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, case WINDOW_METRICFIELD: pNewWindow = VclPtr<MetricField>::Create( pParent, nWinBits ); *ppNewComp = new VCLXMetricField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<MetricField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<MetricField*>(pNewWindow.get())) ); break; case WINDOW_DIALOG: case WINDOW_MODALDIALOG: @@ -1020,9 +1020,9 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_NUMERICFIELD: pNewWindow = VclPtr<NumericField>::Create( pParent, nWinBits ); - static_cast<NumericField*>(pNewWindow)->EnableEmptyFieldValue( true ); + static_cast<NumericField*>(pNewWindow.get())->EnableEmptyFieldValue( true ); *ppNewComp = new VCLXNumericField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<NumericField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<NumericField*>(pNewWindow.get())) ); break; case WINDOW_OKBUTTON: pNewWindow = VclPtr<OKButton>::Create( pParent, nWinBits ); @@ -1034,7 +1034,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, case WINDOW_PATTERNFIELD: pNewWindow = VclPtr<PatternField>::Create( pParent, nWinBits ); *ppNewComp = new VCLXPatternField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<PatternField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<PatternField*>(pNewWindow.get())) ); break; case WINDOW_PUSHBUTTON: pNewWindow = VclPtr<PushButton>::Create( pParent, nWinBits ); @@ -1057,7 +1057,7 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, // is not really valid: the controls are grouped after they have been created, but we're still in // the creation process, so the RadioButton::Check relies on invalid grouping information. // 07.08.2001 - #87254# - frank.schoenheit@sun.com - static_cast<RadioButton*>(pNewWindow)->EnableRadioCheck( false ); + static_cast<RadioButton*>(pNewWindow.get())->EnableRadioCheck( false ); break; case WINDOW_SCROLLBAR: pNewWindow = VclPtr<ScrollBar>::Create( pParent, nWinBits ); @@ -1105,9 +1105,9 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_TIMEFIELD: pNewWindow = VclPtr<TimeField>::Create( pParent, nWinBits ); - static_cast<TimeField*>(pNewWindow)->EnableEmptyFieldValue( true ); + static_cast<TimeField*>(pNewWindow.get())->EnableEmptyFieldValue( true ); *ppNewComp = new VCLXTimeField; - static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<TimeField*>(pNewWindow)) ); + static_cast<VCLXFormattedSpinField*>(*ppNewComp)->SetFormatter( static_cast<FormatterBase*>(static_cast<TimeField*>(pNewWindow.get())) ); break; case WINDOW_TOOLBOX: pNewWindow = VclPtr<ToolBox>::Create( pParent, nWinBits ); @@ -1256,7 +1256,7 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow( css::uno::Reference< css::awt::XWindowPeer > xRef; - vcl::Window* pParent = nullptr; + VclPtr<vcl::Window> pParent; if ( rDescriptor.Parent.is() ) { VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( rDescriptor.Parent ); diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index f8b90098c78f..e4a449925886 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -2480,10 +2480,10 @@ sal_Bool SAL_CALL VCLXWindow::isInPopupMode( ) throw (css::uno::RuntimeExceptio void SAL_CALL VCLXWindow::setOutputSize( const css::awt::Size& aSize ) throw (css::uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - vcl::Window *pWindow; + VclPtr<vcl::Window> pWindow; if( (pWindow = GetWindow()) != nullptr ) { - DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow); + DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow.get()); if( pDockingWindow ) pDockingWindow->SetOutputSizePixel( VCLSize( aSize ) ); else @@ -2494,10 +2494,10 @@ void SAL_CALL VCLXWindow::setOutputSize( const css::awt::Size& aSize ) throw (cs css::awt::Size SAL_CALL VCLXWindow::getOutputSize( ) throw (css::uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - vcl::Window *pWindow; + VclPtr<vcl::Window> pWindow; if( (pWindow = GetWindow()) != nullptr ) { - DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow); + DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow.get()); if( pDockingWindow ) return AWTSize( pDockingWindow->GetOutputSizePixel() ); else diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx index e6c8dfcbcdac..a1d977f53c68 100644 --- a/toolkit/source/helper/vclunohelper.cxx +++ b/toolkit/source/helper/vclunohelper.cxx @@ -152,7 +152,7 @@ css::uno::Reference< css::awt::XWindow> VCLUnoHelper::GetInterface( vcl::Window* OutputDevice* VCLUnoHelper::GetOutputDevice( const css::uno::Reference< css::awt::XDevice>& rxDevice ) { - OutputDevice* pOutDev = nullptr; + VclPtr<OutputDevice> pOutDev; VCLXDevice* pDev = VCLXDevice::GetImplementation( rxDevice ); if ( pDev ) pOutDev = pDev->GetOutputDevice(); |