cpp/poppler-destination.cpp | 16 +++------------- cpp/poppler-destination.h | 4 +++- cpp/poppler-global.cpp | 3 +++ cpp/poppler-global.h | 2 ++ 4 files changed, 11 insertions(+), 14 deletions(-)
New commits: commit c4cc5650067d4aca26091d187fb464eaee54bef0 Author: Oliver Sander <[email protected]> Date: Tue Aug 30 14:30:34 2022 +0200 Store destination_private in a std::unique_ptr This simplifies the code a bit. It also fixes a 'code smell' found by https://sonarcloud.io/project/overview?id=tsdgeos_poppler_mirror diff --git a/cpp/poppler-destination.cpp b/cpp/poppler-destination.cpp index 75339153..80760b89 100644 --- a/cpp/poppler-destination.cpp +++ b/cpp/poppler-destination.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2019, Masamichi Hosoda <[email protected]> * Copyright (C) 2019 Albert Astals Cid <[email protected]> + * Copyright (C) 2022, Oliver Sander <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -264,20 +265,9 @@ bool destination::is_change_zoom() const /** Move assignment operator. */ -destination &destination::operator=(destination &&other) noexcept -{ - if (this != &other) { - d = other.d; - other.d = nullptr; - } - - return *this; -} +destination &destination::operator=(destination &&other) noexcept = default; /** Destructor. */ -destination::~destination() -{ - delete d; -} +destination::~destination() = default; diff --git a/cpp/poppler-destination.h b/cpp/poppler-destination.h index 4629195d..6b0f920c 100644 --- a/cpp/poppler-destination.h +++ b/cpp/poppler-destination.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2019, Masamichi Hosoda <[email protected]> * Copyright (C) 2019, 2021, Albert Astals Cid <[email protected]> + * Copyright (C) 2022, Oliver Sander <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +21,7 @@ #ifndef POPPLER_DESTINATION_H #define POPPLER_DESTINATION_H +#include <memory> #include "poppler-global.h" namespace poppler { @@ -60,7 +62,7 @@ public: private: explicit destination(destination_private *dd); - destination_private *d; + std::unique_ptr<destination_private> d; friend class document; }; commit eb6b42a12a81cdf84b64db9e4e44b5158dcb8a3a Author: Oliver Sander <[email protected]> Date: Tue Aug 30 14:26:43 2022 +0200 Make noncopyable objects move-assignable Move-assignment needs to be allowed explicitly, because otherwise derived classes that implement operator=(&&) will try to use noncopyable::operator=(&), which is not allowed. diff --git a/cpp/poppler-global.cpp b/cpp/poppler-global.cpp index 08765569..9cfb1d70 100644 --- a/cpp/poppler-global.cpp +++ b/cpp/poppler-global.cpp @@ -7,6 +7,7 @@ * Copyright (C) 2018, 2020-2022, Albert Astals Cid <[email protected]> * Copyright (C) 2018 Suzuki Toshiya <[email protected]> * Copyright (C) 2018, 2020, Adam Reichold <[email protected]> + * Copyright (C) 2022, Oliver Sander <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -206,6 +207,8 @@ noncopyable::noncopyable() { } noncopyable::~noncopyable() { } +noncopyable &noncopyable::operator=(noncopyable &&other) noexcept = default; + ustring::ustring() { } ustring::ustring(size_type len, value_type ch) : std::basic_string<value_type>(len, ch) { } diff --git a/cpp/poppler-global.h b/cpp/poppler-global.h index 26a2d008..782e0758 100644 --- a/cpp/poppler-global.h +++ b/cpp/poppler-global.h @@ -5,6 +5,7 @@ * Copyright (C) 2018, Adam Reichold <[email protected]> * Copyright (C) 2021, 2022, Albert Astals Cid <[email protected]> * Copyright (C) 2022, Tobias C. Berner <[email protected]> + * Copyright (C) 2022, Oliver Sander <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,6 +46,7 @@ public: protected: noncopyable(); ~noncopyable(); + noncopyable &operator=(noncopyable &&other) noexcept; }; }
