sc/source/core/opencl/formulagroupcl.cxx | 17 ++++++----------- sc/source/ui/view/dbfunc3.cxx | 10 +++++----- sc/source/ui/view/viewfun5.cxx | 8 +++----- 3 files changed, 14 insertions(+), 21 deletions(-)
New commits: commit 77243437c425547302c45e781df1daf24634b08e Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jan 15 10:02:30 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Jan 16 09:16:01 2019 +0100 use unique_ptr in sc Change-Id: I780157687ba0727ee11f5ccdaf64412eb89c1757 Reviewed-on: https://gerrit.libreoffice.org/66418 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index cef9a82399d7..1846770996ef 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -3769,7 +3769,7 @@ public: DynamicKernel( const ScCalcConfig& config, const FormulaTreeNodeRef& r, int nResultSize ); virtual ~DynamicKernel() override; - static DynamicKernel* create( const ScCalcConfig& config, const ScTokenArray& rCode, int nResultSize ); + static std::unique_ptr<DynamicKernel> create( const ScCalcConfig& config, const ScTokenArray& rCode, int nResultSize ); /// OpenCL code generation void CodeGen(); @@ -4077,7 +4077,7 @@ ScMatrixRef FormulaGroupInterpreterOpenCL::inverseMatrix( const ScMatrix& ) return nullptr; } -DynamicKernel* DynamicKernel::create( const ScCalcConfig& rConfig, const ScTokenArray& rCode, int nResultSize ) +std::unique_ptr<DynamicKernel> DynamicKernel::create( const ScCalcConfig& rConfig, const ScTokenArray& rCode, int nResultSize ) { // Constructing "AST" FormulaTokenIterator aCode(rCode); @@ -4119,7 +4119,7 @@ DynamicKernel* DynamicKernel::create( const ScCalcConfig& rConfig, const ScToken FormulaTreeNodeRef Root = std::make_shared<FormulaTreeNode>(nullptr); Root->Children.push_back(aHashMap[aTokenVector.back()]); - DynamicKernel* pDynamicKernel = new DynamicKernel(rConfig, Root, nResultSize); + std::unique_ptr<DynamicKernel> pDynamicKernel(new DynamicKernel(rConfig, Root, nResultSize)); // OpenCL source code generation and kernel compilation try @@ -4130,14 +4130,12 @@ DynamicKernel* DynamicKernel::create( const ScCalcConfig& rConfig, const ScToken catch (const UnhandledToken& ut) { SAL_INFO("sc.opencl", "Dynamic formula compiler: UnhandledToken: " << ut.mMessage << " at " << ut.mFile << ":" << ut.mLineNumber); - delete pDynamicKernel; return nullptr; } catch (const InvalidParameterCount& ipc) { SAL_INFO("sc.opencl", "Dynamic formula compiler: InvalidParameterCount " << ipc.mParameterCount << " at " << ipc.mFile << ":" << ipc.mLineNumber); - delete pDynamicKernel; return nullptr; } catch (const OpenCLError& oce) @@ -4148,7 +4146,6 @@ DynamicKernel* DynamicKernel::create( const ScCalcConfig& rConfig, const ScToken // OpenCLError used to go to the catch-all below, and not delete pDynamicKernel. Was that // intentional, should we not do it here then either? - delete pDynamicKernel; openclwrapper::kernelFailures++; return nullptr; } @@ -4158,7 +4155,6 @@ DynamicKernel* DynamicKernel::create( const ScCalcConfig& rConfig, const ScToken // Unhandled used to go to the catch-all below, and not delete pDynamicKernel. Was that // intentional, should we not do it here then either? - delete pDynamicKernel; openclwrapper::kernelFailures++; return nullptr; } @@ -4166,7 +4162,6 @@ DynamicKernel* DynamicKernel::create( const ScCalcConfig& rConfig, const ScToken { // FIXME: Do we really want to catch random exceptions here? SAL_WARN("sc.opencl", "Dynamic formula compiler: unexpected exception"); - // FIXME: Not deleting pDynamicKernel here!?, is that intentional? openclwrapper::kernelFailures++; return nullptr; } @@ -4258,10 +4253,10 @@ public: return mpKernel != nullptr; } - void setManagedKernel( DynamicKernel* pKernel ) + void setManagedKernel( std::unique_ptr<DynamicKernel> pKernel ) { - mpKernelStore.reset(pKernel); - mpKernel = pKernel; + mpKernelStore = std::move(pKernel); + mpKernel = mpKernelStore.get(); } CLInterpreterResult launchKernel() diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index e522233717e8..ce2eff3e8c9d 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -1137,15 +1137,15 @@ void ScDBFunc::GroupDataPilot() } } - ScDPSaveGroupDimension* pNewGroupDim = nullptr; + std::unique_ptr<ScDPSaveGroupDimension> pNewGroupDim; if ( !pGroupDimension ) { // create a new group dimension OUString aGroupDimName = pDimData->CreateGroupDimName(aBaseDimName, *pDPObj, false, nullptr); - pNewGroupDim = new ScDPSaveGroupDimension( aBaseDimName, aGroupDimName ); + pNewGroupDim.reset(new ScDPSaveGroupDimension( aBaseDimName, aGroupDimName )); - pGroupDimension = pNewGroupDim; // make changes to the new dim if none existed + pGroupDimension = pNewGroupDim.get(); // make changes to the new dim if none existed if ( pBaseGroupDim ) { @@ -1195,10 +1195,10 @@ void ScDBFunc::GroupDataPilot() if ( pNewGroupDim ) { pDimData->AddGroupDimension( *pNewGroupDim ); - delete pNewGroupDim; // AddGroupDimension copies the object + pNewGroupDim.reset(); // AddGroupDimension copies the object // don't access pGroupDimension after here } - pGroupDimension = pNewGroupDim = nullptr; + pGroupDimension = nullptr; // set orientation ScDPSaveDimension* pSaveDimension = aData.GetDimensionByName( aGroupDimName ); diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx index fc5d357704cf..79d16433dc0d 100644 --- a/sc/source/ui/view/viewfun5.cxx +++ b/sc/source/ui/view/viewfun5.cxx @@ -555,13 +555,13 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId, uno::Reference <io::XInputStream> xStm = aDataHelper.GetInputStream(nFormatId, OUString()); if (xStm.is()) { - ScDocument* pInsDoc = new ScDocument( SCDOCMODE_CLIP ); + std::unique_ptr<ScDocument> pInsDoc(new ScDocument( SCDOCMODE_CLIP )); SCTAB nSrcTab = 0; // Biff5 in clipboard: always sheet 0 pInsDoc->ResetClip( pDoc, nSrcTab ); SfxMedium aMed; aMed.GetItemSet()->Put( SfxUnoAnyItem( SID_INPUTSTREAM, uno::makeAny( xStm ) ) ); - ErrCode eErr = ScFormatFilter::Get().ScImportExcel( aMed, pInsDoc, EIF_AUTO ); + ErrCode eErr = ScFormatFilter::Get().ScImportExcel( aMed, pInsDoc.get(), EIF_AUTO ); if ( eErr == ERRCODE_NONE ) { ScRange aSource; @@ -600,11 +600,9 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId, } pInsDoc->SetClipArea( aSource ); - PasteFromClip( InsertDeleteFlags::ALL, pInsDoc, + PasteFromClip( InsertDeleteFlags::ALL, pInsDoc.get(), ScPasteFunc::NONE, false, false, false, INS_NONE, InsertDeleteFlags::NONE, bAllowDialogs ); - delete pInsDoc; - bRet = true; } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits