From 7f48655fb83bbfe394dcc66f11b01bd634aa2388 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 10 Feb 2016 15:43:15 +0100 Subject: [PATCH] QTextFrame::iterator: restore nothrow move special members The user-defined copy assignment and copy constructors inhibit the move special member functions. We cannot do something about it in Qt 5, because the class is exported (which it shouldn't be), and because making it trivially-copyable might change how it is passed to functions by value, so we need to supply all the missing member functions manually. Change-Id: Ic710b449f6abd386449fa6df71e8bc9bd0f98d2b Reviewed-by: Lars Knoll --- src/gui/text/qtextobject.cpp | 4 ++-- src/gui/text/qtextobject.h | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index 49cf35ecc03..a756549f3e4 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -675,7 +675,7 @@ QTextFrame::iterator::iterator(QTextFrame *frame, int block, int begin, int end) /*! Copy constructor. Constructs a copy of the \a other iterator. */ -QTextFrame::iterator::iterator(const iterator &other) +QTextFrame::iterator::iterator(const iterator &other) Q_DECL_NOTHROW { f = other.f; b = other.b; @@ -688,7 +688,7 @@ QTextFrame::iterator::iterator(const iterator &other) Assigns \a other to this iterator and returns a reference to this iterator. */ -QTextFrame::iterator &QTextFrame::iterator::operator=(const iterator &other) +QTextFrame::iterator &QTextFrame::iterator::operator=(const iterator &other) Q_DECL_NOTHROW { f = other.f; b = other.b; diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h index 18df53945c4..d3f6b3d0aca 100644 --- a/src/gui/text/qtextobject.h +++ b/src/gui/text/qtextobject.h @@ -148,10 +148,14 @@ public: friend class QTextDocumentLayoutPrivate; iterator(QTextFrame *frame, int block, int begin, int end); public: - iterator(); + iterator(); // ### Qt 6: inline #if QT_VERSION < QT_VERSION_CHECK(6,0,0) - iterator(const iterator &o); - iterator &operator=(const iterator &o); + iterator(const iterator &o) Q_DECL_NOTHROW; // = default + iterator &operator=(const iterator &o) Q_DECL_NOTHROW; // = default + iterator(iterator &&other) Q_DECL_NOTHROW // = default + { memcpy(this, &other, sizeof(iterator)); } + iterator &operator=(iterator &&other) Q_DECL_NOTHROW // = default + { memcpy(this, &other, sizeof(iterator)); return *this; } #endif QTextFrame *parentFrame() const { return f; }