From 8ddaf5c74150d18f2639aeca495ec40efd8e8add Mon Sep 17 00:00:00 2001 From: Tomasz Olszak Date: Fri, 3 Oct 2014 16:48:06 +0200 Subject: Gcc 4.5.* build fix. Q_COMPILER_DEFAULT_MEMBERS and Q_COMPILER_DELETE_MEMBERS are now set starting from gcc 4.6. Pre-4.6 compilers implement a non-final snapshot of N2346, hence default and delete functions are supported only if they are public. Starting from 4.6, GCC handles final version - the access modifier is not relevant. Compiler error: qsharedpointer_impl.h:717:31: error: 'QEnableSharedFromThis::QEnableSharedFromThis()' declared with non-public access cannot be defaulted in the class body Change-Id: If1d3d4696f91912a09ca72bd4aa1fb07f491a0cb Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index ac60d47c7e..8e52c50322 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -730,8 +730,6 @@ /* C++11 features supported in GCC 4.4: */ # define Q_COMPILER_AUTO_FUNCTION # define Q_COMPILER_AUTO_TYPE -# define Q_COMPILER_DEFAULT_MEMBERS -# define Q_COMPILER_DELETE_MEMBERS # define Q_COMPILER_EXTERN_TEMPLATES # define Q_COMPILER_UNIFORM_INIT # define Q_COMPILER_UNICODE_STRINGS @@ -748,6 +746,11 @@ # define Q_COMPILER_CLASS_ENUM # endif # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 + /* Pre-4.6 compilers implement a non-final snapshot of N2346, hence default and delete + * functions are supported only if they are public. Starting from 4.6, GCC handles + * final version - the access modifier is not relevant. */ +# define Q_COMPILER_DEFAULT_MEMBERS +# define Q_COMPILER_DELETE_MEMBERS /* C++11 features supported in GCC 4.6: */ # define Q_COMPILER_CONSTEXPR # define Q_COMPILER_NULLPTR -- cgit v1.2.3 From aa0002057835065d6ddb2be4d3c4deeda3276785 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 9 Oct 2014 11:40:04 +0200 Subject: Android: Support QSysInfo::productVersion() Gets the user-readable string for the current running Android version. Task-number: QTBUG-41764 Change-Id: Iefea4a4f5291bfddc99bbf901676ccd33fbc23d6 Reviewed-by: Thiago Macieira Reviewed-by: J-P Nurmi --- src/corelib/global/qglobal.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 2696df9e39..ae3e86629e 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2519,7 +2519,9 @@ QString QSysInfo::productVersion() // fall through // Android and Blackberry should not fall through to the Unix code -#elif defined(Q_OS_ANDROID) +#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + return QJNIObjectPrivate::getStaticObjectField("android/os/Build$VERSION", "RELEASE", "Ljava/lang/String;").toString(); +#elif defined(Q_OS_ANDROID) // Q_OS_ANDROID_NO_SDK // TBD #elif defined(Q_OS_BLACKBERRY) deviceinfo_details_t *deviceInfo; -- cgit v1.2.3 From 01f5ba006eb8b7910b36909727c7b1a0b053ea09 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 29 Sep 2014 15:30:08 +0200 Subject: Fix patching of installation date Marking qt_eval_expiry_date alone as volatile apparently didn't stop the compiler from optimizing away the calculation of the expiry date. Task-number: QTBUG-41612 Change-Id: Ia51fb83f03250346952a76c8a1a641096b4ff9e7 Reviewed-by: Oswald Buddenhagen Reviewed-by: Friedemann Kleint Reviewed-by: Kalle Viironen Reviewed-by: Iikka Eklund --- src/corelib/kernel/qtcore_eval.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qtcore_eval.cpp b/src/corelib/kernel/qtcore_eval.cpp index c0f8897b3b..eb1019534c 100644 --- a/src/corelib/kernel/qtcore_eval.cpp +++ b/src/corelib/kernel/qtcore_eval.cpp @@ -111,10 +111,11 @@ static EvaluationStatus qt_eval_is_supported() static int qt_eval_days_left() { - const char *expiry_date = const_cast(qt_eval_expiry_date + 12); + const volatile char *const expiry_date = qt_eval_expiry_date + 12; QDate today = QDate::currentDate(); - QDate lastday = QDate::fromString(QString::fromLatin1(expiry_date), Qt::ISODate); + QDate lastday = QDate::fromString( + QString::fromLatin1(const_cast(expiry_date)), Qt::ISODate); return today.daysTo(lastday); } -- cgit v1.2.3 From 955c9562bdb07927069f281a8635ce20405051c3 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 23 Sep 2014 23:33:40 +0200 Subject: QSettings: undo unintentional change of config dir on non-XDG platforms. c99dfd8f631289 only meant to be able to switch to the test mode of QStandardPaths, not to move the default dir on OS X, iOS, BB10 and Android. So this commit restores it to the previous behavior, to avoid migration issues. The use of XDG_CONFIG_HOME, defaulting to ~/.config, on OS X, is even documented in the current QSettings documentation, even though these paths are non-standard on OS X (granted, the use of ini-style config files isn't either). Task-number: QTBUG-41461 Change-Id: I5eb610ff7ccbdaf6f955ef7f8f7c2658cbecbb86 Reviewed-by: Eike Ziller Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/io/qsettings.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index f6cd5aa7c9..fd35ae33dc 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -100,6 +100,10 @@ using namespace ABI::Windows::Storage; #define CSIDL_APPDATA 0x001a // \Application Data #endif +#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_ANDROID) +#define Q_XDG_PLATFORM +#endif + // ************************************************************************ // QConfFile @@ -1041,7 +1045,9 @@ static void initDefaultPaths(QMutexLocker *locker) windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator()); #else -#ifdef QT_NO_STANDARDPATHS +#if defined(QT_NO_STANDARDPATHS) || !defined(Q_XDG_PLATFORM) + // Non XDG platforms (OS X, iOS, Blackberry, Android...) have used this code path erroneously + // for some time now. Moving away from that would require migrating existing settings. QString userPath; char *env = getenv("XDG_CONFIG_HOME"); if (env == 0) { @@ -1056,6 +1062,9 @@ static void initDefaultPaths(QMutexLocker *locker) userPath += QFile::decodeName(env); } #else + // When using a proper XDG platform, use QStandardPaths rather than the above hand-written code; + // it makes the use of test mode from unit tests possible. + // Ideally all platforms should use this, but see above for the migration issue. QString userPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); #endif userPath += QLatin1Char('/'); -- cgit v1.2.3 From 26fbeecfa55ee3250c81da6d2e14567ec2051e23 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 20 Sep 2014 17:23:31 +0200 Subject: Initialize QFileSystemMetaData::size_ data member There's a code path which reads that member before it got anything assigned to it, triggering undefined behavior. The code path goes as follows: 1. an instance is created in QFSFileEngineIterator::advance 2. the instance is passed to QFileSystemIterator::advance, which fills in only some members (not size_) 3. the instance is passed to QFileInfoPrivate which does a deep copy, reading an uninitialized size_ Change-Id: I6835ee701a83b63ca4bad6235feeb6a23566fcd3 Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemmetadata_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index de79ec32d3..27e2dac2e4 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -74,7 +74,8 @@ class QFileSystemMetaData { public: QFileSystemMetaData() - : knownFlagsMask(0) + : knownFlagsMask(0), + size_(-1) { } -- cgit v1.2.3 From 4bf0660ae4e695ceb79f585b92dedf00d7757f31 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 13 Oct 2014 08:49:16 +0200 Subject: Make QStringRef::right() consistent with QString::right() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The implementation was inconsistent with QString::right(), and did not return the N rightmost characters but actually did the same as QString::mid(N) (returning the rightmost size - N characters.) Since this function is fairly recent (Qt 5.2), is documented to behave the same as QString::right(), and since these APIs are meant to be interchangeable, this needs to be fixed, even though it changes behavior. [ChangeLog][Important Behavior Changes] Changed QStringRef::right() to be consistent with QString::right(). The function now returns the N right-most characters, like the documentation already claimed. Change-Id: I2d1cd6d958dfa9354aa09f16bd27b1ed209c2d11 Task-number: QTBUG-41858 Reviewed-by: Thiago Macieira Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qdatetime.cpp | 2 +- src/corelib/tools/qstring.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 75f2a93e45..f0f6a56755 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -4419,7 +4419,7 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format) if (size == 10) return QDateTime(date); - isoString = isoString.right(11); + isoString = isoString.right(isoString.length() - 11); int offset = 0; // Check end of string for Time Zone definition, either Z for UTC or [+-]HH:MM for Offset if (isoString.endsWith(QLatin1Char('Z'))) { diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index b805ec792e..48f251e3f4 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -9020,7 +9020,7 @@ QStringRef QStringRef::right(int n) const { if (uint(n) >= uint(m_size)) return *this; - return QStringRef(m_string, n + m_position, m_size - n); + return QStringRef(m_string, m_size - n + m_position, n); } /*! -- cgit v1.2.3 From 29ad07d0a486dd234267fce9a0310ad89683b7d1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 29 Sep 2014 14:55:12 +0200 Subject: Avoid sleeping 100ms in QProcessPrivate::drainOutputPipes() There is no point in waiting 100 milliseconds after each iteration, as all data that we may possibly read will be already in the pipe. We only need to give the notifier thread a chance to inform us, which is best achieved with a yield. Task-number: QTBUG-41282 Change-Id: Id654b688246508494a5549c11900f9ad2957f192 Reviewed-by: Alessandro Portale Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 980fb58865..ee6b7e13f4 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -634,7 +634,7 @@ bool QProcessPrivate::drainOutputPipes() someReadyReadEmitted |= readyReadEmitted; if (!readOperationActive || !readyReadEmitted) break; - Sleep(100); + QThread::yieldCurrentThread(); } return someReadyReadEmitted; -- cgit v1.2.3 From a4ac4b326318ed9034466305222280ed8d1651b5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Oct 2014 14:39:06 +0200 Subject: QWindowsGuiEventDispatcher: Register timers in constructor. Port change 3716a76704273fdbe5ad4ec978438daeda606c26 (Qt 4) to Qt 5. Enforce the creation of the internal window and registering of timers in the event dispatcher constructor for GUI applications instead of delaying it to processEvents() is called. Move the call to virtual wakeUp() out of createInternalHwnd(). Task-number: QTBUG-40881 Change-Id: I82a4748897da140a39feff882c75ad5ac6155148 Reviewed-by: Joerg Bornemann --- src/corelib/kernel/qeventdispatcher_win.cpp | 8 +++----- src/corelib/kernel/qeventdispatcher_win_p.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 7816edd3f9..a3d00faf31 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -639,7 +639,6 @@ void QEventDispatcherWin32::createInternalHwnd() { Q_D(QEventDispatcherWin32); - Q_ASSERT(!d->internalHwnd); if (d->internalHwnd) return; d->internalHwnd = qt_create_internal_window(this); @@ -664,9 +663,6 @@ void QEventDispatcherWin32::createInternalHwnd() // start all normal timers for (int i = 0; i < d->timerVec.count(); ++i) d->registerTimer(d->timerVec.at(i)); - - // trigger a call to sendPostedEvents() - wakeUp(); } QEventDispatcherWin32::QEventDispatcherWin32(QObject *parent) @@ -686,8 +682,10 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QEventDispatcherWin32); - if (!d->internalHwnd) + if (!d->internalHwnd) { createInternalHwnd(); + wakeUp(); // trigger a call to sendPostedEvents() + } d->interrupt = false; emit awake(); diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index f9bb06a5c5..369c276615 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -65,8 +65,8 @@ class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcher Q_OBJECT Q_DECLARE_PRIVATE(QEventDispatcherWin32) +protected: void createInternalHwnd(); - friend class QGuiEventDispatcherWin32; public: explicit QEventDispatcherWin32(QObject *parent = 0); -- cgit v1.2.3 From 0368b24a7f53c945b582097cc8ad22a053856d22 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 9 Oct 2014 09:43:23 +0200 Subject: QSettings: Prevent assert when passing empty keys. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][Important behavior changes][QSettings] QSettings::value() now returns an invalid QVariant when passing an empty key. The code path ran into an assert, which was only noticeable in debug builds. Task-number: QTBUG-41812 Change-Id: I5cc32be3aa267a132e9d6639ecd6cb0bbafc15b0 Reviewed-by: Stéphane Fabry, Cutesoft Reviewed-by: Thiago Macieira --- src/corelib/io/qsettings.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index fd35ae33dc..d896da176a 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -3121,6 +3121,10 @@ bool QSettings::isWritable() const void QSettings::setValue(const QString &key, const QVariant &value) { Q_D(QSettings); + if (key.isEmpty()) { + qWarning("QSettings::setValue: Empty key passed"); + return; + } QString k = d->actualKey(key); d->set(k, value); d->requestUpdate(); @@ -3253,6 +3257,10 @@ bool QSettings::event(QEvent *event) QVariant QSettings::value(const QString &key, const QVariant &defaultValue) const { Q_D(const QSettings); + if (key.isEmpty()) { + qWarning("QSettings::value: Empty key passed"); + return QVariant(); + } QVariant result = defaultValue; QString k = d->actualKey(key); d->get(k, &result); -- cgit v1.2.3 From 16df1ad322689190f9b8107b010d74c92bb19e8b Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 13 Oct 2014 11:57:02 +0200 Subject: Export QFSFileEngine symbols Although it's private API the symbols are used e.g. in the Qt Installer Framework. Change-Id: I557d3b86dbf87cb1b712bae09c3e8fecf6f15e67 Reviewed-by: hjk --- src/corelib/io/qfsfileengine_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 5d5a29243e..3963a9cb11 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE class QFSFileEnginePrivate; -class Q_AUTOTEST_EXPORT QFSFileEngine : public QAbstractFileEngine +class Q_CORE_EXPORT QFSFileEngine : public QAbstractFileEngine { Q_DECLARE_PRIVATE(QFSFileEngine) public: -- cgit v1.2.3 From 45485d9eb47d3129b8a74c2e9d854c07673161cd Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 16 Oct 2014 10:39:44 +0200 Subject: Fix undefined behavior in QLoggingRegistry::defaultCategoryFilter() Report by asan: READ of size 2 at 0x00000041dd40 thread T0 #0 0x2af097b84da6 in QLoggingRegistry::defaultCategoryFilter(QLoggingCategory*) (lib/libQt5Core.so.5+0x566da6) #1 0x2af097b8387b in QLoggingRegistry::registerCategory(QLoggingCategory*, QtMsgType) (lib/libQt5Core.so.5+0x56587b) #2 0x4067f7 in tst_QLogging::QLoggingCategory_categoryName() tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp:238 0x00000041dd41 is located 0 bytes to the right of global variable '*.LC115' defined in 'tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp' (0x41dd40) of size 1 '*.LC115' is ascii string '' At face value, memcmp("", "qt", 2) should not return 0, but since the code invokes undefined behavior, the compiler can do whatever it wants, including returning 0 here, further proving the fact that there are *no* benign cases of undefined behavior. Change-Id: I0c38622c47d1dcea450ea549370be1673b47b18d Reviewed-by: Kai Koehne Reviewed-by: Olivier Goffart --- src/corelib/io/qloggingregistry.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index e9ee8d9458..8af1487834 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -398,9 +398,11 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat) // hard-wired implementation of // qt.*.debug=false // qt.debug=false - char c; - if (!memcmp(cat->categoryName(), "qt", 2) && (!(c = cat->categoryName()[2]) || c == '.')) - debug = false; + if (const char *categoryName = cat->categoryName()) { + // == "qt" or startsWith("qt.") + if (strcmp(categoryName, "qt") == 0 || strncmp(categoryName, "qt.", 3) == 0) + debug = false; + } QString categoryName = QLatin1String(cat->categoryName()); foreach (const QLoggingRule &item, reg->rules) { -- cgit v1.2.3 From cf8f369f8575dcb9ca4d5116f3afc7cff4a080af Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 15 Oct 2014 13:50:27 +0200 Subject: Move Qt Core examples under a common subdirectory Qt Core examples were scattered into several subdirectories under qtbase/examples. This caused an issue with the example manifest file generated by QDoc; it expects to find all examples under a common directory in order to produde correct paths to the example .pro files. Qt Creator will not find the examples without a valid manifest file. This change moves the examples and edits the documentation files accordingly. Task-number: QTBUG-41963 Change-Id: I51d86782e0ba21c5c9bae5f15401ec774abe5cf8 Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen Reviewed-by: Leena Miettinen --- src/corelib/doc/qtcore.qdocconf | 7 ++----- src/corelib/doc/src/custom-types.qdoc | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf index 7c879cbbfd..5a14ba9088 100644 --- a/src/corelib/doc/qtcore.qdocconf +++ b/src/corelib/doc/qtcore.qdocconf @@ -4,7 +4,7 @@ project = QtCore description = Qt Core Reference Documentation version = $QT_VERSION -examplesinstallpath = core +examplesinstallpath = corelib qhp.projects = QtCore @@ -35,10 +35,7 @@ sourcedirs += .. exampledirs += \ ../ \ snippets \ - ../../../examples/threads/ \ - ../../../examples/tools/ \ - ../../../examples/ipc/ \ - ../../../examples/json/ \ + ../../../examples/corelib \ ../../../examples/network/dnslookup imagedirs += images diff --git a/src/corelib/doc/src/custom-types.qdoc b/src/corelib/doc/src/custom-types.qdoc index bac4a90829..81ce698735 100644 --- a/src/corelib/doc/src/custom-types.qdoc +++ b/src/corelib/doc/src/custom-types.qdoc @@ -61,7 +61,7 @@ The following \c Message class definition includes these members: - \snippet customtype/message.h custom type definition + \snippet tools/customtype/message.h custom type definition The class also provides a constructor for normal use and two public member functions that are used to obtain the private data. @@ -77,7 +77,7 @@ to this class, we invoke the Q_DECLARE_METATYPE() macro on the class in the header file where it is defined: - \snippet customtype/message.h custom type meta-type declaration + \snippet tools/customtype/message.h custom type meta-type declaration This now makes it possible for \c Message values to be stored in QVariant objects and retrieved later. See the \l{Custom Type Example} for code that demonstrates @@ -104,19 +104,19 @@ The \l{Queued Custom Type Example} declares a \c Block class which is registered in the \c{main.cpp} file: - \snippet queuedcustomtype/main.cpp main start + \snippet threads/queuedcustomtype/main.cpp main start \dots - \snippet queuedcustomtype/main.cpp register meta-type for queued communications + \snippet threads/queuedcustomtype/main.cpp register meta-type for queued communications \dots - \snippet queuedcustomtype/main.cpp main finish + \snippet threads/queuedcustomtype/main.cpp main finish This type is later used in a signal-slot connection in the \c{window.cpp} file: - \snippet queuedcustomtype/window.cpp Window constructor start + \snippet threads/queuedcustomtype/window.cpp Window constructor start \dots - \snippet queuedcustomtype/window.cpp connecting signal with custom type + \snippet threads/queuedcustomtype/window.cpp connecting signal with custom type \dots - \snippet queuedcustomtype/window.cpp Window constructor finish + \snippet threads/queuedcustomtype/window.cpp Window constructor finish If a type is used in a queued connection without being registered, a warning will be printed at the console; for example: @@ -131,18 +131,18 @@ It is often quite useful to make a custom type printable for debugging purposes, as in the following code: - \snippet customtype/main.cpp printing a custom type + \snippet tools/customtype/main.cpp printing a custom type This is achieved by creating a streaming operator for the type, which is often defined in the header file for that type: - \snippet customtype/message.h custom type streaming operator + \snippet tools/customtype/message.h custom type streaming operator The implementation for the \c Message type in the \l{Custom Type Example} goes to some effort to make the printable representation as readable as possible: - \snippet customtype/message.cpp custom type streaming operator + \snippet tools/customtype/message.cpp custom type streaming operator The output sent to the debug stream can, of course, be made as simple or as complicated as you like. Note that the value returned by this function is -- cgit v1.2.3 From 3d94a564f4c439ca0d1c2a0af807b9edeeb39299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Mon, 29 Sep 2014 14:16:28 +0200 Subject: Android: Improve cache logic in findClass() This change adds guards to ensure that we only do a class look-up once when calling QJNIEnvironmentPrivate::findClass(). IF someone calls findClass() with an environment that does not contain a "valid" class loader, we should fallback to loadClass(), but only once. Change-Id: If5fc82956db889f3269bb33c98a16c49cae55def Reviewed-by: Yoann Lopes --- src/corelib/kernel/qjni.cpp | 65 ++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 30 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index 173127b063..452e3464d6 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -80,38 +80,22 @@ static QString toDotEncodedClassName(const char *className) return QString::fromLatin1(className).replace(QLatin1Char('/'), QLatin1Char('.')); } -static jclass getCachedClass(const QString &classDotEnc) +static jclass getCachedClass(const QString &classDotEnc, bool *isCached = 0) { QHash::iterator it = cachedClasses->find(classDotEnc); + const bool found = (it != cachedClasses->end()); - if (it == cachedClasses->end()) - return 0; - - return it.value(); -} - -static jclass findClass(const char *className, JNIEnv *env) -{ - const QString &classDotEnc = toDotEncodedClassName(className); - jclass clazz = getCachedClass(classDotEnc); - if (clazz != 0) - return clazz; - - jclass fclazz = env->FindClass(className); - if (!exceptionCheckAndClear(env)) { - clazz = static_cast(env->NewGlobalRef(fclazz)); - env->DeleteLocalRef(fclazz); - } + if (isCached != 0) + *isCached = found; - cachedClasses->insert(classDotEnc, clazz); - return clazz; + return found ? it.value() : 0; } -static jclass loadClass(const char *className, JNIEnv *env) +static jclass loadClassDotEnc(const QString &classDotEnc, JNIEnv *env) { - const QString &classDotEnc = toDotEncodedClassName(className); - jclass clazz = getCachedClass(classDotEnc); - if (clazz != 0) + bool isCached = false; + jclass clazz = getCachedClass(classDotEnc, &isCached); + if (clazz != 0 || isCached) return clazz; QJNIObjectPrivate classLoader = QtAndroidPrivate::classLoader(); @@ -130,6 +114,11 @@ static jclass loadClass(const char *className, JNIEnv *env) return clazz; } +inline static jclass loadClass(const char *className, JNIEnv *env) +{ + return loadClassDotEnc(toDotEncodedClassName(className), env); +} + typedef QHash JMethodIDHash; Q_GLOBAL_STATIC(JMethodIDHash, cachedMethodID) @@ -224,12 +213,28 @@ JNIEnv *QJNIEnvironmentPrivate::operator->() jclass QJNIEnvironmentPrivate::findClass(const char *className, JNIEnv *env) { - jclass clazz = 0; - if (env != 0) - clazz = ::findClass(className, env); + const QString &classDotEnc = toDotEncodedClassName(className); + bool isCached = false; + jclass clazz = getCachedClass(classDotEnc, &isCached); + + const bool found = (clazz != 0) || (clazz == 0 && isCached); + + if (found) + return clazz; + + if (env != 0) { // We got an env. pointer (We expect this to be the right env. and call FindClass()) + jclass fclazz = env->FindClass(className); + if (!exceptionCheckAndClear(env)) { + clazz = static_cast(env->NewGlobalRef(fclazz)); + env->DeleteLocalRef(fclazz); + } + + if (clazz != 0) + cachedClasses->insert(classDotEnc, clazz); + } - if (clazz == 0) - clazz = loadClass(className, QJNIEnvironmentPrivate()); + if (clazz == 0) // We didn't get an env. pointer or we got one with the WRONG class loader... + clazz = loadClassDotEnc(classDotEnc, QJNIEnvironmentPrivate()); return clazz; } -- cgit v1.2.3 From 06e706bdbb826b521389409b53079483fda5584a Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 16 Oct 2014 20:25:00 +0200 Subject: Fix QAbstractListModel's detailed description. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3f3e6b9d4e021620505c03458e78856326dcd859 Reviewed-by: Topi Reiniö --- src/corelib/itemmodels/qabstractitemmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 68ab03976f..74a7ea1988 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -3375,7 +3375,7 @@ Qt::ItemFlags QAbstractTableModel::flags(const QModelIndex &index) const QAbstractItemModel, it is not suitable for use with tree views; you will need to subclass QAbstractItemModel if you want to provide a model for that purpose. If you need to use a number of list models to manage data, - it may be more appropriate to subclass QAbstractTableModel class instead. + it may be more appropriate to subclass QAbstractTableModel instead. Simple models can be created by subclassing this class and implementing the minimum number of required functions. For example, we could implement @@ -3399,7 +3399,7 @@ Qt::ItemFlags QAbstractTableModel::flags(const QModelIndex &index) const default ones provided by the roleNames() function, you must override it. For editable list models, you must also provide an implementation of - setData(), implement the flags() function so that it returns a value + setData(), and implement the flags() function so that it returns a value containing \l{Qt::ItemFlags}{Qt::ItemIsEditable}. Note that QAbstractListModel provides a default implementation of -- cgit v1.2.3 From ef1027b8242e8e65e15c382d017cd2b75dbf72ff Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 3 Oct 2014 21:24:44 +0200 Subject: qdatetime.h: include correct header QExplicitlySharedDataPointer is defined in qshareddata.h, not qsharedpointer.h. Change-Id: If81f6615681068a8e8c38817044ea3a0433c42ab Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index 597655f557..c5e64d7d52 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -36,7 +36,7 @@ #include #include -#include +#include #include -- cgit v1.2.3 From 9dcc38b566576ab209a133777fc2d92bdf33c183 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 16 Oct 2014 10:14:08 +0200 Subject: QEasingCurve: fix mem leak in operator>> The code ignored that the QEasingCurve passed in to op>> might already have a QEasingCurveFunction set, overwriting it with a new pointer without deleting the old. Change-Id: Ic14cf7e4b97c7c8c7edb64cde08fbf22c07ac8f3 Reviewed-by: Olivier Goffart --- src/corelib/tools/qeasingcurve.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 0e3375cf21..a3dd4d9a60 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -1497,6 +1497,8 @@ QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing) bool hasConfig; stream >> hasConfig; + delete easing.d_ptr->config; + easing.d_ptr->config = Q_NULLPTR; if (hasConfig) { QEasingCurveFunction *config = curveToFunctionObject(type); stream >> config->_p; -- cgit v1.2.3 From 9dc246c5cccb38d6f4e02af098f1a1a384c11153 Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Tue, 14 Oct 2014 13:56:01 +0200 Subject: Doc: removed unnecessary text Added some commas. Task-number: QTBUG-41928 Change-Id: I52ad75f895f41b109f0496863930ffaa1650447c Reviewed-by: Martin Smith Reviewed-by: Nico Vertriest --- src/corelib/io/qfiledevice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp index 8691a44d8d..8d1c59e159 100644 --- a/src/corelib/io/qfiledevice.cpp +++ b/src/corelib/io/qfiledevice.cpp @@ -608,9 +608,9 @@ qint64 QFileDevice::size() const } /*! - Sets the file size (in bytes) \a sz. Returns \c true if the file if the + Sets the file size (in bytes) \a sz. Returns \c true if the resize succeeds; false otherwise. If \a sz is larger than the file - currently is the new bytes will be set to 0, if \a sz is smaller the + currently is, the new bytes will be set to 0; if \a sz is smaller, the file is simply truncated. \sa size() -- cgit v1.2.3 From 0c71cbea5472191ca5131e18b3f676eae8a51bf4 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 24 Sep 2014 11:21:06 +0200 Subject: Add a hint on application window positioning with QProcess::start Task-number: QTBUG-30999 Change-Id: I65c80917c9bad067bb7d8e69e2431dd1c4886b08 Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen Reviewed-by: Frederik Gladhorn --- src/corelib/io/qprocess.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index e009191be9..e76a836954 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -538,6 +538,13 @@ void QProcessPrivate::Channel::clear() setWorkingDirectory(). By default, processes are run in the current working directory of the calling process. + The positioning and the screen Z-order of windows belonging to + GUI applications started with QProcess are controlled by + the underlying windowing system. For Qt 5 applications, the + positioning can be specified using the \c{-qwindowgeometry} + command line option; X11 applications generally accept a + \c{-geometry} command line option. + \note On QNX, setting the working directory may cause all application threads, with the exception of the QProcess caller thread, to temporarily freeze during the spawning process, -- cgit v1.2.3 From ae89aa330fd1628e0780bfbdf7ceb772412399a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 16 Oct 2014 14:11:49 +0200 Subject: logging: Fix qCleanupFuncinfo to not mangle Objective-C message names Change-Id: I823566ba72668c611d225aa92c4d09a53cabe8fc Reviewed-by: Kai Koehne Reviewed-by: Simon Hausmann --- src/corelib/global/qlogging.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 2a4f2dd4d6..f356bab42d 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -653,9 +653,10 @@ Q_AUTOTEST_EXPORT QByteArray qCleanupFuncinfo(QByteArray info) int pos; - // skip trailing [with XXX] for templates (gcc) + // Skip trailing [with XXX] for templates (gcc), but make + // sure to not affect Objective-C message names. pos = info.size() - 1; - if (info.endsWith(']')) { + if (info.endsWith(']') && !(info.startsWith('+') || info.startsWith('-'))) { while (--pos) { if (info.at(pos) == '[') info.truncate(pos); -- cgit v1.2.3