diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-10-06 08:23:09 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-10-10 11:46:25 +0200 |
commit | 1faeb2e56ffdbeeed4df41b58851e51a7766c18c (patch) | |
tree | 1ab294314db37e98b2d6a6adf53d658eefa16887 /sources/shiboken6/tests | |
parent | 3c703beea87b353d0b99187830f7a1a3f3d65b2b (diff) |
shiboken tests: Fix special functions for class OnlyCopy
Use a shared pointer for the Private class, so that the default
copy/move can be used.
Pick-to: 6.6
Task-number: PYSIDE-2479
Change-Id: Iebc75b230c7b87d47be10e10f6565eaaccb17f66
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/shiboken6/tests')
-rw-r--r-- | sources/shiboken6/tests/libsample/onlycopy.cpp | 21 | ||||
-rw-r--r-- | sources/shiboken6/tests/libsample/onlycopy.h | 12 |
2 files changed, 9 insertions, 24 deletions
diff --git a/sources/shiboken6/tests/libsample/onlycopy.cpp b/sources/shiboken6/tests/libsample/onlycopy.cpp index 5ae746121..981ea88a4 100644 --- a/sources/shiboken6/tests/libsample/onlycopy.cpp +++ b/sources/shiboken6/tests/libsample/onlycopy.cpp @@ -11,28 +11,11 @@ public: int value; }; -OnlyCopy::OnlyCopy(int value) : d(new OnlyCopyPrivate(value)) +OnlyCopy::OnlyCopy(int value) : d(std::make_shared<OnlyCopyPrivate>(value)) { } -OnlyCopy::OnlyCopy(OnlyCopyPrivate *dIn) : d(dIn) -{ -} - -OnlyCopy::~OnlyCopy() -{ - delete d; -} - -OnlyCopy::OnlyCopy(const OnlyCopy &other) : d(new OnlyCopyPrivate(other.value())) -{ -} - -OnlyCopy &OnlyCopy::operator=(const OnlyCopy &other) -{ - d->value = other.d->value; - return *this; -} +OnlyCopy::~OnlyCopy() = default; int OnlyCopy::value() const { diff --git a/sources/shiboken6/tests/libsample/onlycopy.h b/sources/shiboken6/tests/libsample/onlycopy.h index bd414ec34..7dc3e0069 100644 --- a/sources/shiboken6/tests/libsample/onlycopy.h +++ b/sources/shiboken6/tests/libsample/onlycopy.h @@ -7,6 +7,7 @@ #include "libsamplemacros.h" #include <list> +#include <memory> // These classes simulate a situation found in QWebEngineHistoryItem. @@ -15,8 +16,8 @@ class OnlyCopyPrivate; class LIBSAMPLE_API OnlyCopy { public: - OnlyCopy(const OnlyCopy &other); - OnlyCopy &operator=(const OnlyCopy &other); + LIBMINIMAL_DEFAULT_COPY_MOVE(OnlyCopy) + ~OnlyCopy(); int value() const; @@ -24,10 +25,11 @@ public: static int getValueFromReference(const OnlyCopy &onlyCopy) { return onlyCopy.value(); } private: - OnlyCopyPrivate *d; - explicit OnlyCopy(int value); - explicit OnlyCopy(OnlyCopyPrivate *d); // rejected due to unknown OnlyCopyPrivate friend class FriendOfOnlyCopy; + + explicit OnlyCopy(int value); + + std::shared_ptr<OnlyCopyPrivate> d; }; class LIBSAMPLE_API FriendOfOnlyCopy |