summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-06-27 16:47:49 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-06-27 21:47:11 +0200
commitd1069a583dc1bcf4f1cf9b4bed12cb48bc757951 (patch)
treebd4716714a9a67bc0e9d0c8808904c6162f3989a
parent22bacc8205e2a1ee5134dbbddbb75414ab5d12af (diff)
cid#1401342 Uncaught exception
Change-Id: Ia22ed8541f1148355d71cd5b90ad13e64c1b50c2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97289 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--fpicker/source/office/OfficeFilePicker.cxx3
-rw-r--r--fpicker/source/office/OfficeFolderPicker.cxx3
-rw-r--r--include/o3tl/make_shared.hxx15
-rw-r--r--sc/source/ui/view/cellsh2.cxx3
-rw-r--r--sc/source/ui/view/tabvwshc.cxx3
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx4
-rw-r--r--vcl/source/gdi/impgraph.cxx4
7 files changed, 27 insertions, 8 deletions
diff --git a/fpicker/source/office/OfficeFilePicker.cxx b/fpicker/source/office/OfficeFilePicker.cxx
index d849326119f4..2c813d64c013 100644
--- a/fpicker/source/office/OfficeFilePicker.cxx
+++ b/fpicker/source/office/OfficeFilePicker.cxx
@@ -35,6 +35,7 @@
#include <com/sun/star/beans/NamedValue.hpp>
#include <unotools/pathoptions.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <o3tl/make_shared.hxx>
#include <vcl/svapp.hxx>
using namespace ::com::sun::star::container;
@@ -435,7 +436,7 @@ std::shared_ptr<SvtFileDialog_Base> SvtFilePicker::implCreateDialog( weld::Windo
{
PickerFlags nBits = getPickerFlags();
- auto dialog = std::make_shared<SvtFileDialog>(pParent, nBits);
+ auto dialog = o3tl::make_shared<SvtFileDialog>(pParent, nBits);
// Set StandardDir if present
if ( !m_aStandardDir.isEmpty())
diff --git a/fpicker/source/office/OfficeFolderPicker.cxx b/fpicker/source/office/OfficeFolderPicker.cxx
index 424bf708cdb0..8413020df96f 100644
--- a/fpicker/source/office/OfficeFolderPicker.cxx
+++ b/fpicker/source/office/OfficeFolderPicker.cxx
@@ -24,6 +24,7 @@
#include <vector>
#include <tools/urlobj.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <o3tl/make_shared.hxx>
#include <unotools/pathoptions.hxx>
using namespace ::com::sun::star::container;
@@ -70,7 +71,7 @@ void SAL_CALL SvtFolderPicker::startExecuteModal( const Reference< css::ui::dial
std::shared_ptr<SvtFileDialog_Base> SvtFolderPicker::implCreateDialog( weld::Window* pParent )
{
- return std::make_shared<SvtFileDialog>(pParent, PickerFlags::PathDialog);
+ return o3tl::make_shared<SvtFileDialog>(pParent, PickerFlags::PathDialog);
}
sal_Int16 SvtFolderPicker::implExecutePicker( )
diff --git a/include/o3tl/make_shared.hxx b/include/o3tl/make_shared.hxx
index d42783c301fa..9d7998fd5a36 100644
--- a/include/o3tl/make_shared.hxx
+++ b/include/o3tl/make_shared.hxx
@@ -10,6 +10,7 @@
#ifndef INCLUDED_O3TL_MAKE_SHARED_HXX
#define INCLUDED_O3TL_MAKE_SHARED_HXX
+#include <o3tl/deleter.hxx>
#include <memory>
#include <type_traits>
@@ -26,6 +27,20 @@ std::shared_ptr<T> make_shared_array(size_t const size)
return std::shared_ptr<T>(new T[size], std::default_delete<T[]>());
}
+/** To markup std::shared_ptr that coverity warns might throw exceptions
+ which won't throw in practice, or where std::terminate is
+ an acceptable response if they do
+*/
+template<class T, class... Args>
+std::shared_ptr<T> make_shared(Args&&... args)
+{
+#if defined(__COVERITY__)
+ return std::shared_ptr<T>(new T(std::forward<Args>(args)...), o3tl::default_delete<T>());
+#else
+ return std::make_shared<T>(std::forward<Args>(args)...);
+#endif
+}
+
} // namespace o3tl
#endif // INCLUDED_O3TL_MAKE_SHARED_HXX
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 3083cf0fd18a..75f5b463a58c 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -66,6 +66,7 @@
#include <markdata.hxx>
#include <documentlinkmgr.hxx>
+#include <o3tl/make_shared.hxx>
#include <memory>
using namespace com::sun::star;
@@ -793,7 +794,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
break;
case SID_DATA_PROVIDER:
{
- std::shared_ptr<ScDocument> xDoc(new ScDocument, o3tl::default_delete<ScDocument>());
+ auto xDoc = o3tl::make_shared<ScDocument>();
xDoc->InsertTab(0, "test");
ScDocument* pDoc = GetViewData()->GetDocument();
ScDataProviderDlg aDialog(pTabViewShell->GetDialogParent(), xDoc, pDoc);
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 432bbb670675..19b99ec93aa8 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -71,6 +71,7 @@
#include <PivotLayoutDialog.hxx>
#include <comphelper/lok.hxx>
+#include <o3tl/make_shared.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
void ScTabViewShell::SetCurRefDlgId( sal_uInt16 nNew )
@@ -397,7 +398,7 @@ std::shared_ptr<SfxModelessDialogController> ScTabViewShell::CreateRefDialogCont
if (!isLOKMobilePhone())
{
// dialog checks, what is in the cell
- xResult = std::make_shared<ScFormulaDlg>(pB, pCW, pParent, &GetViewData(),ScGlobal::GetStarCalcFunctionMgr());
+ xResult = o3tl::make_shared<ScFormulaDlg>(pB, pCW, pParent, &GetViewData(),ScGlobal::GetStarCalcFunctionMgr());
}
break;
}
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 68ad3415a08a..05e78a46c332 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -99,7 +99,7 @@
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/linguistic2/XLinguProperties.hpp>
#include <o3tl/cppunittraitshelper.hxx>
-#include <o3tl/deleter.hxx>
+#include <o3tl/make_shared.hxx>
#include <osl/file.hxx>
#include <osl/thread.hxx>
#include <paratr.hxx>
@@ -1013,7 +1013,7 @@ void SwUiWriterTest::testExportRTF()
pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 3, /*bBasicCall=*/false);
// Create the clipboard document.
- std::shared_ptr<SwDoc> xClpDoc(new SwDoc, o3tl::default_delete<SwDoc>());
+ auto xClpDoc = o3tl::make_shared<SwDoc>();
xClpDoc->SetClipBoard(true);
pWrtShell->Copy(xClpDoc.get());
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index e06663706d6e..925ec4a34952 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -21,7 +21,7 @@
#include <sal/log.hxx>
#include <comphelper/fileformat.h>
-#include <o3tl/deleter.hxx>
+#include <o3tl/make_shared.hxx>
#include <tools/fract.hxx>
#include <tools/vcompat.hxx>
#include <tools/urlobj.hxx>
@@ -1361,7 +1361,7 @@ bool ImpGraphic::swapOut()
const INetURLObject aTempFileURL(aTempFile.GetURL());
// Create a swap file
- std::shared_ptr<ImpSwapFile> pSwapFile(new ImpSwapFile(aTempFileURL, getOriginURL()), o3tl::default_delete<ImpSwapFile>());
+ auto pSwapFile = o3tl::make_shared<ImpSwapFile>(aTempFileURL, getOriginURL());
bool bResult = false;