summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in10
-rw-r--r--src/corelib/Qt5CoreMacros.cmake6
-rw-r--r--src/corelib/codecs/qicucodec.cpp2
-rw-r--r--src/corelib/codecs/qtextcodec.cpp23
-rw-r--r--src/corelib/codecs/qwindowscodec.cpp4
-rw-r--r--src/corelib/doc/qtcore.qdocconf3
-rw-r--r--src/corelib/doc/snippets/code/doc_src_resources.cpp4
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp5
-rw-r--r--src/corelib/doc/src/statemachine.qdoc32
-rw-r--r--src/corelib/global/qglobal.cpp86
-rw-r--r--src/corelib/global/qglobal.h5
-rw-r--r--src/corelib/global/qlogging.cpp6
-rw-r--r--src/corelib/global/qnamespace.h9
-rw-r--r--src/corelib/global/qnamespace.qdoc18
-rw-r--r--src/corelib/global/qtypetraits.h21
-rw-r--r--src/corelib/io/io.pri2
-rw-r--r--src/corelib/io/qfileselector.cpp12
-rw-r--r--src/corelib/io/qfilesystementry.cpp16
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp4
-rw-r--r--src/corelib/io/qiodevice.cpp53
-rw-r--r--src/corelib/io/qlockfile.cpp12
-rw-r--r--src/corelib/io/qlockfile_p.h1
-rw-r--r--src/corelib/io/qlockfile_unix.cpp58
-rw-r--r--src/corelib/io/qlockfile_win.cpp73
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice.cpp18
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice_p.h4
-rw-r--r--src/corelib/io/qsettings.cpp6
-rw-r--r--src/corelib/io/qstandardpaths.cpp30
-rw-r--r--src/corelib/io/qstandardpaths_ios.mm29
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp24
-rw-r--r--src/corelib/io/qtextstream.cpp12
-rw-r--r--src/corelib/io/qurl.h4
-rw-r--r--src/corelib/io/qwindowspipereader.cpp102
-rw-r--r--src/corelib/io/qwindowspipereader_p.h4
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp10
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt.cpp12
-rw-r--r--src/corelib/kernel/qfunctions_winrt.h8
-rw-r--r--src/corelib/kernel/qjni.cpp472
-rw-r--r--src/corelib/kernel/qjni_p.h1
-rw-r--r--src/corelib/kernel/qmetatype.h15
-rw-r--r--src/corelib/kernel/qobjectdefs.h1
-rw-r--r--src/corelib/kernel/qsharedmemory_win.cpp1
-rw-r--r--src/corelib/mimetypes/qmimetype.cpp6
-rw-r--r--src/corelib/mimetypes/qmimetype_p.h2
-rw-r--r--src/corelib/statemachine/qabstracttransition.cpp46
-rw-r--r--src/corelib/statemachine/qabstracttransition.h10
-rw-r--r--src/corelib/statemachine/qabstracttransition_p.h1
-rw-r--r--src/corelib/statemachine/qeventtransition_p.h2
-rw-r--r--src/corelib/statemachine/qstate_p.h2
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp343
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h21
-rw-r--r--src/corelib/thread/qthread_p.h14
-rw-r--r--src/corelib/tools/qcollator.cpp22
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp8
-rw-r--r--src/corelib/tools/qcontiguouscache.h2
-rw-r--r--src/corelib/tools/qdatetimeparser.cpp14
-rw-r--r--src/corelib/tools/qdatetimeparser_p.h3
-rw-r--r--src/corelib/tools/qpair.qdoc54
-rw-r--r--src/corelib/tools/qregularexpression.cpp20
-rw-r--r--src/corelib/tools/qscopedpointer.cpp7
-rw-r--r--src/corelib/tools/qset.qdoc13
-rw-r--r--src/corelib/tools/qsize.h20
-rw-r--r--src/corelib/tools/qstring.cpp112
-rw-r--r--src/corelib/tools/qstring.h2
64 files changed, 1396 insertions, 546 deletions
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 7213a844f5..65fd1f9383 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -70,8 +70,14 @@ set(_qt5_corelib_extra_includes)
# Qt5_POSITION_INDEPENDENT_CODE variable is used in the # qt5_use_module
# macro to add it.
set(Qt5_POSITION_INDEPENDENT_CODE True)
-set_property(TARGET Qt5::Core PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\")
-set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIE\")
+set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIC\")
+if (CMAKE_VERSION VERSION_LESS 2.8.12
+ AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\"
+ OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
+ set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\")
+else()
+ set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $$QMAKE_CXXFLAGS_APP)
+endif()
!!IF !isEmpty(QT_NAMESPACE)
list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE)
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index a94caf0d25..18563764ad 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -333,8 +333,10 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.9)
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG)
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG)
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG)
-
- if (Qt5_POSITION_INDEPENDENT_CODE)
+ if (Qt5_POSITION_INDEPENDENT_CODE
+ AND (CMAKE_VERSION VERSION_LESS 2.8.12
+ AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\"
+ OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)))
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE})
endif()
endforeach()
diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp
index 65cc337708..b375999aeb 100644
--- a/src/corelib/codecs/qicucodec.cpp
+++ b/src/corelib/codecs/qicucodec.cpp
@@ -121,7 +121,7 @@ struct MibToName {
short index;
};
-static MibToName mibToName[] = {
+static const MibToName mibToName[] = {
{ 3, 0 },
{ 4, 9 },
{ 5, 20 },
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 050f8f207f..8fef333a77 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -1147,13 +1147,30 @@ QTextCodec *QTextCodec::codecForUtfText(const QByteArray &ba)
return codecForUtfText(ba, QTextCodec::codecForMib(/*Latin 1*/ 4));
}
+/*!
+ \fn QTextCodec * QTextCodec::codecForTr ()
+ \obsolete
+
+ Returns the codec used by QObject::tr() on its argument. If this
+ function returns 0 (the default), tr() assumes Latin-1.
+
+ \sa setCodecForTr()
+*/
+
+/*!
+ \fn QTextCodec::setCodecForTr ( QTextCodec * c )
+ \obsolete
+
+ Sets the codec used by QObject::tr() on its argument to c. If c
+ is 0 (the default), tr() assumes Latin-1.
+*/
/*!
\internal
\since 4.3
- Determines whether the decoder encountered a failure while decoding the input. If
- an error was encountered, the produced result is undefined, and gets converted as according
- to the conversion flags.
+ Determines whether the decoder encountered a failure while decoding the
+ input. If an error was encountered, the produced result is undefined, and
+ gets converted as according to the conversion flags.
*/
bool QTextDecoder::hasFailure() const
{
diff --git a/src/corelib/codecs/qwindowscodec.cpp b/src/corelib/codecs/qwindowscodec.cpp
index cf427c64b6..dded93ccb5 100644
--- a/src/corelib/codecs/qwindowscodec.cpp
+++ b/src/corelib/codecs/qwindowscodec.cpp
@@ -172,7 +172,7 @@ QString QWindowsLocalCodec::convertToUnicodeCharByChar(const char *chars, int le
}
#else
QString s;
- int size = mbstowcs(NULL, mb, length);
+ size_t size = mbstowcs(NULL, mb, length);
if (size < 0) {
Q_ASSERT("Error in CE TextCodec");
return QString();
@@ -181,7 +181,7 @@ QString QWindowsLocalCodec::convertToUnicodeCharByChar(const char *chars, int le
ws[size +1] = 0;
ws[size] = 0;
size = mbstowcs(ws, mb, length);
- for (int i=0; i< size; i++)
+ for (size_t i = 0; i < size; i++)
s.append(QChar(ws[i]));
delete [] ws;
#endif
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index df1ee4afea..502689e4c2 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -43,5 +43,8 @@ imagedirs += images
excludedirs += snippets
+excludefiles += ../../../examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc \
+ ../../../examples/widgets/tools/codecs/doc/src/codecs.qdoc
+
navigation.landingpage = "Qt Core"
navigation.cppclassespage = "Qt Core C++ Classes"
diff --git a/src/corelib/doc/snippets/code/doc_src_resources.cpp b/src/corelib/doc/snippets/code/doc_src_resources.cpp
index 430c0c92c1..ab97f609ac 100644
--- a/src/corelib/doc/snippets/code/doc_src_resources.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_resources.cpp
@@ -48,7 +48,7 @@ MyClass::MyClass() : BaseClass()
{
Q_INIT_RESOURCE(resources);
- QFile file("qrc:/myfile.dat");
+ QFile file(":/myfile.dat");
...
}
//! [5]
@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
Q_INIT_RESOURCE(graphlib);
- QFile file("qrc:/graph.png");
+ QFile file(":/graph.png");
...
return app.exec();
}
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
index 77ec85cc36..e3d76453d0 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qsystemsemaphore.cpp
@@ -51,8 +51,9 @@ sem.release(2); // resources available == 3
//! [1]
QSystemSemaphore sem("market", 5, QSystemSemaphore::Create);
-sem.acquire(5); // acquire all 5 resources
-sem.release(5); // release the 5 resources
+for (int i = 0; i < 5; ++i) // acquire all 5 resources
+ sem.acquire();
+sem.release(5); // release the 5 resources
//! [1]
diff --git a/src/corelib/doc/src/statemachine.qdoc b/src/corelib/doc/src/statemachine.qdoc
index 037b09810f..e44a603959 100644
--- a/src/corelib/doc/src/statemachine.qdoc
+++ b/src/corelib/doc/src/statemachine.qdoc
@@ -63,7 +63,7 @@
used to effectively embed the elements and semantics of statecharts in Qt
applications. The framework integrates tightly with Qt's meta-object system;
for example, transitions between states can be triggered by signals, and
- states can be configured to set properties and invoke methods on QObjects.
+ states can be configured to set properties and invoke methods on {QObject}s.
Qt's event system is used to drive the state machines.
The state graph in the State Machine framework is hierarchical. States can be nested inside of
@@ -126,9 +126,9 @@
The QState::entered() signal is emitted when the state is entered, and the
QState::exited() signal is emitted when the state is exited. In the
- following snippet, the button's showMaximized() slot will be called when
- state \c s3 is entered, and the button's showMinimized() slot will be called
- when \c s3 is exited:
+ following snippet, the button's \l {QPushButton::}{showMaximized()} slot
+ will be called when state \c s3 is entered, and the button's \l {QPushButton::}{showMinimized()}
+ slot will be called when \c s3 is exited:
\snippet statemachine/main.cpp 5
@@ -151,7 +151,7 @@
Assume we wanted the user to be able to quit the application at any time by
clicking a Quit button. In order to achieve this, we need to create a final
state and make it the target of a transition associated with the Quit
- button's clicked() signal. We could add a transition from each of \c s1, \c
+ button's \l{QPushButton::}{clicked()} signal. We could add a transition from each of \c s1, \c
s2 and \c s3; however, this seems redundant, and one would also have to
remember to add such a transition from every new state that is added in the
future.
@@ -184,8 +184,8 @@
\snippet statemachine/main2.cpp 1
In this case we want the application to quit when the state machine is
- finished, so the machine's finished() signal is connected to the
- application's quit() slot.
+ finished, so the machine's \l {QStateMachine::}{finished()} signal is connected to the
+ application's \l {QCoreApplication::}{quit()} slot.
A child state can override an inherited transition. For example, the
following code adds a transition that effectively causes the Quit button to
@@ -290,7 +290,7 @@
\endomit
When \c s1 's final state is entered, \c s1 will automatically emit
- finished(). We use a signal transition to cause this event to trigger a
+ \l {QState::}{finished()}. We use a signal transition to cause this event to trigger a
state change:
\snippet statemachine/main3.cpp 1
@@ -302,7 +302,7 @@
encapsulation mechanism when building complex (deeply nested) state
machines. (In the above example, you could of course create a transition
directly from \c s1 's \c done state rather than relying on \c s1 's
- finished() signal, but with the consequence that implementation details of
+ \l {QState::}{finished()} signal, but with the consequence that implementation details of
\c s1 are exposed and depended on).
For parallel state groups, the QState::finished() signal is emitted when \e
@@ -365,8 +365,8 @@
\snippet statemachine/main4.cpp 1
- In the eventTest() reimplementation, we first check if the event type is the
- desired one; if so, we cast the event to a StringEvent and perform the
+ In the \l {QAbstractTransition::}{eventTest()} reimplementation, we first check if the event type is the
+ desired one; if so, we cast the event to a \c StringEvent and perform the
string comparison.
The following is a statechart that uses the custom event and transition:
@@ -486,7 +486,7 @@
message box will pop up before the geometry of the button has actually been set.
To ensure that the message box does not pop up until the geometry actually reaches its final
- value, we can use the state's propertiesAssigned() signal. The propertiesAssigned() signal will be
+ value, we can use the state's \l {QState::}{propertiesAssigned()} signal. The \l {QState::}{propertiesAssigned()} signal will be
emitted when the property is assigned its final value, whether this is done immediately or
after the animation has finished playing.
@@ -503,14 +503,14 @@
has been assigned the defined value.
If the global restore policy is set to QStateMachine::RestoreProperties, the state will not emit
- the propertiesAssigned() signal until these have been executed as well.
+ the \l {QState::}{propertiesAssigned()} signal until these have been executed as well.
\section1 What Happens If A State Is Exited Before The Animation Has Finished
If a state has property assignments, and the transition into the state has animations for the
properties, the state can potentially be exited before the properties have been assigned to the
values defines by the state. This is true in particular when there are transitions out from the
- state that do not depend on the propertiesAssigned signal, as described in the previous section.
+ state that do not depend on the \l {QState::}{propertiesAssigned()} signal, as described in the previous section.
The State Machine API guarantees that a property assigned by the state machine either:
\list
@@ -563,13 +563,13 @@
The parent state machine treats the child machine as an \e atomic state in the state machine
algorithm. The child state machine is self-contained; it maintains its own event queue and
- configuration. In particular, note that the \l{QStateMachine::configuration()}{configuration}
+ configuration. In particular, note that the \l{QStateMachine::}{configuration()}
of the child machine is not part of the parent machine's configuration (only the child machine
itself is).
States of the child state machine cannot be specified as targets of transitions in the parent
state machine; only the child state machine itself can. Conversely, states of the parent state
machine cannot be specified as targets of transitions in the child state machine. The child
- state machine's \l{QState::finished()}{finished}() signal can be used to trigger a transition
+ state machine's \l{QState::}{finished}() signal can be used to trigger a transition
in the parent machine.
*/
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 4f611bddbc..91e8699472 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2124,9 +2124,9 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion()
# define USE_ETC_OS_RELEASE
struct QUnixOSVersion
{
- // from /etc/os-release older /etc/lsb-release
- QString productType; // $ID $DISTRIB_ID
- QString productVersion; // $VERSION_ID $DISTRIB_RELEASE
+ // from /etc/os-release older /etc/lsb-release // redhat /etc/redhat-release // debian /etc/debian_version
+ QString productType; // $ID $DISTRIB_ID // single line file containing: // Debian
+ QString productVersion; // $VERSION_ID $DISTRIB_RELEASE // <Vendor_ID release Version_ID> // single line file <Release_ID/sid>
QString prettyName; // $PRETTY_NAME $DISTRIB_DESCRIPTION
};
@@ -2138,24 +2138,32 @@ static QString unquote(const char *begin, const char *end)
}
return QString::fromLatin1(begin, end - begin);
}
-
-static bool readEtcFile(QUnixOSVersion &v, const char *filename,
- const QByteArray &idKey, const QByteArray &versionKey, const QByteArray &prettyNameKey)
+static QByteArray getEtcFileContent(const char *filename)
{
// we're avoiding QFile here
int fd = qt_safe_open(filename, O_RDONLY);
if (fd == -1)
- return false;
+ return QByteArray();
QT_STATBUF sbuf;
if (QT_FSTAT(fd, &sbuf) == -1) {
qt_safe_close(fd);
- return false;
+ return QByteArray();
}
QByteArray buffer(sbuf.st_size, Qt::Uninitialized);
buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size));
qt_safe_close(fd);
+ return buffer;
+}
+
+static bool readEtcFile(QUnixOSVersion &v, const char *filename,
+ const QByteArray &idKey, const QByteArray &versionKey, const QByteArray &prettyNameKey)
+{
+
+ QByteArray buffer = getEtcFileContent(filename);
+ if (buffer.isEmpty())
+ return false;
const char *ptr = buffer.constData();
const char *end = buffer.constEnd();
@@ -2219,14 +2227,72 @@ static bool readEtcLsbRelease(QUnixOSVersion &v)
}
}
- return ok;
+ // some distributions have a /etc/lsb-release file that does not provide the values
+ // we are looking for, i.e. DISTRIB_ID, DISTRIB_RELEASE and DISTRIB_DESCRIPTION.
+ // Assuming that neither DISTRIB_ID nor DISTRIB_RELEASE were found, or contained valid values,
+ // returning false for readEtcLsbRelease will allow further /etc/<lowercasename>-release parsing.
+ return ok && !(v.productType.isEmpty() && v.productVersion.isEmpty());
}
+#if defined(Q_OS_LINUX)
+static QByteArray getEtcFileFirstLine(const char *fileName)
+{
+ QByteArray buffer = getEtcFileContent(fileName);
+ if (buffer.isEmpty())
+ return QByteArray();
+
+ const char *ptr = buffer.constData();
+ int eol = buffer.indexOf("\n");
+ return QByteArray(ptr, eol).trimmed();
+}
+
+static bool readEtcRedHatRelease(QUnixOSVersion &v)
+{
+ // /etc/redhat-release analysed should be a one line file
+ // the format of its content is <Vendor_ID release Version>
+ // i.e. "Red Hat Enterprise Linux Workstation release 6.5 (Santiago)"
+ QByteArray line = getEtcFileFirstLine("/etc/redhat-release");
+ if (line.isEmpty())
+ return false;
+
+ v.prettyName = QString::fromLatin1(line);
+
+ const char keyword[] = "release ";
+ int releaseIndex = line.indexOf(keyword);
+ v.productType = QString::fromLatin1(line.mid(0, releaseIndex)).remove(QLatin1Char(' '));
+ int spaceIndex = line.indexOf(' ', releaseIndex + strlen(keyword));
+ v.productVersion = QString::fromLatin1(line.mid(releaseIndex + strlen(keyword), spaceIndex > -1 ? spaceIndex - releaseIndex - strlen(keyword) : -1));
+ return true;
+}
+
+static bool readEtcDebianVersion(QUnixOSVersion &v)
+{
+ // /etc/debian_version analysed should be a one line file
+ // the format of its content is <Release_ID/sid>
+ // i.e. "jessie/sid"
+ QByteArray line = getEtcFileFirstLine("/etc/debian_version");
+ if (line.isEmpty())
+ return false;
+
+ v.productType = QStringLiteral("Debian");
+ v.productVersion = QString::fromLatin1(line);
+ return true;
+}
+#endif
+
static bool findUnixOsVersion(QUnixOSVersion &v)
{
if (readEtcOsRelease(v))
return true;
- return readEtcLsbRelease(v);
+ if (readEtcLsbRelease(v))
+ return true;
+#if defined(Q_OS_LINUX)
+ if (readEtcRedHatRelease(v))
+ return true;
+ if (readEtcDebianVersion(v))
+ return true;
+#endif
+ return false;
}
# endif // USE_ETC_OS_RELEASE
#endif // Q_OS_UNIX
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 55aa34223e..4eeee0fef4 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1090,9 +1090,10 @@ Q_CORE_EXPORT int qrand();
#define QT_MODULE(x)
-#if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__)
+#if !defined(QT_BOOTSTRAPPED) && defined(QT_REDUCE_RELOCATIONS) && defined(__ELF__) && \
+ (!defined(__PIC__) || (defined(__PIE__) && defined(Q_CC_GNU) && Q_CC_GNU >= 500))
# error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\
- "Compile your code with -fPIC or -fPIE."
+ "Compile your code with -fPIC (-fPIE is not enough)."
#endif
namespace QtPrivate {
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index d9d21c535c..88882bbe8f 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -972,8 +972,8 @@ struct QMessagePattern {
QElapsedTimer timer;
#endif
#ifdef QLOGGING_HAVE_BACKTRACE
- int backtraceDepth;
QString backtraceSeparator;
+ int backtraceDepth;
#endif
bool fromEnvironment;
@@ -986,8 +986,8 @@ QMessagePattern::QMessagePattern()
: literals(0)
, tokens(0)
#ifdef QLOGGING_HAVE_BACKTRACE
- , backtraceDepth(5)
, backtraceSeparator(QLatin1Char('|'))
+ , backtraceDepth(5)
#endif
, fromEnvironment(false)
{
@@ -1737,7 +1737,7 @@ void qErrnoWarning(int code, const char *msg, ...)
Example:
\code
- QT_MESSAGE_PATTERN="[%{time yyyyMMdd h:mm:ss.zzz t} %{if-debug}D{%endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}"
+ QT_MESSAGE_PATTERN="[%{time yyyyMMdd h:mm:ss.zzz t} %{if-debug}D%{endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}"
\endcode
The default \a pattern is "%{if-category}%{category}: %{endif}%{message}".
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 123e2edf0e..cd0fc4da91 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -294,10 +294,13 @@ public:
WindowCloseButtonHint = 0x08000000,
MacWindowToolBarButtonHint = 0x10000000,
BypassGraphicsProxyWidget = 0x20000000,
- WindowOkButtonHint = 0x00080000,
- WindowCancelButtonHint = 0x00100000,
NoDropShadowWindowHint = 0x40000000,
- WindowFullscreenButtonHint = 0x80000000
+ WindowFullscreenButtonHint = 0x80000000,
+
+ // The following enums have overlapping values with other enums.
+ // This was not intentional, but it's too late to change now.
+ WindowOkButtonHint = 0x00080000, // WindowTransparentForInput
+ WindowCancelButtonHint = 0x00100000 // WindowOverridesSystemGestures
};
Q_DECLARE_FLAGS(WindowFlags, WindowType)
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index d4d7b631ad..2af04ab8d9 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2955,15 +2955,19 @@
\enum Qt::NativeGestureType
\since 5.2
- \value BeginNativeGesture
- \value EndNativeGesture
- \value PanNativeGesture
- \value ZoomNativeGesture
- \value SmartZoomNativeGesture
- \value RotateNativeGesture
- \value SwipeNativeGesture
+ This enum returns the gesture type.
+
+ \value BeginNativeGesture Sent before gesture event stream.
+ \value EndNativeGesture Sent after gesture event stream.
+ \value PanNativeGesture Sent after a panning gesture.
+ Similar to a click-and-drag mouse movement.
+ \value ZoomNativeGesture Specifies the magnification delta in percent.
+ \value SmartZoomNativeGesture Boolean magnification state.
+ \value RotateNativeGesture Rotation delta in degrees.
+ \value SwipeNativeGesture Sent after a swipe movements.
*/
+
/*!
\enum Qt::NavigationMode
\since 4.6
diff --git a/src/corelib/global/qtypetraits.h b/src/corelib/global/qtypetraits.h
index 3a305713e6..488e257e0f 100644
--- a/src/corelib/global/qtypetraits.h
+++ b/src/corelib/global/qtypetraits.h
@@ -506,6 +506,27 @@ Q_STATIC_ASSERT((!is_unsigned<qint64>::value));
Q_STATIC_ASSERT((!is_signed<quint64>::value));
Q_STATIC_ASSERT(( is_signed<qint64>::value));
+template<class T = void> struct is_default_constructible;
+
+template<> struct is_default_constructible<void>
+{
+protected:
+ template<bool> struct test { typedef char type; };
+public:
+ static bool const value = false;
+};
+template<> struct is_default_constructible<>::test<true> { typedef double type; };
+
+template<class T> struct is_default_constructible : is_default_constructible<>
+{
+private:
+ template<class U> static typename test<!!sizeof(::new U())>::type sfinae(U*);
+ template<class U> static char sfinae(...);
+public:
+ static bool const value = sizeof(sfinae<T>(0)) > 1;
+};
+
+
} // namespace QtPrivate
QT_END_NAMESPACE
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index 4c189bfe57..207de2a85b 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -187,7 +187,7 @@ win32 {
}
!nacl {
- freebsd-*|mac|darwin-*|openbsd-*:{
+ freebsd-*|mac|darwin-*|openbsd-*|netbsd-*:{
SOURCES += io/qfilesystemwatcher_kqueue.cpp
HEADERS += io/qfilesystemwatcher_kqueue_p.h
}
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index 4ca07ba41d..cddd70f908 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -225,9 +225,13 @@ QString QFileSelector::select(const QString &filePath) const
return d->select(filePath);
}
-static QString qrcScheme()
+static bool isLocalScheme(const QString &file)
{
- return QStringLiteral("qrc");
+ bool local = file == QStringLiteral("qrc");
+#ifdef Q_OS_ANDROID
+ local |= file == QStringLiteral("assets");
+#endif
+ return local;
}
/*!
@@ -240,10 +244,10 @@ static QString qrcScheme()
QUrl QFileSelector::select(const QUrl &filePath) const
{
Q_D(const QFileSelector);
- if (filePath.scheme() != qrcScheme() && !filePath.isLocalFile())
+ if (!isLocalScheme(filePath.scheme()) && !filePath.isLocalFile())
return filePath;
QUrl ret(filePath);
- if (filePath.scheme() == qrcScheme()) {
+ if (isLocalScheme(filePath.scheme())) {
QString equivalentPath = QLatin1Char(':') + filePath.path();
QString selectedPath = d->select(equivalentPath);
ret.setPath(selectedPath.remove(0, 1));
diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp
index faaf7a00af..79f16a0839 100644
--- a/src/corelib/io/qfilesystementry.cpp
+++ b/src/corelib/io/qfilesystementry.cpp
@@ -255,15 +255,15 @@ QString QFileSystemEntry::completeSuffix() const
bool QFileSystemEntry::isRelative() const
{
resolveFilePath();
- return (m_filePath.isEmpty() || (!m_filePath.isEmpty() && (m_filePath[0].unicode() != '/')
- && (!(m_filePath.length() >= 2 && m_filePath[1].unicode() == ':'))));
+ return (m_filePath.isEmpty() || (!m_filePath.isEmpty() && (m_filePath.at(0).unicode() != '/')
+ && (!(m_filePath.length() >= 2 && m_filePath.at(1).unicode() == ':'))));
}
bool QFileSystemEntry::isAbsolute() const
{
resolveFilePath();
return (!m_filePath.isEmpty() && ((m_filePath.length() >= 3
- && (m_filePath[0].isLetter() && m_filePath[1].unicode() == ':' && m_filePath[2].unicode() == '/'))
+ && (m_filePath.at(0).isLetter() && m_filePath.at(1).unicode() == ':' && m_filePath.at(2).unicode() == '/'))
|| (m_filePath.length() >= 2 && (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/')))
));
}
@@ -276,7 +276,7 @@ bool QFileSystemEntry::isRelative() const
bool QFileSystemEntry::isAbsolute() const
{
resolveFilePath();
- return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/'));
+ return (!m_filePath.isEmpty() && (m_filePath.at(0).unicode() == '/'));
}
#endif
@@ -337,10 +337,10 @@ void QFileSystemEntry::findFileNameSeparators() const
int i = m_filePath.size() - 1;
for (; i >= stop; --i) {
- if (m_filePath[i].unicode() == '.') {
+ if (m_filePath.at(i).unicode() == '.') {
firstDotInFileName = lastDotInFileName = i;
break;
- } else if (m_filePath[i].unicode() == '/') {
+ } else if (m_filePath.at(i).unicode() == '/') {
lastSeparator = i;
break;
}
@@ -348,9 +348,9 @@ void QFileSystemEntry::findFileNameSeparators() const
if (lastSeparator != i) {
for (--i; i >= stop; --i) {
- if (m_filePath[i].unicode() == '.')
+ if (m_filePath.at(i).unicode() == '.')
firstDotInFileName = i;
- else if (m_filePath[i].unicode() == '/') {
+ else if (m_filePath.at(i).unicode() == '/') {
lastSeparator = i;
break;
}
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index 0bd46400d3..3a8f7bd0a9 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -52,7 +52,7 @@
# include "qfilesystemwatcher_win_p.h"
#elif defined(USE_INOTIFY)
# include "qfilesystemwatcher_inotify_p.h"
-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_IOS)
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_IOS)
# include "qfilesystemwatcher_kqueue_p.h"
#elif defined(Q_OS_OSX)
# include "qfilesystemwatcher_fsevents_p.h"
@@ -68,7 +68,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject
// there is a chance that inotify may fail on Linux pre-2.6.13 (August
// 2005), so we can't just new inotify directly.
return QInotifyFileSystemWatcherEngine::create(parent);
-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_IOS)
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_IOS)
return QKqueueFileSystemWatcherEngine::create(parent);
#elif defined(Q_OS_OSX)
return QFseventsFileSystemWatcherEngine::create(parent);
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index d68f33287d..07a2ff8f6b 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -38,9 +38,9 @@
#include "qiodevice_p.h"
#include "qfile.h"
#include "qstringlist.h"
+#include "qdir.h"
#include <algorithm>
-#include <limits.h>
#ifdef QIODEVICE_DEBUG
# include <ctype.h>
@@ -80,10 +80,29 @@ void debugBinaryString(const char *data, qint64 maxlen)
#define Q_VOID
+static void checkWarnMessage(const QIODevice *device, const char *function, const char *what)
+{
+ QDebug d = qWarning();
+ d.noquote();
+ d.nospace();
+ d << "QIODevice::" << function;
+#ifndef QT_NO_QOBJECT
+ d << " (" << device->metaObject()->className();
+ if (!device->objectName().isEmpty())
+ d << ", \"" << device->objectName() << '"';
+ if (const QFile *f = qobject_cast<const QFile *>(device))
+ d << ", \"" << QDir::toNativeSeparators(f->fileName()) << '"';
+ d << ')';
+#else
+ Q_UNUSED(device)
+#endif // !QT_NO_QOBJECT
+ d << ": " << what;
+}
+
#define CHECK_MAXLEN(function, returnType) \
do { \
if (maxSize < 0) { \
- qWarning("QIODevice::"#function": Called with maxSize < 0"); \
+ checkWarnMessage(this, #function, "Called with maxSize < 0"); \
return returnType; \
} \
} while (0)
@@ -92,10 +111,10 @@ void debugBinaryString(const char *data, qint64 maxlen)
do { \
if ((d->openMode & WriteOnly) == 0) { \
if (d->openMode == NotOpen) { \
- qWarning("QIODevice::"#function": device not open"); \
+ checkWarnMessage(this, #function, "device not open"); \
return returnType; \
} \
- qWarning("QIODevice::"#function": ReadOnly device"); \
+ checkWarnMessage(this, #function, "ReadOnly device"); \
return returnType; \
} \
} while (0)
@@ -104,10 +123,10 @@ void debugBinaryString(const char *data, qint64 maxlen)
do { \
if ((d->openMode & ReadOnly) == 0) { \
if (d->openMode == NotOpen) { \
- qWarning("QIODevice::"#function": device not open"); \
+ checkWarnMessage(this, #function, "device not open"); \
return returnType; \
} \
- qWarning("QIODevice::"#function": WriteOnly device"); \
+ checkWarnMessage(this, #function, "WriteOnly device"); \
return returnType; \
} \
} while (0)
@@ -462,7 +481,7 @@ void QIODevice::setTextModeEnabled(bool enabled)
{
Q_D(QIODevice);
if (!isOpen()) {
- qWarning("QIODevice::setTextModeEnabled: The device is not open");
+ checkWarnMessage(this, "setTextModeEnabled", "The device is not open");
return;
}
if (enabled)
@@ -621,11 +640,11 @@ bool QIODevice::seek(qint64 pos)
{
Q_D(QIODevice);
if (d->isSequential()) {
- qWarning("QIODevice::seek: Cannot call seek on a sequential device");
+ checkWarnMessage(this, "seek", "Cannot call seek on a sequential device");
return false;
}
if (d->openMode == NotOpen) {
- qWarning("QIODevice::seek: The device is not open");
+ checkWarnMessage(this, "seek", "The device is not open");
return false;
}
if (pos < 0) {
@@ -922,9 +941,9 @@ QByteArray QIODevice::read(qint64 maxSize)
Q_UNUSED(d);
#endif
- if (maxSize != qint64(int(maxSize))) {
- qWarning("QIODevice::read: maxSize argument exceeds QByteArray size limit");
- maxSize = INT_MAX;
+ if (quint64(maxSize) >= QByteArray::MaxSize) {
+ checkWarnMessage(this, "read", "maxSize argument exceeds QByteArray size limit");
+ maxSize = QByteArray::MaxSize - 1;
}
qint64 readBytes = 0;
@@ -976,7 +995,7 @@ QByteArray QIODevice::readAll()
// flush internal read buffer
if (!(d->openMode & Text) && !d->buffer.isEmpty()) {
- if (d->buffer.size() >= INT_MAX)
+ if (quint64(d->buffer.size()) >= QByteArray::MaxSize)
return QByteArray();
result = d->buffer.readAll();
readBytes = result.size();
@@ -1055,7 +1074,7 @@ qint64 QIODevice::readLine(char *data, qint64 maxSize)
{
Q_D(QIODevice);
if (maxSize < 2) {
- qWarning("QIODevice::readLine: Called with maxSize < 2");
+ checkWarnMessage(this, "readLine", "Called with maxSize < 2");
return qint64(-1);
}
@@ -1159,9 +1178,9 @@ QByteArray QIODevice::readLine(qint64 maxSize)
Q_UNUSED(d);
#endif
- if (maxSize > INT_MAX) {
+ if (quint64(maxSize) >= QByteArray::MaxSize) {
qWarning("QIODevice::read: maxSize argument exceeds QByteArray size limit");
- maxSize = INT_MAX;
+ maxSize = QByteArray::MaxSize - 1;
}
result.resize(int(maxSize));
@@ -1169,7 +1188,7 @@ QByteArray QIODevice::readLine(qint64 maxSize)
if (!result.size()) {
// If resize fails or maxSize == 0, read incrementally
if (maxSize == 0)
- maxSize = INT_MAX;
+ maxSize = QByteArray::MaxSize - 1;
// The first iteration needs to leave an extra byte for the terminating null
result.resize(1);
diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp
index 4f5aeff395..2bd996d213 100644
--- a/src/corelib/io/qlockfile.cpp
+++ b/src/corelib/io/qlockfile.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 David Faure <faure+bluesystems@kde.org>
+** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -66,9 +67,12 @@ QT_BEGIN_NAMESPACE
If the process holding the lock crashes, the lock file stays on disk and can prevent
any other process from accessing the shared resource, ever. For this reason, QLockFile
- tries to detect such a "stale" lock file, based on the process ID written into the file,
- and (in case that process ID got reused meanwhile), on the last modification time of
- the lock file (30s by default, for the use case of a short-lived operation).
+ tries to detect such a "stale" lock file, based on the process ID written into the file.
+ To cover the situation that the process ID got reused meanwhile, the current process name is
+ compared to the name of the process that corresponds to the process ID from the lock file.
+ If the process names differ, the lock file is considered stale.
+ Additionally, the last modification time of the lock file (30s by default, for the use case of a
+ short-lived operation) is taken into account.
If the lock file is found to be stale, it will be deleted.
For the use case of protecting a resource over a long time, you should therefore call
@@ -122,7 +126,7 @@ QLockFile::~QLockFile()
The value of \a staleLockTime is used by lock() and tryLock() in order
to determine when an existing lock file is considered stale, i.e. left over
by a crashed process. This is useful for the case where the PID got reused
- meanwhile, so the only way to detect a stale lock file is by the fact that
+ meanwhile, so one way to detect a stale lock file is by the fact that
it has been around for a long time.
\sa staleLockTime()
diff --git a/src/corelib/io/qlockfile_p.h b/src/corelib/io/qlockfile_p.h
index 0cfaa42849..168062f467 100644
--- a/src/corelib/io/qlockfile_p.h
+++ b/src/corelib/io/qlockfile_p.h
@@ -75,6 +75,7 @@ public:
// Returns \c true if the lock belongs to dead PID, or is old.
// The attempt to delete it will tell us if it was really stale or not, though.
bool isApparentlyStale() const;
+ static QString processNameByPid(qint64 pid);
#ifdef Q_OS_UNIX
static int checkFcntlWorksAfterFlock();
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index b817a24c74..d6ea2f1f2d 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 David Faure <faure+bluesystems@kde.org>
+** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -48,6 +49,15 @@
#include <signal.h> // kill
#include <unistd.h> // gethostname
+#if defined(Q_OS_OSX)
+# include <libproc.h>
+#elif defined(Q_OS_LINUX)
+# include <unistd.h>
+# include <cstdio>
+#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+# include <sys/user.h>
+#endif
+
QT_BEGIN_NAMESPACE
static QByteArray localHostName() // from QHostInfo::localHostName(), modified to return a QByteArray
@@ -185,16 +195,54 @@ bool QLockFilePrivate::isApparentlyStale() const
{
qint64 pid;
QString hostname, appname;
- if (!getLockInfo(&pid, &hostname, &appname))
- return false;
- if (hostname.isEmpty() || hostname == QString::fromLocal8Bit(localHostName())) {
- if (::kill(pid, 0) == -1 && errno == ESRCH)
- return true; // PID doesn't exist anymore
+ if (getLockInfo(&pid, &hostname, &appname)) {
+ if (hostname.isEmpty() || hostname == QString::fromLocal8Bit(localHostName())) {
+ if (::kill(pid, 0) == -1 && errno == ESRCH)
+ return true; // PID doesn't exist anymore
+ const QString processName = processNameByPid(pid);
+ if (!processName.isEmpty()) {
+ QFileInfo fi(appname);
+ if (fi.isSymLink())
+ fi.setFile(fi.symLinkTarget());
+ if (processName != fi.fileName())
+ return true; // PID got reused by a different application.
+ }
+ }
}
const qint64 age = QFileInfo(fileName).lastModified().msecsTo(QDateTime::currentDateTime());
return staleLockTime > 0 && age > staleLockTime;
}
+QString QLockFilePrivate::processNameByPid(qint64 pid)
+{
+#if defined(Q_OS_OSX)
+ char name[1024];
+ proc_name(pid, name, sizeof(name) / sizeof(char));
+ return QString::fromUtf8(name);
+#elif defined(Q_OS_LINUX)
+ if (!QFile::exists(QStringLiteral("/proc/version")))
+ return QString();
+ char exePath[64];
+ char buf[PATH_MAX];
+ memset(buf, 0, sizeof(buf));
+ sprintf(exePath, "/proc/%lld/exe", pid);
+ if (readlink(exePath, buf, sizeof(buf)) < 0) {
+ // The pid is gone. Return some invalid process name to fail the test.
+ return QStringLiteral("/ERROR/");
+ }
+ return QFileInfo(QString::fromUtf8(buf)).fileName();
+#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+ kinfo_proc *proc = kinfo_getproc(pid);
+ if (!proc)
+ return QString();
+ QString name = QString::fromUtf8(proc->ki_comm);
+ free(proc);
+ return name;
+#else
+ return QString();
+#endif
+}
+
void QLockFile::unlock()
{
Q_D(QLockFile);
diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp
index 9fe86e1ad8..5bd1ba04c9 100644
--- a/src/corelib/io/qlockfile_win.cpp
+++ b/src/corelib/io/qlockfile_win.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 David Faure <faure+bluesystems@kde.org>
+** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -126,27 +127,75 @@ bool QLockFilePrivate::isApparentlyStale() const
{
qint64 pid;
QString hostname, appname;
- if (!getLockInfo(&pid, &hostname, &appname))
- return false;
// On WinRT there seems to be no way of obtaining information about other
// processes due to sandboxing
#ifndef Q_OS_WINRT
- if (hostname == QString::fromLocal8Bit(localHostName())) {
- HANDLE procHandle = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
- if (!procHandle)
- return true;
- // We got a handle but check if process is still alive
- DWORD dwR = ::WaitForSingleObject(procHandle, 0);
- ::CloseHandle(procHandle);
- if (dwR == WAIT_TIMEOUT)
- return true;
+ if (getLockInfo(&pid, &hostname, &appname)) {
+ if (hostname.isEmpty() || hostname == QString::fromLocal8Bit(localHostName())) {
+ HANDLE procHandle = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
+ if (!procHandle)
+ return true;
+ // We got a handle but check if process is still alive
+ DWORD dwR = ::WaitForSingleObject(procHandle, 0);
+ ::CloseHandle(procHandle);
+ if (dwR == WAIT_TIMEOUT)
+ return true;
+ const QString processName = processNameByPid(pid);
+ if (!processName.isEmpty() && processName != appname)
+ return true; // PID got reused by a different application.
+ }
}
-#endif // !Q_OS_WINRT
+#else // !Q_OS_WINRT
+ Q_UNUSED(pid);
+ Q_UNUSED(hostname);
+ Q_UNUSED(appname);
+#endif // Q_OS_WINRT
const qint64 age = QFileInfo(fileName).lastModified().msecsTo(QDateTime::currentDateTime());
return staleLockTime > 0 && age > staleLockTime;
}
+QString QLockFilePrivate::processNameByPid(qint64 pid)
+{
+#if !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
+ typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+
+ HMODULE hPsapi = LoadLibraryA("psapi");
+ if (!hPsapi)
+ return QString();
+
+ GetModuleFileNameExFunc qGetModuleFileNameEx
+ = (GetModuleFileNameExFunc)GetProcAddress(hPsapi, "GetModuleFileNameExW");
+ if (!qGetModuleFileNameEx) {
+ FreeLibrary(hPsapi);
+ return QString();
+ }
+
+ HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, DWORD(pid));
+ if (!hProcess) {
+ FreeLibrary(hPsapi);
+ return QString();
+ }
+ wchar_t buf[MAX_PATH];
+ const DWORD length = qGetModuleFileNameEx(hProcess, NULL, buf, sizeof(buf) / sizeof(wchar_t));
+ CloseHandle(hProcess);
+ FreeLibrary(hPsapi);
+ if (!length)
+ return QString();
+ QString name = QString::fromWCharArray(buf, length);
+ int i = name.lastIndexOf(QLatin1Char('\\'));
+ if (i >= 0)
+ name.remove(0, i + 1);
+ i = name.lastIndexOf(QLatin1Char('.'));
+ if (i >= 0)
+ name.truncate(i);
+ return name;
+#else
+ Q_UNUSED(pid);
+ return QString();
+#endif
+}
+
void QLockFile::unlock()
{
Q_D(QLockFile);
diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp
index c17b42ef81..af1bb56fe9 100644
--- a/src/corelib/io/qnoncontiguousbytedevice.cpp
+++ b/src/corelib/io/qnoncontiguousbytedevice.cpp
@@ -216,6 +216,11 @@ qint64 QNonContiguousByteDeviceByteArrayImpl::size()
return byteArray->size();
}
+qint64 QNonContiguousByteDeviceByteArrayImpl::pos()
+{
+ return currentPosition;
+}
+
QNonContiguousByteDeviceRingBufferImpl::QNonContiguousByteDeviceRingBufferImpl(QSharedPointer<QRingBuffer> rb)
: QNonContiguousByteDevice(), currentPosition(0)
{
@@ -253,6 +258,11 @@ bool QNonContiguousByteDeviceRingBufferImpl::atEnd()
return currentPosition >= size();
}
+qint64 QNonContiguousByteDeviceRingBufferImpl::pos()
+{
+ return currentPosition;
+}
+
bool QNonContiguousByteDeviceRingBufferImpl::reset()
{
currentPosition = 0;
@@ -381,6 +391,14 @@ qint64 QNonContiguousByteDeviceIoDeviceImpl::size()
return device->size() - initialPosition;
}
+qint64 QNonContiguousByteDeviceIoDeviceImpl::pos()
+{
+ if (device->isSequential())
+ return -1;
+
+ return device->pos();
+}
+
QByteDeviceWrappingIoDevice::QByteDeviceWrappingIoDevice(QNonContiguousByteDevice *bd) : QIODevice((QObject*)0)
{
byteDevice = bd;
diff --git a/src/corelib/io/qnoncontiguousbytedevice_p.h b/src/corelib/io/qnoncontiguousbytedevice_p.h
index 8b5bf3080a..38089dedd7 100644
--- a/src/corelib/io/qnoncontiguousbytedevice_p.h
+++ b/src/corelib/io/qnoncontiguousbytedevice_p.h
@@ -61,6 +61,7 @@ public:
virtual const char* readPointer(qint64 maximumLength, qint64 &len) = 0;
virtual bool advanceReadPointer(qint64 amount) = 0;
virtual bool atEnd() = 0;
+ virtual qint64 pos() { return -1; }
virtual bool reset() = 0;
virtual qint64 size() = 0;
@@ -103,6 +104,7 @@ public:
bool atEnd() Q_DECL_OVERRIDE;
bool reset() Q_DECL_OVERRIDE;
qint64 size() Q_DECL_OVERRIDE;
+ qint64 pos() Q_DECL_OVERRIDE;
protected:
QByteArray* byteArray;
qint64 currentPosition;
@@ -118,6 +120,7 @@ public:
bool atEnd() Q_DECL_OVERRIDE;
bool reset() Q_DECL_OVERRIDE;
qint64 size() Q_DECL_OVERRIDE;
+ qint64 pos() Q_DECL_OVERRIDE;
protected:
QSharedPointer<QRingBuffer> ringBuffer;
qint64 currentPosition;
@@ -135,6 +138,7 @@ public:
bool atEnd() Q_DECL_OVERRIDE;
bool reset() Q_DECL_OVERRIDE;
qint64 size() Q_DECL_OVERRIDE;
+ qint64 pos() Q_DECL_OVERRIDE;
protected:
QIODevice* device;
QByteArray* currentReadBuffer;
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index cb6de29532..251b10ea89 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -104,6 +104,10 @@ using namespace ABI::Windows::Storage;
#define Q_XDG_PLATFORM
#endif
+#if !defined(QT_NO_STANDARDPATHS) && (defined(Q_XDG_PLATFORM) || defined(Q_OS_IOS))
+#define QSETTINGS_USE_QSTANDARDPATHS
+#endif
+
// ************************************************************************
// QConfFile
@@ -1044,7 +1048,7 @@ static void initDefaultPaths(QMutexLocker *locker)
windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator());
#else
-#if defined(QT_NO_STANDARDPATHS) || !defined(Q_XDG_PLATFORM)
+#ifndef QSETTINGS_USE_QSTANDARDPATHS
// 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;
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index beb5d29d54..04848a38e5 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -274,45 +274,67 @@ QT_BEGIN_NAMESPACE
\endtable
\table
- \header \li Path type \li Android
+ \header \li Path type \li Android \li iOS
\row \li DesktopLocation
\li "<APPROOT>/files"
+ \li "<APPROOT>/<APPDIR>" (not writable)
\row \li DocumentsLocation
\li "<USER>/Documents", "<USER>/<APPNAME>/Documents"
+ \li "<APPROOT>/Documents"
\row \li FontsLocation
\li "/system/fonts" (not writable)
+ \li "<APPROOT>/Documents/.fonts"
\row \li ApplicationsLocation
\li not supported (directory not readable)
+ \li not supported
\row \li MusicLocation
\li "<USER>/Music", "<USER>/<APPNAME>/Music"
+ \li "<APPROOT>/Documents/Music"
\row \li MoviesLocation
\li "<USER>/Movies", "<USER>/<APPNAME>/Movies"
+ \li "<APPROOT>/Documents/Movies"
\row \li PicturesLocation
\li "<USER>/Pictures", "<USER>/<APPNAME>/Pictures"
+ \li "<APPROOT>/Documents/Pictures", "assets-library://"
\row \li TempLocation
\li "<APPROOT>/cache"
+ \li "<APPROOT>/tmp"
\row \li HomeLocation
\li "<APPROOT>/files"
+ \li "<APPROOT>/<APPDIR>" (not writable)
\row \li DataLocation
\li "<APPROOT>/files", "<USER>/<APPNAME>/files"
+ \li "<APPROOT>/Library/Application Support"
\row \li CacheLocation
\li "<APPROOT>/cache", "<USER>/<APPNAME>/cache"
+ \li "<APPROOT>/Library/Caches"
\row \li GenericDataLocation
\li "<USER>"
+ \li "<APPROOT>/Documents"
\row \li RuntimeLocation
\li "<APPROOT>/cache"
+ \li not supported
\row \li ConfigLocation
\li "<APPROOT>/files/settings"
+ \li "<APPROOT>/Documents"
\row \li GenericConfigLocation
\li "<APPROOT>/files/settings" (there is no shared settings)
+ \li "<APPROOT>/Documents"
\row \li DownloadLocation
\li "<USER>/Downloads", "<USER>/<APPNAME>/Downloads"
+ \li "<APPROOT>/Documents/Download"
\row \li GenericCacheLocation
\li "<APPROOT>/cache" (there is no shared cache)
+ \li "<APPROOT>/Library/Caches"
\row \li AppDataLocation
\li "<APPROOT>/files", "<USER>/<APPNAME>/files"
+ \li "<APPROOT>/Library/Application Support"
\row \li AppConfigLocation
\li "<APPROOT>/files/settings"
+ \li "<APPROOT>/Documents"
+ \row \li AppLocalDataLocation
+ \li "<APPROOT>/files", "<USER>/<APPNAME>/files"
+ \li "<APPROOT>/Library/Application Support"
\endtable
In the table above, \c <APPNAME> is usually the organization name, the
@@ -327,6 +349,12 @@ QT_BEGIN_NAMESPACE
\note On Android, applications with open files on the external storage (<USER> locations),
will be killed if the external storage is unmounted.
+ \note On iOS, if you do pass \c {QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last()}
+ as argument to \l{QFileDialog::setDirectory()},
+ a native image picker dialog will be used for accessing the user's photo album.
+ The filename returned can be loaded using QFile and related APIs.
+ This feature was added in Qt 5.5.
+
\sa writableLocation(), standardLocations(), displayName(), locate(), locateAll()
*/
diff --git a/src/corelib/io/qstandardpaths_ios.mm b/src/corelib/io/qstandardpaths_ios.mm
index 27d28526c2..eb85e2fd23 100644
--- a/src/corelib/io/qstandardpaths_ios.mm
+++ b/src/corelib/io/qstandardpaths_ios.mm
@@ -55,30 +55,31 @@ QString QStandardPaths::writableLocation(StandardLocation type)
QString location;
switch (type) {
- case DesktopLocation:
- location = pathForDirectory(NSDesktopDirectory);
- break;
case DocumentsLocation:
location = pathForDirectory(NSDocumentDirectory);
break;
case FontsLocation:
- location = bundlePath() + QLatin1String("/.fonts");
+ location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/.fonts");
break;
case ApplicationsLocation:
- location = pathForDirectory(NSApplicationDirectory);
+ // NSApplicationDirectory points to a non-existing write-protected path.
break;
case MusicLocation:
- location = pathForDirectory(NSMusicDirectory);
+ // NSMusicDirectory points to a non-existing write-protected path. Use sensible fallback.
+ location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Music");
break;
case MoviesLocation:
- location = pathForDirectory(NSMoviesDirectory);
+ // NSMoviesDirectory points to a non-existing write-protected path. Use sensible fallback.
+ location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Movies");
break;
case PicturesLocation:
- location = pathForDirectory(NSPicturesDirectory);
+ // NSPicturesDirectory points to a non-existing write-protected path. Use sensible fallback.
+ location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Pictures");
break;
case TempLocation:
location = QString::fromNSString(NSTemporaryDirectory());
break;
+ case DesktopLocation:
case HomeLocation:
location = bundlePath();
break;
@@ -99,20 +100,12 @@ QString QStandardPaths::writableLocation(StandardLocation type)
location = pathForDirectory(NSDocumentDirectory);
break;
case DownloadLocation:
- location = pathForDirectory(NSDownloadsDirectory);
- break;
- default:
+ // NSDownloadsDirectory points to a non-existing write-protected path.
+ location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Download");
break;
- }
-
- switch (type) {
case RuntimeLocation:
break;
default:
- // All other types must return something, so use the document directory
- // as a reasonable fall-back (which will always exist).
- if (location.isEmpty())
- location = pathForDirectory(NSDocumentDirectory);
break;
}
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 7823787711..f82d0ff0a1 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -67,8 +67,20 @@
#endif
#if defined(Q_OS_BSD4)
-# define QT_STATFSBUF struct statvfs
-# define QT_STATFS ::statvfs
+# if defined(Q_OS_NETBSD)
+ define QT_STATFSBUF struct statvfs
+ define QT_STATFS ::statvfs
+# else
+# define QT_STATFSBUF struct statfs
+# define QT_STATFS ::statfs
+# endif
+
+# if !defined(ST_RDONLY)
+# define ST_RDONLY MNT_RDONLY
+# endif
+# if !defined(_STATFS_F_FLAGS)
+# define _STATFS_F_FLAGS 1
+# endif
#elif defined(Q_OS_ANDROID)
# define QT_STATFS ::statfs
# define QT_STATFSBUF struct statfs
@@ -122,11 +134,7 @@ public:
inline QByteArray device() const;
private:
#if defined(Q_OS_BSD4)
-# if defined(Q_OS_NETBSD)
- struct statvfs *stat_buf;
-# else
- struct statfs *stat_buf;
-# endif
+ QT_STATFSBUF *stat_buf;
int entryCount;
int currentIndex;
#elif defined(Q_OS_SOLARIS)
@@ -502,7 +510,7 @@ void QStorageInfoPrivate::retrieveVolumeInfo()
bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize;
bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize;
bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize;
-#if defined(Q_OS_ANDROID)
+#if defined(Q_OS_ANDROID) || defined (Q_OS_BSD4)
#if defined(_STATFS_F_FLAGS)
readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0;
#endif
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 5fe4cfef9d..47b96d708f 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -464,7 +464,7 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
}
#if defined (QTEXTSTREAM_DEBUG)
qDebug("QTextStreamPrivate::fillReadBuffer(), using %s codec",
- codec->name().constData());
+ codec ? codec->name().constData() : "no");
#endif
#endif
@@ -476,9 +476,10 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
int oldReadBufferSize = readBuffer.size();
#ifndef QT_NO_TEXTCODEC
// convert to unicode
- readBuffer += codec->toUnicode(buf, bytesRead, &readConverterState);
+ readBuffer += Q_LIKELY(codec) ? codec->toUnicode(buf, bytesRead, &readConverterState)
+ : QString::fromLatin1(buf, bytesRead);
#else
- readBuffer += QString::fromLatin1(QByteArray(buf, bytesRead).constData());
+ readBuffer += QString::fromLatin1(buf, bytesRead);
#endif
// reset the Text flag.
@@ -564,7 +565,8 @@ void QTextStreamPrivate::flushWriteBuffer()
codec = QTextCodec::codecForLocale();
#if defined (QTEXTSTREAM_DEBUG)
qDebug("QTextStreamPrivate::flushWriteBuffer(), using %s codec (%s generating BOM)",
- codec->name().constData(), writeConverterState.flags & QTextCodec::IgnoreHeader ? "not" : "");
+ codec ? codec->name().constData() : "no",
+ !codec || (writeConverterState.flags & QTextCodec::IgnoreHeader) ? "not" : "");
#endif
// convert from unicode to raw data
@@ -572,7 +574,7 @@ void QTextStreamPrivate::flushWriteBuffer()
QByteArray data = Q_LIKELY(codec) ? codec->fromUnicode(writeBuffer.data(), writeBuffer.size(), &writeConverterState)
: writeBuffer.toLatin1();
#else
- QByteArray data = writeBuffer.toLocal8Bit();
+ QByteArray data = writeBuffer.toLatin1();
#endif
writeBuffer.clear();
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index 945b7df930..e6c570d1db 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -186,7 +186,7 @@ public:
QString url(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toDisplayString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
- QUrl adjusted(FormattingOptions options) const;
+ QUrl adjusted(FormattingOptions options) const Q_REQUIRED_RESULT;
QByteArray toEncoded(FormattingOptions options = FullyEncoded) const;
static QUrl fromEncoded(const QByteArray &url, ParsingMode mode = TolerantMode);
@@ -243,7 +243,7 @@ public:
QString fragment(ComponentFormattingOptions options = PrettyDecoded) const;
void setFragment(const QString &fragment, ParsingMode mode = TolerantMode);
- QUrl resolved(const QUrl &relative) const;
+ QUrl resolved(const QUrl &relative) const Q_REQUIRED_RESULT;
bool isRelative() const;
bool isParentOf(const QUrl &url) const;
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index 1502e5dada..2cc5741250 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -36,7 +36,6 @@
#include <qdebug.h>
#include <qelapsedtimer.h>
#include <qeventloop.h>
-#include <qtimer.h>
QT_BEGIN_NAMESPACE
@@ -45,13 +44,11 @@ QWindowsPipeReader::QWindowsPipeReader(QObject *parent)
handle(INVALID_HANDLE_VALUE),
readBufferMaxSize(0),
actualReadBufferSize(0),
- emitReadyReadTimer(new QTimer(this)),
+ stopped(true),
readSequenceStarted(false),
pipeBroken(false),
readyReadEmitted(false)
{
- emitReadyReadTimer->setSingleShot(true);
- connect(emitReadyReadTimer, SIGNAL(timeout()), SIGNAL(readyRead()));
dataReadNotifier = new QWinOverlappedIoNotifier(this);
connect(dataReadNotifier, &QWinOverlappedIoNotifier::notified, this, &QWindowsPipeReader::notified);
}
@@ -73,12 +70,7 @@ static bool qt_cancelIo(HANDLE handle, OVERLAPPED *overlapped)
QWindowsPipeReader::~QWindowsPipeReader()
{
- if (readSequenceStarted) {
- if (qt_cancelIo(handle, &overlapped))
- dataReadNotifier->waitForNotified(-1, &overlapped);
- else
- qErrnoWarning("QWindowsPipeReader: qt_cancelIo on handle %x failed.", handle);
- }
+ stop();
}
/*!
@@ -89,9 +81,9 @@ void QWindowsPipeReader::setHandle(HANDLE hPipeReadEnd)
readBuffer.clear();
actualReadBufferSize = 0;
handle = hPipeReadEnd;
- ZeroMemory(&overlapped, sizeof(overlapped));
pipeBroken = false;
readyReadEmitted = false;
+ stopped = false;
if (hPipeReadEnd != INVALID_HANDLE_VALUE) {
dataReadNotifier->setHandle(hPipeReadEnd);
dataReadNotifier->setEnabled(true);
@@ -100,13 +92,24 @@ void QWindowsPipeReader::setHandle(HANDLE hPipeReadEnd)
/*!
Stops the asynchronous read sequence.
- This function assumes that the file already has been closed.
- It does not cancel any I/O operation.
+ If the read sequence is running then the I/O operation is canceled.
*/
void QWindowsPipeReader::stop()
{
- dataReadNotifier->setEnabled(false);
+ stopped = true;
+ if (readSequenceStarted) {
+ if (qt_cancelIo(handle, &overlapped)) {
+ dataReadNotifier->waitForNotified(-1, &overlapped);
+ } else {
+ const DWORD dwError = GetLastError();
+ if (dwError != ERROR_NOT_FOUND) {
+ qErrnoWarning(dwError, "QWindowsPipeReader: qt_cancelIo on handle %x failed.",
+ handle);
+ }
+ }
+ }
readSequenceStarted = false;
+ dataReadNotifier->setEnabled(false);
handle = INVALID_HANDLE_VALUE;
}
@@ -119,7 +122,7 @@ qint64 QWindowsPipeReader::bytesAvailable() const
}
/*!
- Stops the asynchronous read sequence.
+ Copies at most \c{maxlen} bytes from the internal read buffer to \c{data}.
*/
qint64 QWindowsPipeReader::read(char *data, qint64 maxlen)
{
@@ -147,9 +150,7 @@ qint64 QWindowsPipeReader::read(char *data, qint64 maxlen)
}
if (!pipeBroken) {
- if (!actualReadBufferSize)
- emitReadyReadTimer->stop();
- if (!readSequenceStarted)
+ if (!readSequenceStarted && !stopped)
startAsyncRead();
if (readSoFar == 0)
return -2; // signal EWOULDBLOCK
@@ -172,13 +173,41 @@ void QWindowsPipeReader::notified(quint32 numberOfBytesRead, quint32 errorCode,
{
if (&overlapped != notifiedOverlapped)
return;
- if (!completeAsyncRead(numberOfBytesRead, errorCode)) {
+
+ switch (errorCode) {
+ case ERROR_SUCCESS:
+ break;
+ case ERROR_MORE_DATA:
+ // This is not an error. We're connected to a message mode
+ // pipe and the message didn't fit into the pipe's system
+ // buffer. We will read the remaining data in the next call.
+ break;
+ case ERROR_BROKEN_PIPE:
+ case ERROR_PIPE_NOT_CONNECTED:
pipeBroken = true;
+ break;
+ default:
+ emit winError(errorCode, QLatin1String("QWindowsPipeReader::completeAsyncRead"));
+ pipeBroken = true;
+ break;
+ }
+
+ readSequenceStarted = false;
+
+ // After the reader was stopped, the only reason why this function can be called is the
+ // completion of a cancellation. No signals should be emitted, and no new read sequence should
+ // be started in this case.
+ if (stopped)
+ return;
+
+ if (pipeBroken) {
emit pipeClosed();
return;
}
+
+ actualReadBufferSize += numberOfBytesRead;
+ readBuffer.truncate(actualReadBufferSize);
startAsyncRead();
- emitReadyReadTimer->stop();
readyReadEmitted = true;
emit readyRead();
}
@@ -206,6 +235,7 @@ void QWindowsPipeReader::startAsyncRead()
char *ptr = readBuffer.reserve(bytesToRead);
readSequenceStarted = true;
+ ZeroMemory(&overlapped, sizeof(overlapped));
if (ReadFile(handle, ptr, bytesToRead, NULL, &overlapped)) {
// We get notified by the QWinOverlappedIoNotifier - even in the synchronous case.
return;
@@ -241,38 +271,6 @@ void QWindowsPipeReader::startAsyncRead()
/*!
\internal
- Sets the correct size of the read buffer after a read operation.
- Returns \c false, if an error occurred or the connection dropped.
- */
-bool QWindowsPipeReader::completeAsyncRead(DWORD bytesRead, DWORD errorCode)
-{
- readSequenceStarted = false;
-
- switch (errorCode) {
- case ERROR_SUCCESS:
- break;
- case ERROR_MORE_DATA:
- // This is not an error. We're connected to a message mode
- // pipe and the message didn't fit into the pipe's system
- // buffer. We will read the remaining data in the next call.
- break;
- case ERROR_BROKEN_PIPE:
- case ERROR_PIPE_NOT_CONNECTED:
- return false;
- default:
- emit winError(errorCode, QLatin1String("QWindowsPipeReader::completeAsyncRead"));
- return false;
- }
-
- actualReadBufferSize += bytesRead;
- readBuffer.truncate(actualReadBufferSize);
- if (!emitReadyReadTimer->isActive())
- emitReadyReadTimer->start();
- return true;
-}
-
-/*!
- \internal
Returns the number of available bytes in the pipe.
Sets QWindowsPipeReader::pipeBroken to true if the connection is broken.
*/
diff --git a/src/corelib/io/qwindowspipereader_p.h b/src/corelib/io/qwindowspipereader_p.h
index 53872e2552..c8a66d9511 100644
--- a/src/corelib/io/qwindowspipereader_p.h
+++ b/src/corelib/io/qwindowspipereader_p.h
@@ -47,7 +47,6 @@
#include <qbytearray.h>
#include <qobject.h>
-#include <qtimer.h>
#include <private/qringbuffer_p.h>
#include <qt_windows.h>
@@ -89,7 +88,6 @@ private Q_SLOTS:
void notified(quint32 numberOfBytesRead, quint32 errorCode, OVERLAPPED *notifiedOverlapped);
private:
- bool completeAsyncRead(DWORD bytesRead, DWORD errorCode);
DWORD checkPipeState();
private:
@@ -99,7 +97,7 @@ private:
qint64 readBufferMaxSize;
QRingBuffer readBuffer;
qint64 actualReadBufferSize;
- QTimer *emitReadyReadTimer;
+ bool stopped;
bool readSequenceStarted;
bool pipeBroken;
bool readyReadEmitted;
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 05d58ac028..524bfd26cc 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -325,6 +325,7 @@ struct QCoreApplicationData {
#ifndef QT_NO_LIBRARY
app_libpaths = 0;
#endif
+ applicationNameSet = false;
}
~QCoreApplicationData() {
#ifndef QT_NO_LIBRARY
@@ -369,8 +370,8 @@ struct QCoreApplicationData {
QString orgName, orgDomain;
QString application; // application name, initially from argv[0], can then be modified.
- QString applicationNameCompat; // for QDesktopServices. Only set explicitly.
QString applicationVersion;
+ bool applicationNameSet; // true if setApplicationName was called
#ifndef QT_NO_LIBRARY
QStringList *app_libpaths;
@@ -752,7 +753,8 @@ void QCoreApplication::init()
QCoreApplication::self = this;
// Store app name (so it's still available after QCoreApplication is destroyed)
- coreappdata()->application = d_func()->appName();
+ if (!coreappdata()->applicationNameSet)
+ coreappdata()->application = d_func()->appName();
QLoggingRegistry::instance()->init();
@@ -2349,13 +2351,13 @@ QString QCoreApplication::organizationDomain()
*/
void QCoreApplication::setApplicationName(const QString &application)
{
+ coreappdata()->applicationNameSet = !application.isEmpty();
QString newAppName = application;
if (newAppName.isEmpty() && QCoreApplication::self)
newAppName = QCoreApplication::self->d_func()->appName();
if (coreappdata()->application == newAppName)
return;
coreappdata()->application = newAppName;
- coreappdata()->applicationNameCompat = newAppName;
#ifndef QT_NO_QOBJECT
if (QCoreApplication::self)
emit QCoreApplication::self->applicationNameChanged();
@@ -2373,7 +2375,7 @@ QString QCoreApplication::applicationName()
// Exported for QDesktopServices (Qt4 behavior compatibility)
Q_CORE_EXPORT QString qt_applicationName_noFallback()
{
- return coreappdata()->applicationNameCompat;
+ return coreappdata()->applicationNameSet ? coreappdata()->application : QString();
}
/*!
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp
index cc8e961be1..1509996199 100644
--- a/src/corelib/kernel/qeventdispatcher_winrt.cpp
+++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp
@@ -203,9 +203,9 @@ bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags)
}
}
- // Dispatch accumulated user events
- if (sendPostedEvents(flags))
- return true;
+ // Additional user events have to be handled before timer events, but the function may not
+ // return yet.
+ const bool userEventsSent = sendPostedEvents(flags);
emit aboutToBlock();
const QVector<HANDLE> timerHandles = d->timerIdToHandle.values().toVector();
@@ -228,6 +228,9 @@ bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags)
return true;
}
emit awake();
+
+ if (userEventsSent)
+ return true;
} while (flags & QEventLoop::WaitForMoreEvents);
return false;
}
@@ -484,7 +487,8 @@ bool QEventDispatcherWinRT::event(QEvent *e)
QEventDispatcherWinRTPrivate::QEventDispatcherWinRTPrivate()
{
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
- HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Threading_ThreadPoolTimer).Get(), &timerFactory);
+ HRESULT hr;
+ hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Threading_ThreadPoolTimer).Get(), &timerFactory);
Q_ASSERT_SUCCEEDED(hr);
HANDLE interruptHandle = CreateEventEx(NULL, NULL, NULL, SYNCHRONIZE|EVENT_MODIFY_STATE);
timerIdToHandle.insert(INTERRUPT_HANDLE, interruptHandle);
diff --git a/src/corelib/kernel/qfunctions_winrt.h b/src/corelib/kernel/qfunctions_winrt.h
index 3fff52a22c..7efd042456 100644
--- a/src/corelib/kernel/qfunctions_winrt.h
+++ b/src/corelib/kernel/qfunctions_winrt.h
@@ -131,9 +131,13 @@ generate_inline_return_func2(_putenv_s, errno_t, const char *, const char *)
generate_inline_return_func0(tzset, void)
generate_inline_return_func0(_tzset, void)
-QT_BEGIN_NAMESPACE
+namespace Microsoft {
+ namespace WRL {
+ template <typename T> class ComPtr;
+ }
+}
-namespace Microsoft { namespace WRL { template <typename T> class ComPtr; } }
+QT_BEGIN_NAMESPACE
namespace QWinRTFunctions {
diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp
index 097f641d19..108a01aab7 100644
--- a/src/corelib/kernel/qjni.cpp
+++ b/src/corelib/kernel/qjni.cpp
@@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE
static inline QString keyBase()
{
- return QStringLiteral("%1%2%3");
+ return QStringLiteral("%1%2:%3");
}
static QString qt_convertJString(jstring string)
@@ -72,15 +72,15 @@ typedef QHash<QString, jclass> JClassHash;
Q_GLOBAL_STATIC(JClassHash, cachedClasses)
Q_GLOBAL_STATIC(QReadWriteLock, cachedClassesLock)
-static QString toDotEncodedClassName(const char *className)
+static QByteArray toBinaryEncClassName(const QByteArray &className)
{
- return QString::fromLatin1(className).replace(QLatin1Char('/'), QLatin1Char('.'));
+ return QByteArray(className).replace('/', '.');
}
-static jclass getCachedClass(const QString &classDotEnc, bool *isCached = 0)
+static jclass getCachedClass(const QByteArray &classBinEnc, bool *isCached = 0)
{
QReadLocker locker(cachedClassesLock);
- const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(classDotEnc);
+ const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(QString::fromLatin1(classBinEnc));
const bool found = (it != cachedClasses->constEnd());
if (isCached != 0)
@@ -89,10 +89,12 @@ static jclass getCachedClass(const QString &classDotEnc, bool *isCached = 0)
return found ? it.value() : 0;
}
-static jclass loadClassDotEnc(const QString &classDotEnc, JNIEnv *env)
+inline static jclass loadClass(const QByteArray &className, JNIEnv *env, bool binEncoded = false)
{
+ const QByteArray &binEncClassName = binEncoded ? className : toBinaryEncClassName(className);
+
bool isCached = false;
- jclass clazz = getCachedClass(classDotEnc, &isCached);
+ jclass clazz = getCachedClass(binEncClassName, &isCached);
if (clazz != 0 || isCached)
return clazz;
@@ -102,11 +104,12 @@ static jclass loadClassDotEnc(const QString &classDotEnc, JNIEnv *env)
QWriteLocker locker(cachedClassesLock);
// did we lose the race?
- const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(classDotEnc);
+ const QLatin1String key(binEncClassName);
+ const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(key);
if (it != cachedClasses->constEnd())
return it.value();
- QJNIObjectPrivate stringName = QJNIObjectPrivate::fromString(classDotEnc);
+ QJNIObjectPrivate stringName = QJNIObjectPrivate::fromString(key);
QJNIObjectPrivate classObject = classLoader.callObjectMethod("loadClass",
"(Ljava/lang/String;)Ljava/lang/Class;",
stringName.object());
@@ -114,27 +117,40 @@ static jclass loadClassDotEnc(const QString &classDotEnc, JNIEnv *env)
if (!exceptionCheckAndClear(env) && classObject.isValid())
clazz = static_cast<jclass>(env->NewGlobalRef(classObject.object()));
- cachedClasses->insert(classDotEnc, clazz);
+ cachedClasses->insert(key, clazz);
return clazz;
}
-inline static jclass loadClass(const char *className, JNIEnv *env)
-{
- return loadClassDotEnc(toDotEncodedClassName(className), env);
-}
-
typedef QHash<QString, jmethodID> JMethodIDHash;
Q_GLOBAL_STATIC(JMethodIDHash, cachedMethodID)
Q_GLOBAL_STATIC(QReadWriteLock, cachedMethodIDLock)
+static inline jmethodID getMethodID(JNIEnv *env,
+ jclass clazz,
+ const char *name,
+ const char *sig,
+ bool isStatic = false)
+{
+ jmethodID id = isStatic ? env->GetStaticMethodID(clazz, name, sig)
+ : env->GetMethodID(clazz, name, sig);
+
+ if (exceptionCheckAndClear(env))
+ return 0;
+
+ return id;
+}
+
static jmethodID getCachedMethodID(JNIEnv *env,
jclass clazz,
+ const QByteArray &className,
const char *name,
const char *sig,
bool isStatic = false)
{
- // TODO: We need to use something else then the ref. from clazz to avoid collisions.
- const QString key = keyBase().arg(size_t(clazz)).arg(QLatin1String(name)).arg(QLatin1String(sig));
+ if (className.isEmpty())
+ return getMethodID(env, clazz, name, sig, isStatic);
+
+ const QString key = keyBase().arg(QLatin1String(className)).arg(QLatin1String(name)).arg(QLatin1String(sig));
QHash<QString, jmethodID>::const_iterator it;
{
@@ -150,14 +166,7 @@ static jmethodID getCachedMethodID(JNIEnv *env,
if (it != cachedMethodID->constEnd())
return it.value();
- jmethodID id = 0;
- if (isStatic)
- id = env->GetStaticMethodID(clazz, name, sig);
- else
- id = env->GetMethodID(clazz, name, sig);
-
- if (exceptionCheckAndClear(env))
- id = 0;
+ jmethodID id = getMethodID(env, clazz, name, sig, isStatic);
cachedMethodID->insert(key, id);
return id;
@@ -168,13 +177,32 @@ typedef QHash<QString, jfieldID> JFieldIDHash;
Q_GLOBAL_STATIC(JFieldIDHash, cachedFieldID)
Q_GLOBAL_STATIC(QReadWriteLock, cachedFieldIDLock)
+static inline jfieldID getFieldID(JNIEnv *env,
+ jclass clazz,
+ const char *name,
+ const char *sig,
+ bool isStatic = false)
+{
+ jfieldID id = isStatic ? env->GetStaticFieldID(clazz, name, sig)
+ : env->GetFieldID(clazz, name, sig);
+
+ if (exceptionCheckAndClear(env))
+ return 0;
+
+ return id;
+}
+
static jfieldID getCachedFieldID(JNIEnv *env,
jclass clazz,
+ const QByteArray &className,
const char *name,
const char *sig,
bool isStatic = false)
{
- const QString key = keyBase().arg(size_t(clazz)).arg(QLatin1String(name)).arg(QLatin1String(sig));
+ if (className.isNull())
+ return getFieldID(env, clazz, name, sig, isStatic);
+
+ const QString key = keyBase().arg(QLatin1String(className)).arg(QLatin1String(name)).arg(QLatin1String(sig));
QHash<QString, jfieldID>::const_iterator it;
{
@@ -190,14 +218,7 @@ static jfieldID getCachedFieldID(JNIEnv *env,
if (it != cachedFieldID->constEnd())
return it.value();
- jfieldID id = 0;
- if (isStatic)
- id = env->GetStaticFieldID(clazz, name, sig);
- else
- id = env->GetFieldID(clazz, name, sig);
-
- if (exceptionCheckAndClear(env))
- id = 0;
+ jfieldID id = getFieldID(env, clazz, name, sig, isStatic);
cachedFieldID->insert(key, id);
return id;
@@ -251,7 +272,7 @@ JNIEnv *QJNIEnvironmentPrivate::operator->()
jclass QJNIEnvironmentPrivate::findClass(const char *className, JNIEnv *env)
{
- const QString &classDotEnc = toDotEncodedClassName(className);
+ const QByteArray &classDotEnc = toBinaryEncClassName(className);
bool isCached = false;
jclass clazz = getCachedClass(classDotEnc, &isCached);
@@ -260,9 +281,10 @@ jclass QJNIEnvironmentPrivate::findClass(const char *className, JNIEnv *env)
if (found)
return clazz;
+ const QLatin1String key(classDotEnc);
if (env != 0) { // We got an env. pointer (We expect this to be the right env. and call FindClass())
QWriteLocker locker(cachedClassesLock);
- const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(classDotEnc);
+ const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(key);
// Did we lose the race?
if (it != cachedClasses->constEnd())
return it.value();
@@ -274,11 +296,11 @@ jclass QJNIEnvironmentPrivate::findClass(const char *className, JNIEnv *env)
}
if (clazz != 0)
- cachedClasses->insert(classDotEnc, clazz);
+ cachedClasses->insert(key, clazz);
}
if (clazz == 0) // We didn't get an env. pointer or we got one with the WRONG class loader...
- clazz = loadClassDotEnc(classDotEnc, QJNIEnvironmentPrivate());
+ clazz = loadClass(classDotEnc, QJNIEnvironmentPrivate(), true);
return clazz;
}
@@ -319,11 +341,12 @@ QJNIObjectPrivate::QJNIObjectPrivate(const char *className)
: d(new QJNIObjectData())
{
QJNIEnvironmentPrivate env;
- d->m_jclass = loadClass(className, env);
+ d->m_className = toBinaryEncClassName(className);
+ d->m_jclass = loadClass(d->m_className, env, true);
d->m_own_jclass = false;
if (d->m_jclass) {
// get default constructor
- jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", "()V");
+ jmethodID constructorId = getCachedMethodID(env, d->m_jclass, d->m_className, "<init>", "()V");
if (constructorId) {
jobject obj = env->NewObject(d->m_jclass, constructorId);
if (obj) {
@@ -338,10 +361,11 @@ QJNIObjectPrivate::QJNIObjectPrivate(const char *className, const char *sig, ...
: d(new QJNIObjectData())
{
QJNIEnvironmentPrivate env;
- d->m_jclass = loadClass(className, env);
+ d->m_className = toBinaryEncClassName(className);
+ d->m_jclass = loadClass(d->m_className, env, true);
d->m_own_jclass = false;
if (d->m_jclass) {
- jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", sig);
+ jmethodID constructorId = getCachedMethodID(env, d->m_jclass, d->m_className, "<init>", sig);
if (constructorId) {
va_list args;
va_start(args, sig);
@@ -359,10 +383,11 @@ QJNIObjectPrivate::QJNIObjectPrivate(const char *className, const char *sig, con
: d(new QJNIObjectData())
{
QJNIEnvironmentPrivate env;
- d->m_jclass = loadClass(className, env);
+ d->m_className = toBinaryEncClassName(className);
+ d->m_jclass = loadClass(d->m_className, env, true);
d->m_own_jclass = false;
if (d->m_jclass) {
- jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", sig);
+ jmethodID constructorId = getCachedMethodID(env, d->m_jclass, d->m_className, "<init>", sig);
if (constructorId) {
jobject obj = env->NewObjectV(d->m_jclass, constructorId, args);
if (obj) {
@@ -380,7 +405,7 @@ QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz)
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
if (d->m_jclass) {
// get default constructor
- jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", "()V");
+ jmethodID constructorId = getMethodID(env, d->m_jclass, "<init>", "()V");
if (constructorId) {
jobject obj = env->NewObject(d->m_jclass, constructorId);
if (obj) {
@@ -398,7 +423,7 @@ QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz, const char *sig, ...)
if (clazz) {
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
if (d->m_jclass) {
- jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", sig);
+ jmethodID constructorId = getMethodID(env, d->m_jclass, "<init>", sig);
if (constructorId) {
va_list args;
va_start(args, sig);
@@ -420,7 +445,7 @@ QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz, const char *sig, const QVaLis
if (clazz) {
d->m_jclass = static_cast<jclass>(env->NewGlobalRef(clazz));
if (d->m_jclass) {
- jmethodID constructorId = getCachedMethodID(env, d->m_jclass, "<init>", sig);
+ jmethodID constructorId = getMethodID(env, d->m_jclass, "<init>", sig);
if (constructorId) {
jobject obj = env->NewObjectV(d->m_jclass, constructorId, args);
if (obj) {
@@ -440,15 +465,15 @@ QJNIObjectPrivate::QJNIObjectPrivate(jobject obj)
QJNIEnvironmentPrivate env;
d->m_jobject = env->NewGlobalRef(obj);
- jclass objectClass = env->GetObjectClass(d->m_jobject);
- d->m_jclass = static_cast<jclass>(env->NewGlobalRef(objectClass));
- env->DeleteLocalRef(objectClass);
+ jclass cls = env->GetObjectClass(obj);
+ d->m_jclass = static_cast<jclass>(env->NewGlobalRef(cls));
+ env->DeleteLocalRef(cls);
}
template <>
void QJNIObjectPrivate::callMethodV<void>(const char *methodName, const char *sig, va_list args) const
{
QJNIEnvironmentPrivate env;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
env->CallVoidMethodV(d->m_jobject, id, args);
}
@@ -468,7 +493,7 @@ jboolean QJNIObjectPrivate::callMethodV<jboolean>(const char *methodName, const
{
QJNIEnvironmentPrivate env;
jboolean res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallBooleanMethodV(d->m_jobject, id, args);
}
@@ -490,7 +515,7 @@ jbyte QJNIObjectPrivate::callMethodV<jbyte>(const char *methodName, const char *
{
QJNIEnvironmentPrivate env;
jbyte res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallByteMethodV(d->m_jobject, id, args);
}
@@ -512,7 +537,7 @@ jchar QJNIObjectPrivate::callMethodV<jchar>(const char *methodName, const char *
{
QJNIEnvironmentPrivate env;
jchar res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallCharMethodV(d->m_jobject, id, args);
}
@@ -534,7 +559,7 @@ jshort QJNIObjectPrivate::callMethodV<jshort>(const char *methodName, const char
{
QJNIEnvironmentPrivate env;
jshort res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallShortMethodV(d->m_jobject, id, args);
}
@@ -556,7 +581,7 @@ jint QJNIObjectPrivate::callMethodV<jint>(const char *methodName, const char *si
{
QJNIEnvironmentPrivate env;
jint res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallIntMethodV(d->m_jobject, id, args);
}
@@ -578,7 +603,7 @@ jlong QJNIObjectPrivate::callMethodV<jlong>(const char *methodName, const char *
{
QJNIEnvironmentPrivate env;
jlong res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallLongMethodV(d->m_jobject, id, args);
}
@@ -600,7 +625,7 @@ jfloat QJNIObjectPrivate::callMethodV<jfloat>(const char *methodName, const char
{
QJNIEnvironmentPrivate env;
jfloat res = 0.f;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallFloatMethodV(d->m_jobject, id, args);
}
@@ -622,7 +647,7 @@ jdouble QJNIObjectPrivate::callMethodV<jdouble>(const char *methodName, const ch
{
QJNIEnvironmentPrivate env;
jdouble res = 0.;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallDoubleMethodV(d->m_jobject, id, args);
}
@@ -702,7 +727,7 @@ void QJNIObjectPrivate::callStaticMethodV<void>(const char *className,
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
env->CallStaticVoidMethodV(clazz, id, args);
}
@@ -728,7 +753,7 @@ void QJNIObjectPrivate::callStaticMethodV<void>(jclass clazz,
va_list args)
{
QJNIEnvironmentPrivate env;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
env->CallStaticVoidMethodV(clazz, id, args);
}
@@ -756,7 +781,7 @@ jboolean QJNIObjectPrivate::callStaticMethodV<jboolean>(const char *className,
jboolean res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticBooleanMethodV(clazz, id, args);
}
@@ -786,7 +811,7 @@ jboolean QJNIObjectPrivate::callStaticMethodV<jboolean>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jboolean res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticBooleanMethodV(clazz, id, args);
}
@@ -817,7 +842,7 @@ jbyte QJNIObjectPrivate::callStaticMethodV<jbyte>(const char *className,
jbyte res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticByteMethodV(clazz, id, args);
}
@@ -847,7 +872,7 @@ jbyte QJNIObjectPrivate::callStaticMethodV<jbyte>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jbyte res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticByteMethodV(clazz, id, args);
}
@@ -878,7 +903,7 @@ jchar QJNIObjectPrivate::callStaticMethodV<jchar>(const char *className,
jchar res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticCharMethodV(clazz, id, args);
}
@@ -908,7 +933,7 @@ jchar QJNIObjectPrivate::callStaticMethodV<jchar>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jchar res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticCharMethodV(clazz, id, args);
}
@@ -939,7 +964,7 @@ jshort QJNIObjectPrivate::callStaticMethodV<jshort>(const char *className,
jshort res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticShortMethodV(clazz, id, args);
}
@@ -969,7 +994,7 @@ jshort QJNIObjectPrivate::callStaticMethodV<jshort>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jshort res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticShortMethodV(clazz, id, args);
}
@@ -1000,7 +1025,7 @@ jint QJNIObjectPrivate::callStaticMethodV<jint>(const char *className,
jint res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticIntMethodV(clazz, id, args);
}
@@ -1030,7 +1055,7 @@ jint QJNIObjectPrivate::callStaticMethodV<jint>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jint res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticIntMethodV(clazz, id, args);
}
@@ -1061,7 +1086,7 @@ jlong QJNIObjectPrivate::callStaticMethodV<jlong>(const char *className,
jlong res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticLongMethodV(clazz, id, args);
}
@@ -1091,7 +1116,7 @@ jlong QJNIObjectPrivate::callStaticMethodV<jlong>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jlong res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticLongMethodV(clazz, id, args);
}
@@ -1122,7 +1147,7 @@ jfloat QJNIObjectPrivate::callStaticMethodV<jfloat>(const char *className,
jfloat res = 0.f;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticFloatMethodV(clazz, id, args);
}
@@ -1152,7 +1177,7 @@ jfloat QJNIObjectPrivate::callStaticMethodV<jfloat>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jfloat res = 0.f;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticFloatMethodV(clazz, id, args);
}
@@ -1183,7 +1208,7 @@ jdouble QJNIObjectPrivate::callStaticMethodV<jdouble>(const char *className,
jdouble res = 0.;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticDoubleMethodV(clazz, id, args);
}
@@ -1213,7 +1238,7 @@ jdouble QJNIObjectPrivate::callStaticMethodV<jdouble>(jclass clazz,
{
QJNIEnvironmentPrivate env;
jdouble res = 0.;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticDoubleMethodV(clazz, id, args);
}
@@ -1348,7 +1373,7 @@ QJNIObjectPrivate QJNIObjectPrivate::callObjectMethodV(const char *methodName,
{
QJNIEnvironmentPrivate env;
jobject res = 0;
- jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
+ jmethodID id = getCachedMethodID(env, d->m_jclass, d->m_className, methodName, sig);
if (id) {
res = env->CallObjectMethodV(d->m_jobject, id, args);
if (res && env->ExceptionCheck())
@@ -1428,7 +1453,7 @@ QJNIObjectPrivate QJNIObjectPrivate::callStaticObjectMethodV(const char *classNa
jobject res = 0;
jclass clazz = loadClass(className, env);
if (clazz) {
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getCachedMethodID(env, clazz, toBinaryEncClassName(className), methodName, sig, true);
if (id) {
res = env->CallStaticObjectMethodV(clazz, id, args);
if (res && env->ExceptionCheck())
@@ -1460,7 +1485,7 @@ QJNIObjectPrivate QJNIObjectPrivate::callStaticObjectMethodV(jclass clazz,
{
QJNIEnvironmentPrivate env;
jobject res = 0;
- jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
+ jmethodID id = getMethodID(env, clazz, methodName, sig, true);
if (id) {
res = env->CallStaticObjectMethodV(clazz, id, args);
if (res && env->ExceptionCheck())
@@ -1489,7 +1514,7 @@ jboolean QJNIObjectPrivate::getField<jboolean>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jboolean res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "Z");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "Z");
if (id)
res = env->GetBooleanField(d->m_jobject, id);
@@ -1501,7 +1526,7 @@ jbyte QJNIObjectPrivate::getField<jbyte>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jbyte res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "B");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "B");
if (id)
res = env->GetByteField(d->m_jobject, id);
@@ -1513,7 +1538,7 @@ jchar QJNIObjectPrivate::getField<jchar>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jchar res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "C");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "C");
if (id)
res = env->GetCharField(d->m_jobject, id);
@@ -1525,7 +1550,7 @@ jshort QJNIObjectPrivate::getField<jshort>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jshort res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "S");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "S");
if (id)
res = env->GetShortField(d->m_jobject, id);
@@ -1537,7 +1562,7 @@ jint QJNIObjectPrivate::getField<jint>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jint res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "I");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "I");
if (id)
res = env->GetIntField(d->m_jobject, id);
@@ -1549,7 +1574,7 @@ jlong QJNIObjectPrivate::getField<jlong>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jlong res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "J");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "J");
if (id)
res = env->GetLongField(d->m_jobject, id);
@@ -1561,7 +1586,7 @@ jfloat QJNIObjectPrivate::getField<jfloat>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jfloat res = 0.f;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "F");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "F");
if (id)
res = env->GetFloatField(d->m_jobject, id);
@@ -1573,7 +1598,7 @@ jdouble QJNIObjectPrivate::getField<jdouble>(const char *fieldName) const
{
QJNIEnvironmentPrivate env;
jdouble res = 0.;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "D");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "D");
if (id)
res = env->GetDoubleField(d->m_jobject, id);
@@ -1585,7 +1610,7 @@ jboolean QJNIObjectPrivate::getStaticField<jboolean>(jclass clazz, const char *f
{
QJNIEnvironmentPrivate env;
jboolean res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "Z", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "Z", true);
if (id)
res = env->GetStaticBooleanField(clazz, id);
@@ -1596,12 +1621,15 @@ template <>
jboolean QJNIObjectPrivate::getStaticField<jboolean>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jboolean res = 0;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jboolean>(clazz, fieldName);
+ if (clazz == 0)
+ return 0;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "Z", true);
+ if (id == 0)
+ return 0;
+
+ return env->GetStaticBooleanField(clazz, id);
}
template <>
@@ -1609,7 +1637,7 @@ jbyte QJNIObjectPrivate::getStaticField<jbyte>(jclass clazz, const char *fieldNa
{
QJNIEnvironmentPrivate env;
jbyte res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "B", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "B", true);
if (id)
res = env->GetStaticByteField(clazz, id);
@@ -1620,12 +1648,15 @@ template <>
jbyte QJNIObjectPrivate::getStaticField<jbyte>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jbyte res = 0;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jbyte>(clazz, fieldName);
+ if (clazz == 0)
+ return 0;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "B", true);
+ if (id == 0)
+ return 0;
+
+ return env->GetStaticByteField(clazz, id);
}
template <>
@@ -1633,7 +1664,7 @@ jchar QJNIObjectPrivate::getStaticField<jchar>(jclass clazz, const char *fieldNa
{
QJNIEnvironmentPrivate env;
jchar res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "C", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "C", true);
if (id)
res = env->GetStaticCharField(clazz, id);
@@ -1644,12 +1675,15 @@ template <>
jchar QJNIObjectPrivate::getStaticField<jchar>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jchar res = 0;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jchar>(clazz, fieldName);
+ if (clazz == 0)
+ return 0;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "C", true);
+ if (id == 0)
+ return 0;
+
+ return env->GetStaticCharField(clazz, id);
}
template <>
@@ -1657,7 +1691,7 @@ jshort QJNIObjectPrivate::getStaticField<jshort>(jclass clazz, const char *field
{
QJNIEnvironmentPrivate env;
jshort res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "S", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "S", true);
if (id)
res = env->GetStaticShortField(clazz, id);
@@ -1668,12 +1702,15 @@ template <>
jshort QJNIObjectPrivate::getStaticField<jshort>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jshort res = 0;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jshort>(clazz, fieldName);
+ if (clazz == 0)
+ return 0;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "S", true);
+ if (id == 0)
+ return 0;
+
+ return env->GetStaticShortField(clazz, id);
}
template <>
@@ -1681,7 +1718,7 @@ jint QJNIObjectPrivate::getStaticField<jint>(jclass clazz, const char *fieldName
{
QJNIEnvironmentPrivate env;
jint res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "I", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "I", true);
if (id)
res = env->GetStaticIntField(clazz, id);
@@ -1692,12 +1729,15 @@ template <>
jint QJNIObjectPrivate::getStaticField<jint>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jint res = 0;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jint>(clazz, fieldName);
+ if (clazz == 0)
+ return 0;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "I", true);
+ if (id == 0)
+ return 0;
+
+ return env->GetStaticIntField(clazz, id);
}
template <>
@@ -1705,7 +1745,7 @@ jlong QJNIObjectPrivate::getStaticField<jlong>(jclass clazz, const char *fieldNa
{
QJNIEnvironmentPrivate env;
jlong res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "J", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "J", true);
if (id)
res = env->GetStaticLongField(clazz, id);
@@ -1716,12 +1756,15 @@ template <>
jlong QJNIObjectPrivate::getStaticField<jlong>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jlong res = 0;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jlong>(clazz, fieldName);
+ if (clazz == 0)
+ return 0;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "J", true);
+ if (id == 0)
+ return 0;
+
+ return env->GetStaticLongField(clazz, id);
}
template <>
@@ -1729,7 +1772,7 @@ jfloat QJNIObjectPrivate::getStaticField<jfloat>(jclass clazz, const char *field
{
QJNIEnvironmentPrivate env;
jfloat res = 0.f;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "F", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "F", true);
if (id)
res = env->GetStaticFloatField(clazz, id);
@@ -1740,12 +1783,15 @@ template <>
jfloat QJNIObjectPrivate::getStaticField<jfloat>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jfloat res = 0.f;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jfloat>(clazz, fieldName);
+ if (clazz == 0)
+ return 0.f;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "F", true);
+ if (id == 0)
+ return 0.f;
+
+ return env->GetStaticFloatField(clazz, id);
}
template <>
@@ -1753,7 +1799,7 @@ jdouble QJNIObjectPrivate::getStaticField<jdouble>(jclass clazz, const char *fie
{
QJNIEnvironmentPrivate env;
jdouble res = 0.;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "D", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "D", true);
if (id)
res = env->GetStaticDoubleField(clazz, id);
@@ -1764,12 +1810,15 @@ template <>
jdouble QJNIObjectPrivate::getStaticField<jdouble>(const char *className, const char *fieldName)
{
QJNIEnvironmentPrivate env;
- jdouble res = 0.;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticField<jdouble>(clazz, fieldName);
+ if (clazz == 0)
+ return 0.;
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, "D", true);
+ if (id == 0)
+ return 0.;
+
+ return env->GetStaticDoubleField(clazz, id);
}
QJNIObjectPrivate QJNIObjectPrivate::getObjectField(const char *fieldName,
@@ -1777,7 +1826,7 @@ QJNIObjectPrivate QJNIObjectPrivate::getObjectField(const char *fieldName,
{
QJNIEnvironmentPrivate env;
jobject res = 0;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, sig);
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, sig);
if (id) {
res = env->GetObjectField(d->m_jobject, id);
if (res && env->ExceptionCheck())
@@ -1794,12 +1843,21 @@ QJNIObjectPrivate QJNIObjectPrivate::getStaticObjectField(const char *className,
const char *sig)
{
QJNIEnvironmentPrivate env;
- QJNIObjectPrivate res;
jclass clazz = loadClass(className, env);
- if (clazz)
- res = getStaticObjectField(clazz, fieldName, sig);
+ if (clazz == 0)
+ return QJNIObjectPrivate();
- return res;
+ jfieldID id = getCachedFieldID(env, clazz, toBinaryEncClassName(className), fieldName, sig, true);
+ if (id == 0)
+ return QJNIObjectPrivate();
+
+ jobject res = env->GetStaticObjectField(clazz, id);
+ if (res && env->ExceptionCheck())
+ res = 0;
+
+ QJNIObjectPrivate obj(res);
+ env->DeleteLocalRef(res);
+ return obj;
}
QJNIObjectPrivate QJNIObjectPrivate::getStaticObjectField(jclass clazz,
@@ -1808,7 +1866,7 @@ QJNIObjectPrivate QJNIObjectPrivate::getStaticObjectField(jclass clazz,
{
QJNIEnvironmentPrivate env;
jobject res = 0;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, sig, true);
+ jfieldID id = getFieldID(env, clazz, fieldName, sig, true);
if (id) {
res = env->GetStaticObjectField(clazz, id);
if (res && env->ExceptionCheck())
@@ -1824,7 +1882,7 @@ template <>
void QJNIObjectPrivate::setField<jboolean>(const char *fieldName, jboolean value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "Z");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "Z");
if (id)
env->SetBooleanField(d->m_jobject, id, value);
@@ -1834,7 +1892,7 @@ template <>
void QJNIObjectPrivate::setField<jbyte>(const char *fieldName, jbyte value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "B");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "B");
if (id)
env->SetByteField(d->m_jobject, id, value);
@@ -1844,7 +1902,7 @@ template <>
void QJNIObjectPrivate::setField<jchar>(const char *fieldName, jchar value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "C");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "C");
if (id)
env->SetCharField(d->m_jobject, id, value);
@@ -1854,7 +1912,7 @@ template <>
void QJNIObjectPrivate::setField<jshort>(const char *fieldName, jshort value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "S");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "S");
if (id)
env->SetShortField(d->m_jobject, id, value);
@@ -1864,7 +1922,7 @@ template <>
void QJNIObjectPrivate::setField<jint>(const char *fieldName, jint value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "I");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "I");
if (id)
env->SetIntField(d->m_jobject, id, value);
@@ -1874,7 +1932,7 @@ template <>
void QJNIObjectPrivate::setField<jlong>(const char *fieldName, jlong value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "J");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "J");
if (id)
env->SetLongField(d->m_jobject, id, value);
@@ -1884,7 +1942,7 @@ template <>
void QJNIObjectPrivate::setField<jfloat>(const char *fieldName, jfloat value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "F");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "F");
if (id)
env->SetFloatField(d->m_jobject, id, value);
@@ -1894,7 +1952,7 @@ template <>
void QJNIObjectPrivate::setField<jdouble>(const char *fieldName, jdouble value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "D");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "D");
if (id)
env->SetDoubleField(d->m_jobject, id, value);
@@ -1904,7 +1962,7 @@ template <>
void QJNIObjectPrivate::setField<jbooleanArray>(const char *fieldName, jbooleanArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[Z");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[Z");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1914,7 +1972,7 @@ template <>
void QJNIObjectPrivate::setField<jbyteArray>(const char *fieldName, jbyteArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[B");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[B");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1924,7 +1982,7 @@ template <>
void QJNIObjectPrivate::setField<jcharArray>(const char *fieldName, jcharArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[C");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[C");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1934,7 +1992,7 @@ template <>
void QJNIObjectPrivate::setField<jshortArray>(const char *fieldName, jshortArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[S");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[S");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1944,7 +2002,7 @@ template <>
void QJNIObjectPrivate::setField<jintArray>(const char *fieldName, jintArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[I");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[I");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1954,7 +2012,7 @@ template <>
void QJNIObjectPrivate::setField<jlongArray>(const char *fieldName, jlongArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[J");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[J");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1964,7 +2022,7 @@ template <>
void QJNIObjectPrivate::setField<jfloatArray>(const char *fieldName, jfloatArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[F");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[F");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1974,7 +2032,7 @@ template <>
void QJNIObjectPrivate::setField<jdoubleArray>(const char *fieldName, jdoubleArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "[D");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "[D");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1984,7 +2042,7 @@ template <>
void QJNIObjectPrivate::setField<jstring>(const char *fieldName, jstring value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, "Ljava/lang/String;");
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, "Ljava/lang/String;");
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -1996,7 +2054,7 @@ void QJNIObjectPrivate::setField<jobject>(const char *fieldName,
jobject value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, sig);
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, sig);
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -2008,7 +2066,7 @@ void QJNIObjectPrivate::setField<jobjectArray>(const char *fieldName,
jobjectArray value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, d->m_jclass, fieldName, sig);
+ jfieldID id = getCachedFieldID(env, d->m_jclass, d->m_className, fieldName, sig);
if (id)
env->SetObjectField(d->m_jobject, id, value);
@@ -2020,7 +2078,7 @@ void QJNIObjectPrivate::setStaticField<jboolean>(jclass clazz,
jboolean value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "Z", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "Z", true);
if (id)
env->SetStaticBooleanField(clazz, id, value);
}
@@ -2032,8 +2090,14 @@ void QJNIObjectPrivate::setStaticField<jboolean>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jboolean>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "Z", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticBooleanField(clazz, id, value);
}
template <>
@@ -2042,7 +2106,7 @@ void QJNIObjectPrivate::setStaticField<jbyte>(jclass clazz,
jbyte value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "B", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "B", true);
if (id)
env->SetStaticByteField(clazz, id, value);
}
@@ -2054,8 +2118,14 @@ void QJNIObjectPrivate::setStaticField<jbyte>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jbyte>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "B", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticByteField(clazz, id, value);
}
template <>
@@ -2064,7 +2134,7 @@ void QJNIObjectPrivate::setStaticField<jchar>(jclass clazz,
jchar value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "C", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "C", true);
if (id)
env->SetStaticCharField(clazz, id, value);
}
@@ -2076,8 +2146,14 @@ void QJNIObjectPrivate::setStaticField<jchar>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jchar>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "C", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticCharField(clazz, id, value);
}
template <>
@@ -2086,7 +2162,7 @@ void QJNIObjectPrivate::setStaticField<jshort>(jclass clazz,
jshort value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "S", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "S", true);
if (id)
env->SetStaticShortField(clazz, id, value);
}
@@ -2098,8 +2174,14 @@ void QJNIObjectPrivate::setStaticField<jshort>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jshort>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "S", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticShortField(clazz, id, value);
}
template <>
@@ -2108,7 +2190,7 @@ void QJNIObjectPrivate::setStaticField<jint>(jclass clazz,
jint value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "I", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "I", true);
if (id)
env->SetStaticIntField(clazz, id, value);
}
@@ -2120,8 +2202,14 @@ void QJNIObjectPrivate::setStaticField<jint>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jint>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "I", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticIntField(clazz, id, value);
}
template <>
@@ -2130,7 +2218,7 @@ void QJNIObjectPrivate::setStaticField<jlong>(jclass clazz,
jlong value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "J", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "J", true);
if (id)
env->SetStaticLongField(clazz, id, value);
}
@@ -2142,8 +2230,14 @@ void QJNIObjectPrivate::setStaticField<jlong>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jlong>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "J", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticLongField(clazz, id, value);
}
template <>
@@ -2152,7 +2246,7 @@ void QJNIObjectPrivate::setStaticField<jfloat>(jclass clazz,
jfloat value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "F", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "F", true);
if (id)
env->SetStaticFloatField(clazz, id, value);
}
@@ -2164,8 +2258,14 @@ void QJNIObjectPrivate::setStaticField<jfloat>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jfloat>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "F", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticFloatField(clazz, id, value);
}
template <>
@@ -2174,7 +2274,7 @@ void QJNIObjectPrivate::setStaticField<jdouble>(jclass clazz,
jdouble value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, "D", true);
+ jfieldID id = getFieldID(env, clazz, fieldName, "D", true);
if (id)
env->SetStaticDoubleField(clazz, id, value);
}
@@ -2186,8 +2286,14 @@ void QJNIObjectPrivate::setStaticField<jdouble>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jdouble>(clazz, fieldName, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, "D", true);
+ if (id == 0)
+ return;
+
+ env->SetStaticDoubleField(clazz, id, value);
}
template <>
@@ -2197,7 +2303,7 @@ void QJNIObjectPrivate::setStaticField<jobject>(jclass clazz,
jobject value)
{
QJNIEnvironmentPrivate env;
- jfieldID id = getCachedFieldID(env, clazz, fieldName, sig, true);
+ jfieldID id = getFieldID(env, clazz, fieldName, sig, true);
if (id)
env->SetStaticObjectField(clazz, id, value);
}
@@ -2210,8 +2316,14 @@ void QJNIObjectPrivate::setStaticField<jobject>(const char *className,
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
- if (clazz)
- setStaticField<jobject>(clazz, fieldName, sig, value);
+ if (clazz == 0)
+ return;
+
+ jfieldID id = getCachedFieldID(env, clazz, className, fieldName, sig, true);
+ if (id == 0)
+ return;
+
+ env->SetStaticObjectField(clazz, id, value);
}
QJNIObjectPrivate QJNIObjectPrivate::fromString(const QString &string)
diff --git a/src/corelib/kernel/qjni_p.h b/src/corelib/kernel/qjni_p.h
index ae9c7c3a7e..1c23f2ab76 100644
--- a/src/corelib/kernel/qjni_p.h
+++ b/src/corelib/kernel/qjni_p.h
@@ -82,6 +82,7 @@ public:
jobject m_jobject;
jclass m_jclass;
bool m_own_jclass;
+ QByteArray m_className;
};
class Q_CORE_EXPORT QJNIObjectPrivate
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 1e2a860d8c..1b214e9f74 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -1357,12 +1357,16 @@ namespace QtPrivate
enum { Value = sizeof(checkType(static_cast<T*>(0))) == sizeof(yes_type) };
};
+ template<typename T, typename Enable = void>
+ struct IsGadgetHelper { enum { Value = false }; };
+
template<typename T>
- struct IsGadgetHelper
+ struct IsGadgetHelper<T, typename T::QtGadgetHelper>
{
- template<typename X> static typename X::QtGadgetHelper *checkType(X*);
- static char checkType(void*);
- enum { Value = sizeof(checkType(static_cast<T*>(0))) == sizeof(void*) };
+ template <typename X>
+ static char checkType(void (X::*)());
+ static void *checkType(void (T::*)());
+ enum { Value = sizeof(checkType(&T::qt_check_for_QGADGET_macro)) == sizeof(void *) };
};
@@ -1381,6 +1385,7 @@ QT_WARNING_DISABLE_CLANG("-Wlocal-type-template-args")
// qt_getEnumMetaObject(T) which returns 'char'
enum { Value = sizeof(qt_getEnumMetaObject(declval())) == sizeof(QMetaObject*) };
};
+ template<> struct IsQEnumHelper<void> { enum { Value = false }; };
QT_WARNING_POP
template<typename T, typename Enable = void>
@@ -1768,7 +1773,7 @@ template <typename T>
struct QMetaTypeIdQObject<T, QMetaType::IsGadget>
{
enum {
- Defined = 1
+ Defined = QtPrivate::is_default_constructible<T>::value
};
static int qt_metatype_id()
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 31e8a670e9..4d01264906 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -172,6 +172,7 @@ private: \
#define Q_GADGET \
public: \
static const QMetaObject staticMetaObject; \
+ void qt_check_for_QGADGET_macro(); \
typedef void QtGadgetHelper; \
private: \
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);
diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp
index 4d37368b2e..5cc54b1def 100644
--- a/src/corelib/kernel/qsharedmemory_win.cpp
+++ b/src/corelib/kernel/qsharedmemory_win.cpp
@@ -163,6 +163,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
#if defined(Q_OS_WINPHONE)
Q_UNIMPLEMENTED();
Q_UNUSED(mode)
+ Q_UNUSED(permissions)
memory = 0;
#elif defined(Q_OS_WINRT)
memory = (void *)MapViewOfFileFromApp(handle(), permissions, 0, 0);
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp
index ed856a538c..3206ff66e3 100644
--- a/src/corelib/mimetypes/qmimetype.cpp
+++ b/src/corelib/mimetypes/qmimetype.cpp
@@ -54,12 +54,12 @@ QMimeTypePrivate::QMimeTypePrivate()
{}
QMimeTypePrivate::QMimeTypePrivate(const QMimeType &other)
- : name(other.d->name),
+ : loaded(other.d->loaded),
+ name(other.d->name),
localeComments(other.d->localeComments),
genericIconName(other.d->genericIconName),
iconName(other.d->iconName),
- globPatterns(other.d->globPatterns),
- loaded(other.d->loaded)
+ globPatterns(other.d->globPatterns)
{}
void QMimeTypePrivate::clear()
diff --git a/src/corelib/mimetypes/qmimetype_p.h b/src/corelib/mimetypes/qmimetype_p.h
index bf533bbcb0..2161dd8901 100644
--- a/src/corelib/mimetypes/qmimetype_p.h
+++ b/src/corelib/mimetypes/qmimetype_p.h
@@ -66,12 +66,12 @@ public:
void addGlobPattern(const QString &pattern);
+ bool loaded; // QSharedData leaves a 4 byte gap, so don't put 8 byte members first
QString name;
LocaleHash localeComments;
QString genericIconName;
QString iconName;
QStringList globPatterns;
- bool loaded;
};
QT_END_NAMESPACE
diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp
index f128acd54e..81b38ea4c4 100644
--- a/src/corelib/statemachine/qabstracttransition.cpp
+++ b/src/corelib/statemachine/qabstracttransition.cpp
@@ -101,7 +101,35 @@ QT_BEGIN_NAMESPACE
parallel group state.
*/
+/*!
+ \property QAbstractTransition::transitionType
+
+ \brief indicates whether this transition is an internal transition, or an external transition.
+
+ Internal and external transitions behave the same, except for the case of a transition whose
+ source state is a compound state and whose target(s) is a descendant of the source. In such a
+ case, an internal transition will not exit and re-enter its source state, while an external one
+ will.
+
+ By default, the type is an external transition.
+*/
+
+/*!
+ \enum QAbstractTransition::TransitionType
+
+ This enum specifies the kind of transition. By default, the type is an external transition.
+
+ \value ExternalTransition Any state that is the source state of a transition (which is not a
+ target-less transition) is left, and re-entered when necessary.
+ \value InternalTransition If the target state of a transition is a sub-state of a compound state,
+ and that compound state is the source state, an internal transition will
+ not leave the source state.
+
+ \sa QAbstractTransition::transitionType
+*/
+
QAbstractTransitionPrivate::QAbstractTransitionPrivate()
+ : transitionType(QAbstractTransition::ExternalTransition)
{
}
@@ -249,6 +277,24 @@ void QAbstractTransition::setTargetStates(const QList<QAbstractState*> &targets)
}
/*!
+ Returns the type of the transition.
+*/
+QAbstractTransition::TransitionType QAbstractTransition::transitionType() const
+{
+ Q_D(const QAbstractTransition);
+ return d->transitionType;
+}
+
+/*!
+ Sets the type of the transition to \a type.
+*/
+void QAbstractTransition::setTransitionType(TransitionType type)
+{
+ Q_D(QAbstractTransition);
+ d->transitionType = type;
+}
+
+/*!
Returns the state machine that this transition is part of, or 0 if the
transition is not part of a state machine.
*/
diff --git a/src/corelib/statemachine/qabstracttransition.h b/src/corelib/statemachine/qabstracttransition.h
index 768a364a4b..bf32b3e825 100644
--- a/src/corelib/statemachine/qabstracttransition.h
+++ b/src/corelib/statemachine/qabstracttransition.h
@@ -59,7 +59,14 @@ class Q_CORE_EXPORT QAbstractTransition : public QObject
Q_PROPERTY(QState* sourceState READ sourceState)
Q_PROPERTY(QAbstractState* targetState READ targetState WRITE setTargetState NOTIFY targetStateChanged)
Q_PROPERTY(QList<QAbstractState*> targetStates READ targetStates WRITE setTargetStates NOTIFY targetStatesChanged)
+ Q_PROPERTY(TransitionType transitionType READ transitionType WRITE setTransitionType)
public:
+ enum TransitionType {
+ ExternalTransition,
+ InternalTransition
+ };
+ Q_ENUM(TransitionType)
+
QAbstractTransition(QState *sourceState = 0);
virtual ~QAbstractTransition();
@@ -69,6 +76,9 @@ public:
QList<QAbstractState*> targetStates() const;
void setTargetStates(const QList<QAbstractState*> &targets);
+ TransitionType transitionType() const;
+ void setTransitionType(TransitionType type);
+
QStateMachine *machine() const;
#ifndef QT_NO_ANIMATION
diff --git a/src/corelib/statemachine/qabstracttransition_p.h b/src/corelib/statemachine/qabstracttransition_p.h
index d89d057497..4b0644acd9 100644
--- a/src/corelib/statemachine/qabstracttransition_p.h
+++ b/src/corelib/statemachine/qabstracttransition_p.h
@@ -73,6 +73,7 @@ public:
void emitTriggered();
QList<QPointer<QAbstractState> > targetStates;
+ QAbstractTransition::TransitionType transitionType;
#ifndef QT_NO_ANIMATION
QList<QAbstractAnimation*> animations;
diff --git a/src/corelib/statemachine/qeventtransition_p.h b/src/corelib/statemachine/qeventtransition_p.h
index 64ab945187..59b0fcb30f 100644
--- a/src/corelib/statemachine/qeventtransition_p.h
+++ b/src/corelib/statemachine/qeventtransition_p.h
@@ -61,8 +61,8 @@ public:
void unregister();
void maybeRegister();
- bool registered;
QObject *object;
+ bool registered;
QEvent::Type eventType;
};
diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h
index 28bb176b56..2ce0c13522 100644
--- a/src/corelib/statemachine/qstate_p.h
+++ b/src/corelib/statemachine/qstate_p.h
@@ -103,8 +103,8 @@ public:
QAbstractState *initialState;
QState::ChildMode childMode;
mutable bool childStatesListNeedsRefresh;
- mutable QList<QAbstractState*> childStatesList;
mutable bool transitionsListNeedsRefresh;
+ mutable QList<QAbstractState*> childStatesList;
mutable QList<QAbstractTransition*> transitionsList;
#ifndef QT_NO_PROPERTIES
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index a8d07602b6..3a1a852ef5 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -177,6 +177,100 @@ QT_BEGIN_NAMESPACE
// #define QSTATEMACHINE_DEBUG
// #define QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG
+struct CalculationCache {
+ struct TransitionInfo {
+ QList<QAbstractState*> effectiveTargetStates;
+ QSet<QAbstractState*> exitSet;
+ QAbstractState *transitionDomain;
+
+ bool effectiveTargetStatesIsKnown: 1;
+ bool exitSetIsKnown : 1;
+ bool transitionDomainIsKnown : 1;
+
+ TransitionInfo()
+ : transitionDomain(0)
+ , effectiveTargetStatesIsKnown(false)
+ , exitSetIsKnown(false)
+ , transitionDomainIsKnown(false)
+ {}
+ };
+
+ typedef QHash<QAbstractTransition *, TransitionInfo> TransitionInfoCache;
+ TransitionInfoCache cache;
+
+ bool effectiveTargetStates(QAbstractTransition *t, QList<QAbstractState *> *targets) const
+ {
+ Q_ASSERT(targets);
+
+ TransitionInfoCache::const_iterator cacheIt = cache.find(t);
+ if (cacheIt == cache.end() || !cacheIt->effectiveTargetStatesIsKnown)
+ return false;
+
+ *targets = cacheIt->effectiveTargetStates;
+ return true;
+ }
+
+ void insert(QAbstractTransition *t, const QList<QAbstractState *> &targets)
+ {
+ TransitionInfoCache::iterator cacheIt = cache.find(t);
+ TransitionInfo &ti = cacheIt == cache.end()
+ ? *cache.insert(t, TransitionInfo())
+ : *cacheIt;
+
+ Q_ASSERT(!ti.effectiveTargetStatesIsKnown);
+ ti.effectiveTargetStates = targets;
+ ti.effectiveTargetStatesIsKnown = true;
+ }
+
+ bool exitSet(QAbstractTransition *t, QSet<QAbstractState *> *exits) const
+ {
+ Q_ASSERT(exits);
+
+ TransitionInfoCache::const_iterator cacheIt = cache.find(t);
+ if (cacheIt == cache.end() || !cacheIt->exitSetIsKnown)
+ return false;
+
+ *exits = cacheIt->exitSet;
+ return true;
+ }
+
+ void insert(QAbstractTransition *t, const QSet<QAbstractState *> &exits)
+ {
+ TransitionInfoCache::iterator cacheIt = cache.find(t);
+ TransitionInfo &ti = cacheIt == cache.end()
+ ? *cache.insert(t, TransitionInfo())
+ : *cacheIt;
+
+ Q_ASSERT(!ti.exitSetIsKnown);
+ ti.exitSet = exits;
+ ti.exitSetIsKnown = true;
+ }
+
+ bool transitionDomain(QAbstractTransition *t, QAbstractState **domain) const
+ {
+ Q_ASSERT(domain);
+
+ TransitionInfoCache::const_iterator cacheIt = cache.find(t);
+ if (cacheIt == cache.end() || !cacheIt->transitionDomainIsKnown)
+ return false;
+
+ *domain = cacheIt->transitionDomain;
+ return true;
+ }
+
+ void insert(QAbstractTransition *t, QAbstractState *domain)
+ {
+ TransitionInfoCache::iterator cacheIt = cache.find(t);
+ TransitionInfo &ti = cacheIt == cache.end()
+ ? *cache.insert(t, TransitionInfo())
+ : *cacheIt;
+
+ Q_ASSERT(!ti.transitionDomainIsKnown);
+ ti.transitionDomain = domain;
+ ti.transitionDomainIsKnown = true;
+ }
+};
+
/* The function as described in http://www.w3.org/TR/2014/WD-scxml-20140529/ :
function isDescendant(state1, state2)
@@ -205,6 +299,17 @@ static bool containsDecendantOf(const QSet<QAbstractState *> &states, const QAbs
return false;
}
+static int descendantDepth(const QAbstractState *state, const QAbstractState *ancestor)
+{
+ int depth = 0;
+ for (const QAbstractState *it = state; it != 0; it = it->parentState()) {
+ if (it == ancestor)
+ break;
+ ++depth;
+ }
+ return depth;
+}
+
/* The function as described in http://www.w3.org/TR/2014/WD-scxml-20140529/ :
function getProperAncestors(state1, state2)
@@ -245,8 +350,14 @@ function getEffectiveTargetStates(transition)
targets.add(s)
return targets
*/
-static QSet<QAbstractState *> getEffectiveTargetStates(QAbstractTransition *transition)
+static QList<QAbstractState *> getEffectiveTargetStates(QAbstractTransition *transition, CalculationCache *cache)
{
+ Q_ASSERT(cache);
+
+ QList<QAbstractState *> targetsList;
+ if (cache->effectiveTargetStates(transition, &targetsList))
+ return targetsList;
+
QSet<QAbstractState *> targets;
foreach (QAbstractState *s, transition->targetStates()) {
if (QHistoryState *historyState = QStateMachinePrivate::toHistoryState(s)) {
@@ -266,7 +377,10 @@ static QSet<QAbstractState *> getEffectiveTargetStates(QAbstractTransition *tran
targets.insert(s);
}
}
- return targets;
+
+ targetsList = targets.toList();
+ cache->insert(transition, targetsList);
+ return targetsList;
}
template <class T>
@@ -348,10 +462,25 @@ static int indexOfDescendant(QState *s, QAbstractState *desc)
bool QStateMachinePrivate::transitionStateEntryLessThan(QAbstractTransition *t1, QAbstractTransition *t2)
{
QState *s1 = t1->sourceState(), *s2 = t2->sourceState();
- if (s1 == s2)
- return QStatePrivate::get(s1)->transitions().indexOf(t1) < QStatePrivate::get(s2)->transitions().indexOf(t2);
- else
- return stateEntryLessThan(t1->sourceState(), t2->sourceState());
+ if (s1 == s2) {
+ QList<QAbstractTransition*> transitions = QStatePrivate::get(s1)->transitions();
+ return transitions.indexOf(t1) < transitions.indexOf(t2);
+ } else if (isDescendant(s1, s2)) {
+ return true;
+ } else if (isDescendant(s2, s1)) {
+ return false;
+ } else {
+ Q_ASSERT(s1->machine() != 0);
+ QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine());
+ QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2);
+ Q_ASSERT(lca != 0);
+ int s1Depth = descendantDepth(s1, lca);
+ int s2Depth = descendantDepth(s2, lca);
+ if (s1Depth == s2Depth)
+ return (indexOfDescendant(lca, s1) < indexOfDescendant(lca, s2));
+ else
+ return s1Depth > s2Depth;
+ }
}
bool QStateMachinePrivate::stateEntryLessThan(QAbstractState *s1, QAbstractState *s2)
@@ -417,8 +546,9 @@ QState *QStateMachinePrivate::findLCCA(const QList<QAbstractState*> &states) con
return findLCA(states, true);
}
-QList<QAbstractTransition*> QStateMachinePrivate::selectTransitions(QEvent *event)
+QList<QAbstractTransition*> QStateMachinePrivate::selectTransitions(QEvent *event, CalculationCache *cache)
{
+ Q_ASSERT(cache);
Q_Q(const QStateMachine);
QVarLengthArray<QAbstractState *> configuration_sorted;
@@ -453,7 +583,7 @@ QList<QAbstractTransition*> QStateMachinePrivate::selectTransitions(QEvent *even
}
if (!enabledTransitions.isEmpty()) {
- removeConflictingTransitions(enabledTransitions);
+ removeConflictingTransitions(enabledTransitions, cache);
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": enabled transitions after removing conflicts:" << enabledTransitions;
#endif
@@ -486,15 +616,20 @@ function removeConflictingTransitions(enabledTransitions):
Note: the implementation below does not build the transitionsToRemove, but removes them in-place.
*/
-void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransition*> &enabledTransitions)
+void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransition*> &enabledTransitions, CalculationCache *cache)
{
+ Q_ASSERT(cache);
+
+ if (enabledTransitions.size() < 2)
+ return; // There is no transition to conflict with.
+
QList<QAbstractTransition*> filteredTransitions;
filteredTransitions.reserve(enabledTransitions.size());
std::sort(enabledTransitions.begin(), enabledTransitions.end(), transitionStateEntryLessThan);
foreach (QAbstractTransition *t1, enabledTransitions) {
bool t1Preempted = false;
- QSet<QAbstractState*> exitSetT1 = computeExitSet_Unordered(QList<QAbstractTransition*>() << t1);
+ QSet<QAbstractState*> exitSetT1 = computeExitSet_Unordered(t1, cache);
QList<QAbstractTransition*>::iterator t2It = filteredTransitions.begin();
while (t2It != filteredTransitions.end()) {
QAbstractTransition *t2 = *t2It;
@@ -505,8 +640,8 @@ void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransitio
break;
}
- QSet<QAbstractState*> exitSetT2 = computeExitSet_Unordered(QList<QAbstractTransition*>() << t2);
- if (!exitSetT1.intersects(exitSetT2)) {
+ QSet<QAbstractState*> exitSetT2 = computeExitSet_Unordered(t2, cache);
+ if (exitSetT1.intersect(exitSetT2).isEmpty()) {
// No conflict, no cry. Next patient please.
++t2It;
} else {
@@ -529,17 +664,20 @@ void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransitio
enabledTransitions = filteredTransitions;
}
-void QStateMachinePrivate::microstep(QEvent *event, const QList<QAbstractTransition*> &enabledTransitions)
+void QStateMachinePrivate::microstep(QEvent *event, const QList<QAbstractTransition*> &enabledTransitions,
+ CalculationCache *cache)
{
+ Q_ASSERT(cache);
+
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q_func() << ": begin microstep( enabledTransitions:" << enabledTransitions << ')';
qDebug() << q_func() << ": configuration before exiting states:" << configuration;
#endif
- QList<QAbstractState*> exitedStates = computeExitSet(enabledTransitions);
+ QList<QAbstractState*> exitedStates = computeExitSet(enabledTransitions, cache);
QHash<RestorableId, QVariant> pendingRestorables = computePendingRestorables(exitedStates);
QSet<QAbstractState*> statesForDefaultEntry;
- QList<QAbstractState*> enteredStates = computeEntrySet(enabledTransitions, statesForDefaultEntry);
+ QList<QAbstractState*> enteredStates = computeEntrySet(enabledTransitions, statesForDefaultEntry, cache);
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q_func() << ": computed exit set:" << exitedStates;
@@ -598,42 +736,61 @@ function computeExitSet(transitions)
statesToExit.add(s)
return statesToExit
*/
-QList<QAbstractState*> QStateMachinePrivate::computeExitSet(const QList<QAbstractTransition*> &enabledTransitions)
+QList<QAbstractState*> QStateMachinePrivate::computeExitSet(const QList<QAbstractTransition*> &enabledTransitions,
+ CalculationCache *cache)
{
- QList<QAbstractState*> statesToExit_sorted = computeExitSet_Unordered(enabledTransitions).toList();
+ Q_ASSERT(cache);
+
+ QList<QAbstractState*> statesToExit_sorted = computeExitSet_Unordered(enabledTransitions, cache).toList();
std::sort(statesToExit_sorted.begin(), statesToExit_sorted.end(), stateExitLessThan);
return statesToExit_sorted;
}
-QSet<QAbstractState*> QStateMachinePrivate::computeExitSet_Unordered(const QList<QAbstractTransition*> &enabledTransitions)
+QSet<QAbstractState*> QStateMachinePrivate::computeExitSet_Unordered(const QList<QAbstractTransition*> &enabledTransitions,
+ CalculationCache *cache)
{
+ Q_ASSERT(cache);
+
QSet<QAbstractState*> statesToExit;
- for (int i = 0; i < enabledTransitions.size(); ++i) {
- QAbstractTransition *t = enabledTransitions.at(i);
- QList<QAbstractState *> effectiveTargetStates = getEffectiveTargetStates(t).toList();
- QAbstractState *domain = getTransitionDomain(t, effectiveTargetStates);
- if (domain == Q_NULLPTR && !t->targetStates().isEmpty()) {
- // So we didn't find the least common ancestor for the source and target states of the
- // transition. If there were not target states, that would be fine: then the transition
- // will fire any events or signals, but not exit the state.
- //
- // However, there are target states, so it's either a node without a parent (or parent's
- // parent, etc), or the state belongs to a different state machine. Either way, this
- // makes the state machine invalid.
- if (error == QStateMachine::NoError)
- setError(QStateMachine::NoCommonAncestorForTransitionError, t->sourceState());
- QList<QAbstractState *> lst = pendingErrorStates.toList();
- lst.prepend(t->sourceState());
-
- domain = findLCCA(lst);
- Q_ASSERT(domain != 0);
- }
+ foreach (QAbstractTransition *t, enabledTransitions)
+ statesToExit.unite(computeExitSet_Unordered(t, cache));
+ return statesToExit;
+}
- foreach (QAbstractState* s, configuration) {
- if (isDescendant(s, domain))
- statesToExit.insert(s);
- }
- }
+QSet<QAbstractState*> QStateMachinePrivate::computeExitSet_Unordered(QAbstractTransition *t,
+ CalculationCache *cache)
+{
+ Q_ASSERT(cache);
+
+ QSet<QAbstractState*> statesToExit;
+ if (cache->exitSet(t, &statesToExit))
+ return statesToExit;
+
+ QList<QAbstractState *> effectiveTargetStates = getEffectiveTargetStates(t, cache);
+ QAbstractState *domain = getTransitionDomain(t, effectiveTargetStates, cache);
+ if (domain == Q_NULLPTR && !t->targetStates().isEmpty()) {
+ // So we didn't find the least common ancestor for the source and target states of the
+ // transition. If there were not target states, that would be fine: then the transition
+ // will fire any events or signals, but not exit the state.
+ //
+ // However, there are target states, so it's either a node without a parent (or parent's
+ // parent, etc), or the state belongs to a different state machine. Either way, this
+ // makes the state machine invalid.
+ if (error == QStateMachine::NoError)
+ setError(QStateMachine::NoCommonAncestorForTransitionError, t->sourceState());
+ QList<QAbstractState *> lst = pendingErrorStates.toList();
+ lst.prepend(t->sourceState());
+
+ domain = findLCCA(lst);
+ Q_ASSERT(domain != 0);
+ }
+
+ foreach (QAbstractState* s, configuration) {
+ if (isDescendant(s, domain))
+ statesToExit.insert(s);
+ }
+
+ cache->insert(t, statesToExit);
return statesToExit;
}
@@ -695,8 +852,11 @@ void QStateMachinePrivate::executeTransitionContent(QEvent *event, const QList<Q
}
QList<QAbstractState*> QStateMachinePrivate::computeEntrySet(const QList<QAbstractTransition *> &enabledTransitions,
- QSet<QAbstractState *> &statesForDefaultEntry)
+ QSet<QAbstractState *> &statesForDefaultEntry,
+ CalculationCache *cache)
{
+ Q_ASSERT(cache);
+
QSet<QAbstractState*> statesToEnter;
if (pendingErrorStates.isEmpty()) {
foreach (QAbstractTransition *t, enabledTransitions) {
@@ -704,8 +864,8 @@ QList<QAbstractState*> QStateMachinePrivate::computeEntrySet(const QList<QAbstra
addDescendantStatesToEnter(s, statesToEnter, statesForDefaultEntry);
}
- QList<QAbstractState *> effectiveTargetStates = getEffectiveTargetStates(t).toList();
- QAbstractState *ancestor = getTransitionDomain(t, effectiveTargetStates);
+ QList<QAbstractState *> effectiveTargetStates = getEffectiveTargetStates(t, cache);
+ QAbstractState *ancestor = getTransitionDomain(t, effectiveTargetStates, cache);
foreach (QAbstractState *s, effectiveTargetStates) {
addAncestorStatesToEnter(s, ancestor, statesToEnter, statesForDefaultEntry);
}
@@ -742,33 +902,42 @@ function getTransitionDomain(t)
else:
return findLCCA([t.source].append(tstates))
*/
-QAbstractState *QStateMachinePrivate::getTransitionDomain(QAbstractTransition *t, const QList<QAbstractState *> &effectiveTargetStates) const
+QAbstractState *QStateMachinePrivate::getTransitionDomain(QAbstractTransition *t,
+ const QList<QAbstractState *> &effectiveTargetStates,
+ CalculationCache *cache) const
{
+ Q_ASSERT(cache);
+
if (effectiveTargetStates.isEmpty())
return 0;
-#if 0
- // Qt only has external transitions, so skip the special case for the internal transitions
- if (QState *tSource = t->sourceState()) {
- if (isCompound(tSource)) {
- bool allDescendants = true;
- foreach (QAbstractState *s, effectiveTargetStates) {
- if (!isDescendant(s, tSource)) {
- allDescendants = false;
- break;
+ QAbstractState *domain = Q_NULLPTR;
+ if (cache->transitionDomain(t, &domain))
+ return domain;
+
+ if (t->transitionType() == QAbstractTransition::InternalTransition) {
+ if (QState *tSource = t->sourceState()) {
+ if (isCompound(tSource)) {
+ bool allDescendants = true;
+ foreach (QAbstractState *s, effectiveTargetStates) {
+ if (!isDescendant(s, tSource)) {
+ allDescendants = false;
+ break;
+ }
}
- }
- if (allDescendants)
- return tSource;
+ if (allDescendants)
+ return tSource;
+ }
}
}
-#endif
QList<QAbstractState *> states(effectiveTargetStates);
if (QAbstractState *src = t->sourceState())
states.prepend(src);
- return findLCCA(states);
+ domain = findLCCA(states);
+ cache->insert(t, domain);
+ return domain;
}
void QStateMachinePrivate::enterStates(QEvent *event, const QList<QAbstractState*> &exitedStates_sorted,
@@ -1676,6 +1845,8 @@ void QStateMachinePrivate::_q_start()
registerMultiThreadedSignalTransitions();
+ startupHook();
+
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": starting";
#endif
@@ -1683,6 +1854,7 @@ void QStateMachinePrivate::_q_start()
processingScheduled = true; // we call _q_process() below
QList<QAbstractTransition*> transitions;
+ CalculationCache calculationCache;
QAbstractTransition *initialTransition = createInitialTransition();
transitions.append(initialTransition);
@@ -1690,7 +1862,7 @@ void QStateMachinePrivate::_q_start()
executeTransitionContent(&nullEvent, transitions);
QList<QAbstractState*> exitedStates = QList<QAbstractState*>();
QSet<QAbstractState*> statesForDefaultEntry;
- QList<QAbstractState*> enteredStates = computeEntrySet(transitions, statesForDefaultEntry);
+ QList<QAbstractState*> enteredStates = computeEntrySet(transitions, statesForDefaultEntry, &calculationCache);
QHash<RestorableId, QVariant> pendingRestorables;
QHash<QAbstractState*, QList<QPropertyAssignment> > assignmentsForEnteredStates =
computePropertyAssignments(enteredStates, pendingRestorables);
@@ -1745,50 +1917,46 @@ void QStateMachinePrivate::_q_process()
break;
}
QList<QAbstractTransition*> enabledTransitions;
+ CalculationCache calculationCache;
+
QEvent *e = new QEvent(QEvent::None);
- enabledTransitions = selectTransitions(e);
+ enabledTransitions = selectTransitions(e, &calculationCache);
if (enabledTransitions.isEmpty()) {
delete e;
e = 0;
}
- if (enabledTransitions.isEmpty() && ((e = dequeueInternalEvent()) != 0)) {
+ while (enabledTransitions.isEmpty() && ((e = dequeueInternalEvent()) != 0)) {
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": dequeued internal event" << e << "of type" << e->type();
#endif
- enabledTransitions = selectTransitions(e);
+ enabledTransitions = selectTransitions(e, &calculationCache);
if (enabledTransitions.isEmpty()) {
delete e;
e = 0;
}
}
- if (enabledTransitions.isEmpty()) {
- if ((e = dequeueExternalEvent()) != 0) {
+ while (enabledTransitions.isEmpty() && ((e = dequeueExternalEvent()) != 0)) {
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": dequeued external event" << e << "of type" << e->type();
#endif
- enabledTransitions = selectTransitions(e);
+ enabledTransitions = selectTransitions(e, &calculationCache);
if (enabledTransitions.isEmpty()) {
delete e;
e = 0;
}
- } else {
- if (isInternalEventQueueEmpty()) {
- processing = false;
- stopProcessingReason = EventQueueEmpty;
- }
- }
}
- if (!enabledTransitions.isEmpty()) {
- didChange = true;
- q->beginMicrostep(e);
- microstep(e, enabledTransitions);
- q->endMicrostep(e);
- }
- else {
+ if (enabledTransitions.isEmpty()) {
+ processing = false;
+ stopProcessingReason = EventQueueEmpty;
noMicrostep();
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": no transitions enabled";
#endif
+ } else {
+ didChange = true;
+ q->beginMicrostep(e);
+ microstep(e, enabledTransitions, &calculationCache);
+ q->endMicrostep(e);
}
delete e;
}
@@ -1976,12 +2144,17 @@ void QStateMachinePrivate::emitStateFinished(QState *forState, QFinalState *guil
Q_ASSERT(guiltyState);
#ifdef QSTATEMACHINE_DEBUG
+ Q_Q(QStateMachine);
qDebug() << q << ": emitting finished signal for" << forState;
#endif
QStatePrivate::get(forState)->emitFinished();
}
+void QStateMachinePrivate::startupHook()
+{
+}
+
namespace _QStateMachine_Internal{
class GoToStateTransition : public QAbstractTransition
@@ -2554,14 +2727,18 @@ void QStateMachine::setRunning(bool running)
event queue. Events are processed in the order posted. The state machine
takes ownership of the event and deletes it once it has been processed.
- You can only post events when the state machine is running.
+ You can only post events when the state machine is running or when it is starting up.
\sa postDelayedEvent()
*/
void QStateMachine::postEvent(QEvent *event, EventPriority priority)
{
Q_D(QStateMachine);
- if (d->state != QStateMachinePrivate::Running) {
+ switch (d->state) {
+ case QStateMachinePrivate::Running:
+ case QStateMachinePrivate::Starting:
+ break;
+ default:
qWarning("QStateMachine::postEvent: cannot post event when the state machine is not running");
return;
}
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index a66232ee88..426f2732df 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -75,6 +75,7 @@ class QState;
class QAbstractAnimation;
#endif
+struct CalculationCache;
class QStateMachine;
class Q_CORE_EXPORT QStateMachinePrivate : public QStatePrivate
{
@@ -124,17 +125,18 @@ public:
void clearHistory();
QAbstractTransition *createInitialTransition() const;
- void removeConflictingTransitions(QList<QAbstractTransition*> &enabledTransitions);
- void microstep(QEvent *event, const QList<QAbstractTransition*> &transitionList);
+ void removeConflictingTransitions(QList<QAbstractTransition*> &enabledTransitions, CalculationCache *cache);
+ void microstep(QEvent *event, const QList<QAbstractTransition*> &transitionList, CalculationCache *cache);
+ QList<QAbstractTransition *> selectTransitions(QEvent *event, CalculationCache *cache);
virtual void noMicrostep();
virtual void processedPendingEvents(bool didChange);
virtual void beginMacrostep();
virtual void endMacrostep(bool didChange);
- QList<QAbstractTransition *> selectTransitions(QEvent *event);
void exitStates(QEvent *event, const QList<QAbstractState *> &statesToExit_sorted,
const QHash<QAbstractState*, QList<QPropertyAssignment> > &assignmentsForEnteredStates);
- QList<QAbstractState*> computeExitSet(const QList<QAbstractTransition*> &enabledTransitions);
- QSet<QAbstractState*> computeExitSet_Unordered(const QList<QAbstractTransition*> &enabledTransitions);
+ QList<QAbstractState*> computeExitSet(const QList<QAbstractTransition*> &enabledTransitions, CalculationCache *cache);
+ QSet<QAbstractState*> computeExitSet_Unordered(const QList<QAbstractTransition*> &enabledTransitions, CalculationCache *cache);
+ QSet<QAbstractState*> computeExitSet_Unordered(QAbstractTransition *t, CalculationCache *cache);
void executeTransitionContent(QEvent *event, const QList<QAbstractTransition*> &transitionList);
void enterStates(QEvent *event, const QList<QAbstractState*> &exitedStates_sorted,
const QList<QAbstractState*> &statesToEnter_sorted,
@@ -145,9 +147,10 @@ public:
#endif
);
QList<QAbstractState*> computeEntrySet(const QList<QAbstractTransition*> &enabledTransitions,
- QSet<QAbstractState*> &statesForDefaultEntry);
+ QSet<QAbstractState*> &statesForDefaultEntry, CalculationCache *cache);
QAbstractState *getTransitionDomain(QAbstractTransition *t,
- const QList<QAbstractState *> &effectiveTargetStates) const;
+ const QList<QAbstractState *> &effectiveTargetStates,
+ CalculationCache *cache) const;
void addDescendantStatesToEnter(QAbstractState *state,
QSet<QAbstractState*> &statesToEnter,
QSet<QAbstractState*> &statesForDefaultEntry);
@@ -199,6 +202,7 @@ public:
void cancelAllDelayedEvents();
virtual void emitStateFinished(QState *forState, QFinalState *guiltyState);
+ virtual void startupHook();
#ifndef QT_NO_PROPERTIES
class RestorableId {
@@ -206,7 +210,8 @@ public:
QObject *obj;
QByteArray prop;
// two overloads because friends can't have default arguments
- friend uint qHash(const RestorableId &key, uint seed) Q_DECL_NOEXCEPT_EXPR(noexcept(std::declval<QByteArray>()))
+ friend uint qHash(const RestorableId &key, uint seed)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(std::declval<QByteArray>())))
{ return qHash(qMakePair(key.obj, key.prop), seed); }
friend uint qHash(const RestorableId &key) Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(key, 0U)))
{ return qHash(key, 0U); }
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index b8544b1f0a..2008f76621 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -57,6 +57,16 @@
#include <algorithm>
+#ifdef Q_OS_WINRT
+namespace ABI {
+ namespace Windows {
+ namespace Foundation {
+ struct IAsyncAction;
+ }
+ }
+}
+#endif // Q_OS_WINRT
+
QT_BEGIN_NAMESPACE
class QAbstractEventDispatcher;
@@ -125,10 +135,6 @@ private:
#ifndef QT_NO_THREAD
-#ifdef Q_OS_WINRT
-namespace ABI { namespace Windows { namespace Foundation { struct IAsyncAction; } } }
-#endif
-
class QThreadPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QThread)
diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp
index 9148ecf6fc..615b7a4e3e 100644
--- a/src/corelib/tools/qcollator.cpp
+++ b/src/corelib/tools/qcollator.cpp
@@ -87,7 +87,7 @@ QCollator::QCollator(const QCollator &other)
}
/*!
- Destroys the collator.
+ Destructor for QCollator.
*/
QCollator::~QCollator()
{
@@ -109,8 +109,8 @@ QCollator &QCollator::operator=(const QCollator &other)
return *this;
}
-/*
- \fn void QCollator::QCollator(QCollator &&other)
+/*!
+ \fn QCollator::QCollator(QCollator &&other)
Move constructor. Moves from \a other into this collator.
@@ -119,8 +119,8 @@ QCollator &QCollator::operator=(const QCollator &other)
one of the assignment operators is undefined.
*/
-/*
- \fn QCollator &QCollator::operator=(QCollator &&other)
+/*!
+ \fn QCollator & QCollator::operator=(QCollator && other)
Move-assigns from \a other to this collator.
@@ -367,6 +367,12 @@ QCollatorSortKey& QCollatorSortKey::operator=(const QCollatorSortKey &other)
}
/*!
+ \fn QCollatorSortKey &QCollatorSortKey::operator=(QCollatorSortKey && other)
+
+ Move-assigns \a other to this collator key.
+*/
+
+/*!
\fn bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
\relates QCollatorSortKey
@@ -377,6 +383,12 @@ QCollatorSortKey& QCollatorSortKey::operator=(const QCollatorSortKey &other)
*/
/*!
+ \fn void QCollatorSortKey::swap(QCollatorSortKey & other)
+
+ Swaps this collator key with \a other.
+*/
+
+/*!
\fn int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const
Compares the key to \a otherKey. Returns a negative value if the key
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index 7e49253f9b..4cc3a2c293 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -119,8 +119,8 @@ public:
QStringList QCommandLineParserPrivate::aliases(const QString &optionName) const
{
- const NameHash_t::const_iterator it = nameHash.find(optionName);
- if (it == nameHash.end()) {
+ const NameHash_t::const_iterator it = nameHash.constFind(optionName);
+ if (it == nameHash.cend()) {
qWarning("QCommandLineParser: option not defined: \"%s\"", qPrintable(optionName));
return QStringList();
}
@@ -847,8 +847,8 @@ QString QCommandLineParser::value(const QString &optionName) const
QStringList QCommandLineParser::values(const QString &optionName) const
{
d->checkParsed("values");
- const NameHash_t::const_iterator it = d->nameHash.find(optionName);
- if (it != d->nameHash.end()) {
+ const NameHash_t::const_iterator it = d->nameHash.constFind(optionName);
+ if (it != d->nameHash.cend()) {
const int optionOffset = *it;
QStringList values = d->optionValuesHash.value(optionOffset);
if (values.isEmpty())
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h
index fc4fb1e7cb..41d198f9bc 100644
--- a/src/corelib/tools/qcontiguouscache.h
+++ b/src/corelib/tools/qcontiguouscache.h
@@ -291,7 +291,7 @@ QContiguousCache<T> &QContiguousCache<T>::operator=(const QContiguousCache<T> &o
{
other.d->ref.ref();
if (!d->ref.deref())
- freeData(d);
+ freeData(p);
d = other.d;
if (!d->sharable)
detach_helper();
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp
index 255e9557e2..eaa695ef27 100644
--- a/src/corelib/tools/qdatetimeparser.cpp
+++ b/src/corelib/tools/qdatetimeparser.cpp
@@ -1362,11 +1362,11 @@ int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex
\internal
returns
- 0 if str == QDateTimeEdit::tr("AM")
- 1 if str == QDateTimeEdit::tr("PM")
- 2 if str can become QDateTimeEdit::tr("AM")
- 3 if str can become QDateTimeEdit::tr("PM")
- 4 if str can become QDateTimeEdit::tr("PM") and can become QDateTimeEdit::tr("AM")
+ 0 if str == tr("AM")
+ 1 if str == tr("PM")
+ 2 if str can become tr("AM")
+ 3 if str can become tr("PM")
+ 4 if str can become tr("PM") and can become tr("AM")
-1 can't become anything sensible
*/
@@ -1737,9 +1737,9 @@ QDateTime QDateTimeParser::getMaximum() const
QString QDateTimeParser::getAmPmText(AmPm ap, Case cs) const
{
if (ap == AmText) {
- return (cs == UpperCase ? QLatin1String("AM") : QLatin1String("am"));
+ return (cs == UpperCase ? tr("AM") : tr("am"));
} else {
- return (cs == UpperCase ? QLatin1String("PM") : QLatin1String("pm"));
+ return (cs == UpperCase ? tr("PM") : tr("pm"));
}
}
diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h
index 55dc3bf7a0..9457e35ad5 100644
--- a/src/corelib/tools/qdatetimeparser_p.h
+++ b/src/corelib/tools/qdatetimeparser_p.h
@@ -54,7 +54,7 @@
# include "QtCore/qvariant.h"
#endif
#include "QtCore/qvector.h"
-
+#include "QtCore/qcoreapplication.h"
#define QDATETIMEEDIT_TIME_MIN QTime(0, 0, 0, 0)
#define QDATETIMEEDIT_TIME_MAX QTime(23, 59, 59, 999)
@@ -72,6 +72,7 @@ QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QDateTimeParser
{
+ Q_DECLARE_TR_FUNCTIONS(QDateTimeParser)
public:
enum Context {
FromString,
diff --git a/src/corelib/tools/qpair.qdoc b/src/corelib/tools/qpair.qdoc
index 48555ed6d1..4452d2f0b8 100644
--- a/src/corelib/tools/qpair.qdoc
+++ b/src/corelib/tools/qpair.qdoc
@@ -96,6 +96,30 @@
\sa qMakePair()
*/
+\fn void QPair::swap(QPair &other)
+
+ \since 5.5
+ Swaps this pair with \a other.
+
+ Equivalent to
+ \code
+ qSwap(this->first, other.first);
+ qSwap(this->second, other.second);
+ \endcode
+
+ Swap overloads are found in namespace \c std as well as via
+ argument-dependent lookup (ADL) in \c{T}'s namespace.
+*/
+
+/*!
+\fn void swap(QPair<T1, T2> &lhs, QPair<T1, T2> &rhs)
+ \overload
+ \relates QPair
+ \since 5.5
+
+ Swaps \a lhs with \a rhs.
+*/
+
/*!
\fn QPair::QPair(const QPair<TT1, TT2> &p)
\since 5.2
@@ -108,37 +132,27 @@
*/
/*!
- \fn QPair &QPair::operator=(const QPair<TT1, TT2> &p)
+ \fn QPair::QPair(QPair<TT1, TT2> &&p)
\since 5.2
- Copies the pair \a p onto this pair.
-
- \sa qMakePair()
+ Move-constructs a QPair instance, making it point to the same object that
+ \a p was pointing to.
*/
/*!
- \fn void QPair::swap(QPair &other)
- \since 5.5
-
- Swaps this pair with \a other.
+ \fn QPair & QPair::operator=(const QPair<TT1, TT2> &p)
+ \since 5.2
- Equivalent to
- \code
- qSwap(this->first, other.first);
- qSwap(this->second, other.second);
- \endcode
+ Copies pair \a p into this pair.
- Swap overloads are found in namespace \c std as well as via
- argument-dependent lookup (ADL) in \c{T}'s namespace.
+ \sa qMakePair()
*/
/*!
- \fn void swap(QPair<T1, T2> &lhs, QPair<T1, T2> &rhs)
- \overload
- \relates QPair
- \since 5.5
+ \fn QPair & QPair::operator=(QPair<TT1, TT2> &&p)
+ \since 5.2
- Swaps \a lhs with \a rhs.
+ Move-assigns pair \a p into this pair instance.
*/
/*! \fn bool operator==(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 18dd2d12c2..47cad6349c 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -1830,6 +1830,13 @@ bool QRegularExpression::operator==(const QRegularExpression &re) const
}
/*!
+ \fn QRegularExpression & QRegularExpression::operator=(QRegularExpression && re)
+
+ Move-assigns the regular expression \a re to this object, and returns a reference
+ to the copy. Both the pattern and the pattern options are copied.
+*/
+
+/*!
\fn bool QRegularExpression::operator!=(const QRegularExpression &re) const
Returns \c true if the regular expression is different from \a re, or
@@ -1956,6 +1963,13 @@ QRegularExpressionMatch &QRegularExpressionMatch::operator=(const QRegularExpres
}
/*!
+ \fn QRegularExpressionMatch &QRegularExpressionMatch::operator=(QRegularExpressionMatch &&match)
+
+ Move-assigns the match result \a match to this object, and returns a reference
+ to the copy.
+*/
+
+/*!
\fn void QRegularExpressionMatch::swap(QRegularExpressionMatch &other)
Swaps the match result \a other with this match result. This
@@ -2320,6 +2334,12 @@ QRegularExpressionMatchIterator &QRegularExpressionMatchIterator::operator=(cons
}
/*!
+ \fn QRegularExpressionMatchIterator &QRegularExpressionMatchIterator::operator=(QRegularExpressionMatchIterator &&iterator)
+
+ Move-assigns the \a iterator to this object.
+*/
+
+/*!
\fn void QRegularExpressionMatchIterator::swap(QRegularExpressionMatchIterator &other)
Swaps the iterator \a other with this iterator object. This operation is
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 35551f4061..c113c38aa2 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -255,6 +255,13 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn QScopedArrayPointer::QScopedArrayPointer(D * p, QtPrivate::QScopedArrayEnsureSameType<T, D>::Type = 0)
+ \internal
+
+ Constructs a QScopedArrayPointer and stores the array of objects.
+*/
+
+/*!
\fn T *QScopedArrayPointer::operator[](int i)
Provides access to entry \a i of the scoped pointer's array of
diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc
index c4f33deed6..495329b90d 100644
--- a/src/corelib/tools/qset.qdoc
+++ b/src/corelib/tools/qset.qdoc
@@ -127,6 +127,13 @@
*/
/*!
+ \fn QSet::QSet(QSet && other)
+
+ Move-constructs a QSet instance, making it point to the same object that \a other was pointing to.
+*/
+
+
+/*!
\fn QSet<T> &QSet::operator=(const QSet<T> &other)
Assigns the \a other set to this set and returns a reference to
@@ -134,6 +141,12 @@
*/
/*!
+ \fn QSet<T> &QSet::operator=(QSet<T> &&other)
+
+ Move-assigns the \a other set to this set.
+*/
+
+/*!
\fn void QSet::swap(QSet<T> &other)
Swaps set \a other with this set. This operation is very fast and
diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h
index 6e7ed40dff..e71eeb607e 100644
--- a/src/corelib/tools/qsize.h
+++ b/src/corelib/tools/qsize.h
@@ -54,15 +54,15 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) Q_DECL_NOTHROW;
void transpose() Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QSize transposed() const Q_DECL_NOTHROW;
+ Q_DECL_CONSTEXPR inline QSize transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
inline void scale(int w, int h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW;
inline void scale(const QSize &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW;
- QSize scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW;
- QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW;
+ QSize scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const Q_DECL_NOTHROW;
+ Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
Q_DECL_RELAXED_CONSTEXPR inline int &rwidth() Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline int &rheight() Q_DECL_NOTHROW;
@@ -214,15 +214,15 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) Q_DECL_NOTHROW;
void transpose() Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QSizeF transposed() const Q_DECL_NOTHROW;
+ Q_DECL_CONSTEXPR inline QSizeF transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
inline void scale(qreal w, qreal h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW;
inline void scale(const QSizeF &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW;
- QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW;
- QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW;
+ QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const Q_DECL_NOTHROW;
+ Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
Q_DECL_RELAXED_CONSTEXPR inline qreal &rwidth() Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline qreal &rheight() Q_DECL_NOTHROW;
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 373d25c6ad..2585686156 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -2721,6 +2721,8 @@ bool QString::operator<(QLatin1String other) const
/*! \fn bool QString::operator<=(const QString &s1, const QString &s2)
+ \relates Qstring
+
Returns \c true if string \a s1 is lexically less than or equal to
string \a s2; otherwise returns \c false.
@@ -2766,9 +2768,10 @@ bool QString::operator<(QLatin1String other) const
*/
/*! \fn bool QString::operator>(const QString &s1, const QString &s2)
+ \relates QString
- Returns \c true if string \a s1 is lexically greater than string \a
- s2; otherwise returns \c false.
+ Returns \c true if string \a s1 is lexically greater than string \a s2;
+ otherwise returns \c false.
The comparison is based exclusively on the numeric Unicode values
of the characters and is very fast, but is not what a human would
@@ -8923,6 +8926,110 @@ bool operator<(const QStringRef &s1,const QStringRef &s2)
*/
/*!
+ \fn bool QStringRef::operator==(const char * s) const
+
+ \overload operator==()
+
+ The \a s byte array is converted to a QStringRef using the
+ fromUtf8() function. This function stops conversion at the
+ first NUL character found, or the end of the byte array.
+
+ You can disable this operator by defining \c
+ QT_NO_CAST_FROM_ASCII when you compile your applications. This
+ can be useful if you want to ensure that all user-visible strings
+ go through QObject::tr(), for example.
+
+ Returns \c true if this string is lexically equal to the parameter
+ string \a s. Otherwise returns \c false.
+
+*/
+
+/*!
+ \fn bool QStringRef::operator!=(const char * s) const
+
+ \overload operator!=()
+
+ The \a s const char pointer is converted to a QStringRef using
+ the fromUtf8() function.
+
+ You can disable this operator by defining \c
+ QT_NO_CAST_FROM_ASCII when you compile your applications. This
+ can be useful if you want to ensure that all user-visible strings
+ go through QObject::tr(), for example.
+
+ Returns \c true if this string is not lexically equal to the parameter
+ string \a s. Otherwise returns \c false.
+*/
+
+/*!
+ \fn bool QStringRef::operator<(const char * s) const
+
+ \overload operator<()
+
+ The \a s const char pointer is converted to a QStringRef using
+ the fromUtf8() function.
+
+ You can disable this operator by defining \c
+ QT_NO_CAST_FROM_ASCII when you compile your applications. This
+ can be useful if you want to ensure that all user-visible strings
+ go through QObject::tr(), for example.
+
+ Returns \c true if this string is lexically smaller than the parameter
+ string \a s. Otherwise returns \c false.
+*/
+
+/*!
+ \fn bool QStringRef::operator<=(const char * s) const
+
+ \overload operator<=()
+
+ The \a s const char pointer is converted to a QStringRef using
+ the fromUtf8() function.
+
+ You can disable this operator by defining \c
+ QT_NO_CAST_FROM_ASCII when you compile your applications. This
+ can be useful if you want to ensure that all user-visible strings
+ go through QObject::tr(), for example.
+
+ Returns \c true if this string is lexically smaller than or equal to the parameter
+ string \a s. Otherwise returns \c false.
+*/
+
+/*!
+ \fn bool QStringRef::operator>(const char * s) const
+
+
+ \overload operator>()
+
+ The \a s const char pointer is converted to a QStringRef using
+ the fromUtf8() function.
+
+ You can disable this operator by defining \c
+ QT_NO_CAST_FROM_ASCII when you compile your applications. This
+ can be useful if you want to ensure that all user-visible strings
+ go through QObject::tr(), for example.
+
+ Returns \c true if this string is lexically greater than the parameter
+ string \a s. Otherwise returns \c false.
+*/
+
+/*!
+ \fn bool QStringRef::operator>= (const char * s) const
+
+ \overload operator>=()
+
+ The \a s const char pointer is converted to a QStringRef using
+ the fromUtf8() function.
+
+ You can disable this operator by defining \c
+ QT_NO_CAST_FROM_ASCII when you compile your applications. This
+ can be useful if you want to ensure that all user-visible strings
+ go through QObject::tr(), for example.
+
+ Returns \c true if this string is lexically greater than or equal to the
+ parameter string \a s. Otherwise returns \c false.
+*/
+/*!
\typedef QString::Data
\internal
*/
@@ -10332,7 +10439,6 @@ QString QString::toHtmlEscaped() const
\endlist
*/
-
/*!
\internal
*/
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 532b294c28..670d94279d 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -498,7 +498,7 @@ public:
};
QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned) const Q_REQUIRED_RESULT;
- QString repeated(int times) const;
+ QString repeated(int times) const Q_REQUIRED_RESULT;
const ushort *utf16() const;