Merge remote-tracking branch 'origin/5.6' into dev

Conflicts:
	src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
	src/dbus/qdbusconnection_p.h
	src/dbus/qdbusintegrator.cpp
	src/dbus/qdbusintegrator_p.h
	tests/auto/corelib/io/qdir/qdir.pro
	tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp

Change-Id: I3d3fd07aed015c74b1f545f1327aa73d5f365fcc
This commit is contained in:
Liang Qi 2016-01-26 14:35:50 +01:00
commit a15c3d086d
100 changed files with 820 additions and 511 deletions

View File

@ -28,9 +28,8 @@
/*! /*!
\example desktop/systray \example desktop/systray
\title System Tray Icon Example \title System Tray Icon Example
\ingroup examples-widgets
\brief The System Tray Icon example shows how to add an icon with a menu
The System Tray Icon example shows how to add an icon with a menu
and popup messages to a desktop environment's system tray. and popup messages to a desktop environment's system tray.
\image systemtray-example.png Screenshot of the System Tray Icon. \image systemtray-example.png Screenshot of the System Tray Icon.
@ -47,7 +46,7 @@
The editor allows the user to choose the preferred icon as well as The editor allows the user to choose the preferred icon as well as
set the balloon message's type and duration. The user can also set the balloon message's type and duration. The user can also
edit the message's title and body. Finally, the editor provide a edit the message's title and body. Finally, the editor provides a
checkbox controlling whether the icon is actually shown in the checkbox controlling whether the icon is actually shown in the
system tray, or not. system tray, or not.
@ -65,8 +64,8 @@
check whether a system tray is present on the user's desktop, call check whether a system tray is present on the user's desktop, call
the static QSystemTrayIcon::isSystemTrayAvailable() the static QSystemTrayIcon::isSystemTrayAvailable()
function. Associated with the icon, we provide a menu containing function. Associated with the icon, we provide a menu containing
the typical \gui minimize, \gui maximize, \gui restore and \gui the typical \uicontrol minimize, \uicontrol maximize, \uicontrol restore and
quit actions. We reimplement the QWidget::setVisible() function to \uicontrol quit actions. We reimplement the QWidget::setVisible() function to
update the tray icon's menu whenever the editor's appearance update the tray icon's menu whenever the editor's appearance
changes, e.g., when maximizing or minimizing the main application changes, e.g., when maximizing or minimizing the main application
window. window.
@ -74,7 +73,7 @@
Finally, we reimplement QWidget's \l {QWidget::}{closeEvent()} Finally, we reimplement QWidget's \l {QWidget::}{closeEvent()}
function to be able to inform the user (when closing the editor function to be able to inform the user (when closing the editor
window) that the program will keep running in the system tray window) that the program will keep running in the system tray
until the user chooses the \gui Quit entry in the icon's context until the user chooses the \uicontrol Quit entry in the icon's context
menu. menu.
\section1 Window Class Implementation \section1 Window Class Implementation

View File

@ -28,6 +28,8 @@
/*! /*!
\example draganddrop/fridgemagnets \example draganddrop/fridgemagnets
\title Fridge Magnets Example \title Fridge Magnets Example
\brief The Fridge Magnets example illustrates how to move around several types of
MIME-encoded data with drag and drop.
The Fridge Magnets example shows how to supply more than one type The Fridge Magnets example shows how to supply more than one type
of MIME-encoded data with a drag and drop operation. of MIME-encoded data with a drag and drop operation.

View File

@ -1,179 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example desktop/systray
\title System Tray Icon Example
\ingroup examples-widgets
\brief The System Tray Icon example shows how to add an icon with a menu
and popup messages to a desktop environment's system tray.
\image systemtray-example.png Screenshot of the System Tray Icon.
Modern operating systems usually provide a special area on the
desktop, called the system tray or notification area, where
long-running applications can display icons and short messages.
This example consists of one single class, \c Window, providing
the main application window (i.e., an editor for the system tray
icon) and the associated icon.
\image systemtray-editor.png
The editor allows the user to choose the preferred icon as well as
set the balloon message's type and duration. The user can also
edit the message's title and body. Finally, the editor provides a
checkbox controlling whether the icon is actually shown in the
system tray, or not.
\section1 Window Class Definition
The \c Window class inherits QWidget:
\snippet desktop/systray/window.h 0
We implement several private slots to respond to user
interaction. The other private functions are only convenience
functions provided to simplify the constructor.
The tray icon is an instance of the QSystemTrayIcon class. To
check whether a system tray is present on the user's desktop, call
the static QSystemTrayIcon::isSystemTrayAvailable()
function. Associated with the icon, we provide a menu containing
the typical \uicontrol minimize, \uicontrol maximize, \uicontrol restore and
\uicontrol quit actions. We reimplement the QWidget::setVisible() function
to update the tray icon's menu whenever the editor's appearance
changes, e.g., when maximizing or minimizing the main application
window.
Finally, we reimplement QWidget's \l {QWidget::}{closeEvent()}
function to be able to inform the user (when closing the editor
window) that the program will keep running in the system tray
until the user chooses the \uicontrol Quit entry in the icon's context
menu.
\section1 Window Class Implementation
When constructing the editor widget, we first create the various
editor elements before we create the actual system tray icon:
\snippet desktop/systray/window.cpp 0
We ensure that the application responds to user input by
connecting most of the editor's input widgets (including the
system tray icon) to the application's private slots. But note the
visibility checkbox; its \l {QCheckBox::}{toggled()} signal is
connected to the \e {icon}'s \l {QSystemTrayIcon::}{setVisible()}
function instead.
\snippet desktop/systray/window.cpp 3
The \c setIcon() slot is triggered whenever the current index in
the icon combobox changes, i.e., whenever the user chooses another
icon in the editor. Note that it is also called when the user
activates the tray icon with the left mouse button, triggering the
icon's \l {QSystemTrayIcon::}{activated()} signal. We will come
back to this signal shortly.
The QSystemTrayIcon::setIcon() function sets the \l
{QSystemTrayIcon::}{icon} property that holds the actual system
tray icon. On Windows, the system tray icon size is 16x16; on X11,
the preferred size is 22x22. The icon will be scaled to the
appropriate size as necessary.
Note that on X11, due to a limitation in the system tray
specification, mouse clicks on transparent areas in the icon are
propagated to the system tray. If this behavior is unacceptable,
we suggest using an icon with no transparency.
\snippet desktop/systray/window.cpp 4
Whenever the user activates the system tray icon, it emits its \l
{QSystemTrayIcon::}{activated()} signal passing the triggering
reason as parameter. QSystemTrayIcon provides the \l
{QSystemTrayIcon::}{ActivationReason} enum to describe how the
icon was activated.
In the constructor, we connected our icon's \l
{QSystemTrayIcon::}{activated()} signal to our custom \c
iconActivated() slot: If the user has clicked the icon using the
left mouse button, this function changes the icon image by
incrementing the icon combobox's current index, triggering the \c
setIcon() slot as mentioned above. If the user activates the icon
using the middle mouse button, it calls the custom \c
showMessage() slot:
\snippet desktop/systray/window.cpp 5
When the \e showMessage() slot is triggered, we first retrieve the
message icon depending on the currently chosen message type. The
QSystemTrayIcon::MessageIcon enum describes the icon that is shown
when a balloon message is displayed. Then we call
QSystemTrayIcon's \l {QSystemTrayIcon::}{showMessage()} function
to show the message with the title, body, and icon for the time
specified in milliseconds.
QSystemTrayIcon also has the corresponding, \l {QSystemTrayIcon::}
{messageClicked()} signal, which is emitted when the user clicks a
message displayed by \l {QSystemTrayIcon::}{showMessage()}.
\snippet desktop/systray/window.cpp 6
In the constructor, we connected the \l
{QSystemTrayIcon::}{messageClicked()} signal to our custom \c
messageClicked() slot that simply displays a message using the
QMessageBox class.
QMessageBox provides a modal dialog with a short message, an icon,
and buttons laid out depending on the current style. It supports
four severity levels: "Question", "Information", "Warning" and
"Critical". The easiest way to pop up a message box in Qt is to
call one of the associated static functions, e.g.,
QMessageBox::information().
As we mentioned earlier, we reimplement a couple of QWidget's
virtual functions:
\snippet desktop/systray/window.cpp 1
Our reimplementation of the QWidget::setVisible() function updates
the tray icon's menu whenever the editor's appearance changes,
e.g., when maximizing or minimizing the main application window,
before calling the base class implementation.
\snippet desktop/systray/window.cpp 2
We have reimplemented the QWidget::closeEvent() event handler to
receive widget close events, showing the above message to the
users when they are closing the editor window.
In addition to the functions and slots discussed above, we have
also implemented several convenience functions to simplify the
constructor: \c createIconGroupBox(), \c createMessageGroupBox(),
\c createActions() and \c createTrayIcon(). See the \l
{desktop/systray/window.cpp}{window.cpp} file for details.
*/

View File

@ -28,6 +28,7 @@
/*! /*!
\example tools/codecs \example tools/codecs
\title Text Codecs Example \title Text Codecs Example
\brief How to import and export text using text codecs.
The Text Codecs example demonstrates the principles behind importing and exporting text The Text Codecs example demonstrates the principles behind importing and exporting text
using codecs to ensure that characters are encoded properly, avoiding loss of data using codecs to ensure that characters are encoded properly, avoiding loss of data

View File

@ -29,6 +29,7 @@
\example dombookmarks \example dombookmarks
\title DOM Bookmarks Example \title DOM Bookmarks Example
\ingroup xml-examples \ingroup xml-examples
\brief Provides a reader for XML Bookmark Exchange Language files
The DOM Bookmarks example provides a reader for XML Bookmark Exchange Language (XBEL) The DOM Bookmarks example provides a reader for XML Bookmark Exchange Language (XBEL)
files that uses Qt's DOM-based XML API to read and parse the files. The SAX Bookmarks files that uses Qt's DOM-based XML API to read and parse the files. The SAX Bookmarks

View File

@ -29,6 +29,8 @@
\example xmlstreamlint \example xmlstreamlint
\title XML Stream Lint Example \title XML Stream Lint Example
\ingroup xml-examples \ingroup xml-examples
\brief A commandline tool reading from an input file and writing to
the standard output file.
The XML Stream Lint example provides a simple command line utility that The XML Stream Lint example provides a simple command line utility that
accepts a file name as its single argument and writes it to the standard accepts a file name as its single argument and writes it to the standard

View File

@ -25,4 +25,4 @@ QMAKE_NM = $${CROSS_COMPILE}nm -P
QMAKE_STRIP = $${CROSS_COMPILE}strip QMAKE_STRIP = $${CROSS_COMPILE}strip
contains(DISTRO_OPTS, deb-multi-arch): \ contains(DISTRO_OPTS, deb-multi-arch): \
PKG_CONFIG = $${CROSS_COMPILE}pkg-config QMAKE_PKG_CONFIG = $${CROSS_COMPILE}pkg-config

View File

@ -215,12 +215,16 @@ defineTest(qtAddTargetEnv) {
defineReplace(pkgConfigExecutable) { defineReplace(pkgConfigExecutable) {
isEmpty(PKG_CONFIG) { isEmpty(PKG_CONFIG) {
PKG_CONFIG = pkg-config !isEmpty(QMAKE_PKG_CONFIG): \
PKG_CONFIG = $$QMAKE_PKG_CONFIG
else: \
PKG_CONFIG = pkg-config
sysroot.name = PKG_CONFIG_SYSROOT_DIR sysroot.name = PKG_CONFIG_SYSROOT_DIR
sysroot.value = $$PKG_CONFIG_SYSROOT_DIR sysroot.value = $$PKG_CONFIG_SYSROOT_DIR
libdir.name = PKG_CONFIG_LIBDIR libdir.name = PKG_CONFIG_LIBDIR
libdir.value = $$PKG_CONFIG_LIBDIR libdir.value = $$PKG_CONFIG_LIBDIR
QT_TOOL_NAME = pkg-config
qtAddToolEnv(PKG_CONFIG, sysroot libdir, SYS) qtAddToolEnv(PKG_CONFIG, sysroot libdir, SYS)
} }

View File

@ -493,11 +493,11 @@ static QString xcodeFiletypeForFilename(const QString &filename)
return QStringLiteral("sourcecode.cpp.objcpp"); return QStringLiteral("sourcecode.cpp.objcpp");
if (filename.endsWith(Option::objc_ext)) if (filename.endsWith(Option::objc_ext))
return QStringLiteral("sourcecode.c.objc"); return QStringLiteral("sourcecode.c.objc");
if (filename.endsWith(QStringLiteral(".framework"))) if (filename.endsWith(QLatin1String(".framework")))
return QStringLiteral("wrapper.framework"); return QStringLiteral("wrapper.framework");
if (filename.endsWith(QStringLiteral(".a"))) if (filename.endsWith(QLatin1String(".a")))
return QStringLiteral("archive.ar"); return QStringLiteral("archive.ar");
if (filename.endsWith(QStringLiteral(".pro")) || filename.endsWith(QStringLiteral(".qrc"))) if (filename.endsWith(QLatin1String(".pro")) || filename.endsWith(QLatin1String(".qrc")))
return QStringLiteral("text"); return QStringLiteral("text");
return QString(); return QString();

View File

@ -1209,7 +1209,7 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild)
} }
bool do_default = true; bool do_default = true;
const QString root = "$(INSTALL_ROOT)"; const QString root = installRoot();
QString dst; QString dst;
if (installConfigValues.indexOf("no_path") == -1 && if (installConfigValues.indexOf("no_path") == -1 &&
installConfigValues.indexOf("dummy_install") == -1) { installConfigValues.indexOf("dummy_install") == -1) {

View File

@ -187,6 +187,7 @@ protected:
//for installs //for installs
virtual QString defaultInstall(const QString &); virtual QString defaultInstall(const QString &);
virtual QString installRoot() const;
//for prl //for prl
QString prlFileName(bool fixify=true); QString prlFileName(bool fixify=true);
@ -272,6 +273,9 @@ inline bool MakefileGenerator::noIO() const
inline QString MakefileGenerator::defaultInstall(const QString &) inline QString MakefileGenerator::defaultInstall(const QString &)
{ return QString(""); } { return QString(""); }
inline QString MakefileGenerator::installRoot() const
{ return QStringLiteral("$(INSTALL_ROOT)"); }
inline bool MakefileGenerator::findLibraries(bool, bool) inline bool MakefileGenerator::findLibraries(bool, bool)
{ return true; } { return true; }

View File

@ -509,6 +509,20 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
return false; return false;
} }
#ifdef Q_OS_WIN // MinGW x-compiling for QNX
QString UnixMakefileGenerator::installRoot() const
{
/*
We include a magic prefix on the path to bypass mingw-make's "helpful"
intervention in the environment, recognising variables that look like
paths and adding the msys system root as prefix, which we don't want.
Once this hack has smuggled INSTALL_ROOT into make's variable space, we
can trivially strip the magic prefix back off to get the path we meant.
*/
return QStringLiteral("$(INSTALL_ROOT:@msyshack@%=%)");
}
#endif
QString QString
UnixMakefileGenerator::defaultInstall(const QString &t) UnixMakefileGenerator::defaultInstall(const QString &t)
{ {
@ -517,7 +531,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
enum { NoBundle, SolidBundle, SlicedBundle } bundle = NoBundle; enum { NoBundle, SolidBundle, SlicedBundle } bundle = NoBundle;
bool isAux = (project->first("TEMPLATE") == "aux"); bool isAux = (project->first("TEMPLATE") == "aux");
const QString root = "$(INSTALL_ROOT)"; const QString root = installRoot();
ProStringList &uninst = project->values(ProKey(t + ".uninstall")); ProStringList &uninst = project->values(ProKey(t + ".uninstall"));
QString ret, destdir = project->first("DESTDIR").toQString(); QString ret, destdir = project->first("DESTDIR").toQString();
if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep) if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)

View File

@ -47,6 +47,9 @@ public:
protected: protected:
virtual bool doPrecompiledHeaders() const { return project->isActiveConfig("precompile_header"); } virtual bool doPrecompiledHeaders() const { return project->isActiveConfig("precompile_header"); }
virtual bool doDepends() const { return !Option::mkfile::do_stub_makefile && MakefileGenerator::doDepends(); } virtual bool doDepends() const { return !Option::mkfile::do_stub_makefile && MakefileGenerator::doDepends(); }
#ifdef Q_OS_WIN // MinGW x-compiling for QNX
virtual QString installRoot() const;
#endif
virtual QString defaultInstall(const QString &); virtual QString defaultInstall(const QString &);
virtual ProString fixLibFlag(const ProString &lib); virtual ProString fixLibFlag(const ProString &lib);

View File

@ -58,8 +58,8 @@ struct ContainsPathKey
{ {
bool operator()(const QString &val) const bool operator()(const QString &val) const
{ {
return !(val.endsWith(QStringLiteral("MSBuildToolsPath")) return !(val.endsWith(QLatin1String("MSBuildToolsPath"))
|| val.endsWith(QStringLiteral("MSBuildToolsRoot"))); || val.endsWith(QLatin1String("MSBuildToolsRoot")));
} }
}; };
@ -136,7 +136,7 @@ bool CeSdkHandler::parseMsBuildFile(QFile *file, CeSdkInfo *info)
if (success) { if (success) {
const QString startPattern = QStringLiteral("$(Registry:"); const QString startPattern = QStringLiteral("$(Registry:");
const int startIndex = sdkRootPath.indexOf(startPattern); const int startIndex = sdkRootPath.indexOf(startPattern);
const int endIndex = sdkRootPath.lastIndexOf(QStringLiteral(")")); const int endIndex = sdkRootPath.lastIndexOf(QLatin1Char(')'));
const QString regString = sdkRootPath.mid(startIndex + startPattern.size(), const QString regString = sdkRootPath.mid(startIndex + startPattern.size(),
endIndex - startIndex - startPattern.size()); endIndex - startIndex - startPattern.size());
QSettings sdkRootPathRegistry(regString, QSettings::NativeFormat); QSettings sdkRootPathRegistry(regString, QSettings::NativeFormat);
@ -175,7 +175,7 @@ QStringList CeSdkHandler::filterMsBuildToolPaths(const QStringList &paths) const
QStringList result; QStringList result;
foreach (const QString &path, paths) { foreach (const QString &path, paths) {
QDir dirVC110(path); QDir dirVC110(path);
if (path.endsWith(QStringLiteral("bin"))) if (path.endsWith(QLatin1String("bin")))
dirVC110.cdUp(); dirVC110.cdUp();
QDir dirVC120 = dirVC110; QDir dirVC120 = dirVC110;
if (dirVC110.cd(QStringLiteral("Microsoft.Cpp\\v4.0\\V110\\Platforms"))) if (dirVC110.cd(QStringLiteral("Microsoft.Cpp\\v4.0\\V110\\Platforms")))
@ -274,7 +274,7 @@ void CeSdkHandler::retrieveWEC2013SDKs()
if (cpuInfo.properties.isEmpty()) if (cpuInfo.properties.isEmpty())
continue; continue;
const PropertyContainer &cpuInfoVal = cpuInfo.properties.first().properties.value(QLatin1String("CpuName")); const PropertyContainer &cpuInfoVal = cpuInfo.properties.first().properties.value(QLatin1String("CpuName"));
if (cpuInfoVal.name != QStringLiteral("CpuName")) if (cpuInfoVal.name != QLatin1String("CpuName"))
continue; continue;
const QString SDKName = QStringLiteral("SDK name"); const QString SDKName = QStringLiteral("SDK name");
currentSdk.m_name = currentProperty.properties.value(SDKName).value+ currentSdk.m_name = currentProperty.properties.value(SDKName).value+

View File

@ -107,6 +107,18 @@ bool MingwMakefileGenerator::writeMakefile(QTextStream &t)
return false; return false;
} }
QString MingwMakefileGenerator::installRoot() const
{
/*
We include a magic prefix on the path to bypass mingw-make's "helpful"
intervention in the environment, recognising variables that look like
paths and adding the msys system root as prefix, which we don't want.
Once this hack has smuggled INSTALL_ROOT into make's variable space, we
can trivially strip the magic prefix back off to get the path we meant.
*/
return QStringLiteral("$(INSTALL_ROOT:@msyshack@%=%)");
}
void createLdObjectScriptFile(const QString &fileName, const ProStringList &objList) void createLdObjectScriptFile(const QString &fileName, const ProStringList &objList)
{ {
QString filePath = Option::output_dir + QDir::separator() + fileName; QString filePath = Option::output_dir + QDir::separator() + fileName;

View File

@ -45,6 +45,7 @@ protected:
virtual QString getManifestFileForRcFile() const; virtual QString getManifestFileForRcFile() const;
bool writeMakefile(QTextStream &); bool writeMakefile(QTextStream &);
void init(); void init();
virtual QString installRoot() const;
private: private:
void writeMingwParts(QTextStream &); void writeMingwParts(QTextStream &);
void writeIncPart(QTextStream &t); void writeIncPart(QTextStream &t);

View File

@ -603,8 +603,8 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool)
xml.setIndentString(" "); xml.setIndentString(" ");
const QString toolsVersion = (tool.SdkVersion == QStringLiteral("10.0")) ? QStringLiteral("14.0") const QString toolsVersion = (tool.SdkVersion == QLatin1String("10.0")) ? QStringLiteral("14.0")
: QStringLiteral("4.0"); : QStringLiteral("4.0");
xml << decl("1.0", "utf-8") xml << decl("1.0", "utf-8")
<< tag("Project") << tag("Project")

View File

@ -105,10 +105,10 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t)
QString arch = project->first("VCPROJ_ARCH").toQString().toLower(); QString arch = project->first("VCPROJ_ARCH").toQString().toLower();
QString compiler; QString compiler;
QString compilerArch; QString compilerArch;
if (arch == QStringLiteral("arm")) { if (arch == QLatin1String("arm")) {
compiler = QStringLiteral("x86_arm"); compiler = QStringLiteral("x86_arm");
compilerArch = QStringLiteral("arm"); compilerArch = QStringLiteral("arm");
} else if (arch == QStringLiteral("x64")) { } else if (arch == QLatin1String("x64")) {
const ProStringList hostArch = project->values("QMAKE_TARGET.arch"); const ProStringList hostArch = project->values("QMAKE_TARGET.arch");
if (hostArch.contains("x86_64")) if (hostArch.contains("x86_64"))
compiler = QStringLiteral("amd64"); compiler = QStringLiteral("amd64");
@ -263,7 +263,7 @@ QString NmakeMakefileGenerator::defaultInstall(const QString &t)
QString ret = Win32MakefileGenerator::defaultInstall(t); QString ret = Win32MakefileGenerator::defaultInstall(t);
const QString root = "$(INSTALL_ROOT)"; const QString root = installRoot();
ProStringList &uninst = project->values(ProKey(t + ".uninstall")); ProStringList &uninst = project->values(ProKey(t + ".uninstall"));
QString targetdir = fileFixify(project->first(ProKey(t + ".path")).toQString(), FileFixifyAbsolute); QString targetdir = fileFixify(project->first(ProKey(t + ".path")).toQString(), FileFixifyAbsolute);
if(targetdir.right(1) != Option::dir_sep) if(targetdir.right(1) != Option::dir_sep)

View File

@ -1194,7 +1194,7 @@ void VcprojGenerator::initResourceTool()
foreach (const ProString &path, project->values("RC_INCLUDEPATH")) { foreach (const ProString &path, project->values("RC_INCLUDEPATH")) {
QString fixedPath = fileFixify(path.toQString()); QString fixedPath = fileFixify(path.toQString());
if (fileInfo(fixedPath).isRelative()) { if (fileInfo(fixedPath).isRelative()) {
if (fixedPath == QStringLiteral(".")) if (fixedPath == QLatin1String("."))
fixedPath = QStringLiteral("$(ProjectDir)"); fixedPath = QStringLiteral("$(ProjectDir)");
else else
fixedPath.prepend(QStringLiteral("$(ProjectDir)\\")); fixedPath.prepend(QStringLiteral("$(ProjectDir)\\"));
@ -1329,7 +1329,7 @@ void VcprojGenerator::initDeploymentTool()
if (!vcInstallDir.isEmpty()) { if (!vcInstallDir.isEmpty()) {
vcInstallDir += "\\ce\\dll\\"; vcInstallDir += "\\ce\\dll\\";
vcInstallDir += project->values("CE_ARCH").join(QLatin1Char(' ')); vcInstallDir += project->values("CE_ARCH").join(QLatin1Char(' '));
if (!QFileInfo(vcInstallDir + QDir::separator() + runtimeVersion).exists()) if (!QFileInfo::exists(vcInstallDir + QDir::separator() + runtimeVersion))
runtime.clear(); runtime.clear();
else else
runtime = vcInstallDir; runtime = vcInstallDir;

View File

@ -684,7 +684,7 @@ QString Win32MakefileGenerator::defaultInstall(const QString &t)
project->first("TEMPLATE") == "subdirs" || project->first("TEMPLATE") == "aux") project->first("TEMPLATE") == "subdirs" || project->first("TEMPLATE") == "aux")
return QString(); return QString();
const QString root = "$(INSTALL_ROOT)"; const QString root = installRoot();
ProStringList &uninst = project->values(ProKey(t + ".uninstall")); ProStringList &uninst = project->values(ProKey(t + ".uninstall"));
QString ret; QString ret;
QString targetdir = fileFixify(project->first(ProKey(t + ".path")).toQString(), FileFixifyAbsolute); QString targetdir = fileFixify(project->first(ProKey(t + ".path")).toQString(), FileFixifyAbsolute);

View File

@ -952,7 +952,7 @@ static ProString msvcBinDirToQMakeArch(QString subdir)
if (idx >= 0) if (idx >= 0)
subdir.remove(0, idx + 1); subdir.remove(0, idx + 1);
subdir = subdir.toLower(); subdir = subdir.toLower();
if (subdir == QStringLiteral("amd64")) if (subdir == QLatin1String("amd64"))
return ProString("x86_64"); return ProString("x86_64");
return ProString(subdir); return ProString(subdir);
} }

View File

@ -304,8 +304,8 @@ int runQMake(int argc, char **argv)
dir = tmp_dir; dir = tmp_dir;
} }
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
if (fi.fileName().endsWith(QStringLiteral(".pbxproj")) if (fi.fileName().endsWith(QLatin1String(".pbxproj"))
&& dir.endsWith(QStringLiteral(".xcodeproj"))) && dir.endsWith(QLatin1String(".xcodeproj")))
dir += QStringLiteral("/.."); dir += QStringLiteral("/..");
#endif #endif
if(!dir.isNull() && dir != ".") if(!dir.isNull() && dir != ".")

View File

@ -19,13 +19,13 @@
<property name="IconName" type="s" access="read"/> <property name="IconName" type="s" access="read"/>
<!--struct containing width, height and image data--> <!--struct containing width, height and image data-->
<property name="IconPixmap" type="(iiay)" access="read"> <property name="IconPixmap" type="a(iiay)" access="read">
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QXdgDBusImageVector"/> <annotation name="org.qtproject.QtDBus.QtTypeName" value="QXdgDBusImageVector"/>
</property> </property>
<property name="OverlayIconName" type="s" access="read"/> <property name="OverlayIconName" type="s" access="read"/>
<property name="OverlayIconPixmap" type="(iiay)" access="read"> <property name="OverlayIconPixmap" type="a(iiay)" access="read">
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QXdgDBusImageVector"/> <annotation name="org.qtproject.QtDBus.QtTypeName" value="QXdgDBusImageVector"/>
</property> </property>
@ -34,7 +34,7 @@
<property name="AttentionIconName" type="s" access="read"/> <property name="AttentionIconName" type="s" access="read"/>
<!--same definition as image--> <!--same definition as image-->
<property name="AttentionIconPixmap" type="(iiay)" access="read"> <property name="AttentionIconPixmap" type="a(iiay)" access="read">
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QXdgDBusImageVector"/> <annotation name="org.qtproject.QtDBus.QtTypeName" value="QXdgDBusImageVector"/>
</property> </property>
@ -45,7 +45,7 @@
<!-- tooltip data --> <!-- tooltip data -->
<!--(iiay) is an image--> <!--(iiay) is an image-->
<property name="ToolTip" type="(s(iiay)ss)" access="read"> <property name="ToolTip" type="(sa(iiay)ss)" access="read">
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QXdgDBusToolTipStruct"/> <annotation name="org.qtproject.QtDBus.QtTypeName" value="QXdgDBusToolTipStruct"/>
</property> </property>

View File

@ -15,6 +15,9 @@ DEFINES += HAVE_ATEXIT
unix: DEFINES += HAVE_PTHREAD HAVE_SCHED_H HAVE_SCHED_YIELD unix: DEFINES += HAVE_PTHREAD HAVE_SCHED_H HAVE_SCHED_YIELD
win32: DEFINES += HB_NO_WIN1256 win32: DEFINES += HB_NO_WIN1256
#Workaround https://code.google.com/p/android/issues/detail?id=194631
android: DEFINES += _POSIX_C_SOURCE=200112L
INCLUDEPATH += $$PWD/include INCLUDEPATH += $$PWD/include
INCLUDEPATH += $$QT.core.includes INCLUDEPATH += $$QT.core.includes

View File

@ -48,6 +48,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.Rect;
import android.net.LocalServerSocket; import android.net.LocalServerSocket;
import android.net.LocalSocket; import android.net.LocalSocket;
import android.os.Build; import android.os.Build;
@ -74,7 +75,6 @@ import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.widget.PopupMenu; import android.widget.PopupMenu;
import android.graphics.Rect;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.DataOutputStream; import java.io.DataOutputStream;
@ -134,6 +134,9 @@ public class QtActivityDelegate
private boolean m_keyboardIsVisible = false; private boolean m_keyboardIsVisible = false;
public boolean m_backKeyPressedSent = false; public boolean m_backKeyPressedSent = false;
private long m_showHideTimeStamp = System.nanoTime(); private long m_showHideTimeStamp = System.nanoTime();
private int m_portraitKeyboardHeight = 0;
private int m_landscapeKeyboardHeight = 0;
private int m_probeKeyboardHeightDelay = 50; // ms
public void setFullScreen(boolean enterFullScreen) public void setFullScreen(boolean enterFullScreen)
{ {
@ -244,19 +247,26 @@ public class QtActivityDelegate
}, 5); }, 5);
} }
public void showSoftwareKeyboard(int x, int y, int width, int height, int inputHints, int enterKeyType) public void showSoftwareKeyboard(final int x, final int y, final int width, final int height, final int inputHints, final int enterKeyType)
{ {
if (m_imm == null) if (m_imm == null)
return; return;
DisplayMetrics metrics = new DisplayMetrics();
m_activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
// If the screen is in portrait mode than we estimate that keyboard height will not be higher than 2/5 of the screen.
// else than we estimate that keyboard height will not be higher than 2/3 of the screen
final int visibleHeight;
if (metrics.widthPixels < metrics.heightPixels)
visibleHeight = m_portraitKeyboardHeight != 0 ? m_portraitKeyboardHeight : metrics.heightPixels * 3 / 5;
else
visibleHeight = m_landscapeKeyboardHeight != 0 ? m_landscapeKeyboardHeight : metrics.heightPixels / 3;
if (m_softInputMode != 0) { if (m_softInputMode != 0) {
m_activity.getWindow().setSoftInputMode(m_softInputMode); m_activity.getWindow().setSoftInputMode(m_softInputMode);
// softInputIsHidden is true if SOFT_INPUT_STATE_HIDDEN or SOFT_INPUT_STATE_ALWAYS_HIDDEN is set.
final boolean softInputIsHidden = (m_softInputMode & WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) != 0;
if (softInputIsHidden)
return;
} else { } else {
if (height > m_layout.getHeight() * 2 / 3) if (height > visibleHeight)
m_activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); m_activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
else else
m_activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); m_activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
@ -362,6 +372,38 @@ public class QtActivityDelegate
//FALLTHROUGH //FALLTHROUGH
case InputMethodManager.RESULT_UNCHANGED_SHOWN: case InputMethodManager.RESULT_UNCHANGED_SHOWN:
setKeyboardVisibility(true, System.nanoTime()); setKeyboardVisibility(true, System.nanoTime());
if (m_softInputMode == 0) {
// probe for real keyboard height
m_layout.postDelayed(new Runnable() {
@Override
public void run() {
if (!m_keyboardIsVisible)
return;
DisplayMetrics metrics = new DisplayMetrics();
m_activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
Rect r = new Rect();
m_activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
if (metrics.heightPixels != r.bottom) {
if (metrics.widthPixels > metrics.heightPixels) { // landscape
if (m_landscapeKeyboardHeight != r.bottom) {
m_landscapeKeyboardHeight = r.bottom;
showSoftwareKeyboard(x, y, width, height, inputHints, enterKeyType);
}
} else {
if (m_portraitKeyboardHeight != r.bottom) {
m_portraitKeyboardHeight = r.bottom;
showSoftwareKeyboard(x, y, width, height, inputHints, enterKeyType);
}
}
} else {
// no luck ?
// maybe the delay was too short, so let's make it longer
if (m_probeKeyboardHeightDelay < 1000)
m_probeKeyboardHeightDelay *= 2;
}
}
}, m_probeKeyboardHeightDelay);
}
break; break;
case InputMethodManager.RESULT_HIDDEN: case InputMethodManager.RESULT_HIDDEN:
case InputMethodManager.RESULT_UNCHANGED_HIDDEN: case InputMethodManager.RESULT_UNCHANGED_HIDDEN:

View File

@ -188,6 +188,58 @@ int BlockSizeManager::blockSize()
return m_blockSize; return m_blockSize;
} }
/*! \internal
*/
BlockSizeManagerV2::BlockSizeManagerV2(int iterationCount)
: maxBlockSize(iterationCount / (QThreadPool::globalInstance()->maxThreadCount() * 2)),
beforeUser(0), afterUser(0),
m_blockSize(1)
{ }
// Records the time before user code.
void BlockSizeManagerV2::timeBeforeUser()
{
if (blockSizeMaxed())
return;
beforeUser = getticks();
controlPartElapsed.addValue(elapsed(beforeUser, afterUser));
}
// Records the time after user code and adjust the block size if we are spending
// to much time in the for control code compared with the user code.
void BlockSizeManagerV2::timeAfterUser()
{
if (blockSizeMaxed())
return;
afterUser = getticks();
userPartElapsed.addValue(elapsed(afterUser, beforeUser));
if (controlPartElapsed.isMedianValid() == false)
return;
if (controlPartElapsed.median() * TargetRatio < userPartElapsed.median())
return;
m_blockSize = qMin(m_blockSize * 2, maxBlockSize);
#ifdef QTCONCURRENT_FOR_DEBUG
qDebug() << QThread::currentThread() << "adjusting block size" << controlPartElapsed.median() << userPartElapsed.median() << m_blockSize;
#endif
// Reset the medians after adjusting the block size so we get
// new measurements with the new block size.
controlPartElapsed.reset();
userPartElapsed.reset();
}
int BlockSizeManagerV2::blockSize()
{
return m_blockSize;
}
} // namespace QtConcurrent } // namespace QtConcurrent
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -88,6 +88,32 @@ private:
Q_DISABLE_COPY(BlockSizeManager) Q_DISABLE_COPY(BlockSizeManager)
}; };
// ### Qt6: Replace BlockSizeManager with V2 implementation
class Q_CONCURRENT_EXPORT BlockSizeManagerV2
{
public:
explicit BlockSizeManagerV2(int iterationCount);
void timeBeforeUser();
void timeAfterUser();
int blockSize();
private:
inline bool blockSizeMaxed()
{
return (m_blockSize >= maxBlockSize);
}
const int maxBlockSize;
qint64 beforeUser;
qint64 afterUser;
MedianDouble controlPartElapsed;
MedianDouble userPartElapsed;
int m_blockSize;
Q_DISABLE_COPY(BlockSizeManagerV2)
};
template <typename T> template <typename T>
class ResultReporter class ResultReporter
{ {
@ -196,7 +222,7 @@ public:
ThreadFunctionResult forThreadFunction() ThreadFunctionResult forThreadFunction()
{ {
BlockSizeManager blockSizeManager(iterationCount); BlockSizeManagerV2 blockSizeManager(iterationCount);
ResultReporter<T> resultReporter(this); ResultReporter<T> resultReporter(this);
for(;;) { for(;;) {

View File

@ -127,6 +127,72 @@ private:
bool dirty; bool dirty;
}; };
// ### Qt6: Drop Median<double> in favor of this faster MedianDouble
class MedianDouble
{
public:
enum { BufferSize = 7 };
MedianDouble()
: currentMedian(), currentIndex(0), valid(false), dirty(true)
{
}
void reset()
{
std::fill_n(values, static_cast<int>(BufferSize), 0.0);
currentIndex = 0;
valid = false;
dirty = true;
}
void addValue(double value)
{
++currentIndex;
if (currentIndex == BufferSize) {
currentIndex = 0;
valid = true;
}
// Only update the cached median value when we have to, that
// is when the new value is on then other side of the median
// compared to the current value at the index.
const double currentIndexValue = values[currentIndex];
if ((currentIndexValue > currentMedian && currentMedian > value)
|| (currentMedian > currentIndexValue && value > currentMedian)) {
dirty = true;
}
values[currentIndex] = value;
}
bool isMedianValid() const
{
return valid;
}
double median()
{
if (dirty) {
dirty = false;
double sorted[BufferSize];
::memcpy(&sorted, &values, sizeof(sorted));
std::sort(sorted, sorted + static_cast<int>(BufferSize));
currentMedian = sorted[BufferSize / 2];
}
return currentMedian;
}
private:
double values[BufferSize];
double currentMedian;
int currentIndex;
bool valid;
bool dirty;
};
} // namespace QtConcurrent } // namespace QtConcurrent
#endif //Q_QDOC #endif //Q_QDOC

View File

@ -156,10 +156,9 @@ for (i = list.begin(); i != list.end(); ++i)
QList<QString> list; QList<QString> list;
list << "A" << "B" << "C" << "D"; list << "A" << "B" << "C" << "D";
QList<QString>::iterator i = list.end(); QList<QString>::reverse_iterator i;
while (i != list.begin()) { for (i = list.rbegin(); i != list.rend(); ++i)
--i; *i = i->toLower();
*i = (*i).toLower();
} }
//! [11] //! [11]

View File

@ -472,9 +472,7 @@
\image stliterators1.png \image stliterators1.png
Iterating backward with an STL-style iterator requires us to Iterating backward with an STL-style iterator is done with reverse iterators:
decrement the iterator \e before we access the item. This
requires a \c while loop:
\snippet code/doc_src_containers.cpp 11 \snippet code/doc_src_containers.cpp 11

View File

@ -937,8 +937,8 @@
// Older versions (QNX 650) do not support C++11 features // Older versions (QNX 650) do not support C++11 features
// _HAS_* macros are set to 1 by toolchains that actually include // _HAS_* macros are set to 1 by toolchains that actually include
// Dinkum C++11 libcpp. // Dinkum C++11 libcpp.
# if !__GLIBCXX__ # if !defined(__GLIBCXX__)
# if !_HAS_CPP0X # if !defined(_HAS_CPP0X) || !_HAS_CPP0X
// Disable C++11 features that depend on library support // Disable C++11 features that depend on library support
# undef Q_COMPILER_INITIALIZER_LISTS # undef Q_COMPILER_INITIALIZER_LISTS
# undef Q_COMPILER_RVALUE_REFS # undef Q_COMPILER_RVALUE_REFS
@ -946,10 +946,10 @@
# undef Q_COMPILER_UNICODE_STRINGS # undef Q_COMPILER_UNICODE_STRINGS
# undef Q_COMPILER_NOEXCEPT # undef Q_COMPILER_NOEXCEPT
# endif // !_HAS_CPP0X # endif // !_HAS_CPP0X
# if !_HAS_NULLPTR_T # if !defined(_HAS_NULLPTR_T) || !_HAS_NULLPTR_T
# undef Q_COMPILER_NULLPTR # undef Q_COMPILER_NULLPTR
# endif //!_HAS_NULLPTR_T # endif //!_HAS_NULLPTR_T
# if !_HAS_CONSTEXPR # if !defined(_HAS_CONSTEXPR) || !_HAS_CONSTEXPR
// The libcpp is missing constexpr keywords on important functions like std::numeric_limits<>::min() // The libcpp is missing constexpr keywords on important functions like std::numeric_limits<>::min()
// Disable constexpr support on QNX even if the compiler supports it // Disable constexpr support on QNX even if the compiler supports it
# undef Q_COMPILER_CONSTEXPR # undef Q_COMPILER_CONSTEXPR

View File

@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
* qt_version_tag symbol that is present in QtCore. Such symbol is versioned, * qt_version_tag symbol that is present in QtCore. Such symbol is versioned,
* so the linker will automatically pull the current Qt version and add it to * so the linker will automatically pull the current Qt version and add it to
* the ELF header of the library/application. The assembly produces one section * the ELF header of the library/application. The assembly produces one section
* called ".qtversion" containing two pointer-sized values. The first is a * called ".qtversion" containing two 32-bit values. The first is a
* relocation to the qt_version_tag symbol (which is what causes the ELF * relocation to the qt_version_tag symbol (which is what causes the ELF
* version to get used). The second value is the current Qt version at the time * version to get used). The second value is the current Qt version at the time
* of compilation. * of compilation.
@ -64,10 +64,12 @@ QT_BEGIN_NAMESPACE
// don't make tags in QtCore, bootstrapped systems or if the user asked not to // don't make tags in QtCore, bootstrapped systems or if the user asked not to
#elif defined(Q_CC_GNU) && !defined(Q_OS_ANDROID) #elif defined(Q_CC_GNU) && !defined(Q_OS_ANDROID)
# if defined(Q_PROCESSOR_X86) && (defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD_KERNEL)) # if defined(Q_PROCESSOR_X86) && (defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD_KERNEL))
# ifdef __LP64__ # if defined(Q_PROCESSOR_X86_64) // x86-64 or x32
# define QT_VERSION_TAG_RELOC(sym) ".quad " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOTPCREL\n" # if defined(__code_model_large__)
# elif defined(Q_PROCESSOR_X86_64) // x32 # define QT_VERSION_TAG_RELOC(sym) ".quad " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n"
# define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOTPCREL\n" # else
# define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOTPCREL\n"
# endif
# else // x86 # else // x86
# define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n" # define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n"
# endif # endif

View File

@ -158,7 +158,11 @@ inline void QDirPrivate::setPath(const QString &path)
if (p.endsWith(QLatin1Char('/')) if (p.endsWith(QLatin1Char('/'))
&& p.length() > 1 && p.length() > 1
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
# if defined (Q_OS_WINRT)
&& (!(p.toLower() == QDir::rootPath().toLower()))
# else
&& (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter())) && (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter()))
# endif
#endif #endif
) { ) {
p.truncate(p.length() - 1); p.truncate(p.length() - 1);
@ -891,6 +895,9 @@ bool QDir::cd(const QString &dirName)
#if defined (Q_OS_UNIX) #if defined (Q_OS_UNIX)
//After cleanPath() if path is "/.." or starts with "/../" it means trying to cd above root. //After cleanPath() if path is "/.." or starts with "/../" it means trying to cd above root.
if (newPath.startsWith(QLatin1String("/../")) || newPath == QLatin1String("/..")) if (newPath.startsWith(QLatin1String("/../")) || newPath == QLatin1String("/.."))
#elif defined (Q_OS_WINRT)
const QString rootPath = QDir::rootPath();
if (newPath.size() < rootPath.size() && rootPath.startsWith(newPath))
#else #else
/* /*
cleanPath() already took care of replacing '\' with '/'. cleanPath() already took care of replacing '\' with '/'.
@ -2193,7 +2200,11 @@ QString QDir::cleanPath(const QString &path)
// Strip away last slash except for root directories // Strip away last slash except for root directories
if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) { if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) {
#if defined (Q_OS_WIN) #if defined (Q_OS_WIN)
# if defined(Q_OS_WINRT)
if (!((ret.length() == 3 || ret.length() == QDir::rootPath().length()) && ret.at(1) == QLatin1Char(':')))
# else
if (!(ret.length() == 3 && ret.at(1) == QLatin1Char(':'))) if (!(ret.length() == 3 && ret.at(1) == QLatin1Char(':')))
# endif
#endif #endif
ret.chop(1); ret.chop(1);
} }

View File

@ -1101,7 +1101,7 @@ bool QFileInfo::isRoot() const
return true; return true;
if (d->fileEngine == 0) { if (d->fileEngine == 0) {
if (d->fileEntry.isRoot()) { if (d->fileEntry.isRoot()) {
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
//the path is a drive root, but the drive may not exist //the path is a drive root, but the drive may not exist
//for backward compatibility, return true only if the drive exists //for backward compatibility, return true only if the drive exists
if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute)) if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute))

View File

@ -84,6 +84,11 @@ using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::Foundation; using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Storage; using namespace ABI::Windows::Storage;
using namespace ABI::Windows::ApplicationModel; using namespace ABI::Windows::ApplicationModel;
#if _MSC_VER < 1900
#define Q_OS_WINRT_WIN81
#endif
#endif // Q_OS_WINRT #endif // Q_OS_WINRT
#ifndef SPI_GETPLATFORMTYPE #ifndef SPI_GETPLATFORMTYPE
@ -528,7 +533,7 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
{ {
// can be //server or //server/share // can be //server or //server/share
QString absPath; QString absPath;
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) #if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
QVarLengthArray<wchar_t, MAX_PATH> buf(qMax(MAX_PATH, path.size() + 1)); QVarLengthArray<wchar_t, MAX_PATH> buf(qMax(MAX_PATH, path.size() + 1));
wchar_t *fileName = 0; wchar_t *fileName = 0;
DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName); DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName);
@ -538,6 +543,16 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
} }
if (retLen != 0) if (retLen != 0)
absPath = QString::fromWCharArray(buf.data(), retLen); absPath = QString::fromWCharArray(buf.data(), retLen);
# if defined(Q_OS_WINRT)
// Win32 returns eg C:/ as root directory with a trailing /.
// WinRT returns the sandbox root without /.
// Also C:/../.. returns C:/ on Win32, while for WinRT it steps outside the package
// and goes beyond package root. Hence force the engine to stay inside
// the package.
const QString rootPath = QDir::toNativeSeparators(QDir::rootPath());
if (absPath.size() < rootPath.size() && rootPath.startsWith(absPath))
absPath = rootPath;
# endif // Q_OS_WINRT
#elif !defined(Q_OS_WINCE) #elif !defined(Q_OS_WINCE)
if (QDir::isRelativePath(path)) if (QDir::isRelativePath(path))
absPath = QDir::toNativeSeparators(QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + path)); absPath = QDir::toNativeSeparators(QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + path));
@ -575,7 +590,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
ret = entry.filePath(); ret = entry.filePath();
#endif #endif
} else { } else {
#ifndef Q_OS_WINRT #ifndef Q_OS_WINRT_WIN81
ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath()); ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath());
#else #else
// Some WinRT APIs do not support absolute paths (due to sandboxing). // Some WinRT APIs do not support absolute paths (due to sandboxing).
@ -1224,8 +1239,8 @@ QString QFileSystemEngine::rootPath()
if (FAILED(item->get_Path(finalWinPath.GetAddressOf()))) if (FAILED(item->get_Path(finalWinPath.GetAddressOf())))
return ret; return ret;
ret = QDir::fromNativeSeparators(QString::fromWCharArray(finalWinPath.GetRawBuffer(nullptr))); const QString qtWinPath = QDir::fromNativeSeparators(QString::fromWCharArray(finalWinPath.GetRawBuffer(nullptr)));
ret = qtWinPath.endsWith(QLatin1Char('/')) ? qtWinPath : qtWinPath + QLatin1Char('/');
#else #else
QString ret = QString::fromLatin1(qgetenv("SystemDrive")); QString ret = QString::fromLatin1(qgetenv("SystemDrive"));
if (ret.isEmpty()) if (ret.isEmpty())
@ -1343,7 +1358,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
if(!(meta.exists() && meta.isDirectory())) if(!(meta.exists() && meta.isDirectory()))
return false; return false;
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) #if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
//TODO: this should really be using nativeFilePath(), but that returns a path in long format \\?\c:\foo //TODO: this should really be using nativeFilePath(), but that returns a path in long format \\?\c:\foo
//which causes many problems later on when it's returned through currentPath() //which causes many problems later on when it's returned through currentPath()
return ::SetCurrentDirectory(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(entry.filePath()).utf16())) != 0; return ::SetCurrentDirectory(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(entry.filePath()).utf16())) != 0;
@ -1356,7 +1371,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
QFileSystemEntry QFileSystemEngine::currentPath() QFileSystemEntry QFileSystemEngine::currentPath()
{ {
QString ret; QString ret;
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) #if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
DWORD size = 0; DWORD size = 0;
wchar_t currentName[PATH_MAX]; wchar_t currentName[PATH_MAX];
size = ::GetCurrentDirectory(PATH_MAX, currentName); size = ::GetCurrentDirectory(PATH_MAX, currentName);
@ -1372,17 +1387,17 @@ QFileSystemEntry QFileSystemEngine::currentPath()
} }
if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters. ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
#else // !Q_OS_WINCE && !Q_OS_WINRT #else // !Q_OS_WINCE && !Q_OS_WINRT_WIN81
//TODO - a race condition exists when using currentPath / setCurrentPath from multiple threads //TODO - a race condition exists when using currentPath / setCurrentPath from multiple threads
if (qfsPrivateCurrentDir.isEmpty()) if (qfsPrivateCurrentDir.isEmpty())
#ifndef Q_OS_WINRT #ifndef Q_OS_WINRT_WIN81
qfsPrivateCurrentDir = QCoreApplication::applicationDirPath(); qfsPrivateCurrentDir = QCoreApplication::applicationDirPath();
#else #else
qfsPrivateCurrentDir = QDir::rootPath(); qfsPrivateCurrentDir = QDir::rootPath();
#endif #endif
ret = qfsPrivateCurrentDir; ret = qfsPrivateCurrentDir;
#endif // Q_OS_WINCE || Q_OS_WINRT #endif // Q_OS_WINCE || Q_OS_WINRT_WIN81
return QFileSystemEntry(ret, QFileSystemEntry::FromNativePath()); return QFileSystemEntry(ret, QFileSystemEntry::FromNativePath());
} }

View File

@ -172,6 +172,12 @@ void QFileSystemEntry::resolveNativeFilePath() const
m_nativeFilePath.remove(0,1); m_nativeFilePath.remove(0,1);
if (m_nativeFilePath.isEmpty()) if (m_nativeFilePath.isEmpty())
m_nativeFilePath.append(QLatin1Char('.')); m_nativeFilePath.append(QLatin1Char('.'));
// WinRT/MSVC2015 allows a maximum of 256 characters for a filepath
// unless //?/ is prepended which extends the rule to have a maximum
// of 256 characters in the filename plus the preprending path
#if _MSC_VER >= 1900
m_nativeFilePath.prepend("\\\\?\\");
#endif
#endif #endif
} }
} }
@ -289,9 +295,13 @@ bool QFileSystemEntry::isAbsolute() const
bool QFileSystemEntry::isDriveRoot() const bool QFileSystemEntry::isDriveRoot() const
{ {
resolveFilePath(); resolveFilePath();
#ifndef Q_OS_WINRT
return (m_filePath.length() == 3 return (m_filePath.length() == 3
&& m_filePath.at(0).isLetter() && m_filePath.at(1) == QLatin1Char(':') && m_filePath.at(0).isLetter() && m_filePath.at(1) == QLatin1Char(':')
&& m_filePath.at(2) == QLatin1Char('/')); && m_filePath.at(2) == QLatin1Char('/'));
#else // !Q_OS_WINRT
return m_filePath == QDir::rootPath();
#endif // !Q_OS_WINRT
} }
#endif #endif

View File

@ -73,7 +73,8 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi
if (!nativePath.endsWith(QLatin1Char('\\'))) if (!nativePath.endsWith(QLatin1Char('\\')))
nativePath.append(QLatin1Char('\\')); nativePath.append(QLatin1Char('\\'));
nativePath.append(QLatin1Char('*')); nativePath.append(QLatin1Char('*'));
#ifdef Q_OS_WINRT // In MSVC2015+ case we prepend //?/ for longer file-name support
#if defined(Q_OS_WINRT) && _MSC_VER < 1900
if (nativePath.startsWith(QLatin1Char('\\'))) if (nativePath.startsWith(QLatin1Char('\\')))
nativePath.remove(0, 1); nativePath.remove(0, 1);
#endif #endif

View File

@ -1043,7 +1043,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
offsetHi, offsetLo, size + extra); offsetHi, offsetLo, size + extra);
#else #else
LPVOID mapAddress = ::MapViewOfFileFromApp(mapHandle, access, LPVOID mapAddress = ::MapViewOfFileFromApp(mapHandle, access,
(ULONG64(offsetHi) << 32) + offsetLo, size); (ULONG64(offsetHi) << 32) + offsetLo, size + extra);
#endif #endif
if (mapAddress) { if (mapAddress) {
uchar *address = extra + static_cast<uchar*>(mapAddress); uchar *address = extra + static_cast<uchar*>(mapAddress);

View File

@ -183,16 +183,18 @@ void QCoreApplicationPrivate::processCommandLineArguments()
{ {
int j = argc ? 1 : 0; int j = argc ? 1 : 0;
for (int i = 1; i < argc; ++i) { for (int i = 1; i < argc; ++i) {
if (argv[i] && *argv[i] != '-') { if (!argv[i])
continue;
if (*argv[i] != '-') {
argv[j++] = argv[i]; argv[j++] = argv[i];
continue; continue;
} }
QByteArray arg = argv[i]; const char *arg = argv[i];
if (arg.startsWith("--")) if (arg[1] == '-') // startsWith("--")
arg.remove(0, 1); ++arg;
if (arg.startsWith("-qmljsdebugger=")) { if (strncmp(arg, "-qmljsdebugger=", 15) == 0) {
qmljs_debug_arguments = QString::fromLocal8Bit(arg.right(arg.length() - 15)); qmljs_debug_arguments = QString::fromLocal8Bit(arg + 15);
} else if (arg == "-qmljsdebugger" && i < argc - 1) { } else if (strcmp(arg, "-qmljsdebugger") == 0 && i < argc - 1) {
++i; ++i;
qmljs_debug_arguments = QString::fromLocal8Bit(argv[i]); qmljs_debug_arguments = QString::fromLocal8Bit(argv[i]);
} else { } else {

View File

@ -2706,10 +2706,11 @@ qint64 QDateTimePrivate::toMSecsSinceEpoch() const
} }
case Qt::TimeZone: case Qt::TimeZone:
#ifndef QT_BOOTSTRAPPED #ifdef QT_BOOTSTRAPPED
break;
#else
return zoneMSecsToEpochMSecs(m_msecs, m_timeZone); return zoneMSecsToEpochMSecs(m_msecs, m_timeZone);
#endif #endif
break;
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
return 0; return 0;
@ -3206,7 +3207,9 @@ QString QDateTime::timeZoneAbbreviation() const
case Qt::OffsetFromUTC: case Qt::OffsetFromUTC:
return QTimeZonePrivate::utcQString() + toOffsetString(Qt::ISODate, d->m_offsetFromUtc); return QTimeZonePrivate::utcQString() + toOffsetString(Qt::ISODate, d->m_offsetFromUtc);
case Qt::TimeZone: case Qt::TimeZone:
#ifndef QT_BOOTSTRAPPED #ifdef QT_BOOTSTRAPPED
break;
#else
return d->m_timeZone.d->abbreviation(d->toMSecsSinceEpoch()); return d->m_timeZone.d->abbreviation(d->toMSecsSinceEpoch());
#endif // QT_BOOTSTRAPPED #endif // QT_BOOTSTRAPPED
case Qt::LocalTime: { case Qt::LocalTime: {
@ -3237,7 +3240,9 @@ bool QDateTime::isDaylightTime() const
case Qt::OffsetFromUTC: case Qt::OffsetFromUTC:
return false; return false;
case Qt::TimeZone: case Qt::TimeZone:
#ifndef QT_BOOTSTRAPPED #ifdef QT_BOOTSTRAPPED
break;
#else
return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch()); return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch());
#endif // QT_BOOTSTRAPPED #endif // QT_BOOTSTRAPPED
case Qt::LocalTime: { case Qt::LocalTime: {
@ -4829,10 +4834,8 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)
out << (qint8)QDateTimePrivate::OffsetFromUTC; out << (qint8)QDateTimePrivate::OffsetFromUTC;
break; break;
case Qt::TimeZone: case Qt::TimeZone:
#ifndef QT_BOOTSTRAPPED
out << (qint8)QDateTimePrivate::TimeZone; out << (qint8)QDateTimePrivate::TimeZone;
break; break;
#endif // QT_BOOTSTRAPPED
case Qt::LocalTime: case Qt::LocalTime:
out << (qint8)QDateTimePrivate::LocalUnknown; out << (qint8)QDateTimePrivate::LocalUnknown;
break; break;
@ -4905,10 +4908,11 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime)
spec = Qt::OffsetFromUTC; spec = Qt::OffsetFromUTC;
break; break;
case QDateTimePrivate::TimeZone: case QDateTimePrivate::TimeZone:
#ifndef QT_BOOTSTRAPPED
spec = Qt::TimeZone; spec = Qt::TimeZone;
#ifndef QT_BOOTSTRAPPED
// FIXME: need to use a different constructor !
#endif
break; break;
#endif // QT_BOOTSTRAPPED
case QDateTimePrivate::LocalUnknown: case QDateTimePrivate::LocalUnknown:
case QDateTimePrivate::LocalStandard: case QDateTimePrivate::LocalStandard:
case QDateTimePrivate::LocalDST: case QDateTimePrivate::LocalDST:
@ -4964,8 +4968,8 @@ QDebug operator<<(QDebug dbg, const QDateTime &date)
case Qt::TimeZone: case Qt::TimeZone:
#ifndef QT_BOOTSTRAPPED #ifndef QT_BOOTSTRAPPED
dbg << ' ' << date.timeZone().id(); dbg << ' ' << date.timeZone().id();
break;
#endif // QT_BOOTSTRAPPED #endif // QT_BOOTSTRAPPED
break;
case Qt::LocalTime: case Qt::LocalTime:
break; break;
} }

View File

@ -5733,37 +5733,42 @@ static QString detachAndConvertCase(T &str, QStringIterator it)
Q_ASSERT(!str.isEmpty()); Q_ASSERT(!str.isEmpty());
QString s = qMove(str); // will copy if T is const QString QString s = qMove(str); // will copy if T is const QString
QChar *pp = s.begin() + it.index(); // will detach if necessary QChar *pp = s.begin() + it.index(); // will detach if necessary
uint uc = it.nextUnchecked();
forever { do {
uint uc = it.nextUnchecked();
const QUnicodeTables::Properties *prop = qGetProp(uc); const QUnicodeTables::Properties *prop = qGetProp(uc);
signed short caseDiff = Traits::caseDiff(prop); signed short caseDiff = Traits::caseDiff(prop);
if (Q_UNLIKELY(Traits::caseSpecial(prop))) { if (Q_UNLIKELY(Traits::caseSpecial(prop))) {
// slow path: the string is growing
const ushort *specialCase = specialCaseMap + caseDiff; const ushort *specialCase = specialCaseMap + caseDiff;
ushort length = *specialCase++; ushort length = *specialCase++;
int inpos = it.index() - 1;
int outpos = pp - s.constBegin();
s.replace(outpos, 1, reinterpret_cast<const QChar *>(specialCase), length); if (Q_LIKELY(length == 1)) {
pp = const_cast<QChar *>(s.constBegin()) + outpos + length; *pp++ = QChar(*specialCase);
} else {
// slow path: the string is growing
int inpos = it.index() - 1;
int outpos = pp - s.constBegin();
// do we need to adjust the input iterator too? s.replace(outpos, 1, reinterpret_cast<const QChar *>(specialCase), length);
// if it is pointing to s's data, str is empty pp = const_cast<QChar *>(s.constBegin()) + outpos + length;
if (str.isEmpty())
it = QStringIterator(s.constBegin(), inpos + length, s.constEnd()); // do we need to adjust the input iterator too?
} else if (QChar::requiresSurrogates(uc)) { // if it is pointing to s's data, str is empty
*pp++ = QChar::highSurrogate(uc + caseDiff); if (str.isEmpty())
it = QStringIterator(s.constBegin(), inpos + length, s.constEnd());
}
} else if (Q_UNLIKELY(QChar::requiresSurrogates(uc))) {
// so far, case convertion never changes planes (guaranteed by the qunicodetables generator)
pp++;
*pp++ = QChar::lowSurrogate(uc + caseDiff); *pp++ = QChar::lowSurrogate(uc + caseDiff);
} else { } else {
*pp++ = QChar(uc + caseDiff); *pp++ = QChar(uc + caseDiff);
} }
} while (it.hasNext());
if (!it.hasNext()) return s;
return s;
uc = it.nextUnchecked();
}
} }
template <typename Traits, typename T> template <typename Traits, typename T>
@ -5776,12 +5781,13 @@ static QString convertCase(T &str)
while (e != p && e[-1].isHighSurrogate()) while (e != p && e[-1].isHighSurrogate())
--e; --e;
const QUnicodeTables::Properties *prop;
QStringIterator it(p, e); QStringIterator it(p, e);
for ( ; it.hasNext(); it.advanceUnchecked()) { while (it.hasNext()) {
prop = qGetProp(it.peekNextUnchecked()); uint uc = it.nextUnchecked();
if (Traits::caseDiff(prop)) if (Traits::caseDiff(qGetProp(uc))) {
it.recedeUnchecked();
return detachAndConvertCase<Traits>(str, it); return detachAndConvertCase<Traits>(str, it);
}
} }
return qMove(str); return qMove(str);
} }

View File

@ -286,6 +286,7 @@ private slots:
signals: signals:
void dispatchStatusChanged(); void dispatchStatusChanged();
void spyHooksFinished(const QDBusMessage &msg);
void messageNeedsSending(QDBusPendingCallPrivate *pcall, void *msg, int timeout = -1); void messageNeedsSending(QDBusPendingCallPrivate *pcall, void *msg, int timeout = -1);
void signalNeedsConnecting(const QString &key, const QDBusConnectionPrivate::SignalHook &hook); void signalNeedsConnecting(const QString &key, const QDBusConnectionPrivate::SignalHook &hook);
bool signalNeedsDisconnecting(const QString &key, const QDBusConnectionPrivate::SignalHook &hook); bool signalNeedsDisconnecting(const QString &key, const QDBusConnectionPrivate::SignalHook &hook);

View File

@ -126,8 +126,7 @@ void qdbusDefaultThreadDebug(int action, int condition, QDBusConnectionPrivate *
qdbusThreadDebugFunc qdbusThreadDebug = 0; qdbusThreadDebugFunc qdbusThreadDebug = 0;
#endif #endif
typedef void (*QDBusSpyHook)(const QDBusMessage&); typedef QVarLengthArray<QDBusSpyCallEvent::Hook, 4> QDBusSpyHookList;
typedef QVarLengthArray<QDBusSpyHook, 4> QDBusSpyHookList;
Q_GLOBAL_STATIC(QDBusSpyHookList, qDBusSpyHookList) Q_GLOBAL_STATIC(QDBusSpyHookList, qDBusSpyHookList)
extern "C" { extern "C" {
@ -467,12 +466,29 @@ static QStringList matchArgsForService(const QString &service, QDBusServiceWatch
} }
extern Q_DBUS_EXPORT void qDBusAddSpyHook(QDBusSpyHook); extern Q_DBUS_EXPORT void qDBusAddSpyHook(QDBusSpyCallEvent::Hook);
void qDBusAddSpyHook(QDBusSpyHook hook) void qDBusAddSpyHook(QDBusSpyCallEvent::Hook hook)
{ {
qDBusSpyHookList()->append(hook); qDBusSpyHookList()->append(hook);
} }
QDBusSpyCallEvent::~QDBusSpyCallEvent()
{
// Reinsert the message into the processing queue for the connection.
// This is done in the destructor so the message is reinserted even if
// QCoreApplication is destroyed.
QDBusConnectionPrivate *d = static_cast<QDBusConnectionPrivate *>(const_cast<QObject *>(sender()));
qDBusDebug() << d << "message spies done for" << msg;
emit d->spyHooksFinished(msg);
}
void QDBusSpyCallEvent::placeMetaCall(QObject *)
{
// call the spy hook list
for (int i = 0; i < hookCount; ++i)
hooks[i](msg);
}
extern "C" { extern "C" {
static DBusHandlerResult static DBusHandlerResult
qDBusSignalFilter(DBusConnection *connection, DBusMessage *message, void *data) qDBusSignalFilter(DBusConnection *connection, DBusMessage *message, void *data)
@ -494,16 +510,11 @@ qDBusSignalFilter(DBusConnection *connection, DBusMessage *message, void *data)
bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg) bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg)
{ {
const QDBusSpyHookList *list = qDBusSpyHookList();
for (int i = 0; list && i < list->size(); ++i) {
qDBusDebug() << "calling the message spy hook";
(*(*list)[i])(amsg);
}
if (!ref.load()) if (!ref.load())
return false; return false;
if (!dispatchEnabled && !QDBusMessagePrivate::isLocal(amsg)) { if (!dispatchEnabled && !QDBusMessagePrivate::isLocal(amsg)) {
// queue messages only, we'll handle them later // queue messages only, we'll handle them later
qDBusDebug() << this << "delivery is suspended";
pendingMessages << amsg; pendingMessages << amsg;
return amsg.type() == QDBusMessage::MethodCallMessage; return amsg.type() == QDBusMessage::MethodCallMessage;
} }
@ -515,6 +526,15 @@ bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg)
// let them see the signal too // let them see the signal too
return false; return false;
case QDBusMessage::MethodCallMessage: case QDBusMessage::MethodCallMessage:
// run it through the spy filters (if any) before the regular processing
if (Q_UNLIKELY(qDBusSpyHookList.exists()) && qApp) {
const QDBusSpyHookList &list = *qDBusSpyHookList;
qDBusDebug() << this << "invoking message spies";
QCoreApplication::postEvent(qApp, new QDBusSpyCallEvent(this, QDBusConnection(this),
amsg, list.constData(), list.size()));
return true;
}
handleObjectCall(amsg); handleObjectCall(amsg);
return true; return true;
case QDBusMessage::ReplyMessage: case QDBusMessage::ReplyMessage:
@ -986,6 +1006,8 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
QDBusMetaTypeId::init(); QDBusMetaTypeId::init();
connect(this, &QDBusConnectionPrivate::dispatchStatusChanged, connect(this, &QDBusConnectionPrivate::dispatchStatusChanged,
this, &QDBusConnectionPrivate::doDispatch, Qt::QueuedConnection); this, &QDBusConnectionPrivate::doDispatch, Qt::QueuedConnection);
connect(this, &QDBusConnectionPrivate::spyHooksFinished,
this, &QDBusConnectionPrivate::handleObjectCall, Qt::QueuedConnection);
connect(this, &QDBusConnectionPrivate::messageNeedsSending, connect(this, &QDBusConnectionPrivate::messageNeedsSending,
this, &QDBusConnectionPrivate::sendInternal); this, &QDBusConnectionPrivate::sendInternal);
connect(this, &QDBusConnectionPrivate::signalNeedsConnecting, connect(this, &QDBusConnectionPrivate::signalNeedsConnecting,
@ -1097,8 +1119,10 @@ void QDBusConnectionPrivate::doDispatch()
// dispatch previously queued messages // dispatch previously queued messages
PendingMessageList::Iterator it = pendingMessages.begin(); PendingMessageList::Iterator it = pendingMessages.begin();
PendingMessageList::Iterator end = pendingMessages.end(); PendingMessageList::Iterator end = pendingMessages.end();
for ( ; it != end; ++it) for ( ; it != end; ++it) {
qDBusDebug() << this << "dequeueing message" << *it;
handleMessage(qMove(*it)); handleMessage(qMove(*it));
}
pendingMessages.clear(); pendingMessages.clear();
} }
} }

View File

@ -1,6 +1,7 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtDBus module of the Qt Toolkit. ** This file is part of the QtDBus module of the Qt Toolkit.
@ -71,6 +72,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDBusConnectionPrivate; class QDBusConnectionPrivate;
class QDBusMessage;
// Really private structs used by qdbusintegrator.cpp // Really private structs used by qdbusintegrator.cpp
// Things that aren't used by any other file // Things that aren't used by any other file
@ -139,6 +141,23 @@ private:
bool handled; bool handled;
}; };
class QDBusSpyCallEvent : public QMetaCallEvent
{
public:
typedef void (*Hook)(const QDBusMessage&);
QDBusSpyCallEvent(QDBusConnectionPrivate *cp, const QDBusConnection &c, const QDBusMessage &msg,
const Hook *hooks, int count)
: QMetaCallEvent(0, 0, Q_NULLPTR, cp, 0), conn(c), msg(msg), hooks(hooks), hookCount(count)
{}
~QDBusSpyCallEvent();
void placeMetaCall(QObject *) Q_DECL_OVERRIDE;
QDBusConnection conn; // keeps the refcount in QDBusConnectionPrivate up
QDBusMessage msg;
const Hook *hooks;
int hookCount;
};
QT_END_NAMESPACE QT_END_NAMESPACE
Q_DECLARE_METATYPE(QDBusSlotCache) Q_DECLARE_METATYPE(QDBusSlotCache)

View File

@ -1220,30 +1220,32 @@ void QGuiApplicationPrivate::createPlatformIntegration()
int j = argc ? 1 : 0; int j = argc ? 1 : 0;
for (int i=1; i<argc; i++) { for (int i=1; i<argc; i++) {
if (argv[i] && *argv[i] != '-') { if (!argv[i])
continue;
if (*argv[i] != '-') {
argv[j++] = argv[i]; argv[j++] = argv[i];
continue; continue;
} }
const bool isXcb = platformName == "xcb"; const bool isXcb = platformName == "xcb";
QByteArray arg = argv[i]; const char *arg = argv[i];
if (arg.startsWith("--")) if (arg[1] == '-') // startsWith("--")
arg.remove(0, 1); ++arg;
if (arg == "-platformpluginpath") { if (strcmp(arg, "-platformpluginpath") == 0) {
if (++i < argc) if (++i < argc)
platformPluginPath = QString::fromLocal8Bit(argv[i]); platformPluginPath = QString::fromLocal8Bit(argv[i]);
} else if (arg == "-platform") { } else if (strcmp(arg, "-platform") == 0) {
if (++i < argc) if (++i < argc)
platformName = argv[i]; platformName = argv[i];
} else if (arg == "-platformtheme") { } else if (strcmp(arg, "-platformtheme") == 0) {
if (++i < argc) if (++i < argc)
platformThemeName = QString::fromLocal8Bit(argv[i]); platformThemeName = QString::fromLocal8Bit(argv[i]);
} else if (arg == "-qwindowgeometry" || (isXcb && arg == "-geometry")) { } else if (strcmp(arg, "-qwindowgeometry") == 0 || (isXcb && strcmp(arg, "-geometry") == 0)) {
if (++i < argc) if (++i < argc)
windowGeometrySpecification = QWindowGeometrySpecification::fromArgument(argv[i]); windowGeometrySpecification = QWindowGeometrySpecification::fromArgument(argv[i]);
} else if (arg == "-qwindowtitle" || (isXcb && arg == "-title")) { } else if (strcmp(arg, "-qwindowtitle") == 0 || (isXcb && strcmp(arg, "-title") == 0)) {
if (++i < argc) if (++i < argc)
firstWindowTitle = QString::fromLocal8Bit(argv[i]); firstWindowTitle = QString::fromLocal8Bit(argv[i]);
} else if (arg == "-qwindowicon" || (isXcb && arg == "-icon")) { } else if (strcmp(arg, "-qwindowicon") == 0 || (isXcb && strcmp(arg, "-icon") == 0)) {
if (++i < argc) { if (++i < argc) {
icon = QString::fromLocal8Bit(argv[i]); icon = QString::fromLocal8Bit(argv[i]);
} }
@ -1319,20 +1321,22 @@ void QGuiApplicationPrivate::init()
QString s; QString s;
int j = argc ? 1 : 0; int j = argc ? 1 : 0;
for (int i=1; i<argc; i++) { for (int i=1; i<argc; i++) {
if (argv[i] && *argv[i] != '-') { if (!argv[i])
continue;
if (*argv[i] != '-') {
argv[j++] = argv[i]; argv[j++] = argv[i];
continue; continue;
} }
QByteArray arg = argv[i]; const char *arg = argv[i];
if (arg.startsWith("--")) if (arg[1] == '-') // startsWith("--")
arg.remove(0, 1); ++arg;
if (arg == "-plugin") { if (strcmp(arg, "-plugin") == 0) {
if (++i < argc) if (++i < argc)
pluginList << argv[i]; pluginList << argv[i];
} else if (arg == "-reverse") { } else if (strcmp(arg, "-reverse") == 0) {
force_reverse = true; force_reverse = true;
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
} else if (arg.startsWith("-psn_")) { } else if (strncmp(arg, "-psn_", 5) == 0) {
// eat "-psn_xxxx" on Mac, which is passed when starting an app from Finder. // eat "-psn_xxxx" on Mac, which is passed when starting an app from Finder.
// special hack to change working directory (for an app bundle) when running from finder // special hack to change working directory (for an app bundle) when running from finder
if (QDir::currentPath() == QLatin1String("/")) { if (QDir::currentPath() == QLatin1String("/")) {
@ -1344,7 +1348,7 @@ void QGuiApplicationPrivate::init()
} }
#endif #endif
#ifndef QT_NO_SESSIONMANAGER #ifndef QT_NO_SESSIONMANAGER
} else if (arg == "-session" && i < argc-1) { } else if (strcmp(arg, "-session") == 0 && i < argc - 1) {
++i; ++i;
if (argv[i] && *argv[i]) { if (argv[i] && *argv[i]) {
session_id = QString::fromLatin1(argv[i]); session_id = QString::fromLatin1(argv[i]);
@ -1356,11 +1360,11 @@ void QGuiApplicationPrivate::init()
is_session_restored = true; is_session_restored = true;
} }
#endif #endif
} else if (arg == "-testability") { } else if (strcmp(arg, "-testability") == 0) {
loadTestability = true; loadTestability = true;
} else if (arg.indexOf("-style=", 0) != -1) { } else if (strncmp(arg, "-style=", 7) == 0) {
s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower()); s = QString::fromLocal8Bit(arg + 7).toLower();
} else if (arg == "-style" && i < argc-1) { } else if (strcmp(arg, "-style") == 0 && i < argc - 1) {
s = QString::fromLocal8Bit(argv[++i]).toLower(); s = QString::fromLocal8Bit(argv[++i]).toLower();
} else { } else {
argv[j++] = argv[i]; argv[j++] = argv[i];

View File

@ -238,6 +238,7 @@ bool QPlatformGraphicsBufferHelper::bindSWToTexture(const QPlatformGraphicsBuffe
#else #else
Q_UNUSED(graphicsBuffer) Q_UNUSED(graphicsBuffer)
Q_UNUSED(swizzleRandB) Q_UNUSED(swizzleRandB)
Q_UNUSED(premultipliedB)
Q_UNUSED(subRect) Q_UNUSED(subRect)
return false; return false;
#endif // QT_NO_OPENGL #endif // QT_NO_OPENGL

View File

@ -99,13 +99,6 @@ QOpenGL2PaintEngineExPrivate::~QOpenGL2PaintEngineExPrivate()
{ {
delete shaderManager; delete shaderManager;
while (pathCaches.size()) {
QVectorPath::CacheEntry *e = *(pathCaches.constBegin());
e->cleanup(e->engine, e->data);
e->data = 0;
e->engine = 0;
}
if (elementIndicesVBOId != 0) { if (elementIndicesVBOId != 0) {
funcs.glDeleteBuffers(1, &elementIndicesVBOId); funcs.glDeleteBuffers(1, &elementIndicesVBOId);
elementIndicesVBOId = 0; elementIndicesVBOId = 0;
@ -298,8 +291,6 @@ void QOpenGL2PaintEngineExPrivate::updateBrushTexture()
} }
updateTexture(QT_BRUSH_TEXTURE_UNIT, currentBrushImage, wrapMode, filterMode, ForceUpdate); updateTexture(QT_BRUSH_TEXTURE_UNIT, currentBrushImage, wrapMode, filterMode, ForceUpdate);
textureInvertedY = false;
} }
brushTextureDirty = false; brushTextureDirty = false;
} }
@ -415,11 +406,7 @@ void QOpenGL2PaintEngineExPrivate::updateBrushUniforms()
dy = 0; dy = 0;
} }
QTransform gl_to_qt(1, 0, 0, m22, 0, dy); QTransform gl_to_qt(1, 0, 0, m22, 0, dy);
QTransform inv_matrix; QTransform inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate;
if (style == Qt::TexturePattern && textureInvertedY == -1)
inv_matrix = gl_to_qt * (QTransform(1, 0, 0, -1, 0, currentBrush.texture().height()) * brushQTransform * matrix).inverted() * translate;
else
inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate;
shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::BrushTransform), inv_matrix); shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::BrushTransform), inv_matrix);
shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::BrushTexture), QT_BRUSH_TEXTURE_UNIT); shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::BrushTexture), QT_BRUSH_TEXTURE_UNIT);

View File

@ -315,14 +315,9 @@ public:
bool needsSync; bool needsSync;
bool multisamplingAlwaysEnabled; bool multisamplingAlwaysEnabled;
GLfloat depthRange[2];
float textureInvertedY;
QTriangulatingStroker stroker; QTriangulatingStroker stroker;
QDashedStrokeProcessor dasher; QDashedStrokeProcessor dasher;
QSet<QVectorPath::CacheEntry *> pathCaches;
QVector<GLuint> unusedVBOSToClean; QVector<GLuint> unusedVBOSToClean;
QVector<GLuint> unusedIBOSToClean; QVector<GLuint> unusedIBOSToClean;

View File

@ -391,7 +391,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
// The backingstore is for the entire tlw. // The backingstore is for the entire tlw.
// In case of native children offset tells the position relative to the tlw. // In case of native children offset tells the position relative to the tlw.
const QRect srcRect = toBottomLeftRect(deviceWindowRect.translated(offset), d_ptr->textureSize.height()); const QRect srcRect = toBottomLeftRect(deviceWindowRect.translated(offset), d_ptr->textureSize.height());
const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(deviceRect(srcRect, window), const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(srcRect,
d_ptr->textureSize, d_ptr->textureSize,
origin); origin);
d_ptr->blitter->blit(textureId, QMatrix4x4(), source); d_ptr->blitter->blit(textureId, QMatrix4x4(), source);

View File

@ -195,65 +195,65 @@ private:
mutable int fast_glyph_count; mutable int fast_glyph_count;
}; };
virtual QFontEngine::FaceId faceId() const Q_DECL_OVERRIDE; QFontEngine::FaceId faceId() const Q_DECL_OVERRIDE;
virtual QFontEngine::Properties properties() const Q_DECL_OVERRIDE; QFontEngine::Properties properties() const Q_DECL_OVERRIDE;
virtual QFixed emSquareSize() const Q_DECL_OVERRIDE; QFixed emSquareSize() const Q_DECL_OVERRIDE;
virtual bool supportsSubPixelPositions() const Q_DECL_OVERRIDE bool supportsSubPixelPositions() const Q_DECL_OVERRIDE
{ {
return default_hint_style == HintLight || return default_hint_style == HintLight ||
default_hint_style == HintNone; default_hint_style == HintNone;
} }
virtual bool getSfntTableData(uint tag, uchar *buffer, uint *length) const Q_DECL_OVERRIDE; bool getSfntTableData(uint tag, uchar *buffer, uint *length) const Q_DECL_OVERRIDE;
virtual int synthesized() const Q_DECL_OVERRIDE; int synthesized() const Q_DECL_OVERRIDE;
virtual QFixed ascent() const Q_DECL_OVERRIDE; QFixed ascent() const Q_DECL_OVERRIDE;
virtual QFixed descent() const Q_DECL_OVERRIDE; QFixed descent() const Q_DECL_OVERRIDE;
virtual QFixed leading() const Q_DECL_OVERRIDE; QFixed leading() const Q_DECL_OVERRIDE;
virtual QFixed xHeight() const Q_DECL_OVERRIDE; QFixed xHeight() const Q_DECL_OVERRIDE;
virtual QFixed averageCharWidth() const Q_DECL_OVERRIDE; QFixed averageCharWidth() const Q_DECL_OVERRIDE;
virtual qreal maxCharWidth() const Q_DECL_OVERRIDE; qreal maxCharWidth() const Q_DECL_OVERRIDE;
virtual QFixed lineThickness() const Q_DECL_OVERRIDE; QFixed lineThickness() const Q_DECL_OVERRIDE;
virtual QFixed underlinePosition() const Q_DECL_OVERRIDE; QFixed underlinePosition() const Q_DECL_OVERRIDE;
virtual glyph_t glyphIndex(uint ucs4) const Q_DECL_OVERRIDE; glyph_t glyphIndex(uint ucs4) const Q_DECL_OVERRIDE;
void doKerning(QGlyphLayout *, ShaperFlags) const Q_DECL_OVERRIDE; void doKerning(QGlyphLayout *, ShaperFlags) const Q_DECL_OVERRIDE;
virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) Q_DECL_OVERRIDE; void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) Q_DECL_OVERRIDE;
virtual bool supportsTransformation(const QTransform &transform) const Q_DECL_OVERRIDE; bool supportsTransformation(const QTransform &transform) const Q_DECL_OVERRIDE;
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE; QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE;
virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs,
QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE; QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE;
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const Q_DECL_OVERRIDE; bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const Q_DECL_OVERRIDE;
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) Q_DECL_OVERRIDE; glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) Q_DECL_OVERRIDE;
virtual glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE; glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE;
virtual glyph_metrics_t boundingBox(glyph_t glyph, const QTransform &matrix) Q_DECL_OVERRIDE; glyph_metrics_t boundingBox(glyph_t glyph, const QTransform &matrix) Q_DECL_OVERRIDE;
virtual void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags flags) const Q_DECL_OVERRIDE; void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags flags) const Q_DECL_OVERRIDE;
virtual QImage alphaMapForGlyph(glyph_t g) Q_DECL_OVERRIDE { return alphaMapForGlyph(g, 0); } QImage alphaMapForGlyph(glyph_t g) Q_DECL_OVERRIDE { return alphaMapForGlyph(g, 0); }
virtual QImage alphaMapForGlyph(glyph_t, QFixed) Q_DECL_OVERRIDE; QImage alphaMapForGlyph(glyph_t, QFixed) Q_DECL_OVERRIDE;
QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE; QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE;
virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE; QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE;
virtual glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, glyph_metrics_t alphaMapBoundingBox(glyph_t glyph,
QFixed subPixelPosition, QFixed subPixelPosition,
const QTransform &matrix, const QTransform &matrix,
QFontEngine::GlyphFormat format) Q_DECL_OVERRIDE; QFontEngine::GlyphFormat format) Q_DECL_OVERRIDE;
virtual QImage *lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, QImage *lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition,
GlyphFormat neededFormat, const QTransform &t, GlyphFormat neededFormat, const QTransform &t,
QPoint *offset) Q_DECL_OVERRIDE; QPoint *offset) Q_DECL_OVERRIDE;
virtual bool hasInternalCaching() const Q_DECL_OVERRIDE { return cacheEnabled; } bool hasInternalCaching() const Q_DECL_OVERRIDE { return cacheEnabled; }
virtual void unlockAlphaMapForGlyph() Q_DECL_OVERRIDE; void unlockAlphaMapForGlyph() Q_DECL_OVERRIDE;
virtual void removeGlyphFromCache(glyph_t glyph) Q_DECL_OVERRIDE; void removeGlyphFromCache(glyph_t glyph) Q_DECL_OVERRIDE;
virtual int glyphMargin(QFontEngine::GlyphFormat /* format */) Q_DECL_OVERRIDE { return 0; } int glyphMargin(QFontEngine::GlyphFormat /* format */) Q_DECL_OVERRIDE { return 0; }
virtual int glyphCount() const Q_DECL_OVERRIDE; int glyphCount() const Q_DECL_OVERRIDE;
enum Scaling { enum Scaling {
Scaled, Scaled,
@ -283,12 +283,12 @@ private:
bool init(FaceId faceId, bool antialias, GlyphFormat format, bool init(FaceId faceId, bool antialias, GlyphFormat format,
QFreetypeFace *freetypeFace); QFreetypeFace *freetypeFace);
virtual int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints) Q_DECL_OVERRIDE; int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints) Q_DECL_OVERRIDE;
void setQtDefaultHintStyle(QFont::HintingPreference hintingPreference); void setQtDefaultHintStyle(QFont::HintingPreference hintingPreference);
virtual void setDefaultHintStyle(HintStyle style) Q_DECL_OVERRIDE; void setDefaultHintStyle(HintStyle style) Q_DECL_OVERRIDE;
virtual QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE; QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE;
bool initFromFontEngine(const QFontEngineFT *fontEngine); bool initFromFontEngine(const QFontEngineFT *fontEngine);
HintStyle defaultHintStyle() const { return default_hint_style; } HintStyle defaultHintStyle() const { return default_hint_style; }

View File

@ -1078,8 +1078,8 @@ QTextCursor::QTextCursor(const QTextBlock &block)
/*! /*!
\internal \internal
*/ */
QTextCursor::QTextCursor(QTextDocumentPrivate *p, int pos) QTextCursor::QTextCursor(QTextDocumentPrivate &p, int pos)
: d(new QTextCursorPrivate(p)) : d(new QTextCursorPrivate(&p))
{ {
d->adjusted_anchor = d->anchor = d->position = pos; d->adjusted_anchor = d->anchor = d->position = pos;

View File

@ -67,10 +67,8 @@ class Q_GUI_EXPORT QTextCursor
public: public:
QTextCursor(); QTextCursor();
explicit QTextCursor(QTextDocument *document); explicit QTextCursor(QTextDocument *document);
QTextCursor(QTextDocumentPrivate *p, int pos);
explicit QTextCursor(QTextFrame *frame); explicit QTextCursor(QTextFrame *frame);
explicit QTextCursor(const QTextBlock &block); explicit QTextCursor(const QTextBlock &block);
explicit QTextCursor(QTextCursorPrivate *d);
QTextCursor(const QTextCursor &cursor); QTextCursor(const QTextCursor &cursor);
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
QTextCursor &operator=(QTextCursor &&other) Q_DECL_NOTHROW { swap(other); return *this; } QTextCursor &operator=(QTextCursor &&other) Q_DECL_NOTHROW { swap(other); return *this; }
@ -227,8 +225,12 @@ public:
QTextDocument *document() const; QTextDocument *document() const;
private: private:
QTextCursor(QTextDocumentPrivate &p, int pos);
explicit QTextCursor(QTextCursorPrivate *d);
QSharedDataPointer<QTextCursorPrivate> d; QSharedDataPointer<QTextCursorPrivate> d;
friend class QTextCursorPrivate; friend class QTextCursorPrivate;
friend class QTextDocumentPrivate;
friend class QTextDocumentFragmentPrivate; friend class QTextDocumentFragmentPrivate;
friend class QTextCopyHelper; friend class QTextCopyHelper;
friend class QWidgetTextControlPrivate; friend class QWidgetTextControlPrivate;

View File

@ -106,6 +106,9 @@ public:
void aboutToRemoveCell(int from, int to); void aboutToRemoveCell(int from, int to);
static QTextCursor fromPosition(QTextDocumentPrivate *d, int pos)
{ return QTextCursor(*d, pos); }
QTextDocumentPrivate *priv; QTextDocumentPrivate *priv;
qreal x; qreal x;
int position; int position;

View File

@ -39,6 +39,7 @@
#include "qtextdocument.h" #include "qtextdocument.h"
#include <qtextformat.h> #include <qtextformat.h>
#include "qtextcursor_p.h"
#include "qtextdocumentlayout_p.h" #include "qtextdocumentlayout_p.h"
#include "qtextdocumentfragment.h" #include "qtextdocumentfragment.h"
#include "qtextdocumentfragment_p.h" #include "qtextdocumentfragment_p.h"
@ -1279,7 +1280,7 @@ static bool findInBlock(const QTextBlock &block, const QString &expression, int
} }
} }
//we have a hit, return the cursor for that. //we have a hit, return the cursor for that.
*cursor = QTextCursor(block.docHandle(), block.position() + idx); *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx);
cursor->setPosition(cursor->position() + expression.length(), QTextCursor::KeepAnchor); cursor->setPosition(cursor->position() + expression.length(), QTextCursor::KeepAnchor);
return true; return true;
} }
@ -1397,7 +1398,7 @@ static bool findInBlock(const QTextBlock &block, const QRegExp &expression, int
} }
} }
//we have a hit, return the cursor for that. //we have a hit, return the cursor for that.
*cursor = QTextCursor(block.docHandle(), block.position() + idx); *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx);
cursor->setPosition(cursor->position() + expr.matchedLength(), QTextCursor::KeepAnchor); cursor->setPosition(cursor->position() + expr.matchedLength(), QTextCursor::KeepAnchor);
return true; return true;
} }
@ -1525,7 +1526,7 @@ static bool findInBlock(const QTextBlock &block, const QRegularExpression &expre
} }
} }
//we have a hit, return the cursor for that. //we have a hit, return the cursor for that.
*cursor = QTextCursor(block.docHandle(), block.position() + idx); *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx);
cursor->setPosition(cursor->position() + match.capturedLength(), QTextCursor::KeepAnchor); cursor->setPosition(cursor->position() + match.capturedLength(), QTextCursor::KeepAnchor);
return true; return true;
} }

View File

@ -1710,7 +1710,7 @@ bool QTextDocumentPrivate::ensureMaximumBlockCount()
beginEditBlock(); beginEditBlock();
const int blocksToRemove = blocks.numNodes() - maximumBlockCount; const int blocksToRemove = blocks.numNodes() - maximumBlockCount;
QTextCursor cursor(this, 0); QTextCursor cursor(*this, 0);
cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor, blocksToRemove); cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor, blocksToRemove);
unreachableCharacterCount += cursor.selectionEnd() - cursor.selectionStart(); unreachableCharacterCount += cursor.selectionEnd() - cursor.selectionStart();

View File

@ -39,6 +39,7 @@
#include "qtextobject.h" #include "qtextobject.h"
#include "qtextobject_p.h" #include "qtextobject_p.h"
#include "qtextcursor_p.h"
#include "qtextdocument.h" #include "qtextdocument.h"
#include "qtextformat_p.h" #include "qtextformat_p.h"
#include "qtextdocument_p.h" #include "qtextdocument_p.h"
@ -467,7 +468,7 @@ QTextFrame *QTextFrame::parentFrame() const
QTextCursor QTextFrame::firstCursorPosition() const QTextCursor QTextFrame::firstCursorPosition() const
{ {
Q_D(const QTextFrame); Q_D(const QTextFrame);
return QTextCursor(d->pieceTable, firstPosition()); return QTextCursorPrivate::fromPosition(d->pieceTable, firstPosition());
} }
/*! /*!
@ -478,7 +479,7 @@ QTextCursor QTextFrame::firstCursorPosition() const
QTextCursor QTextFrame::lastCursorPosition() const QTextCursor QTextFrame::lastCursorPosition() const
{ {
Q_D(const QTextFrame); Q_D(const QTextFrame);
return QTextCursor(d->pieceTable, lastPosition()); return QTextCursorPrivate::fromPosition(d->pieceTable, lastPosition());
} }
/*! /*!

View File

@ -41,6 +41,7 @@
#include "qtextcursor.h" #include "qtextcursor.h"
#include "qtextformat.h" #include "qtextformat.h"
#include <qdebug.h> #include <qdebug.h>
#include "qtextcursor_p.h"
#include "qtexttable_p.h" #include "qtexttable_p.h"
#include "qvarlengtharray.h" #include "qvarlengtharray.h"
@ -226,7 +227,7 @@ int QTextTableCell::columnSpan() const
*/ */
QTextCursor QTextTableCell::firstCursorPosition() const QTextCursor QTextTableCell::firstCursorPosition() const
{ {
return QTextCursor(table->d_func()->pieceTable, firstPosition()); return QTextCursorPrivate::fromPosition(table->d_func()->pieceTable, firstPosition());
} }
/*! /*!
@ -236,7 +237,7 @@ QTextCursor QTextTableCell::firstCursorPosition() const
*/ */
QTextCursor QTextTableCell::lastCursorPosition() const QTextCursor QTextTableCell::lastCursorPosition() const
{ {
return QTextCursor(table->d_func()->pieceTable, lastPosition()); return QTextCursorPrivate::fromPosition(table->d_func()->pieceTable, lastPosition());
} }
@ -1109,10 +1110,10 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols)
if (nextPos > pos) { if (nextPos > pos) {
if (needsParagraph) { if (needsParagraph) {
needsParagraph = false; needsParagraph = false;
QTextCursor(p, insertPos++).insertBlock(); QTextCursorPrivate::fromPosition(p, insertPos++).insertBlock();
p->move(pos + 1, insertPos, nextPos - pos); p->move(pos + 1, insertPos, nextPos - pos);
} else if (rowHasText) { } else if (rowHasText) {
QTextCursor(p, insertPos++).insertText(QLatin1String(" ")); QTextCursorPrivate::fromPosition(p, insertPos++).insertText(QLatin1String(" "));
p->move(pos + 1, insertPos, nextPos - pos); p->move(pos + 1, insertPos, nextPos - pos);
} else { } else {
p->move(pos, insertPos, nextPos - pos); p->move(pos, insertPos, nextPos - pos);
@ -1288,7 +1289,7 @@ QTextCursor QTextTable::rowStart(const QTextCursor &c) const
int row = cell.row(); int row = cell.row();
QTextDocumentPrivate *p = d->pieceTable; QTextDocumentPrivate *p = d->pieceTable;
QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), d->grid[row*d->nCols]); QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), d->grid[row*d->nCols]);
return QTextCursor(p, it.position()); return QTextCursorPrivate::fromPosition(p, it.position());
} }
/*! /*!
@ -1310,7 +1311,7 @@ QTextCursor QTextTable::rowEnd(const QTextCursor &c) const
int fragment = row < d->nRows ? d->grid[row*d->nCols] : d->fragment_end; int fragment = row < d->nRows ? d->grid[row*d->nCols] : d->fragment_end;
QTextDocumentPrivate *p = d->pieceTable; QTextDocumentPrivate *p = d->pieceTable;
QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), fragment); QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), fragment);
return QTextCursor(p, it.position() - 1); return QTextCursorPrivate::fromPosition(p, it.position() - 1);
} }
/*! /*!

View File

@ -320,29 +320,29 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
} }
#endif #endif
// Get the interface broadcast address
QNetworkAddressEntry entry;
if (iface->flags & QNetworkInterface::CanBroadcast) {
if (qt_safe_ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) {
sockaddr *sa = &req.ifr_addr;
if (sa->sa_family == AF_INET)
entry.setBroadcast(addressFromSockaddr(sa));
}
}
// Get the address of the interface // Get the address of the interface
QNetworkAddressEntry entry;
if (qt_safe_ioctl(socket, SIOCGIFADDR, &req) >= 0) { if (qt_safe_ioctl(socket, SIOCGIFADDR, &req) >= 0) {
sockaddr *sa = &req.ifr_addr; sockaddr *sa = &req.ifr_addr;
entry.setIp(addressFromSockaddr(sa)); entry.setIp(addressFromSockaddr(sa));
}
// Get the interface netmask // Get the interface broadcast address
if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) { if (iface->flags & QNetworkInterface::CanBroadcast) {
sockaddr *sa = &req.ifr_addr; if (qt_safe_ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) {
entry.setNetmask(addressFromSockaddr(sa)); sockaddr *sa = &req.ifr_addr;
} if (sa->sa_family == AF_INET)
entry.setBroadcast(addressFromSockaddr(sa));
}
}
iface->addressEntries << entry; // Get the interface netmask
if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) {
sockaddr *sa = &req.ifr_addr;
entry.setNetmask(addressFromSockaddr(sa));
}
iface->addressEntries << entry;
}
} }
::close(socket); ::close(socket);
@ -395,7 +395,7 @@ static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList)
// - virtual interfaces with no HW address have no AF_PACKET // - virtual interfaces with no HW address have no AF_PACKET
// - interface labels have no AF_PACKET, but shouldn't be shown as a new interface // - interface labels have no AF_PACKET, but shouldn't be shown as a new interface
for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) { for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) {
if (ptr->ifa_addr && ptr->ifa_addr->sa_family != AF_PACKET) { if (!ptr->ifa_addr || ptr->ifa_addr->sa_family != AF_PACKET) {
QString name = QString::fromLatin1(ptr->ifa_name); QString name = QString::fromLatin1(ptr->ifa_name);
if (seenInterfaces.contains(name)) if (seenInterfaces.contains(name))
continue; continue;

View File

@ -584,7 +584,7 @@ qint64 QNativeSocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHea
} else { } else {
readOrigin = datagram.data; readOrigin = datagram.data;
} }
strcpy(data, readOrigin); memcpy(data, readOrigin, qMin(maxlen, qint64(datagram.data.length())));
return readOrigin.length(); return readOrigin.length();
} }

View File

@ -92,19 +92,19 @@ class QStatusNotifierItemAdaptor: public QDBusAbstractAdaptor
" <property access=\"read\" type=\"o\" name=\"Menu\"/>\n" " <property access=\"read\" type=\"o\" name=\"Menu\"/>\n"
" <property access=\"read\" type=\"b\" name=\"ItemIsMenu\"/>\n" " <property access=\"read\" type=\"b\" name=\"ItemIsMenu\"/>\n"
" <property access=\"read\" type=\"s\" name=\"IconName\"/>\n" " <property access=\"read\" type=\"s\" name=\"IconName\"/>\n"
" <property access=\"read\" type=\"(iiay)\" name=\"IconPixmap\">\n" " <property access=\"read\" type=\"a(iiay)\" name=\"IconPixmap\">\n"
" <annotation value=\"QXdgDBusImageVector\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n" " <annotation value=\"QXdgDBusImageVector\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
" </property>\n" " </property>\n"
" <property access=\"read\" type=\"s\" name=\"OverlayIconName\"/>\n" " <property access=\"read\" type=\"s\" name=\"OverlayIconName\"/>\n"
" <property access=\"read\" type=\"(iiay)\" name=\"OverlayIconPixmap\">\n" " <property access=\"read\" type=\"a(iiay)\" name=\"OverlayIconPixmap\">\n"
" <annotation value=\"QXdgDBusImageVector\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n" " <annotation value=\"QXdgDBusImageVector\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
" </property>\n" " </property>\n"
" <property access=\"read\" type=\"s\" name=\"AttentionIconName\"/>\n" " <property access=\"read\" type=\"s\" name=\"AttentionIconName\"/>\n"
" <property access=\"read\" type=\"(iiay)\" name=\"AttentionIconPixmap\">\n" " <property access=\"read\" type=\"a(iiay)\" name=\"AttentionIconPixmap\">\n"
" <annotation value=\"QXdgDBusImageVector\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n" " <annotation value=\"QXdgDBusImageVector\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
" </property>\n" " </property>\n"
" <property access=\"read\" type=\"s\" name=\"AttentionMovieName\"/>\n" " <property access=\"read\" type=\"s\" name=\"AttentionMovieName\"/>\n"
" <property access=\"read\" type=\"(s(iiay)ss)\" name=\"ToolTip\">\n" " <property access=\"read\" type=\"(sa(iiay)ss)\" name=\"ToolTip\">\n"
" <annotation value=\"QXdgDBusToolTipStruct\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n" " <annotation value=\"QXdgDBusToolTipStruct\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
" </property>\n" " </property>\n"
" <method name=\"ContextMenu\">\n" " <method name=\"ContextMenu\">\n"

View File

@ -281,6 +281,12 @@ void QEGLPlatformContext::destroyTemporaryOffscreenSurface(EGLSurface surface)
eglDestroySurface(m_eglDisplay, surface); eglDestroySurface(m_eglDisplay, surface);
} }
void QEGLPlatformContext::runGLChecks()
{
// Nothing to do here, subclasses may override in order to perform OpenGL
// queries needing a context.
}
void QEGLPlatformContext::updateFormatFromGL() void QEGLPlatformContext::updateFormatFromGL()
{ {
#ifndef QT_NO_OPENGL #ifndef QT_NO_OPENGL
@ -352,6 +358,7 @@ void QEGLPlatformContext::updateFormatFromGL()
} }
} }
} }
runGLChecks();
eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext); eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext);
} else { } else {
qWarning("QEGLPlatformContext: Failed to make temporary surface current, format not updated (%x)", eglGetError()); qWarning("QEGLPlatformContext: Failed to make temporary surface current, format not updated (%x)", eglGetError());

View File

@ -90,6 +90,7 @@ protected:
virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) = 0; virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) = 0;
virtual EGLSurface createTemporaryOffscreenSurface(); virtual EGLSurface createTemporaryOffscreenSurface();
virtual void destroyTemporaryOffscreenSurface(EGLSurface surface); virtual void destroyTemporaryOffscreenSurface(EGLSurface surface);
virtual void runGLChecks();
private: private:
void init(const QSurfaceFormat &format, QPlatformOpenGLContext *share); void init(const QSurfaceFormat &format, QPlatformOpenGLContext *share);

View File

@ -66,10 +66,10 @@ public:
QFbBackingStore(QWindow *window); QFbBackingStore(QWindow *window);
~QFbBackingStore(); ~QFbBackingStore();
virtual QPaintDevice *paintDevice() Q_DECL_OVERRIDE { return &mImage; } QPaintDevice *paintDevice() Q_DECL_OVERRIDE { return &mImage; }
virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE; void flush(QWindow *window, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
virtual void resize(const QSize &size, const QRegion &region) Q_DECL_OVERRIDE; void resize(const QSize &size, const QRegion &region) Q_DECL_OVERRIDE;
const QImage image(); const QImage image();

View File

@ -72,7 +72,7 @@ public:
virtual ~QSpiAccessibleBridge(); virtual ~QSpiAccessibleBridge();
virtual void notifyAccessibilityUpdate(QAccessibleEvent *event) Q_DECL_OVERRIDE; void notifyAccessibilityUpdate(QAccessibleEvent *event) Q_DECL_OVERRIDE;
QDBusConnection dBusConnection() const; QDBusConnection dBusConnection() const;
public Q_SLOTS: public Q_SLOTS:

View File

@ -63,8 +63,8 @@ public:
QByteArray desktopEnvironment() const Q_DECL_OVERRIDE; QByteArray desktopEnvironment() const Q_DECL_OVERRIDE;
virtual bool openUrl(const QUrl &url) Q_DECL_OVERRIDE; bool openUrl(const QUrl &url) Q_DECL_OVERRIDE;
virtual bool openDocument(const QUrl &url) Q_DECL_OVERRIDE; bool openDocument(const QUrl &url) Q_DECL_OVERRIDE;
private: private:
QString m_webBrowser; QString m_webBrowser;

View File

@ -583,23 +583,23 @@ const char *QGnomeTheme::name = "gnome";
class QGnomeThemePrivate : public QPlatformThemePrivate class QGnomeThemePrivate : public QPlatformThemePrivate
{ {
public: public:
QGnomeThemePrivate() : fontsConfigured(false) { } QGnomeThemePrivate() : systemFont(Q_NULLPTR), fixedFont(Q_NULLPTR) {}
~QGnomeThemePrivate() { delete systemFont; delete fixedFont; }
void configureFonts(const QString &gtkFontName) const void configureFonts(const QString &gtkFontName) const
{ {
Q_ASSERT(!fontsConfigured); Q_ASSERT(!systemFont);
const int split = gtkFontName.lastIndexOf(QChar::Space); const int split = gtkFontName.lastIndexOf(QChar::Space);
float size = gtkFontName.mid(split+1).toFloat(); float size = gtkFontName.mid(split+1).toFloat();
QString fontName = gtkFontName.left(split); QString fontName = gtkFontName.left(split);
systemFont = QFont(fontName, size); systemFont = new QFont(fontName, size);
fixedFont = QFont(QLatin1String("monospace"), systemFont.pointSize()); fixedFont = new QFont(QLatin1String("monospace"), systemFont->pointSize());
fixedFont.setStyleHint(QFont::TypeWriter); fixedFont->setStyleHint(QFont::TypeWriter);
fontsConfigured = true;
} }
mutable QFont systemFont; mutable QFont *systemFont;
mutable QFont fixedFont; mutable QFont *fixedFont;
mutable bool fontsConfigured;
}; };
QGnomeTheme::QGnomeTheme() QGnomeTheme::QGnomeTheme()
@ -638,13 +638,13 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
const QFont *QGnomeTheme::font(Font type) const const QFont *QGnomeTheme::font(Font type) const
{ {
Q_D(const QGnomeTheme); Q_D(const QGnomeTheme);
if (!d->fontsConfigured) if (!d->systemFont)
d->configureFonts(gtkFontName()); d->configureFonts(gtkFontName());
switch (type) { switch (type) {
case QPlatformTheme::SystemFont: case QPlatformTheme::SystemFont:
return &d->systemFont; return d->systemFont;
case QPlatformTheme::FixedFont: case QPlatformTheme::FixedFont:
return &d->fixedFont; return d->fixedFont;
default: default:
return 0; return 0;
} }

View File

@ -81,8 +81,8 @@ public:
static QPlatformTheme *createUnixTheme(const QString &name); static QPlatformTheme *createUnixTheme(const QString &name);
static QStringList themeNames(); static QStringList themeNames();
virtual const QFont *font(Font type) const Q_DECL_OVERRIDE; const QFont *font(Font type) const Q_DECL_OVERRIDE;
virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
static QStringList xdgIconThemePaths(); static QStringList xdgIconThemePaths();
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
@ -102,11 +102,11 @@ public:
QKdeTheme(const QStringList& kdeDirs, int kdeVersion); QKdeTheme(const QStringList& kdeDirs, int kdeVersion);
static QPlatformTheme *createKdeTheme(); static QPlatformTheme *createKdeTheme();
virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
virtual const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE; const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE;
virtual const QFont *font(Font type) const Q_DECL_OVERRIDE; const QFont *font(Font type) const Q_DECL_OVERRIDE;
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const Q_DECL_OVERRIDE; QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const Q_DECL_OVERRIDE;
#endif #endif
@ -122,8 +122,8 @@ class QGnomeTheme : public QPlatformTheme
Q_DECLARE_PRIVATE(QGnomeTheme) Q_DECLARE_PRIVATE(QGnomeTheme)
public: public:
QGnomeTheme(); QGnomeTheme();
virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
virtual const QFont *font(Font type) const Q_DECL_OVERRIDE; const QFont *font(Font type) const Q_DECL_OVERRIDE;
QString standardButtonText(int button) const Q_DECL_OVERRIDE; QString standardButtonText(int button) const Q_DECL_OVERRIDE;
virtual QString gtkFontName() const; virtual QString gtkFontName() const;

View File

@ -201,7 +201,7 @@ QJsonObject AndroidStyle::loadStyleData()
} }
Q_ASSERT(!stylePath.isEmpty()); Q_ASSERT(!stylePath.isEmpty());
if (!androidTheme.isEmpty() && QFileInfo(stylePath + androidTheme + QLatin1String("style.json")).exists()) if (!androidTheme.isEmpty() && QFileInfo::exists(stylePath + androidTheme + QLatin1String("style.json")))
stylePath += androidTheme; stylePath += androidTheme;
QFile f(stylePath + QLatin1String("style.json")); QFile f(stylePath + QLatin1String("style.json"));

View File

@ -1792,6 +1792,18 @@ void QCocoaWindow::exposeWindow()
if (!isWindowExposable()) if (!isWindowExposable())
return; return;
// Update the QWindow's screen property. This property is set
// to QGuiApplication::primaryScreen() at QWindow construciton
// time, and we won't get a NSWindowDidChangeScreenNotification
// on show. The case where the window is initially displayed
// on a non-primary screen needs special handling here.
NSUInteger screenIndex = [[NSScreen screens] indexOfObject:m_nsWindow.screen];
if (screenIndex != NSNotFound) {
QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenAtIndex(screenIndex);
if (cocoaScreen)
window()->setScreen(cocoaScreen->screen());
}
if (!m_isExposed) { if (!m_isExposed) {
m_isExposed = true; m_isExposed = true;
m_exposedGeometry = geometry(); m_exposedGeometry = geometry();

View File

@ -91,6 +91,16 @@ void QEglFSContext::destroyTemporaryOffscreenSurface(EGLSurface surface)
} }
} }
void QEglFSContext::runGLChecks()
{
// Note that even though there is an EGL context current here,
// QOpenGLContext and QOpenGLFunctions are not yet usable at this stage.
const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
// Be nice and warn about a common source of confusion.
if (renderer && strstr(renderer, "llvmpipe"))
qWarning("Running on a software rasterizer (LLVMpipe), expect limited performance.");
}
void QEglFSContext::swapBuffers(QPlatformSurface *surface) void QEglFSContext::swapBuffers(QPlatformSurface *surface)
{ {
// draw the cursor // draw the cursor

View File

@ -54,6 +54,7 @@ public:
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) Q_DECL_OVERRIDE; EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) Q_DECL_OVERRIDE;
EGLSurface createTemporaryOffscreenSurface() Q_DECL_OVERRIDE; EGLSurface createTemporaryOffscreenSurface() Q_DECL_OVERRIDE;
void destroyTemporaryOffscreenSurface(EGLSurface surface) Q_DECL_OVERRIDE; void destroyTemporaryOffscreenSurface(EGLSurface surface) Q_DECL_OVERRIDE;
void runGLChecks() Q_DECL_OVERRIDE;
void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE; void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
private: private:

View File

@ -1969,7 +1969,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
QString testsPath = QLibraryInfo::location(QLibraryInfo::TestsPath); QString testsPath = QLibraryInfo::location(QLibraryInfo::TestsPath);
QString candidate = QString::fromLatin1("%1/%2/%3") QString candidate = QString::fromLatin1("%1/%2/%3")
.arg(testsPath, QFile::decodeName(testObjectName).toLower(), base); .arg(testsPath, QFile::decodeName(testObjectName).toLower(), base);
if (QFileInfo(candidate).exists()) { if (QFileInfo::exists(candidate)) {
found = candidate; found = candidate;
} }
else if (QTestLog::verboseLevel() >= 2) { else if (QTestLog::verboseLevel() >= 2) {
@ -1994,7 +1994,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
} }
QString candidate = QString::fromLatin1("%1/%2").arg(srcdir.canonicalFilePath(), base); QString candidate = QString::fromLatin1("%1/%2").arg(srcdir.canonicalFilePath(), base);
if (QFileInfo(candidate).exists()) { if (QFileInfo::exists(candidate)) {
found = candidate; found = candidate;
} }
else if (QTestLog::verboseLevel() >= 2) { else if (QTestLog::verboseLevel() >= 2) {
@ -2008,21 +2008,21 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co
// 4. Try resources // 4. Try resources
if (found.isEmpty()) { if (found.isEmpty()) {
QString candidate = QString::fromLatin1(":/%1").arg(base); QString candidate = QString::fromLatin1(":/%1").arg(base);
if (QFileInfo(candidate).exists()) if (QFileInfo::exists(candidate))
found = candidate; found = candidate;
} }
// 5. Try current directory // 5. Try current directory
if (found.isEmpty()) { if (found.isEmpty()) {
QString candidate = QString::fromLatin1("%1/%2").arg(QDir::currentPath()).arg(base); QString candidate = QString::fromLatin1("%1/%2").arg(QDir::currentPath()).arg(base);
if (QFileInfo(candidate).exists()) if (QFileInfo::exists(candidate))
found = candidate; found = candidate;
} }
// 6. Try main source directory // 6. Try main source directory
if (found.isEmpty()) { if (found.isEmpty()) {
QString candidate = QTest::mainSourcePath % QLatin1Char('/') % base; QString candidate = QTest::mainSourcePath % QLatin1Char('/') % base;
if (QFileInfo(candidate).exists()) if (QFileInfo::exists(candidate))
found = candidate; found = candidate;
} }

View File

@ -1255,6 +1255,7 @@ void Generator::generateStaticMetacall()
fprintf(out, " if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&%s::%s)) {\n", fprintf(out, " if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&%s::%s)) {\n",
cdef->classname.constData(), f.name.constData()); cdef->classname.constData(), f.name.constData());
fprintf(out, " *result = %d;\n", methodindex); fprintf(out, " *result = %d;\n", methodindex);
fprintf(out, " return;\n");
fprintf(out, " }\n }\n"); fprintf(out, " }\n }\n");
} }
if (!anythingUsed) if (!anythingUsed)

View File

@ -871,7 +871,7 @@ QModelIndex QDirModel::index(const QString &path, int column) const
#endif #endif
QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts); QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts);
if ((pathElements.isEmpty() || !QFileInfo(path).exists()) if ((pathElements.isEmpty() || !QFileInfo::exists(path))
#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE) #if !defined(Q_OS_WIN) || defined(Q_OS_WINCE)
&& path != QLatin1String("/") && path != QLatin1String("/")
#endif #endif

View File

@ -485,22 +485,24 @@ void QApplicationPrivate::process_cmdline()
j = 1; j = 1;
for (i=1; i<argc; i++) { // if you add anything here, modify QCoreApplication::arguments() for (i=1; i<argc; i++) { // if you add anything here, modify QCoreApplication::arguments()
if (argv[i] && *argv[i] != '-') { if (!argv[i])
continue;
if (*argv[i] != '-') {
argv[j++] = argv[i]; argv[j++] = argv[i];
continue; continue;
} }
QByteArray arg = argv[i]; const char *arg = argv[i];
if (arg.startsWith("--")) if (arg[1] == '-') // startsWith("--")
arg.remove(0, 1); ++arg;
if (arg == "-qdevel" || arg == "-qdebug") { if (strcmp(arg, "-qdevel") == 0 || strcmp(arg, "-qdebug") == 0) {
// obsolete argument // obsolete argument
#ifndef QT_NO_STYLE_STYLESHEET #ifndef QT_NO_STYLE_STYLESHEET
} else if (arg == "-stylesheet" && i < argc -1) { } else if (strcmp(arg, "-stylesheet") == 0 && i < argc -1) {
styleSheet = QLatin1String("file:///"); styleSheet = QLatin1String("file:///");
styleSheet.append(QString::fromLocal8Bit(argv[++i])); styleSheet.append(QString::fromLocal8Bit(argv[++i]));
} else if (arg.indexOf("-stylesheet=") != -1) { } else if (strncmp(arg, "-stylesheet=", 12) == 0) {
styleSheet = QLatin1String("file:///"); styleSheet = QLatin1String("file:///");
styleSheet.append(QString::fromLocal8Bit(arg.right(arg.length() - 12))); styleSheet.append(QString::fromLocal8Bit(arg + 12));
#endif #endif
} else if (qstrcmp(arg, "-widgetcount") == 0) { } else if (qstrcmp(arg, "-widgetcount") == 0) {
widgetCount = true; widgetCount = true;

View File

@ -9174,6 +9174,9 @@ bool QWidget::event(QEvent *event)
const QWindow *win = te->window; const QWindow *win = te->window;
d->setWinId((win && win->handle()) ? win->handle()->winId() : 0); d->setWinId((win && win->handle()) ? win->handle()->winId() : 0);
} }
#ifndef QT_NO_OPENGL
d->renderToTextureReallyDirty = 1;
#endif
break; break;
#ifndef QT_NO_PROPERTIES #ifndef QT_NO_PROPERTIES
case QEvent::DynamicPropertyChange: { case QEvent::DynamicPropertyChange: {

View File

@ -63,4 +63,5 @@ winrt: SUBDIRS -= \
qprocess \ qprocess \
qprocess-noapplication \ qprocess-noapplication \
qprocessenvironment \ qprocessenvironment \
qstorageinfo \
qwinoverlappedionotifier qwinoverlappedionotifier

View File

@ -65,7 +65,7 @@ public:
, fd_(-1) , fd_(-1)
, stream_(0) , stream_(0)
{ {
#if defined(QT_LARGEFILE_SUPPORT) && !defined(Q_OS_MAC) #if defined(QT_LARGEFILE_SUPPORT) && !defined(Q_OS_MAC) && !defined(Q_OS_WINRT)
maxSizeBits = 36; // 64 GiB maxSizeBits = 36; // 64 GiB
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
// HFS+ does not support sparse files, so we limit file size for the test // HFS+ does not support sparse files, so we limit file size for the test
@ -130,6 +130,9 @@ private:
int fd_; int fd_;
FILE *stream_; FILE *stream_;
QSharedPointer<QTemporaryDir> m_tempDir;
QString m_previousCurrent;
}; };
/* /*
@ -224,6 +227,11 @@ QByteArray const &tst_LargeFile::getDataBlock(int index, qint64 position)
void tst_LargeFile::initTestCase() void tst_LargeFile::initTestCase()
{ {
m_previousCurrent = QDir::currentPath();
m_tempDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir);
QVERIFY2(!m_tempDir.isNull(), qPrintable("Could not create temporary directory."));
QVERIFY2(QDir::setCurrent(m_tempDir->path()), qPrintable("Could not switch current directory"));
QFile file("qt_largefile.tmp"); QFile file("qt_largefile.tmp");
QVERIFY( !file.exists() || file.remove() ); QVERIFY( !file.exists() || file.remove() );
} }
@ -235,6 +243,8 @@ void tst_LargeFile::cleanupTestCase()
QFile file("qt_largefile.tmp"); QFile file("qt_largefile.tmp");
QVERIFY( !file.exists() || file.remove() ); QVERIFY( !file.exists() || file.remove() );
QDir::setCurrent(m_previousCurrent);
} }
void tst_LargeFile::init() void tst_LargeFile::init()

View File

@ -47,6 +47,7 @@ class tst_QAbstractFileEngine
{ {
Q_OBJECT Q_OBJECT
public slots: public slots:
void initTestCase();
void cleanupTestCase(); void cleanupTestCase();
private slots: private slots:
@ -59,6 +60,8 @@ private slots:
void mounting(); void mounting();
private: private:
QStringList filesForRemoval; QStringList filesForRemoval;
QSharedPointer<QTemporaryDir> m_currentDir;
QString m_previousCurrent;
}; };
class ReferenceFileEngine class ReferenceFileEngine
@ -558,6 +561,14 @@ class FileEngineHandler
} }
}; };
void tst_QAbstractFileEngine::initTestCase()
{
m_previousCurrent = QDir::currentPath();
m_currentDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir());
QVERIFY2(!m_currentDir.isNull(), qPrintable("Could not create current directory."));
QDir::setCurrent(m_currentDir->path());
}
void tst_QAbstractFileEngine::cleanupTestCase() void tst_QAbstractFileEngine::cleanupTestCase()
{ {
bool failed = false; bool failed = false;
@ -571,6 +582,8 @@ void tst_QAbstractFileEngine::cleanupTestCase()
} }
QVERIFY(!failed); QVERIFY(!failed);
QDir::setCurrent(m_previousCurrent);
} }
void tst_QAbstractFileEngine::customHandler() void tst_QAbstractFileEngine::customHandler()

View File

@ -45,6 +45,7 @@ public:
void stream_data(int noOfElements); void stream_data(int noOfElements);
public slots: public slots:
void initTestCase();
void cleanupTestCase(); void cleanupTestCase();
private slots: private slots:
@ -243,6 +244,10 @@ private:
void readqint64(QDataStream *s); void readqint64(QDataStream *s);
void readQIcon(QDataStream *s); void readQIcon(QDataStream *s);
void readQEasingCurve(QDataStream *s); void readQEasingCurve(QDataStream *s);
private:
QSharedPointer<QTemporaryDir> m_tempDir;
QString m_previousCurrent;
}; };
static int NColorRoles[] = { static int NColorRoles[] = {
@ -293,10 +298,20 @@ void tst_QDataStream::getSetCheck()
QCOMPARE(QDataStream::ReadCorruptData, obj1.status()); QCOMPARE(QDataStream::ReadCorruptData, obj1.status());
} }
void tst_QDataStream::initTestCase()
{
m_previousCurrent = QDir::currentPath();
m_tempDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir);
QVERIFY2(!m_tempDir.isNull(), qPrintable("Could not create temporary directory."));
QVERIFY2(QDir::setCurrent(m_tempDir->path()), qPrintable("Could not switch current directory"));
}
void tst_QDataStream::cleanupTestCase() void tst_QDataStream::cleanupTestCase()
{ {
QFile::remove(QLatin1String("qdatastream.out")); QFile::remove(QLatin1String("qdatastream.out"));
QFile::remove(QLatin1String("datastream.tmp")); QFile::remove(QLatin1String("datastream.tmp"));
QDir::setCurrent(m_previousCurrent);
} }
static int dataIndex(const QString &tag) static int dataIndex(const QString &tag)

View File

@ -6,6 +6,8 @@ RESOURCES += qdir.qrc
TESTDATA += testdir testData searchdir resources entrylist types tst_qdir.cpp TESTDATA += testdir testData searchdir resources entrylist types tst_qdir.cpp
contains(CONFIG, builtin_testdata): DEFINES += BUILTIN_TESTDATA
android:!android-no-sdk { android:!android-no-sdk {
RESOURCES += android_testdata.qrc RESOURCES += android_testdata.qrc
} }

View File

@ -51,7 +51,7 @@
# include <sys/stat.h> # include <sys/stat.h>
#endif #endif
#if defined(Q_OS_VXWORKS) #if defined(Q_OS_VXWORKS) || defined(Q_OS_WINRT)
#define Q_NO_SYMLINKS #define Q_NO_SYMLINKS
#endif #endif
@ -211,7 +211,12 @@ private slots:
void cdBelowRoot(); void cdBelowRoot();
private: private:
#ifdef BUILTIN_TESTDATA
QString m_dataPath;
QSharedPointer<QTemporaryDir> m_dataDir;
#else
const QString m_dataPath; const QString m_dataPath;
#endif
}; };
Q_DECLARE_METATYPE(tst_QDir::UncHandling) Q_DECLARE_METATYPE(tst_QDir::UncHandling)
@ -219,7 +224,7 @@ Q_DECLARE_METATYPE(tst_QDir::UncHandling)
tst_QDir::tst_QDir() tst_QDir::tst_QDir()
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
: m_dataPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)) : m_dataPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))
#else #elif !defined(BUILTIN_TESTDATA)
: m_dataPath(QFileInfo(QFINDTESTDATA("testData")).absolutePath()) : m_dataPath(QFileInfo(QFINDTESTDATA("testData")).absolutePath())
#endif #endif
{ {
@ -256,12 +261,23 @@ void tst_QDir::init()
void tst_QDir::initTestCase() void tst_QDir::initTestCase()
{ {
#ifdef BUILTIN_TESTDATA
m_dataDir = QEXTRACTTESTDATA("/");
QVERIFY2(!m_dataDir.isNull(), qPrintable("Did not find testdata. Is this builtin?"));
m_dataPath = m_dataDir->path();
#endif
QVERIFY2(!m_dataPath.isEmpty(), "test data not found"); QVERIFY2(!m_dataPath.isEmpty(), "test data not found");
} }
void tst_QDir::cleanupTestCase() void tst_QDir::cleanupTestCase()
{ {
#ifdef BUILTIN_TESTDATA
// We need to reset the current directory outside of QTemporaryDir for successful deletion
QDir::setCurrent(QCoreApplication::applicationDirPath());
#else
QDir(QDir::currentPath() + "/tmpdir").removeRecursively(); QDir(QDir::currentPath() + "/tmpdir").removeRecursively();
#endif
} }
// Testing get/set functions // Testing get/set functions
@ -527,7 +543,7 @@ void tst_QDir::exists_data()
QTest::newRow("simple dir") << (m_dataPath + "/resources") << true; QTest::newRow("simple dir") << (m_dataPath + "/resources") << true;
QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << true; QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << true;
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) && !defined(Q_OS_WINRT)
const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
QTest::newRow("unc 1") << uncRoot << true; QTest::newRow("unc 1") << uncRoot << true;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true; QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
@ -539,7 +555,7 @@ void tst_QDir::exists_data()
QTest::newRow("unc 8") << uncRoot + "/asharethatshouldnotexist" << false; QTest::newRow("unc 8") << uncRoot + "/asharethatshouldnotexist" << false;
QTest::newRow("unc 9") << "//ahostthatshouldnotexist" << false; QTest::newRow("unc 9") << "//ahostthatshouldnotexist" << false;
#endif #endif
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
QTest::newRow("This drive should exist") << "C:/" << true; QTest::newRow("This drive should exist") << "C:/" << true;
// find a non-existing drive and check if it does not exist // find a non-existing drive and check if it does not exist
#ifdef QT_BUILD_INTERNAL #ifdef QT_BUILD_INTERNAL
@ -892,7 +908,7 @@ void tst_QDir::entryListSimple_data()
QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << 2; QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << 2;
#endif #endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
QTest::newRow("unc 1") << uncRoot << 2; QTest::newRow("unc 1") << uncRoot << 2;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << 2; QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << 2;
@ -975,7 +991,6 @@ void tst_QDir::canonicalPath_data()
QTest::newRow("relative") << "." << m_dataPath; QTest::newRow("relative") << "." << m_dataPath;
QTest::newRow("relativeSubDir") << "./testData/../testData" << m_dataPath + "/testData"; QTest::newRow("relativeSubDir") << "./testData/../testData" << m_dataPath + "/testData";
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
QTest::newRow("absPath") << m_dataPath + "/testData/../testData" << m_dataPath + "/testData"; QTest::newRow("absPath") << m_dataPath + "/testData/../testData" << m_dataPath + "/testData";
#else #else
@ -1174,7 +1189,7 @@ tst_QDir::cleanPath_data()
QTest::newRow("data10") << "/:/" << "/:"; QTest::newRow("data10") << "/:/" << "/:";
#endif #endif
#endif #endif
#ifdef Q_OS_WIN #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QTest::newRow("data11") << "//foo//bar" << "//foo/bar"; QTest::newRow("data11") << "//foo//bar" << "//foo/bar";
#endif #endif
QTest::newRow("data12") << "ab/a/" << "ab/a"; // Path item with length of 2 QTest::newRow("data12") << "ab/a/" << "ab/a"; // Path item with length of 2
@ -1186,11 +1201,13 @@ tst_QDir::cleanPath_data()
QTest::newRow("data14") << "c://foo" << "c:/foo"; QTest::newRow("data14") << "c://foo" << "c:/foo";
// Drive letters and unc path in one string // Drive letters and unc path in one string
#ifndef Q_OS_WINRT
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
QTest::newRow("data15") << "//c:/foo" << "//c:/foo"; QTest::newRow("data15") << "//c:/foo" << "//c:/foo";
#else #else
QTest::newRow("data15") << "//c:/foo" << "/c:/foo"; QTest::newRow("data15") << "//c:/foo" << "/c:/foo";
#endif #endif
#endif // !Q_OS_WINRT
QTest::newRow("QTBUG-23892_0") << "foo/.." << "."; QTest::newRow("QTBUG-23892_0") << "foo/.." << ".";
QTest::newRow("QTBUG-23892_1") << "foo/../" << "."; QTest::newRow("QTBUG-23892_1") << "foo/../" << ".";
@ -1309,7 +1326,7 @@ void tst_QDir::absoluteFilePath_data()
QTest::newRow("2") << "/" << "passwd" << "/passwd"; QTest::newRow("2") << "/" << "passwd" << "/passwd";
QTest::newRow("3") << "relative" << "path" << QDir::currentPath() + "/relative/path"; QTest::newRow("3") << "relative" << "path" << QDir::currentPath() + "/relative/path";
QTest::newRow("4") << "" << "" << QDir::currentPath(); QTest::newRow("4") << "" << "" << QDir::currentPath();
#ifdef Q_OS_WIN #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QTest::newRow("5") << "//machine" << "share" << "//machine/share"; QTest::newRow("5") << "//machine" << "share" << "//machine/share";
#endif #endif
@ -1333,7 +1350,7 @@ void tst_QDir::absolutePath_data()
QTest::addColumn<QString>("expectedPath"); QTest::addColumn<QString>("expectedPath");
QTest::newRow("0") << "/machine/share/dir1" << "/machine/share/dir1"; QTest::newRow("0") << "/machine/share/dir1" << "/machine/share/dir1";
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
QTest::newRow("1") << "\\machine\\share\\dir1" << "/machine/share/dir1"; QTest::newRow("1") << "\\machine\\share\\dir1" << "/machine/share/dir1";
QTest::newRow("2") << "//machine/share/dir1" << "//machine/share/dir1"; QTest::newRow("2") << "//machine/share/dir1" << "//machine/share/dir1";
QTest::newRow("3") << "\\\\machine\\share\\dir1" << "//machine/share/dir1"; QTest::newRow("3") << "\\\\machine\\share\\dir1" << "//machine/share/dir1";
@ -1401,10 +1418,12 @@ void tst_QDir::relativeFilePath_data()
QTest::newRow("27") << "C:" << "D:/" << "D:/"; QTest::newRow("27") << "C:" << "D:/" << "D:/";
QTest::newRow("28") << "C:/" << "D:" << "D:"; QTest::newRow("28") << "C:/" << "D:" << "D:";
QTest::newRow("29") << "C:/" << "D:/" << "D:/"; QTest::newRow("29") << "C:/" << "D:/" << "D:/";
#ifndef Q_OS_WINRT
QTest::newRow("30") << "C:/foo/bar" << "//anotherHost/foo/bar" << "//anotherHost/foo/bar"; QTest::newRow("30") << "C:/foo/bar" << "//anotherHost/foo/bar" << "//anotherHost/foo/bar";
QTest::newRow("31") << "//anotherHost/foo" << "//anotherHost/foo/bar" << "bar"; QTest::newRow("31") << "//anotherHost/foo" << "//anotherHost/foo/bar" << "bar";
QTest::newRow("32") << "//anotherHost/foo" << "bar" << "bar"; QTest::newRow("32") << "//anotherHost/foo" << "bar" << "bar";
QTest::newRow("33") << "//anotherHost/foo" << "C:/foo/bar" << "C:/foo/bar"; QTest::newRow("33") << "//anotherHost/foo" << "C:/foo/bar" << "C:/foo/bar";
#endif // !Q_OS_WINRT
#endif #endif
QTest::newRow("resource0") << ":/prefix" << "foo.bar" << "foo.bar"; QTest::newRow("resource0") << ":/prefix" << "foo.bar" << "foo.bar";
@ -1589,7 +1608,11 @@ void tst_QDir::homePath()
qputenv("HOME", envHome); qputenv("HOME", envHome);
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
if (strHome.length() > 3) // root dir = "c:/"; "//" is not really valid... if (strHome.length() > 3 // root dir = "c:/"; "//" is not really valid...
#if defined(Q_OS_WINRT)
&& strHome.length() > QDir::rootPath().length()
#endif
)
QVERIFY(!strHome.endsWith('/')); QVERIFY(!strHome.endsWith('/'));
#endif #endif
@ -2054,6 +2077,9 @@ void tst_QDir::drives()
QVERIFY(list.count() >= 1); //system QVERIFY(list.count() >= 1); //system
QLatin1Char systemdrive('c'); QLatin1Char systemdrive('c');
#endif #endif
#if defined(Q_OS_WINRT)
QSKIP("WinRT has no concept of drives");
#endif
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
QVERIFY(list.count() <= 26); QVERIFY(list.count() <= 26);
bool foundsystem = false; bool foundsystem = false;
@ -2110,7 +2136,9 @@ void tst_QDir::equalityOperator_data()
<< true; << true;
//need a path in the root directory that is unlikely to be a symbolic link. //need a path in the root directory that is unlikely to be a symbolic link.
#if defined (Q_OS_WIN) #if defined (Q_OS_WINRT)
QString pathinroot(QDir::rootPath() + QLatin1String("assets/.."));
#elif defined (Q_OS_WIN)
QString pathinroot("c:/windows/.."); QString pathinroot("c:/windows/..");
#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) #elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
QString pathinroot("/system/.."); QString pathinroot("/system/..");
@ -2241,6 +2269,10 @@ void tst_QDir::cdBelowRoot()
#define ROOT QString("/") #define ROOT QString("/")
#define DIR QString("/tmp") #define DIR QString("/tmp")
#define CD_INTO "tmp" #define CD_INTO "tmp"
#elif defined (Q_OS_WINRT)
#define ROOT QDir::rootPath()
#define DIR QDir::rootPath()
#define CD_INTO QDir::rootPath()
#else #else
#define ROOT QString::fromLocal8Bit(qgetenv("SystemDrive"))+"/" #define ROOT QString::fromLocal8Bit(qgetenv("SystemDrive"))+"/"
#define DIR QString::fromLocal8Bit(qgetenv("SystemRoot")).replace('\\', '/') #define DIR QString::fromLocal8Bit(qgetenv("SystemRoot")).replace('\\', '/')
@ -2255,6 +2287,9 @@ void tst_QDir::cdBelowRoot()
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
if (::getuid() == 0) if (::getuid() == 0)
QSKIP("Running this test as root doesn't make sense"); QSKIP("Running this test as root doesn't make sense");
#endif
#ifdef Q_OS_WINRT
QSKIP("WinRT has no concept of system root");
#endif #endif
QDir dir(DIR); QDir dir(DIR);
QVERIFY(!dir.cd("../..")); QVERIFY(!dir.cd("../.."));

View File

@ -5,6 +5,7 @@ SOURCES = tst_qdiriterator.cpp
RESOURCES += qdiriterator.qrc RESOURCES += qdiriterator.qrc
TESTDATA += entrylist TESTDATA += entrylist
contains(CONFIG, builtin_testdata): DEFINES += BUILTIN_TESTDATA
wince*mips*|wincewm50smart-msvc200*: DEFINES += WINCE_BROKEN_ITERATE=1 wince*mips*|wincewm50smart-msvc200*: DEFINES += WINCE_BROKEN_ITERATE=1

View File

@ -37,7 +37,7 @@
#include <QtCore/private/qfsfileengine_p.h> #include <QtCore/private/qfsfileengine_p.h>
#if defined(Q_OS_VXWORKS) #if defined(Q_OS_VXWORKS) || defined(Q_OS_WINRT)
#define Q_NO_SYMLINKS #define Q_NO_SYMLINKS
#endif #endif
@ -110,6 +110,10 @@ private slots:
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
void hiddenDirs_hiddenFiles(); void hiddenDirs_hiddenFiles();
#endif #endif
#ifdef BUILTIN_TESTDATA
private:
QSharedPointer<QTemporaryDir> m_dataDir;
#endif
}; };
void tst_QDirIterator::initTestCase() void tst_QDirIterator::initTestCase()
@ -136,6 +140,10 @@ void tst_QDirIterator::initTestCase()
} }
testdata_dir += QStringLiteral("/entrylist"); testdata_dir += QStringLiteral("/entrylist");
#elif defined(BUILTIN_TESTDATA)
m_dataDir = QEXTRACTTESTDATA("/");
QVERIFY2(!m_dataDir.isNull(), qPrintable("Could not extract test data"));
QString testdata_dir = m_dataDir->path();
#else #else
// chdir into testdata directory, then find testdata by relative paths. // chdir into testdata directory, then find testdata by relative paths.
@ -212,6 +220,11 @@ void tst_QDirIterator::cleanupTestCase()
Q_FOREACH(QString dirName, createdDirectories) Q_FOREACH(QString dirName, createdDirectories)
currentDir.rmdir(dirName); currentDir.rmdir(dirName);
#ifdef Q_OS_WINRT
QDir::setCurrent(QCoreApplication::applicationDirPath());
#endif // Q_OS_WINRT
} }
void tst_QDirIterator::iterateRelativeDirectory_data() void tst_QDirIterator::iterateRelativeDirectory_data()

View File

@ -61,7 +61,7 @@
#include <private/qfileinfo_p.h> #include <private/qfileinfo_p.h>
#include "../../../../shared/filesystem.h" #include "../../../../shared/filesystem.h"
#if defined(Q_OS_VXWORKS) #if defined(Q_OS_VXWORKS) || defined(Q_OS_WINRT)
#define Q_NO_SYMLINKS #define Q_NO_SYMLINKS
#endif #endif
@ -422,12 +422,12 @@ void tst_QFileInfo::isDir_data()
QTest::newRow("broken link") << "brokenlink.lnk" << false; QTest::newRow("broken link") << "brokenlink.lnk" << false;
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
QTest::newRow("drive 1") << "c:" << true; QTest::newRow("drive 1") << "c:" << true;
QTest::newRow("drive 2") << "c:/" << true; QTest::newRow("drive 2") << "c:/" << true;
//QTest::newRow("drive 2") << "t:s" << false; //QTest::newRow("drive 2") << "t:s" << false;
#endif #endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
QTest::newRow("unc 1") << uncRoot << true; QTest::newRow("unc 1") << uncRoot << true;
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true; QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
@ -464,7 +464,7 @@ void tst_QFileInfo::isRoot_data()
QTest::newRow("simple dir") << m_resourcesDir << false; QTest::newRow("simple dir") << m_resourcesDir << false;
QTest::newRow("simple dir with slash") << (m_resourcesDir + QLatin1Char('/')) << false; QTest::newRow("simple dir with slash") << (m_resourcesDir + QLatin1Char('/')) << false;
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
QTest::newRow("drive 1") << "c:" << false; QTest::newRow("drive 1") << "c:" << false;
QTest::newRow("drive 2") << "c:/" << true; QTest::newRow("drive 2") << "c:/" << true;
QTest::newRow("drive 3") << "p:/" << false; QTest::newRow("drive 3") << "p:/" << false;
@ -508,7 +508,12 @@ void tst_QFileInfo::exists_data()
QTest::newRow("data8") << (m_resourcesDir + "/*.ext1") << false; QTest::newRow("data8") << (m_resourcesDir + "/*.ext1") << false;
QTest::newRow("data9") << (m_resourcesDir + "/file?.ext1") << false; QTest::newRow("data9") << (m_resourcesDir + "/file?.ext1") << false;
QTest::newRow("data10") << "." << true; QTest::newRow("data10") << "." << true;
// Skip for the WinRT case, as GetFileAttributesEx removes _any_
// trailing whitespace and "." is a valid entry as seen in data10
#ifndef Q_OS_WINRT
QTest::newRow("data11") << ". " << false; QTest::newRow("data11") << ". " << false;
#endif
QTest::newRow("empty") << "" << false; QTest::newRow("empty") << "" << false;
QTest::newRow("simple dir") << m_resourcesDir << true; QTest::newRow("simple dir") << m_resourcesDir << true;
@ -549,7 +554,7 @@ void tst_QFileInfo::absolutePath_data()
QTest::addColumn<QString>("filename"); QTest::addColumn<QString>("filename");
QString drivePrefix; QString drivePrefix;
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
drivePrefix = QDir::currentPath().left(2); drivePrefix = QDir::currentPath().left(2);
QString nonCurrentDrivePrefix = QString nonCurrentDrivePrefix =
drivePrefix.left(1).compare("X", Qt::CaseInsensitive) == 0 ? QString("Y:") : QString("X:"); drivePrefix.left(1).compare("X", Qt::CaseInsensitive) == 0 ? QString("Y:") : QString("X:");
@ -559,6 +564,8 @@ void tst_QFileInfo::absolutePath_data()
QTest::newRow("<not current drive>:my.dll") << nonCurrentDrivePrefix + "my.dll" QTest::newRow("<not current drive>:my.dll") << nonCurrentDrivePrefix + "my.dll"
<< nonCurrentDrivePrefix + "/" << nonCurrentDrivePrefix + "/"
<< "my.dll"; << "my.dll";
#elif defined(Q_OS_WINRT)
drivePrefix = QDir::currentPath().left(2);
#endif #endif
QTest::newRow("0") << "/machine/share/dir1/" << drivePrefix + "/machine/share/dir1" << ""; QTest::newRow("0") << "/machine/share/dir1/" << drivePrefix + "/machine/share/dir1" << "";
QTest::newRow("1") << "/machine/share/dir1" << drivePrefix + "/machine/share" << "dir1"; QTest::newRow("1") << "/machine/share/dir1" << drivePrefix + "/machine/share" << "dir1";
@ -566,7 +573,7 @@ void tst_QFileInfo::absolutePath_data()
QTest::newRow("3") << "/usr/local/bin/" << drivePrefix + "/usr/local/bin" << ""; QTest::newRow("3") << "/usr/local/bin/" << drivePrefix + "/usr/local/bin" << "";
QTest::newRow("/test") << "/test" << drivePrefix + "/" << "test"; QTest::newRow("/test") << "/test" << drivePrefix + "/" << "test";
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
QTest::newRow("c:\\autoexec.bat") << "c:\\autoexec.bat" << "C:/" QTest::newRow("c:\\autoexec.bat") << "c:\\autoexec.bat" << "C:/"
<< "autoexec.bat"; << "autoexec.bat";
QTest::newRow("c:autoexec.bat") << QDir::currentPath().left(2) + "autoexec.bat" << QDir::currentPath() QTest::newRow("c:autoexec.bat") << QDir::currentPath().left(2) + "autoexec.bat" << QDir::currentPath()
@ -730,7 +737,7 @@ void tst_QFileInfo::canonicalFilePath()
} }
#endif #endif
#ifdef Q_OS_WIN #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
typedef BOOL (WINAPI *PtrCreateSymbolicLink)(LPTSTR, LPTSTR, DWORD); typedef BOOL (WINAPI *PtrCreateSymbolicLink)(LPTSTR, LPTSTR, DWORD);
PtrCreateSymbolicLink ptrCreateSymbolicLink = PtrCreateSymbolicLink ptrCreateSymbolicLink =
(PtrCreateSymbolicLink)QLibrary::resolve(QLatin1String("kernel32"), "CreateSymbolicLinkW"); (PtrCreateSymbolicLink)QLibrary::resolve(QLatin1String("kernel32"), "CreateSymbolicLinkW");
@ -826,7 +833,7 @@ void tst_QFileInfo::dir_data()
QTest::newRow("absFilePath") << QDir::currentPath() + "/tmp.txt" << false << QDir::currentPath(); QTest::newRow("absFilePath") << QDir::currentPath() + "/tmp.txt" << false << QDir::currentPath();
QTest::newRow("absFilePathAbsPath") << QDir::currentPath() + "/tmp.txt" << true << QDir::currentPath(); QTest::newRow("absFilePathAbsPath") << QDir::currentPath() + "/tmp.txt" << true << QDir::currentPath();
QTest::newRow("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << true << ":/tst_qfileinfo/resources"; QTest::newRow("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << true << ":/tst_qfileinfo/resources";
#ifdef Q_OS_WIN #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QTest::newRow("driveWithSlash") << "C:/file1.ext1.ext2" << true << "C:/"; QTest::newRow("driveWithSlash") << "C:/file1.ext1.ext2" << true << "C:/";
QTest::newRow("driveWithoutSlash") << QDir::currentPath().left(2) + "file1.ext1.ext2" << false << QDir::currentPath().left(2); QTest::newRow("driveWithoutSlash") << QDir::currentPath().left(2) + "file1.ext1.ext2" << false << QDir::currentPath().left(2);
#endif #endif
@ -1017,7 +1024,7 @@ void tst_QFileInfo::size()
void tst_QFileInfo::systemFiles() void tst_QFileInfo::systemFiles()
{ {
#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE) #if !defined(Q_OS_WIN) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
QSKIP("This is a Windows only test"); QSKIP("This is a Windows only test");
#endif #endif
QFileInfo fi("c:\\pagefile.sys"); QFileInfo fi("c:\\pagefile.sys");
@ -1188,6 +1195,8 @@ void tst_QFileInfo::fileTimes()
#endif #endif
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
QEXPECT_FAIL("simple", "WinCE only stores date of access data, not the time", Continue); QEXPECT_FAIL("simple", "WinCE only stores date of access data, not the time", Continue);
#elif defined(Q_OS_WINRT)
QEXPECT_FAIL("", "WinRT does not allow timestamp handling change in the filesystem due to sandboxing", Continue);
#elif defined(Q_OS_QNX) #elif defined(Q_OS_QNX)
QEXPECT_FAIL("", "QNX uses the noatime filesystem option", Continue); QEXPECT_FAIL("", "QNX uses the noatime filesystem option", Continue);
#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) #elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
@ -1623,7 +1632,7 @@ void tst_QFileInfo::isWritable()
QVERIFY(QFileInfo("tempfile.txt").isWritable()); QVERIFY(QFileInfo("tempfile.txt").isWritable());
tempfile.remove(); tempfile.remove();
#ifdef Q_OS_WIN #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
#ifdef Q_OS_WINCE #ifdef Q_OS_WINCE
QFileInfo fi("\\Windows\\wince.nls"); QFileInfo fi("\\Windows\\wince.nls");
#else #else

View File

@ -23,6 +23,7 @@
<file>platforms/+unix/test</file> <file>platforms/+unix/test</file>
<file>platforms/+windows/+wince/test</file> <file>platforms/+windows/+wince/test</file>
<file>platforms/+windows/+winnt/test</file> <file>platforms/+windows/+winnt/test</file>
<file>platforms/+windows/+winrt/test</file>
<file>platforms/+windows/test</file> <file>platforms/+windows/test</file>
<file>platforms/+android/test</file> <file>platforms/+android/test</file>
<file>platforms/+ios/test</file> <file>platforms/+ios/test</file>
@ -32,6 +33,7 @@
<file>platforms/+haiku/test</file> <file>platforms/+haiku/test</file>
<file>platforms/+linux/test</file> <file>platforms/+linux/test</file>
<file>platforms/+wince/test</file> <file>platforms/+wince/test</file>
<file>platforms/+winrt/test</file>
<!-- platforms/test2: shallow selection for the deepest selector --> <!-- platforms/test2: shallow selection for the deepest selector -->
<file>platforms/test2</file> <file>platforms/test2</file>
@ -42,6 +44,7 @@
<file>platforms/+linux/test2</file> <file>platforms/+linux/test2</file>
<file>platforms/+wince/test2</file> <file>platforms/+wince/test2</file>
<file>platforms/+winnt/test2</file> <file>platforms/+winnt/test2</file>
<file>platforms/+winrt/test2</file>
<!-- platforms/test3: selection for the family only --> <!-- platforms/test3: selection for the family only -->
<file>platforms/test3</file> <file>platforms/test3</file>

View File

@ -94,7 +94,7 @@ void tst_QFileSelector::basicTest_data()
expectedPlatform2File = QString(":/platforms/test2"); expectedPlatform2File = QString(":/platforms/test2");
#else #else
QString distributionName; QString distributionName;
# if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || defined(Q_OS_FREEBSD) # if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || defined(Q_OS_FREEBSD) || defined(Q_OS_WINRT)
distributionName = QSysInfo::productType(); distributionName = QSysInfo::productType();
# endif # endif
foreach (const QString &selector, QFileSelectorPrivate::platformSelectors()) { foreach (const QString &selector, QFileSelectorPrivate::platformSelectors()) {

View File

@ -38,6 +38,7 @@ class tst_QIODevice : public QObject
private slots: private slots:
void initTestCase(); void initTestCase();
void cleanupTestCase();
void getSetCheck(); void getSetCheck();
void constructing_QTcpSocket(); void constructing_QTcpSocket();
void constructing_QFile(); void constructing_QFile();
@ -57,6 +58,10 @@ private slots:
void transaction_data(); void transaction_data();
void transaction(); void transaction();
private:
QSharedPointer<QTemporaryDir> m_tempDir;
QString m_previousCurrent;
}; };
void tst_QIODevice::initTestCase() void tst_QIODevice::initTestCase()
@ -65,6 +70,15 @@ void tst_QIODevice::initTestCase()
QVERIFY(QFileInfo(QStringLiteral("./tst_qiodevice.cpp")).exists() QVERIFY(QFileInfo(QStringLiteral("./tst_qiodevice.cpp")).exists()
|| QFile::copy(QStringLiteral(":/tst_qiodevice.cpp"), QStringLiteral("./tst_qiodevice.cpp"))); || QFile::copy(QStringLiteral(":/tst_qiodevice.cpp"), QStringLiteral("./tst_qiodevice.cpp")));
#endif #endif
m_previousCurrent = QDir::currentPath();
m_tempDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir);
QVERIFY2(!m_tempDir.isNull(), qPrintable("Could not create temporary directory."));
QVERIFY2(QDir::setCurrent(m_tempDir->path()), qPrintable("Could not switch current directory"));
}
void tst_QIODevice::cleanupTestCase()
{
QDir::setCurrent(m_previousCurrent);
} }
// Testing get/set functions // Testing get/set functions

View File

@ -6,6 +6,7 @@ QT = core core-private testlib
SOURCES += tst_qloggingregistry.cpp SOURCES += tst_qloggingregistry.cpp
OTHER_FILES += qtlogging.ini OTHER_FILES += qtlogging.ini
TESTDATA += qtlogging.ini
android:!android-no-sdk: { android:!android-no-sdk: {
RESOURCES += \ RESOURCES += \

View File

@ -424,6 +424,8 @@ void tst_qstandardpaths::testFindExecutable()
void tst_qstandardpaths::testFindExecutableLinkToDirectory() void tst_qstandardpaths::testFindExecutableLinkToDirectory()
{ {
// WinRT has no link support
#ifndef Q_OS_WINRT
// link to directory // link to directory
const QString target = QDir::tempPath() + QDir::separator() + QLatin1String("link.lnk"); const QString target = QDir::tempPath() + QDir::separator() + QLatin1String("link.lnk");
QFile::remove(target); QFile::remove(target);
@ -431,15 +433,16 @@ void tst_qstandardpaths::testFindExecutableLinkToDirectory()
QVERIFY(appFile.link(target)); QVERIFY(appFile.link(target));
QVERIFY(QStandardPaths::findExecutable(target).isEmpty()); QVERIFY(QStandardPaths::findExecutable(target).isEmpty());
QFile::remove(target); QFile::remove(target);
#endif
} }
void tst_qstandardpaths::testRuntimeDirectory() void tst_qstandardpaths::testRuntimeDirectory()
{ {
#ifdef Q_XDG_PLATFORM
const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
QVERIFY(!runtimeDir.isEmpty()); QVERIFY(!runtimeDir.isEmpty());
// Check that it can automatically fix permissions // Check that it can automatically fix permissions
#ifdef Q_XDG_PLATFORM
QFile file(runtimeDir); QFile file(runtimeDir);
const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser; const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser;
const QFile::Permissions additionalPerms = QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner; const QFile::Permissions additionalPerms = QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner;

View File

@ -67,11 +67,14 @@ private slots:
void QTBUG43352_failedSetPermissions(); void QTBUG43352_failedSetPermissions();
public: private:
QString m_previousCurrent;
}; };
void tst_QTemporaryDir::initTestCase() void tst_QTemporaryDir::initTestCase()
{ {
m_previousCurrent = QDir::currentPath();
QDir::setCurrent(QDir::tempPath());
QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX")); QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX"));
QCoreApplication::setApplicationName("tst_qtemporarydir"); QCoreApplication::setApplicationName("tst_qtemporarydir");
} }
@ -79,6 +82,8 @@ void tst_QTemporaryDir::initTestCase()
void tst_QTemporaryDir::cleanupTestCase() void tst_QTemporaryDir::cleanupTestCase()
{ {
QVERIFY(QDir().rmdir("test-XXXXXX")); QVERIFY(QDir().rmdir("test-XXXXXX"));
QDir::setCurrent(m_previousCurrent);
} }
void tst_QTemporaryDir::construction() void tst_QTemporaryDir::construction()

View File

@ -80,10 +80,15 @@ private slots:
void QTBUG_4796_data(); void QTBUG_4796_data();
void QTBUG_4796(); void QTBUG_4796();
void guaranteeUnique(); void guaranteeUnique();
private:
QString m_previousCurrent;
}; };
void tst_QTemporaryFile::initTestCase() void tst_QTemporaryFile::initTestCase()
{ {
m_previousCurrent = QDir::currentPath();
QDir::setCurrent(QDir::tempPath());
// For QTBUG_4796 // For QTBUG_4796
QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX")); QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX"));
QCoreApplication::setApplicationName("tst_qtemporaryfile"); QCoreApplication::setApplicationName("tst_qtemporaryfile");
@ -111,6 +116,8 @@ void tst_QTemporaryFile::cleanupTestCase()
{ {
// From QTBUG_4796 // From QTBUG_4796
QVERIFY(QDir().rmdir("test-XXXXXX")); QVERIFY(QDir().rmdir("test-XXXXXX"));
QDir::setCurrent(m_previousCurrent);
} }
void tst_QTemporaryFile::construction() void tst_QTemporaryFile::construction()
@ -673,8 +680,11 @@ void tst_QTemporaryFile::createNativeFile_data()
const QString nativeFilePath = QFINDTESTDATA("resources/test.txt"); const QString nativeFilePath = QFINDTESTDATA("resources/test.txt");
#endif #endif
QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray(); // File might not exist locally in case of sandboxing or remote testing
QTest::newRow("nativeFileWithPos") << nativeFilePath << (qint64)5 << false << QByteArray(); if (!nativeFilePath.startsWith(QLatin1String(":/"))) {
QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray();
QTest::newRow("nativeFileWithPos") << nativeFilePath << (qint64)5 << false << QByteArray();
}
QTest::newRow("resourceFile") << ":/resources/test.txt" << (qint64)-1 << true << QByteArray("This is a test"); QTest::newRow("resourceFile") << ":/resources/test.txt" << (qint64)-1 << true << QByteArray("This is a test");
QTest::newRow("resourceFileWithPos") << ":/resources/test.txt" << (qint64)5 << true << QByteArray("This is a test"); QTest::newRow("resourceFileWithPos") << ":/resources/test.txt" << (qint64)5 << true << QByteArray("This is a test");
} }

View File

@ -3009,15 +3009,21 @@ void tst_QUrl::fromUserInputWithCwd_data()
it.next(); it.next();
QUrl url = QUrl::fromLocalFile(it.filePath()); QUrl url = QUrl::fromLocalFile(it.filePath());
if (it.fileName() == QLatin1String(".")) { if (it.fileName() == QLatin1String(".")) {
url = QUrl::fromLocalFile(QDir::currentPath()); // fromUserInput cleans the path url = QUrl::fromLocalFile(QDir::currentPath()
#ifdef Q_OS_WINRT
+ QLatin1Char('/')
#endif
); // fromUserInput cleans the path
} }
QTest::newRow(("file-" + QByteArray::number(c++)).constData()) QTest::newRow(("file-" + QByteArray::number(c++)).constData())
<< it.fileName() << QDir::currentPath() << url << url; << it.fileName() << QDir::currentPath() << url << url;
} }
#ifndef Q_OS_WINRT // WinRT cannot cd outside current / sandbox
QDir parent = QDir::current(); QDir parent = QDir::current();
QVERIFY(parent.cdUp()); QVERIFY(parent.cdUp());
QUrl parentUrl = QUrl::fromLocalFile(parent.path()); QUrl parentUrl = QUrl::fromLocalFile(parent.path());
QTest::newRow("dotdot") << ".." << QDir::currentPath() << parentUrl << parentUrl; QTest::newRow("dotdot") << ".." << QDir::currentPath() << parentUrl << parentUrl;
#endif
QTest::newRow("nonexisting") << "nonexisting" << QDir::currentPath() << QUrl("http://nonexisting") << QUrl::fromLocalFile(QDir::currentPath() + "/nonexisting"); QTest::newRow("nonexisting") << "nonexisting" << QDir::currentPath() << QUrl("http://nonexisting") << QUrl::fromLocalFile(QDir::currentPath() + "/nonexisting");
QTest::newRow("short-url") << "example.org" << QDir::currentPath() << QUrl("http://example.org") << QUrl::fromLocalFile(QDir::currentPath() + "/example.org"); QTest::newRow("short-url") << "example.org" << QDir::currentPath() << QUrl("http://example.org") << QUrl::fromLocalFile(QDir::currentPath() + "/example.org");

View File

@ -798,16 +798,18 @@ void tst_QDateTime::toString_textDate_data()
QTest::addColumn<QDateTime>("datetime"); QTest::addColumn<QDateTime>("datetime");
QTest::addColumn<QString>("expected"); QTest::addColumn<QString>("expected");
QString wednesdayJanuary = QDate::shortDayName(3) + ' ' + QDate::shortMonthName(1);
QTest::newRow("localtime") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::LocalTime) QTest::newRow("localtime") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::LocalTime)
<< QString("Wed Jan 2 01:02:03 2013"); << wednesdayJanuary + QString(" 2 01:02:03 2013");
QTest::newRow("utc") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::UTC) QTest::newRow("utc") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::UTC)
<< QString("Wed Jan 2 01:02:03 2013 GMT"); << wednesdayJanuary + QString(" 2 01:02:03 2013 GMT");
QTest::newRow("offset+") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::OffsetFromUTC, QTest::newRow("offset+") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::OffsetFromUTC,
10 * 60 * 60) 10 * 60 * 60)
<< QString("Wed Jan 2 01:02:03 2013 GMT+1000"); << wednesdayJanuary + QString(" 2 01:02:03 2013 GMT+1000");
QTest::newRow("offset-") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::OffsetFromUTC, QTest::newRow("offset-") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::OffsetFromUTC,
-10 * 60 * 60) -10 * 60 * 60)
<< QString("Wed Jan 2 01:02:03 2013 GMT-1000"); << wednesdayJanuary + QString(" 2 01:02:03 2013 GMT-1000");
QTest::newRow("invalid") << QDateTime() QTest::newRow("invalid") << QDateTime()
<< QString(""); << QString("");
} }
@ -817,9 +819,6 @@ void tst_QDateTime::toString_textDate()
QFETCH(QDateTime, datetime); QFETCH(QDateTime, datetime);
QFETCH(QString, expected); QFETCH(QString, expected);
QLocale oldLocale;
QLocale::setDefault(QLocale("en_US"));
QString result = datetime.toString(Qt::TextDate); QString result = datetime.toString(Qt::TextDate);
QCOMPARE(result, expected); QCOMPARE(result, expected);
@ -829,8 +828,6 @@ void tst_QDateTime::toString_textDate()
QCOMPARE(resultDatetime.time(), datetime.time()); QCOMPARE(resultDatetime.time(), datetime.time());
QCOMPARE(resultDatetime.timeSpec(), datetime.timeSpec()); QCOMPARE(resultDatetime.timeSpec(), datetime.timeSpec());
QCOMPARE(resultDatetime.utcOffset(), datetime.utcOffset()); QCOMPARE(resultDatetime.utcOffset(), datetime.utcOffset());
QLocale::setDefault(oldLocale);
} }
void tst_QDateTime::toString_rfcDate_data() void tst_QDateTime::toString_rfcDate_data()

View File

@ -1,4 +1,4 @@
CONFIG += testcase CONFIG += testcase
TARGET = tst_qtextcursor TARGET = tst_qtextcursor
SOURCES += tst_qtextcursor.cpp SOURCES += tst_qtextcursor.cpp
QT += testlib QT += core-private gui-private testlib

View File

@ -29,7 +29,6 @@
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include <qtextdocument.h> #include <qtextdocument.h>
#include <qtexttable.h> #include <qtexttable.h>
#include <qvariant.h> #include <qvariant.h>
@ -40,6 +39,8 @@
#include <qtextobject.h> #include <qtextobject.h>
#include <qdebug.h> #include <qdebug.h>
#include <private/qtextcursor_p.h>
QT_FORWARD_DECLARE_CLASS(QTextDocument) QT_FORWARD_DECLARE_CLASS(QTextDocument)
class tst_QTextCursor : public QObject class tst_QTextCursor : public QObject
@ -1278,7 +1279,7 @@ void tst_QTextCursor::anchorInitialized1()
void tst_QTextCursor::anchorInitialized2() void tst_QTextCursor::anchorInitialized2()
{ {
cursor.insertBlock(); cursor.insertBlock();
cursor = QTextCursor(cursor.block().docHandle(), 1); cursor = QTextCursorPrivate::fromPosition(cursor.block().docHandle(), 1);
QCOMPARE(cursor.position(), 1); QCOMPARE(cursor.position(), 1);
QCOMPARE(cursor.anchor(), 1); QCOMPARE(cursor.anchor(), 1);
QCOMPARE(cursor.selectionStart(), 1); QCOMPARE(cursor.selectionStart(), 1);

View File

@ -233,13 +233,6 @@ void tst_QNetworkInterface::interfaceFromXXX()
// but only for IPv4 (there is no such thing as broadcast in IPv6) // but only for IPv4 (there is no such thing as broadcast in IPv6)
if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol) { if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol) {
QVERIFY(!entry.broadcast().isNull()); QVERIFY(!entry.broadcast().isNull());
// verify that the broadcast address is correct
quint32 ip = entry.ip().toIPv4Address();
quint32 mask = entry.netmask().toIPv4Address();
quint32 bcast = entry.broadcast().toIPv4Address();
QCOMPARE(bcast, ip | ~mask);
} }
} }