From 59eb393cf57015a4dfea94617c863aafb096afa7 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 14 Oct 2012 16:29:39 +0100 Subject: Rename QRegularExpression-related feature defs to QT_NO_REGULAREXPRESSION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QRegExp and QRegularExpression are totally independent, therefore using two different defines is the right thing to do. Also, document the new define in qfeatures.{txt,h}. Change-Id: Ice4826ea543f4b22f1cc27bf31ed6e043d0c43b0 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira Reviewed-by: Jędrzej Nowacki --- src/corelib/global/qfeatures.h | 3 +++ src/corelib/global/qfeatures.txt | 7 +++++++ 2 files changed, 10 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index a63d3a3b3d..da5ef4687b 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -154,6 +154,9 @@ // Properties //#define QT_NO_PROPERTIES +// QRegularExpression +//#define QT_NO_REGULAREXPRESSION + // Resize Handler //#define QT_NO_RESIZEHANDLER diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index ad1ca5a6d5..25fd28c4cd 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -28,6 +28,13 @@ Requires: Name: CssParser SeeAlso: ??? +Feature: REGULAREXPRESSION +Description: Perl-compatible regular expression APIs +Section: Kernel +Requires: +Name: QRegularExpression +SeeAlso: ??? + Feature: CONCURRENT Description: Provides a high-level multi-threaded APIs Section: Kernel -- cgit v1.2.3 From 7818eaf2b1129061e1cbbaf3e91517397b135cdd Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 11 Jan 2013 11:38:39 +0100 Subject: Bump Qt version to 5.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6d372c933e48eeda921fe781b073bf4e05b31585 Reviewed-by: Jędrzej Nowacki Reviewed-by: David Faure (KDE) --- src/corelib/global/qglobal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 48cc477d51..03cd3dc591 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -45,11 +45,11 @@ #include -#define QT_VERSION_STR "5.0.1" +#define QT_VERSION_STR "5.1.0" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x050001 +#define QT_VERSION 0x050100 /* can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) */ -- cgit v1.2.3 From f7eff7251786186ca895c8fc537b304bc89977b3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 24 Feb 2012 18:44:17 +0100 Subject: Add a new Q_GLOBAL_STATIC implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unlike the previous implementation, this implementation is locked: only one initialisation is ever run at the same time. It is exception-safe, meaning that a throwing constructor will restart the process. Also, start using the thread-safe behaviour that GCC has offered for a long time and C++11 requires. Change-Id: I20db44f57d258923df64c0051358fd0d9a5ccd51 Reviewed-by: Olivier Goffart Reviewed-by: David Faure (KDE) Reviewed-by: Jędrzej Nowacki --- src/corelib/global/global.pri | 1 + src/corelib/global/qglobal.h | 122 +--------------------------- src/corelib/global/qglobalstatic.h | 157 +++++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+), 119 deletions(-) create mode 100644 src/corelib/global/qglobalstatic.h (limited to 'src/corelib/global') diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index 01756c8419..491464621c 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -9,6 +9,7 @@ HEADERS += \ global/qendian.h \ global/qnumeric_p.h \ global/qnumeric.h \ + global/qglobalstatic.h \ global/qlibraryinfo.h \ global/qlogging.h \ global/qtypeinfo.h \ diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 03cd3dc591..60b6e32522 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -664,125 +664,6 @@ typedef void (*QFunctionPointer)(); # define Q_UNIMPLEMENTED() qWarning("%s:%d: %s: Unimplemented code.", __FILE__, __LINE__, Q_FUNC_INFO) #endif -#if defined(QT_NO_THREAD) - -template -class QGlobalStatic -{ -public: - T *pointer; - inline QGlobalStatic(T *p) : pointer(p) { } - inline ~QGlobalStatic() { pointer = 0; } -}; - -#define Q_GLOBAL_STATIC(TYPE, NAME) \ - static TYPE *NAME() \ - { \ - static TYPE thisVariable; \ - static QGlobalStatic thisGlobalStatic(&thisVariable); \ - return thisGlobalStatic.pointer; \ - } - -#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ - static TYPE *NAME() \ - { \ - static TYPE thisVariable ARGS; \ - static QGlobalStatic thisGlobalStatic(&thisVariable); \ - return thisGlobalStatic.pointer; \ - } - -#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \ - static TYPE *NAME() \ - { \ - static TYPE thisVariable; \ - static QGlobalStatic thisGlobalStatic(0); \ - if (!thisGlobalStatic.pointer) { \ - TYPE *x = thisGlobalStatic.pointer = &thisVariable; \ - INITIALIZER; \ - } \ - return thisGlobalStatic.pointer; \ - } - -#else - -// forward declaration, since qatomic.h needs qglobal.h -template class QBasicAtomicPointer; - -// POD for Q_GLOBAL_STATIC -template -class QGlobalStatic -{ -public: - QBasicAtomicPointer pointer; - bool destroyed; -}; - -// Created as a function-local static to delete a QGlobalStatic -template -class QGlobalStaticDeleter -{ -public: - QGlobalStatic &globalStatic; - QGlobalStaticDeleter(QGlobalStatic &_globalStatic) - : globalStatic(_globalStatic) - { } - - inline ~QGlobalStaticDeleter() - { - delete globalStatic.pointer.load(); - globalStatic.pointer.store(0); - globalStatic.destroyed = true; - } -}; - -#define Q_GLOBAL_STATIC(TYPE, NAME) \ - static TYPE *NAME() \ - { \ - static QGlobalStatic thisGlobalStatic \ - = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \ - if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \ - TYPE *x = new TYPE; \ - if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \ - delete x; \ - else \ - static QGlobalStaticDeleter cleanup(thisGlobalStatic); \ - } \ - return thisGlobalStatic.pointer.load(); \ - } - -#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ - static TYPE *NAME() \ - { \ - static QGlobalStatic thisGlobalStatic \ - = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \ - if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \ - TYPE *x = new TYPE ARGS; \ - if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \ - delete x; \ - else \ - static QGlobalStaticDeleter cleanup(thisGlobalStatic); \ - } \ - return thisGlobalStatic.pointer.load(); \ - } - -#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \ - static TYPE *NAME() \ - { \ - static QGlobalStatic thisGlobalStatic \ - = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \ - if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { \ - QScopedPointer x(new TYPE); \ - INITIALIZER; \ - if (thisGlobalStatic.pointer.testAndSetOrdered(0, x.data())) { \ - static QGlobalStaticDeleter cleanup(thisGlobalStatic); \ - x.take(); \ - } \ - } \ - return thisGlobalStatic.pointer.load(); \ - } - -#endif - Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) { return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2))); @@ -1089,6 +970,9 @@ template struct QEnableIf { typedef T Type; }; QT_END_NAMESPACE QT_END_HEADER +// Q_GLOBAL_STATIC +#include + // qDebug and friends #include #include diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h new file mode 100644 index 0000000000..78a4acff12 --- /dev/null +++ b/src/corelib/global/qglobalstatic.h @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Intel Corporation +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#ifndef QGLOBALSTATIC_H +#define QGLOBALSTATIC_H + +#include + +QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE + +/* + * QGlobalStatic internals: + * + * The pointer is initialized to 0. + * The guard is initialized to 0. + * The guard can assume the following values: + * -2: object initialized and already destroyed + * -1: object initialized and is still valid + * 0: not initialized, the value of the pointer should be null + * +1: initializing, must wait until a state change happens + * (not used in the current implementation) + */ + +namespace QtGlobalStatic { +enum GuardValues { + Destroyed = -2, + Initialized = -1, + Uninitialized = 0, + Initializing = 1 +}; +} + +#if defined(QT_NO_THREAD) || defined(Q_CC_GNU) +// some compilers support thread-safe statics +// The IA-64 C++ ABI requires this, so we know that all GCC versions since 3.4 +// support it. C++11 also requires this behavior. +// Clang and Intel CC masquerade as GCC when compiling on Linux and Mac OS X. + +#define Q_GLOBAL_STATIC_INTERNAL(ARGS) \ + Q_DECL_HIDDEN inline Type *innerFunction() \ + { \ + struct HolderBase { \ + ~HolderBase() Q_DECL_NOTHROW \ + { guard.store(QtGlobalStatic::Destroyed); } \ + }; \ + static struct Holder : public HolderBase { \ + Type value; \ + Holder() \ + Q_DECL_NOEXCEPT_EXPR(noexcept(Type ARGS)) \ + : value ARGS \ + { guard.store(QtGlobalStatic::Initialized); } \ + } holder; \ + return &holder.value; \ + } +#else +// We don't know if this compiler supports thread-safe global statics +// so use our own locked implementation + +QT_END_NAMESPACE +#include +QT_BEGIN_NAMESPACE + +#define Q_GLOBAL_STATIC_INTERNAL(ARGS) \ + Q_DECL_HIDDEN inline Type *innerFunction() \ + { \ + static Type *d; \ + static QBasicMutex mutex; \ + int x = guard.loadAcquire(); \ + if (Q_UNLIKELY(x >= QtGlobalStatic::Uninitialized)) { \ + QMutexLocker locker(&mutex); \ + if (guard.load() == QtGlobalStatic::Uninitialized) { \ + d = new Type ARGS; \ + static struct Cleanup { \ + ~Cleanup() { \ + delete d; \ + guard.store(QtGlobalStatic::Destroyed); \ + } \ + } cleanup; \ + guard.store(QtGlobalStatic::Initialized); \ + } \ + } \ + return d; \ + } +#endif + +// this class must be POD, unless the compiler supports thread-safe statics +template +struct QGlobalStatic +{ + typedef T Type; + + bool isDestroyed() const { return guard.load() <= QtGlobalStatic::Destroyed; } + bool exists() const { return guard.load() == QtGlobalStatic::Initialized; } + operator Type *() { if (isDestroyed()) return 0; return innerFunction(); } + Type *operator()() { if (isDestroyed()) return 0; return innerFunction(); } + Type *operator->() { return innerFunction(); } + Type &operator*() { return *innerFunction(); } +}; + +#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ + namespace { namespace Q_QGS_ ## NAME { \ + typedef TYPE Type; \ + QBasicAtomicInt guard = Q_BASIC_ATOMIC_INITIALIZER(QtGlobalStatic::Uninitialized); \ + Q_GLOBAL_STATIC_INTERNAL(ARGS) \ + } } \ + static QGlobalStatic NAME; + +#define Q_GLOBAL_STATIC(TYPE, NAME) \ + Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ()) + +QT_END_NAMESPACE +QT_END_HEADER + +#endif // QGLOBALSTATIC_H -- cgit v1.2.3 From baad50e97946c4b99998f215aa5c023c17be29ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pasi=20Pet=C3=A4j=C3=A4j=C3=A4rvi?= Date: Fri, 15 Jun 2012 13:55:08 +0300 Subject: VxWorks header only available in DKM mode and not in RTP mode. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check if _WRS_KERNEL is defined so we are compiling for DKM mode. Change-Id: I15801b0575d3fe6e543f81a177fd01d015d9085f Reviewed-by: Samuel Rødal --- src/corelib/global/qglobal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 6818b1d64d..144a864ec0 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -68,7 +68,7 @@ # endif #endif -#if defined(Q_OS_VXWORKS) +#if defined(Q_OS_VXWORKS) && defined(_WRS_KERNEL) # include #endif -- cgit v1.2.3 From 2da24ac2b9a539e4d2cca4ee14035a99d0b4b04e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Jan 2013 23:07:57 -0800 Subject: Change QT_FATAL_WARNINGS behavior to require a non-empty value This allows easy unsetting of the variable in a shell like: QT_FATAL_WARNINGS= progname Change-Id: Ie9cfb6ebfd4931de1c90af68bfeeae1e9f3d4b9d Reviewed-by: Kai Koehne --- src/corelib/global/qlogging.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 339cedb57e..2fab7c5be6 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -73,7 +73,7 @@ static bool isFatal(QtMsgType msgType) return true; if (msgType == QtWarningMsg) { - static bool fatalWarnings = qEnvironmentVariableIsSet("QT_FATAL_WARNINGS"); + static bool fatalWarnings = !qEnvironmentVariableIsEmpty("QT_FATAL_WARNINGS"); return fatalWarnings; } -- cgit v1.2.3 From c0860d26a1b87f42842faeda3e6043a775916594 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 22 Jan 2013 18:26:25 -0800 Subject: Doc: write up the docs for Q_GLOBAL_STATIC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5bf4d0d027dc8f960c94b4be3ebf7381e9ef4be1 Reviewed-by: Jędrzej Nowacki Reviewed-by: Olivier Goffart --- src/corelib/global/global.pri | 1 + src/corelib/global/qglobalstatic.cpp | 522 +++++++++++++++++++++++++++++++++++ src/corelib/global/qglobalstatic.h | 13 - 3 files changed, 523 insertions(+), 13 deletions(-) create mode 100644 src/corelib/global/qglobalstatic.cpp (limited to 'src/corelib/global') diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index 491464621c..6ac32cd35d 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -20,6 +20,7 @@ HEADERS += \ SOURCES += \ global/qglobal.cpp \ + global/qglobalstatic.cpp \ global/qlibraryinfo.cpp \ global/qmalloc.cpp \ global/qnumeric.cpp \ diff --git a/src/corelib/global/qglobalstatic.cpp b/src/corelib/global/qglobalstatic.cpp new file mode 100644 index 0000000000..7caa2e9848 --- /dev/null +++ b/src/corelib/global/qglobalstatic.cpp @@ -0,0 +1,522 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Intel Corporation. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qglobalstatic.h" + +/*! + \macro Q_GLOBAL_STATIC(Type, VariableName) + \since 5.1 + \relates QGlobalStatic + + Creates a global and static object of type \l QGlobalStatic, of name \a + VariableName and that behaves as a pointer to \a Type. The object created + by Q_GLOBAL_STATIC initializes itself on the first use, which means that it + will not increase the application or the library's load time. Additionally, + the object is initialized in a thread-safe manner on all platforms. + + The typical use of this macro is as follows, in a global context (that is, + outside of any function bodies): + + \code + Q_GLOBAL_STATIC(MyType, staticType) + \endcode + + This macro is intended to replace global static objects that are not POD + (Plain Old Data, or in C++11 terms, not made of a trivial type), hence the + name. For example, the following C++ code creates a global static: + + \code + static MyType staticType; + \endcode + + Compared to Q_GLOBAL_STATIC, and assuming that \c MyType is a class or + struct that has a constructor, a destructor, or is otherwise non-POD, the + above has the following drawbacks: + + \list + \li it requires load-time initialization of \c MyType (that is, the + default constructor for \c MyType is called when the library or + application is loaded); + + \li the type will be initialized even if it is never used; + + \li the order of initialization and destruction among different + translation units is not determined, leading to possible uses before + initialization or after destruction; + + \li if it is found inside a function (that is, not global), it will be + initialized on first use, but many current compilers (as of 2013) do + not guarantee that the initialization will be thread-safe; + \endlist + + The Q_GLOBAL_STATIC macro solves all of the above problems by guaranteeing + thread-safe initialization on first use and allowing the user to query for + whether the type has already been destroyed, to avoid the + use-after-destruction problem (see QGlobalStatic::isDestroyed()). + + \section1 Constructor and destructor + + For Q_GLOBAL_STATIC, the type \c Type must be publicly + default-constructible and publicly destructible. For + Q_GLOBAL_STATIC_WITH_ARGS(), there must be a public constructor that + matches the arguments passed. + + It is not possible to use Q_GLOBAL_STATIC with types that have protected or + private default constructors or destructors (for Q_GLOBAL_STATIC_WITH_ARGS(), + a protected or private constructor matching the arguments). If the type in + question has those members as protected, it is possible to overcome the + issue by deriving from the type and creating public a constructor and + destructor. If the type has them as private, a friend declaration is + necessary before deriving. + + For example, the following is enough to create \c MyType based on a + previously-defined \c MyOtherType which has a protected default constructor + and/or a protected destructor (or has them as private, but that defines \c + MyType as a friend). + + \code + class MyType : public MyOtherType { }; + Q_GLOBAL_STATIC(MyType, staticType) + \endcode + + No body for \c MyType is required since the destructor is an implicit + member and so is the default constructor if no other constructors are + defined. For use with Q_GLOBAL_STATIC_WITH_ARGS(), however, a suitable + constructor body is necessary: + + \code + class MyType : public MyOtherType + { + public: + MyType(int i) : MyOtherType(i) {} + }; + Q_GLOBAL_STATIC_WITH_ARGS(MyType, staticType, (42)) + \endcode + + Alternatively, if the compiler supports C++11 inheriting constructors, one could write: + + \code + class MyType : public MyOtherType + { + public: + using MyOtherType::MyOtherType; + }; + Q_GLOBAL_STATIC_WITH_ARGS(MyType, staticType, (42)) + \endcode + + \section1 Placement + + The Q_GLOBAL_STATIC macro creates a type that is necessarily static, at the + global scope. It is not possible to place the Q_GLOBAL_STATIC macro inside + a function (doing so will result in compilation errors). + + More importantly, this macro should be placed in source files, never in + headers. Since the resulting object is has static linkage, if the macro is + placed in a header and included by multiple source files, the object will + be defined multiple times and will not cause linking errors. Instead, each + translation unit will refer to a different object, which could lead to + subtle and hard-to-track errors. + + \section1 Non-recommended uses + + Note that the macro is not recommended for use with types that are POD or + that have C++11 constexpr constructors (trivially constructible and + destructible). For those types, it is still recommended to use regular + static, whether global or function-local. + + This macro will work, but it will add unnecessary overhead. + + \section1 Reentrancy, thread-safety, deadlocks, and exception-safety on construction + + The Q_GLOBAL_STATIC macro creates an object that initializes itself on + first use in a thread-safe manner: if multiple threads attempt to + initialize the object at the same time, only one thread will proceed to + initialize, while all other threads wait for completion. + + If the initialization process throws an exception, the initialization is + deemed not complete and will be attempted again when control reaches any + use of the object. If there are any threads waiting for initialization, one + of them will be woken up to attempt to initialize. + + The macro makes no guarantee about reentrancy from the same thread. If the + global static object is accessed directly or indirectly from inside the + constructor, a deadlock will surely happen. + + In addition, if two Q_GLOBAL_STATIC objects are being initialized on two + different threads and each one's initialization sequence accesses the + other, a deadlock might happen. For that reason, it is recommended to keep + global static constructors simple or, failing that, to ensure that there's + no cross-dependency of uses of global static during construction. + + \section1 Destruction + + If the object is never used during the lifetime of the program, aside from + the QGlobalStatic::exists() and QGlobalStatic::isDestroyed() functions, the + contents of type \a Type will not be created and there will not be any + exit-time operation. + + If the object is created, it will be destroyed at exit-time, similar to the + C \c atexit function. On most systems, in fact, the destructor will also be + called if the library or plugin is unloaded from memory before exit. + + Since the destruction is meant to happen at program exit, no thread-safety + is provided. This includes the case of plugin or library unload. In + addition, since destructors are not supposed to throw exceptions, no + exception safety is provided either. + + However, reentrancy is permitted: during destruction, it is possible to + access the global static object and the pointer returned will be the same + as it was before destruction began. After the destruction has completed, + accessing the global static object is not permitted, except as noted in the + \l QGlobalStatic API. + + \omit + \section1 Compatibility with Qt 4 and Qt 5.0 + + This macro, in its current form and behavior, was introduced in Qt 5.1. + Prior to that version, Qt had another macro with the same name that was + private API. This section is not meant to document how to use + Q_GLOBAL_STATIC in those versions, but instead to serve as a porting guide + for Qt code that used those macros. + + The Qt 4 Q_GLOBAL_STATIC macro differed in behavior in the following ways: + + \list + \li the object created was not of type \l QGlobalStatic, but instead + it was a function that returned a pointer to \a Type; that means the + \l QGlobalStatic API was not present; + + \li the initialization was thread-safe, but not guaranteed to be + unique: instead, if N threads tried to initialize the object at the + same time, N objects would be created on the heap and N-1 would be + destroyed; + + \li the object was always created on the heap. + \endlist + + \section1 Implementation details + + Q_GLOBAL_STATIC is implemented by creating a QBasicAtomicInt called the \c + guard and a free, inline function called \c innerFunction. The guard + variable is initialized to value 0 (chosen so that the guard can be placed + in the .bss section of the binary file), which denotes that construction + has not yet taken place (uninitialized). The inner function is implemented + by the helper macro Q_GLOBAL_STATIC_INTERNAL. + + Both the guard variable and the inner function are passed as template + parameters to QGlobalStatic, along with the type \a Type. Both should also + have static linkage or be placed inside an anonymous namespace, so that the + visibility of Q_GLOBAL_STATIC is that of a global static. To permit + multiple Q_GLOBAL_STATIC per translation unit, the guard variable and the + inner function must have unique names, which can be accomplished by + concatenating with \a VariableName or by placing them in a namespace that + has \a VariableName as part of the name. To simplify and improve + readability on Q_GLOBAL_STATIC_INTERNAL, we chose the namespace solution. + It's also required for C++98 builds, since static symbols cannot be used as + template parameters. + + The guard variable can assume the following values: + + \list + \li -2: object was once initialized but has been destroyed already; + \li -1: object was initialized and is still valid; + \li 0: object was not initialized yet; + \li +1: object is being initialized and any threads encountering this + value must wait for completion (not used in the current implementation). + \endlist + + Collectively, all positive values indicate that the initialization is + progressing and must be waited on, whereas all negative values indicate + that the initialization has terminated and must not be attempted again. + Positive values are not used in the current implementation, but were in + earlier versions. They could be used again in the future. + + The QGlobalStatic::exists() and QGlobalStatic::isDestroyed() functions + operate solely on the guard variable: the former returns true if the guard + is negative, whereas the latter returns true only if it is -2. + + The Q_GLOBAL_STATIC_INTERNAL macro implements the actual construction and + destruction. There are two implementations of it: one for compilers that + support thread-safe initialization of function-local statics and one for + compilers that don't. Thread-safe initialization is required by C++11 in + [stmt.decl], but as of the time of this writing, only compilers based on + the IA-64 C++ ABI implemented it properly. The implementation requiring + thread-safe initialization is also used on the Qt bootstrapped tools, which + define QT_NO_THREAD. + + The implementation requiring thread-safe initialization from the compiler + is the simplest: it creates the \a Type object as a function-local static + and returns its address. The actual object is actually inside a holder + structure so holder's destructor can set the guard variable to the value -2 + (destroyed) when the type has finished destruction. Since we need to set + the guard \b after the destruction has finished, this code needs to be in a + base struct's destructor. A holder structure is used to avoid creating two + statics, which the ABI might require duplicating the thread-safe control + structures for. + + The other implementation is similar to Qt 4's Q_GLOBAL_STATIC, but unlike + that one, it uses a \l QBasicMutex to provide locking. It is also more + efficient memory-wise. It use a simple double-checked locking of the mutex + and then creates the contents on the heap. After that, it creates a + function-local structure called "Cleanup", whose destructor will be run at + program exit and will actually destroy the contents. + + \endomit + + \sa Q_GLOBAL_STATIC_WITH_ARGS(), QGlobalStatic +*/ + +/*! + \macro Q_GLOBAL_STATIC_WITH_ARGS(Type, VariableName, Arguments) + \since 5.1 + \relates QGlobalStatic + + Creates a global and static object of type \l QGlobalStatic, of name \a + VariableName, initialized by the arguments \a Arguments and that behaves as + a pointer to \a Type. The object created by Q_GLOBAL_STATIC_WITH_ARGS + initializes itself on the first use, which means that it will not increase + the application or the library's load time. Additionally, the object is + initialized in a thread-safe manner on all platforms. + + The typical use of this macro is as follows, in a global context (that is, + outside of any function bodies): + + \code + Q_GLOBAL_STATIC_WITH_ARGS(MyType, staticType, (42, "Hello", "World")) + \endcode + + The \a Arguments macro parameter must always include the parentheses or, if + C++11 uniform initialization is allowed, the braces. + + Aside from the actual initialization of the contents with the supplied + arguments, this macro behaves identically to Q_GLOBAL_STATIC(). Please + see that macro's documentation for more information. + + \sa Q_GLOBAL_STATIC(), QGlobalStatic +*/ + +/*! + \class QGlobalStatic + \threadsafe + \inmodule QtCore + \since 5.1 + \brief The QGlobalStatic class is used to implement a global static object + + The QGlobalStatic class is the front-end API exported when + Q_GLOBAL_STATIC() is used. See the documentation for the macro for a + discussion on when to use it and its requirements. + + Normally, you will never use this class directly, but instead you will use + the Q_GLOBAL_STATIC() or Q_GLOBAL_STATIC_WITH_ARGS() macros, as + follows: + + \code + Q_GLOBAL_STATIC(MyType, staticType) + \endcode + + The above example creates an object of type QGlobalStatic called \c + staticType. After the above declaration, the \c staticType object may be + used as if it were a pointer, guaranteed to be initialized exactly once. In + addition to the use as a pointer, the object offers two methods to + determine the current status of the global: exists() and isDestroyed(). + + \sa Q_GLOBAL_STATIC(), Q_GLOBAL_STATIC_WITH_ARGS() +*/ + +/*! + \typedef QGlobalStatic::Type + + This type is equivalent to the \c Type parameter passed to the + Q_GLOBAL_STATIC() or Q_GLOBAL_STATIC_WITH_ARGS() macros. It is used in the + return types of some functions. +*/ + +/*! + \fn bool QGlobalStatic::isDestroyed() const + + This function returns true if the global static object has already + completed destruction (that is, if the destructor for the type has already + returned). In specific, note that this function returns false if + the destruction is still in progress. + + Once this function has returned true once, it will never return + false again until either the program is restarted or the plugin or library + containing the global static is unloaded and reloaded. + + This function is safe to call at any point in the program execution: it + cannot fail and cannot cause a deadlock. Additionally, it will not cause + the contents to be created if they have not yet been created. + + This function is useful in code that may be executed at program shutdown, + to determine whether the contents may still be accessed or not. + + \omit + Due to the non-atomic nature of destruction, it's possible that + QGlobalStatic::isDestroyed might return false for a short time after the + destructor has finished. However, since the destructor is only run in an + environment where concurrent multithreaded access is impossible, no one can + see that state. (omitted because it's useless information) + \endomit + + \sa exists() +*/ + +/*! + \fn bool QGlobalStatic::exists() const + + This function returns true if the global static object has already + completed initialization (that is, if the constructor for the type has + already returned). In specific, note that this function returns false if + the initialization is still in progress. + + Once this function has returned true once, it will never return false again + until either the program is restarted or the plugin or library containing + the global static is unloaded and reloaded. + + This function is safe to call at any point in the program execution: it + cannot fail and cannot cause a deadlock. Additionally, it will not cause + the contents to be created if they have not yet been created. + + This function is useful if one can determine the initial conditions of the + global static object and would prefer to avoid a possibly expensive + construction operation. + + For example, in the following code sample, this function is used to + short-circuit the creation of the global static called \c globalState and + returns a default value: + + \code + Q_GLOBAL_STATIC(MyType, globalState) + QString someState() + { + if (globalState.exists()) + return globalState->someState; + return QString(); + } + \endcode + + \b{Thread-safety notice:} this function is thread-safe in the sense that it + may be called from any thread at any time and will always return a valid + reply. But due to the non-atomic nature of construction, this function may + return false for a short time after the construction has completed. + + \b{Memory ordering notice:} this function does not impose any memory + ordering guarantees. That is instead provided by the accessor functions + that return the pointer or reference to the contents. If you bypass the + accessor functions and attempt to access some global state set by the + constructor, be sure to use the correct memory ordering semantics provided + by \l QAtomicInt or \l QAtomicPointer. + + \sa isDestroyed() +*/ + +/*! + \fn QGlobalStatic::operator Type*() + + This function returns the address of the contents of this global static. If + the contents have not yet been created, they will be created thread-safely + by this function. If the contents have already been destroyed, this + function will return a null pointer. + + This function can be used, for example, to store the pointer to the + contents of the global static in a local variable, thus avoiding multiple + calls to the function. The implementation of Q_GLOBAL_STATIC() is quite + efficient already, but in performance-critical sections it might be useful + to help the compiler a little. For example: + + \code + Q_GLOBAL_STATIC(MyType, globalState) + QString someState() + { + MyType *state = globalState; + if (!state) { + // we're in a post-destruction state + return QString(); + } + if (state->condition) + return state->value1; + else + return state->value2; + } + \endcode + + \sa operator->(), operator*() +*/ + +/*! + \fn Type *QGlobalStatic::operator()() + \deprecated + + This function returns the address of the contents of this global static. If + the contents have not yet been created, they will be created thread-safely + by this function. If the contents have already been destroyed, this + function will return a null pointer. + + This function is equivalent to \l {operator Type *()}. It is provided for + compatibility with the private Q_GLOBAL_STATIC implementation that existed + in Qt 4.x and 5.0. New code should avoid using it and should instead treat + the object as a smart pointer. +*/ + +/*! + \fn Type *QGlobalStatic::operator->() + + This function returns the address of the contents of this global static. If + the contents have not yet been created, they will be created thread-safely + by this function. + + This function does not check if the contents have already been destroyed and + will never return null. If this function is called after the object has + been destroyed, it will return a dangling pointer that should not be + dereferenced. +*/ + +/*! + \fn Type &QGlobalStatic::operator*() + + This function returns a reference to the contents of this global static. If + the contents have not yet been created, they will be created thread-safely + by this function. + + This function does not check if the contents have already been destroyed. + If this function is called after the object has been destroyed, it will + return an invalid reference that must not be used. +*/ diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 78a4acff12..487b0dfdb4 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -49,19 +49,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -/* - * QGlobalStatic internals: - * - * The pointer is initialized to 0. - * The guard is initialized to 0. - * The guard can assume the following values: - * -2: object initialized and already destroyed - * -1: object initialized and is still valid - * 0: not initialized, the value of the pointer should be null - * +1: initializing, must wait until a state change happens - * (not used in the current implementation) - */ - namespace QtGlobalStatic { enum GuardValues { Destroyed = -2, -- cgit v1.2.3 From 07e3bcdc106ac42703ae0fb88b6cac2d2bfdd072 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Sat, 26 Jan 2013 21:42:12 +0100 Subject: Remove QT_{BEGIN,END}_HEADER macro usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp Reviewed-by: Jędrzej Nowacki Reviewed-by: hjk --- src/corelib/global/qendian.h | 4 ---- src/corelib/global/qflags.h | 4 ---- src/corelib/global/qglobal.h | 6 ------ src/corelib/global/qglobalstatic.h | 3 --- src/corelib/global/qisenum.h | 3 --- src/corelib/global/qlibraryinfo.h | 4 ---- src/corelib/global/qlogging.h | 3 --- src/corelib/global/qnamespace.h | 4 ---- src/corelib/global/qnumeric.h | 4 ---- src/corelib/global/qsysinfo.h | 3 --- src/corelib/global/qtypeinfo.h | 3 --- src/corelib/global/qtypetraits.h | 3 --- 12 files changed, 44 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index cdffb10d5a..c9c4d23aab 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -52,8 +52,6 @@ #include #endif -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -386,6 +384,4 @@ template <> inline qint8 qbswap(qint8 source) QT_END_NAMESPACE -QT_END_HEADER - #endif // QENDIAN_H diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index 4b75383213..4722fe2282 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -47,8 +47,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE class QFlag @@ -152,6 +150,4 @@ typedef uint Flags; QT_END_NAMESPACE -QT_END_HEADER - #endif // QFLAGS_H diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index f3be05a8ec..48df55e86e 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -151,14 +151,10 @@ namespace QT_NAMESPACE {} #endif /* __cplusplus */ -#define QT_BEGIN_HEADER -#define QT_END_HEADER - #if defined(Q_OS_DARWIN) && !defined(QT_LARGEFILE_SUPPORT) # define QT_LARGEFILE_SUPPORT 64 #endif -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE /* @@ -968,8 +964,6 @@ template struct QEnableIf { typedef T Type; }; } QT_END_NAMESPACE -QT_END_HEADER - // Q_GLOBAL_STATIC #include diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 487b0dfdb4..336512eac3 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -46,7 +46,6 @@ #include -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE namespace QtGlobalStatic { @@ -139,6 +138,4 @@ struct QGlobalStatic Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ()) QT_END_NAMESPACE -QT_END_HEADER - #endif // QGLOBALSTATIC_H diff --git a/src/corelib/global/qisenum.h b/src/corelib/global/qisenum.h index 073d5a591f..577007b455 100644 --- a/src/corelib/global/qisenum.h +++ b/src/corelib/global/qisenum.h @@ -62,9 +62,6 @@ #endif // shut up syncqt -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_END_NAMESPACE -QT_END_HEADER - #endif // QISENUM_H diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 054231b084..1a00a14caf 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -45,8 +45,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QLibraryInfo @@ -103,6 +101,4 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif // QLIBRARYINFO_H diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index 7d8f7313c8..a6f244698d 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -49,7 +49,6 @@ #pragma qt_no_master_include #endif -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE /* @@ -172,6 +171,4 @@ Q_CORE_EXPORT QtMessageHandler qInstallMessageHandler(QtMessageHandler); Q_CORE_EXPORT void qSetMessagePattern(const QString &messagePattern); QT_END_NAMESPACE -QT_END_HEADER - #endif // QLOGGING_H diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index e6cd166832..ebbfc9ca83 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -44,8 +44,6 @@ #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -1603,6 +1601,4 @@ public: QT_END_NAMESPACE -QT_END_HEADER - #endif // QNAMESPACE_H diff --git a/src/corelib/global/qnumeric.h b/src/corelib/global/qnumeric.h index f8e84825c0..25db5443eb 100644 --- a/src/corelib/global/qnumeric.h +++ b/src/corelib/global/qnumeric.h @@ -44,8 +44,6 @@ #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE @@ -65,6 +63,4 @@ Q_CORE_EXPORT double qInf(); QT_END_NAMESPACE -QT_END_HEADER - #endif // QNUMERIC_H diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h index c95c1674eb..edeef3c461 100644 --- a/src/corelib/global/qsysinfo.h +++ b/src/corelib/global/qsysinfo.h @@ -44,7 +44,6 @@ #ifndef QSYSINFO_H #define QSYSINFO_H -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE /* @@ -151,6 +150,4 @@ public: }; QT_END_NAMESPACE -QT_END_HEADER - #endif // QSYSINFO_H diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 754aa6712b..8e34c9792d 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -44,7 +44,6 @@ #ifndef QTYPEINFO_H #define QTYPEINFO_H -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE /* @@ -241,6 +240,4 @@ Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE); #endif QT_END_NAMESPACE -QT_END_HEADER - #endif // QTYPEINFO_H diff --git a/src/corelib/global/qtypetraits.h b/src/corelib/global/qtypetraits.h index 54b48667b4..7ccad067d0 100644 --- a/src/corelib/global/qtypetraits.h +++ b/src/corelib/global/qtypetraits.h @@ -109,7 +109,6 @@ #include // For pair -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE namespace QtPrivate { @@ -505,6 +504,4 @@ Q_STATIC_ASSERT(( is_signed::value)); } // namespace QtPrivate QT_END_NAMESPACE -QT_END_HEADER - #endif // QTYPETRAITS_H -- cgit v1.2.3 From d315e012184a2b71b7b5e41869d166c05093d13d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 23 Nov 2012 15:24:48 +0100 Subject: Add the Qt::ItemNeverHasChildren flag and use it in QTreeView. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It can be used to determine whether expand() should really expand. Change-Id: If79d8c295a4ca1356e60051682b227524a065126 Reviewed-by: David Faure (KDE) Reviewed-by: Olivier Goffart Reviewed-by: Thorbjørn Lund Martsum --- src/corelib/global/qnamespace.h | 3 ++- src/corelib/global/qnamespace.qdoc | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index ebbfc9ca83..a60743d3df 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1395,7 +1395,8 @@ public: ItemIsDropEnabled = 8, ItemIsUserCheckable = 16, ItemIsEnabled = 32, - ItemIsTristate = 64 + ItemIsTristate = 64, + ItemNeverHasChildren = 128 }; Q_DECLARE_FLAGS(ItemFlags, ItemFlag) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index f157190591..b271620ee0 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2441,6 +2441,7 @@ \value ItemIsUserCheckable It can be checked or unchecked by the user. \value ItemIsEnabled The user can interact with the item. \value ItemIsTristate The item is checkable with three separate states. + \value ItemNeverHasChildren The item never has child items. Note that checkable items need to be given both a suitable set of flags and an initial state, indicating whether the item is checked or not. -- cgit v1.2.3 From 1e33f30f75dea6481c85b5f636f1136eb1a3da15 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Wed, 30 Jan 2013 20:06:45 +0100 Subject: Remove left-overs of QT_{BEGIN,END}_HEADERS This macro is useless from Qt 5.1 on, so: - Remove comment about using QT_BEGIN_NAMESPACE after QT_BEGIN_HEADER - There is no need to blacklist these in qt-cpp-ignore.qdocconf Change-Id: I2c3ceb3d77d294a606b87f7486071a2350b3d42f Reviewed-by: Laszlo Papp Reviewed-by: hjk Reviewed-by: Lars Knoll Reviewed-by: Jerome Pasion --- src/corelib/global/qglobal.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 454e5d828d..8bbc44978d 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2792,8 +2792,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) As a rule of thumb, \c QT_BEGIN_NAMESPACE should appear in all Qt header and Qt source files after the last \c{#include} line and before the first - declaration. In Qt headers using \c QT_BEGIN_HEADER, \c QT_BEGIN_NAMESPACE - follows \c QT_BEGIN_HEADER immediately. + declaration. If that rule can't be followed because, e.g., \c{#include} lines and declarations are wildly mixed, place \c QT_BEGIN_NAMESPACE before -- cgit v1.2.3 From 8779d73d8c525443a5add158cf1e9b1d8bf16caf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 28 Jan 2013 20:16:05 -0800 Subject: Put #ifdef around Windows-only function Only on Windows do we use wchar_t messages. Change-Id: I9672371aa001effc755b32f9d7c83ada8464394f Reviewed-by: Olivier Goffart Reviewed-by: Kai Koehne --- src/corelib/global/qlogging.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 20e649bab5..c3ce405156 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -115,6 +115,7 @@ static bool isFatal(QtMsgType msgType) extern bool usingWinMain; #endif +#ifdef Q_OS_WIN static inline void convert_to_wchar_t_elided(wchar_t *d, size_t space, const char *s) Q_DECL_NOEXCEPT { size_t len = qstrlen(s); @@ -128,6 +129,7 @@ static inline void convert_to_wchar_t_elided(wchar_t *d, size_t space, const cha *d++ = *s++; *d++ = 0; } +#endif #if !defined(QT_NO_EXCEPTIONS) /*! -- cgit v1.2.3 From f316502d58c947863f5caf17c64dc68d865162a4 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Sun, 3 Feb 2013 13:08:26 +0100 Subject: Add QT_{BEGIN,END}_HEADER definition back This commit partially reverts 07e3bcdc106ac42703ae0fb88b6cac2d2bfdd072 The empty macro defition was not supposed to be removed yet. Change-Id: Ie83b2adbe2328b83c70a70274a401e1e6c74498f Reviewed-by: David Faure (KDE) --- src/corelib/global/qglobal.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 48df55e86e..1c76c54ad6 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -151,6 +151,9 @@ namespace QT_NAMESPACE {} #endif /* __cplusplus */ +#define QT_BEGIN_HEADER +#define QT_END_HEADER + #if defined(Q_OS_DARWIN) && !defined(QT_LARGEFILE_SUPPORT) # define QT_LARGEFILE_SUPPORT 64 #endif -- cgit v1.2.3 From c6ac59cc91e6a5efb59857c28317329175658a0f Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Wed, 6 Feb 2013 00:12:27 +0100 Subject: Add note about QT_{BEGIN,END}_HEADER removal for Qt 6 This macro usage has been removed from most of the Qt 5 code, so adding a note to be completely removed in Qt 6. Change-Id: I19a90db78745f3cacbcbf206e8642c7d7c36e04a Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 1c76c54ad6..4ee91d821c 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -151,6 +151,7 @@ namespace QT_NAMESPACE {} #endif /* __cplusplus */ +// ### Qt6: remove me. #define QT_BEGIN_HEADER #define QT_END_HEADER -- cgit v1.2.3 From 574e5cf9c510fb28781c8006a1184ca158ee859f Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 12 Jan 2013 10:12:47 +0100 Subject: Add qunsetenv(), next to qputenv() and friends. The existing tst_qgetputenv shows that qputenv with an empty value doesn't lead to the same result on Windows and on Unix, and there was no way to fully delete an env var on Unix (which is needed for some env vars where not-set and empty are different, such as TZ, see `man tzset`). This is also why qglobal has qEnvironmentVariableIsSet() vs qEnvironmentVariableIsEmpty(), on the getter side. Qt4's ifdefs around unsetenv in qapplication_x11.cpp show that this is needed within Qt too (although this particular startup notification code has to be re-imported into Qt5 still). Change-Id: I631c8cddbcf933d4b9008f11aefc59f5a3c7c866 Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/corelib/global/qglobal.h | 1 + 2 files changed, 38 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 8bbc44978d..9cd19ccae9 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2171,6 +2171,10 @@ bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT \a varName. It will create the variable if it does not exist. It returns 0 if the variable could not be set. + Calling qputenv with an empty value removes the environment variable on + Windows, and makes it set (but empty) on Unix. Prefer using qunsetenv() + for fully portable behavior. + \note qputenv() was introduced because putenv() from the standard C library was deprecated in VC2005 (and later versions). qputenv() uses the replacement function in VC, and calls the standard C @@ -2197,6 +2201,39 @@ bool qputenv(const char *varName, const QByteArray& value) #endif } +/*! + \relates + + This function deletes the variable \a varName from the environment. + + Returns true on success. + + \since 5.1 + + \sa qputenv(), qgetenv() +*/ +bool qunsetenv(const char *varName) +{ +#if defined(_MSC_VER) && _MSC_VER >= 1400 + return _putenv_s(varName, "") == 0; +#elif (defined(_POSIX_VERSION) && (_POSIX_VERSION-0) >= 200112L) || defined(Q_OS_BSD4) + // POSIX.1-2001 and BSD have unsetenv + return unsetenv(varName) == 0; +#elif defined(Q_CC_MINGW) + // On mingw, putenv("var=") removes "var" from the environment + QByteArray buffer(varName); + buffer += '='; + return putenv(buffer.constData()) == 0; +#else + // Fallback to putenv("var=") which will insert an empty var into the + // environment and leak it + QByteArray buffer(varName); + buffer += '='; + char *envVar = qstrdup(buffer.constData()); + return putenv(envVar) == 0; +#endif +} + #if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) # if defined(Q_OS_INTEGRITY) && defined(__GHS_VERSION_NUMBER) && (__GHS_VERSION_NUMBER < 500) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 4ee91d821c..73e849cb3e 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -934,6 +934,7 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1); class QByteArray; Q_CORE_EXPORT QByteArray qgetenv(const char *varName); Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value); +Q_CORE_EXPORT bool qunsetenv(const char *varName); Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) Q_DECL_NOEXCEPT; Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) Q_DECL_NOEXCEPT; -- cgit v1.2.3 From adb0cfc24c17f35067cb9aa58c2fae1392872091 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 28 Jan 2013 19:33:27 -0800 Subject: Add Q_DECL_UNUSED, marking functions or variables unused It's similar to Q_UNUSED, but this is to be added in the declaration Change-Id: I2f664129fb1f34f7913ef371d45c2c0fec958174 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index d062ea0d15..a4af8b8899 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -179,6 +179,7 @@ # define Q_TYPEOF(expr) __typeof__(expr) # define Q_DECL_DEPRECATED __attribute__ ((__deprecated__)) # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) +# define Q_DECL_UNUSED __attribute__((__unused__)) # define Q_LIKELY(expr) __builtin_expect(!!(expr), true) # define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false) # define Q_NORETURN __attribute__((__noreturn__)) @@ -816,6 +817,9 @@ #ifndef Q_DECL_HIDDEN # define Q_DECL_HIDDEN #endif +#ifndef Q_DECL_UNUSED +# define Q_DECL_UNUSED +#endif #ifndef Q_FUNC_INFO # if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC) # define Q_FUNC_INFO __FILE__ "(line number unavailable)" -- cgit v1.2.3 From 0768920dbdabef25eb7d41e8dbba891704b24f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 16 Feb 2013 14:56:50 +0100 Subject: Remove ifdefs for supporting Mac OS <= 10.5 Qt5 requires Mac OS 10.6, so we can remove checks such as if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 Change-Id: Iea21727a277291148704ecf9677ed0b68c24920f Reviewed-by: Thiago Macieira --- src/corelib/global/qsystemdetection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index 5f9671932f..b7c586a3e2 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -178,7 +178,7 @@ # ifdef MAC_OS_X_VERSION_MIN_REQUIRED # undef MAC_OS_X_VERSION_MIN_REQUIRED # endif -# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4 +# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6 # include # if !defined(MAC_OS_X_VERSION_10_3) # define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1 -- cgit v1.2.3 From 193e3ba32e0c808b48216d9d96aa88e591dd189f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 16 Feb 2013 15:03:33 +0100 Subject: Don't override OS X deployment target unconditionally in qsystemdetection.h AvailabilityMacros.h will pick up the MACOSX_DEPLOYMENT_TARGET environment variable, as well as the -mmacosx-min-version= command line flag, and set the MAC_OS_X_VERSION_MIN_REQUIRED based on that. By setting the define before including AvailabilityMacros.h we essentially skipped that whole logic and always set it to 10.6. Only in the case where there's no deployment target specified on the command line do we want to ensure that it's at least 10.6 Change-Id: Ic558ff4deb77937ea805b048d83949815b273bcc Reviewed-by: Thiago Macieira --- src/corelib/global/qsystemdetection.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index b7c586a3e2..f8a61962ec 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -175,11 +175,12 @@ #endif #ifdef Q_OS_DARWIN -# ifdef MAC_OS_X_VERSION_MIN_REQUIRED -# undef MAC_OS_X_VERSION_MIN_REQUIRED -# endif -# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6 # include +# if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 +# undef MAC_OS_X_VERSION_MIN_REQUIRED +# define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6 +# endif +# # if !defined(MAC_OS_X_VERSION_10_3) # define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1 # endif -- cgit v1.2.3 From 4e78ce288aa67caddea65cd070663e95dc4f7183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 16 Feb 2013 17:16:53 +0100 Subject: Start using Availability.h over AvailabilityMacros.h on Mac OS The former was introduced with Mac OS 10.6 and can also be used for checking iOS versions, so it's preferable. We still include the old availability header, and use it in various places in Qt, and so does the Mac OS frameworks, so there's no need to phase it out, but for new platform checks we want to use the updated macros of the form: #if __MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_7 Ideally you should not use the named version macro, and use 1070 instead, in case you build against an SDK that does not define the named version yet, but we take care of defining these in qsystemdetection.h for convenience. Change-Id: I9cfa72e37816583f28ff9643793f111e155b7789 Reviewed-by: Thiago Macieira --- src/corelib/global/qsystemdetection.h | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index f8a61962ec..eb7aa2e64f 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -175,31 +175,34 @@ #endif #ifdef Q_OS_DARWIN +# include +# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_6 +# undef __MAC_OS_X_VERSION_MIN_REQUIRED +# define __MAC_OS_X_VERSION_MIN_REQUIRED __MAC_10_6 +# endif # include # if !defined(MAC_OS_X_VERSION_MIN_REQUIRED) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 # undef MAC_OS_X_VERSION_MIN_REQUIRED # define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6 # endif # -# if !defined(MAC_OS_X_VERSION_10_3) -# define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1 -# endif -# if !defined(MAC_OS_X_VERSION_10_4) -# define MAC_OS_X_VERSION_10_4 MAC_OS_X_VERSION_10_3 + 1 -# endif -# if !defined(MAC_OS_X_VERSION_10_5) -# define MAC_OS_X_VERSION_10_5 MAC_OS_X_VERSION_10_4 + 1 +# // Numerical checks are preferred to named checks, but to be safe +# // we define the missing version names in case Qt uses them. +# +# if !defined(__MAC_10_7) +# define __MAC_10_7 1070 # endif -# if !defined(MAC_OS_X_VERSION_10_6) -# define MAC_OS_X_VERSION_10_6 MAC_OS_X_VERSION_10_5 + 1 +# if !defined(__MAC_10_8) +# define __MAC_10_8 1080 # endif # if !defined(MAC_OS_X_VERSION_10_7) -# define MAC_OS_X_VERSION_10_7 MAC_OS_X_VERSION_10_6 + 1 +# define MAC_OS_X_VERSION_10_7 1070 # endif # if !defined(MAC_OS_X_VERSION_10_8) -# define MAC_OS_X_VERSION_10_8 MAC_OS_X_VERSION_10_7 + 1 +# define MAC_OS_X_VERSION_10_8 1080 # endif -# if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_8) +# +# if (__MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_8) # warning "This version of Mac OS X is unsupported" # endif #endif -- cgit v1.2.3 From f2191d9900cbb9930e2fbdefb4682ce59769e007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 16 Feb 2013 17:31:58 +0100 Subject: Introduce macros for simplifying platform checks on Mac OS and iOS Change-Id: Ibab8486e1e6d7e4d8922fce96add055e60c6095c Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 73e849cb3e..233743f3ce 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -512,6 +512,16 @@ template Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max) { return qMax(min, qMin(max, val)); } +#ifdef Q_OS_DARWIN +# define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) \ + (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= osx) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios) + +# define QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, ios) \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && osx != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < osx) || \ + (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MIN_REQUIRED < ios) +#endif + /* Data stream functions are provided by many classes (defined in qdatastream.h) */ -- cgit v1.2.3 From 22077e1609c8a5af39d48ddfb65066581ef15c0d Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 28 Jan 2013 15:16:02 +0100 Subject: QPA: Add interface for setting the application state explicitly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The motivation for this patch is twofold: 1: we need a way (for iOS/Android) to tell the current window to remove focus from the focus object when the user hides the input panel. Otherwise, if the focus object is e.g a line edit, the cursor will continue to blink inside it, which is wrong. As it stands, telling the active window to deactivate (by calling QWindowSystemInterface::handleWindowActivated(0)), will cause the whole application to deactivate if no windows are active, which is not what we want. 2: Qt currently understands just two application states, Activated and Deactivated. On mobile platforms we can have other states as well, like "suspended" on iOS. So controlling the application state should not depend on window activation, but instead be controlled through a separate API by the platform plugin. This patch will add the following function: QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState newState) that lets us control the application state from the plugin. This also means that we factor out application state handling from window activation, which also gives us a way to remove focus from a window while keeping the application active. To not break existing desktop platforms that relies on application activation being tied to window activation, we need to make this API opt-in by using a platform integration capability hint. This is not optimal, but found necessary after investigating several other solutions. Which states (other that active/inactive) it makes sense to add to Qt::ApplicationState will be a topic for later patches. Change-Id: Ic6fdd3b66867abb67da43eba04ec86f06d82ff94 Reviewed-by: Friedemann Kleint Reviewed-by: Samuel Rødal --- src/corelib/global/qnamespace.h | 7 +++++++ src/corelib/global/qnamespace.qdoc | 15 +++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index a60743d3df..c8a615a1f7 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -325,6 +325,13 @@ public: Q_DECLARE_FLAGS(WindowStates, WindowState) + enum ApplicationState { + ApplicationInactive = 0x00000000, + ApplicationActive = 0x00000001 + }; + + Q_DECLARE_FLAGS(ApplicationStates, ApplicationState) + enum ScreenOrientation { PrimaryOrientation = 0x00000000, PortraitOrientation = 0x00000001, diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 1f1ff36442..248cdbce96 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1782,6 +1782,21 @@ */ +/*! + \enum Qt::ApplicationState + + \keyword application state + + This enum type is used to specify the current state of the application. + + The states are + + \value ApplicationInactive The application is running in the background. + \value ApplicationActive The application is running in the foreground. + + \since 5.1 +*/ + /*! \enum Qt::ScreenOrientation -- cgit v1.2.3 From 3bc4afc223bcd56245797a0bd3628f02a992301c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 1 Nov 2012 12:31:50 +0100 Subject: iOS: Move Q_OS_IOS out of makesespec to qsystemdetection.h We treat iOS as a variant of Mac OS, so for iOS both Q_OS_MAC and Q_OS_IOS will be defined. This matches what Apple assumes in the header file TargetConditionals.h Change-Id: I55cc851401b748297478e4c32e84e0f6e1fdfc28 Reviewed-by: Thiago Macieira --- src/corelib/global/qsystemdetection.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index eb7aa2e64f..86c724ebb5 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -50,6 +50,8 @@ The operating system, must be one of: (Q_OS_x) DARWIN - Darwin OS (synonym for Q_OS_MAC) + MAC - Mac OS X or iOS (iPhoneOS) + IOS - iOS (treated as a variant of Mac OS) MSDOS - MS-DOS and Windows OS2 - OS/2 OS2EMX - XFree86 on OS/2 (not PM) @@ -166,6 +168,10 @@ # elif defined(Q_OS_DARWIN32) # define Q_OS_MAC32 # endif +# include +# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +# define Q_OS_IOS +# endif #endif #if defined(Q_OS_WIN) -- cgit v1.2.3 From 212ff4f34de927d1efb4845654b74d4bba8d73b7 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 22 Jan 2013 17:18:36 +0100 Subject: Add multi-line input method hint Enabler for input on Android. Change-Id: I44670b95b35f773814125c5d35c67e9713567813 Reviewed-by: BogDan Vatra Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/global/qnamespace.h | 2 ++ src/corelib/global/qnamespace.qdoc | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index c8a615a1f7..6f977d847d 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1305,6 +1305,8 @@ public: ImhPreferLatin = 0x200, + ImhMultiLine = 0x400, + ImhDigitsOnly = 0x10000, ImhFormattedNumbersOnly = 0x20000, ImhUppercaseOnly = 0x40000, diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 248cdbce96..e1c64aab94 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2330,6 +2330,8 @@ \value ImhTime The text editor functions as a time field. \value ImhPreferLatin Latin characters are preferred (but not required). + \value ImhMultiLine Multiple lines can be entered into the text field. + Flags that restrict input (exclusive flags): \value ImhDigitsOnly Only digits are allowed. -- cgit v1.2.3 From 123ce761c058acc0222792e96c9aba22d06e619c Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 5 Feb 2013 13:20:31 +0100 Subject: QT_MESSAGE_OUTPUT: add support for condition depending on the type The motivation is to enable coloration the way KDE currently does. It can now be achieved with a QT_MESSAGE_OUTPUT set to "%{appname}(%{category}) \033[31m%{if-debug}\033[34m%{endif}%{function}\033[0m: %{message}" I was thinking about supporting directly color using something like %{begin-category-color} that would be smart and detect if we are running on a terminal, but it would be less flexible in the way the colors van be configured. Changelog: QT_MESSAGE_OUTPUT can contain conditionals based on the type of the message Change-Id: Icd8de04734a94a3afcbf542a5b78b290a1914960 Reviewed-by: David Faure (KDE) --- src/corelib/global/qlogging.cpp | 87 +++++++++++++++++++++++++++++++++-------- 1 file changed, 71 insertions(+), 16 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index c3ce405156..7204efc752 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -523,6 +523,11 @@ static const char functionTokenC[] = "%{function}"; static const char pidTokenC[] = "%{pid}"; static const char appnameTokenC[] = "%{appname}"; static const char threadidTokenC[] = "%{threadid}"; +static const char ifDebugTokenC[] = "%{if-debug}"; +static const char ifWarningTokenC[] = "%{if-warning}"; +static const char ifCriticalTokenC[] = "%{if-critical}"; +static const char ifFatalTokenC[] = "%{if-fatal}"; +static const char endifTokenC[] = "%{endif}"; static const char emptyTokenC[] = ""; static const char defaultPattern[] = "%{message}"; @@ -609,6 +614,10 @@ void QMessagePattern::setPattern(const QString &pattern) tokens = new const char*[lexemes.size() + 1]; tokens[lexemes.size()] = 0; + bool nestedIfError = false; + bool inIf = false; + QString error; + for (int i = 0; i < lexemes.size(); ++i) { const QString lexeme = lexemes.at(i); if (lexeme.startsWith(QLatin1String("%{")) @@ -632,23 +641,28 @@ void QMessagePattern::setPattern(const QString &pattern) tokens[i] = appnameTokenC; else if (lexeme == QLatin1String(threadidTokenC)) tokens[i] = threadidTokenC; - else { - tokens[i] = emptyTokenC; - QString error = QStringLiteral("QT_MESSAGE_PATTERN: Unknown placeholder %1\n") +#define IF_TOKEN(LEVEL) \ + else if (lexeme == QLatin1String(LEVEL)) { \ + if (inIf) \ + nestedIfError = true; \ + tokens[i] = LEVEL; \ + inIf = true; \ + } + IF_TOKEN(ifDebugTokenC) + IF_TOKEN(ifWarningTokenC) + IF_TOKEN(ifCriticalTokenC) + IF_TOKEN(ifFatalTokenC) +#undef IF_TOKEN + else if (lexeme == QLatin1String(endifTokenC)) { + tokens[i] = endifTokenC; + if (!inIf && !nestedIfError) + error += QStringLiteral("QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n"); + inIf = false; + } else { + tokens[i] = emptyTokenC; + error += QStringLiteral("QT_MESSAGE_PATTERN: Unknown placeholder %1\n") .arg(lexeme); - -#if defined(Q_OS_WINCE) - OutputDebugString(reinterpret_cast(error.utf16())); - continue; -#elif defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB) - if (usingWinMain) { - OutputDebugString(reinterpret_cast(error.utf16())); - continue; - } -#endif - fprintf(stderr, "%s", error.toLocal8Bit().constData()); - fflush(stderr); } } else { char *literal = new char[lexeme.size() + 1]; @@ -658,6 +672,24 @@ void QMessagePattern::setPattern(const QString &pattern) tokens[i] = literal; } } + if (nestedIfError) + error += QStringLiteral("QT_MESSAGE_PATTERN: %{if-*} cannot be nested\n"); + else if (inIf) + error += QStringLiteral("QT_MESSAGE_PATTERN: missing %{endif}\n"); + if (!error.isEmpty()) { +#if defined(Q_OS_WINCE) + OutputDebugString(reinterpret_cast(error.utf16())); + if (0) +#elif defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB) + if (usingWinMain) { + OutputDebugString(reinterpret_cast(error.utf16())); + } else +#endif + { + fprintf(stderr, "%s", error.toLocal8Bit().constData()); + fflush(stderr); + } + } literals = new const char*[literalsVar.size() + 1]; literals[literalsVar.size()] = 0; memcpy(literals, literalsVar.constData(), literalsVar.size() * sizeof(const char*)); @@ -737,10 +769,16 @@ Q_CORE_EXPORT QString qMessageFormatString(QtMsgType type, const QMessageLogCont if (pattern->tokens[0] == 0) return message; + bool skip = false; + // we do not convert file, function, line literals to local encoding due to overhead for (int i = 0; pattern->tokens[i] != 0; ++i) { const char *token = pattern->tokens[i]; - if (token == messageTokenC) { + if (token == endifTokenC) { + skip = false; + } else if (skip) { + // do nothing + } else if (token == messageTokenC) { message.append(str); } else if (token == categoryTokenC) { message.append(QLatin1String(context.category)); @@ -772,6 +810,14 @@ Q_CORE_EXPORT QString qMessageFormatString(QtMsgType type, const QMessageLogCont message.append(QLatin1String("0x")); message.append(QString::number(qlonglong(QThread::currentThread()->currentThread()), 16)); #endif +#define HANDLE_IF_TOKEN(LEVEL) \ + } else if (token == if##LEVEL##TokenC) { \ + skip = type != Qt##LEVEL##Msg; + HANDLE_IF_TOKEN(Debug) + HANDLE_IF_TOKEN(Warning) + HANDLE_IF_TOKEN(Critical) + HANDLE_IF_TOKEN(Fatal) +#undef HANDLE_IF_TOKEN } else { message.append(QLatin1String(token)); } @@ -1011,6 +1057,15 @@ void qErrnoWarning(int code, const char *msg, ...) \row \li \c %{type} \li "debug", "warning", "critical" or "fatal" \endtable + You can also use conditionals on the type of the message using \c %{if-debug}, + \c %{if-warning}, \c %{if-critical} or \c %{if-fatal} followed by an \c %{endif}. + What is inside the \c %{if-*} and \c %{endif} will only be printed if the type matches. + + Example: + \code + QT_MESSAGE_PATTERN="[%{if-debug}D%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}" + \endcode + The default \a pattern is "%{message}". The \a pattern can also be changed at runtime by setting the QT_MESSAGE_PATTERN -- cgit v1.2.3 From 0c1ae5f8660941fed55c468487635c9a74846f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 21 Feb 2013 08:07:04 +0100 Subject: iOS: Add potentially undefined version defines to qsystemdetection.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unless we're building on the 6.1 SDK some of the version defines will not be defined in Availability.h, so we define them ourselves so that Qt can still use them. Change-Id: Ibb45e9f8f4e888fc57e35286bf15d2fee2c1a217 Reviewed-by: Morten Johan Sørvig --- src/corelib/global/qsystemdetection.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index 86c724ebb5..6062dc7b7b 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -208,6 +208,22 @@ # define MAC_OS_X_VERSION_10_8 1080 # endif # +# if !defined(__IPHONE_4_3) +# define __IPHONE_4_3 40300 +# endif +# if !defined(__IPHONE_5_0) +# define __IPHONE_5_0 50000 +# endif +# if !defined(__IPHONE_5_1) +# define __IPHONE_5_1 50100 +# endif +# if !defined(__IPHONE_6_0) +# define __IPHONE_6_0 60000 +# endif +# if !defined(__IPHONE_6_1) +# define __IPHONE_6_1 60100 +# endif +# # if (__MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_8) # warning "This version of Mac OS X is unsupported" # endif -- cgit v1.2.3 From 50d3a2917e37cd173f373a83542314002b2ab6c7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 27 Feb 2013 15:48:17 -0800 Subject: Fix Q_GLOBAL_STATIC support for exceptions The problem was that the HolderBase destructor was getting called after the contained type's constructor threw an exception, as is required by RAII semantics (the base was fully initialized, so it had to be destroyed). That was required because we want to return a non-null pointer from operator() during destruction and return null after destruction, to keep compatibility with Qt 4. The solution is to only set the guard to Destroyed only if it is already at value Initialized. This way, if the HolderBase destructor is run as part of the stack unwinding, it knows that the construction did not complete. Change-Id: I9849b43ed7112bf9e70861b48a56a924c286617e Reviewed-by: Olivier Goffart --- src/corelib/global/qglobalstatic.cpp | 8 +++++--- src/corelib/global/qglobalstatic.h | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qglobalstatic.cpp b/src/corelib/global/qglobalstatic.cpp index 7caa2e9848..8474d132b4 100644 --- a/src/corelib/global/qglobalstatic.cpp +++ b/src/corelib/global/qglobalstatic.cpp @@ -288,9 +288,11 @@ structure so holder's destructor can set the guard variable to the value -2 (destroyed) when the type has finished destruction. Since we need to set the guard \b after the destruction has finished, this code needs to be in a - base struct's destructor. A holder structure is used to avoid creating two - statics, which the ABI might require duplicating the thread-safe control - structures for. + base struct's destructor. And it only sets to -2 (destroyed) if it finds + the guard at -1 (initialized): this is done to ensure that the guard isn't + set to -2 in the event the type's constructor threw an exception. A holder + structure is used to avoid creating two statics, which the ABI might + require duplicating the thread-safe control structures for. The other implementation is similar to Qt 4's Q_GLOBAL_STATIC, but unlike that one, it uses a \l QBasicMutex to provide locking. It is also more diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 336512eac3..a6268e057e 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -68,7 +68,8 @@ enum GuardValues { { \ struct HolderBase { \ ~HolderBase() Q_DECL_NOTHROW \ - { guard.store(QtGlobalStatic::Destroyed); } \ + { if (guard.load() == QtGlobalStatic::Initialized) \ + guard.store(QtGlobalStatic::Destroyed); } \ }; \ static struct Holder : public HolderBase { \ Type value; \ -- cgit v1.2.3 From e786a347c8f8a90f5c5d0fa0d198e343e96c82d2 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 14 Feb 2013 09:10:53 +0200 Subject: Add __ARM_ARCH_5TE__ to Q_PROCESSOR_ARM_V5 Android uses this define for armv5. Change-Id: Iee32f3e8691fa731ab0c2185a01620e18741f9a4 Reviewed-by: Thiago Macieira Reviewed-by: BogDan Vatra --- src/corelib/global/qprocessordetection.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h index c005c5446e..86023d1703 100644 --- a/src/corelib/global/qprocessordetection.h +++ b/src/corelib/global/qprocessordetection.h @@ -118,6 +118,7 @@ # define Q_PROCESSOR_ARM_V6 # define Q_PROCESSOR_ARM_V5 # elif defined(__ARM_ARCH_5TEJ__) \ + || defined(__ARM_ARCH_5TE__) \ || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) \ || (defined(_M_ARM) && _M_ARM-0 >= 5) # define Q_PROCESSOR_ARM_V5 -- cgit v1.2.3 From d93b2ef968f70fe2dd66f0879cc13ad4170e8553 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 22 Dec 2012 13:10:53 -0800 Subject: Mark all qtbase headers that aren't clean QtCore has a few headers that, though public, aren't meant to be included directly. Those are the atomic headers, the three _impl.h headers and qt_windows.h. QtGui includes two OpenGL headers that don't compile on their own. Other libraries should not have headers like that (but they do, something we need to fix eventually). Change-Id: I55e4eb057748f47df927ee618f9409acbc189cc1 Reviewed-by: Sean Harmer Reviewed-by: Gunnar Sletta Reviewed-by: Thiago Macieira --- src/corelib/global/qt_windows.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qt_windows.h b/src/corelib/global/qt_windows.h index 26b55336ed..c3266c5487 100644 --- a/src/corelib/global/qt_windows.h +++ b/src/corelib/global/qt_windows.h @@ -42,6 +42,11 @@ #ifndef QT_WINDOWS_H #define QT_WINDOWS_H +#if 0 +#pragma qt_sync_skip_header_check +#pragma qt_sync_stop_processing +#endif + #if defined(Q_CC_BOR) // Borland's windows.h does not set these correctly, resulting in // unusable WinSDK standard dialogs -- cgit v1.2.3 From e27ca37d18a1a2bbddce3479e34fa12b88ba481c Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 28 Feb 2013 14:57:27 +0100 Subject: ApplicationStates: add more states to Qt::ApplicationState MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On mobile platforms, Qt::ApplicationActive and Qt::ApplicationInactive are not sufficient to describe the different states an application can be in. This patch introduces Qt::ApplicationHidden and Qt::ApplicationSuspended that should fill in the gaps, at least on Android and iOS. Change-Id: I3f5a584cf6f4832e7c81dea095dcf711a8866c38 Reviewed-by: Samuel Rødal Reviewed-by: Gunnar Sletta --- src/corelib/global/qnamespace.h | 6 ++++-- src/corelib/global/qnamespace.qdoc | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 6f977d847d..41bca2a443 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -326,8 +326,10 @@ public: Q_DECLARE_FLAGS(WindowStates, WindowState) enum ApplicationState { - ApplicationInactive = 0x00000000, - ApplicationActive = 0x00000001 + ApplicationSuspended = 0x00000000, + ApplicationHidden = 0x00000001, + ApplicationInactive = 0x00000002, + ApplicationActive = 0x00000004 }; Q_DECLARE_FLAGS(ApplicationStates, ApplicationState) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index e1c64aab94..8ec206a572 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1791,8 +1791,23 @@ The states are - \value ApplicationInactive The application is running in the background. - \value ApplicationActive The application is running in the foreground. + \value ApplicationSuspended The application is about to suspend. When entering this state, the + application should save its state, cease all activities, and be + prepared for code execution to stop. While suspended, the + application can be killed at any time without further warnings + (e.g. when low memory forces the OS to purge suspended applications). + \value ApplicationHidden The application is hidden and runs in the background. This + is the normal state for applications that need to do background + processing, like playing music, while the user interacts with + other applications. The application should free up all graphical + resources when entering this state. + \value ApplicationInactive The application is visible, but not selected to be in front. + On desktop platforms, this typically means that the user + activated another application. On mobile platforms, it is + more common to enter this state when the OS is interrupting + the user with e.g. incoming calls or SMS-messages. + While in this state, consider reducing CPU-intensive tasks. + \value ApplicationActive The application is visible and selected to be in front. \since 5.1 */ -- cgit v1.2.3 From 97fcf3bc987a18f32233fea550eb4a5a22e2b822 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 4 Mar 2013 10:16:42 +0100 Subject: Introducing the Qt Android port MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on the Necessitas project by Bogdan Vatra. Contributors to the Qt5 project: BogDan Vatra Eskil Abrahamsen Blomfeldt hjk Oswald Buddenhagen Paul Olav Tvete Robin Burchell Samuel Rødal Yoann Lopes The full history of the Qt5 port can be found in refs/old-heads/android, SHA-1 249ca9ca2c7d876b91b31df9434dde47f9065d0d Change-Id: Iff1a7b2dbb707c986f2639e65e39ed8f22430120 Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- src/corelib/global/qlogging.cpp | 24 ++++++++++++++++++++++++ src/corelib/global/qsystemdetection.h | 4 ++++ 2 files changed, 28 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 7204efc752..6a127e1786 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -57,6 +57,10 @@ #include #endif +#ifdef Q_OS_ANDROID +#include +#endif + #include QT_BEGIN_NAMESPACE @@ -835,6 +839,24 @@ Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler); static QtMsgHandler msgHandler = 0; // pointer to debug handler (without context) static QtMessageHandler messageHandler = 0; // pointer to debug handler (with context) +#ifdef Q_OS_ANDROID +static void android_default_message_handler(QtMsgType type, + const QMessageLogContext &context, + const QString &message) +{ + android_LogPriority priority; + switch (type) { + case QtDebugMsg: priority = ANDROID_LOG_DEBUG; break; + case QtWarningMsg: priority = ANDROID_LOG_WARN; break; + case QtCriticalMsg: priority = ANDROID_LOG_ERROR; break; + case QtFatalMsg: priority = ANDROID_LOG_FATAL; break; + }; + + __android_log_print(priority, "Qt", "%s:%d (%s): %s", qPrintable(context.file), context.line, + qPrintable(context.function), qPrintable(message)); +} +#endif //Q_OS_ANDROID + /*! \internal */ @@ -855,6 +877,8 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con #if defined(QT_USE_SLOG2) slog2_default_handler(type, logMessage.toLocal8Bit().constData()); +#elif defined(Q_OS_ANDROID) + android_default_message_handler(type, context, logMessage); #else fprintf(stderr, "%s", logMessage.toLocal8Bit().constData()); fflush(stderr); diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index 6062dc7b7b..0caac3d797 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -80,6 +80,7 @@ LYNX - LynxOS BSD4 - Any BSD 4.4 system UNIX - Any UNIX BSD/SYSV system + ANDROID - Android platform */ #if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__)) @@ -90,6 +91,9 @@ # else # define Q_OS_DARWIN32 # endif +#elif defined(ANDROID) +# define Q_OS_ANDROID +# define Q_OS_LINUX #elif defined(__CYGWIN__) # define Q_OS_CYGWIN #elif !defined(SAG_COM) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__)) -- cgit v1.2.3 From 163dcf2b71f34a12137f200e4af5640e42e5f5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 4 Mar 2013 14:27:35 +0100 Subject: Fix build with older Clang versions without __has_extension Change-Id: I505d3e4ad2fcd56ee229935d8543811a43923273 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index a4af8b8899..383d9c9c6e 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -157,6 +157,10 @@ # define Q_CC_CLANG # define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable() # define Q_UNREACHABLE_IMPL() __builtin_unreachable() +# if !defined(__has_extension) +# /* Compatibility with older Clang versions */ +# define __has_extension __has_feature +# endif # else /* Plain GCC */ # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 -- cgit v1.2.3 From b5bdd31de41cb5e6d6abedce79864fc01d8d4984 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Wed, 12 Dec 2012 17:18:28 +0100 Subject: Implement XEmbed protocol Add a static QWindow::fromWinId(WId id) constructor which can be used to create a QWindow object representing windows created by other processes. Then, QWindow::setParent() can be used to embed a window into a foreign window socket and QWindow::setTransientParent() to stick the current window on top of a foreign window. The changes in the QtWidgets module ensure that the focus chain (TAB navigation) correctly works when a QtWidgets-based window is embedded into another application. As far as the platform implementation is concerned, this commit only implements the embedding functionality in the XCB plugin. So, this is roughly equivalent to the Qt4 QX11EmbedWidget functionality. Change-Id: Iff8f7b9ee974d33fb30f36056f7838b433a413c7 Reviewed-by: Gunnar Sletta --- src/corelib/global/qnamespace.h | 1 + src/corelib/global/qnamespace.qdoc | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 41bca2a443..a33c50a041 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -284,6 +284,7 @@ public: SplashScreen = ToolTip | Dialog, Desktop = 0x00000010 | Window, SubWindow = 0x00000012, + ForeignWindow = 0x00000020 | Window, WindowType_Mask = 0x000000ff, MSWindowsFixedSizeDialogHint = 0x00000100, diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 8ec206a572..02d00c213b 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1966,6 +1966,10 @@ \value SubWindow Indicates that this widget is a sub-window, such as a QMdiSubWindow widget. + \value ForeignWindow Indicates that this window object is a handle + representing a native platform window created by + another process or by manually using native code. + There are also a number of flags which you can use to customize the appearance of top-level windows. These have no effect on other windows: -- cgit v1.2.3 From 27b3746b33006afd2d2153e529e9d5b2886a900b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 6 Mar 2013 12:35:31 +0100 Subject: fix encoding when invoking default message handler the output is local8bit, not latin1. Change-Id: Ib1ab260ac378b354c5ab47856ce6c6c657caefd4 Reviewed-by: Thiago Macieira Reviewed-by: Kai Koehne --- src/corelib/global/qlogging.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 6a127e1786..ccb09a84d4 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -891,7 +891,7 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con static void qDefaultMsgHandler(QtMsgType type, const char *buf) { QMessageLogContext emptyContext; - qDefaultMessageHandler(type, emptyContext, QLatin1String(buf)); + qDefaultMessageHandler(type, emptyContext, QString::fromLocal8Bit(buf)); } static void qt_message_print(QtMsgType msgType, const QMessageLogContext &context, const QString &message) -- cgit v1.2.3 From 77057674fbe871b6a3eb6fe07084b9288b78571a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 6 Mar 2013 12:33:33 +0100 Subject: de-duplicate and accelerate code ... by using existing function. Change-Id: I25e60e70b307885c46b03b6458f06a561976590c Reviewed-by: Thiago Macieira Reviewed-by: Kai Koehne --- src/corelib/global/qlogging.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index ccb09a84d4..13470d9479 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -171,9 +171,7 @@ static void qEmergencyOut(QtMsgType msgType, const char *msg, va_list ap) Q_DECL fflush(stderr); #endif - if (msgType == QtFatalMsg - || (msgType == QtWarningMsg - && qEnvironmentVariableIsSet("QT_FATAL_WARNINGS"))) { + if (isFatal(msgType)) { #if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) // get the current report mode int reportMode = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW); -- cgit v1.2.3 From b7155b6c07b76d802b15dea8eb5aca4085b0d10d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 6 Mar 2013 12:34:29 +0100 Subject: make QtCriticalMsg fatal if QT_FATAL_WARNINGS is set if warnings are fatal, then critical messages should be even more so. Change-Id: I3681fa1fc606337006f1781dd961ea9cf6ce282d Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll Reviewed-by: Kai Koehne --- src/corelib/global/qlogging.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 13470d9479..f95e1e9447 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -76,7 +76,7 @@ static bool isFatal(QtMsgType msgType) if (msgType == QtFatalMsg) return true; - if (msgType == QtWarningMsg) { + if (msgType == QtWarningMsg || msgType == QtCriticalMsg) { static bool fatalWarnings = !qEnvironmentVariableIsEmpty("QT_FATAL_WARNINGS"); return fatalWarnings; } -- cgit v1.2.3 From b6e9a8f21ac8b4cc3cc56232ce346ebd7ba17a70 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 11 Mar 2013 19:19:32 +0100 Subject: Add a generic Qt::Edge enum The values are Top/Left/Right/BottomEdge and values specified so that it can be extended as flags later. Change-Id: I67482265e14d89942a8f59bf09e9e3fadab8243f Reviewed-by: Friedemann Kleint Reviewed-by: Gabriel de Dietrich Reviewed-by: Jerome Pasion Reviewed-by: Lars Knoll Reviewed-by: Jens Bache-Wiig --- src/corelib/global/qnamespace.h | 9 ++++++++- src/corelib/global/qnamespace.qdoc | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index a33c50a041..0ae0fdf57c 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -63,7 +63,7 @@ Qt { Q_ENUMS(ScrollBarPolicy FocusPolicy ContextMenuPolicy) Q_ENUMS(ArrowType ToolButtonStyle PenStyle PenCapStyle PenJoinStyle BrushStyle) Q_ENUMS(FillRule MaskMode BGMode ClipOperation SizeMode) - Q_ENUMS(Axis Corner LayoutDirection SizeHint Orientation DropAction) + Q_ENUMS(Axis Corner Edge LayoutDirection SizeHint Orientation DropAction) Q_FLAGS(Alignment Orientations DropActions) Q_FLAGS(DockWidgetAreas ToolBarAreas) Q_ENUMS(DockWidgetArea ToolBarArea) @@ -1202,6 +1202,13 @@ public: BottomRightCorner = 0x00003 }; + enum Edge { + TopEdge = 0x00001, + LeftEdge = 0x00002, + RightEdge = 0x00004, + BottomEdge = 0x00008 + }; + enum ConnectionType { AutoConnection, DirectConnection, diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 02d00c213b..b065507645 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1709,6 +1709,17 @@ \value BottomRightCorner The bottom-right corner of the rectangle. */ +/*! + \enum Qt::Edge + + This enum type specifies an edge in a rectangle: + + \value TopEdge The top edge of the rectangle. + \value LeftEdge The left edge of the rectangle. + \value RightEdge The right edge of the rectangle. + \value BottomEdge The bottom edge of the rectangle. +*/ + /*! \enum Qt::ScrollBarPolicy -- cgit v1.2.3 From b11317a64339f5a4bcffc8234ecaf15c7fb416f2 Mon Sep 17 00:00:00 2001 From: Axel Waggershauser Date: Fri, 15 Mar 2013 00:42:15 +0100 Subject: Whitespace cleanup: remove trailing whitespace Remove all trailing whitespace from the following list of files: *.cpp *.h *.conf *.qdoc *.pro *.pri *.mm *.rc *.pl *.qps *.xpm *.txt *README excluding 3rdparty, test-data and auto generated code. Note A): the only non 3rdparty c++-files that still have trailing whitespace after this change are: * src/corelib/codecs/cp949codetbl_p.h * src/corelib/codecs/qjpunicode.cpp * src/corelib/codecs/qbig5codec.cpp * src/corelib/xml/qxmlstream_p.h * src/tools/qdoc/qmlparser/qqmljsgrammar.cpp * src/tools/uic/ui4.cpp * tests/auto/other/qtokenautomaton/tokenizers/* * tests/benchmarks/corelib/tools/qstring/data.cpp * util/lexgen/tokenizer.cpp Note B): in about 30 files some overlapping 'leading tab' and 'TAB character in non-leading whitespace' issues have been fixed to make the sanity bot happy. Plus some general ws-fixes here and there as asked for during review. Change-Id: Ia713113c34d82442d6ce4d93d8b1cf545075d11d Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qfeatures.h | 2 +- src/corelib/global/qfeatures.txt | 8 ++++---- src/corelib/global/qglobal.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index a751f9af56..daf853b916 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -238,7 +238,7 @@ // QWheelEvent //#define QT_NO_WHEELEVENT -// +// //#define QT_NO_XMLSTREAM // Animation diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index c27463897f..43db585643 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -325,7 +325,7 @@ SeeAlso: ??? Feature: COMBOBOX Description: Supports comboboxes presenting a list of options to the user. Section: Widgets -Requires: LINEEDIT STANDARDITEMMODEL LISTVIEW +Requires: LINEEDIT STANDARDITEMMODEL LISTVIEW Name: QComboBox SeeAlso: ??? @@ -516,7 +516,7 @@ SeeAlso: ??? Feature: WHATSTHIS Description: Supports displaying "What's this" help. Section: Widgets -Requires: TOOLBUTTON +Requires: TOOLBUTTON Name: QWhatsThis SeeAlso: ??? @@ -636,7 +636,7 @@ SeeAlso: ??? Feature: DIRMODEL Description: Supports a data model for the local filesystem. Section: ItemViews -Requires: ITEMVIEWS FILESYSTEMMODEL +Requires: ITEMVIEWS FILESYSTEMMODEL Name: QDirModel SeeAlso: ??? @@ -1030,7 +1030,7 @@ SeeAlso: ??? Feature: SYSTEMTRAYICON Description: Provides an icon for an application in the system tray. Section: Utilities -Requires: +Requires: Name: QSystemTrayIcon SeeAlso: ??? diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 233743f3ce..c45ad12e99 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -470,7 +470,7 @@ typedef qptrdiff qintptr; # else # define QT_ENSURE_STACK_ALIGNED_FOR_SSE # endif -# define QT_WIN_CALLBACK CALLBACK QT_ENSURE_STACK_ALIGNED_FOR_SSE +# define QT_WIN_CALLBACK CALLBACK QT_ENSURE_STACK_ALIGNED_FOR_SSE #endif typedef int QNoImplicitBoolCast; -- cgit v1.2.3 From b74ba4e198256f9c4a4c8af02a1339bf0ecc41aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 1 Mar 2013 11:38:19 +0100 Subject: Add Qt::AA_UseHighDpiPixmaps. Setting this attribute enables QIcon::pixmap() to return high-dpi pixmaps when running on "retina" type displays. This requires an opt-in flag since the returned pixmap can be larger than the requested size, which is a change in previous documented behaviour that can break existing code. Change-Id: I5ff3d25c68de24aa4eda7ad1f8aa9199da04707e Reviewed-by: Gabriel de Dietrich --- src/corelib/global/qnamespace.h | 1 + src/corelib/global/qnamespace.qdoc | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 0ae0fdf57c..f130288a24 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -498,6 +498,7 @@ public: AA_X11InitThreads = 10, AA_SynthesizeTouchForUnhandledMouseEvents = 11, AA_SynthesizeMouseForUnhandledTouchEvents = 12, + AA_UseHighDpiPixmaps = 13, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index b065507645..0d9cacdb1f 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -167,6 +167,14 @@ to left button mouse events instead. This attribute is enabled by default. + \value AA_UseHighDpiPixmaps Make QIcon::pixmap() generate high-dpi pixmaps + that can be larger than the requested size. Such pixmaps will have + devicePixelRatio set to a value higher than 1. + + After setting this attribute application code that uses pixmap + sizes in layout geometry calculations should typically divide by + QPixmap::devicePixelRatio() to get device-independent layout geometry. + \omitvalue AA_AttributeCount */ -- cgit v1.2.3 From 0ea6b8ada00d56de939363e033aab8e9c0d3fdca Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Sun, 17 Mar 2013 13:14:46 +0000 Subject: Add predefined macros for endian detection with the TI toolchains Change-Id: I88768adc8acb3b28b7a774f2e9a285d983c9d76d Reviewed-by: Thiago Macieira --- src/corelib/global/qprocessordetection.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h index 86023d1703..178afb1db6 100644 --- a/src/corelib/global/qprocessordetection.h +++ b/src/corelib/global/qprocessordetection.h @@ -280,9 +280,9 @@ # if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == Q_BIG_ENDIAN || __BYTE_ORDER__ == Q_LITTLE_ENDIAN) // Reuse __BYTE_ORDER__ as-is, since our Q_*_ENDIAN #defines match the preprocessor defaults # define Q_BYTE_ORDER __BYTE_ORDER__ -# elif defined(__BIG_ENDIAN__) +# elif defined(__BIG_ENDIAN__) || defined(_big_endian__) || defined(_BIG_ENDIAN) # define Q_BYTE_ORDER Q_BIG_ENDIAN -# elif defined(__LITTLE_ENDIAN__) \ +# elif defined(__LITTLE_ENDIAN__) || defined(_little_endian__) || defined(_LITTLE_ENDIAN) \ || defined(_WIN32_WCE) // Windows CE is always little-endian according to MSDN. # define Q_BYTE_ORDER Q_LITTLE_ENDIAN # else -- cgit v1.2.3