summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2013-02-17 20:31:38 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-17 20:31:38 +0100
commite88011357e5dd3b0ae4e6bc715ef29e5f4f3ffab (patch)
treec5b05d45e49194d70ff4defae41e5d5d5cf75e80 /src/corelib
parent2df8884bc68343ad96962e7496b98d6e585c0347 (diff)
parente65cd6f3794e12e6bc5c2ee985eae8e70ff5f333 (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5CTestMacros.cmake12
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in16
-rw-r--r--src/corelib/Qt5CoreMacros.cmake2
-rw-r--r--src/corelib/corelib.pro5
-rw-r--r--src/corelib/doc/qtcore.qdocconf15
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp8
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp3
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp79
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp10
-rw-r--r--src/corelib/doc/snippets/qstring/main.cpp4
-rw-r--r--src/corelib/doc/snippets/qxmlstreamwriter/main.cpp4
-rw-r--r--src/corelib/doc/snippets/resource-system/application.pro14
-rw-r--r--src/corelib/doc/snippets/resource-system/application.qrc10
-rw-r--r--src/corelib/doc/snippets/resource-system/mainwindow.cpp392
-rw-r--r--src/corelib/doc/src/containers.qdoc2
-rw-r--r--src/corelib/doc/src/eventsandfilters.qdoc2
-rw-r--r--src/corelib/doc/src/external-resources.qdoc7
-rw-r--r--src/corelib/doc/src/resource-system.qdoc6
-rw-r--r--src/corelib/global/qnamespace.qdoc12
-rw-r--r--src/corelib/io/qiodevice.cpp4
-rw-r--r--src/corelib/io/qprocess_win.cpp3
-rw-r--r--src/corelib/io/qurl.cpp2
-rw-r--r--src/corelib/kernel/qmetaobject_moc_p.h2
-rw-r--r--src/corelib/kernel/qobject.cpp6
-rw-r--r--src/corelib/kernel/qobject_impl.h6
-rw-r--r--src/corelib/kernel/qobject_p.h2
-rw-r--r--src/corelib/kernel/qtimer.cpp1
-rw-r--r--src/corelib/kernel/qvariant.cpp2
-rw-r--r--src/corelib/thread/qthread.cpp62
-rw-r--r--src/corelib/tools/qpair.qdoc2
-rw-r--r--src/corelib/tools/qsimd_p.h3
-rw-r--r--src/corelib/tools/qstring.cpp2
-rw-r--r--src/corelib/xml/qxmlstream.cpp16
-rw-r--r--src/corelib/xml/qxmlstream.g58
-rw-r--r--src/corelib/xml/qxmlstream_p.h58
36 files changed, 644 insertions, 190 deletions
diff --git a/src/corelib/Qt5CTestMacros.cmake b/src/corelib/Qt5CTestMacros.cmake
index c5d10c9b5b..60b98a7138 100644
--- a/src/corelib/Qt5CTestMacros.cmake
+++ b/src/corelib/Qt5CTestMacros.cmake
@@ -94,6 +94,18 @@ function(test_module_includes)
include_directories(\${Qt5${qtmodule}_INCLUDE_DIRS})
add_definitions(\${Qt5${qtmodule}_DEFINITIONS})\n"
)
+
+ # Because the CI system tests built packages before installation,
+ # the include dir allowing module-includes for the new module is not
+ # the same as the dir for QtCore (because that is at the installation
+ # location). The CI system is untypical here in that it attempts to use
+ # packages while they are in an intermediate state, so we work around
+ # that in the test system.
+ set(packages_string
+ "${packages_string}
+ include_directories(\"\${Qt5${qtmodule}_DIR}/../../../include\")\n"
+ )
+
set(libraries_string "${libraries_string} Qt5::${qtmodule}")
endwhile()
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 06ff6dc831..4e0fcda20e 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -1,12 +1,10 @@
-get_filename_component(_qt5_corelib_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
-
if (NOT TARGET Qt5::qmake)
add_executable(Qt5::qmake IMPORTED)
set_target_properties(Qt5::qmake PROPERTIES
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
- IMPORTED_LOCATION \"${_qt5_corelib_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\"
+ IMPORTED_LOCATION \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\"
!!ELSE
IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\"
!!ENDIF
@@ -18,7 +16,7 @@ if (NOT TARGET Qt5::moc)
set_target_properties(Qt5::moc PROPERTIES
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
- IMPORTED_LOCATION \"${_qt5_corelib_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\"
+ IMPORTED_LOCATION \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\"
!!ELSE
IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\"
!!ENDIF
@@ -32,7 +30,7 @@ if (NOT TARGET Qt5::rcc)
set_target_properties(Qt5::rcc PROPERTIES
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
- IMPORTED_LOCATION \"${_qt5_corelib_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\"
+ IMPORTED_LOCATION \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\"
!!ELSE
IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\"
!!ENDIF
@@ -44,9 +42,9 @@ set(Qt5Core_MOC_EXECUTABLE Qt5::moc)
set(Qt5Core_RCC_EXECUTABLE Qt5::rcc)
!!IF isEmpty(CMAKE_ARCHDATA_DIR_IS_ABSOLUTE)
-list(APPEND Qt5Core_INCLUDE_DIRS \"${_qt5_corelib_install_prefix}/$${CMAKE_ARCHDATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
+list(APPEND Qt5Core_INCLUDE_DIRS \"${_qt5Core_install_prefix}/$$CMAKE_INCLUDE_DIR\" \"${_qt5Core_install_prefix}/$${CMAKE_ARCHDATA_DIR}/mkspecs/$${CMAKE_MKSPEC}\")
!!ELSE
-list(APPEND Qt5Core_INCLUDE_DIRS \"$${CMAKE_ARCHDATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
+list(APPEND Qt5Core_INCLUDE_DIRS \"$$CMAKE_INCLUDE_DIR\" \"$${CMAKE_ARCHDATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
!!ENDIF
!!IF !isEmpty(CMAKE_ADD_FPIE_FLAGS)
@@ -80,7 +78,7 @@ if (NOT TARGET Qt5::WinMain)
set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(Qt5::WinMain PROPERTIES
!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
- IMPORTED_LOCATION_DEBUG \"${_qt5_corelib_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\"
+ IMPORTED_LOCATION_DEBUG \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\"
!!ELSE
IMPORTED_LOCATION_DEBUG \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\"
!!ENDIF
@@ -91,7 +89,7 @@ if (NOT TARGET Qt5::WinMain)
set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(Qt5::WinMain PROPERTIES
!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
- IMPORTED_LOCATION_RELEASE \"${_qt5_corelib_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\"
+ IMPORTED_LOCATION_RELEASE \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\"
!!ELSE
IMPORTED_LOCATION_RELEASE \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\"
!!ENDIF
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index 614b79ab88..e3115db8ee 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -234,7 +234,7 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.9)
foreach(_module ${_qt5_modules})
if (NOT Qt5${_module}_FOUND)
- find_package(Qt5${_module} PATHS ${_qt5_corelib_install_prefix} NO_DEFAULT_PATH)
+ find_package(Qt5${_module} PATHS ${_qt5Core_install_prefix} NO_DEFAULT_PATH)
if (NOT Qt5${_module}_FOUND)
message(FATAL_ERROR "Can not use \"${_module}\" module which has not yet been found.")
endif()
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 2bac1bcbef..cbfb457212 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -54,7 +54,10 @@ HOST_BINS = $$[QT_HOST_BINS/raw]
host_bins.name = host_bins
host_bins.variable = HOST_BINS
-QMAKE_PKGCONFIG_VARIABLES += host_bins
+qt_conf.name = qt_config
+qt_conf.variable = QT_CONFIG
+
+QMAKE_PKGCONFIG_VARIABLES += host_bins qt_conf
ctest_macros_file.input = $$PWD/Qt5CTestMacros.cmake
ctest_macros_file.output = $$DESTDIR/cmake/Qt5Core/Qt5CTestMacros.cmake
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index bf402cae97..0e275ee8d4 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -2,22 +2,22 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
project = QtCore
description = Qt Core Reference Documentation
-url = http://qt-project.org/doc/qtcore
-version = 5.1.0
+url = http://qt-project.org/doc/qt-$QT_VER/qtcore
+version = $QT_VERSION
examplesinstallpath = core
qhp.projects = QtCore
qhp.QtCore.file = qtcore.qhp
-qhp.QtCore.namespace = org.qt-project.qtcore.510
+qhp.QtCore.namespace = org.qt-project.qtcore.$QT_VERSION_TAG
qhp.QtCore.virtualFolder = qtcore
qhp.QtCore.indexTitle = Qt Core
qhp.QtCore.indexRoot =
-qhp.QtCore.filterAttributes = qtcore 5.1.0 qtrefdoc
-qhp.QtCore.customFilters.Qt.name = QtCore 5.1.0
-qhp.QtCore.customFilters.Qt.filterAttributes = qtcore 5.1.0
+qhp.QtCore.filterAttributes = qtcore $QT_VERSION qtrefdoc
+qhp.QtCore.customFilters.Qt.name = QtCore $QT_VERSION
+qhp.QtCore.customFilters.Qt.filterAttributes = qtcore $QT_VERSION
qhp.QtCore.subprojects = classes
qhp.QtCore.subprojects.classes.title = C++ Classes
qhp.QtCore.subprojects.classes.indexTitle = Qt Core C++ Classes
@@ -36,7 +36,6 @@ exampledirs += \
../ \
snippets \
../../../examples/threads/ \
- ../../../examples/tools/ \
- ../../../examples/widgets/
+ ../../../examples/tools/
imagedirs += images
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
index 2b58802426..ddb84bcc74 100644
--- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
@@ -535,7 +535,7 @@ CApaApplication *myApplicationFactory();
//! [49]
-void myMessageHandler(QtMsgType, const QMessageLogContext &, const char *);
+void myMessageHandler(QtMsgType, const QMessageLogContext &, const QString &);
//! [49]
//! [50]
diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp
index ad2e502be8..532a0e1f59 100644
--- a/src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_io_qurl.cpp
@@ -45,7 +45,7 @@ QUrl url("http://www.example.com/List of holidays.xml");
//! [1]
-QUrl url = QUrl::fromEncoded("http://qt.nokia.com/List%20of%20holidays.xml");
+QUrl url = QUrl::fromEncoded("http://qt-project.org/List%20of%20holidays.xml");
//! [1]
@@ -73,10 +73,10 @@ http://www.example.com/cgi-bin/drawgraph.cgi?type(pie)color(green)
//! [5]
-QUrl baseUrl("http://qt.nokia.com/support");
-QUrl relativeUrl("../products/solutions");
+QUrl baseUrl("http://qt.digia.com/Support/");
+QUrl relativeUrl("../Product/Library/");
qDebug(baseUrl.resolved(relativeUrl).toString());
-// prints "http://qt.nokia.com/products/solutions"
+// prints "http://qt.digia.com/Product/Library/"
//! [5]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
index 932a006436..bafd3f8eb8 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
@@ -480,7 +480,8 @@ QObject::disconnect(lineEdit, &QLineEdit::textChanged,
//! [48]
//! [49]
-if (isSignalConnected(QMetaMethod::fromSignal(&MyObject::valueChanged))) {
+static const QMetaMethod valueChangedSignal = QMetaMethod::fromSignal(&MyObject::valueChanged);
+if (isSignalConnected(valueChangedSignal)) {
QByteArray data;
data = get_the_value(); // expensive operation
emit valueChanged(data);
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp
index f0bc759320..c33c8bb48a 100644
--- a/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_thread_qthread.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
@@ -38,41 +38,68 @@
**
****************************************************************************/
-//! [0]
-class Worker : public QObject
+#include <QtCore/QThread>
+class MyObject;
+
+//! [reimpl-run]
+class WorkerThread : public QThread
{
Q_OBJECT
-
-public slots:
- void doWork() {
- ...
+ void run() Q_DECL_OVERRIDE {
+ QString result;
+ /* expensive or blocking operation */
+ emit resultReady(result);
}
+signals:
+ void resultReady(const QString &s);
};
-void MyObject::putWorkerInAThread()
+void MyObject::startWorkInAThread()
{
- Worker *worker = new Worker;
- QThread *workerThread = new QThread(this);
-
- connect(workerThread, &QThread::started, worker, &Worker::doWork);
- connect(workerThread, &QThread::finished, worker, &Worker::deleteLater);
- worker->moveToThread(workerThread);
-
- // Starts an event loop, and emits workerThread->started()
+ WorkerThread *workerThread = new WorkerThread(this);
+ connect(workerThread, &WorkerThread::resultReady, this, &MyObject::handleResults);
+ connect(workerThread, &WorkerThread::finished, workerThread, &QObject::deleteLater);
workerThread->start();
}
-//! [0]
+//! [reimpl-run]
+
-//! [1]
-class AdvancedThreadManager : public QThread
+//! [worker]
+class Worker : public QObject
{
-protected:
- void run()
- {
- /* ... other code to initialize thread... */
+ Q_OBJECT
+ QThread workerThread;
- // Begin event handling
- exec();
+public slots:
+ void doWork(const QString &parameter) {
+ // ...
+ emit resultReady(result);
}
+
+signals:
+ void resultReady(const QString &result);
+};
+
+class Controller : public QObject
+{
+ Q_OBJECT
+ QThread workerThread;
+public:
+ Controller() {
+ Worker *worker = new Worker;
+ worker->moveToThread(&workerThread);
+ connect(workerThread, &QThread::finished, worker, &QObject::deleteLater);
+ connect(this, &Controller::operate, worker, &Worker::doWork);
+ connect(worker, &Worker::resultReady, this, &Controller::handleResults);
+ workerThread.start();
+ }
+ ~Controller() {
+ workerThread.quit();
+ workerThread.wait();
+ }
+public slots:
+ void handleResults(const QString &);
+signals:
+ void operate(const QString &);
};
-//! [1]
+//! [worker]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp
index 9f52fcff98..7e221cfaab 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp
@@ -258,7 +258,7 @@ if (url.startsWith("ftp:"))
//! [26]
-QByteArray url("http://qt.nokia.com/index.html");
+QByteArray url("http://qt-project.org/doc/qt-5.0/qtdoc/index.html");
if (url.endsWith(".html"))
...
//! [26]
@@ -286,16 +286,16 @@ QByteArray z = x.mid(5); // z == "pineapples"
//! [30]
-QByteArray x("Qt by NOKIA");
+QByteArray x("Qt by DIGIA");
QByteArray y = x.toLower();
-// y == "qt by nokia"
+// y == "qt by digia"
//! [30]
//! [31]
-QByteArray x("Qt by NOKIA");
+QByteArray x("Qt by DIGIA");
QByteArray y = x.toUpper();
-// y == "QT BY NOKIA"
+// y == "QT BY DIGIA"
//! [31]
diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp
index 0fdb88cd8b..6ee3088138 100644
--- a/src/corelib/doc/snippets/qstring/main.cpp
+++ b/src/corelib/doc/snippets/qstring/main.cpp
@@ -856,8 +856,8 @@ void Widget::toLongLongFunction()
void Widget::toLowerFunction()
{
//! [75]
- QString str = "Qt by NOKIA";
- str = str.toLower(); // str == "qt by nokia"
+ QString str = "The Qt PROJECT";
+ str = str.toLower(); // str == "the qt project"
//! [75]
}
diff --git a/src/corelib/doc/snippets/qxmlstreamwriter/main.cpp b/src/corelib/doc/snippets/qxmlstreamwriter/main.cpp
index 134c3b55ff..046790e8ae 100644
--- a/src/corelib/doc/snippets/qxmlstreamwriter/main.cpp
+++ b/src/corelib/doc/snippets/qxmlstreamwriter/main.cpp
@@ -61,8 +61,8 @@ int main(int argc, char *argv[])
stream.writeAttribute("folded", "no");
//! [write element]
stream.writeStartElement("bookmark");
- stream.writeAttribute("href", "http://qt.nokia.com/");
- stream.writeTextElement("title", "Qt Home");
+ stream.writeAttribute("href", "http://qt-project.org/");
+ stream.writeTextElement("title", "Qt Project");
stream.writeEndElement(); // bookmark
//! [write element]
stream.writeEndElement(); // folder
diff --git a/src/corelib/doc/snippets/resource-system/application.pro b/src/corelib/doc/snippets/resource-system/application.pro
new file mode 100644
index 0000000000..652cc73485
--- /dev/null
+++ b/src/corelib/doc/snippets/resource-system/application.pro
@@ -0,0 +1,14 @@
+QT += widgets
+
+HEADERS = mainwindow.h
+SOURCES = main.cpp \
+ mainwindow.cpp
+#! [0]
+RESOURCES = application.qrc
+#! [0]
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/widgets/mainwindows/application
+INSTALLS += target
+
+simulator: warning(This example might not fully work on Simulator platform)
diff --git a/src/corelib/doc/snippets/resource-system/application.qrc b/src/corelib/doc/snippets/resource-system/application.qrc
new file mode 100644
index 0000000000..0a776fab4d
--- /dev/null
+++ b/src/corelib/doc/snippets/resource-system/application.qrc
@@ -0,0 +1,10 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/copy.png</file>
+ <file>images/cut.png</file>
+ <file>images/new.png</file>
+ <file>images/open.png</file>
+ <file>images/paste.png</file>
+ <file>images/save.png</file>
+</qresource>
+</RCC>
diff --git a/src/corelib/doc/snippets/resource-system/mainwindow.cpp b/src/corelib/doc/snippets/resource-system/mainwindow.cpp
new file mode 100644
index 0000000000..8bdd0303de
--- /dev/null
+++ b/src/corelib/doc/snippets/resource-system/mainwindow.cpp
@@ -0,0 +1,392 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#include <QtWidgets>
+
+#include "mainwindow.h"
+//! [0]
+
+//! [1]
+MainWindow::MainWindow()
+//! [1] //! [2]
+{
+ textEdit = new QPlainTextEdit;
+ setCentralWidget(textEdit);
+
+ createActions();
+ createMenus();
+ createToolBars();
+ createStatusBar();
+
+ readSettings();
+
+ connect(textEdit->document(), SIGNAL(contentsChanged()),
+ this, SLOT(documentWasModified()));
+
+ setCurrentFile("");
+ setUnifiedTitleAndToolBarOnMac(true);
+}
+//! [2]
+
+//! [3]
+void MainWindow::closeEvent(QCloseEvent *event)
+//! [3] //! [4]
+{
+ if (maybeSave()) {
+ writeSettings();
+ event->accept();
+ } else {
+ event->ignore();
+ }
+}
+//! [4]
+
+//! [5]
+void MainWindow::newFile()
+//! [5] //! [6]
+{
+ if (maybeSave()) {
+ textEdit->clear();
+ setCurrentFile("");
+ }
+}
+//! [6]
+
+//! [7]
+void MainWindow::open()
+//! [7] //! [8]
+{
+ if (maybeSave()) {
+ QString fileName = QFileDialog::getOpenFileName(this);
+ if (!fileName.isEmpty())
+ loadFile(fileName);
+ }
+}
+//! [8]
+
+//! [9]
+bool MainWindow::save()
+//! [9] //! [10]
+{
+ if (curFile.isEmpty()) {
+ return saveAs();
+ } else {
+ return saveFile(curFile);
+ }
+}
+//! [10]
+
+//! [11]
+bool MainWindow::saveAs()
+//! [11] //! [12]
+{
+ QString fileName = QFileDialog::getSaveFileName(this);
+ if (fileName.isEmpty())
+ return false;
+
+ return saveFile(fileName);
+}
+//! [12]
+
+//! [13]
+void MainWindow::about()
+//! [13] //! [14]
+{
+ QMessageBox::about(this, tr("About Application"),
+ tr("The <b>Application</b> example demonstrates how to "
+ "write modern GUI applications using Qt, with a menu bar, "
+ "toolbars, and a status bar."));
+}
+//! [14]
+
+//! [15]
+void MainWindow::documentWasModified()
+//! [15] //! [16]
+{
+ setWindowModified(textEdit->document()->isModified());
+}
+//! [16]
+
+//! [17]
+void MainWindow::createActions()
+//! [17] //! [18]
+{
+ newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
+ newAct->setShortcuts(QKeySequence::New);
+ newAct->setStatusTip(tr("Create a new file"));
+ connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
+
+//! [19]
+ openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
+ openAct->setShortcuts(QKeySequence::Open);
+ openAct->setStatusTip(tr("Open an existing file"));
+ connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
+//! [18] //! [19]
+
+ saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this);
+ saveAct->setShortcuts(QKeySequence::Save);
+ saveAct->setStatusTip(tr("Save the document to disk"));
+ connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
+
+ saveAsAct = new QAction(tr("Save &As..."), this);
+ saveAsAct->setShortcuts(QKeySequence::SaveAs);
+ saveAsAct->setStatusTip(tr("Save the document under a new name"));
+ connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
+
+//! [20]
+ exitAct = new QAction(tr("E&xit"), this);
+ exitAct->setShortcuts(QKeySequence::Quit);
+//! [20]
+ exitAct->setStatusTip(tr("Exit the application"));
+ connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
+
+//! [21]
+ cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this);
+//! [21]
+ cutAct->setShortcuts(QKeySequence::Cut);
+ cutAct->setStatusTip(tr("Cut the current selection's contents to the "
+ "clipboard"));
+ connect(cutAct, SIGNAL(triggered()), textEdit, SLOT(cut()));
+
+ copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this);
+ copyAct->setShortcuts(QKeySequence::Copy);
+ copyAct->setStatusTip(tr("Copy the current selection's contents to the "
+ "clipboard"));
+ connect(copyAct, SIGNAL(triggered()), textEdit, SLOT(copy()));
+
+ pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
+ pasteAct->setShortcuts(QKeySequence::Paste);
+ pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
+ "selection"));
+ connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste()));
+
+ aboutAct = new QAction(tr("&About"), this);
+ aboutAct->setStatusTip(tr("Show the application's About box"));
+ connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
+
+//! [22]
+ aboutQtAct = new QAction(tr("About &Qt"), this);
+ aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
+ connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+//! [22]
+
+//! [23]
+ cutAct->setEnabled(false);
+//! [23] //! [24]
+ copyAct->setEnabled(false);
+ connect(textEdit, SIGNAL(copyAvailable(bool)),
+ cutAct, SLOT(setEnabled(bool)));
+ connect(textEdit, SIGNAL(copyAvailable(bool)),
+ copyAct, SLOT(setEnabled(bool)));
+}
+//! [24]
+
+//! [25] //! [26]
+void MainWindow::createMenus()
+//! [25] //! [27]
+{
+ fileMenu = menuBar()->addMenu(tr("&File"));
+ fileMenu->addAction(newAct);
+//! [28]
+ fileMenu->addAction(openAct);
+//! [28]
+ fileMenu->addAction(saveAct);
+//! [26]
+ fileMenu->addAction(saveAsAct);
+ fileMenu->addSeparator();
+ fileMenu->addAction(exitAct);
+
+ editMenu = menuBar()->addMenu(tr("&Edit"));
+ editMenu->addAction(cutAct);
+ editMenu->addAction(copyAct);
+ editMenu->addAction(pasteAct);
+
+ menuBar()->addSeparator();
+
+ helpMenu = menuBar()->addMenu(tr("&Help"));
+ helpMenu->addAction(aboutAct);
+ helpMenu->addAction(aboutQtAct);
+}
+//! [27]
+
+//! [29] //! [30]
+void MainWindow::createToolBars()
+{
+ fileToolBar = addToolBar(tr("File"));
+ fileToolBar->addAction(newAct);
+//! [29] //! [31]
+ fileToolBar->addAction(openAct);
+//! [31]
+ fileToolBar->addAction(saveAct);
+
+ editToolBar = addToolBar(tr("Edit"));
+ editToolBar->addAction(cutAct);
+ editToolBar->addAction(copyAct);
+ editToolBar->addAction(pasteAct);
+}
+//! [30]
+
+//! [32]
+void MainWindow::createStatusBar()
+//! [32] //! [33]
+{
+ statusBar()->showMessage(tr("Ready"));
+}
+//! [33]
+
+//! [34] //! [35]
+void MainWindow::readSettings()
+//! [34] //! [36]
+{
+ QSettings settings("QtProject", "Application Example");
+ QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
+ QSize size = settings.value("size", QSize(400, 400)).toSize();
+ resize(size);
+ move(pos);
+}
+//! [35] //! [36]
+
+//! [37] //! [38]
+void MainWindow::writeSettings()
+//! [37] //! [39]
+{
+ QSettings settings("QtProject", "Application Example");
+ settings.setValue("pos", pos());
+ settings.setValue("size", size());
+}
+//! [38] //! [39]
+
+//! [40]
+bool MainWindow::maybeSave()
+//! [40] //! [41]
+{
+ if (textEdit->document()->isModified()) {
+ QMessageBox::StandardButton ret;
+ ret = QMessageBox::warning(this, tr("Application"),
+ tr("The document has been modified.\n"
+ "Do you want to save your changes?"),
+ QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+ if (ret == QMessageBox::Save)
+ return save();
+ else if (ret == QMessageBox::Cancel)
+ return false;
+ }
+ return true;
+}
+//! [41]
+
+//! [42]
+void MainWindow::loadFile(const QString &fileName)
+//! [42] //! [43]
+{
+ QFile file(fileName);
+ if (!file.open(QFile::ReadOnly | QFile::Text)) {
+ QMessageBox::warning(this, tr("Application"),
+ tr("Cannot read file %1:\n%2.")
+ .arg(fileName)
+ .arg(file.errorString()));
+ return;
+ }
+
+ QTextStream in(&file);
+#ifndef QT_NO_CURSOR
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+#endif
+ textEdit->setPlainText(in.readAll());
+#ifndef QT_NO_CURSOR
+ QApplication::restoreOverrideCursor();
+#endif
+
+ setCurrentFile(fileName);
+ statusBar()->showMessage(tr("File loaded"), 2000);
+}
+//! [43]
+
+//! [44]
+bool MainWindow::saveFile(const QString &fileName)
+//! [44] //! [45]
+{
+ QFile file(fileName);
+ if (!file.open(QFile::WriteOnly | QFile::Text)) {
+ QMessageBox::warning(this, tr("Application"),
+ tr("Cannot write file %1:\n%2.")
+ .arg(fileName)
+ .arg(file.errorString()));
+ return false;
+ }
+
+ QTextStream out(&file);
+#ifndef QT_NO_CURSOR
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+#endif
+ out << textEdit->toPlainText();
+#ifndef QT_NO_CURSOR
+ QApplication::restoreOverrideCursor();
+#endif
+
+ setCurrentFile(fileName);
+ statusBar()->showMessage(tr("File saved"), 2000);
+ return true;
+}
+//! [45]
+
+//! [46]
+void MainWindow::setCurrentFile(const QString &fileName)
+//! [46] //! [47]
+{
+ curFile = fileName;
+ textEdit->document()->setModified(false);
+ setWindowModified(false);
+
+ QString shownName = curFile;
+ if (curFile.isEmpty())
+ shownName = "untitled.txt";
+ setWindowFilePath(shownName);
+}
+//! [47]
+
+//! [48]
+QString MainWindow::strippedName(const QString &fullFileName)
+//! [48] //! [49]
+{
+ return QFileInfo(fullFileName).fileName();
+}
+//! [49]
diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc
index 9f63eb0a7e..30d86eac63 100644
--- a/src/corelib/doc/src/containers.qdoc
+++ b/src/corelib/doc/src/containers.qdoc
@@ -221,7 +221,7 @@
\codeline
\snippet streaming/main.cpp 2
- \keyword default-constructed values
+ \keyword default-constructed value
The documentation of certain container class functions refer to
\e{default-constructed values}; for example, QVector
diff --git a/src/corelib/doc/src/eventsandfilters.qdoc b/src/corelib/doc/src/eventsandfilters.qdoc
index 58da01f835..cd31e36dee 100644
--- a/src/corelib/doc/src/eventsandfilters.qdoc
+++ b/src/corelib/doc/src/eventsandfilters.qdoc
@@ -100,7 +100,7 @@
event delivery mechanisms are flexible. The documentation for
QCoreApplication::notify() concisely tells the whole story; the
\e{Qt Quarterly} article
- \l{http://doc.qt.nokia.com/qq/qq11-events.html}{Another Look at Events}
+ \l{http://doc.qt.digia.com/qq/qq11-events.html}{Another Look at Events}
rehashes it less concisely. Here we will explain enough for 95%
of applications.
diff --git a/src/corelib/doc/src/external-resources.qdoc b/src/corelib/doc/src/external-resources.qdoc
index c92f752476..86df385d9e 100644
--- a/src/corelib/doc/src/external-resources.qdoc
+++ b/src/corelib/doc/src/external-resources.qdoc
@@ -64,4 +64,9 @@
/*!
\externalpage http://www.ietf.org/rfc/rfc2045.txt
\title RFC 2045
-*/ \ No newline at end of file
+*/
+
+/*!
+ \externalpage http://www.iana.org/assignments/character-sets/character-sets.xml
+ \title IANA character-sets encoding file
+*/
diff --git a/src/corelib/doc/src/resource-system.qdoc b/src/corelib/doc/src/resource-system.qdoc
index 4a676c0fdf..5ef6bb285c 100644
--- a/src/corelib/doc/src/resource-system.qdoc
+++ b/src/corelib/doc/src/resource-system.qdoc
@@ -50,7 +50,7 @@
Here's an example \c .qrc file:
- \quotefile mainwindows/application/application.qrc
+ \quotefile resource-system/application.qrc
The resource files listed in the \c .qrc file are files that are
part of the application's source tree. The specified paths are
@@ -122,7 +122,7 @@
mentioned in the application's \c .pro file so that \c qmake knows
about it. For example:
- \snippet mainwindows/application/application.pro 0
+ \snippet resource-system/application.pro 0
\c qmake will produce make rules to generate a file called \c
qrc_application.cpp that is linked into the application. This
@@ -167,7 +167,7 @@
pass a resource path instead of a file name to the QIcon, QImage,
or QPixmap constructor:
- \snippet mainwindows/application/mainwindow.cpp 21
+ \snippet resource-system/mainwindow.cpp 21
See the \l{mainwindows/application}{Application} example for an
actual application that uses Qt's resource system to store its
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index b271620ee0..1f1ff36442 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -523,11 +523,11 @@
application to deadlock.
\value UniqueConnection
- Same as AutoConnection, but the connection is made only if
- it does not duplicate an existing connection. i.e., if the
- same signal is already connected to the same slot for the
- same pair of objects, then the connection will fail. This
- connection type was introduced in Qt 4.6.
+ This is a flag that can be combined with any one of the above
+ connection types, using a bitwise OR. When Qt::UniqueConnection is
+ set, QObject::connect() will fail if the connection already exists
+ (i.e. if the same signal is already connected to the same slot
+ for the same pair of objects). This flag was introduced in Qt 4.6.
With queued connections, the parameters must be of types that are
known to Qt's meta-object system, because Qt needs to copy the
@@ -2493,7 +2493,7 @@
"\l{http://bugreports.qt-project.org/browse/QTWEBSITE-13}{http://bugreports.qt.../QTWEBSITE-13/}"),
whereas Qt::ElideRight is appropriate
for other strings (e.g.,
- "\l{http://qt.nokia.com/doc/qq/qq09-mac-deployment.html}{Deploying Applications on Ma...}").
+ "\l{http://doc.qt.digia.com/qq/qq09-mac-deployment.html}{Deploying Applications on Ma...}").
\sa QAbstractItemView::textElideMode, QFontMetrics::elidedText(), AlignmentFlag, QTabBar::elideMode
*/
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 4f3518aeb8..4df9c6b911 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -1640,8 +1640,8 @@ QString QIODevice::errorString() const
all the requested information was read and therefore does not retry reading
if there was a problem.
- This function will be called with maxSize 0 when the device is
- buffered and the buffer was emptied by a call to read().
+ This function might be called with a maxSize of 0, which can be used to
+ perform post-reading operations.
\sa read(), readLine(), writeData()
*/
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index d249bb17fb..693778e629 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -364,7 +364,8 @@ QProcessEnvironment QProcessEnvironment::systemEnvironment()
if (wchar_t *envStrings = GetEnvironmentStringsW()) {
for (const wchar_t *entry = envStrings; *entry; ) {
const int entryLen = int(wcslen(entry));
- if (const wchar_t *equal = wcschr(entry, L'=')) {
+ // + 1 to permit magic cmd variable names starting with =
+ if (const wchar_t *equal = wcschr(entry + 1, L'=')) {
int nameLen = equal - entry;
QString name = QString::fromWCharArray(entry, nameLen);
QString value = QString::fromWCharArray(equal + 1, entryLen - nameLen - 1);
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index ed0ff8d2e2..c71bb3afac 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -3887,7 +3887,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\section1 Examples:
\list
- \li qt.nokia.com becomes http://qt.nokia.com
+ \li qt-project.org becomes http://qt-project.org
\li ftp.qt-project.org becomes ftp://ftp.qt-project.org
\li hostname becomes http://hostname
\li /home/user/test.html becomes file:///home/user/test.html
diff --git a/src/corelib/kernel/qmetaobject_moc_p.h b/src/corelib/kernel/qmetaobject_moc_p.h
index 70b9d80f2d..c791f017d4 100644
--- a/src/corelib/kernel/qmetaobject_moc_p.h
+++ b/src/corelib/kernel/qmetaobject_moc_p.h
@@ -71,7 +71,7 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc
break;
}
/*
- We musn't convert 'char * const *' into 'const char **'
+ We mustn't convert 'char * const *' into 'const char **'
and we must beware of 'Bar<const Bla>'.
*/
if (t[i] == '&' || t[i] == '*' ||t[i] == '<')
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 69e2c6e1a2..e8c30d753e 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1917,7 +1917,11 @@ void QObject::removeEventFilter(QObject *obj)
loop. If the event loop is not running when this function is
called (e.g. deleteLater() is called on an object before
QCoreApplication::exec()), the object will be deleted once the
- event loop is started.
+ event loop is started. If deleteLater() is called after the main event loop
+ has stopped, the object will not be deleted.
+ Since Qt 4.8, if deleteLater() is called on an object that lives in a
+ thread with no running event loop, the object will be destroyed when the
+ thread finishes.
Note that entering and leaving a new event loop (e.g., by opening a modal
dialog) will \e not perform the deferred deletion; for the object to be
diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h
index 49fa1897f7..e6f924814d 100644
--- a/src/corelib/kernel/qobject_impl.h
+++ b/src/corelib/kernel/qobject_impl.h
@@ -76,14 +76,14 @@ namespace QtPrivate {
{ static const int *types() { static const int t[4] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg2>::qt_metatype_id(),
QtPrivate::QMetaTypeIdHelper<Arg3>::qt_metatype_id(), 0 }; return t; } };
template <typename Arg1, typename Arg2, typename Arg3, typename Arg4> struct ConnectionTypes<List<Arg1, List<Arg2, List<Arg3, List<Arg4, void> > > >, true>
- { static const int *types() { static const int t[4] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg2>::qt_metatype_id(),
+ { static const int *types() { static const int t[5] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg2>::qt_metatype_id(),
QtPrivate::QMetaTypeIdHelper<Arg3>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg4>::qt_metatype_id(), 0 }; return t; } };
template <typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> struct ConnectionTypes<List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, void> > > > >, true>
- { static const int *types() { static const int t[4] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg2>::qt_metatype_id(),
+ { static const int *types() { static const int t[6] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg2>::qt_metatype_id(),
QtPrivate::QMetaTypeIdHelper<Arg3>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg4>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg5>::qt_metatype_id(), 0 }; return t; } };
template <typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6>
struct ConnectionTypes<List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, List<Arg6, void> > > > > >, true>
- { static const int *types() { static const int t[4] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg2>::qt_metatype_id(),
+ { static const int *types() { static const int t[7] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg2>::qt_metatype_id(),
QtPrivate::QMetaTypeIdHelper<Arg3>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg4>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg5>::qt_metatype_id(),
QtPrivate::QMetaTypeIdHelper<Arg6>::qt_metatype_id(), 0 }; return t; } };
#else
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index d8bc87d13e..e4b4ce8b42 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -69,7 +69,7 @@ class QThreadData;
class QObjectConnectionListVector;
namespace QtSharedPointer { struct ExternalRefCountData; }
-/* for QtTestLib */
+/* for Qt Test */
struct QSignalSpyCallbackSet
{
typedef void (*BeginCallback)(QObject *caller, int signal_or_method_index, void **argv);
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index d0c2dd6380..667c490d31 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -385,6 +385,7 @@ void QTimer::setInterval(int msec)
/*!
\property QTimer::remainingTime
+ \since 5.0
\brief the remaining time in milliseconds
Returns the timer's remaining value in milliseconds left until the timeout.
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 8cc26c5ff6..ed1a8a4974 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -2960,7 +2960,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
Returns the stored value converted to the template type \c{T}.
Call canConvert() to find out whether a type can be converted.
- If the value cannot be converted, \l{default-constructed value}
+ If the value cannot be converted, a \l{default-constructed value}
will be returned.
If the type \c{T} is supported by QVariant, this function behaves
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 712681024d..bd8c6341c1 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -178,21 +178,38 @@ QThreadPrivate::~QThreadPrivate()
\ingroup thread
A QThread object manages one thread of control within the
- program. To make code run in a separate thread, simply create a
- QThread, change the thread affinity of the QObject(s) that
- contain the code, and start() the new event loop. For example:
+ program. QThreads begin executing in run(). By default, run() starts the
+ event loop by calling exec() and runs a Qt event loop inside the thread.
- \snippet code/src_corelib_thread_qthread.cpp 0
+ You can use worker objects by moving them to the thread using
+ QObject::moveToThread.
+
+ \snippet code/src_corelib_thread_qthread.cpp worker
The code inside the Worker's slot would then execute in a
- separate thread. In this example, the QThread triggers the
- Worker's doWork() slot upon starting, and frees the Worker's
- memory upon terminating. However, you are free to connect the
+ separate thread. However, you are free to connect the
Worker's slots to any signal, from any object, in any thread. It
is safe to connect signals and slots across different threads,
thanks to a mechanism called \l{Qt::QueuedConnection}{queued
connections}.
+ Another way to make code run in a separate thread, is to subclass QThread
+ and reimplement run(). For example:
+
+ \snippet code/src_corelib_thread_qthread.cpp reimpl-run
+
+ In that example, the thread will exit after the run function has returned.
+ There will not be any event loop running in the thread unless you call
+ exec().
+
+ It is important to remember that a QThread object usually lives
+ in the thread where it was created, not in the thread that it
+ manages. This oft-overlooked detail means that a QThread's slots
+ will be executed in the context of its home thread, not in the
+ context of the thread it is managing. For this reason,
+ implementing new slots in a QThread subclass is error-prone and
+ discouraged.
+
\note If you interact with an object, using any technique other
than queued signal/slot connections (e.g. direct function calls),
then the usual multithreading precautions need to be taken.
@@ -200,7 +217,6 @@ QThreadPrivate::~QThreadPrivate()
\note It is not possible to change the thread affinity of GUI
objects; they must remain in the main thread.
-
\section1 Managing threads
QThread will notifiy you via a signal when the thread is
@@ -244,36 +260,6 @@ QThreadPrivate::~QThreadPrivate()
\l{Mandelbrot Example}, as that is the name of the QThread subclass).
Note that this is currently not available with release builds on Windows.
- \section1 Subclassing QThread
-
- Subclassing QThread is unnecessary for most purposes, since
- QThread provides fully-functional thread management capabilities.
- Nonetheless, QThread can be subclassed if you wish to implement
- advanced thread management. This is done by adding new member
- functions to the subclass, and/or by reimplementing run().
- QThread's run() function is analogous to an application's main()
- function -- it is executed when the thread is started, and the
- thread will end when it returns.
-
- \note Prior to Qt 4.4, the only way to use QThread for parallel
- processing was to subclass it and implement the processing code
- inside run(). This approach is now considered \b {bad practice};
- a QThread should only manage a thread, not process data.
-
- If you require event handling and signal/slot connections to
- work in your thread, and if you reimplement run(), you must
- explicitly call exec() at the end of your reimplementation:
-
- \snippet code/src_corelib_thread_qthread.cpp 1
-
- It is important to remember that a QThread object usually lives
- in the thread where it was created, not in the thread that it
- manages. This oft-overlooked detail means that a QThread's slots
- will be executed in the context of its home thread, not in the
- context of the thread it is managing. For this reason,
- implementing new slots in a QThread subclass is error-prone and
- discouraged.
-
\sa {Thread Support in Qt}, QThreadStorage, QMutex, QSemaphore, QWaitCondition,
{Mandelbrot Example}, {Semaphores Example}, {Wait Conditions Example}
*/
diff --git a/src/corelib/tools/qpair.qdoc b/src/corelib/tools/qpair.qdoc
index a79486115d..55353dc258 100644
--- a/src/corelib/tools/qpair.qdoc
+++ b/src/corelib/tools/qpair.qdoc
@@ -84,7 +84,7 @@
/*! \fn QPair::QPair()
Constructs an empty pair. The \c first and \c second elements are
- initialized with \l{default-constructed values}.
+ initialized with \l{default-constructed value}s.
*/
/*!
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 1a9c25837e..b9d546452f 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -139,7 +139,8 @@
#endif
// other x86 intrinsics
-#if defined(QT_COMPILER_SUPPORTS_AVX) && defined(Q_CC_GNU)
+#if defined(QT_COMPILER_SUPPORTS_AVX) && defined(Q_CC_GNU) && \
+ (!defined(Q_CC_INTEL)|| __INTEL_COMPILER >= 1310 || (__GNUC__ * 100 + __GNUC_MINOR__ < 407))
#define QT_COMPILER_SUPPORTS_X86INTRIN
#include <x86intrin.h>
#endif
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index ed8cb734f5..0be0a84459 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -4965,7 +4965,7 @@ int QString::compare_helper(const QChar *data1, int length1, QLatin1String s2,
lists of strings to the user.
On Mac OS X since Qt 4.3, this function compares according the
- "Order for sorted lists" setting in the International prefereces panel.
+ "Order for sorted lists" setting in the International preferences panel.
\sa compare(), QTextCodec::locale()
*/
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index 455df4ec73..4be4593e95 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -1958,7 +1958,7 @@ QStringRef QXmlStreamReader::text() const
}
-/*! If the state() is \l DTD, this function returns the DTD's
+/*! If the tokenType() is \l DTD, this function returns the DTD's
notation declarations. Otherwise an empty vector is returned.
The QXmlStreamNotationDeclarations class is defined to be a QVector
@@ -1973,7 +1973,7 @@ QXmlStreamNotationDeclarations QXmlStreamReader::notationDeclarations() const
}
-/*! If the state() is \l DTD, this function returns the DTD's
+/*! If the tokenType() is \l DTD, this function returns the DTD's
unparsed (external) entity declarations. Otherwise an empty vector is returned.
The QXmlStreamEntityDeclarations class is defined to be a QVector
@@ -1990,7 +1990,7 @@ QXmlStreamEntityDeclarations QXmlStreamReader::entityDeclarations() const
/*!
\since 4.4
- If the state() is \l DTD, this function returns the DTD's
+ If the tokenType() is \l DTD, this function returns the DTD's
name. Otherwise an empty string is returned.
*/
@@ -2005,7 +2005,7 @@ QStringRef QXmlStreamReader::dtdName() const
/*!
\since 4.4
- If the state() is \l DTD, this function returns the DTD's
+ If the tokenType() is \l DTD, this function returns the DTD's
public identifier. Otherwise an empty string is returned.
*/
@@ -2020,7 +2020,7 @@ QStringRef QXmlStreamReader::dtdPublicId() const
/*!
\since 4.4
- If the state() is \l DTD, this function returns the DTD's
+ If the tokenType() is \l DTD, this function returns the DTD's
system identifier. Otherwise an empty string is returned.
*/
@@ -2032,7 +2032,7 @@ QStringRef QXmlStreamReader::dtdSystemId() const
return QStringRef();
}
-/*! If the state() is \l StartElement, this function returns the
+/*! If the tokenType() is \l StartElement, this function returns the
element's namespace declarations. Otherwise an empty vector is
returned.
@@ -2845,7 +2845,7 @@ bool QXmlStreamReader::isStandaloneDocument() const
/*!
\since 4.4
- If the state() is \l StartDocument, this function returns the
+ If the tokenType() is \l StartDocument, this function returns the
version string as specified in the XML declaration.
Otherwise an empty string is returned.
*/
@@ -2860,7 +2860,7 @@ QStringRef QXmlStreamReader::documentVersion() const
/*!
\since 4.4
- If the state() is \l StartDocument, this function returns the
+ If the tokenType() is \l StartDocument, this function returns the
encoding string as specified in the XML declaration.
Otherwise an empty string is returned.
*/
diff --git a/src/corelib/xml/qxmlstream.g b/src/corelib/xml/qxmlstream.g
index dc0bb353c9..cd7b4fe14e 100644
--- a/src/corelib/xml/qxmlstream.g
+++ b/src/corelib/xml/qxmlstream.g
@@ -207,18 +207,18 @@ public:
inline QStringRef addToStringStorage(const QStringRef &s) {
int pos = tagStackStringStorageSize;
- int sz = s.size();
- if (pos != tagStackStringStorage.size())
- tagStackStringStorage.resize(pos);
+ int sz = s.size();
+ if (pos != tagStackStringStorage.size())
+ tagStackStringStorage.resize(pos);
tagStackStringStorage.insert(pos, s.unicode(), sz);
tagStackStringStorageSize += sz;
return QStringRef(&tagStackStringStorage, pos, sz);
}
inline QStringRef addToStringStorage(const QString &s) {
int pos = tagStackStringStorageSize;
- int sz = s.size();
- if (pos != tagStackStringStorage.size())
- tagStackStringStorage.resize(pos);
+ int sz = s.size();
+ if (pos != tagStackStringStorage.size())
+ tagStackStringStorage.resize(pos);
tagStackStringStorage.insert(pos, s.unicode(), sz);
tagStackStringStorageSize += sz;
return QStringRef(&tagStackStringStorage, pos, sz);
@@ -525,7 +525,7 @@ bool QXmlStreamReaderPrivate::parse()
case QXmlStreamReader::StartElement:
name.clear();
prefix.clear();
- qualifiedName.clear();
+ qualifiedName.clear();
namespaceUri.clear();
if (publicNamespaceDeclarations.size())
publicNamespaceDeclarations.clear();
@@ -536,7 +536,7 @@ bool QXmlStreamReaderPrivate::parse()
Tag &tag = tagStack_pop();
namespaceUri = tag.namespaceDeclaration.namespaceUri;
name = tag.name;
- qualifiedName = tag.qualifiedName;
+ qualifiedName = tag.qualifiedName;
isEmptyElement = false;
return true;
}
@@ -545,7 +545,7 @@ bool QXmlStreamReaderPrivate::parse()
case QXmlStreamReader::EndElement:
name.clear();
prefix.clear();
- qualifiedName.clear();
+ qualifiedName.clear();
namespaceUri.clear();
clearTextBuffer();
break;
@@ -559,7 +559,7 @@ bool QXmlStreamReaderPrivate::parse()
case QXmlStreamReader::Comment:
case QXmlStreamReader::Characters:
isCDATA = false;
- isWhitespace = true;
+ isWhitespace = true;
text.clear();
clearTextBuffer();
break;
@@ -571,21 +571,21 @@ bool QXmlStreamReaderPrivate::parse()
case QXmlStreamReader::ProcessingInstruction:
processingInstructionTarget.clear();
processingInstructionData.clear();
- clearTextBuffer();
+ clearTextBuffer();
break;
case QXmlStreamReader::NoToken:
case QXmlStreamReader::Invalid:
break;
case QXmlStreamReader::StartDocument:
- lockEncoding = true;
+ lockEncoding = true;
documentVersion.clear();
documentEncoding.clear();
#ifndef QT_NO_TEXTCODEC
- if(decoder->hasFailure()) {
- raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content."));
- readBuffer.clear();
- return false;
- }
+ if (decoder->hasFailure()) {
+ raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content."));
+ readBuffer.clear();
+ return false;
+ }
#endif
// fall through
default:
@@ -1225,7 +1225,7 @@ cdata ::= langle_bang CDATA_START;
case $rule_number: {
setType(QXmlStreamReader::Characters);
isCDATA = true;
- isWhitespace = false;
+ isWhitespace = false;
int pos = sym(2).pos;
if (scanUntil("]]>", -1)) {
text = QStringRef(&textBuffer, pos, textBuffer.size() - pos - 3);
@@ -1294,7 +1294,7 @@ scan_content_char ::= SPACE;
resume($rule_number);
return false;
}
- break;
+ break;
./
content_char_list ::= content_char_list char_ref;
@@ -1310,11 +1310,11 @@ content_char_list ::= scan_content_char;
character_content ::= content_char_list %prec SHIFT_THERE;
/.
case $rule_number:
- if (!textBuffer.isEmpty()) {
+ if (!textBuffer.isEmpty()) {
setType(QXmlStreamReader::Characters);
text = &textBuffer;
- }
- break;
+ }
+ break;
./
literal ::= QUOTE QUOTE;
@@ -1361,7 +1361,7 @@ literal_content_start ::= LETTER | DIGIT | RANGLE | HASH | LBRACK | RBRACK | LPA
literal_content_start ::= SPACE;
/.
case $rule_number:
- if (normalizeLiterals)
+ if (normalizeLiterals)
textBuffer.data()[textBuffer.size()-1] = QLatin1Char(' ');
break;
./
@@ -1405,7 +1405,7 @@ entity_value ::= QUOTE entity_value_content_with_dblquote QUOTE;
entity_value ::= DBLQUOTE entity_value_content_with_quote DBLQUOTE;
/.
case $rule_number:
- sym(1) = sym(2);
+ sym(1) = sym(2);
break;
./
@@ -1609,7 +1609,7 @@ unresolved_entity ::= UNRESOLVED_ENTITY;
}
setType(QXmlStreamReader::EntityReference);
name = &unresolvedEntity;
- break;
+ break;
./
entity_ref ::= AMPERSAND name SEMICOLON;
@@ -1646,10 +1646,10 @@ entity_ref ::= AMPERSAND name SEMICOLON;
}
}
- injectToken(UNRESOLVED_ENTITY);
- unresolvedEntity = symString(2).toString();
- textBuffer.chop(2 + sym(2).len);
- clearSym();
+ injectToken(UNRESOLVED_ENTITY);
+ unresolvedEntity = symString(2).toString();
+ textBuffer.chop(2 + sym(2).len);
+ clearSym();
} break;
./
diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h
index 8276fe2721..68b7ff7af3 100644
--- a/src/corelib/xml/qxmlstream_p.h
+++ b/src/corelib/xml/qxmlstream_p.h
@@ -701,18 +701,18 @@ public:
inline QStringRef addToStringStorage(const QStringRef &s) {
int pos = tagStackStringStorageSize;
- int sz = s.size();
- if (pos != tagStackStringStorage.size())
- tagStackStringStorage.resize(pos);
+ int sz = s.size();
+ if (pos != tagStackStringStorage.size())
+ tagStackStringStorage.resize(pos);
tagStackStringStorage.insert(pos, s.unicode(), sz);
tagStackStringStorageSize += sz;
return QStringRef(&tagStackStringStorage, pos, sz);
}
inline QStringRef addToStringStorage(const QString &s) {
int pos = tagStackStringStorageSize;
- int sz = s.size();
- if (pos != tagStackStringStorage.size())
- tagStackStringStorage.resize(pos);
+ int sz = s.size();
+ if (pos != tagStackStringStorage.size())
+ tagStackStringStorage.resize(pos);
tagStackStringStorage.insert(pos, s.unicode(), sz);
tagStackStringStorageSize += sz;
return QStringRef(&tagStackStringStorage, pos, sz);
@@ -1019,7 +1019,7 @@ bool QXmlStreamReaderPrivate::parse()
case QXmlStreamReader::StartElement:
name.clear();
prefix.clear();
- qualifiedName.clear();
+ qualifiedName.clear();
namespaceUri.clear();
if (publicNamespaceDeclarations.size())
publicNamespaceDeclarations.clear();
@@ -1030,7 +1030,7 @@ bool QXmlStreamReaderPrivate::parse()
Tag &tag = tagStack_pop();
namespaceUri = tag.namespaceDeclaration.namespaceUri;
name = tag.name;
- qualifiedName = tag.qualifiedName;
+ qualifiedName = tag.qualifiedName;
isEmptyElement = false;
return true;
}
@@ -1039,7 +1039,7 @@ bool QXmlStreamReaderPrivate::parse()
case QXmlStreamReader::EndElement:
name.clear();
prefix.clear();
- qualifiedName.clear();
+ qualifiedName.clear();
namespaceUri.clear();
clearTextBuffer();
break;
@@ -1053,7 +1053,7 @@ bool QXmlStreamReaderPrivate::parse()
case QXmlStreamReader::Comment:
case QXmlStreamReader::Characters:
isCDATA = false;
- isWhitespace = true;
+ isWhitespace = true;
text.clear();
clearTextBuffer();
break;
@@ -1065,21 +1065,21 @@ bool QXmlStreamReaderPrivate::parse()
case QXmlStreamReader::ProcessingInstruction:
processingInstructionTarget.clear();
processingInstructionData.clear();
- clearTextBuffer();
+ clearTextBuffer();
break;
case QXmlStreamReader::NoToken:
case QXmlStreamReader::Invalid:
break;
case QXmlStreamReader::StartDocument:
- lockEncoding = true;
+ lockEncoding = true;
documentVersion.clear();
documentEncoding.clear();
#ifndef QT_NO_TEXTCODEC
- if(decoder->hasFailure()) {
- raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content."));
- readBuffer.clear();
- return false;
- }
+ if (decoder->hasFailure()) {
+ raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content."));
+ readBuffer.clear();
+ return false;
+ }
#endif
// fall through
default:
@@ -1550,7 +1550,7 @@ bool QXmlStreamReaderPrivate::parse()
case 101: {
setType(QXmlStreamReader::Characters);
isCDATA = true;
- isWhitespace = false;
+ isWhitespace = false;
int pos = sym(2).pos;
if (scanUntil("]]>", -1)) {
text = QStringRef(&textBuffer, pos, textBuffer.size() - pos - 3);
@@ -1597,14 +1597,14 @@ bool QXmlStreamReaderPrivate::parse()
resume(130);
return false;
}
- break;
+ break;
case 139:
- if (!textBuffer.isEmpty()) {
+ if (!textBuffer.isEmpty()) {
setType(QXmlStreamReader::Characters);
text = &textBuffer;
- }
- break;
+ }
+ break;
case 140:
case 141:
@@ -1624,7 +1624,7 @@ bool QXmlStreamReaderPrivate::parse()
break;
case 173:
- if (normalizeLiterals)
+ if (normalizeLiterals)
textBuffer.data()[textBuffer.size()-1] = QLatin1Char(' ');
break;
@@ -1651,7 +1651,7 @@ bool QXmlStreamReaderPrivate::parse()
case 178:
case 179:
- sym(1) = sym(2);
+ sym(1) = sym(2);
break;
case 180:
@@ -1789,7 +1789,7 @@ bool QXmlStreamReaderPrivate::parse()
}
setType(QXmlStreamReader::EntityReference);
name = &unresolvedEntity;
- break;
+ break;
case 240: {
sym(1).len += sym(2).len + 1;
@@ -1823,10 +1823,10 @@ bool QXmlStreamReaderPrivate::parse()
}
}
- injectToken(UNRESOLVED_ENTITY);
- unresolvedEntity = symString(2).toString();
- textBuffer.chop(2 + sym(2).len);
- clearSym();
+ injectToken(UNRESOLVED_ENTITY);
+ unresolvedEntity = symString(2).toString();
+ textBuffer.chop(2 + sym(2).len);
+ clearSym();
} break;