summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-10-11 07:40:32 +0200
committerLiang Qi <liang.qi@qt.io>2016-10-11 07:40:32 +0200
commit905329200f2f3f9372bf07a001371c30c0663684 (patch)
treee6f072ea693c377ae306b3960f4bde36ee20bc17 /src
parent91cde062968f97041bca8d2a30d13aa03b606c3d (diff)
parent1a78ef09b93b0a7337075555dc91032f39fab2a9 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: src/gui/image/qpixmap.cpp src/widgets/kernel/qformlayout.cpp Change-Id: I8a8391a202adf7f18464a22ddf0a6c4974eab692
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents.mm103
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents_p.h19
-rw-r--r--src/corelib/io/qtemporaryfile.cpp2
-rw-r--r--src/corelib/kernel/qtimer.cpp2
-rw-r--r--src/dbus/qdbusdemarshaller.cpp7
-rw-r--r--src/gui/image/qpixmap.cpp50
-rw-r--r--src/gui/kernel/qevent.cpp2
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp15
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h1
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp3
-rw-r--r--src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp8
-rw-r--r--src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h1
-rw-r--r--src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp15
-rw-r--r--src/plugins/platforms/cocoa/qcocoakeymapper.mm16
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp2
-rw-r--r--src/widgets/doc/src/model-view-programming.qdoc2
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp5
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp9
-rw-r--r--src/widgets/kernel/qformlayout.cpp15
-rw-r--r--src/widgets/widgets/qdockwidget.cpp4
-rw-r--r--src/widgets/widgets/qtextedit.cpp2
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp5
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p.h2
23 files changed, 180 insertions, 110 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm
index beb8acb05f..a5558b62e7 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents.mm
+++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm
@@ -87,7 +87,7 @@ bool QFseventsFileSystemWatcherEngine::checkDir(DirsByName::iterator &it)
if (res == -1) {
needsRestart |= derefPath(info.watchedPath);
emit emitDirectoryChanged(info.origPath, true);
- it = watchedDirectories.erase(it);
+ it = watchingState.watchedDirectories.erase(it);
} else if (st.st_ctimespec != info.ctime || st.st_mode != info.mode) {
info.ctime = st.st_ctimespec;
info.mode = st.st_mode;
@@ -138,7 +138,8 @@ bool QFseventsFileSystemWatcherEngine::rescanDirs(const QString &path)
{
bool needsRestart = false;
- for (DirsByName::iterator it = watchedDirectories.begin(); it != watchedDirectories.end(); ) {
+ for (DirsByName::iterator it = watchingState.watchedDirectories.begin();
+ it != watchingState.watchedDirectories.end(); ) {
if (it.key().startsWith(path))
needsRestart |= checkDir(it);
else
@@ -177,11 +178,12 @@ bool QFseventsFileSystemWatcherEngine::rescanFiles(const QString &path)
{
bool needsRestart = false;
- for (FilesByPath::iterator i = watchedFiles.begin(); i != watchedFiles.end(); ) {
+ for (FilesByPath::iterator i = watchingState.watchedFiles.begin();
+ i != watchingState.watchedFiles.end(); ) {
if (i.key().startsWith(path)) {
needsRestart |= rescanFiles(i.value());
if (i.value().isEmpty()) {
- i = watchedFiles.erase(i);
+ i = watchingState.watchedFiles.erase(i);
continue;
}
}
@@ -232,8 +234,8 @@ void QFseventsFileSystemWatcherEngine::processEvent(ConstFSEventStreamRef stream
if (eFlags & kFSEventStreamEventFlagRootChanged) {
// re-check everything:
- DirsByName::iterator dirIt = watchedDirectories.find(path);
- if (dirIt != watchedDirectories.end())
+ DirsByName::iterator dirIt = watchingState.watchedDirectories.find(path);
+ if (dirIt != watchingState.watchedDirectories.end())
needsRestart |= checkDir(dirIt);
needsRestart |= rescanFiles(path);
continue;
@@ -243,13 +245,13 @@ void QFseventsFileSystemWatcherEngine::processEvent(ConstFSEventStreamRef stream
needsRestart |= rescanDirs(path);
// check watched directories:
- DirsByName::iterator dirIt = watchedDirectories.find(path);
- if (dirIt != watchedDirectories.end())
+ DirsByName::iterator dirIt = watchingState.watchedDirectories.find(path);
+ if (dirIt != watchingState.watchedDirectories.end())
needsRestart |= checkDir(dirIt);
// check watched files:
- FilesByPath::iterator pIt = watchedFiles.find(path);
- if (pIt != watchedFiles.end())
+ FilesByPath::iterator pIt = watchingState.watchedFiles.find(path);
+ if (pIt != watchingState.watchedFiles.end())
needsRestart |= rescanFiles(pIt.value());
}
@@ -276,12 +278,11 @@ void QFseventsFileSystemWatcherEngine::doEmitDirectoryChanged(const QString &pat
emit directoryChanged(path, removed);
}
-void QFseventsFileSystemWatcherEngine::restartStream()
+bool QFseventsFileSystemWatcherEngine::restartStream()
{
- QMacAutoReleasePool pool;
QMutexLocker locker(&lock);
stopStream();
- startStream();
+ return startStream();
}
QFseventsFileSystemWatcherEngine *QFseventsFileSystemWatcherEngine::create(QObject *parent)
@@ -311,6 +312,7 @@ QFseventsFileSystemWatcherEngine::~QFseventsFileSystemWatcherEngine()
{
QMacAutoReleasePool pool;
+ // Stop the stream in case we have to wait for the lock below to be acquired.
if (stream)
FSEventStreamStop(stream);
@@ -334,8 +336,10 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths,
QMutexLocker locker(&lock);
+ bool wasRunning = stream != Q_NULLPTR;
bool needsRestart = false;
+ WatchingState oldState = watchingState;
QStringList p = paths;
QMutableListIterator<QString> it(p);
while (it.hasNext()) {
@@ -356,7 +360,7 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths,
const bool isDir = S_ISDIR(st.st_mode);
if (isDir) {
- if (watchedDirectories.contains(realPath))
+ if (watchingState.watchedDirectories.contains(realPath))
continue;
directories->append(origPath);
watchedPath = realPath;
@@ -371,17 +375,18 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths,
parentPath = watchedPath;
}
- for (PathRefCounts::const_iterator i = watchedPaths.begin(), ei = watchedPaths.end(); i != ei; ++i) {
+ for (PathRefCounts::const_iterator i = watchingState.watchedPaths.begin(),
+ ei = watchingState.watchedPaths.end(); i != ei; ++i) {
if (watchedPath.startsWith(i.key())) {
watchedPath = i.key();
break;
}
}
- PathRefCounts::iterator it = watchedPaths.find(watchedPath);
- if (it == watchedPaths.end()) {
+ PathRefCounts::iterator it = watchingState.watchedPaths.find(watchedPath);
+ if (it == watchingState.watchedPaths.end()) {
needsRestart = true;
- watchedPaths.insert(watchedPath, 1);
+ watchingState.watchedPaths.insert(watchedPath, 1);
DEBUG("Adding '%s' to watchedPaths", qPrintable(watchedPath));
} else {
++it.value();
@@ -392,18 +397,25 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths,
DirInfo dirInfo;
dirInfo.dirInfo = info;
dirInfo.entries = scanForDirEntries(realPath);
- watchedDirectories.insert(realPath, dirInfo);
+ watchingState.watchedDirectories.insert(realPath, dirInfo);
DEBUG("-- Also adding '%s' to watchedDirectories", qPrintable(realPath));
} else {
- watchedFiles[parentPath].insert(realPath, info);
+ watchingState.watchedFiles[parentPath].insert(realPath, info);
DEBUG("-- Also adding '%s' to watchedFiles", qPrintable(realPath));
}
}
if (needsRestart) {
stopStream();
- if (!startStream())
+ if (!startStream()) {
+ // ok, something went wrong, let's try to restore the previous state
+ watchingState = qMove(oldState);
+ // and because we don't know which path caused the issue (if any), fail on all of them
p = paths;
+
+ if (wasRunning)
+ startStream();
+ }
}
return p;
@@ -419,6 +431,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat
bool needsRestart = false;
+ WatchingState oldState = watchingState;
QStringList p = paths;
QMutableListIterator<QString> it(p);
while (it.hasNext()) {
@@ -431,10 +444,10 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat
realPath = fi.canonicalFilePath();
if (fi.isDir()) {
- DirsByName::iterator dirIt = watchedDirectories.find(realPath);
- if (dirIt != watchedDirectories.end()) {
+ DirsByName::iterator dirIt = watchingState.watchedDirectories.find(realPath);
+ if (dirIt != watchingState.watchedDirectories.end()) {
needsRestart |= derefPath(dirIt->dirInfo.watchedPath);
- watchedDirectories.erase(dirIt);
+ watchingState.watchedDirectories.erase(dirIt);
directories->removeAll(origPath);
it.remove();
DEBUG("Removed directory '%s'", qPrintable(realPath));
@@ -442,15 +455,15 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat
} else {
QFileInfo fi(realPath);
QString parentPath = fi.path();
- FilesByPath::iterator pIt = watchedFiles.find(parentPath);
- if (pIt != watchedFiles.end()) {
+ FilesByPath::iterator pIt = watchingState.watchedFiles.find(parentPath);
+ if (pIt != watchingState.watchedFiles.end()) {
InfoByName &filesInDir = pIt.value();
InfoByName::iterator fIt = filesInDir.find(realPath);
if (fIt != filesInDir.end()) {
needsRestart |= derefPath(fIt->watchedPath);
filesInDir.erase(fIt);
if (filesInDir.isEmpty())
- watchedFiles.erase(pIt);
+ watchingState.watchedFiles.erase(pIt);
files->removeAll(origPath);
it.remove();
DEBUG("Removed file '%s'", qPrintable(realPath));
@@ -461,26 +474,33 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat
locker.unlock();
- if (needsRestart)
- restartStream();
+ if (needsRestart) {
+ if (!restartStream()) {
+ watchingState = qMove(oldState);
+ startStream();
+ }
+ }
return p;
}
+// Returns false if FSEventStream* calls failed for some mysterious reason, true if things got a
+// thumbs-up.
bool QFseventsFileSystemWatcherEngine::startStream()
{
Q_ASSERT(stream == 0);
- QMacAutoReleasePool pool;
- if (stream) // This shouldn't happen, but let's be nice and handle it.
+ if (stream) // Ok, this really shouldn't happen, esp. not after the assert. But let's be nice in release mode and still handle it.
stopStream();
- if (watchedPaths.isEmpty())
- return false;
+ QMacAutoReleasePool pool;
- DEBUG() << "Starting stream with paths" << watchedPaths.keys();
+ if (watchingState.watchedPaths.isEmpty())
+ return true; // we succeeded in doing nothing
- NSMutableArray *pathsToWatch = [NSMutableArray arrayWithCapacity:watchedPaths.size()];
- for (PathRefCounts::const_iterator i = watchedPaths.begin(), ei = watchedPaths.end(); i != ei; ++i)
+ DEBUG() << "Starting stream with paths" << watchingState.watchedPaths.keys();
+
+ NSMutableArray *pathsToWatch = [NSMutableArray arrayWithCapacity:watchingState.watchedPaths.size()];
+ for (PathRefCounts::const_iterator i = watchingState.watchedPaths.begin(), ei = watchingState.watchedPaths.end(); i != ei; ++i)
[pathsToWatch addObject:i.key().toNSString()];
struct FSEventStreamContext callBackInfo = {
@@ -504,7 +524,7 @@ bool QFseventsFileSystemWatcherEngine::startStream()
latency,
FSEventStreamCreateFlags(0));
- if (!stream) {
+ if (!stream) { // nope, no way to know what went wrong, so just fail
DEBUG() << "Failed to create stream!";
return false;
}
@@ -514,7 +534,7 @@ bool QFseventsFileSystemWatcherEngine::startStream()
if (FSEventStreamStart(stream)) {
DEBUG() << "Stream started successfully with sinceWhen =" << lastReceivedEvent;
return true;
- } else {
+ } else { // again, no way to know what went wrong, so just clean up and fail
DEBUG() << "Stream failed to start!";
FSEventStreamInvalidate(stream);
FSEventStreamRelease(stream);
@@ -525,6 +545,7 @@ bool QFseventsFileSystemWatcherEngine::startStream()
void QFseventsFileSystemWatcherEngine::stopStream(bool isStopped)
{
+ QMacAutoReleasePool pool;
if (stream) {
if (!isStopped)
FSEventStreamStop(stream);
@@ -554,9 +575,9 @@ QFseventsFileSystemWatcherEngine::InfoByName QFseventsFileSystemWatcherEngine::s
bool QFseventsFileSystemWatcherEngine::derefPath(const QString &watchedPath)
{
- PathRefCounts::iterator it = watchedPaths.find(watchedPath);
- if (it != watchedPaths.end() && --it.value() < 1) {
- watchedPaths.erase(it);
+ PathRefCounts::iterator it = watchingState.watchedPaths.find(watchedPath);
+ if (it != watchingState.watchedPaths.end() && --it.value() < 1) {
+ watchingState.watchedPaths.erase(it);
DEBUG("Removing '%s' from watchedPaths.", qPrintable(watchedPath));
return true;
}
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents_p.h b/src/corelib/io/qfilesystemwatcher_fsevents_p.h
index dc4e5bf38b..1b0b8ae15c 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents_p.h
+++ b/src/corelib/io/qfilesystemwatcher_fsevents_p.h
@@ -87,7 +87,7 @@ Q_SIGNALS:
private slots:
void doEmitFileChanged(const QString &path, bool removed);
void doEmitDirectoryChanged(const QString &path, bool removed);
- void restartStream();
+ bool restartStream();
private:
struct Info {
@@ -118,6 +118,19 @@ private:
typedef QHash<QString, DirInfo> DirsByName;
typedef QHash<QString, qint64> PathRefCounts;
+ struct WatchingState {
+ // These fields go hand-in-hand. FSEvents watches paths, and there is no use in watching
+ // the same path multiple times. So, the "refcount" on a path is the number of watched
+ // files that have the same path, plus the number of directories that have the same path.
+ //
+ // If the stream fails to start after adding files/directories, the watcher will try to
+ // keep watching files/directories that it was already watching. It does that by restoring
+ // the previous WatchingState and restarting the stream.
+ FilesByPath watchedFiles;
+ DirsByName watchedDirectories;
+ PathRefCounts watchedPaths;
+ };
+
QFseventsFileSystemWatcherEngine(QObject *parent);
bool startStream();
void stopStream(bool isStopped = false);
@@ -131,10 +144,8 @@ private:
QMutex lock;
dispatch_queue_t queue;
FSEventStreamRef stream;
- FilesByPath watchedFiles;
- DirsByName watchedDirectories;
- PathRefCounts watchedPaths;
FSEventStreamEventId lastReceivedEvent;
+ WatchingState watchingState;
};
QT_END_NAMESPACE
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index c430c7714a..7aae128796 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -665,7 +665,7 @@ QString QTemporaryFile::fileTemplate() const
/*!
Sets the static portion of the file name to \a name. If the file
- template ends in XXXXXX that will automatically be replaced with
+ template contains XXXXXX that will automatically be replaced with
the unique part of the filename, otherwise a filename will be
determined automatically based on the static portion specified.
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index 8ba494ec3d..6d39233aa7 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -611,6 +611,8 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
A single-shot timer fires only once, non-single-shot timers fire
every \l interval milliseconds.
+ The default value for this property is \c false.
+
\sa interval, singleShot()
*/
diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp
index 567c827f7e..57684897c6 100644
--- a/src/dbus/qdbusdemarshaller.cpp
+++ b/src/dbus/qdbusdemarshaller.cpp
@@ -39,6 +39,9 @@
#include "qdbusargument_p.h"
#include "qdbusconnection.h"
+
+#include <qscopedpointer.h>
+
#include <stdlib.h>
QT_BEGIN_NAMESPACE
@@ -423,12 +426,12 @@ QDBusDemarshaller *QDBusDemarshaller::endCommon()
QDBusArgument QDBusDemarshaller::duplicate()
{
- QDBusDemarshaller *d = new QDBusDemarshaller(capabilities);
+ QScopedPointer<QDBusDemarshaller> d(new QDBusDemarshaller(capabilities));
d->iterator = iterator;
d->message = q_dbus_message_ref(message);
q_dbus_message_iter_next(&iterator);
- return QDBusArgumentPrivate::create(d);
+ return QDBusArgumentPrivate::create(d.take());
}
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index a360debf5b..0aa05a04e2 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -760,39 +760,37 @@ QBitmap QPixmap::createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode)
bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConversionFlags flags)
{
- if (fileName.isEmpty()) {
- data.reset();
- return false;
- }
-
- detach();
+ if (!fileName.isEmpty()) {
- QFileInfo info(fileName);
- QString key = QLatin1String("qt_pixmap")
- % info.absoluteFilePath()
- % HexString<uint>(info.lastModified().toSecsSinceEpoch())
- % HexString<quint64>(info.size())
- % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType);
+ QFileInfo info(fileName);
+ // Note: If no extension is provided, we try to match the
+ // file against known plugin extensions
+ if (info.completeSuffix().isEmpty() || info.exists()) {
- // Note: If no extension is provided, we try to match the
- // file against known plugin extensions
- if (!info.completeSuffix().isEmpty() && !info.exists()) {
- data.reset();
- return false;
- }
+ QString key = QLatin1String("qt_pixmap")
+ % info.absoluteFilePath()
+ % HexString<uint>(info.lastModified().toSecsSinceEpoch())
+ % HexString<quint64>(info.size())
+ % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType);
- if (QPixmapCache::find(key, this))
- return true;
+ if (QPixmapCache::find(key, this))
+ return true;
- if (!data)
- data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType);
+ data = QPlatformPixmap::create(0, 0, data ? data->pixelType() : QPlatformPixmap::PixmapType);
- if (data->fromFile(fileName, format, flags)) {
- QPixmapCache::insert(key, *this);
- return true;
+ if (data->fromFile(fileName, format, flags)) {
+ QPixmapCache::insert(key, *this);
+ return true;
+ }
+ }
}
- data.reset();
+ if (!isNull()) {
+ if (isQBitmap())
+ *this = QBitmap();
+ else
+ data.reset();
+ }
return false;
}
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index affc4c2526..254b8926c8 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -1667,7 +1667,7 @@ QResizeEvent::~QResizeEvent()
The event handler QWidget::closeEvent() receives close events. The
default implementation of this event handler accepts the close
event. If you do not want your widget to be hidden, or want some
- special handing, you should reimplement the event handler and
+ special handling, you should reimplement the event handler and
ignore() the event.
The \l{mainwindows/application#close event handler}{closeEvent() in the
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 8e5cfd9497..6f837de27f 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -674,8 +674,7 @@ bool QHttpNetworkConnectionPrivate::dequeueRequest(QAbstractSocket *socket)
HttpMessagePair messagePair = highPriorityQueue.takeLast();
if (!messagePair.second->d_func()->requestIsPrepared)
prepareRequest(messagePair);
- channels[i].request = messagePair.first;
- channels[i].reply = messagePair.second;
+ updateChannel(i, messagePair);
return true;
}
@@ -684,13 +683,21 @@ bool QHttpNetworkConnectionPrivate::dequeueRequest(QAbstractSocket *socket)
HttpMessagePair messagePair = lowPriorityQueue.takeLast();
if (!messagePair.second->d_func()->requestIsPrepared)
prepareRequest(messagePair);
- channels[i].request = messagePair.first;
- channels[i].reply = messagePair.second;
+ updateChannel(i, messagePair);
return true;
}
return false;
}
+void QHttpNetworkConnectionPrivate::updateChannel(int i, const HttpMessagePair &messagePair)
+{
+ channels[i].request = messagePair.first;
+ channels[i].reply = messagePair.second;
+ // Now that reply is assigned a channel, correct reply to channel association
+ // previously set in queueRequest.
+ channels[i].reply->d_func()->connectionChannel = &channels[i];
+}
+
QHttpNetworkRequest QHttpNetworkConnectionPrivate::predictNextRequest() const
{
if (!highPriorityQueue.isEmpty())
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index cad0ab1ac4..430c715717 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -210,6 +210,7 @@ public:
void requeueRequest(const HttpMessagePair &pair); // e.g. after pipeline broke
bool dequeueRequest(QAbstractSocket *socket);
void prepareRequest(HttpMessagePair &request);
+ void updateChannel(int i, const HttpMessagePair &messagePair);
QHttpNetworkRequest predictNextRequest() const;
void fillPipeline(QAbstractSocket *socket);
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index b6a9b80511..205490b830 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -1111,6 +1111,7 @@ void QHttpNetworkConnectionChannel::_q_encrypted()
connection->d_func()->dequeueRequest(socket);
if (reply) {
reply->setSpdyWasUsed(false);
+ Q_ASSERT(reply->d_func()->connectionChannel == this);
emit reply->encrypted();
}
if (reply)
@@ -1137,8 +1138,6 @@ void QHttpNetworkConnectionChannel::_q_sslErrors(const QList<QSslError> &errors)
connection->d_func()->pauseConnection();
if (pendingEncrypt && !reply)
connection->d_func()->dequeueRequest(socket);
- if (reply) // a reply was actually dequeued.
- reply->d_func()->connectionChannel = this; // set correct channel like in sendRequest() and queueRequest();
if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP) {
if (reply)
emit reply->sslErrors(errors);
diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
index 361146dc23..a9d758209a 100644
--- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
@@ -95,6 +95,12 @@ bool QDBusMenuConnection::registerTrayIconMenu(QDBusTrayIcon *item)
return success;
}
+void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+{
+ if (item->menu())
+ connection().unregisterObject(MenuBarPath);
+}
+
bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
{
bool success = connection().registerService(item->instanceId());
@@ -124,7 +130,7 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
{
- connection().unregisterObject(MenuBarPath);
+ unregisterTrayIconMenu(item);
connection().unregisterObject(StatusNotifierItemPath);
bool success = connection().unregisterService(item->instanceId());
if (!success)
diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
index 84eb2a6f3a..ae0595ae3b 100644
--- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
@@ -72,6 +72,7 @@ public:
bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
#ifndef QT_NO_SYSTEMTRAYICON
bool registerTrayIconMenu(QDBusTrayIcon *item);
+ void unregisterTrayIconMenu(QDBusTrayIcon *item);
bool registerTrayIcon(QDBusTrayIcon *item);
bool unregisterTrayIcon(QDBusTrayIcon *item);
#endif // QT_NO_SYSTEMTRAYICON
diff --git a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
index 95e9651e9a..a686a33464 100644
--- a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+++ b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
@@ -214,20 +214,21 @@ QPlatformMenu *QDBusTrayIcon::createMenu() const
void QDBusTrayIcon::updateMenu(QPlatformMenu * menu)
{
qCDebug(qLcTray) << menu;
- bool needsRegistering = !m_menu;
- if (!m_menu)
- m_menu = qobject_cast<QDBusPlatformMenu *>(menu);
- if (!m_menuAdaptor) {
+ QDBusPlatformMenu *newMenu = qobject_cast<QDBusPlatformMenu *>(menu);
+ if (m_menu != newMenu) {
+ if (m_menu) {
+ dBusConnection()->unregisterTrayIconMenu(this);
+ delete m_menuAdaptor;
+ }
+ m_menu = newMenu;
m_menuAdaptor = new QDBusMenuAdaptor(m_menu);
// TODO connect(m_menu, , m_menuAdaptor, SIGNAL(ItemActivationRequested(int,uint)));
connect(m_menu, SIGNAL(propertiesUpdated(QDBusMenuItemList,QDBusMenuItemKeysList)),
m_menuAdaptor, SIGNAL(ItemsPropertiesUpdated(QDBusMenuItemList,QDBusMenuItemKeysList)));
connect(m_menu, SIGNAL(updated(uint,int)),
m_menuAdaptor, SIGNAL(LayoutUpdated(uint,int)));
- }
- m_menu->emitUpdated();
- if (needsRegistering)
dBusConnection()->registerTrayIconMenu(this);
+ }
}
void QDBusTrayIcon::showMessage(const QString &title, const QString &msg, const QIcon &icon,
diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm
index 2faf82f5ff..e7952ae1f6 100644
--- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm
+++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm
@@ -394,11 +394,6 @@ bool QCocoaKeyMapper::updateKeyboard()
keyboardInputLocale = QLocale::c();
keyboardInputDirection = Qt::LeftToRight;
}
-
- const auto newMode = keyboard_mode;
- deleteLayouts();
- keyboard_mode = newMode;
-
return true;
}
@@ -421,8 +416,10 @@ void QCocoaKeyMapper::clearMappings()
void QCocoaKeyMapper::updateKeyMap(unsigned short macVirtualKey, QChar unicodeKey)
{
- updateKeyboard();
-
+ if (updateKeyboard()) {
+ // ### Qt 4 did this:
+ // QKeyMapper::changeKeyboard();
+ }
if (keyLayout[macVirtualKey])
return;
@@ -478,8 +475,9 @@ QList<int> QCocoaKeyMapper::possibleKeys(const QKeyEvent *event) const
for (int i = 1; i < 8; ++i) {
Qt::KeyboardModifiers neededMods = ModsTbl[i];
int key = kbItem->qtKey[i];
- if (key && key != baseKey && ((keyMods & neededMods) == neededMods))
- ret << int(key + neededMods);
+ if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) {
+ ret << int(key + (keyMods & ~neededMods));
+ }
}
return ret;
}
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index 79b5bbae41..fd7eca9e32 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -507,7 +507,7 @@ static const uint CmdTbl[] = { // Multimedia keys mapping table
Qt::Key_Open, // 30 0x1e APPCOMMAND_OPEN
Qt::Key_Close, // 31 0x1f APPCOMMAND_CLOSE
Qt::Key_Save, // 32 0x20 APPCOMMAND_SAVE
- Qt::Key_Print, // 33 0x21 APPCOMMAND_PRINT
+ Qt::Key_Printer, // 33 0x21 APPCOMMAND_PRINT
Qt::Key_Undo, // 34 0x22 APPCOMMAND_UNDO
Qt::Key_Redo, // 35 0x23 APPCOMMAND_REDO
Qt::Key_Copy, // 36 0x24 APPCOMMAND_COPY
diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc
index 6a4aaa489a..e727d7fe56 100644
--- a/src/widgets/doc/src/model-view-programming.qdoc
+++ b/src/widgets/doc/src/model-view-programming.qdoc
@@ -737,7 +737,7 @@
\image spinboxdelegate-example.png
- We subclass the delegate from \l QItemDelegate because we do not want
+ We subclass the delegate from \l QStyledItemDelegate because we do not want
to write custom display functions. However, we must still provide
functions to manage the editor widget:
diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp
index d52aff5131..e1ba3759e0 100644
--- a/src/widgets/graphicsview/qgraphicswidget.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget.cpp
@@ -274,6 +274,11 @@ QGraphicsWidget::~QGraphicsWidget()
// Remove this graphics widget from widgetStyles
widgetStyles()->setStyleForWidget(this, 0);
+
+ // Unset the parent here, when we're still a QGraphicsWidget.
+ // It is otherwise done in ~QGraphicsItem() where we'd be
+ // calling QGraphicsWidget members on an ex-QGraphicsWidget object
+ setParentItem(Q_NULLPTR);
}
/*!
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index a4e24b80b1..fff09b46d0 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -1786,13 +1786,18 @@ void QAbstractItemView::mousePressEvent(QMouseEvent *event)
d->autoScroll = false;
d->selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
d->autoScroll = autoScroll;
- QRect rect(visualRect(d->currentSelectionStartIndex).center(), pos);
if (command.testFlag(QItemSelectionModel::Toggle)) {
command &= ~QItemSelectionModel::Toggle;
d->ctrlDragSelectionFlag = d->selectionModel->isSelected(index) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
command |= d->ctrlDragSelectionFlag;
}
- setSelection(rect, command);
+
+ if ((command & QItemSelectionModel::Current) == 0) {
+ setSelection(QRect(pos, QSize(1, 1)), command);
+ } else {
+ QRect rect(visualRect(d->currentSelectionStartIndex).center(), pos);
+ setSelection(rect, command);
+ }
// signal handlers may change the model
emit pressed(index);
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index 73e82c577c..3e60723f17 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -165,7 +165,7 @@ public:
int insertRow(int row);
void insertRows(int row, int count);
void removeRow(int row);
- void setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item);
+ bool setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item);
void setLayout(int row, QFormLayout::ItemRole role, QLayout *layout);
void setWidget(int row, QFormLayout::ItemRole role, QWidget *widget);
@@ -933,21 +933,21 @@ void QFormLayoutPrivate::removeRow(int row)
m_matrix.removeRow(row);
}
-void QFormLayoutPrivate::setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item)
+bool QFormLayoutPrivate::setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item)
{
const bool fullRow = role == QFormLayout::SpanningRole;
const int column = role == QFormLayout::SpanningRole ? 1 : static_cast<int>(role);
if (Q_UNLIKELY(uint(row) >= uint(m_matrix.rowCount()) || uint(column) > 1U)) {
qWarning("QFormLayoutPrivate::setItem: Invalid cell (%d, %d)", row, column);
- return;
+ return false;
}
if (!item)
- return;
+ return false;
if (Q_UNLIKELY(m_matrix(row, column))) {
qWarning("QFormLayoutPrivate::setItem: Cell (%d, %d) already occupied", row, column);
- return;
+ return false;
}
QFormLayoutItem *i = new QFormLayoutItem(item);
@@ -955,6 +955,7 @@ void QFormLayoutPrivate::setItem(int row, QFormLayout::ItemRole role, QLayoutIte
m_matrix(row, column) = i;
m_things.append(i);
+ return true;
}
void QFormLayoutPrivate::setLayout(int row, QFormLayout::ItemRole role, QLayout *layout)
@@ -971,7 +972,9 @@ void QFormLayoutPrivate::setWidget(int row, QFormLayout::ItemRole role, QWidget
if (widget) {
Q_Q(QFormLayout);
q->addChildWidget(widget);
- setItem(row, role, QLayoutPrivate::createWidgetItem(q, widget));
+ QWidgetItem *item = QLayoutPrivate::createWidgetItem(q, widget);
+ if (!setItem(row, role, item))
+ delete item;
}
}
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 9e95d086bd..5059616870 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -1315,7 +1315,9 @@ QDockWidget::DockWidgetFeatures QDockWidget::features() const
By default, this property is \c true.
- \sa isWindow()
+ When this property changes, the \c {topLevelChanged()} signal is emitted.
+
+ \sa isWindow(), topLevelChanged()
*/
void QDockWidget::setFloating(bool floating)
{
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index af6d13a647..f354495e70 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -1514,7 +1514,7 @@ void QTextEditPrivate::paint(QPainter *p, QPaintEvent *e)
if (layout)
layout->setViewport(QRect());
- if (!placeholderText.isEmpty() && doc->isEmpty()) {
+ if (!placeholderText.isEmpty() && doc->isEmpty() && !control->isPreediting()) {
QColor col = control->palette().text().color();
col.setAlpha(128);
p->setPen(col);
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index d5ecb150a8..47806a194e 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -2584,6 +2584,11 @@ bool QWidgetTextControl::isWordSelectionEnabled() const
return d->wordSelectionEnabled;
}
+bool QWidgetTextControl::isPreediting()
+{
+ return d_func()->isPreediting();
+}
+
#ifndef QT_NO_PRINTER
void QWidgetTextControl::print(QPagedPaintDevice *printer) const
{
diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h
index e1687f83a3..b45f4fff74 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p.h
@@ -173,6 +173,8 @@ public:
bool isWordSelectionEnabled() const;
void setWordSelectionEnabled(bool enabled);
+ bool isPreediting();
+
void print(QPagedPaintDevice *printer) const;
virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const;