From db8167c224348fe828aaa0746701b7fa3040c2df Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 25 Feb 2014 23:07:46 +0100 Subject: QPen: add move constructor After this change, the relation between copy/move constructor calls in QtGui is something like 40/16. A moved-from QPen can only be copied, assigned-to or else destroyed. This required adding a nullptr check to the copy ctor and the dtor and rewriting copy assignment (which used non-nullptr-safe qAtomicAssign) in terms of copy construction and swapping. Extensive tests included. They are implemented such that they work in C++98 as well as C++11 mode, but they naturally test move semantics only in a C++11 build. Change-Id: If68f37c10b8eeefb2478cbae386cd2e38b4f6e19 Reviewed-by: Thiago Macieira --- src/gui/painting/qpen.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gui/painting/qpen.h') diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h index c5144f784f..486f699476 100644 --- a/src/gui/painting/qpen.h +++ b/src/gui/painting/qpen.h @@ -72,6 +72,8 @@ public: QPen &operator=(const QPen &pen); #ifdef Q_COMPILER_RVALUE_REFS + inline QPen(QPen &&other) + : d(other.d) { other.d = 0; } inline QPen &operator=(QPen &&other) { qSwap(d, other.d); return *this; } #endif -- cgit v1.2.3