1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #ifndef INCLUDED_O3TL_DELETER_HXX
11 #define INCLUDED_O3TL_DELETER_HXX
13 #include <sal/config.h>
17 #include <com/sun/star/uno/Exception.hpp>
18 #include <sal/log.hxx>
22 /** To markup std::unique_ptr that coverity warns might throw exceptions
23 which won't throw in practice, or where std::terminate is
24 an acceptable response if they do
26 template <typename T
> struct default_delete
28 void operator()(T
* p
) noexcept
30 #if defined(__COVERITY__)
35 catch (const css::uno::Exception
& ex
)
37 SAL_WARN("vcl.app", "Fatal exception: " << exceptionToString(ex
));
40 catch (const std::exception
& e
)
42 SAL_WARN("vcl.app", "Fatal exception: " << e
.what());
53 void operator()(void* p
) { std::free(p
); }
56 template <typename uniqueptr
> void reset_preserve_ptr_during(uniqueptr
& ptr
)
58 // HACK: for the case where the dtor of the obj held by ptr will trigger
59 // functions which expect ptr to still be set during the dtor.
60 // e.g. SdrObject::GetBroadcaster() is called during the destructor
61 // in SdrEdgeObj::Notify(). So delete first, then clear the pointer
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */