Use comphelper::ScopeGuard instead of an ad-hoc struct

It occurred to me, that we already have something for that (thanks
Tomaž); and that it has an advantage of being non-copyable.

Change-Id: I4d5f5b61abe6e39f216d4f093e270d95cb0c6b82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189893
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Mike Kaganski
2025-08-19 08:59:21 +02:00
parent 92952f59f0
commit 48d36423d5
+2 -9
View File
@@ -60,8 +60,8 @@
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <unotools/fontdefs.hxx>
#include <comphelper/scopeguard.hxx>
#include <cppuhelper/weakref.hxx>
#include <o3tl/deleter.hxx>
#include <com/sun/star/drawing/LineCap.hpp>
#include <com/sun/star/uno/Reference.h>
@@ -1921,15 +1921,8 @@ protected:
[[nodiscard]] inline auto OutputDevice::ScopedPush(vcl::PushFlags nFlags)
{
struct OutputDeviceRestoreStateGuard
{
OutputDevice& m_rDev;
~OutputDeviceRestoreStateGuard() { suppress_fun_call_w_exception(m_rDev.Pop()); }
};
Push(nFlags);
// [-loplugin:redundantfcast]
return OutputDeviceRestoreStateGuard{ *this };
return comphelper::ScopeGuard([this]() { Pop(); });
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */