From 1a421248396e4b2bdc9ff3ebb63b1edf41c93474 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 2 Apr 2014 22:50:23 +0200 Subject: Q{File,Font,Color,Message}DialogOptions are no value classes These classes are only held in QSharedPointer, so optimize for that: 1. Disable default ctor, copy ctor and assignment operator, destructor and swap for public users. 2. Add create() to return an instance in a shared pointer. 3. Allocate public and private classes in one memory block, use QSharedPointer::create() to also add the QSharedPointer control block to the same memory allocation. As a consequence, this reduces the creation of a Q*DialogOptions into a shared pointer by two memory allocations. Add a macro to enable atomic updates to QtQuick and other users outside QtBase. [ChangeLog][QtGui] [QFileDialogOptions/QFontDialogOptions/QMessageDialogOptions/QColorDialogOptions] This class no longer has value semantics, but needs to be held in QSharedPointer (as it always was). To copy an instance, use the clone() method. Change-Id: I4c81220e0a8286a310df1c224a30eca34824c4e6 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll Reviewed-by: Shawn Rutledge --- src/widgets/dialogs/qcolordialog.cpp | 2 +- src/widgets/dialogs/qfiledialog.cpp | 2 +- src/widgets/dialogs/qfontdialog.cpp | 2 +- src/widgets/dialogs/qmessagebox.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/widgets/dialogs') diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 9f86bea0ca..beeef75fb5 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -92,7 +92,7 @@ public: SetColorAll = ShowColor | SelectColor }; - QColorDialogPrivate() : options(new QColorDialogOptions) + QColorDialogPrivate() : options(QColorDialogOptions::create()) #ifdef Q_OS_WIN32 , updateTimer(0) #endif diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 50667e2a91..3bcd6f7c4b 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -533,7 +533,7 @@ QFileDialogPrivate::QFileDialogPrivate() showHiddenAction(0), useDefaultCaption(true), qFileDialogUi(0), - options(new QFileDialogOptions) + options(QFileDialogOptions::create()) { } diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index a0525f6fbd..c130998198 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -110,7 +110,7 @@ static const Qt::WindowFlags DefaultWindowFlags = QFontDialogPrivate::QFontDialogPrivate() : writingSystem(QFontDatabase::Any), - options(QSharedPointer::create()) + options(QFontDialogOptions::create()) { } diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 207b6e3919..ee760c38a0 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -200,7 +200,7 @@ public: #endif compatMode(false), autoAddOkButton(true), detectedEscapeButton(0), informativeLabel(0), - options(new QMessageDialogOptions) { } + options(QMessageDialogOptions::create()) { } void init(const QString &title = QString(), const QString &text = QString()); void setupLayout(); -- cgit v1.2.3