[Libreoffice-commits] core.git: vcl/inc vcl/win

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 9 10:06:27 UTC 2019


 vcl/inc/win/ScopedHDC.hxx  |   45 ---------------------------------------------
 vcl/win/gdi/scoped_gdi.hxx |    7 +++++++
 vcl/win/gdi/winlayout.cxx  |    2 +-
 3 files changed, 8 insertions(+), 46 deletions(-)

New commits:
commit 8addcffd4c4b1ce8d7e4c8dee01c312b68f1de71
Author:     Dmitriy Shilin <dshil at fastmail.com>
AuthorDate: Tue Jan 8 03:39:16 2019 -0800
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jan 9 11:06:02 2019 +0100

    tdf#107792 vcl/win: replace ScopedHDC with type alias
    
    Change-Id: I2d12ebc2a7e353ce685ec5132b0a65b393c36212
    Reviewed-on: https://gerrit.libreoffice.org/65962
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/inc/win/ScopedHDC.hxx b/vcl/inc/win/ScopedHDC.hxx
deleted file mode 100644
index bd4642ee6642..000000000000
--- a/vcl/inc/win/ScopedHDC.hxx
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- 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_VCL_INC_WIN_SCOPEDHDC_HXX
-#define INCLUDED_VCL_INC_WIN_SCOPEDHDC_HXX
-
-class ScopedHDC
-{
-private:
-    HDC m_hDC;
-
-public:
-    explicit ScopedHDC(HDC hDC)
-        : m_hDC(hDC)
-    {}
-
-    ScopedHDC(const ScopedHDC&) = delete;
-    ScopedHDC& operator=(const ScopedHDC&) = delete;
-
-    ~ScopedHDC()
-    {
-        if (m_hDC)
-            DeleteDC(m_hDC);
-    }
-
-    HDC get() const
-    {
-        return m_hDC;
-    }
-
-    explicit operator bool() const
-    {
-        return m_hDC != nullptr;
-    }
-};
-
-#endif // INCLUDED_VCL_INC_WIN_SCOPEDHDC_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/gdi/scoped_gdi.hxx b/vcl/win/gdi/scoped_gdi.hxx
index 90af7340f06a..b5a66d9d3698 100644
--- a/vcl/win/gdi/scoped_gdi.hxx
+++ b/vcl/win/gdi/scoped_gdi.hxx
@@ -27,8 +27,15 @@ struct HRGNDeleter
     void operator()(HRGN hRgn) { DeleteRegion(hRgn); }
 };
 
+struct HDCDeleter
+{
+    using pointer = HDC;
+    void operator()(HDC hDC) { DeleteDC(hDC); }
+};
+
 using ScopedHBRUSH = std::unique_ptr<HBRUSH, HBRUSHDeleter>;
 using ScopedHRGN = std::unique_ptr<HRGN, HRGNDeleter>;
+using ScopedHDC = std::unique_ptr<HDC, HDCDeleter>;
 
 #endif // INCLUDED_VCL_WIN_GDI_SCOPED_GDI_HXX
 
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 91e82e8ba40e..f5e2c025e965 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -38,7 +38,7 @@
 
 #include <sft.hxx>
 #include <sallayout.hxx>
-#include <win/ScopedHDC.hxx>
+#include "scoped_gdi.hxx"
 
 #include <cstdio>
 #include <cstdlib>


More information about the Libreoffice-commits mailing list