summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/doc/qtcore.qdocconf7
-rw-r--r--src/corelib/doc/src/custom-types.qdoc22
-rw-r--r--src/corelib/io/qfsfileengine_p.h2
-rw-r--r--src/corelib/io/qloggingregistry.cpp8
-rw-r--r--src/corelib/io/qprocess_win.cpp2
-rw-r--r--src/corelib/io/qsettings.cpp8
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp4
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp8
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h2
-rw-r--r--src/corelib/kernel/qjni.cpp65
-rw-r--r--src/corelib/tools/qdatetime.cpp2
-rw-r--r--src/corelib/tools/qstring.cpp2
12 files changed, 71 insertions, 61 deletions
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index 7c879cbbfd..5a14ba9088 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -4,7 +4,7 @@ project = QtCore
description = Qt Core Reference Documentation
version = $QT_VERSION
-examplesinstallpath = core
+examplesinstallpath = corelib
qhp.projects = QtCore
@@ -35,10 +35,7 @@ sourcedirs += ..
exampledirs += \
../ \
snippets \
- ../../../examples/threads/ \
- ../../../examples/tools/ \
- ../../../examples/ipc/ \
- ../../../examples/json/ \
+ ../../../examples/corelib \
../../../examples/network/dnslookup
imagedirs += images
diff --git a/src/corelib/doc/src/custom-types.qdoc b/src/corelib/doc/src/custom-types.qdoc
index bac4a90829..81ce698735 100644
--- a/src/corelib/doc/src/custom-types.qdoc
+++ b/src/corelib/doc/src/custom-types.qdoc
@@ -61,7 +61,7 @@
The following \c Message class definition includes these members:
- \snippet customtype/message.h custom type definition
+ \snippet tools/customtype/message.h custom type definition
The class also provides a constructor for normal use and two public member functions
that are used to obtain the private data.
@@ -77,7 +77,7 @@
to this class, we invoke the Q_DECLARE_METATYPE() macro on the class in the header
file where it is defined:
- \snippet customtype/message.h custom type meta-type declaration
+ \snippet tools/customtype/message.h custom type meta-type declaration
This now makes it possible for \c Message values to be stored in QVariant objects
and retrieved later. See the \l{Custom Type Example} for code that demonstrates
@@ -104,19 +104,19 @@
The \l{Queued Custom Type Example} declares a \c Block class which is registered
in the \c{main.cpp} file:
- \snippet queuedcustomtype/main.cpp main start
+ \snippet threads/queuedcustomtype/main.cpp main start
\dots
- \snippet queuedcustomtype/main.cpp register meta-type for queued communications
+ \snippet threads/queuedcustomtype/main.cpp register meta-type for queued communications
\dots
- \snippet queuedcustomtype/main.cpp main finish
+ \snippet threads/queuedcustomtype/main.cpp main finish
This type is later used in a signal-slot connection in the \c{window.cpp} file:
- \snippet queuedcustomtype/window.cpp Window constructor start
+ \snippet threads/queuedcustomtype/window.cpp Window constructor start
\dots
- \snippet queuedcustomtype/window.cpp connecting signal with custom type
+ \snippet threads/queuedcustomtype/window.cpp connecting signal with custom type
\dots
- \snippet queuedcustomtype/window.cpp Window constructor finish
+ \snippet threads/queuedcustomtype/window.cpp Window constructor finish
If a type is used in a queued connection without being registered, a warning will be
printed at the console; for example:
@@ -131,18 +131,18 @@
It is often quite useful to make a custom type printable for debugging purposes,
as in the following code:
- \snippet customtype/main.cpp printing a custom type
+ \snippet tools/customtype/main.cpp printing a custom type
This is achieved by creating a streaming operator for the type, which is often
defined in the header file for that type:
- \snippet customtype/message.h custom type streaming operator
+ \snippet tools/customtype/message.h custom type streaming operator
The implementation for the \c Message type in the \l{Custom Type Example}
goes to some effort to make the printable representation as readable as
possible:
- \snippet customtype/message.cpp custom type streaming operator
+ \snippet tools/customtype/message.cpp custom type streaming operator
The output sent to the debug stream can, of course, be made as simple or as
complicated as you like. Note that the value returned by this function is
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index 5d5a29243e..3963a9cb11 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
class QFSFileEnginePrivate;
-class Q_AUTOTEST_EXPORT QFSFileEngine : public QAbstractFileEngine
+class Q_CORE_EXPORT QFSFileEngine : public QAbstractFileEngine
{
Q_DECLARE_PRIVATE(QFSFileEngine)
public:
diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp
index e9ee8d9458..8af1487834 100644
--- a/src/corelib/io/qloggingregistry.cpp
+++ b/src/corelib/io/qloggingregistry.cpp
@@ -398,9 +398,11 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat)
// hard-wired implementation of
// qt.*.debug=false
// qt.debug=false
- char c;
- if (!memcmp(cat->categoryName(), "qt", 2) && (!(c = cat->categoryName()[2]) || c == '.'))
- debug = false;
+ if (const char *categoryName = cat->categoryName()) {
+ // == "qt" or startsWith("qt.")
+ if (strcmp(categoryName, "qt") == 0 || strncmp(categoryName, "qt.", 3) == 0)
+ debug = false;
+ }
QString categoryName = QLatin1String(cat->categoryName());
foreach (const QLoggingRule &item, reg->rules) {
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 980fb58865..ee6b7e13f4 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -634,7 +634,7 @@ bool QProcessPrivate::drainOutputPipes()
someReadyReadEmitted |= readyReadEmitted;
if (!readOperationActive || !readyReadEmitted)
break;
- Sleep(100);
+ QThread::yieldCurrentThread();
}
return someReadyReadEmitted;
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index fd35ae33dc..d896da176a 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -3121,6 +3121,10 @@ bool QSettings::isWritable() const
void QSettings::setValue(const QString &key, const QVariant &value)
{
Q_D(QSettings);
+ if (key.isEmpty()) {
+ qWarning("QSettings::setValue: Empty key passed");
+ return;
+ }
QString k = d->actualKey(key);
d->set(k, value);
d->requestUpdate();
@@ -3253,6 +3257,10 @@ bool QSettings::event(QEvent *event)
QVariant QSettings::value(const QString &key, const QVariant &defaultValue) const
{
Q_D(const QSettings);
+ if (key.isEmpty()) {
+ qWarning("QSettings::value: Empty key passed");
+ return QVariant();
+ }
QVariant result = defaultValue;
QString k = d->actualKey(key);
d->get(k, &result);
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 68ab03976f..74a7ea1988 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -3375,7 +3375,7 @@ Qt::ItemFlags QAbstractTableModel::flags(const QModelIndex &index) const
QAbstractItemModel, it is not suitable for use with tree views; you will
need to subclass QAbstractItemModel if you want to provide a model for
that purpose. If you need to use a number of list models to manage data,
- it may be more appropriate to subclass QAbstractTableModel class instead.
+ it may be more appropriate to subclass QAbstractTableModel instead.
Simple models can be created by subclassing this class and implementing
the minimum number of required functions. For example, we could implement
@@ -3399,7 +3399,7 @@ Qt::ItemFlags QAbstractTableModel::flags(const QModelIndex &index) const
default ones provided by the roleNames() function, you must override it.
For editable list models, you must also provide an implementation of
- setData(), implement the flags() function so that it returns a value
+ setData(), and implement the flags() function so that it returns a value
containing \l{Qt::ItemFlags}{Qt::ItemIsEditable}.
Note that QAbstractListModel provides a default implementation of
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 7816edd3f9..a3d00faf31 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -639,7 +639,6 @@ void QEventDispatcherWin32::createInternalHwnd()
{
Q_D(QEventDispatcherWin32);
- Q_ASSERT(!d->internalHwnd);
if (d->internalHwnd)
return;
d->internalHwnd = qt_create_internal_window(this);
@@ -664,9 +663,6 @@ void QEventDispatcherWin32::createInternalHwnd()
// start all normal timers
for (int i = 0; i < d->timerVec.count(); ++i)
d->registerTimer(d->timerVec.at(i));
-
- // trigger a call to sendPostedEvents()
- wakeUp();
}
QEventDispatcherWin32::QEventDispatcherWin32(QObject *parent)
@@ -686,8 +682,10 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
{
Q_D(QEventDispatcherWin32);
- if (!d->internalHwnd)
+ if (!d->internalHwnd) {
createInternalHwnd();
+ wakeUp(); // trigger a call to sendPostedEvents()
+ }
d->interrupt = false;
emit awake();
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index f9bb06a5c5..369c276615 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -65,8 +65,8 @@ class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcher
Q_OBJECT
Q_DECLARE_PRIVATE(QEventDispatcherWin32)
+protected:
void createInternalHwnd();
- friend class QGuiEventDispatcherWin32;
public:
explicit QEventDispatcherWin32(QObject *parent = 0);
diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp
index 173127b063..452e3464d6 100644
--- a/src/corelib/kernel/qjni.cpp
+++ b/src/corelib/kernel/qjni.cpp
@@ -80,38 +80,22 @@ static QString toDotEncodedClassName(const char *className)
return QString::fromLatin1(className).replace(QLatin1Char('/'), QLatin1Char('.'));
}
-static jclass getCachedClass(const QString &classDotEnc)
+static jclass getCachedClass(const QString &classDotEnc, bool *isCached = 0)
{
QHash<QString, jclass>::iterator it = cachedClasses->find(classDotEnc);
+ const bool found = (it != cachedClasses->end());
- if (it == cachedClasses->end())
- return 0;
-
- return it.value();
-}
-
-static jclass findClass(const char *className, JNIEnv *env)
-{
- const QString &classDotEnc = toDotEncodedClassName(className);
- jclass clazz = getCachedClass(classDotEnc);
- if (clazz != 0)
- return clazz;
-
- jclass fclazz = env->FindClass(className);
- if (!exceptionCheckAndClear(env)) {
- clazz = static_cast<jclass>(env->NewGlobalRef(fclazz));
- env->DeleteLocalRef(fclazz);
- }
+ if (isCached != 0)
+ *isCached = found;
- cachedClasses->insert(classDotEnc, clazz);
- return clazz;
+ return found ? it.value() : 0;
}
-static jclass loadClass(const char *className, JNIEnv *env)
+static jclass loadClassDotEnc(const QString &classDotEnc, JNIEnv *env)
{
- const QString &classDotEnc = toDotEncodedClassName(className);
- jclass clazz = getCachedClass(classDotEnc);
- if (clazz != 0)
+ bool isCached = false;
+ jclass clazz = getCachedClass(classDotEnc, &isCached);
+ if (clazz != 0 || isCached)
return clazz;
QJNIObjectPrivate classLoader = QtAndroidPrivate::classLoader();
@@ -130,6 +114,11 @@ static jclass loadClass(const char *className, JNIEnv *env)
return clazz;
}
+inline static jclass loadClass(const char *className, JNIEnv *env)
+{
+ return loadClassDotEnc(toDotEncodedClassName(className), env);
+}
+
typedef QHash<QString, jmethodID> JMethodIDHash;
Q_GLOBAL_STATIC(JMethodIDHash, cachedMethodID)
@@ -224,12 +213,28 @@ JNIEnv *QJNIEnvironmentPrivate::operator->()
jclass QJNIEnvironmentPrivate::findClass(const char *className, JNIEnv *env)
{
- jclass clazz = 0;
- if (env != 0)
- clazz = ::findClass(className, env);
+ const QString &classDotEnc = toDotEncodedClassName(className);
+ bool isCached = false;
+ jclass clazz = getCachedClass(classDotEnc, &isCached);
+
+ const bool found = (clazz != 0) || (clazz == 0 && isCached);
+
+ if (found)
+ return clazz;
+
+ if (env != 0) { // We got an env. pointer (We expect this to be the right env. and call FindClass())
+ jclass fclazz = env->FindClass(className);
+ if (!exceptionCheckAndClear(env)) {
+ clazz = static_cast<jclass>(env->NewGlobalRef(fclazz));
+ env->DeleteLocalRef(fclazz);
+ }
+
+ if (clazz != 0)
+ cachedClasses->insert(classDotEnc, clazz);
+ }
- if (clazz == 0)
- clazz = loadClass(className, QJNIEnvironmentPrivate());
+ if (clazz == 0) // We didn't get an env. pointer or we got one with the WRONG class loader...
+ clazz = loadClassDotEnc(classDotEnc, QJNIEnvironmentPrivate());
return clazz;
}
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 75f2a93e45..f0f6a56755 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -4419,7 +4419,7 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format)
if (size == 10)
return QDateTime(date);
- isoString = isoString.right(11);
+ isoString = isoString.right(isoString.length() - 11);
int offset = 0;
// Check end of string for Time Zone definition, either Z for UTC or [+-]HH:MM for Offset
if (isoString.endsWith(QLatin1Char('Z'))) {
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index b805ec792e..48f251e3f4 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -9020,7 +9020,7 @@ QStringRef QStringRef::right(int n) const
{
if (uint(n) >= uint(m_size))
return *this;
- return QStringRef(m_string, n + m_position, m_size - n);
+ return QStringRef(m_string, m_size - n + m_position, n);
}
/*!