Merge "Merge remote branch 'gerrit/master' into HEAD" into refactor

This commit is contained in:
Paul Olav Tvete 2011-09-06 11:08:48 +02:00 committed by Qt by Nokia
commit a446ff945f
166 changed files with 1756 additions and 2319 deletions

1
.gitignore vendored
View File

@ -126,6 +126,7 @@ src/openvg/qtopenvgversion.h
src/sql/qtsqlversion.h
src/testlib/qttestversion.h
src/xml/qtxmlversion.h
src/v8/qtv8version.h
# Test generated files
QObject.log

View File

@ -299,9 +299,10 @@ if (abs_path($out_basedir) ne abs_path($qtbasedir)) {
# Generate the new contents
my $newContents = $existingContents;
# Strip out any existing config test results
$newContents =~ s/^config_test_.*$//gms;
$newContents =~ s/^# Compile time test results.*$//gms;
# Strip out any existing config test results or include statements
$newContents =~ s/^config_test_[^\$]*$//gm;
$newContents =~ s/^# Compile time test results[^\$]*$//gm;
$newContents =~ s/include\(\$\$PWD\/..\/.qmake.cache\)$//gm;
# Add any remaining content and make sure we start on a new line
if ($newContents and chop $newContents ne '\n') {
@ -318,6 +319,12 @@ if (abs_path($out_basedir) ne abs_path($qtbasedir)) {
}
}
# Remove blank lines
$newContents =~ s/^[\s]*$//gms;
# Include top level .qmake.cache
$newContents = $newContents . "include(\$\$PWD/../.qmake.cache)\n";
# and open the file
open my $cacheFileHandle, ">$qmakeCachePath" or die "Unable to open $qmakeCachePath for writing: $!\n";

262
configure vendored
View File

@ -780,7 +780,6 @@ CFG_AVX=auto
CFG_REDUCE_RELOCATIONS=no
CFG_NAS=no
CFG_QWS_DEPTHS=all
CFG_USER_BUILD_KEY=
CFG_ACCESSIBILITY=auto
CFG_QT3SUPPORT=no
CFG_ENDIAN=auto
@ -1058,7 +1057,7 @@ while [ "$#" -gt 0 ]; do
shift
VAL=$1
;;
-prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-depths|-make|-nomake|-platform|-xplatform|-buildkey|-sdk|-arch|-host-arch|-mysql_config)
-prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-depths|-make|-nomake|-platform|-xplatform|-sdk|-arch|-host-arch|-mysql_config)
VAR=`echo $1 | sed "s,^-\(.*\),\1,"`
shift
VAL="$1"
@ -1321,9 +1320,6 @@ while [ "$#" -gt 0 ]; do
bindir)
QT_INSTALL_BINS="$VAL"
;;
buildkey)
CFG_USER_BUILD_KEY="$VAL"
;;
sxe)
CFG_SXE="$VAL"
;;
@ -3721,7 +3717,7 @@ if [ "$OPT_HELP" = "yes" ]; then
Usage: $relconf [-h] [-prefix <dir>] [-prefix-install] [-bindir <dir>] [-libdir <dir>]
[-docdir <dir>] [-headerdir <dir>] [-plugindir <dir> ] [-importdir <dir>] [-datadir <dir>]
[-translationdir <dir>] [-sysconfdir <dir>] [-examplesdir <dir>]
[-buildkey <key>] [-release] [-debug] [-debug-and-release]
[-release] [-debug] [-debug-and-release]
[-developer-build] [-shared] [-static] [-no-fast] [-fast] [-no-largefile]
[-largefile] [-no-exceptions] [-exceptions] [-no-accessibility]
[-accessibility] [-no-stl] [-stl] [-no-sql-<driver>] [-sql-<driver>]
@ -3799,12 +3795,6 @@ cat <<EOF
-examplesdir <dir> .... Examples will be installed to <dir>
(default PREFIX/examples)
You may use these options to turn on strict plugin loading.
-buildkey <key> .... Build the Qt library and plugins using the specified
<key>. When the library loads plugins, it will only
load those that have a matching key.
Configure options:
The defaults (*) are usually acceptable. A plus (+) denotes a default value
@ -7611,7 +7601,7 @@ if [ "$CFG_DECLARATIVE" = "yes" ]; then
fi
fi
if [ "$CFG_DECLARATIVE" = "auto" ]; then
if [ "$CFG_SCRIPT" = "no" -o "$CFG_GUI" = "no" ]; then
if [ "$CFG_V8" = "no" -o "$CFG_GUI" = "no" ]; then
CFG_DECLARATIVE=no
else
CFG_DECLARATIVE=yes
@ -7695,226 +7685,6 @@ if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_XARCH" != "no" ] ; then
fi
fi
#-------------------------------------------------------------------------------
# generate QT_BUILD_KEY
#-------------------------------------------------------------------------------
# some compilers generate binary incompatible code between different versions,
# so we need to generate a build key that is different between these compilers
COMPAT_COMPILER=
case "$COMPILER" in
g++*)
# GNU C++
COMPILER_VERSION=`${QMAKE_CONF_COMPILER} -dumpversion 2>/dev/null`
case "$COMPILER_VERSION" in
*.*.*)
QT_GCC_MAJOR_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\1,'`
QT_GCC_MINOR_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\2,'`
QT_GCC_PATCH_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\3,'`
;;
*.*)
QT_GCC_MAJOR_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\).*,\1,'`
QT_GCC_MINOR_VERSION=`echo $COMPILER_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\).*,\2,'`
QT_GCC_PATCH_VERSION=0
;;
esac
case "$COMPILER_VERSION" in
2.95.*)
COMPILER_VERSION="2.95.*"
;;
3.*)
COMPILER_VERSION="3.*"
;;
4.*)
COMPILER_VERSION="4"
;;
*)
;;
esac
[ '!' -z "$COMPILER_VERSION" ] && COMPILER="g++-${COMPILER_VERSION}"
;;
icc*)
# The Intel CC compiler on Unix systems matches the ABI of the g++
# that is found on PATH
COMPAT_COMPILER="icc"
COMPILER="g++-4"
case "`g++ -dumpversion` 2>/dev/null" in
2.95.*)
COMPILER="g++-2.95.*"
;;
3.*)
a COMPILER="g++-3.*"
;;
*)
;;
esac
;;
*)
#
;;
esac
# QT_CONFIG can contain the following:
#
# Things that affect the Qt API/ABI:
#
# Options:
# minimal-config small-config medium-config large-config full-config
#
# Different edition modules:
# gui network canvas table xml opengl sql
#
# Things that do not affect the Qt API/ABI:
# stl
# system-jpeg no-jpeg jpeg
# system-mng no-mng mng
# system-png no-png png
# system-zlib no-zlib zlib
# system-libtiff no-libtiff
# no-gif gif
# debug release
# dll staticlib
#
# nocrosscompiler
# GNUmake
# largefile
# nis
# nas
# tablet
# ipv6
#
# X11 : x11sm xinerama xcursor xfixes xrandr xrender mitshm fontconfig xkb
# Embedded: embedded qpa freetype
#
ALL_OPTIONS=
BUILD_CONFIG=
BUILD_OPTIONS=
# determine the build options
for config_option in $QMAKE_CONFIG $QT_CONFIG; do
SKIP="yes"
case "$config_option" in
*-config)
# take the last *-config setting. this is the highest config being used,
# and is the one that we will use for tagging plugins
BUILD_CONFIG="$config_option"
;;
*) # skip all other options since they don't affect the Qt API/ABI.
;;
esac
if [ "$SKIP" = "no" ]; then
BUILD_OPTIONS="$BUILD_OPTIONS $config_option"
fi
done
# put the options that we are missing into .options
rm -f .options
for opt in `echo $ALL_OPTIONS`; do
SKIP="no"
if echo $BUILD_OPTIONS | grep $opt >/dev/null 2>&1; then
SKIP="yes"
fi
if [ "$SKIP" = "no" ]; then
echo "$opt" >> .options
fi
done
# reconstruct BUILD_OPTIONS with a sorted negative feature list
# (ie. only things that are missing are will be put into the build key)
BUILD_OPTIONS=
if [ -f .options ]; then
for opt in `sort -f .options | uniq`; do
BUILD_OPTIONS="$BUILD_OPTIONS no-$opt"
done
fi
rm -f .options
# QT_NO* defines affect the Qt API (and binary compatibility). they need
# to be included in the build key
for build_option in $D_FLAGS; do
build_option=`echo $build_option | cut -d \" -f 2 -`
case "$build_option" in
QT_NO*)
echo "$build_option" >> .options
;;
*)
# skip all other compiler defines
;;
esac
done
# sort the compile time defines (helps ensure that changes in this configure
# script don't affect the QT_BUILD_KEY generation)
if [ -f .options ]; then
for opt in `sort -f .options | uniq`; do
BUILD_OPTIONS="$BUILD_OPTIONS $opt"
done
fi
rm -f .options
BUILD_OPTIONS="$BUILD_CONFIG $BUILD_OPTIONS"
# extract the operating system from the XPLATFORM
TARGET_OPERATING_SYSTEM=`echo $XPLATFORM | cut -f 2- -d/ | cut -f -1 -d-`
if [ "$XPLATFORM_SYMBIAN" = "yes" ]; then
QT_BUILD_KEY_SYSTEM_PART="Symbian"
else
QT_BUILD_KEY_SYSTEM_PART="$CFG_ARCH $TARGET_OPERATING_SYSTEM $COMPILER"
fi
# when cross-compiling, don't include build-host information (build key is target specific)
QT_BUILD_KEY="$CFG_USER_BUILD_KEY $QT_BUILD_KEY_SYSTEM_PART $BUILD_OPTIONS"
if [ -n "$QT_NAMESPACE" ]; then
QT_BUILD_KEY="$QT_BUILD_KEY $QT_NAMESPACE"
fi
MAC_NEED_TWO_BUILD_KEYS="no"
if [ "$PLATFORM_MAC" = "yes" -a "$CFG_MAC_COCOA" = "yes" ]; then
QT_BUILD_KEY_CARBON=$QT_BUILD_KEY
TARGET_OPERATING_SYSTEM="$TARGET_OPERATING_SYSTEM-cocoa"
QT_BUILD_KEY_COCOA="$CFG_USER_BUILD_KEY $CFG_ARCH $TARGET_OPERATING_SYSTEM $COMPILER $BUILD_OPTIONS"
if [ "$CFG_MAC_CARBON" = "no" ]; then
QT_BUILD_KEY=$QT_BUILD_KEY_COCOA
else
MAC_NEED_TWO_BUILD_KEYS="yes"
fi
fi
# don't break loading plugins build with an older version of Qt
QT_BUILD_KEY_COMPAT=
if [ "$QT_CROSS_COMPILE" = "no" ]; then
# previous versions of Qt used a build key built from the uname
QT_BUILD_KEY_COMPAT="$CFG_USER_BUILD_KEY $UNAME_MACHINE $UNAME_SYSTEM $COMPILER $BUILD_OPTIONS"
if [ -n "$QT_NAMESPACE" ]; then
QT_BUILD_KEY_COMPAT="$QT_BUILD_KEY_COMPAT $QT_NAMESPACE"
fi
fi
# is this compiler compatible with some other "standard" build key
QT_BUILD_KEY_COMPAT_COMPILER=
if [ ! -z "$COMPAT_COMPILER" ]; then
QT_BUILD_KEY_COMPAT_COMPILER="$CFG_USER_BUILD_KEY $CFG_ARCH $TARGET_OPERATING_SYSTEM $COMPAT_COMPILER $BUILD_OPTIONS"
if [ -n "$QT_NAMESPACE" ]; then
QT_BUILD_KEY_COMPAT_COMPILER="$QT_BUILD_KEY_COMPAT_COMPILER $QT_NAMESPACE"
fi
fi
# is this arch compatible with some other "standard" build key
QT_BUILD_KEY_COMPAT_ARCH=
if [ ! -z "$COMPAT_ARCH" ]; then
QT_BUILD_KEY_COMPAT_ARCH="$CFG_USER_BUILD_KEY $COMPAT_ARCH $TARGET_OPERATING_SYSTEM $COMPILER $BUILD_OPTIONS"
if [ -n "$QT_NAMESPACE" ]; then
QT_BUILD_KEY_COMPAT_COMPILER="$QT_BUILD_KEY_COMPAT_ARCH $QT_NAMESPACE"
fi
fi
# strip out leading/trailing/extra whitespace
QT_BUILD_KEY=`echo $QT_BUILD_KEY | sed -e "s, *, ,g" -e "s,^ *,," -e "s, *$,,"`
QT_BUILD_KEY_COMPAT=`echo $QT_BUILD_KEY_COMPAT | sed -e "s, *, ,g" -e "s,^ *,," -e "s, *$,,"`
QT_BUILD_KEY_COMPAT_COMPILER=`echo $QT_BUILD_KEY_COMPAT_COMPILER | sed -e "s, *, ,g" -e "s,^ *,," -e "s, *$,,"`
QT_BUILD_KEY_COMPAT_ARCH=`echo $QT_BUILD_KEY_COMPAT_ARCH | sed -e "s, *, ,g" -e "s,^ *,," -e "s, *$,,"`
#-------------------------------------------------------------------------------
# part of configuration information goes into qconfig.h
#-------------------------------------------------------------------------------
@ -7947,32 +7717,6 @@ cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
#define Q_LITTLE_ENDIAN 1234
EOF
if [ "$MAC_NEED_TWO_BUILD_KEYS" = "no" ]; then
echo "#define QT_BUILD_KEY \"$QT_BUILD_KEY\"" \
>> "$outpath/src/corelib/global/qconfig.h.new"
else
cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
#define QT_BUILD_KEY_CARBON "$QT_BUILD_KEY_CARBON"
#define QT_BUILD_KEY_COCOA "$QT_BUILD_KEY_COCOA"
EOF
fi
if [ -n "$QT_BUILD_KEY_COMPAT" ]; then
echo "#define QT_BUILD_KEY_COMPAT \"$QT_BUILD_KEY_COMPAT\"" \
>> "$outpath/src/corelib/global/qconfig.h.new"
fi
if [ -n "$QT_BUILD_KEY_COMPAT_COMPILER" ]; then
echo "#define QT_BUILD_KEY_COMPAT2 \"$QT_BUILD_KEY_COMPAT_COMPILER\"" \
>> "$outpath/src/corelib/global/qconfig.h.new"
fi
if [ -n "$QT_BUILD_KEY_COMPAT_ARCH" ]; then
echo "#define QT_BUILD_KEY_COMPAT3 \"$QT_BUILD_KEY_COMPAT_ARCH\"" \
>> "$outpath/src/corelib/global/qconfig.h.new"
fi
echo "" >>"$outpath/src/corelib/global/qconfig.h.new"
echo "#ifdef QT_BOOTSTRAPPED" >>"$outpath/src/corelib/global/qconfig.h.new"
if [ "$CFG_HOST_ENDIAN" = "auto" ]; then
cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF

4
dist/changes-5.0.0 vendored
View File

@ -24,6 +24,10 @@ information about a particular change.
via QT_DISABLE_DEPRECATED_BEFORE), use
QSslCertificate::subjectAlternativeNames() instead.
- QLibraryInfo::buildKey() has been removed. Likewise, the QT_BUILD_KEY
preprocessor #define has also been removed. The build-key is obsolete
and is no longer necessary.
****************************************************************************
* General *
****************************************************************************

View File

@ -1182,10 +1182,6 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max
class QDataStream;
#ifndef QT_BUILD_KEY
#define QT_BUILD_KEY "unspecified"
#endif
#if defined(Q_WS_MAC)
# ifndef QMAC_QMENUBAR_NO_EVENT
# define QMAC_QMENUBAR_NO_EVENT

View File

@ -202,21 +202,6 @@ QLibraryInfo::licensedProducts()
return QString::fromLatin1(str);
}
/*!
Returns a unique key identifying this build of Qt and its
configurations. This key is not globally unique, rather only useful
for establishing of two configurations are compatible. This can be
used to compare with the \c QT_BUILD_KEY preprocessor symbol.
\sa location()
*/
QString
QLibraryInfo::buildKey()
{
return QString::fromLatin1(QT_BUILD_KEY);
}
/*!
\since 4.6
Returns the installation date for this build of Qt. The install date will
@ -514,18 +499,6 @@ void qt_core_boilerplate()
"Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).\n"
"Contact: Nokia Corporation (qt-info@nokia.com)\n"
"\n"
"Build key: " QT_BUILD_KEY "\n"
"Compat build key: "
#ifdef QT_BUILD_KEY_COMPAT
"| " QT_BUILD_KEY_COMPAT " "
#endif
#ifdef QT_BUILD_KEY_COMPAT2
"| " QT_BUILD_KEY_COMPAT2 " "
#endif
#ifdef QT_BUILD_KEY_COMPAT3
"| " QT_BUILD_KEY_COMPAT3 " "
#endif
"|\n"
"Build date: %s\n"
"Installation prefix: %s\n"
"Library path: %s\n"

View File

@ -59,7 +59,6 @@ public:
static QString licensee();
static QString licensedProducts();
static QString buildKey();
#ifndef QT_NO_DATESTRING
static QDate buildDate();
#endif //QT_NO_DATESTRING

View File

@ -190,7 +190,7 @@ inline void QDirPrivate::resolveAbsoluteEntry() const
QString absoluteName;
if (fileEngine.isNull()) {
if (!dirEntry.isRelative()) {
if (!dirEntry.isRelative() && dirEntry.isClean()) {
absoluteDirEntry = dirEntry;
return;
}

View File

@ -114,9 +114,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
{
QString orig = entry.filePath();
const bool isAbsolute = entry.isAbsolute();
const bool isDirty = (orig.contains(QLatin1String("/../")) || orig.contains(QLatin1String("/./")) ||
orig.contains(QLatin1String("//")) ||
orig.endsWith(QLatin1String("/..")) || orig.endsWith(QLatin1String("/.")));
const bool isDirty = !entry.isClean();
if (isAbsolute && !isDirty)
return entry;

View File

@ -218,7 +218,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
//static
QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
{
if (entry.isAbsolute())
if (entry.isAbsolute() && entry.isClean())
return entry;
QByteArray orig = entry.nativeFilePath();

View File

@ -508,11 +508,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
if (!entry.isRelative()) {
#if !defined(Q_OS_WINCE)
if (entry.isAbsolute()
&& !entry.filePath().contains(QLatin1String("/../"))
&& !entry.filePath().contains(QLatin1String("/./"))
&& !entry.filePath().endsWith(QLatin1String("/.."))
&& !entry.filePath().endsWith(QLatin1String("/."))) {
if (entry.isAbsolute() && entry.isClean()) {
ret = entry.filePath();
} else {
ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(entry.filePath()));

View File

@ -380,4 +380,35 @@ void QFileSystemEntry::findFileNameSeparators() const
}
}
bool QFileSystemEntry::isClean() const
{
resolveFilePath();
int dots = 0;
bool dotok = true; // checking for ".." or "." starts to relative paths
bool slashok = true;
for (QString::const_iterator iter = m_filePath.constBegin(); iter != m_filePath.constEnd(); iter++) {
if (*iter == QLatin1Char('/')) {
if (dots == 1 || dots == 2)
return false; // path contains "./" or "../"
if (!slashok)
return false; // path contains "//"
dots = 0;
dotok = true;
slashok = false;
} else if (dotok) {
slashok = true;
if (*iter == QLatin1Char('.')) {
dots++;
if (dots > 2)
dotok = false;
} else {
//path element contains a character other than '.', it's clean
dots = 0;
dotok = false;
}
}
}
return (dots != 1 && dots != 2); // clean if path doesn't end in . or ..
}
QT_END_NAMESPACE

View File

@ -91,6 +91,7 @@ public:
QString completeSuffix() const;
bool isAbsolute() const;
bool isRelative() const;
bool isClean() const;
#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
bool isDriveRoot() const;

View File

@ -266,18 +266,6 @@ bool QCoreApplicationPrivate::is_app_closing = false;
// initialized in qcoreapplication and in qtextstream autotest when setlocale is called.
Q_CORE_EXPORT bool qt_locale_initialized = false;
/*
Create an instance of Trolltech.conf. This ensures that the settings will not
be thrown out of QSetting's cache for unused settings.
*/
Q_GLOBAL_STATIC_WITH_ARGS(QSettings, staticTrolltechConf, (QSettings::UserScope, QLatin1String("Trolltech")))
QSettings *QCoreApplicationPrivate::trolltechConf()
{
return staticTrolltechConf();
}
Q_CORE_EXPORT uint qGlobalPostedEventsCount()
{
QThreadData *currentThreadData = QThreadData::current();

View File

@ -141,7 +141,6 @@ public:
static uint attribs;
static inline bool testAttribute(uint flag) { return attribs & (1 << flag); }
static int app_compile_version;
static QSettings *trolltechConf();
};
QT_END_NAMESPACE

View File

@ -45,7 +45,6 @@
#include "qfactoryinterface.h"
#include "qmap.h"
#include <qdir.h>
#include <qsettings.h>
#include <qdebug.h>
#include "qmutex.h"
#include "qplugin.h"
@ -107,7 +106,6 @@ void QFactoryLoader::update()
#ifdef QT_SHARED
Q_D(QFactoryLoader);
QStringList paths = QCoreApplication::libraryPaths();
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
for (int i = 0; i < paths.count(); ++i) {
const QString &pluginDir = paths.at(i);
// Already loaded, skip it...
@ -127,7 +125,7 @@ void QFactoryLoader::update()
qDebug() << "QFactoryLoader::QFactoryLoader() looking at" << fileName;
}
library = QLibraryPrivate::findOrCreate(QFileInfo(fileName).canonicalFilePath());
if (!library->isPlugin(&settings)) {
if (!library->isPlugin()) {
if (qt_debug_component()) {
qDebug() << library->errorString;
qDebug() << " not a plugin";
@ -135,45 +133,26 @@ void QFactoryLoader::update()
library->release();
continue;
}
QString regkey = QString::fromLatin1("Qt Factory Cache %1.%2/%3:/%4")
.arg((QT_VERSION & 0xff0000) >> 16)
.arg((QT_VERSION & 0xff00) >> 8)
.arg(QLatin1String(d->iid))
.arg(fileName);
QStringList reg, keys;
reg = settings.value(regkey).toStringList();
if (reg.count() && library->lastModified == reg[0]) {
keys = reg;
keys.removeFirst();
} else {
if (!library->loadPlugin()) {
if (qt_debug_component()) {
qDebug() << library->errorString;
qDebug() << " could not load";
}
library->release();
continue;
QStringList keys;
if (!library->loadPlugin()) {
if (qt_debug_component()) {
qDebug() << library->errorString;
qDebug() << " could not load";
}
QObject *instance = library->instance();
if (!instance) {
library->release();
// ignore plugins that have a valid signature but cannot be loaded.
continue;
}
QFactoryInterface *factory = qobject_cast<QFactoryInterface*>(instance);
if (instance && factory && instance->qt_metacast(d->iid))
keys = factory->keys();
if (keys.isEmpty())
library->unload();
reg.clear();
reg << library->lastModified;
reg += keys;
settings.setValue(regkey, reg);
library->release();
continue;
}
if (qt_debug_component()) {
qDebug() << "keys" << keys;
QObject *instance = library->instance();
if (!instance) {
library->release();
// ignore plugins that have a valid signature but cannot be loaded.
continue;
}
QFactoryInterface *factory = qobject_cast<QFactoryInterface*>(instance);
if (instance && factory && instance->qt_metacast(d->iid))
keys = factory->keys();
if (keys.isEmpty())
library->unload();
if (keys.isEmpty()) {
library->release();
continue;

View File

@ -50,8 +50,6 @@
#include <qfileinfo.h>
#include <qmutex.h>
#include <qmap.h>
#include <qsettings.h>
#include <qdatetime.h>
#include <private/qcoreapplication_p.h>
#ifdef Q_OS_MAC
# include <private/qcore_mac_p.h>
@ -250,7 +248,7 @@ static int qt_tokenize(const char *s, ulong s_len, ulong *advance,
/*
returns true if the string s was correctly parsed, false otherwise.
*/
static bool qt_parse_pattern(const char *s, uint *version, bool *debug, QByteArray *key)
static bool qt_parse_pattern(const char *s, uint *version, bool *debug)
{
bool ret = true;
@ -282,10 +280,6 @@ static bool qt_parse_pattern(const char *s, uint *version, bool *debug, QByteArr
}
} else if (qstrncmp("debug", pinfo.results[0], pinfo.lengths[0]) == 0) {
*debug = qstrncmp("true", pinfo.results[1], pinfo.lengths[1]) == 0;
} else if (qstrncmp("buildkey", pinfo.results[0],
pinfo.lengths[0]) == 0){
// save buildkey
*key = QByteArray(pinfo.results[1], pinfo.lengths[1]);
}
} while (parse == 1 && parselen > 0);
@ -337,11 +331,11 @@ static long qt_find_pattern(const char *s, ulong s_len,
we can get the verification data without have to actually load the library.
This lets us detect mismatches more safely.
Returns false if version/key information is not present, or if the
Returns false if version information is not present, or if the
information could not be read.
Returns true if version/key information is present and successfully read.
Returns true if version information is present and successfully read.
*/
static bool qt_unix_query(const QString &library, uint *version, bool *debug, QByteArray *key, QLibraryPrivate *lib = 0)
static bool qt_unix_query(const QString &library, uint *version, bool *debug, QLibraryPrivate *lib = 0)
{
QFile file(library);
if (!file.open(QIODevice::ReadOnly)) {
@ -396,7 +390,7 @@ static bool qt_unix_query(const QString &library, uint *version, bool *debug, QB
#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
bool ret = false;
if (pos >= 0)
ret = qt_parse_pattern(filedata + pos, version, debug, key);
ret = qt_parse_pattern(filedata + pos, version, debug);
if (!ret && lib)
lib->errorString = QLibrary::tr("Plugin verification data mismatch in '%1'").arg(library);
@ -636,7 +630,7 @@ typedef const char * __stdcall (*QtPluginQueryVerificationDataFunction)();
typedef const char * (*QtPluginQueryVerificationDataFunction)();
#endif
bool qt_get_verificationdata(QtPluginQueryVerificationDataFunction pfn, uint *qt_version, bool *debug, QByteArray *key, bool *exceptionThrown)
bool qt_get_verificationdata(QtPluginQueryVerificationDataFunction pfn, uint *qt_version, bool *debug, bool *exceptionThrown)
{
*exceptionThrown = false;
const char *szData = 0;
@ -649,10 +643,10 @@ bool qt_get_verificationdata(QtPluginQueryVerificationDataFunction pfn, uint *qt
#else
szData = pfn();
#endif
return qt_parse_pattern(szData, qt_version, debug, key);
return qt_parse_pattern(szData, qt_version, debug);
}
bool QLibraryPrivate::isPlugin(QSettings *settings)
bool QLibraryPrivate::isPlugin()
{
errorString.clear();
if (pluginState != MightBeAPlugin)
@ -660,7 +654,6 @@ bool QLibraryPrivate::isPlugin(QSettings *settings)
#ifndef QT_NO_PLUGIN_CHECK
bool debug = !QLIBRARY_AS_DEBUG;
QByteArray key;
bool success = false;
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
@ -677,141 +670,88 @@ bool QLibraryPrivate::isPlugin(QSettings *settings)
}
#endif
QFileInfo fileinfo(fileName);
#ifndef QT_NO_DATESTRING
lastModified = fileinfo.lastModified().toString(Qt::ISODate);
#endif
QString regkey = QString::fromLatin1("Qt Plugin Cache %1.%2.%3/%4")
.arg((QT_VERSION & 0xff0000) >> 16)
.arg((QT_VERSION & 0xff00) >> 8)
.arg(QLIBRARY_AS_DEBUG ? QLatin1String("debug") : QLatin1String("false"))
.arg(fileName);
#ifdef Q_WS_MAC
// On Mac, add the application arch to the reg key in order to
// cache plugin information separately for each arch. This prevents
// Qt from wrongly caching plugin load failures when the archs
// don't match.
#if defined(__x86_64__)
regkey += QLatin1String("-x86_64");
#elif defined(__i386__)
regkey += QLatin1String("-i386");
#elif defined(__ppc64__)
regkey += QLatin1String("-ppc64");
#elif defined(__ppc__)
regkey += QLatin1String("-ppc");
#endif
#endif // Q_WS_MAC
QStringList reg;
#ifndef QT_NO_SETTINGS
if (!settings) {
settings = QCoreApplicationPrivate::trolltechConf();
}
reg = settings->value(regkey).toStringList();
#endif
if (reg.count() == 4 && lastModified == reg.at(3)) {
qt_version = reg.at(0).toUInt(0, 16);
debug = bool(reg.at(1).toInt());
key = reg.at(2).toLatin1();
success = qt_version != 0;
} else {
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)
if (!pHnd) {
// use unix shortcut to avoid loading the library
success = qt_unix_query(fileName, &qt_version, &debug, &key, this);
} else
if (!pHnd) {
// use unix shortcut to avoid loading the library
success = qt_unix_query(fileName, &qt_version, &debug, this);
} else
#endif
{
bool retryLoadLibrary = false; // Only used on Windows with MS compiler.(false in other cases)
do {
bool temporary_load = false;
{
bool retryLoadLibrary = false; // Only used on Windows with MS compiler.(false in other cases)
do {
bool temporary_load = false;
#ifdef Q_OS_WIN
HMODULE hTempModule = 0;
HMODULE hTempModule = 0;
#endif
if (!pHnd) {
if (!pHnd) {
#ifdef Q_OS_WIN
DWORD dwFlags = (retryLoadLibrary) ? 0: DONT_RESOLVE_DLL_REFERENCES;
//avoid 'Bad Image' message box
UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
hTempModule = ::LoadLibraryEx((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, dwFlags);
SetErrorMode(oldmode);
DWORD dwFlags = (retryLoadLibrary) ? 0: DONT_RESOLVE_DLL_REFERENCES;
//avoid 'Bad Image' message box
UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
hTempModule = ::LoadLibraryEx((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, dwFlags);
SetErrorMode(oldmode);
#else
# if defined(Q_OS_SYMBIAN)
//Guard against accidentally trying to load non-plugin libraries by making sure the stub exists
if (fileinfo.exists())
//Guard against accidentally trying to load non-plugin libraries by making sure the stub exists
if (fileinfo.exists())
# endif
temporary_load = load_sys();
temporary_load = load_sys();
#endif
}
}
#ifdef Q_OS_WIN
QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = hTempModule ? (QtPluginQueryVerificationDataFunction)
QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = hTempModule ? (QtPluginQueryVerificationDataFunction)
#ifdef Q_OS_WINCE
::GetProcAddress(hTempModule, L"qt_plugin_query_verification_data")
::GetProcAddress(hTempModule, L"qt_plugin_query_verification_data")
#else
::GetProcAddress(hTempModule, "qt_plugin_query_verification_data")
::GetProcAddress(hTempModule, "qt_plugin_query_verification_data")
#endif
: (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
: (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
#else
QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = NULL;
QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = NULL;
# if defined(Q_OS_SYMBIAN)
if (temporary_load) {
qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
// If resolving with function name failed (i.e. not STDDLL), try resolving using known ordinal
if (!qtPluginQueryVerificationDataFunction)
qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("1");
}
# else
if (temporary_load) {
qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
// If resolving with function name failed (i.e. not STDDLL), try resolving using known ordinal
if (!qtPluginQueryVerificationDataFunction)
qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("1");
}
# else
qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
# endif
#endif
bool exceptionThrown = false;
bool ret = qt_get_verificationdata(qtPluginQueryVerificationDataFunction,
&qt_version, &debug, &key, &exceptionThrown);
if (!exceptionThrown) {
if (!ret) {
qt_version = 0;
key = "unknown";
if (temporary_load)
unload_sys();
} else {
success = true;
}
retryLoadLibrary = false;
bool exceptionThrown = false;
bool ret = qt_get_verificationdata(qtPluginQueryVerificationDataFunction,
&qt_version, &debug, &exceptionThrown);
if (!exceptionThrown) {
if (!ret) {
qt_version = 0;
if (temporary_load)
unload_sys();
} else {
success = true;
}
retryLoadLibrary = false;
}
#ifdef QT_USE_MS_STD_EXCEPTION
else {
// An exception was thrown when calling qt_plugin_query_verification_data().
// This usually happens when plugin is compiled with the /clr compiler flag,
// & will only work if the dependencies are loaded & DLLMain() is called.
// LoadLibrary() will do this, try once with this & if it fails dont load.
retryLoadLibrary = !retryLoadLibrary;
}
else {
// An exception was thrown when calling qt_plugin_query_verification_data().
// This usually happens when plugin is compiled with the /clr compiler flag,
// & will only work if the dependencies are loaded & DLLMain() is called.
// LoadLibrary() will do this, try once with this & if it fails dont load.
retryLoadLibrary = !retryLoadLibrary;
}
#endif
#ifdef Q_OS_WIN
if (hTempModule) {
BOOL ok = ::FreeLibrary(hTempModule);
if (ok) {
hTempModule = 0;
}
if (hTempModule) {
BOOL ok = ::FreeLibrary(hTempModule);
if (ok) {
hTempModule = 0;
}
#endif
} while(retryLoadLibrary); // Will be 'false' in all cases other than when an
// exception is thrown(will happen only when using a MS compiler)
}
// Qt 4.5 compatibility: stl doesn't affect binary compatibility
key.replace(" no-stl", "");
#ifndef QT_NO_SETTINGS
QStringList queried;
queried << QString::number(qt_version,16)
<< QString::number((int)debug)
<< QLatin1String(key)
<< lastModified;
settings->setValue(regkey, queried);
}
#endif
} while (retryLoadLibrary); // Will be 'false' in all cases other than when an
// exception is thrown(will happen only when using a MS compiler)
}
if (!success) {
@ -840,31 +780,6 @@ bool QLibraryPrivate::isPlugin(QSettings *settings)
.arg((qt_version&0xff00) >> 8)
.arg(qt_version&0xff)
.arg(debug ? QLatin1String("debug") : QLatin1String("release"));
} else if (key != QT_BUILD_KEY
// we may have some compatibility keys, try them too:
#ifdef QT_BUILD_KEY_COMPAT
&& key != QT_BUILD_KEY_COMPAT
#endif
#ifdef QT_BUILD_KEY_COMPAT2
&& key != QT_BUILD_KEY_COMPAT2
#endif
#ifdef QT_BUILD_KEY_COMPAT3
&& key != QT_BUILD_KEY_COMPAT3
#endif
) {
if (qt_debug_component()) {
qWarning("In %s:\n"
" Plugin uses incompatible Qt library\n"
" expected build key \"%s\", got \"%s\"",
(const char*) QFile::encodeName(fileName),
QT_BUILD_KEY,
key.isEmpty() ? "<null>" : (const char *) key);
}
errorString = QLibrary::tr("The plugin '%1' uses incompatible Qt library."
" Expected build key \"%2\", got \"%3\"")
.arg(fileName)
.arg(QLatin1String(QT_BUILD_KEY))
.arg(key.isEmpty() ? QLatin1String("<null>") : QLatin1String((const char *) key));
#ifndef QT_NO_DEBUG_PLUGIN_CHECK
} else if(debug != QLIBRARY_AS_DEBUG) {
//don't issue a qWarning since we will hopefully find a non-debug? --Sam

View File

@ -68,7 +68,6 @@ QT_BEGIN_NAMESPACE
bool qt_debug_component();
class QSettings;
class QLibraryPrivate
{
public:
@ -99,7 +98,7 @@ public:
QString errorString;
QLibrary::LoadHints loadHints;
bool isPlugin(QSettings *settings = 0);
bool isPlugin();
private:

View File

@ -117,8 +117,7 @@ void Q_CORE_EXPORT qRegisterStaticPluginInstanceFunction(QtPluginInstanceFunctio
static const char qt_plugin_verification_data[] = \
"pattern=""QT_PLUGIN_VERIFICATION_DATA""\n" \
"version="QT_VERSION_STR"\n" \
"debug="QPLUGIN_DEBUG_STR"\n" \
"buildkey="QT_BUILD_KEY;
"debug="QPLUGIN_DEBUG_STR;
# if defined (Q_OF_ELF) && defined (Q_CC_GNU)
# define Q_PLUGIN_VERIFICATION_SECTION \

View File

@ -98,22 +98,6 @@ QT_BEGIN_NAMESPACE
every instance has called unload(). Right before the unloading
happen, the root component will also be deleted.
In order to speed up loading and validation of plugins, some of
the information that is collected during loading is cached in
persistent memory (through QSettings). For instance, the result
of a load operation (e.g. succeeded or failed) is stored in the
cache, so that subsequent load operations don't try to load an
invalid plugin. However, if the "last modified" timestamp of
a plugin has changed, the plugin's cache entry is invalidated
and the plugin is reloaded regardless of the values in the cache
entry. The cache entry is then updated with the new result of the
load operation.
This also means that the timestamp must be updated each time the
plugin or any dependent resources (such as a shared library) is
updated, since the dependent resources might influence the result
of loading a plugin.
See \l{How to Create Qt Plugins} for more information about
how to make your application extensible through plugins.

View File

@ -1402,7 +1402,8 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion
ucs4 = QChar::surrogateToUcs4(high, ucs4);
}
}
if (QChar::unicodeVersion(ucs4) > version)
const QChar::UnicodeVersion v = QChar::unicodeVersion(ucs4);
if (v > version || v == QChar::Unicode_Unassigned)
continue;
int length;
int tag;
@ -1462,7 +1463,7 @@ static ushort ligatureHelper(ushort u1, ushort u2)
return 0;
}
static void composeHelper(QString *str, int from)
static void composeHelper(QString *str, QChar::UnicodeVersion version, int from)
{
QString &s = *str;
@ -1482,7 +1483,14 @@ static void composeHelper(QString *str, int from)
++pos;
}
}
int combining = QChar::combiningClass(uc);
const QUnicodeTables::Properties *p = qGetProp(uc);
if (p->unicodeVersion > version || p->unicodeVersion == QChar::Unicode_Unassigned) {
starter = -1; // to prevent starter == pos - 1
lastCombining = 0;
++pos;
continue;
}
int combining = p->combiningClass;
if (starter == pos - 1 || combining > lastCombining) {
// allowed to form ligature with S
QChar ligature = ligatureHelper(s.at(starter).unicode(), uc);
@ -1529,7 +1537,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
ushort c2 = 0;
{
const QUnicodeTables::Properties *p = qGetProp(u2);
if ((QChar::UnicodeVersion)p->unicodeVersion <= version)
if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned)
c2 = p->combiningClass;
}
if (c2 == 0) {
@ -1540,7 +1548,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
ushort c1 = 0;
{
const QUnicodeTables::Properties *p = qGetProp(u1);
if ((QChar::UnicodeVersion)p->unicodeVersion <= version)
if (p->unicodeVersion <= version && p->unicodeVersion != QChar::Unicode_Unassigned)
c1 = p->combiningClass;
}

View File

@ -181,7 +181,7 @@ void **QListData::append()
}
// ensures that enough space is available to append the list
void **QListData::append2(const QListData& l)
void **QListData::append(const QListData& l)
{
return append(l.d->end - l.d->begin);
}

View File

@ -79,9 +79,6 @@ struct Q_CORE_EXPORT QListData {
Data *detach(int alloc);
Data *detach_grow(int *i, int n);
Data *detach(); // remove in 5.0
Data *detach2(); // remove in 5.0
Data *detach3(); // remove in 5.0
void realloc(int alloc);
static Data shared_null;
Data *d;
@ -89,7 +86,6 @@ struct Q_CORE_EXPORT QListData {
void **append(int n);
void **append();
void **append(const QListData &l);
void **append2(const QListData &l); // remove in 5.0
void **prepend();
void **insert(int i);
void remove(int i);
@ -338,7 +334,7 @@ private:
Node *detach_helper_grow(int i, int n);
void detach_helper(int alloc);
void detach_helper();
void free(QListData::Data *d);
void dealloc(QListData::Data *d);
void node_construct(Node *n, const T &t);
void node_destruct(Node *n);
@ -426,7 +422,7 @@ Q_INLINE_TEMPLATE QList<T> &QList<T>::operator=(const QList<T> &l)
QListData::Data *o = l.d;
o->ref.ref();
if (!d->ref.deref())
free(d);
dealloc(d);
d = o;
if (!d->sharable)
detach_helper();
@ -683,7 +679,7 @@ Q_OUTOFLINE_TEMPLATE typename QList<T>::Node *QList<T>::detach_helper_grow(int i
}
if (!x->ref.deref())
free(x);
dealloc(x);
return reinterpret_cast<Node *>(p.begin() + i);
}
@ -702,7 +698,7 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::detach_helper(int alloc)
}
if (!x->ref.deref())
free(x);
dealloc(x);
}
template <typename T>
@ -715,7 +711,7 @@ template <typename T>
Q_OUTOFLINE_TEMPLATE QList<T>::~QList()
{
if (!d->ref.deref())
free(d);
dealloc(d);
}
template <typename T>
@ -736,9 +732,8 @@ Q_OUTOFLINE_TEMPLATE bool QList<T>::operator==(const QList<T> &l) const
return true;
}
// ### Qt 5: rename freeData() to avoid confusion with std::free()
template <typename T>
Q_OUTOFLINE_TEMPLATE void QList<T>::free(QListData::Data *data)
Q_OUTOFLINE_TEMPLATE void QList<T>::dealloc(QListData::Data *data)
{
node_destruct(reinterpret_cast<Node *>(data->array + data->begin),
reinterpret_cast<Node *>(data->array + data->end));
@ -802,7 +797,7 @@ Q_OUTOFLINE_TEMPLATE QList<T> &QList<T>::operator+=(const QList<T> &l)
} else {
Node *n = (d->ref != 1)
? detach_helper_grow(INT_MAX, l.size())
: reinterpret_cast<Node *>(p.append2(l.p));
: reinterpret_cast<Node *>(p.append(l.p));
QT_TRY {
node_copy(n, reinterpret_cast<Node *>(p.end()),
reinterpret_cast<Node *>(l.p.begin()));

View File

@ -89,6 +89,8 @@ Q_GLOBAL_STATIC(QLocalePrivate, globalLocalePrivate)
#ifdef QT_USE_ICU
extern bool qt_initIcu(const QString &localeName);
extern bool qt_u_strToUpper(const QString &str, QString *out, const QLocale &locale);
extern bool qt_u_strToLower(const QString &str, QString *out, const QLocale &locale);
#endif
/******************************************************************************
@ -2171,6 +2173,42 @@ Qt::LayoutDirection QLocale::textDirection() const
return Qt::LeftToRight;
}
/*!
\since 4.8
Returns an uppercase copy of \a str.
*/
QString QLocale::toUpper(const QString &str) const
{
#ifdef QT_USE_ICU
{
QString result;
if (qt_u_strToUpper(str, &result, *this))
return result;
// else fall through and use Qt's toUpper
}
#endif
return str.toUpper();
}
/*!
\since 4.8
Returns a lowercase copy of \a str.
*/
QString QLocale::toLower(const QString &str) const
{
#ifdef QT_USE_ICU
{
QString result;
if (qt_u_strToLower(str, &result, *this))
return result;
// else fall through and use Qt's toUpper
}
#endif
return str.toLower();
}
/*!
\since 4.5

View File

@ -724,6 +724,9 @@ public:
Qt::LayoutDirection textDirection() const;
QString toUpper(const QString &str) const;
QString toLower(const QString &str) const;
QString currencySymbol(CurrencySymbolFormat = CurrencySymbol) const;
QString toCurrencyString(qlonglong, const QString &symbol = QString()) const;
QString toCurrencyString(qulonglong, const QString &symbol = QString()) const;

View File

@ -105,8 +105,6 @@ QTextCodec *QString::codecForCStrings;
#ifdef QT_USE_ICU
// qlocale_icu.cpp
extern bool qt_ucol_strcoll(const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result);
extern bool qt_u_strToUpper(const QString &str, QString *out, const QLocale &locale);
extern bool qt_u_strToLower(const QString &str, QString *out, const QLocale &locale);
#endif
@ -4878,7 +4876,10 @@ QString QString::rightJustified(int width, QChar fill, bool truncate) const
\snippet doc/src/snippets/qstring/main.cpp 75
\sa toUpper()
The case conversion will always happen in the 'C' locale. For locale dependent
case folding use QLocale::toLower()
\sa toUpper(), QLocale::toLower()
*/
QString QString::toLower() const
@ -4889,15 +4890,6 @@ QString QString::toLower() const
if (!d->size)
return *this;
#ifdef QT_USE_ICU
{
QString result;
if (qt_u_strToLower(*this, &result, QLocale()))
return result;
// else fall through and use Qt's toUpper
}
#endif
const ushort *e = d->data() + d->size;
// this avoids one out of bounds check in the loop
@ -4978,7 +4970,10 @@ QString QString::toCaseFolded() const
\snippet doc/src/snippets/qstring/main.cpp 81
\sa toLower()
The case conversion will always happen in the 'C' locale. For locale dependent
case folding use QLocale::toUpper()
\sa toLower(), QLocale::toLower()
*/
QString QString::toUpper() const
@ -4989,15 +4984,6 @@ QString QString::toUpper() const
if (!d->size)
return *this;
#ifdef QT_USE_ICU
{
QString result;
if (qt_u_strToUpper(*this, &result, QLocale()))
return result;
// else fall through and use Qt's toUpper
}
#endif
const ushort *e = d->data() + d->size;
// this avoids one out of bounds check in the loop
@ -6244,7 +6230,7 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::
if (mode == QString::NormalizationForm_D || mode == QString::NormalizationForm_KD)
return;
composeHelper(data, from);
composeHelper(data, version, from);
}

View File

@ -58,6 +58,29 @@
#include <pngconf.h>
#endif
#if PNG_LIBPNG_VER >= 10400 && PNG_LIBPNG_VER <= 10502 \
&& defined(PNG_PEDANTIC_WARNINGS_SUPPORTED)
/*
Versions 1.4.0 to 1.5.2 of libpng declare png_longjmp_ptr to
have a noreturn attribute if PNG_PEDANTIC_WARNINGS_SUPPORTED
is enabled, but most declarations of longjmp in the wild do
not add this attribute. This causes problems when the png_jmpbuf
macro expands to calling png_set_longjmp_fn with a mismatched
longjmp, as compilers such as Clang will treat this as an error.
To work around this we override the png_jmpbuf macro to cast
longjmp to a png_longjmp_ptr.
*/
# undef png_jmpbuf
# ifdef PNG_SETJMP_SUPPORTED
# define png_jmpbuf(png_ptr) \
(*png_set_longjmp_fn((png_ptr), (png_longjmp_ptr)longjmp, sizeof(jmp_buf)))
# else
# define png_jmpbuf(png_ptr) \
(LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)
# endif
#endif
#ifdef Q_OS_WINCE
#define CALLBACK_CALL_TYPE __cdecl
#else

View File

@ -64,4 +64,45 @@ void * QPlatformNativeInterface::nativeResourceForBackingStore(const QByteArray
return 0;
}
/*!
Contains generic window properties that the platform may utilize.
*/
QVariantMap QPlatformNativeInterface::windowProperties(QPlatformWindow *window) const
{
return QVariantMap();
}
/*!
Returns a window property with \a name.
If the property does not exist, returns a default-constructed value.
*/
QVariant QPlatformNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const
{
Q_UNUSED(window);
Q_UNUSED(name);
return QVariant();
}
/*!
Returns a window property with \a name. If the value does not exist, defaultValue is returned.
*/
QVariant QPlatformNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const
{
Q_UNUSED(window);
Q_UNUSED(name);
Q_UNUSED(defaultValue);
return QVariant();
}
/*!
Sets a window property with \a name to \a value.
*/
void QPlatformNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value)
{
Q_UNUSED(window);
Q_UNUSED(name);
Q_UNUSED(value);
}
QT_END_NAMESPACE

View File

@ -43,6 +43,8 @@
#define QPLATFORMNATIVEINTERFACE_QPA_H
#include <QtGui/qwindowdefs.h>
#include <QtCore/QObject>
#include <QtCore/QVariant>
QT_BEGIN_HEADER
@ -52,14 +54,24 @@ QT_MODULE(Gui)
class QOpenGLContext;
class QWindow;
class QPlatformWindow;
class QBackingStore;
class Q_GUI_EXPORT QPlatformNativeInterface
class Q_GUI_EXPORT QPlatformNativeInterface : public QObject
{
Q_OBJECT
public:
virtual void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context);
virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window);
virtual void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore);
virtual QVariantMap windowProperties(QPlatformWindow *window) const;
virtual QVariant windowProperty(QPlatformWindow *window, const QString &name) const;
virtual QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const;
virtual void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value);
Q_SIGNALS:
void windowPropertyChanged(QPlatformWindow *window, const QString &propertyName);
};
QT_END_NAMESPACE

View File

@ -425,13 +425,12 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal
swapped = true;
qSwap(y1, y2);
qSwap(x1, x2);
--x1; --x2; --y1; --y2;
}
int xinc = F16Dot16FixedDiv(x2 - x1, y2 - y1);
int x = x1 << 10;
int y = (y1+32) >> 6;
int ys = (y2+32) >> 6;
int y = y1 >> 6;
int ys = y2 >> 6;
if (y != ys) {
x += ( ((((y << 6) + 32 - y1))) * xinc ) >> 6;
@ -457,13 +456,12 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal
swapped = true;
qSwap(x1, x2);
qSwap(y1, y2);
--x1; --x2; --y1; --y2;
}
int yinc = F16Dot16FixedDiv(y2 - y1, x2 - x1);
int y = y1 << 10;
int x = (x1+32) >> 6;
int xs = (x2+32) >> 6;
int x = x1 >> 6;
int xs = x2 >> 6;
if (x != xs) {
y += ( ((((x << 6) + 32 - x1))) * yinc ) >> 6;
@ -716,10 +714,11 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2,
QCosmeticStroker::Point last = stroker->lastPixel;
// qDebug() << "stroke" << x1/64. << y1/64. << x2/64. << y2/64. << capString(caps);
// qDebug() << "stroke" << x1/64. << y1/64. << x2/64. << y2/64.;
if (dx < dy) {
// vertical
QCosmeticStroker::Direction dir = QCosmeticStroker::TopToBottom;
bool swapped = false;
if (y1 > y2) {
@ -727,30 +726,31 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2,
qSwap(y1, y2);
qSwap(x1, x2);
caps = swapCaps(caps);
--x1; --x2; --y1; --y2;
dir = QCosmeticStroker::BottomToTop;
}
int xinc = F16Dot16FixedDiv(x2 - x1, y2 - y1);
int x = x1 << 10;
if ((stroker->lastDir ^ QCosmeticStroker::VerticalMask) == dir)
caps |= swapped ? QCosmeticStroker::CapEnd : QCosmeticStroker::CapBegin;
capAdjust(caps, y1, y2, x, xinc);
int y = (y1+32) >> 6;
int ys = (y2+32) >> 6;
int y = y1 >> 6;
int ys = y2 >> 6;
if (y != ys) {
x += ( ((((y << 6) + 32 - y1))) * xinc ) >> 6;
// calculate first and last pixel and perform dropout control
QCosmeticStroker::Direction dir = QCosmeticStroker::TopToBottom;
QCosmeticStroker::Point first;
first.x = x >> 16;
first.y = y;
last.x = (x + (ys - y - 1)*xinc) >> 16;
last.y = ys - 1;
if (swapped) {
if (swapped)
qSwap(first, last);
dir = QCosmeticStroker::BottomToTop;
}
bool axisAligned = qAbs(xinc) < (1 << 14);
if (stroker->lastPixel.x >= 0) {
if (first.x == stroker->lastPixel.x &&
@ -765,7 +765,7 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2,
} else if (stroker->lastDir != dir &&
(((axisAligned && stroker->lastAxisAligned) &&
stroker->lastPixel.x != first.x && stroker->lastPixel.y != first.y) ||
(qAbs(stroker->lastPixel.x - first.x) > 1 &&
(qAbs(stroker->lastPixel.x - first.x) > 1 ||
qAbs(stroker->lastPixel.y - first.y) > 1))) {
// have a missing pixel, insert it
if (swapped) {
@ -793,37 +793,39 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2,
if (!dx)
return;
QCosmeticStroker::Direction dir = QCosmeticStroker::LeftToRight;
bool swapped = false;
if (x1 > x2) {
swapped = true;
qSwap(x1, x2);
qSwap(y1, y2);
caps = swapCaps(caps);
--x1; --x2; --y1; --y2;
dir = QCosmeticStroker::RightToLeft;
}
int yinc = F16Dot16FixedDiv(y2 - y1, x2 - x1);
int y = y1 << 10;
if ((stroker->lastDir ^ QCosmeticStroker::HorizontalMask) == dir)
caps |= swapped ? QCosmeticStroker::CapEnd : QCosmeticStroker::CapBegin;
capAdjust(caps, x1, x2, y, yinc);
int x = (x1+32) >> 6;
int xs = (x2+32) >> 6;
int x = x1 >> 6;
int xs = x2 >> 6;
if (x != xs) {
y += ( ((((x << 6) + 32 - x1))) * yinc ) >> 6;
// calculate first and last pixel to perform dropout control
QCosmeticStroker::Direction dir = QCosmeticStroker::LeftToRight;
QCosmeticStroker::Point first;
first.x = x;
first.y = y >> 16;
last.x = xs - 1;
last.y = (y + (xs - x - 1)*yinc) >> 16;
if (swapped) {
if (swapped)
qSwap(first, last);
dir = QCosmeticStroker::RightToLeft;
}
bool axisAligned = qAbs(yinc) < (1 << 14);
if (stroker->lastPixel.x >= 0) {
if (first.x == stroker->lastPixel.x && first.y == stroker->lastPixel.y) {
@ -837,7 +839,7 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2,
} else if (stroker->lastDir != dir &&
(((axisAligned && stroker->lastAxisAligned) &&
stroker->lastPixel.x != first.x && stroker->lastPixel.y != first.y) ||
(qAbs(stroker->lastPixel.x - first.x) > 1 &&
(qAbs(stroker->lastPixel.x - first.x) > 1 ||
qAbs(stroker->lastPixel.y - first.y) > 1))) {
// have a missing pixel, insert it
if (swapped) {

View File

@ -78,10 +78,12 @@ public:
// used to avoid drop outs or duplicated points
enum Direction {
TopToBottom,
BottomToTop,
LeftToRight,
RightToLeft
TopToBottom = 0x1,
BottomToTop = 0x2,
LeftToRight = 0x4,
RightToLeft = 0x8,
VerticalMask = 0x3,
HorizontalMask = 0xc
};
QCosmeticStroker(QRasterPaintEngineState *s, const QRect &dr)

View File

@ -685,20 +685,30 @@ void QTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, qrea
if (!wordSelectionEnabled && (mouseXPosition < wordStartX || mouseXPosition > wordEndX))
return;
// keep the already selected word even when moving to the left
// (#39164)
if (suggestedNewPosition < selectedWordOnDoubleClick.position())
cursor.setPosition(selectedWordOnDoubleClick.selectionEnd());
else
cursor.setPosition(selectedWordOnDoubleClick.selectionStart());
if (wordSelectionEnabled) {
if (suggestedNewPosition < selectedWordOnDoubleClick.position()) {
cursor.setPosition(selectedWordOnDoubleClick.selectionEnd());
setCursorPosition(wordStartPos, QTextCursor::KeepAnchor);
} else {
cursor.setPosition(selectedWordOnDoubleClick.selectionStart());
setCursorPosition(wordEndPos, QTextCursor::KeepAnchor);
}
} else {
// keep the already selected word even when moving to the left
// (#39164)
if (suggestedNewPosition < selectedWordOnDoubleClick.position())
cursor.setPosition(selectedWordOnDoubleClick.selectionEnd());
else
cursor.setPosition(selectedWordOnDoubleClick.selectionStart());
const qreal differenceToStart = mouseXPosition - wordStartX;
const qreal differenceToEnd = wordEndX - mouseXPosition;
const qreal differenceToStart = mouseXPosition - wordStartX;
const qreal differenceToEnd = wordEndX - mouseXPosition;
if (differenceToStart < differenceToEnd)
setCursorPosition(wordStartPos, QTextCursor::KeepAnchor);
else
setCursorPosition(wordEndPos, QTextCursor::KeepAnchor);
if (differenceToStart < differenceToEnd)
setCursorPosition(wordStartPos, QTextCursor::KeepAnchor);
else
setCursorPosition(wordEndPos, QTextCursor::KeepAnchor);
}
if (interactionFlags & Qt::TextSelectableByMouse) {
#ifndef QT_NO_CLIPBOARD
@ -1591,8 +1601,10 @@ void QTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button, cons
#endif //QT_NO_IM
} else {
//emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1)));
if (cursor.position() != oldCursorPos)
if (cursor.position() != oldCursorPos) {
emit q->cursorPositionChanged();
emit q->microFocusChanged();
}
}
selectionChanged(true);
repaintOldAndNewSelection(oldSelection);
@ -1636,8 +1648,10 @@ void QTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton button, c
repaintOldAndNewSelection(oldSelection);
if (cursor.position() != oldCursorPos)
if (cursor.position() != oldCursorPos) {
emit q->cursorPositionChanged();
emit q->microFocusChanged();
}
if (interactionFlags & Qt::LinksAccessibleByMouse) {
if (!(button & Qt::LeftButton))

View File

@ -63,6 +63,7 @@ namespace QSsl {
};
enum KeyAlgorithm {
Opaque,
Rsa,
Dsa
};

View File

@ -892,23 +892,24 @@ QList<QSslCertificate> QSslCertificatePrivate::certificatesFromDer(const QByteAr
// These certificates are known to be fraudulent and were created during the comodo
// compromise. See http://www.comodo.com/Comodo-Fraud-Incident-2011-03-23.html
static const char *certificate_blacklist[] = {
"04:7e:cb:e9:fc:a5:5f:7b:d0:9e:ae:36:e1:0c:ae:1e",
"f5:c8:6a:f3:61:62:f1:3a:64:f5:4f:6d:c9:58:7c:06",
"d7:55:8f:da:f5:f1:10:5b:b2:13:28:2b:70:77:29:a3",
"39:2a:43:4f:0e:07:df:1f:8a:a3:05:de:34:e0:c2:29",
"3e:75:ce:d4:6b:69:30:21:21:88:30:ae:86:a8:2a:71",
"e9:02:8b:95:78:e4:15:dc:1a:71:0a:2b:88:15:44:47",
"92:39:d5:34:8f:40:d1:69:5a:74:54:70:e1:f2:3f:43",
"b0:b7:13:3e:d0:96:f9:b5:6f:ae:91:c8:74:bd:3a:c0",
"d8:f3:5f:4e:b7:87:2b:2d:ab:06:92:e3:15:38:2f:b0",
"05:e2:e6:a4:cd:09:ea:54:d6:65:b0:75:fe:22:a2:56",
"04:7e:cb:e9:fc:a5:5f:7b:d0:9e:ae:36:e1:0c:ae:1e", "mail.google.com", // Comodo
"f5:c8:6a:f3:61:62:f1:3a:64:f5:4f:6d:c9:58:7c:06", "www.google.com", // Comodo
"d7:55:8f:da:f5:f1:10:5b:b2:13:28:2b:70:77:29:a3", "login.yahoo.com", // Comodo
"39:2a:43:4f:0e:07:df:1f:8a:a3:05:de:34:e0:c2:29", "login.yahoo.com", // Comodo
"3e:75:ce:d4:6b:69:30:21:21:88:30:ae:86:a8:2a:71", "login.yahoo.com", // Comodo
"e9:02:8b:95:78:e4:15:dc:1a:71:0a:2b:88:15:44:47", "login.skype.com", // Comodo
"92:39:d5:34:8f:40:d1:69:5a:74:54:70:e1:f2:3f:43", "addons.mozilla.org", // Comodo
"b0:b7:13:3e:d0:96:f9:b5:6f:ae:91:c8:74:bd:3a:c0", "login.live.com", // Comodo
"d8:f3:5f:4e:b7:87:2b:2d:ab:06:92:e3:15:38:2f:b0", "global trustee", // Comodo
"05:e2:e6:a4:cd:09:ea:54:d6:65:b0:75:fe:22:a2:56", "*.google.com", // DigiNotar
0
};
bool QSslCertificatePrivate::isBlacklisted(const QSslCertificate &certificate)
{
for (int a = 0; certificate_blacklist[a] != 0; a++) {
if (certificate.serialNumber() == certificate_blacklist[a])
if (certificate.serialNumber() == certificate_blacklist[a++] &&
certificate.subjectInfo(QSslCertificate::CommonName).contains(QString::fromUtf8(certificate_blacklist[a])))
return true;
}
return false;

View File

@ -89,6 +89,11 @@ void QSslKeyPrivate::clear(bool deep)
q_DSA_free(dsa);
dsa = 0;
}
if (opaque) {
if (deep)
q_EVP_PKEY_free(opaque);
opaque = 0;
}
}
/*!
@ -264,6 +269,23 @@ QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::Encoding
passPhrase);
}
/*!
Constructs a QSslKey from a valid native key \a handle.
\a type specifies whether the key is public or private.
QSslKey will take ownership for this key and you must not
free the key using the native library. The algorithm used
when creating a key from a handle will always be QSsl::Opaque.
*/
QSslKey::QSslKey(Qt::HANDLE handle, QSsl::KeyType type)
: d(new QSslKeyPrivate)
{
d->opaque = reinterpret_cast<EVP_PKEY *>(handle);
d->algorithm = QSsl::Opaque;
d->type = type;
d->isNull = !d->opaque;
}
/*!
Constructs an identical copy of \a other.
*/
@ -315,8 +337,9 @@ void QSslKey::clear()
*/
int QSslKey::length() const
{
if (d->isNull)
if (d->isNull || d->algorithm == QSsl::Opaque)
return -1;
return (d->algorithm == QSsl::Rsa)
? q_BN_num_bits(d->rsa->n) : q_BN_num_bits(d->dsa->p);
}
@ -345,8 +368,9 @@ QSsl::KeyAlgorithm QSslKey::algorithm() const
// ### autotest failure for non-empty passPhrase and private key
QByteArray QSslKey::toDer(const QByteArray &passPhrase) const
{
if (d->isNull)
if (d->isNull || d->algorithm == QSsl::Opaque)
return QByteArray();
return d->derFromPem(toPem(passPhrase));
}
@ -357,7 +381,7 @@ QByteArray QSslKey::toDer(const QByteArray &passPhrase) const
*/
QByteArray QSslKey::toPem(const QByteArray &passPhrase) const
{
if (!QSslSocket::supportsSsl() || d->isNull)
if (!QSslSocket::supportsSsl() || d->isNull || d->algorithm == QSsl::Opaque)
return QByteArray();
BIO *bio = q_BIO_new(q_BIO_s_mem());
@ -417,7 +441,16 @@ QByteArray QSslKey::toPem(const QByteArray &passPhrase) const
*/
Qt::HANDLE QSslKey::handle() const
{
return (d->algorithm == QSsl::Rsa) ? Qt::HANDLE(d->rsa) : Qt::HANDLE(d->dsa);
switch (d->algorithm) {
case QSsl::Opaque:
return Qt::HANDLE(d->opaque);
case QSsl::Rsa:
return Qt::HANDLE(d->rsa);
case QSsl::Dsa:
return Qt::HANDLE(d->dsa);
default:
return Qt::HANDLE(NULL);
}
}
/*!
@ -435,6 +468,8 @@ bool QSslKey::operator==(const QSslKey &other) const
return false;
if (length() != other.length())
return false;
if (algorithm() == QSsl::Opaque)
return handle() == other.handle();
return toDer() == other.toDer();
}
@ -450,7 +485,8 @@ QDebug operator<<(QDebug debug, const QSslKey &key)
{
debug << "QSslKey("
<< (key.type() == QSsl::PublicKey ? "PublicKey" : "PrivateKey")
<< ", " << (key.algorithm() == QSsl::Rsa ? "RSA" : "DSA")
<< ", " << (key.algorithm() == QSsl::Opaque ? "OPAQUE" :
(key.algorithm() == QSsl::Rsa ? "RSA" : "DSA"))
<< ", " << key.length()
<< ')';
return debug;

View File

@ -73,6 +73,7 @@ public:
QSsl::EncodingFormat format = QSsl::Pem,
QSsl::KeyType type = QSsl::PrivateKey,
const QByteArray &passPhrase = QByteArray());
explicit QSslKey(Qt::HANDLE handle, QSsl::KeyType type = QSsl::PrivateKey);
QSslKey(const QSslKey &other);
~QSslKey();
QSslKey &operator=(const QSslKey &other);

View File

@ -67,6 +67,7 @@ public:
inline QSslKeyPrivate()
: rsa(0)
, dsa(0)
, opaque(0)
{
clear();
}
@ -88,6 +89,7 @@ public:
QSsl::KeyAlgorithm algorithm;
RSA *rsa;
DSA *dsa;
EVP_PKEY *opaque;
QAtomicInt ref;

View File

@ -322,7 +322,7 @@ init_context:
if (! caCertificate.isValid()) {
expiredCerts.append(caCertificate);
} else {
q_X509_STORE_add_cert(ctx->cert_store, (X509 *)caCertificate.handle());
q_X509_STORE_add_cert(ctx->cert_store, reinterpret_cast<X509 *>(caCertificate.handle()));
}
}
@ -335,7 +335,7 @@ init_context:
// now add the expired certs
if (addExpiredCerts) {
foreach (const QSslCertificate &caCertificate, expiredCerts) {
q_X509_STORE_add_cert(ctx->cert_store, (X509 *)caCertificate.handle());
q_X509_STORE_add_cert(ctx->cert_store, reinterpret_cast<X509 *>(caCertificate.handle()));
}
}
@ -358,26 +358,33 @@ init_context:
}
// Load certificate
if (!q_SSL_CTX_use_certificate(ctx, (X509 *)configuration.localCertificate.handle())) {
if (!q_SSL_CTX_use_certificate(ctx, reinterpret_cast<X509 *>(configuration.localCertificate.handle()))) {
q->setErrorString(QSslSocket::tr("Error loading local certificate, %1").arg(getErrorsFromOpenSsl()));
emit q->error(QAbstractSocket::UnknownSocketError);
return false;
}
// Load private key
pkey = q_EVP_PKEY_new();
// before we were using EVP_PKEY_assign_R* functions and did not use EVP_PKEY_free.
// this lead to a memory leak. Now we use the *_set1_* functions which do not
// take ownership of the RSA/DSA key instance because the QSslKey already has ownership.
if (configuration.privateKey.algorithm() == QSsl::Rsa)
q_EVP_PKEY_set1_RSA(pkey, (RSA *)configuration.privateKey.handle());
else
q_EVP_PKEY_set1_DSA(pkey, (DSA *)configuration.privateKey.handle());
if (configuration.privateKey.algorithm() == QSsl::Opaque) {
pkey = reinterpret_cast<EVP_PKEY *>(configuration.privateKey.handle());
} else {
// Load private key
pkey = q_EVP_PKEY_new();
// before we were using EVP_PKEY_assign_R* functions and did not use EVP_PKEY_free.
// this lead to a memory leak. Now we use the *_set1_* functions which do not
// take ownership of the RSA/DSA key instance because the QSslKey already has ownership.
if (configuration.privateKey.algorithm() == QSsl::Rsa)
q_EVP_PKEY_set1_RSA(pkey, reinterpret_cast<RSA *>(configuration.privateKey.handle()));
else
q_EVP_PKEY_set1_DSA(pkey, reinterpret_cast<DSA *>(configuration.privateKey.handle()));
}
if (!q_SSL_CTX_use_PrivateKey(ctx, pkey)) {
q->setErrorString(QSslSocket::tr("Error loading private key, %1").arg(getErrorsFromOpenSsl()));
emit q->error(QAbstractSocket::UnknownSocketError);
return false;
}
if (configuration.privateKey.algorithm() == QSsl::Opaque)
pkey = 0; // Don't free the private key, it belongs to QSslKey
// Check if the certificate matches the private key.
if (!q_SSL_CTX_check_private_key(ctx)) {
@ -1383,7 +1390,6 @@ void QSslSocketBackendPrivate::disconnected()
q_EVP_PKEY_free(pkey);
pkey = 0;
}
}
QSslCipher QSslSocketBackendPrivate::sessionCipher() const
@ -1508,7 +1514,7 @@ QList<QSslError> QSslSocketBackendPrivate::verify(QList<QSslCertificate> certifi
if (!caCertificate.isValid()) {
expiredCerts.append(caCertificate);
} else {
q_X509_STORE_add_cert(certStore, (X509 *)caCertificate.handle());
q_X509_STORE_add_cert(certStore, reinterpret_cast<X509 *>(caCertificate.handle()));
}
}
@ -1521,7 +1527,7 @@ QList<QSslError> QSslSocketBackendPrivate::verify(QList<QSslCertificate> certifi
// now add the expired certs
if (addExpiredCerts) {
foreach (const QSslCertificate &caCertificate, expiredCerts) {
q_X509_STORE_add_cert(certStore, (X509 *)caCertificate.handle());
q_X509_STORE_add_cert(certStore, reinterpret_cast<X509 *>(caCertificate.handle()));
}
}
@ -1548,9 +1554,9 @@ QList<QSslError> QSslSocketBackendPrivate::verify(QList<QSslCertificate> certifi
continue;
}
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
q_sk_push( (_STACK *)intermediates, (X509 *)cert.handle());
q_sk_push( (_STACK *)intermediates, reinterpret_cast<X509 *>(cert.handle()));
#else
q_sk_push( (STACK *)intermediates, (X509 *)cert.handle());
q_sk_push( (STACK *)intermediates, reinterpret_cast<X509 *>(cert.handle()));
#endif
}
}
@ -1562,7 +1568,7 @@ QList<QSslError> QSslSocketBackendPrivate::verify(QList<QSslCertificate> certifi
return errors;
}
if (!q_X509_STORE_CTX_init(storeContext, certStore, (X509 *)certificateChain[0].handle(), intermediates)) {
if (!q_X509_STORE_CTX_init(storeContext, certStore, reinterpret_cast<X509 *>(certificateChain[0].handle()), intermediates)) {
q_X509_STORE_CTX_free(storeContext);
q_X509_STORE_free(certStore);
errors << QSslError(QSslError::UnspecifiedError);

View File

@ -228,13 +228,13 @@ char *q_ERR_error_string(unsigned long a, char *b);
unsigned long q_ERR_get_error();
const EVP_CIPHER *q_EVP_des_ede3_cbc();
int q_EVP_PKEY_assign(EVP_PKEY *a, int b, char *c);
int q_EVP_PKEY_set1_RSA(EVP_PKEY *a, RSA *b);
Q_AUTOTEST_EXPORT int q_EVP_PKEY_set1_RSA(EVP_PKEY *a, RSA *b);
int q_EVP_PKEY_set1_DSA(EVP_PKEY *a, DSA *b);
void q_EVP_PKEY_free(EVP_PKEY *a);
RSA *q_EVP_PKEY_get1_RSA(EVP_PKEY *a);
DSA *q_EVP_PKEY_get1_DSA(EVP_PKEY *a);
int q_EVP_PKEY_type(int a);
EVP_PKEY *q_EVP_PKEY_new();
Q_AUTOTEST_EXPORT EVP_PKEY *q_EVP_PKEY_new();
int q_i2d_X509(X509 *a, unsigned char **b);
const char *q_OBJ_nid2sn(int a);
const char *q_OBJ_nid2ln(int a);

View File

@ -40,12 +40,13 @@
****************************************************************************/
#include "qwaylandnativeinterface.h"
#include "qwaylanddisplay.h"
#include "qwaylandwindow.h"
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/QScreen>
#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{
QByteArray lowerCaseResource = resourceString.toLower();
@ -71,3 +72,32 @@ QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWindow(QWindow *wind
}
return screen;
}
QVariantMap QWaylandNativeInterface::windowProperties(QPlatformWindow *window) const
{
return m_windowProperties.value(window);
}
QVariant QWaylandNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const
{
const QVariantMap properties = m_windowProperties.value(window);
return properties.value(name);
}
QVariant QWaylandNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const
{
const QVariantMap properties = m_windowProperties.value(window);
return properties.value(name, defaultValue);
}
void QWaylandNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value)
{
QVariantMap props = m_windowProperties.value(window);
props.insert(name, value);
m_windowProperties.insert(window, props);
QWaylandWindow *wlWindow = static_cast<QWaylandWindow*>(window);
QWaylandWindowManagerIntegration::instance()->setWindowProperty(wlWindow, name, value);
emit windowPropertyChanged(window, name);
}

View File

@ -43,7 +43,7 @@
#define QWAYLANDNATIVEINTERFACE_H
#include "qwaylandscreen.h"
#include <QVariantMap>
#include <QtGui/QPlatformNativeInterface>
class QWaylandNativeInterface : public QPlatformNativeInterface
@ -52,8 +52,16 @@ public:
void *nativeResourceForWindow(const QByteArray &resourceString,
QWindow *window);
QVariantMap windowProperties(QPlatformWindow *window) const;
QVariant windowProperty(QPlatformWindow *window, const QString &name) const;
QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const;
void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value);
private:
static QWaylandScreen *qPlatformScreenForWindow(QWindow *window);
private:
QHash<QPlatformWindow*, QVariantMap> m_windowProperties;
};

View File

@ -149,6 +149,9 @@ void QWaylandWindow::newSurfaceCreated()
// do not damage the surface here, as this leads to graphical corruptions in the compositor until
// the first frame has been rendered
}
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
QWaylandWindowManagerIntegration::instance()->flushPropertyChanges(this);
#endif
}
void QWaylandWindow::frameCallback(struct wl_surface *surface, void *data, uint32_t time)

View File

@ -1,106 +0,0 @@
/*
* Copyright © 2010 Kristian Høgsberg
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the name of the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#ifndef WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H
#define WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "wayland-util.h"
struct wl_client;
struct wl_windowmanager;
extern const struct wl_interface wl_windowmanager_interface;
struct wl_windowmanager_listener {
void (*client_onscreen_visibility)(void *data,
struct wl_windowmanager *wl_windowmanager,
int visible);
void (*set_screen_rotation)(void *data,
struct wl_windowmanager *wl_windowmanager,
int rotation);
};
static inline int
wl_windowmanager_add_listener(struct wl_windowmanager *wl_windowmanager,
const struct wl_windowmanager_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) wl_windowmanager,
(void (**)(void)) listener, data);
}
#define WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0
#define WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN 1
static inline struct wl_windowmanager *
wl_windowmanager_create(struct wl_display *display, uint32_t id, uint32_t version)
{
wl_display_bind(display, id, "wl_windowmanager", version);
return (struct wl_windowmanager *)
wl_proxy_create_for_id(display, &wl_windowmanager_interface, id);
}
static inline void
wl_windowmanager_set_user_data(struct wl_windowmanager *wl_windowmanager, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) wl_windowmanager, user_data);
}
static inline void *
wl_windowmanager_get_user_data(struct wl_windowmanager *wl_windowmanager)
{
return wl_proxy_get_user_data((struct wl_proxy *) wl_windowmanager);
}
static inline void
wl_windowmanager_destroy(struct wl_windowmanager *wl_windowmanager)
{
wl_proxy_destroy((struct wl_proxy *) wl_windowmanager);
}
static inline void
wl_windowmanager_map_client_to_process(struct wl_windowmanager *wl_windowmanager, uint32_t processid)
{
wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid);
}
static inline void
wl_windowmanager_authenticate_with_token(struct wl_windowmanager *wl_windowmanager, const char *processid)
{
wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN, processid);
}
#ifdef __cplusplus
}
#endif
#endif

View File

@ -40,17 +40,43 @@
****************************************************************************/
#include "qwaylandwindowmanagerintegration.h"
#include "qwaylandwindowmanager-client-protocol.h"
#include "wayland-windowmanager-client-protocol.h"
#include "qwaylandwindow.h"
#include <stdint.h>
#include <QDebug>
#include <QEvent>
#include <QtCore/QEvent>
#include <QtCore/QHash>
#include <QtGui/QPlatformNativeInterface>
#include <QtGui/QPlatformWindow>
#include <QtGui/QtEvents>
#include <QCoreApplication>
#include <QtGui/QGuiApplication>
const struct wl_windowmanager_listener QWaylandWindowManagerIntegration::mWindowManagerListener = {
#include <QDebug>
class QWaylandWindowManagerIntegrationPrivate {
public:
QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay);
bool m_blockPropertyUpdates;
QWaylandDisplay *m_waylandDisplay;
struct wl_windowmanager *m_waylandWindowManager;
QHash<QWaylandWindow*,QVariantMap> m_queuedProperties;
};
QWaylandWindowManagerIntegrationPrivate::QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay)
: m_blockPropertyUpdates(false)
, m_waylandDisplay(waylandDisplay)
, m_waylandWindowManager(0)
{
}
QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::m_instance = 0;
const struct wl_windowmanager_listener QWaylandWindowManagerIntegration::m_windowManagerListener = {
QWaylandWindowManagerIntegration::wlHandleOnScreenVisibilityChange,
QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange,
QWaylandWindowManagerIntegration::wlHandleWindowPropertyChange
};
QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegration(QWaylandDisplay *waylandDisplay)
@ -59,10 +85,11 @@ QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegr
}
QWaylandWindowManagerIntegration::QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay)
: mWaylandDisplay(waylandDisplay)
, mWaylandWindowManager(0)
: d_ptr(new QWaylandWindowManagerIntegrationPrivate(waylandDisplay))
{
wl_display_add_global_listener(mWaylandDisplay->wl_display(),
m_instance = this;
wl_display_add_global_listener(d_ptr->m_waylandDisplay->wl_display(),
QWaylandWindowManagerIntegration::wlHandleListenerGlobal,
this);
}
@ -72,9 +99,15 @@ QWaylandWindowManagerIntegration::~QWaylandWindowManagerIntegration()
}
QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::instance()
{
return m_instance;
}
struct wl_windowmanager *QWaylandWindowManagerIntegration::windowManager() const
{
return mWaylandWindowManager;
Q_D(const QWaylandWindowManagerIntegration);
return d->m_waylandWindowManager;
}
void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data)
@ -82,29 +115,95 @@ void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *displa
Q_UNUSED(version);
if (strcmp(interface, "wl_windowmanager") == 0) {
QWaylandWindowManagerIntegration *integration = static_cast<QWaylandWindowManagerIntegration *>(data);
integration->mWaylandWindowManager = wl_windowmanager_create(display, id, 1);
wl_windowmanager_add_listener(integration->mWaylandWindowManager, &mWindowManagerListener, integration);
integration->d_ptr->m_waylandWindowManager = wl_windowmanager_create(display, id, 1);
wl_windowmanager *windowManager = integration->d_ptr->m_waylandWindowManager;
wl_windowmanager_add_listener(windowManager, &m_windowManagerListener, integration);
}
}
void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId)
{
if (mWaylandWindowManager)
wl_windowmanager_map_client_to_process(mWaylandWindowManager, (uint32_t) processId);
Q_D(QWaylandWindowManagerIntegration);
if (d->m_waylandWindowManager)
wl_windowmanager_map_client_to_process(d->m_waylandWindowManager, (uint32_t) processId);
}
void QWaylandWindowManagerIntegration::authenticateWithToken(const QByteArray &token)
{
Q_D(QWaylandWindowManagerIntegration);
QByteArray authToken = token;
if (authToken.isEmpty())
authToken = qgetenv("WL_AUTHENTICATION_TOKEN");
if (mWaylandWindowManager && !authToken.isEmpty()) {
wl_windowmanager_authenticate_with_token(mWaylandWindowManager, authToken.constData());
if (d->m_waylandWindowManager && !authToken.isEmpty()) {
wl_windowmanager_authenticate_with_token(d->m_waylandWindowManager, authToken.constData());
}
}
static wl_array writePropertyValue(const QVariant &value)
{
QByteArray byteValue;
QDataStream ds(&byteValue, QIODevice::WriteOnly);
ds << value;
wl_array data;
data.size = byteValue.size();
data.data = (void*)byteValue.constData();
data.alloc = 0;
return data;
}
void QWaylandWindowManagerIntegration::setWindowProperty(QWaylandWindow *window, const QString &propertyName, const QVariant &propertyValue)
{
Q_D(QWaylandWindowManagerIntegration);
if (d->m_blockPropertyUpdates)
return;
if (window->wl_surface()) {
wl_array data = writePropertyValue(propertyValue);
wl_windowmanager_update_generic_property(d->m_waylandWindowManager, window->wl_surface(),
propertyName.toLatin1().constData(),
&data);
} else {
QVariantMap props = d->m_queuedProperties.value(window);
props.insert(propertyName, propertyValue);
d->m_queuedProperties.insert(window, props);
// ### TODO we'll need to add listening to destroyed() of QWindow that owns QWaylandWindow
// once refactor changes are in, and connect to removeQueuedPropertiesForWindow().
}
}
void QWaylandWindowManagerIntegration::flushPropertyChanges(QWaylandWindow *windowToFlush)
{
// write all changes we got while we did not have a surface.
// this can happen during startup, for example, or while the window is hidden.
Q_D(QWaylandWindowManagerIntegration);
if (!windowToFlush)
return;
QVariantMap properties = d->m_queuedProperties.value(windowToFlush);
wl_surface *surface = windowToFlush->wl_surface();
QMapIterator<QString, QVariant> pIt(properties);
while (pIt.hasNext()) {
pIt.next();
wl_array data = writePropertyValue(pIt.value());
wl_windowmanager_update_generic_property(d->m_waylandWindowManager, surface, pIt.key().toLatin1().constData(), &data);
}
d->m_queuedProperties.clear();
}
void QWaylandWindowManagerIntegration::removeQueuedPropertiesForWindow()
{
// TODO enable this later once refactor changes are in.
// Q_D(QWaylandWindowManagerIntegration);
// QWaylandWindow *window = 0;
// d->m_queuedProperties.remove(window);
}
void QWaylandWindowManagerIntegration::wlHandleOnScreenVisibilityChange(void *data, struct wl_windowmanager *wl_windowmanager, int visible)
{
Q_UNUSED(data);
@ -120,3 +219,45 @@ void QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange(void *dat
QScreenOrientationChangeEvent event(screenOrientation);
QCoreApplication::sendEvent(QCoreApplication::instance(), &event);
}
void QWaylandWindowManagerIntegration::wlHandleWindowPropertyChange(void *data, struct wl_windowmanager *wl_windowmanager,
struct wl_surface *surface,
const char *propertyName, struct wl_array *propertyValue)
{
// window manager changes a window property
Q_UNUSED(data);
Q_UNUSED(wl_windowmanager);
QVariant variantValue;
QByteArray baValue = QByteArray((const char*)propertyValue->data, propertyValue->size);
QDataStream ds(&baValue, QIODevice::ReadOnly);
ds >> variantValue;
QPlatformNativeInterface *nativeInterface = qApp->platformNativeInterface();
QWaylandWindowManagerIntegration *inst = QWaylandWindowManagerIntegration::instance();
QList<QWindow *> windows = qApp->topLevelWindows();
foreach (QWindow *window, windows) {
QPlatformWindow *platformWindowForWindow = window->handle();
if (!platformWindowForWindow)
continue;
QWaylandWindow *waylandWindow = static_cast<QWaylandWindow*>(platformWindowForWindow);
wl_surface *windowSurface = (wl_surface*)nativeInterface->nativeResourceForWindow(QByteArray("surface"), window);
if (windowSurface == surface) {
inst->handleWindowPropertyChange(waylandWindow, QString(propertyName), variantValue);
break;
}
}
}
void QWaylandWindowManagerIntegration::handleWindowPropertyChange(QWaylandWindow *window,
const QString &propertyName, const QVariant &propertyValue)
{
Q_D(QWaylandWindowManagerIntegration);
d->m_blockPropertyUpdates = true;
QPlatformNativeInterface *nativeInterface = qApp->platformNativeInterface();
nativeInterface->setWindowProperty(window, propertyName, propertyValue);
d->m_blockPropertyUpdates = false;
}

View File

@ -42,21 +42,37 @@
#ifndef QWAYLANDWINDOWMANAGERINTEGRATION_H
#define QWAYLANDWINDOWMANAGERINTEGRATION_H
#include <QObject>
#include <QtCore/QObject>
#include <QtCore/QScopedPointer>
#include "wayland-client.h"
#include "qwaylanddisplay.h"
class QWaylandWindowManagerIntegration
class QWaylandWindow;
class QWaylandWindowManagerIntegrationPrivate;
class QWaylandWindowManagerIntegration : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandWindowManagerIntegration)
public:
explicit QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay);
virtual ~QWaylandWindowManagerIntegration();
static QWaylandWindowManagerIntegration *createIntegration(QWaylandDisplay *waylandDisplay);
struct wl_windowmanager *windowManager() const;
static QWaylandWindowManagerIntegration *instance();
void mapSurfaceToProcess(struct wl_surface *surface, long long processId);
void mapClientToProcess(long long processId);
void authenticateWithToken(const QByteArray &token = QByteArray());
void setWindowProperty(QWaylandWindow *window, const QString &propertyName, const QVariant &propertyValue);
void flushPropertyChanges(QWaylandWindow *windowToFlush);
private slots:
void removeQueuedPropertiesForWindow();
private:
static void wlHandleListenerGlobal(wl_display *display, uint32_t id,
@ -64,12 +80,17 @@ private:
static void wlHandleOnScreenVisibilityChange(void *data, struct wl_windowmanager *wl_windowmanager, int visible);
static void wlHandleScreenOrientationChange(void *data, struct wl_windowmanager *wl_windowmanager, int screenOrientation);
static void wlHandleWindowPropertyChange(void *data, struct wl_windowmanager *wl_windowmanager,
struct wl_surface *surface,
const char *propertyName, struct wl_array *propertyValue);
void handleWindowPropertyChange(QWaylandWindow *window, const QString &propertyName, const QVariant &propertyValue);
private:
QScopedPointer<QWaylandWindowManagerIntegrationPrivate> d_ptr;
static QWaylandWindowManagerIntegration *m_instance;
QWaylandDisplay *mWaylandDisplay;
struct wl_windowmanager *mWaylandWindowManager;
static const struct wl_windowmanager_listener mWindowManagerListener;
static const struct wl_windowmanager_listener m_windowManagerListener;
};
#endif // QWAYLANDWINDOWMANAGERINTEGRATION_H

View File

@ -0,0 +1,96 @@
#ifndef WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H
#define WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "wayland-util.h"
struct wl_client;
struct wl_windowmanager;
extern const struct wl_interface wl_windowmanager_interface;
struct wl_windowmanager_listener {
void (*client_onscreen_visibility)(void *data,
struct wl_windowmanager *wl_windowmanager,
int32_t visible);
void (*set_screen_rotation)(void *data,
struct wl_windowmanager *wl_windowmanager,
int32_t rotation);
void (*set_generic_property)(void *data,
struct wl_windowmanager *wl_windowmanager,
struct wl_surface *surface,
const char *name,
struct wl_array *value);
};
static inline int
wl_windowmanager_add_listener(struct wl_windowmanager *wl_windowmanager,
const struct wl_windowmanager_listener *listener, void *data)
{
return wl_proxy_add_listener((struct wl_proxy *) wl_windowmanager,
(void (**)(void)) listener, data);
}
#define WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0
#define WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN 1
#define WL_WINDOWMANAGER_UPDATE_GENERIC_PROPERTY 2
static inline struct wl_windowmanager *
wl_windowmanager_create(struct wl_display *display, uint32_t id, uint32_t version)
{
wl_display_bind(display, id, "wl_windowmanager", version);
return (struct wl_windowmanager *)
wl_proxy_create_for_id(display, &wl_windowmanager_interface, id);
}
static inline void
wl_windowmanager_set_user_data(struct wl_windowmanager *wl_windowmanager, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) wl_windowmanager, user_data);
}
static inline void *
wl_windowmanager_get_user_data(struct wl_windowmanager *wl_windowmanager)
{
return wl_proxy_get_user_data((struct wl_proxy *) wl_windowmanager);
}
static inline void
wl_windowmanager_destroy(struct wl_windowmanager *wl_windowmanager)
{
wl_proxy_destroy((struct wl_proxy *) wl_windowmanager);
}
static inline void
wl_windowmanager_map_client_to_process(struct wl_windowmanager *wl_windowmanager, uint32_t processid)
{
wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid);
}
static inline void
wl_windowmanager_authenticate_with_token(struct wl_windowmanager *wl_windowmanager, const char *processid)
{
wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN, processid);
}
static inline void
wl_windowmanager_update_generic_property(struct wl_windowmanager *wl_windowmanager, struct wl_surface *surface, const char *name, struct wl_array *value)
{
wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
WL_WINDOWMANAGER_UPDATE_GENERIC_PROPERTY, surface, name, value);
}
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,38 +1,29 @@
/*
* Copyright © 2010 Kristian Høgsberg
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the name of the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#include <stdlib.h>
#include <stdint.h>
#include "wayland-util.h"
extern const struct wl_interface wl_surface_interface;
static const struct wl_interface *types[] = {
NULL,
&wl_surface_interface,
NULL,
NULL,
&wl_surface_interface,
NULL,
NULL,
};
static const struct wl_message wl_windowmanager_requests[] = {
{ "map_client_to_process", "u", NULL },
{ "authenticate_with_token", "s", NULL },
{ "map_client_to_process", "u", types + 0 },
{ "authenticate_with_token", "s", types + 0 },
{ "update_generic_property", "osa", types + 1 },
};
static const struct wl_message wl_windowmanager_events[] = {
{ "client_onscreen_visibility", "i", NULL },
{ "set_screen_rotation", "i", NULL },
{ "client_onscreen_visibility", "i", types + 0 },
{ "set_screen_rotation", "i", types + 0 },
{ "set_generic_property", "osa", types + 4 },
};
WL_EXPORT const struct wl_interface wl_windowmanager_interface = {

View File

@ -3,7 +3,7 @@ DEFINES += QT_WAYLAND_WINDOWMANAGER_SUPPORT
contains(DEFINES, QT_WAYLAND_WINDOWMANAGER_SUPPORT) {
HEADERS += \
$$PWD/qwaylandwindowmanager-client-protocol.h \
$$PWD/wayland-windowmanager-client-protocol.h \
$$PWD/qwaylandwindowmanagerintegration.h
SOURCES += \

View File

@ -15,7 +15,7 @@ nacl: SRC_SUBDIRS -= src_network src_testlib
!symbian:contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus
contains(QT_CONFIG, no-gui): SRC_SUBDIRS -= src_gui
!contains(QT_CONFIG, no-v8): SRC_SUBDIRS += src_v8
contains(QT_CONFIG, v8): SRC_SUBDIRS += src_v8
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2): SRC_SUBDIRS += src_opengl
SRC_SUBDIRS += src_plugins

View File

@ -54,18 +54,8 @@
QT_BEGIN_NAMESPACE
void QAbstractTestLogger::outputString(const char *msg)
QAbstractTestLogger::QAbstractTestLogger(const char *filename)
{
QTEST_ASSERT(stream);
::fputs(msg, stream);
::fflush(stream);
}
void QAbstractTestLogger::startLogging(const char *filename)
{
QTEST_ASSERT(!stream);
if (!filename) {
stream = stdout;
return;
@ -81,7 +71,7 @@ void QAbstractTestLogger::startLogging(const char *filename)
}
}
void QAbstractTestLogger::stopLogging()
QAbstractTestLogger::~QAbstractTestLogger()
{
QTEST_ASSERT(stream);
if (stream != stdout) {
@ -97,6 +87,22 @@ void QAbstractTestLogger::stopLogging()
stream = 0;
}
void QAbstractTestLogger::outputString(const char *msg)
{
QTEST_ASSERT(stream);
::fputs(msg, stream);
::fflush(stream);
}
void QAbstractTestLogger::startLogging()
{
}
void QAbstractTestLogger::stopLogging()
{
}
namespace QTest
{

View File

@ -80,10 +80,10 @@ public:
Info
};
QAbstractTestLogger() : stream(0) {}
virtual ~QAbstractTestLogger() {}
QAbstractTestLogger(const char *filename);
virtual ~QAbstractTestLogger();
virtual void startLogging(const char *filename);
virtual void startLogging();
virtual void stopLogging();
virtual void enterTestFunction(const char *function) = 0;
@ -98,7 +98,7 @@ public:
void outputString(const char *msg);
private:
protected:
FILE *stream;
};

View File

@ -119,7 +119,6 @@ QBenchmarkTestMethodData *QBenchmarkTestMethodData::current;
QBenchmarkTestMethodData::QBenchmarkTestMethodData()
:resultAccepted(false), runOnce(false), iterationCount(-1)
{
}
QBenchmarkTestMethodData::~QBenchmarkTestMethodData()
@ -134,7 +133,6 @@ void QBenchmarkTestMethodData::beginDataRun()
void QBenchmarkTestMethodData::endDataRun()
{
}
int QBenchmarkTestMethodData::adjustIterationCount(int suggestion)
@ -164,7 +162,7 @@ void QBenchmarkTestMethodData::setResult(
accepted = true;
}
// Test the result directly without calling the measurer if the minimum time
// Test the result directly without calling the measurer if the minimum time
// has been specified on the command line with -minimumvalue.
else if (QBenchmarkGlobalData::current->walltimeMinimum != -1)
accepted = (value > QBenchmarkGlobalData::current->walltimeMinimum);
@ -196,7 +194,7 @@ QTest::QBenchmarkIterationController::QBenchmarkIterationController(RunMode runM
{
i = 0;
if (runMode == RunOnce)
QBenchmarkTestMethodData::current->runOnce = true;
QBenchmarkTestMethodData::current->runOnce = true;
QTest::beginBenchmarkMeasurement();
}
@ -265,16 +263,16 @@ void QTest::beginBenchmarkMeasurement()
quint64 QTest::endBenchmarkMeasurement()
{
// the clock is ticking before the line below, don't add code here.
return QBenchmarkGlobalData::current->measurer->stop();
return QBenchmarkGlobalData::current->measurer->stop();
}
/*!
Sets the benchmark result for this test function to \a result.
Use this function if you want to report benchmark results without
using the QBENCHMARK macro. Use \a metric to specify how QTestLib
should interpret the results.
The context for the result will be the test function name and any
data tag from the _data function. This function can only be called
once in each test function, subsequent calls will replace the

View File

@ -58,7 +58,7 @@
#include <QtCore/qglobal.h>
#if (defined(Q_OS_LINUX) || defined Q_OS_MAC) && !defined(QT_NO_PROCESS)
#define QTESTLIB_USE_VALGRIND
#define QTESTLIB_USE_VALGRIND
#else
#undef QTESTLIB_USE_VALGRIND
#endif
@ -119,7 +119,7 @@ public:
, valid(true)
{ }
bool operator<(const QBenchmarkResult &other) const
bool operator<(const QBenchmarkResult &other) const
{
return (value / iterations) < (other.value / other.iterations);
}

View File

@ -69,12 +69,12 @@ public:
bool isMeasurementAccepted(qint64 measurement);
int adjustIterationCount(int suggestion);
int adjustMedianCount(int suggestion);
bool repeatCount() { return 1; }
bool repeatCount() { return 1; }
QTest::QBenchmarkMetric metricType();
static bool eventCountingMechanism(void *message);
static qint64 eventCounter;
};
QT_END_NAMESPACE
#endif // QBENCHMARKEVENT_H

View File

@ -60,7 +60,7 @@ qint64 QBenchmarkTimeMeasurer::checkpoint()
}
qint64 QBenchmarkTimeMeasurer::stop()
{
{
return time.elapsed();
}
@ -70,8 +70,8 @@ bool QBenchmarkTimeMeasurer::isMeasurementAccepted(qint64 measurement)
}
int QBenchmarkTimeMeasurer::adjustIterationCount(int suggestion)
{
return suggestion;
{
return suggestion;
}
bool QBenchmarkTimeMeasurer::needsWarmupIteration()
@ -80,8 +80,8 @@ bool QBenchmarkTimeMeasurer::needsWarmupIteration()
}
int QBenchmarkTimeMeasurer::adjustMedianCount(int)
{
return 1;
{
return 1;
}
QTest::QBenchmarkMetric QBenchmarkTimeMeasurer::metricType()
@ -114,18 +114,18 @@ bool QBenchmarkTickMeasurer::isMeasurementAccepted(qint64)
}
int QBenchmarkTickMeasurer::adjustIterationCount(int)
{
return 1;
{
return 1;
}
int QBenchmarkTickMeasurer::adjustMedianCount(int)
{
return 1;
{
return 1;
}
bool QBenchmarkTickMeasurer::needsWarmupIteration()
{
return true;
{
return true;
}
QTest::QBenchmarkMetric QBenchmarkTickMeasurer::metricType()

View File

@ -72,8 +72,8 @@ public:
virtual bool isMeasurementAccepted(qint64 measurement) = 0;
virtual int adjustIterationCount(int suggestion) = 0;
virtual int adjustMedianCount(int suggestion) = 0;
virtual bool repeatCount() { return 1; }
virtual bool needsWarmupIteration() { return false; }
virtual bool repeatCount() { return 1; }
virtual bool needsWarmupIteration() { return false; }
virtual QTest::QBenchmarkMetric metricType() = 0;
};

View File

@ -46,7 +46,7 @@
\since 4.7
This enum lists all the things that can be benchmarked.
\value FramesPerSecond Frames per second
\value BitsPerSecond Bits per second
\value BytesPerSecond Bytes per second

View File

@ -238,7 +238,7 @@ qint64 QBenchmarkCallgrindMeasurer::checkpoint()
}
qint64 QBenchmarkCallgrindMeasurer::stop()
{
{
return checkpoint();
}
@ -249,17 +249,17 @@ bool QBenchmarkCallgrindMeasurer::isMeasurementAccepted(qint64 measurement)
}
int QBenchmarkCallgrindMeasurer::adjustIterationCount(int)
{
{
return 1;
}
int QBenchmarkCallgrindMeasurer::adjustMedianCount(int)
{
{
return 1;
}
bool QBenchmarkCallgrindMeasurer::needsWarmupIteration()
{
{
return true;
}

View File

@ -211,7 +211,7 @@ void QPlainTestLogger::outputMessage(const char *str)
OutputDebugString((wchar_t*)tmp.utf16());
strUtf16.remove(0, maxOutputLength);
} while (!strUtf16.isEmpty());
if (QTestLog::outputFileName())
if (stream != stdout)
#elif defined(Q_OS_WIN)
EnterCriticalSection(&QTest::outputCriticalSection);
// OutputDebugString is not threadsafe
@ -344,7 +344,8 @@ void QPlainTestLogger::printBenchmarkResult(const QBenchmarkResult &result)
outputMessage(buf);
}
QPlainTestLogger::QPlainTestLogger()
QPlainTestLogger::QPlainTestLogger(const char *filename)
: QAbstractTestLogger(filename)
{
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
InitializeCriticalSection(&QTest::outputCriticalSection);
@ -358,9 +359,9 @@ QPlainTestLogger::~QPlainTestLogger()
#endif
}
void QPlainTestLogger::startLogging(const char *filename)
void QPlainTestLogger::startLogging()
{
QAbstractTestLogger::startLogging(filename);
QAbstractTestLogger::startLogging();
char buf[1024];
if (QTestLog::verboseLevel() < 0) {

View File

@ -60,10 +60,10 @@ QT_BEGIN_NAMESPACE
class QPlainTestLogger : public QAbstractTestLogger
{
public:
QPlainTestLogger();
QPlainTestLogger(const char *filename);
~QPlainTestLogger();
void startLogging(const char *filename);
void startLogging();
void stopLogging();
void enterTestFunction(const char *function);

View File

@ -50,9 +50,9 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Test)
#define QTEST_ASSERT(cond) do {if(!(cond))qt_assert(#cond,__FILE__,__LINE__);} while (0)
#define QTEST_ASSERT(cond) do { if (!(cond)) qt_assert(#cond,__FILE__,__LINE__); } while (0)
#define QTEST_ASSERT_X(cond, where, what) do {if(!(cond))qt_assert_x(where, what,__FILE__,__LINE__);} while (0)
#define QTEST_ASSERT_X(cond, where, what) do { if (!(cond)) qt_assert_x(where, what,__FILE__,__LINE__); } while (0)
QT_END_NAMESPACE

View File

@ -1,165 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtTest module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtestbasicstreamer.h"
#include "qtestlogger_p.h"
#include "qtestelement.h"
#include "qtestelementattribute.h"
#include "qtestassert.h"
#include <stdio.h>
#include <stdlib.h>
#ifndef Q_OS_WIN
#include <unistd.h>
#endif
QT_BEGIN_NAMESPACE
QTestBasicStreamer::QTestBasicStreamer(QTestLogger *logger)
:testLogger(logger)
{
QTEST_ASSERT(testLogger);
}
QTestBasicStreamer::~QTestBasicStreamer()
{}
void QTestBasicStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted )
return;
formatted->data()[0] = '\0';
}
void QTestBasicStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted )
return;
formatted->data()[0] = '\0';
}
void QTestBasicStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted )
return;
formatted->data()[0] = '\0';
}
void QTestBasicStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted )
return;
formatted->data()[0] = '\0';
}
void QTestBasicStreamer::formatAttributes(const QTestElement *, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const
{
if(!attribute || !formatted )
return;
formatted->data()[0] = '\0';
}
void QTestBasicStreamer::output(QTestElement *element) const
{
if(!element)
return;
outputElements(element);
}
void QTestBasicStreamer::outputElements(QTestElement *element, bool) const
{
QTestCharBuffer buf;
bool hasChildren;
/*
Elements are in reverse order of occurrence, so start from the end and work
our way backwards.
*/
while (element && element->nextElement()) {
element = element->nextElement();
}
while (element) {
hasChildren = element->childElements();
formatStart(element, &buf);
outputString(buf.data());
formatBeforeAttributes(element, &buf);
outputString(buf.data());
outputElementAttributes(element, element->attributes());
formatAfterAttributes(element, &buf);
outputString(buf.data());
if(hasChildren)
outputElements(element->childElements(), true);
formatEnd(element, &buf);
outputString(buf.data());
element = element->previousElement();
}
}
void QTestBasicStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const
{
QTestCharBuffer buf;
while(attribute){
formatAttributes(element, attribute, &buf);
outputString(buf.data());
attribute = attribute->nextElement();
}
}
void QTestBasicStreamer::outputString(const char *msg) const
{
testLogger->outputString(msg);
}
QTestLogger *QTestBasicStreamer::logger() const
{
return testLogger;
}
QT_END_NAMESPACE

View File

@ -1,87 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtTest module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTESTBASICSTREAMER_H
#define QTESTBASICSTREAMER_H
#include <QtCore/qglobal.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Test)
class QTestElement;
class QTestElementAttribute;
class QTestLogger;
struct QTestCharBuffer;
class QTestBasicStreamer
{
public:
QTestBasicStreamer(QTestLogger *logger);
virtual ~QTestBasicStreamer();
virtual void output(QTestElement *element) const;
void outputString(const char *msg) const;
QTestLogger *logger() const;
protected:
virtual void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
virtual void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
virtual void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
virtual void formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
virtual void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const;
virtual void outputElements(QTestElement *element, bool isChildElement = false) const;
virtual void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const;
private:
QTestLogger *testLogger;
};
QT_END_NAMESPACE
QT_END_HEADER
#endif

View File

@ -1000,40 +1000,44 @@ static int qToInt(char *str)
Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
{
QTestLog::LogMode logFormat = QTestLog::Plain;
const char *logFilename = 0;
const char *testOptions =
" options:\n"
" -functions : Returns a list of current testfunctions\n"
" -xunitxml : Outputs results as XML XUnit document\n"
" -xml : Outputs results as XML document\n"
" -lightxml : Outputs results as stream of XML tags\n"
" -flush : Flushes the results\n"
" -o filename: Writes all output into a file\n"
" -silent : Only outputs warnings and failures\n"
" -v1 : Print enter messages for each testfunction\n"
" -v2 : Also print out each QVERIFY/QCOMPARE/QTEST\n"
" -vs : Print every signal emitted\n"
" -eventdelay ms : Set default delay for mouse and keyboard simulation to ms milliseconds\n"
" -keydelay ms : Set default delay for keyboard simulation to ms milliseconds\n"
" -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n"
" -keyevent-verbose : Turn on verbose messages for keyboard simulation\n"
" -maxwarnings n : Sets the maximum amount of messages to output.\n"
" 0 means unlimited, default: 2000\n"
" Output options:\n"
" -xunitxml : Outputs results as XML XUnit document\n"
" -xml : Outputs results as XML document\n"
" -lightxml : Outputs results as stream of XML tags\n"
" -o filename : Writes all output into a file\n"
" -silent : Only outputs warnings and failures\n"
" -v1 : Print enter messages for each testfunction\n"
" -v2 : Also print out each QVERIFY/QCOMPARE/QTEST\n"
" -vs : Print every signal emitted\n"
"\n"
" Testing options:\n"
" -functions : Returns a list of current testfunctions\n"
" -eventdelay ms : Set default delay for mouse and keyboard simulation to ms milliseconds\n"
" -keydelay ms : Set default delay for keyboard simulation to ms milliseconds\n"
" -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n"
" -keyevent-verbose : Turn on verbose messages for keyboard simulation\n"
" -maxwarnings n : Sets the maximum amount of messages to output.\n"
" 0 means unlimited, default: 2000\n"
#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
" -nocrashhandler : Disables the crash handler\n"
" -nocrashhandler : Disables the crash handler\n"
#endif
"\n"
" Benchmark related options:\n"
" Benchmarking options:\n"
#ifdef QTESTLIB_USE_VALGRIND
" -callgrind : Use callgrind to time benchmarks\n"
" -callgrind : Use callgrind to time benchmarks\n"
#endif
#ifdef HAVE_TICK_COUNTER
" -tickcounter : Use CPU tick counters to time benchmarks\n"
" -tickcounter : Use CPU tick counters to time benchmarks\n"
#endif
" -eventcounter : Counts events received during benchmarks\n"
" -minimumvalue n : Sets the minimum acceptable measurement value\n"
" -iterations n : Sets the number of accumulation iterations.\n"
" -median n : Sets the number of median iterations.\n"
" -vb : Print out verbose benchmarking information.\n";
" -eventcounter : Counts events received during benchmarks\n"
" -minimumvalue n : Sets the minimum acceptable measurement value\n"
" -iterations n : Sets the number of accumulation iterations.\n"
" -median n : Sets the number of median iterations.\n"
" -vb : Print out verbose benchmarking information.\n";
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "--help") == 0
@ -1043,15 +1047,16 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
"%s", argv[0], testOptions);
if (qml) {
printf ("\nqmltest related options:\n"
" -import : Specify an import directory.\n"
" -input : Specify the root directory for test cases.\n"
" -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n"
printf ("\n"
" QmlTest options:\n"
" -import : Specify an import directory.\n"
" -input : Specify the root directory for test cases.\n"
" -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n"
);
}
printf("\n"
" -help : This help\n");
" -help : This help\n");
exit(0);
} else if (strcmp(argv[i], "-functions") == 0) {
if (qml) {
@ -1060,14 +1065,12 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
qPrintTestSlots(stdout);
exit(0);
}
} else if(strcmp(argv[i], "-xunitxml") == 0){
QTestLog::setLogMode(QTestLog::XunitXML);
} else if (strcmp(argv[i], "-xunitxml") == 0) {
logFormat = QTestLog::XunitXML;
} else if (strcmp(argv[i], "-xml") == 0) {
QTestLog::setLogMode(QTestLog::XML);
logFormat = QTestLog::XML;
} else if (strcmp(argv[i], "-lightxml") == 0) {
QTestLog::setLogMode(QTestLog::LightXML);
} else if (strcmp(argv[i], "-flush") == 0){
QTestLog::setFlushMode(QTestLog::FlushOn);
logFormat = QTestLog::LightXML;
} else if (strcmp(argv[i], "-silent") == 0) {
QTestLog::setVerboseLevel(-1);
} else if (strcmp(argv[i], "-v1") == 0) {
@ -1081,7 +1084,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
fprintf(stderr, "-o needs an extra parameter specifying the filename\n");
exit(1);
} else {
QTestLog::redirectOutput(argv[++i]);
logFilename = argv[++i];
}
} else if (strcmp(argv[i], "-eventdelay") == 0) {
if (i + 1 >= argc) {
@ -1192,7 +1195,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
// we load the QML files. So just store the data for now.
int colon = -1;
int offset;
for(offset = 0; *(argv[i]+offset); ++offset) {
for (offset = 0; *(argv[i]+offset); ++offset) {
if (*(argv[i]+offset) == ':') {
if (*(argv[i]+offset+1) == ':') {
// "::" is used as a test name separator.
@ -1221,13 +1224,13 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
int colon = -1;
char buf[512], *data=0;
int off;
for(off = 0; *(argv[i]+off); ++off) {
for (off = 0; *(argv[i]+off); ++off) {
if (*(argv[i]+off) == ':') {
colon = off;
break;
}
}
if(colon != -1) {
if (colon != -1) {
data = qstrdup(argv[i]+colon+1);
}
QTest::qt_snprintf(buf, qMin(512, off + 1), "%s", argv[i]); // copy text before the ':' into buf
@ -1244,6 +1247,9 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
QTEST_ASSERT(QTest::testFuncCount < 512);
}
}
// Create the logger
QTestLog::initLogger(logFormat, logFilename);
}
QBenchmarkResult qMedian(const QList<QBenchmarkResult> &container)
@ -1428,7 +1434,7 @@ static bool qInvokeTestMethod(const char *slotName, const char *data=0)
if (data && !foundFunction) {
fprintf(stderr, "Unknown testdata for function %s: '%s'\n", slotName, data);
fprintf(stderr, "Available testdata:\n");
for(int i = 0; i < table.dataCount(); ++i)
for (int i = 0; i < table.dataCount(); ++i)
fprintf(stderr, "%s\n", table.testData(i)->dataTag());
return false;
}
@ -1479,7 +1485,7 @@ void *fetchData(QTestData *data, const char *tagName, int typeId)
*/
char *toHexRepresentation(const char *ba, int length)
{
if(length == 0)
if (length == 0)
return qstrdup("");
/* We output at maximum about maxLen characters in order to avoid
@ -1493,7 +1499,7 @@ char *toHexRepresentation(const char *ba, int length)
const int len = qMin(maxLen, length);
char *result = 0;
if(length > maxLen) {
if (length > maxLen) {
const int size = len * 3 + 4;
result = new char[size];
@ -1514,7 +1520,7 @@ char *toHexRepresentation(const char *ba, int length)
int i = 0;
int o = 0;
while(true) {
while (true) {
const char at = ba[i];
result[o] = toHex[(at >> 4) & 0x0F];
@ -1523,7 +1529,7 @@ char *toHexRepresentation(const char *ba, int length)
++i;
++o;
if(i == len)
if (i == len)
break;
else {
result[o] = ' ';
@ -1552,7 +1558,7 @@ static void qInvokeTestMethods(QObject *testObject)
const bool previousFailed = QTestResult::testFailed();
QTestResult::finishedCurrentTestFunction();
if(!QTestResult::skipCurrentTest() && !previousFailed) {
if (!QTestResult::skipCurrentTest() && !previousFailed) {
if (QTest::testFuncs) {
for (int i = 0; i != QTest::testFuncCount; i++) {
@ -1725,18 +1731,18 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
#endif
#ifdef Q_WS_MAC
bool macNeedsActivate = qApp && (qstrcmp(qApp->metaObject()->className(), "QApplication") == 0);
bool macNeedsActivate = qApp && (qstrcmp(qApp->metaObject()->className(), "QApplication") == 0);
#ifdef QT_MAC_USE_COCOA
IOPMAssertionID powerID;
IOPMAssertionID powerID;
#endif
#endif
#ifndef QT_NO_EXCEPTIONS
try {
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX);
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX);
#endif
#ifdef Q_WS_MAC
// Starting with Qt 4.4, applications launched from the command line
@ -1745,13 +1751,13 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
if (macNeedsActivate) {
ProcessSerialNumber psn = { 0, kCurrentProcess };
SetFrontProcess(&psn);
# ifdef QT_MAC_USE_COCOA
#ifdef QT_MAC_USE_COCOA
IOReturn ok = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &powerID);
if (ok != kIOReturnSuccess)
macNeedsActivate = false; // no need to release the assertion on exit.
# else
#else
UpdateSystemActivity(1); // Wake the display.
# endif
#endif
}
#endif
@ -1813,7 +1819,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
throw;
return 1;
}
# endif
#endif
currentTestObject = 0;
#ifdef QT_MAC_USE_COCOA
@ -1846,7 +1852,7 @@ int QTest::qExec(QObject *testObject, const QStringList &arguments)
QVector<QByteArray> args;
args.reserve(argc);
for(int i = 0; i < argc; ++i)
for (int i = 0; i < argc; ++i)
{
args.append(arguments.at(i).toLocal8Bit().constData());
argv[i] = args.last().data();

View File

@ -87,10 +87,7 @@ QTestCoreElement<ElementType>::~QTestCoreElement()
template <class ElementType>
void QTestCoreElement<ElementType>::addAttribute(const QTest::AttributeIndex attributeIndex, const char *value)
{
if(attributeIndex == -1)
return;
if (attribute(attributeIndex))
if (attributeIndex == -1 || attribute(attributeIndex))
return;
QTestElementAttribute *testAttribute = new QTestElementAttribute;
@ -108,7 +105,7 @@ template <class ElementType>
const char *QTestCoreElement<ElementType>::attributeValue(QTest::AttributeIndex index) const
{
const QTestElementAttribute *attrb = attribute(index);
if(attrb)
if (attrb)
return attrb->value();
return 0;
@ -118,7 +115,7 @@ template <class ElementType>
const char *QTestCoreElement<ElementType>::attributeName(QTest::AttributeIndex index) const
{
const QTestElementAttribute *attrb = attribute(index);
if(attrb)
if (attrb)
return attrb->name();
return 0;
@ -139,7 +136,7 @@ const char *QTestCoreElement<ElementType>::elementName() const
"system-err"
};
if(type != QTest::LET_Undefined)
if (type != QTest::LET_Undefined)
return xmlElementNames[type];
return 0;
@ -155,8 +152,8 @@ template <class ElementType>
const QTestElementAttribute *QTestCoreElement<ElementType>::attribute(QTest::AttributeIndex index) const
{
QTestElementAttribute *iterator = listOfAttributes;
while(iterator){
if(iterator->index() == index)
while (iterator) {
if (iterator->index() == index)
return iterator;
iterator = iterator->nextElement();

View File

@ -70,8 +70,8 @@ class QTestCoreList
template <class T>
QTestCoreList<T>::QTestCoreList()
:next(0)
,prev(0)
: next(0)
, prev(0)
{
}
@ -121,7 +121,7 @@ int QTestCoreList<T>::count()
int numOfElements = 0;
T *it = next;
while(it){
while (it) {
++numOfElements;
it = it->nextElement();
}

View File

@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
class QTestDataPrivate
{
public:
QTestDataPrivate(): tag(0), parent(0), data(0), dataCount(0) {}
QTestDataPrivate() : tag(0), parent(0), data(0), dataCount(0) {}
char *tag;
QTestTable *parent;

View File

@ -44,9 +44,9 @@
QT_BEGIN_NAMESPACE
QTestElement::QTestElement(int type)
:QTestCoreElement<QTestElement>(type),
listOfChildren(0),
parent(0)
: QTestCoreElement<QTestElement>(type)
, listOfChildren(0)
, parent(0)
{
}
@ -57,10 +57,10 @@ QTestElement::~QTestElement()
bool QTestElement::addLogElement(QTestElement *element)
{
if(!element)
if (!element)
return false;
if(element->elementType() != QTest::LET_Undefined){
if (element->elementType() != QTest::LET_Undefined) {
element->addToList(&listOfChildren);
element->setParent(this);
return true;

View File

@ -50,37 +50,37 @@ QT_BEGIN_NAMESPACE
This enum numbers the different tests.
\value AI_Undefined
\value AI_Name
\value AI_Result
\value AI_Tests
\value AI_Failures
\value AI_Errors
\value AI_Type
\value AI_Description
\value AI_PropertyValue
\value AI_QTestVersion
\value AI_QtVersion
\value AI_File
\value AI_Line
\value AI_Metric
\value AI_Tag
\value AI_Value
\value AI_Iterations
*/
@ -144,7 +144,7 @@ const char *QTestElementAttribute::name() const
"iterations"
};
if(attributeIndex != QTest::AI_Undefined)
if (attributeIndex != QTest::AI_Undefined)
return AttributeNames[attributeIndex];
return 0;
@ -162,7 +162,7 @@ bool QTestElementAttribute::isNull() const
bool QTestElementAttribute::setPair(QTest::AttributeIndex index, const char *value)
{
if(!value)
if (!value)
return false;
delete[] attributeValue;

View File

@ -75,7 +75,7 @@ namespace QTest
if (delay == -1 || delay < defaultKeyDelay())
delay = defaultKeyDelay();
if(delay > 0)
if (delay > 0)
QTest::qWait(delay);
QKeyEvent a(press ? QEvent::KeyPress : QEvent::KeyRelease, code, modifier, text, repeat);

View File

@ -1,179 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtTest module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtestlightxmlstreamer.h"
#include "qtestelement.h"
#include "qtestelementattribute.h"
#include "qtestlogger_p.h"
#include "QtTest/private/qtestlog_p.h"
#include "QtTest/private/qtestresult_p.h"
#include "QtTest/private/qxmltestlogger_p.h"
#include <string.h>
QT_BEGIN_NAMESPACE
QTestLightXmlStreamer::QTestLightXmlStreamer(QTestLogger *logger)
: QTestBasicStreamer(logger)
{
}
QTestLightXmlStreamer::~QTestLightXmlStreamer()
{}
void QTestLightXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
switch(element->elementType()){
case QTest::LET_TestCase: {
QTestCharBuffer quotedTf;
QXmlTestLogger::xmlQuote(&quotedTf, element->attributeValue(QTest::AI_Name));
QTest::qt_asprintf(formatted, "<TestFunction name=\"%s\">\n", quotedTf.constData());
break;
}
case QTest::LET_Failure: {
QTestCharBuffer cdataDesc;
QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
QTest::qt_asprintf(formatted, " <Description><![CDATA[%s]]></Description>\n",
cdataDesc.constData());
break;
}
case QTest::LET_Error: {
// assuming type and attribute names don't need quoting
QTestCharBuffer quotedFile;
QTestCharBuffer cdataDesc;
QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n",
element->attributeValue(QTest::AI_Type),
element->attributeName(QTest::AI_File),
quotedFile.constData(),
element->attributeName(QTest::AI_Line),
element->attributeValue(QTest::AI_Line),
cdataDesc.constData());
break;
}
case QTest::LET_Benchmark: {
// assuming value and iterations don't need quoting
QTestCharBuffer quotedMetric;
QTestCharBuffer quotedTag;
QXmlTestLogger::xmlQuote(&quotedMetric, element->attributeValue(QTest::AI_Metric));
QXmlTestLogger::xmlQuote(&quotedTag, element->attributeValue(QTest::AI_Tag));
QTest::qt_asprintf(formatted, "<BenchmarkResult %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\" />\n",
element->attributeName(QTest::AI_Metric),
quotedMetric.constData(),
element->attributeName(QTest::AI_Tag),
quotedTag.constData(),
element->attributeName(QTest::AI_Value),
element->attributeValue(QTest::AI_Value),
element->attributeName(QTest::AI_Iterations),
element->attributeValue(QTest::AI_Iterations) );
break;
}
default:
formatted->data()[0] = '\0';
}
}
void QTestLightXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
if (element->elementType() == QTest::LET_TestCase) {
if( element->attribute(QTest::AI_Result) && element->childElements())
QTest::qt_asprintf(formatted, "</Incident>\n</TestFunction>\n");
else
QTest::qt_asprintf(formatted, "</TestFunction>\n");
} else {
formatted->data()[0] = '\0';
}
}
void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)) {
QTestCharBuffer buf;
QTestCharBuffer quotedFile;
QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
QTest::qt_asprintf(&buf, "%s=\"%s\" %s=\"%s\"",
element->attributeName(QTest::AI_File),
quotedFile.constData(),
element->attributeName(QTest::AI_Line),
element->attributeValue(QTest::AI_Line));
if( !element->childElements() )
QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n",
element->attributeValue(QTest::AI_Result), buf.constData());
else
QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n",
element->attributeValue(QTest::AI_Result), buf.constData());
} else {
formatted->data()[0] = '\0';
}
}
void QTestLightXmlStreamer::output(QTestElement *element) const
{
QTestCharBuffer buf;
QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
qVersion(), QTEST_VERSION_STR );
outputString(buf.constData());
QTest::qt_asprintf(&buf, "</Environment>\n");
outputString(buf.constData());
QTestBasicStreamer::output(element);
}
QT_END_NAMESPACE

View File

@ -1,72 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtTest module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTESTLIGHTXMLSTREAMER_H
#define QTESTLIGHTXMLSTREAMER_H
#include <QtTest/qtestbasicstreamer.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Test)
class QTestElement;
class QTestElementAttribute;
class QTestLightXmlStreamer: public QTestBasicStreamer
{
public:
QTestLightXmlStreamer(QTestLogger *logger);
~QTestLightXmlStreamer();
void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
void output(QTestElement *element) const;
};
QT_END_NAMESPACE
QT_END_HEADER
#endif

View File

@ -45,7 +45,7 @@
#include "QtTest/private/qtestresult_p.h"
#include "QtTest/private/qabstracttestlogger_p.h"
#include "QtTest/private/qplaintestlogger_p.h"
#include "QtTest/private/qtestlogger_p.h"
#include "QtTest/private/qxunittestlogger_p.h"
#include "QtTest/private/qxmltestlogger_p.h"
#include <QtCore/qatomic.h>
#include <QtCore/qbytearray.h>
@ -83,12 +83,10 @@ namespace QTest {
static IgnoreResultList *ignoreResultList = 0;
static QTestLog::LogMode logMode = QTestLog::Plain;
static QTestLog::FlushMode flushMode = QTestLog::NoFlush;
static int verbosity = 0;
static int maxWarnings = 2002;
static QAbstractTestLogger *testLogger = 0;
static const char *outFile = 0;
static QtMsgHandler oldMessageHandler;
@ -165,30 +163,6 @@ namespace QTest {
break;
}
}
void initLogger()
{
switch (QTest::logMode) {
case QTestLog::Plain:
QTest::testLogger = new QPlainTestLogger;
break;
case QTestLog::XML:
if (QTest::flushMode == QTestLog::FlushOn)
QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete);
else
QTest::testLogger = new QTestLogger(QTestLogger::TLF_XML);
break;
case QTestLog::LightXML:
if (QTest::flushMode == QTestLog::FlushOn)
QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light);
else
QTest::testLogger = new QTestLogger(QTestLogger::TLF_LightXml);
break;
case QTestLog::XunitXML:
QTest::testLogger = new QTestLogger(QTestLogger::TLF_XunitXml);
}
}
}
void QTestLog::enterTestFunction(const char* function)
@ -283,9 +257,8 @@ void QTestLog::addBenchmarkResult(const QBenchmarkResult &result)
void QTestLog::startLogging()
{
QTEST_ASSERT(!QTest::testLogger);
QTest::initLogger();
QTest::testLogger->startLogging(QTest::outFile);
QTEST_ASSERT(QTest::testLogger);
QTest::testLogger->startLogging();
QTest::oldMessageHandler = qInstallMsgHandler(QTest::messageHandler);
}
@ -299,6 +272,27 @@ void QTestLog::stopLogging()
QTest::testLogger = 0;
}
void QTestLog::initLogger(LogMode mode, const char *filename)
{
QTest::logMode = mode;
switch (mode) {
case QTestLog::Plain:
QTest::testLogger = new QPlainTestLogger(filename);
break;
case QTestLog::XML:
QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete, filename);
break;
case QTestLog::LightXML:
QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light, filename);
break;
case QTestLog::XunitXML:
QTest::testLogger = new QXunitTestLogger(filename);
break;
}
QTEST_ASSERT(QTest::testLogger);
}
void QTestLog::warn(const char *msg)
{
QTEST_ASSERT(QTest::testLogger);
@ -315,11 +309,6 @@ void QTestLog::info(const char *msg, const char *file, int line)
QTest::testLogger->addMessage(QAbstractTestLogger::Info, msg, file, line);
}
void QTestLog::setLogMode(LogMode mode)
{
QTest::logMode = mode;
}
QTestLog::LogMode QTestLog::logMode()
{
return QTest::logMode;
@ -351,26 +340,9 @@ void QTestLog::addIgnoreMessage(QtMsgType type, const char *msg)
list->next = item;
}
void QTestLog::redirectOutput(const char *fileName)
{
QTEST_ASSERT(fileName);
QTest::outFile = fileName;
}
const char *QTestLog::outputFileName()
{
return QTest::outFile;
}
void QTestLog::setMaxWarnings(int m)
{
QTest::maxWarnings = m <= 0 ? INT_MAX : m + 2;
}
void QTestLog::setFlushMode(FlushMode mode)
{
QTest::flushMode = mode;
}
QT_END_NAMESPACE

View File

@ -63,7 +63,6 @@ class Q_TESTLIB_EXPORT QTestLog
{
public:
enum LogMode { Plain = 0, XML, LightXML, XunitXML };
enum FlushMode { NoFlush = 0, FlushOn };
static void enterTestFunction(const char* function);
static void leaveTestFunction();
@ -84,18 +83,15 @@ public:
static void startLogging();
static void stopLogging();
static void setLogMode(LogMode mode);
static void initLogger(LogMode mode, const char *filename);
static LogMode logMode();
static void setVerboseLevel(int level);
static int verboseLevel();
static void redirectOutput(const char *fileName);
static const char *outputFileName();
static void setMaxWarnings(int max);
static void setFlushMode(FlushMode mode);
private:
QTestLog();
~QTestLog();

View File

@ -76,7 +76,7 @@ namespace QTest
if (delay == -1 || delay < defaultMouseDelay())
delay = defaultMouseDelay();
if(delay > 0)
if (delay > 0)
QTest::qWait(delay);
if (pos.isNull())

View File

@ -1,222 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtTest module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtestxmlstreamer.h"
#include "qtestelement.h"
#include "qtestelementattribute.h"
#include "qtestlogger_p.h"
#include "QtTest/private/qtestlog_p.h"
#include "QtTest/private/qtestresult_p.h"
#include "QtTest/private/qxmltestlogger_p.h"
#include <string.h>
#include <stdio.h>
QT_BEGIN_NAMESPACE
QTestXmlStreamer::QTestXmlStreamer(QTestLogger *logger)
: QTestBasicStreamer(logger)
{
}
QTestXmlStreamer::~QTestXmlStreamer()
{}
void QTestXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
switch(element->elementType()){
case QTest::LET_TestCase: {
QTestCharBuffer quotedTf;
QXmlTestLogger::xmlQuote(&quotedTf, element->attributeValue(QTest::AI_Name));
QTest::qt_asprintf(formatted, "<TestFunction name=\"%s\">\n", quotedTf.constData());
break;
}
case QTest::LET_Failure: {
QTestCharBuffer cdataDesc;
QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
QTestCharBuffer location;
QTestCharBuffer quotedFile;
QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
QTest::qt_asprintf(&location, "%s=\"%s\" %s=\"%s\"",
element->attributeName(QTest::AI_File),
quotedFile.constData(),
element->attributeName(QTest::AI_Line),
element->attributeValue(QTest::AI_Line));
if (element->attribute(QTest::AI_Tag)) {
QTestCharBuffer cdataTag;
QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag));
QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n"
" <DataTag><![CDATA[%s]]></DataTag>\n"
" <Description><![CDATA[%s]]></Description>\n"
"</Incident>\n", element->attributeValue(QTest::AI_Result),
location.constData(), cdataTag.constData(), cdataDesc.constData());
}
else {
QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n"
" <Description><![CDATA[%s]]></Description>\n"
"</Incident>\n", element->attributeValue(QTest::AI_Result),
location.constData(), cdataDesc.constData());
}
break;
}
case QTest::LET_Error: {
// assuming type and attribute names don't need quoting
QTestCharBuffer quotedFile;
QTestCharBuffer cdataDesc;
QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
QTestCharBuffer tagbuf;
if (element->attribute(QTest::AI_Tag)) {
QTestCharBuffer cdataTag;
QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag));
QTest::qt_asprintf(&tagbuf, " <DataTag><![CDATA[%s]]></DataTag>\n", cdataTag.constData());
}
QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n%s <Description><![CDATA[%s]]></Description>\n</Message>\n",
element->attributeValue(QTest::AI_Type),
element->attributeName(QTest::AI_File),
quotedFile.constData(),
element->attributeName(QTest::AI_Line),
element->attributeValue(QTest::AI_Line),
tagbuf.constData(),
cdataDesc.constData());
break;
}
case QTest::LET_Benchmark: {
// assuming value and iterations don't need quoting
QTestCharBuffer quotedMetric;
QTestCharBuffer quotedTag;
QXmlTestLogger::xmlQuote(&quotedMetric, element->attributeValue(QTest::AI_Metric));
QXmlTestLogger::xmlQuote(&quotedTag, element->attributeValue(QTest::AI_Tag));
QTest::qt_asprintf(formatted, "<BenchmarkResult %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\" />\n",
element->attributeName(QTest::AI_Metric),
quotedMetric.constData(),
element->attributeName(QTest::AI_Tag),
quotedTag.constData(),
element->attributeName(QTest::AI_Value),
element->attributeValue(QTest::AI_Value),
element->attributeName(QTest::AI_Iterations),
element->attributeValue(QTest::AI_Iterations) );
break;
}
default:
formatted->data()[0] = '\0';
}
}
void QTestXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
if (element->elementType() == QTest::LET_TestCase) {
bool failed = false;
for (QTestElement* child = element->childElements(); child; child = child->nextElement()) {
if ( child->elementType() == QTest::LET_Failure
&& child->attribute(QTest::AI_Result)
&& ( !strcmp(child->attributeValue(QTest::AI_Result), "fail")
|| !strcmp(child->attributeValue(QTest::AI_Result), "xpass"))
)
{
failed = true;
break;
}
}
// For passing functions, no Incident has been output yet.
// For failing functions, we already output one.
// Please note: we are outputting "pass" even if there was an xfail etc.
// This is by design (arguably bad design, but dangerous to change now!)
if (element->attribute(QTest::AI_Result) && !failed) {
QTest::qt_asprintf(formatted, "<Incident type=\"pass\" file=\"\" line=\"0\" />\n</TestFunction>\n");
}
else {
QTest::qt_asprintf(formatted, "</TestFunction>\n");
}
} else {
formatted->data()[0] = '\0';
}
}
void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
{
Q_UNUSED(element);
if (!formatted)
return;
formatted->data()[0] = '\0';
}
void QTestXmlStreamer::output(QTestElement *element) const
{
QTestCharBuffer buf;
QTestCharBuffer quotedTc;
QXmlTestLogger::xmlQuote(&quotedTc, QTestResult::currentTestObjectName());
QTest::qt_asprintf(&buf, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<TestCase name=\"%s\">\n",
quotedTc.constData());
outputString(buf.constData());
QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
qVersion(), QTEST_VERSION_STR );
outputString(buf.constData());
QTest::qt_asprintf(&buf, "</Environment>\n");
outputString(buf.constData());
QTestBasicStreamer::output(element);
QTest::qt_asprintf(&buf, "</TestCase>\n");
outputString(buf.constData());
}
QT_END_NAMESPACE

View File

@ -1,72 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtTest module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTESTXMLSTREAMER_H
#define QTESTXMLSTREAMER_H
#include <QtTest/qtestbasicstreamer.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Test)
class QTestElement;
class QTestElementAttribute;
class QTestXmlStreamer: public QTestBasicStreamer
{
public:
QTestXmlStreamer(QTestLogger *logger);
~QTestXmlStreamer();
void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
void output(QTestElement *element) const;
};
QT_END_NAMESPACE
QT_END_HEADER
#endif

View File

@ -40,7 +40,10 @@
****************************************************************************/
#include "qtestxunitstreamer.h"
#include "qxunittestlogger_p.h"
#include "qtestelement.h"
#include "qtestelementattribute.h"
#include "qtestassert.h"
#include "QtTest/private/qtestlog_p.h"
#include "QtTest/private/qtestresult_p.h"
@ -48,9 +51,11 @@
QT_BEGIN_NAMESPACE
QTestXunitStreamer::QTestXunitStreamer(QTestLogger *logger)
: QTestBasicStreamer(logger)
{}
QTestXunitStreamer::QTestXunitStreamer(QXunitTestLogger *logger)
: testLogger(logger)
{
QTEST_ASSERT(testLogger);
}
QTestXunitStreamer::~QTestXunitStreamer()
{}
@ -75,7 +80,7 @@ void QTestXunitStreamer::indentForElement(const QTestElement* element, char* buf
void QTestXunitStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted )
if (!element || !formatted )
return;
char indent[20];
@ -99,7 +104,7 @@ void QTestXunitStreamer::formatEnd(const QTestElement *element, QTestCharBuffer
if (!element || !formatted )
return;
if (!element->childElements()){
if (!element->childElements()) {
formatted->data()[0] = '\0';
return;
}
@ -112,7 +117,7 @@ void QTestXunitStreamer::formatEnd(const QTestElement *element, QTestCharBuffer
void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const
{
if(!attribute || !formatted )
if (!attribute || !formatted )
return;
QTest::AttributeIndex attrindex = attribute->index();
@ -144,7 +149,7 @@ void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTe
void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted )
if (!element || !formatted )
return;
// Errors are written as CDATA within system-err, comments elsewhere
@ -157,7 +162,7 @@ void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTes
return;
}
if(!element->childElements())
if (!element->childElements())
QTest::qt_asprintf(formatted, "/>\n");
else
QTest::qt_asprintf(formatted, ">\n");
@ -165,8 +170,10 @@ void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTes
void QTestXunitStreamer::output(QTestElement *element) const
{
QTEST_ASSERT(element);
outputString("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
QTestBasicStreamer::output(element);
outputElements(element);
}
void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
@ -183,19 +190,16 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
while (element) {
hasChildren = element->childElements();
if(element->elementType() != QTest::LET_Benchmark){
if (element->elementType() != QTest::LET_Benchmark) {
formatStart(element, &buf);
outputString(buf.data());
formatBeforeAttributes(element, &buf);
outputString(buf.data());
outputElementAttributes(element, element->attributes());
formatAfterAttributes(element, &buf);
outputString(buf.data());
if(hasChildren)
if (hasChildren)
outputElements(element->childElements(), true);
formatEnd(element, &buf);
@ -205,5 +209,19 @@ void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
}
}
QT_END_NAMESPACE
void QTestXunitStreamer::outputElementAttributes(const QTestElement* element, QTestElementAttribute *attribute) const
{
QTestCharBuffer buf;
while (attribute) {
formatAttributes(element, attribute, &buf);
outputString(buf.data());
attribute = attribute->nextElement();
}
}
void QTestXunitStreamer::outputString(const char *msg) const
{
testLogger->outputString(msg);
}
QT_END_NAMESPACE

View File

@ -42,7 +42,7 @@
#ifndef QTESTXUNITSTREAMER_H
#define QTESTXUNITSTREAMER_H
#include <QtTest/qtestbasicstreamer.h>
#include <QtCore/qglobal.h>
QT_BEGIN_HEADER
@ -50,12 +50,15 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Test)
class QTestLogger;
class QTestElement;
class QTestElementAttribute;
class QXunitTestLogger;
struct QTestCharBuffer;
class QTestXunitStreamer: public QTestBasicStreamer
class QTestXunitStreamer
{
public:
QTestXunitStreamer(QTestLogger *logger);
QTestXunitStreamer(QXunitTestLogger *logger);
~QTestXunitStreamer();
void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
@ -64,10 +67,15 @@ class QTestXunitStreamer: public QTestBasicStreamer
void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const;
void output(QTestElement *element) const;
void outputElements(QTestElement *element, bool isChildElement = false) const;
void outputElementAttributes(const QTestElement *element, QTestElementAttribute *attribute) const;
void outputString(const char *msg) const;
private:
void displayXunitXmlHeader() const;
static void indentForElement(const QTestElement* element, char* buf, int size);
QXunitTestLogger *testLogger;
};
QT_END_NAMESPACE

View File

@ -92,8 +92,8 @@ namespace QTest {
}
QXmlTestLogger::QXmlTestLogger(XmlMode mode )
: xmlmode(mode)
QXmlTestLogger::QXmlTestLogger(XmlMode mode, const char *filename)
: QAbstractTestLogger(filename), xmlmode(mode)
{
}
@ -101,9 +101,9 @@ QXmlTestLogger::~QXmlTestLogger()
{
}
void QXmlTestLogger::startLogging(const char *filename)
void QXmlTestLogger::startLogging()
{
QAbstractTestLogger::startLogging(filename);
QAbstractTestLogger::startLogging();
QTestCharBuffer buf;
if (xmlmode == QXmlTestLogger::Complete) {
@ -115,7 +115,7 @@ void QXmlTestLogger::startLogging(const char *filename)
outputString(buf.constData());
}
QTest::qt_asprintf(&buf,
QTest::qt_asprintf(&buf,
"<Environment>\n"
" <QtVersion>%s</QtVersion>\n"
" <QTestVersion>"QTEST_VERSION_STR"</QTestVersion>\n"

View File

@ -63,10 +63,10 @@ class QXmlTestLogger : public QAbstractTestLogger
public:
enum XmlMode { Complete = 0, Light };
QXmlTestLogger(XmlMode mode = Complete);
QXmlTestLogger(XmlMode mode, const char *filename);
~QXmlTestLogger();
void startLogging(const char *filename);
void startLogging();
void stopLogging();
void enterTestFunction(const char *function);

View File

@ -39,11 +39,9 @@
**
****************************************************************************/
#include "qtestlogger_p.h"
#include "qxunittestlogger_p.h"
#include "qtestelement.h"
#include "qtestxunitstreamer.h"
#include "qtestxmlstreamer.h"
#include "qtestlightxmlstreamer.h"
#include "QtTest/qtestcase.h"
#include "QtTest/private/qtestresult_p.h"
@ -53,102 +51,84 @@
QT_BEGIN_NAMESPACE
QTestLogger::QTestLogger(int fm)
: listOfTestcases(0)
QXunitTestLogger::QXunitTestLogger(const char *filename)
: QAbstractTestLogger(filename)
, listOfTestcases(0)
, currentLogElement(0)
, errorLogElement(0)
, logFormatter(0)
, format( (TestLoggerFormat)fm )
, testCounter(0)
, failureCounter(0)
, errorCounter(0)
{
}
QTestLogger::~QTestLogger()
QXunitTestLogger::~QXunitTestLogger()
{
if(format == TLF_XunitXml)
delete currentLogElement;
else
delete listOfTestcases;
delete currentLogElement;
delete logFormatter;
}
void QTestLogger::startLogging(const char *filename)
void QXunitTestLogger::startLogging()
{
QAbstractTestLogger::startLogging(filename);
QAbstractTestLogger::startLogging();
switch(format){
case TLF_LightXml:
logFormatter = new QTestLightXmlStreamer(this);
break;
case TLF_XML:
logFormatter = new QTestXmlStreamer(this);
break;
case TLF_XunitXml:
logFormatter = new QTestXunitStreamer(this);
delete errorLogElement;
errorLogElement = new QTestElement(QTest::LET_SystemError);
break;
}
logFormatter = new QTestXunitStreamer(this);
delete errorLogElement;
errorLogElement = new QTestElement(QTest::LET_SystemError);
}
void QTestLogger::stopLogging()
void QXunitTestLogger::stopLogging()
{
QTestElement *iterator = listOfTestcases;
if(format == TLF_XunitXml ){
char buf[10];
char buf[10];
currentLogElement = new QTestElement(QTest::LET_TestSuite);
currentLogElement->addAttribute(QTest::AI_Name, QTestResult::currentTestObjectName());
currentLogElement = new QTestElement(QTest::LET_TestSuite);
currentLogElement->addAttribute(QTest::AI_Name, QTestResult::currentTestObjectName());
QTest::qt_snprintf(buf, sizeof(buf), "%i", testCounter);
currentLogElement->addAttribute(QTest::AI_Tests, buf);
QTest::qt_snprintf(buf, sizeof(buf), "%i", testCounter);
currentLogElement->addAttribute(QTest::AI_Tests, buf);
QTest::qt_snprintf(buf, sizeof(buf), "%i", failureCounter);
currentLogElement->addAttribute(QTest::AI_Failures, buf);
QTest::qt_snprintf(buf, sizeof(buf), "%i", failureCounter);
currentLogElement->addAttribute(QTest::AI_Failures, buf);
QTest::qt_snprintf(buf, sizeof(buf), "%i", errorCounter);
currentLogElement->addAttribute(QTest::AI_Errors, buf);
QTest::qt_snprintf(buf, sizeof(buf), "%i", errorCounter);
currentLogElement->addAttribute(QTest::AI_Errors, buf);
QTestElement *property;
QTestElement *properties = new QTestElement(QTest::LET_Properties);
QTestElement *property;
QTestElement *properties = new QTestElement(QTest::LET_Properties);
property = new QTestElement(QTest::LET_Property);
property->addAttribute(QTest::AI_Name, "QTestVersion");
property->addAttribute(QTest::AI_PropertyValue, QTEST_VERSION_STR);
properties->addLogElement(property);
property = new QTestElement(QTest::LET_Property);
property->addAttribute(QTest::AI_Name, "QTestVersion");
property->addAttribute(QTest::AI_PropertyValue, QTEST_VERSION_STR);
properties->addLogElement(property);
property = new QTestElement(QTest::LET_Property);
property->addAttribute(QTest::AI_Name, "QtVersion");
property->addAttribute(QTest::AI_PropertyValue, qVersion());
properties->addLogElement(property);
property = new QTestElement(QTest::LET_Property);
property->addAttribute(QTest::AI_Name, "QtVersion");
property->addAttribute(QTest::AI_PropertyValue, qVersion());
properties->addLogElement(property);
currentLogElement->addLogElement(properties);
currentLogElement->addLogElement(properties);
currentLogElement->addLogElement(iterator);
currentLogElement->addLogElement(iterator);
/* For correct indenting, make sure every testcase knows its parent */
QTestElement* testcase = iterator;
while (testcase) {
testcase->setParent(currentLogElement);
testcase = testcase->nextElement();
}
currentLogElement->addLogElement(errorLogElement);
QTestElement *it = currentLogElement;
logFormatter->output(it);
}else{
logFormatter->output(iterator);
/* For correct indenting, make sure every testcase knows its parent */
QTestElement* testcase = iterator;
while (testcase) {
testcase->setParent(currentLogElement);
testcase = testcase->nextElement();
}
currentLogElement->addLogElement(errorLogElement);
QTestElement *it = currentLogElement;
logFormatter->output(it);
QAbstractTestLogger::stopLogging();
}
void QTestLogger::enterTestFunction(const char *function)
void QXunitTestLogger::enterTestFunction(const char *function)
{
currentLogElement = new QTestElement(QTest::LET_TestCase);
currentLogElement->addAttribute(QTest::AI_Name, function);
@ -157,12 +137,12 @@ void QTestLogger::enterTestFunction(const char *function)
++testCounter;
}
void QTestLogger::leaveTestFunction()
void QXunitTestLogger::leaveTestFunction()
{
}
void QTestLogger::addIncident(IncidentTypes type, const char *description,
const char *file, int line)
void QXunitTestLogger::addIncident(IncidentTypes type, const char *description,
const char *file, int line)
{
const char *typeBuf = 0;
char buf[100];
@ -187,11 +167,10 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description,
break;
}
if (type == QAbstractTestLogger::Fail || type == QAbstractTestLogger::XPass
|| ((format != TLF_XunitXml) && (type == QAbstractTestLogger::XFail))) {
if (type == QAbstractTestLogger::Fail || type == QAbstractTestLogger::XPass) {
QTestElement *failureElement = new QTestElement(QTest::LET_Failure);
failureElement->addAttribute(QTest::AI_Result, typeBuf);
if(file)
if (file)
failureElement->addAttribute(QTest::AI_File, file);
else
failureElement->addAttribute(QTest::AI_File, "");
@ -229,7 +208,7 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description,
currentLogElement->addAttribute(QTest::AI_Result, typeBuf);
}
if(file)
if (file)
currentLogElement->addAttribute(QTest::AI_File, file);
else
currentLogElement->addAttribute(QTest::AI_File, "");
@ -241,12 +220,12 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description,
Since XFAIL does not add a failure to the testlog in xunitxml, add a message, so we still
have some information about the expected failure.
*/
if (format == TLF_XunitXml && type == QAbstractTestLogger::XFail) {
QTestLogger::addMessage(QAbstractTestLogger::Info, description, file, line);
if (type == QAbstractTestLogger::XFail) {
QXunitTestLogger::addMessage(QAbstractTestLogger::Info, description, file, line);
}
}
void QTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
void QXunitTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
{
QTestElement *benchmarkElement = new QTestElement(QTest::LET_Benchmark);
@ -262,7 +241,7 @@ void QTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
currentLogElement->addLogElement(benchmarkElement);
}
void QTestLogger::addTag(QTestElement* element)
void QXunitTestLogger::addTag(QTestElement* element)
{
const char *tag = QTestResult::currentDataTag();
const char *gtag = QTestResult::currentGlobalDataTag();
@ -283,7 +262,7 @@ void QTestLogger::addTag(QTestElement* element)
element->addAttribute(QTest::AI_Tag, buf.constData());
}
void QTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line)
void QXunitTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line)
{
QTestElement *errorElement = new QTestElement(QTest::LET_Error);
const char *typeBuf = 0;
@ -319,7 +298,7 @@ void QTestLogger::addMessage(MessageTypes type, const char *message, const char
errorElement->addAttribute(QTest::AI_Description, message);
addTag(errorElement);
if(file)
if (file)
errorElement->addAttribute(QTest::AI_File, file);
else
errorElement->addAttribute(QTest::AI_File, "");

View File

@ -57,23 +57,16 @@
QT_BEGIN_NAMESPACE
class QTestBasicStreamer;
class QTestXunitStreamer;
class QTestElement;
class QTestLogger : public QAbstractTestLogger
class QXunitTestLogger : public QAbstractTestLogger
{
public:
QTestLogger(int fm = 0);
~QTestLogger();
QXunitTestLogger(const char *filename);
~QXunitTestLogger();
enum TestLoggerFormat
{
TLF_XML = 0,
TLF_LightXml = 1,
TLF_XunitXml = 2
};
void startLogging(const char *filename);
void startLogging();
void stopLogging();
void enterTestFunction(const char *function);
@ -91,8 +84,7 @@ class QTestLogger : public QAbstractTestLogger
QTestElement *listOfTestcases;
QTestElement *currentLogElement;
QTestElement *errorLogElement;
QTestBasicStreamer *logFormatter;
TestLoggerFormat format;
QTestXunitStreamer *logFormatter;
int testCounter;
int failureCounter;

View File

@ -18,7 +18,6 @@ HEADERS = qbenchmark.h \
qsignalspy.h \
qtestaccessible.h \
qtestassert.h \
qtestbasicstreamer.h \
qtestcase.h \
qtestcoreelement.h \
qtestcorelist.h \
@ -31,12 +30,10 @@ HEADERS = qbenchmark.h \
qtest_gui.h \
qtest.h \
qtestkeyboard.h \
qtestlightxmlstreamer.h \
qtestmouse.h \
qtestspontaneevent.h \
qtestsystem.h \
qtesttouch.h \
qtestxmlstreamer.h \
qtestxunitstreamer.h
SOURCES = qtestcase.cpp \
qtestlog.cpp \
@ -55,11 +52,8 @@ SOURCES = qtestcase.cpp \
qbenchmarkmetric.cpp \
qtestelement.cpp \
qtestelementattribute.cpp \
qtestbasicstreamer.cpp \
qtestxunitstreamer.cpp \
qtestxmlstreamer.cpp \
qtestlightxmlstreamer.cpp \
qtestlogger.cpp
qxunittestlogger.cpp
DEFINES *= QT_NO_CAST_TO_ASCII \
QT_NO_CAST_FROM_ASCII \
QTESTLIB_MAKEDLL \

View File

@ -514,7 +514,6 @@ QT_CLASS_LIB(QTest, QtTest, qtest.h)
QT_CLASS_LIB(QtTestGui, QtTest, qtest_gui.h)
QT_CLASS_LIB(QTestAccessibilityEvent, QtTest, qtestaccessible.h)
QT_CLASS_LIB(QTestAccessibility, QtTest, qtestaccessible.h)
QT_CLASS_LIB(QTestBasicStreamer, QtTest, qtestbasicstreamer.h)
QT_CLASS_LIB(QTestCoreElement, QtTest, qtestcoreelement.h)
QT_CLASS_LIB(QTestCoreList, QtTest, qtestcorelist.h)
QT_CLASS_LIB(QTestData, QtTest, qtestdata.h)
@ -527,11 +526,9 @@ QT_CLASS_LIB(QTestMouseEvent, QtTest, qtestevent.h)
QT_CLASS_LIB(QTestDelayEvent, QtTest, qtestevent.h)
QT_CLASS_LIB(QTestEventList, QtTest, qtestevent.h)
QT_CLASS_LIB(QTestEventLoop, QtTest, qtesteventloop.h)
QT_CLASS_LIB(QTestLightXmlStreamer, QtTest, qtestlightxmlstreamer.h)
QT_CLASS_LIB(QEventSizeOfChecker, QtTest, qtestspontaneevent.h)
QT_CLASS_LIB(QEventSizeOfChecker, QtTest, qtestspontaneevent.h)
QT_CLASS_LIB(QSpontaneKeyEvent, QtTest, qtestspontaneevent.h)
QT_CLASS_LIB(QTestXmlStreamer, QtTest, qtestxmlstreamer.h)
QT_CLASS_LIB(QTestXunitStreamer, QtTest, qtestxunitstreamer.h)
QT_CLASS_LIB(QDBusAbstractAdaptor, QtDBus, qdbusabstractadaptor.h)
QT_CLASS_LIB(QDBusAbstractInterfaceBase, QtDBus, qdbusabstractinterface.h)

View File

@ -1,7 +1,7 @@
From e13ce09287a56c920d5ffdc5d4662d49f1838f16 Mon Sep 17 00:00:00 2001
From: Aaron Kennedy <aaron.kennedy@nokia.com>
Date: Mon, 23 May 2011 15:47:20 +1000
Subject: [PATCH 01/13] Add hashing and comparison methods to v8::String
Subject: [PATCH 01/16] Add hashing and comparison methods to v8::String
This allows us to more rapidly search for a v8::String inside
a hash of QStrings.
@ -339,5 +339,5 @@ index e966b3d..6e26f57 100644
// Maximal memory usage for a single sequential two-byte string.
--
1.7.2.3
1.7.6

View File

@ -1,7 +1,7 @@
From 7c9cfff80b7864d5687432d424074e51712c4a07 Mon Sep 17 00:00:00 2001
From: Aaron Kennedy <aaron.kennedy@nokia.com>
Date: Mon, 23 May 2011 15:55:26 +1000
Subject: [PATCH 02/13] Add a bit field 3 to Map
Subject: [PATCH 02/16] Add a bit field 3 to Map
Bit field 3 will be used to add QML specific map flags.
---
@ -114,5 +114,5 @@ index 6e26f57..07e1089 100644
static const int kCodeCacheEntrySize = 2;
static const int kCodeCacheEntryNameOffset = 0;
--
1.7.2.3
1.7.6

View File

@ -1,7 +1,7 @@
From ae8688b53d67044f2c9b0cce25fc282b078610c1 Mon Sep 17 00:00:00 2001
From: Aaron Kennedy <aaron.kennedy@nokia.com>
Date: Mon, 23 May 2011 16:21:02 +1000
Subject: [PATCH 03/13] Add a "fallback" mode for named property interceptors
Subject: [PATCH 03/16] Add a "fallback" mode for named property interceptors
By default interceptors are called before the normal property
resolution on objects. When an interceptor is installed as a
@ -360,5 +360,5 @@ index 7335da8..660352c 100644
return isolate->heap()->undefined_value();
}
--
1.7.2.3
1.7.6

View File

@ -1,7 +1,7 @@
From 4827116b12c50f6662794017c5a662b5dbb2da0b Mon Sep 17 00:00:00 2001
From: Aaron Kennedy <aaron.kennedy@nokia.com>
Date: Mon, 23 May 2011 16:55:35 +1000
Subject: [PATCH 04/13] Generalize external object resources
Subject: [PATCH 04/16] Generalize external object resources
V8 was already able to manage and finalize an external string
resource. This change generalizes that mechanism to handle a
@ -890,5 +890,5 @@ index a209cd0..1bdb5c7 100644
--
1.7.2.3
1.7.6

View File

@ -1,7 +1,7 @@
From fd7d475e298e5b63cd6383c78cc900635c82aa38 Mon Sep 17 00:00:00 2001
From: Aaron Kennedy <aaron.kennedy@nokia.com>
Date: Mon, 23 May 2011 18:26:19 +1000
Subject: [PATCH 05/13] Introduce a QML compilation mode
Subject: [PATCH 05/16] Introduce a QML compilation mode
In QML mode, there is a second global object - known as the QML
global object. During property resolution, if a property is not
@ -1773,5 +1773,5 @@ index 4c17720..aa284ed 100644
static inline Operand StackSpaceOperand(int index) {
#ifdef _WIN64
--
1.7.2.3
1.7.6

View File

@ -1,7 +1,7 @@
From f890f0d1a1e5bd62711815489c87755a4f382436 Mon Sep 17 00:00:00 2001
From: Aaron Kennedy <aaron.kennedy@nokia.com>
Date: Wed, 25 May 2011 10:36:13 +1000
Subject: [PATCH 06/13] Allow access to the calling script data
Subject: [PATCH 06/16] Allow access to the calling script data
---
include/v8.h | 1 +
@ -44,5 +44,5 @@ index 39767f4..ff74efb 100644
v8::Local<v8::Object> Context::Global() {
if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) {
--
1.7.2.3
1.7.6

View File

@ -1,7 +1,7 @@
From dac5d9db84cf20564621c679937ca7b9c6a8e880 Mon Sep 17 00:00:00 2001
From: Aaron Kennedy <aaron.kennedy@nokia.com>
Date: Fri, 27 May 2011 13:04:15 +1000
Subject: [PATCH 07/13] Fix warnings
Subject: [PATCH 07/16] Fix warnings
---
include/v8.h | 16 ++++++++--------
@ -42,5 +42,5 @@ index 9aba4a8..8891dab 100644
} // namespace internal
--
1.7.2.3
1.7.6

View File

@ -1,7 +1,7 @@
From bec11b8b7f89d135e7d9a823ac4fe98c70d017cf Mon Sep 17 00:00:00 2001
From: Aaron Kennedy <aaron.kennedy@nokia.com>
Date: Mon, 27 Jun 2011 14:57:28 +1000
Subject: [PATCH 08/13] Add custom object compare callback
Subject: [PATCH 08/16] Add custom object compare callback
A global custom object comparison callback can be set with:
V8::SetUserObjectComparisonCallbackFunction()
@ -485,5 +485,5 @@ index d923494..10b9b56 100644
ASSERT(GetCondition() == equal);
__ subq(rax, rdx);
--
1.7.2.3
1.7.6

View File

@ -1,7 +1,8 @@
From 4183b973ed3bd603784c798dfa63ba48f6b68003 Mon Sep 17 00:00:00 2001
From: ager@chromium.org <ager@chromium.org>
From: "ager@chromium.org" <ager@chromium.org>
Date: Wed, 4 May 2011 13:03:08 +0000
Subject: [PATCH 09/13] Add CallAsFunction method to the Object class in the API
Subject: [PATCH 09/16] Add CallAsFunction method to the Object class in the
API
Patch by Peter Varga.
@ -282,5 +283,5 @@ index d7621d1..693d51e 100644
--
1.7.2.3
1.7.6

View File

@ -1,7 +1,8 @@
From 3d6d4249878f7960eac4c9c94e0f2529f9a58c4a Mon Sep 17 00:00:00 2001
From: ager@chromium.org <ager@chromium.org>
From: "ager@chromium.org" <ager@chromium.org>
Date: Fri, 6 May 2011 11:07:52 +0000
Subject: [PATCH 10/13] Implement CallAsConstructor method for Object in the API
Subject: [PATCH 10/16] Implement CallAsConstructor method for Object in the
API
Patch by Peter Varga.
@ -393,5 +394,5 @@ index 693d51e..1334f63 100644
}
}
--
1.7.2.3
1.7.6

View File

@ -1,7 +1,8 @@
From f22d0312faeb93ced8747d9aae8c6d77e11b4aba Mon Sep 17 00:00:00 2001
From: Jedrzej Nowacki <jedrzej.nowacki@nokia.com>
Date: Tue, 7 Dec 2010 11:56:42 +0100
Subject: [PATCH 11/13] QtScript/V8: Add new v8 api to check if a value is an error.
Subject: [PATCH 11/16] QtScript/V8: Add new v8 api to check if a value is an
error.
New function v8::Value::IsError was created.
@ -59,5 +60,5 @@ index 8cbf378..db90bb9 100644
V(to_string_symbol, "toString") \
V(char_at_symbol, "CharAt") \
--
1.7.2.3
1.7.6

View File

@ -1,7 +1,8 @@
From 472c04c9e7a64e8734c76d2cf97a7cc5b773b788 Mon Sep 17 00:00:00 2001
From: ager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
From: "ager@chromium.org"
<ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Date: Mon, 9 May 2011 15:24:48 +0000
Subject: [PATCH 12/13] Add IsCallable method for Object in the API
Subject: [PATCH 12/16] Add IsCallable method for Object in the API
Patch by Peter Varga.
@ -112,5 +113,5 @@ index 1334f63..45db5a1 100644
return v8::HandleScope::NumberOfHandles();
}
--
1.7.2.3
1.7.6

View File

@ -1,7 +1,7 @@
From dc2cad4f8fc88c52fcea09b8d0262d35cd32dc44 Mon Sep 17 00:00:00 2001
From: Aaron Kennedy <aaron.kennedy@nokia.com>
Date: Thu, 25 Aug 2011 11:09:58 +1000
Subject: [PATCH 13/13] Remove execute flag from v8-debug.h
Subject: [PATCH 13/16] Remove execute flag from v8-debug.h
---
0 files changed, 0 insertions(+), 0 deletions(-)
@ -11,5 +11,5 @@ diff --git a/include/v8-debug.h b/include/v8-debug.h
old mode 100755
new mode 100644
--
1.7.2.3
1.7.6

View File

@ -0,0 +1,25 @@
From d7e876decc00c611d327185bf890a7efecb2cf7e Mon Sep 17 00:00:00 2001
From: Kent Hansen <kent.hansen@nokia.com>
Date: Mon, 29 Aug 2011 13:26:13 +0200
Subject: [PATCH 14/16] Fix build error: "suggest parentheses around '&&'
within '||'"
---
src/mark-compact.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index 1b1e361..775f787 100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -1020,7 +1020,7 @@ class SymbolTableCleaner : public ObjectVisitor {
// Since no objects have yet been moved we can safely access the map of
// the object.
if ((*p)->IsExternalString() ||
- (*p)->IsHeapObject() && HeapObject::cast(*p)->map()->has_external_resource()) {
+ ((*p)->IsHeapObject() && HeapObject::cast(*p)->map()->has_external_resource())) {
heap_->FinalizeExternalString(HeapObject::cast(*p));
}
// Set the entry to null_value (as deleted).
--
1.7.6

View File

@ -0,0 +1,25 @@
From 0af1e15a3d6b28923c262a02a5ace35812c8f5d6 Mon Sep 17 00:00:00 2001
From: Simon Hausmann <simon.hausmann@nokia.com>
Date: Thu, 4 Aug 2011 21:28:38 +0200
Subject: [PATCH 15/16] Fix source compatibility where the String::Equals
overloads would shadow the Value::Equals function,
breaking the build.
---
include/v8.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/include/v8.h b/include/v8.h
index 4194d4a..5e1ce50 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -1048,6 +1048,7 @@ class String : public Primitive {
*/
V8EXPORT bool Equals(uint16_t *string, int length);
V8EXPORT bool Equals(char *string, int length);
+ inline bool Equals(Handle<Value> that) const { return v8::Value::Equals(that); }
/**
* Write the contents of the string to an external buffer.
--
1.7.6

Some files were not shown because too many files have changed in this diff Show More