office-gobmx/include/o3tl/deleter.hxx
Gabor Kelemen bdb0775a26 Add missing sal/log.hxx headers
rtl/string.hxx and rtl/ustring.hxx both unnecessarily #include <sal/log.hxx> (and don't make use of it themselves), but many other files happen to depend on it.
This is a continuation of commit 6ff2d84ade to be able to remove those unneeded includes.

This commit adds missing headers to every file found by:
grep -FwL sal/log.hxx $(git grep -Elw 'SAL_INFO|SAL_INFO_IF|SAL_WARN|SAL_WARN_IF|SAL_DETAIL_LOG_STREAM|SAL_WHERE|SAL_STREAM|SAL_DEBUG')
to directories from filter to jvmfwk

Change-Id: I2a73d63f2aaef5f26d7d08957daaa8a30b412ac5
Reviewed-on: https://gerrit.libreoffice.org/58204
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2018-07-30 09:28:40 +02:00

61 lines
1.6 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_O3TL_DELETER_HXX
#define INCLUDED_O3TL_DELETER_HXX
#include <com/sun/star/uno/Exception.hpp>
#include <sal/log.hxx>
namespace o3tl {
/** To markup std::unique_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<typename T> struct default_delete
{
void operator() (T* p) noexcept
{
#if defined(__COVERITY__)
try
{
delete p;
}
catch (const css::uno::Exception& e)
{
SAL_WARN("vcl.app", "Fatal exception: " << e.Message);
std::terminate();
}
catch (const std::exception& e)
{
SAL_WARN("vcl.app", "Fatal exception: " << e.what());
std::terminate();
}
#else
delete p;
#endif
}
};
template<typename uniqueptr> void reset_preserve_ptr_during(uniqueptr& ptr)
{
// HACK: for the case where the dtor of the obj held by ptr will trigger
// functions which expect ptr to still be set during the dtor.
// e.g. SdrObject::GetBroadcaster() is called during the destructor
// in SdrEdgeObj::Notify(). So delete first, then clear the pointer
delete ptr.get();
(void)ptr.release();
}
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */