summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qbitmap.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-05-07 20:19:40 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-06 16:08:02 +0200
commit7d63fa6edcbe706bf0eab2c7e24efa1ed8940e6d (patch)
treed70ab41cbfb283b8f8ff6444dd8454d581791f81 /src/gui/image/qbitmap.cpp
parent8f2c57ddb2842c0983a36bca44c1810d58cbc370 (diff)
QtGui: replace some copies with swaps
This provides move speed even for non-C++11 compilers and avoids having to call the copy assignment operator from within copy ctors. (which will result in infinite recursion when using the copy-swap idiom). Change-Id: I379bc8bf2c72d9f986c0f17f9eef56cd592e7a06 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com> Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Diffstat (limited to 'src/gui/image/qbitmap.cpp')
-rw-r--r--src/gui/image/qbitmap.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp
index 59756d8693..f7ab853905 100644
--- a/src/gui/image/qbitmap.cpp
+++ b/src/gui/image/qbitmap.cpp
@@ -187,8 +187,7 @@ QBitmap::QBitmap(const QString& fileName, const char *format)
QBitmap &QBitmap::operator=(const QPixmap &pixmap)
{
if (pixmap.isNull()) { // a null pixmap
- QBitmap bm(0, 0);
- QBitmap::operator=(bm);
+ QBitmap(0, 0).swap(*this);
} else if (pixmap.depth() == 1) { // 1-bit pixmap
QPixmap::operator=(pixmap); // shallow assignment
} else { // n-bit depth pixmap