Merge "Merge branch 'stable' into dev" into refs/staging/dev

This commit is contained in:
Sergio Ahumada 2013-09-27 11:31:32 +02:00 committed by The Qt Project
commit 150b8ca294
85 changed files with 1055 additions and 311 deletions

View File

@ -125,8 +125,8 @@ manifestmeta.android.names = "QtQuick/Qt Quick Demo - Maroon*" \
"QtLinguist/Arrow Pad Example" \
"QtGui/Raster Window Example" \
"QtGui/Analog Clock Window Example" \
"QtMultimedia/Video Widget Example" \
"QtMultimedia/Media Player Example" \
"QtMultimediaWidgets/Video Widget Example" \
"QtMultimediaWidgets/Media Player Example" \
"QtSVG/Text Object Example" \
"QtQML/Qt Quick Examples - XMLHttpRequest" \
"QtQuick/Qt Quick Particles Examples - *" \
@ -188,7 +188,7 @@ manifestmeta.thumbnail.names = "QtConcurrent/Map Example" \
"QtHelp/*" \
"QtMultimedia/AudioEngine Example" \
"QtMultimedia/Declarative Radio Example" \
"QtMultimedia/Media Player Example" \
"QtMultimediaWidgets/Media Player Example" \
"QtQml/Extending QML*" \
"QtQuick/Qt Quick Examples - Accessibility" \
"QtSensors/Qt Sensors - SensorGesture QML Type example" \

View File

@ -79,12 +79,14 @@ char **qtArgv;
QApplication *qtApp = 0;
}
@interface WindowCreator : NSObject {}
- (void)createWindow;
@interface WindowCreator : NSObject <NSApplicationDelegate>
@end
@implementation WindowCreator
- (void)createWindow {
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
Q_UNUSED(notification)
// Qt widgets rely on a QApplication being alive somewhere
qtApp = new QApplication(qtArgc, qtArgv);
@ -120,18 +122,25 @@ QApplication *qtApp = 0;
// Show the NSWindow
[window makeKeyAndOrderFront:NSApp];
}
- (void)applicationWillTerminate:(NSNotification *)notification
{
Q_UNUSED(notification)
delete qtApp;
}
@end
int main(int argc, char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Q_UNUSED(pool);
// Normally, we would use the application delegate.
// We resort to the notification mechanism for conciseness.
// Normally, we would use let the main bundle instanciate and set
// the application delegate, but we set it manually for conciseness.
WindowCreator *windowCreator= [WindowCreator alloc];
[[NSNotificationCenter defaultCenter]
addObserver:windowCreator selector:@selector(createWindow)
name:NSApplicationDidFinishLaunchingNotification object:nil];
[[NSApplication sharedApplication] setDelegate:windowCreator];
// Save these for QApplication
qtArgc = argc;

View File

@ -54,7 +54,7 @@ class QEglFS8726MHooks : public QEglFSHooks
{
public:
virtual QSize screenSize() const;
virtual EGLNativeWindowType createNativeWindow(const QSize &size, const QSurfaceFormat &format);
virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format);
virtual void destroyNativeWindow(EGLNativeWindowType window);
};
@ -75,9 +75,10 @@ QSize QEglFS8726MHooks::screenSize() const
return QSize(vinfo.xres, vinfo.yres);
}
EGLNativeWindowType QEglFS8726MHooks::createNativeWindow(const QSize &size, const QSurfaceFormat &format)
EGLNativeWindowType QEglFS8726MHooks::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format)
{
Q_UNUSED(format);
Q_UNUSED(window)
Q_UNUSED(format)
fbdev_window *window = new fbdev_window;
window->width = size.width();

View File

@ -49,7 +49,7 @@ class QEglFSImx6Hooks : public QEglFSHooks
public:
QEglFSImx6Hooks();
virtual QSize screenSize() const;
virtual EGLNativeWindowType createNativeWindow(const QSize &size, const QSurfaceFormat &format);
virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format);
virtual void destroyNativeWindow(EGLNativeWindowType window);
virtual EGLNativeDisplayType platformDisplay() const;
@ -78,9 +78,10 @@ EGLNativeDisplayType QEglFSImx6Hooks::platformDisplay() const
return mNativeDisplay;
}
EGLNativeWindowType QEglFSImx6Hooks::createNativeWindow(const QSize &size, const QSurfaceFormat &format)
EGLNativeWindowType QEglFSImx6Hooks::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format)
{
Q_UNUSED(format);
Q_UNUSED(window)
Q_UNUSED(format)
EGLNativeWindowType eglWindow = fbCreateWindow(mNativeDisplay, 0, 0, size.width(), size.height());
return eglWindow;

View File

@ -226,7 +226,7 @@ public:
virtual void platformDestroy();
virtual EGLNativeDisplayType platformDisplay() const;
virtual QSize screenSize() const;
virtual EGLNativeWindowType createNativeWindow(const QSize &size, const QSurfaceFormat &format);
virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format);
virtual void destroyNativeWindow(EGLNativeWindowType window);
virtual bool hasCapability(QPlatformIntegration::Capability cap) const;
@ -258,8 +258,9 @@ QSize QEglFSPiHooks::screenSize() const
return QSize(width, height);
}
EGLNativeWindowType QEglFSPiHooks::createNativeWindow(const QSize &size, const QSurfaceFormat &format)
EGLNativeWindowType QEglFSPiHooks::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format)
{
Q_UNUSED(window)
return createDispmanxLayer(QPoint(0, 0), size, 1, format.hasAlpha() ? DISPMANX_FLAGS_ALPHA_FROM_SOURCE : DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS);
}

View File

@ -2,13 +2,10 @@ contains(TEMPLATE, ".*app") {
!android_app {
!contains(TARGET, ".so"): TARGET = lib$${TARGET}.so
QMAKE_LFLAGS += -Wl,-soname,$$TARGET
android_install: {
target.path=/libs/$$ANDROID_TARGET_ARCH/
INSTALLS *= target
}
}
}
!QTDIR_build:android_install {
isEmpty(QT_BUILD_TREE) {
target.path=/libs/$$ANDROID_TARGET_ARCH/
} else {
target.path = /
}
INSTALLS *= target
}

View File

@ -45,10 +45,10 @@ contains(TEMPLATE, ".*app"):!build_pass:!android-no-sdk {
FILE_CONTENT += " \"android-package\": \"$$ANDROID_PACKAGE\","
!isEmpty(ANDROID_MINIMUM_VERSION): \
FILE_CONTENT += " \"android-minimum-version\": \"$$ANDROID_MINIMUM_VERSION\","
FILE_CONTENT += " \"android-minimum-version\": $$ANDROID_MINIMUM_VERSION,"
!isEmpty(ANDROID_TARGET_VERSION): \
FILE_CONTENT += " \"android-target-version\": \"$$ANDROID_TARGET_VERSION\","
FILE_CONTENT += " \"android-target-version\": $$ANDROID_TARGET_VERSION,"
!isEmpty(ANDROID_APP_NAME): \
FILE_CONTENT += " \"android-app-name\": \"$$ANDROID_APP_NAME\","

View File

@ -19,7 +19,7 @@ equals(TEMPLATE, app) {
# We use xcodebuild to do the actual build, but filter out the verbose
# output that shows all environment variables for each build step.
xcodebuild_build.commands = "@xcodebuild build | grep -v setenv"
xcodebuild_build.commands = "@bash -o pipefail -c 'xcodebuild | grep -v setenv'"
QMAKE_EXTRA_TARGETS += xcodebuild_build
all.depends = xcodebuild_build
QMAKE_EXTRA_TARGETS += all

View File

@ -62,7 +62,7 @@ class QEglFSPandaHooks : public QEglFSHooks
{
public:
QEglFSPandaHooks();
virtual EGLNativeWindowType createNativeWindow(const QSize &size, const QSurfaceFormat &format);
virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format);
virtual bool filterConfig(EGLDisplay display, EGLConfig config) const;
virtual const char *fbDeviceName() const { return "/dev/graphics/fb0"; }
@ -103,8 +103,9 @@ void QEglFSPandaHooks::ensureFramebufferNativeWindowCreated()
window->query(window, NATIVE_WINDOW_FORMAT, &mFramebufferVisualId);
}
EGLNativeWindowType QEglFSPandaHooks::createNativeWindow(const QSize &size, const QSurfaceFormat &format)
EGLNativeWindowType QEglFSPandaHooks::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format)
{
Q_UNUSED(window)
return mUseFramebuffer ? createNativeWindowFramebuffer(size, format) : createNativeWindowSurfaceFlinger(size, format);
}

View File

@ -1,4 +1,4 @@
CONFIG -= qt
CONFIG -= qt android_install
javaresources.files = \
$$PWD/AndroidManifest.xml \

View File

@ -27,7 +27,7 @@ qhp.QtConcurrent.subprojects.classes.sortPages = true
tagfile = ../../../doc/qtconcurrent/qtconcurrent.tags
depends += qtcore
depends += qtcore qtdoc
headerdirs += ..

View File

@ -90,10 +90,13 @@ static qint64 getticks()
# if (_POSIX_THREAD_CPUTIME-0 == 0)
// detect availablility of CLOCK_THREAD_CPUTIME_ID
static long useThreadCpuTime = -2;
static QBasicAtomicInt sUseThreadCpuTime = Q_BASIC_ATOMIC_INITIALIZER(-2);
int useThreadCpuTime = sUseThreadCpuTime.load();
if (useThreadCpuTime == -2) {
// sysconf() will return either -1 or _POSIX_VERSION (don't care about thread races here)
useThreadCpuTime = sysconf(_SC_THREAD_CPUTIME);
// sysconf() will return either -1L or _POSIX_VERSION
// (don't care about sysconf's exact return value)
useThreadCpuTime = sysconf(_SC_THREAD_CPUTIME) == -1L ? -1 : 0 ;
sUseThreadCpuTime.store(useThreadCpuTime); // might happen multiple times, but doesn't matter
}
if (useThreadCpuTime != -1)
clockId = CLOCK_THREAD_CPUTIME_ID;

View File

@ -0,0 +1,180 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <QCoreApplication>
#include <QLoggingCategory>
//![1]
QLoggingCategory theFooArea("foo");
QLoggingCategory theBarArea("bar");
QLoggingCategory theBazArea("baz");
//![1]
// Note: These locations are Ubuntu specific.
// Note: To make the example work with user permissions, make sure
// the files are user-writable and the path leading there accessible.
const char traceSwitch[] = "/sys/kernel/debug/tracing/tracing_on";
const char traceSink[] = "/sys/kernel/debug/tracing/trace_marker";
// The base class only serves as a facility to share code
// between the "single line" data logging aspect and the
// scoped "measuring" aspect.
// Both aspects and the base class could be combined into
// a single tracer serving both purposes, but are split
// here for clarity.
// Error handling is left as an exercise.
//![2]
class MyTracerBase : public QTracer
{
public:
MyTracerBase() {
enable = ::open(traceSwitch, O_WRONLY);
marker = ::open(traceSink, O_WRONLY);
}
~MyTracerBase() {
::close(enable);
::close(marker);
}
protected:
int enable;
int marker;
};
//![2]
//![2]
class MyTracer : public MyTracerBase
{
public:
void start() { ::write(marker, "B", 1); }
void end() { ::write(marker, "E", 1); }
};
//![2]
//![3]
class MyDataLogger : public MyTracerBase
{
public:
MyDataLogger() {
buf[0] = 0;
pos = 0;
}
void record(int i) { pos += sprintf(buf + pos, "%d", i); }
void record(const char *msg) { pos += sprintf(buf + pos, "%s", msg); }
void end() { ::write(marker, buf, pos); pos = 0; }
private:
char buf[100];
int pos;
};
//![3]
// Simplest possible example for "measuring".
//![4]
int foo(int i)
{
qCTraceGuard(theFooArea);
// Here could be some lengthy code.
return i * i;
}
//![4]
// We can switch on/off tracing dynamically.
// The tracer will be temporarily switched off at the third call
// and re-enabled at the eighth.
//![5]
int bar(int i)
{
static int n = 0;
++n;
if (n == 3)
theBarArea.setEnabled(QtTraceMsg, false);
if (n == 8)
theBarArea.setEnabled(QtTraceMsg, true);
qCTraceGuard(theBarArea);
return i * i;
}
//![5]
// An example to create "complex" log messages.
//![6]
int baz(int i)
{
qCTrace(theBazArea) << 32 << "some stuff";
return i * i;
}
//![6]
//![7]
namespace {
static struct Init
{
Init() {
tracer.addToCategory(theFooArea);
tracer.addToCategory(theBarArea);
logger.addToCategory(theBazArea);
}
MyTracer tracer;
MyDataLogger logger;
} initializer;
}
//![7]

View File

@ -0,0 +1,59 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
int foo(int i);
int bar(int i);
int baz(int i);
int main()
{
int s = 0;
for (int i = 0; i != 10; ++i)
s += foo(i);
for (int i = 0; i != 10; ++i)
s += bar(i);
for (int i = 0; i != 10; ++i)
s += baz(i);
return s;
}

View File

@ -0,0 +1,2 @@
SOURCES += ftracer.cpp main.cpp

View File

@ -46,26 +46,6 @@
\title ISO 8601
*/
/*!
\externalpage http://www.ietf.org/rfc/rfc3986.txt
\title RFC 3986
*/
/*!
\externalpage http://www.ietf.org/rfc/rfc1738.txt
\title RFC 1738
*/
/*!
\externalpage http://www.ietf.org/rfc/rfc3941.txt
\title RFC 3491
*/
/*!
\externalpage http://www.ietf.org/rfc/rfc2045.txt
\title RFC 2045
*/
/*!
\externalpage http://www.ietf.org/rfc/rfc4648.txt
\title RFC 4648

View File

@ -717,6 +717,10 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
A message generated by the qCritical() function.
\value QtFatalMsg
A message generated by the qFatal() function.
\value QtTraceMsg
Used by the qCTrace() macro. Trace events are usually passed only
to dedicated \a QTracer objects, and do not appear in the installed
message handler.
\value QtSystemMsg

View File

@ -814,6 +814,7 @@ Q_CORE_EXPORT QString qMessageFormatString(QtMsgType type, const QMessageLogCont
case QtWarningMsg: message.append(QLatin1String("warning")); break;
case QtCriticalMsg:message.append(QLatin1String("critical")); break;
case QtFatalMsg: message.append(QLatin1String("fatal")); break;
case QtTraceMsg: message.append(QLatin1String("trace")); break;
}
} else if (token == fileTokenC) {
if (context.file)

View File

@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
class QDebug;
class QNoDebug;
enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtSystemMsg = QtCriticalMsg };
enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtTraceMsg, QtSystemMsg = QtCriticalMsg };
class QMessageLogContext
{

View File

@ -511,7 +511,14 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea
if (slash) {
const QByteArray chunk = QFile::encodeName(dirName.left(slash));
if (QT_MKDIR(chunk.constData(), 0777) != 0) {
if (errno == EEXIST) {
if (errno == EEXIST
#if defined(Q_OS_QNX)
// On QNX the QNet (VFS paths of other hosts mounted under a directory
// such as /net) mountpoint returns ENOENT, despite existing. stat()
// on the QNet mountpoint returns successfully and reports S_IFDIR.
|| errno == ENOENT
#endif
) {
QT_STATBUF st;
if (QT_STAT(chunk.constData(), &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR)
continue;

View File

@ -107,7 +107,8 @@ QLoggingCategory::QLoggingCategory(const char *category)
: name(0),
enabledDebug(false),
enabledWarning(true),
enabledCritical(true)
enabledCritical(true),
enabledTrace(false)
{
bool isDefaultCategory
= (category == 0) || (strcmp(category, qtDefaultCategoryName) == 0);
@ -122,7 +123,8 @@ QLoggingCategory::QLoggingCategory(const char *category)
}
if (QLoggingRegistry *reg = QLoggingRegistry::instance())
reg->registerCategory(this);}
reg->registerCategory(this);
}
/*!
Destructs a QLoggingCategory object
@ -164,6 +166,7 @@ bool QLoggingCategory::isEnabled(QtMsgType msgtype) const
case QtDebugMsg: return enabledDebug;
case QtWarningMsg: return enabledWarning;
case QtCriticalMsg: return enabledCritical;
case QtTraceMsg: return enabledTrace;
case QtFatalMsg: return true;
default: break;
}
@ -177,6 +180,10 @@ bool QLoggingCategory::isEnabled(QtMsgType msgtype) const
change e.g. the settings of another objects for the same category name.
\note QtFatalMsg cannot be changed. It will always return true.
Example:
\snippet qtracer/ftracer.cpp 5
*/
void QLoggingCategory::setEnabled(QtMsgType type, bool enable)
{
@ -184,6 +191,7 @@ void QLoggingCategory::setEnabled(QtMsgType type, bool enable)
case QtDebugMsg: enabledDebug = enable; break;
case QtWarningMsg: enabledWarning = enable; break;
case QtCriticalMsg: enabledCritical = enable; break;
case QtTraceMsg: enabledTrace = enable; break;
case QtFatalMsg:
default: break;
}
@ -319,11 +327,60 @@ void QLoggingCategory::setFilterRules(const QString &rules)
\snippet qloggingcategory/main.cpp 12
\note Arguments are not processed if critical output for the category is not
enabled, so do not reply on any side effects.
enabled, so do not rely on any side effects.
\sa qCritical()
*/
/*!
\relates QLoggingCategory
\macro qCTrace(category)
\since 5.2
Returns an output stream for trace messages in the logging category
\a category.
The macro expands to code that first checks whether
\l QLoggingCategory::isEnabled() evaluates for trace output to \c{true}.
If so, the stream arguments are processed and sent to the tracers
registered with the category.
\note Arguments are not processed if trace output for the category is not
enabled, so do not rely on any side effects.
Example:
\snippet qtracer/ftracer.cpp 6
\sa qCTraceGuard()
*/
/*!
\relates QLoggingCategory
\macro qCTraceGuard(category)
\since 5.2
The macro expands to code that creates a guard object with automatic
storage. The guard constructor checks whether
\l QLoggingCategory::isEnabled() evaluates for trace output to \c{true}.
If so, the stream arguments are processed and the \c{start()}
functions of the tracers registered with the \a category are called.
The guard destructor also checks whether the category is enabled for
tracing and if so, the \c{end()}
functions of the tracers registered with the \a category are called.
\note Arguments are always processed, even if trace output for the
category is disabled. They will, however, in that case not be passed
to the \c{record()} functions of the registered tracers.
Example:
\snippet qtracer/ftracer.cpp 4
\sa qCTrace()
*/
/*!
\macro Q_DECLARE_LOGGING_CATEGORY(name)
\relates QLoggingCategory
@ -349,4 +406,234 @@ void QLoggingCategory::setFilterRules(const QString &rules)
This macro must be used outside of a class or method.
*/
/*!
\class QTracer
\inmodule QtCore
\since 5.2
\brief The QTracer class provides an interface for handling
trace events associated with a logging category.
\c QTracer objects are registered with logging categories.
Multiple \c QTracer objects
can be registered with the same category, and the same
\c QTracer object can be registered with different categories.
If code containing \c qCTrace is executed, and the associated
logging category is enabled for tracing, all \c QTracer objects
that are registered with the category are notified.
\c QTracer objects
*/
/*!
\fn QTracer::QTracer()
Constructs a tracer object.
Example:
\snippet qtracer/ftracer.cpp 2
*/
/*!
\fn QTracer::~QTracer()
Destroys the tracer object.
*/
/*!
Registers this tracer for the \a category.
The tracer will later be notified of messages of type
\c QtTraceMsg, as long as that message type
is enabled in the category.
Example:
\snippet qtracer/ftracer.cpp 1
\codeline
\snippet qtracer/ftracer.cpp 7
*/
void QTracer::addToCategory(QLoggingCategory &category)
{
category.tracers.append(this);
}
/*!
\fn void QTracer::start()
This function is invoked when a tracing activity starts,
typically from the constructor of a \c QTraceGuard object
defined by \c qCTrace() or \c qCTraceGuard().
The base implementation does nothing. \c QTracer subclasses
are advised to override it if needed.
\sa qCTrace(), qCTraceGuard()
*/
/*!
\fn void QTracer::end()
This function is invoked when a tracing activity ends,
typically from the destructor of a \c QTraceGuard object
defined by \c qCTrace() or \c qCTraceGuard().
The base implementation does nothing. It is common for
\c QTracer subclasses to override it to perform flushing
of collected data.
\sa qCTrace(), qCTraceGuard()
*/
/*!
\fn void QTracer::record(int data)
This function is invoked during a tracing activity to
pass integer \a data to the \c QTracer object.
Example:
\snippet qtracer/ftracer.cpp 3
*/
/*!
\fn void QTracer::record(const char *data)
This function is invoked during a tracing activity to
pass string \a data to the \c QTracer object.
*/
/*!
\fn void QTracer::record(const QVariant &data)
This function is invoked during a tracing activity to
pass abitrary (non-integer, non-string) \a data to
the \c QTracer object.
*/
/*!
\class QTraceGuard
\since 5.2
\inmodule QtCore
\brief The QTraceGuard class facilitates notifications to
\c QTracer objects.
\c QTraceGuard objects are typically implicitly created on the
stack when using the \c qCTrace or \c qCTraceGuard macros and
are associated to a \c QLoggingCategory.
The constructor of a \c QTraceGuard objects checks whether
its associated category is enabled, and if so, informs all
\c QTracer objects registered with the category that a
tracing activity starts.
The destructor of a \c QTraceGuard objects checks whether
its associated category is enabled, and if so, informs all
\c QTracer objects registered with the category that a
tracing activity ended.
A \c QTraceGuard object created by \c qCTrace will be destroyed
at the end of the full expression, a guard created by
\c qCTraceGuard at the end of the block containing the macro.
During the lifetime of a QTraceGuard object, its \c operator<<()
can be used to pass additional data to the active tracers.
The fast path handles only \c int and \c{const char *} data,
but it is possible to use arbitrary values wrapped in \c QVariants.
\sa QTracer
*/
/*!
\fn QTraceGuard::QTraceGuard(QLoggingCategory &category)
\internal
Constructs a trace guard object relaying to \a category.
*/
/*!
\fn QTraceGuard::~QTraceGuard()
\internal
Destroys the trace guard object.
*/
/*!
\internal
Calls \c start() on all registered tracers.
*/
void QTraceGuard::start()
{
QLoggingCategory::Tracers &tracers = target->tracers;
for (int i = tracers.size(); --i >= 0; )
tracers.at(i)->start();
}
/*!
\internal
Calls \c end() on all registered tracers.
*/
void QTraceGuard::end()
{
QLoggingCategory::Tracers &tracers = target->tracers;
for (int i = tracers.size(); --i >= 0; )
tracers.at(i)->end();
}
/*!
\internal
This function is called for int parameters passed to the
qCTrace stream.
*/
QTraceGuard &QTraceGuard::operator<<(int msg)
{
QLoggingCategory::Tracers &tracers = target->tracers;
for (int i = tracers.size(); --i >= 0; )
tracers.at(i)->record(msg);
return *this;
}
/*!
\internal
This function is called for string parameters passed to the
qCTrace stream.
*/
QTraceGuard &QTraceGuard::operator<<(const char *msg)
{
QLoggingCategory::Tracers &tracers = target->tracers;
for (int i = tracers.size(); --i >= 0; )
tracers.at(i)->record(msg);
return *this;
}
/*!
\internal
This function is called for QVariant parameters passed to the
qCTrace stream.
*/
QTraceGuard &QTraceGuard::operator<<(const QVariant &msg)
{
QLoggingCategory::Tracers &tracers = target->tracers;
for (int i = tracers.size(); --i >= 0; )
tracers.at(i)->record(msg);
return *this;
}
QT_END_NAMESPACE

View File

@ -44,9 +44,13 @@
#include <QtCore/qglobal.h>
#include <QtCore/qdebug.h>
#include <QtCore/qvector.h>
QT_BEGIN_NAMESPACE
class QTracer;
class QTraceGuard;
class Q_CORE_EXPORT QLoggingCategory
{
Q_DISABLE_COPY(QLoggingCategory)
@ -76,13 +80,18 @@ public:
static void setFilterRules(const QString &rules);
private:
friend class QLoggingRegistry;
friend class QTraceGuard;
friend class QTracer;
const char *name;
bool enabledDebug;
bool enabledWarning;
bool enabledCritical;
friend class QLoggingRegistry;
bool enabledTrace;
typedef QVector<QTracer *> Tracers;
Tracers tracers;
};
template <>
@ -103,6 +112,56 @@ inline bool QLoggingCategory::isEnabled<QtCriticalMsg>() const
return enabledCritical;
}
template <>
inline bool QLoggingCategory::isEnabled<QtTraceMsg>() const
{
return enabledTrace;
}
class Q_CORE_EXPORT QTracer
{
Q_DISABLE_COPY(QTracer)
public:
QTracer() {}
virtual ~QTracer() {}
void addToCategory(QLoggingCategory &category);
virtual void start() {}
virtual void end() {}
virtual void record(int) {}
virtual void record(const char *) {}
virtual void record(const QVariant &) {}
};
class Q_CORE_EXPORT QTraceGuard
{
Q_DISABLE_COPY(QTraceGuard)
public:
QTraceGuard(QLoggingCategory &category)
{
target = category.isEnabled<QtTraceMsg>() ? &category : 0;
if (target)
start();
}
~QTraceGuard()
{
if (target)
end();
}
QTraceGuard &operator<<(int msg);
QTraceGuard &operator<<(const char *msg);
QTraceGuard &operator<<(const QVariant &msg);
private:
void start();
void end();
QLoggingCategory *target;
};
#define Q_DECLARE_LOGGING_CATEGORY(name) \
extern QLoggingCategory &name();
@ -123,6 +182,17 @@ inline bool QLoggingCategory::isEnabled<QtCriticalMsg>() const
#define qCCritical(category) \
for (bool enabled = category().isEnabled<QtCriticalMsg>(); enabled; enabled = false) \
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).critical()
#define qCTrace(category) \
for (bool enabled = category.isEnabled<QtTraceMsg>(); enabled; enabled = false) \
QTraceGuard(category)
#define Q_TRACE_GUARD_NAME_HELPER(line) qTraceGuard ## line
#define Q_TRACE_GUARD_NAME(line) Q_TRACE_GUARD_NAME_HELPER(line)
#define qCTraceGuard(category) \
QTraceGuard Q_TRACE_GUARD_NAME(__LINE__)(category);
#if defined(QT_NO_DEBUG_OUTPUT)
# undef qCDebug

View File

@ -86,6 +86,9 @@ int QLoggingRule::pass(const QString &categoryName, QtMsgType msgType) const
case QtCriticalMsg:
fullCategory += QLatin1String(".critical");
break;
case QtTraceMsg:
fullCategory += QLatin1String(".trace");
break;
default:
break;
}
@ -288,6 +291,7 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat)
bool debug = (cat->categoryName() == qtDefaultCategoryName);
bool warning = true;
bool critical = true;
bool trace = true;
QString categoryName = QLatin1String(cat->categoryName());
QLoggingRegistry *reg = QLoggingRegistry::instance();
@ -301,11 +305,15 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat)
filterpass = item.pass(categoryName, QtCriticalMsg);
if (filterpass != 0)
critical = (filterpass > 0);
filterpass = item.pass(categoryName, QtTraceMsg);
if (filterpass != 0)
trace = (filterpass > 0);
}
cat->setEnabled(QtDebugMsg, debug);
cat->setEnabled(QtWarningMsg, warning);
cat->setEnabled(QtCriticalMsg, critical);
cat->setEnabled(QtTraceMsg, trace);
}

View File

@ -141,7 +141,8 @@ static void qt_sa_sigchld_sigaction(int signum, siginfo_t *info, void *context)
if (qt_sa_old_sigchld_handler.sa_flags & SA_SIGINFO) {
void (*oldAction)(int, siginfo_t *, void *) = vsa->sa_sigaction;
oldAction(signum, info, context);
if (oldAction)
oldAction(signum, info, context);
} else {
void (*oldAction)(int) = vsa->sa_handler;

View File

@ -61,6 +61,11 @@ struct NameprepCaseFoldingEntry {
ushort mapping[4];
};
#if defined(Q_CC_MSVC) && _MSC_VER < 1600
inline bool operator<(const NameprepCaseFoldingEntry &one, const NameprepCaseFoldingEntry &other)
{ return one.uc < other.uc; }
#endif
inline bool operator<(uint one, const NameprepCaseFoldingEntry &other)
{ return one < other.uc; }

View File

@ -150,15 +150,20 @@ QString QCoreApplicationPrivate::macMenuBarName()
#endif
QString QCoreApplicationPrivate::appName() const
{
static QString applName;
static QBasicMutex applicationNameMutex;
QMutexLocker locker(&applicationNameMutex);
if (applicationName.isNull()) {
#ifdef Q_OS_MAC
applName = macMenuBarName();
applicationName = macMenuBarName();
#endif
if (applName.isEmpty() && argv[0]) {
char *p = strrchr(argv[0], '/');
applName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
if (applicationName.isEmpty() && argv[0]) {
char *p = strrchr(argv[0], '/');
applicationName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
}
}
return applName;
return applicationName;
}
#endif

View File

@ -83,6 +83,7 @@ public:
~QCoreApplicationPrivate();
QString appName() const;
mutable QString applicationName;
#ifdef Q_OS_MAC
static QString macMenuBarName();

View File

@ -70,16 +70,24 @@ static jclass getCachedClass(JNIEnv *env, const char *className)
QString key = QLatin1String(className);
QHash<QString, jclass>::iterator it = cachedClasses->find(key);
if (it == cachedClasses->end()) {
jclass c = env->FindClass(className);
QJNIObjectPrivate classLoader = QtAndroidPrivate::classLoader();
if (!classLoader.isValid())
return 0;
QJNIObjectPrivate stringName = QJNIObjectPrivate::fromString(QLatin1String(className));
QJNIObjectPrivate classObject = classLoader.callObjectMethod("loadClass",
"(Ljava/lang/String;)Ljava/lang/Class;",
stringName.object());
if (env->ExceptionCheck()) {
c = 0;
#ifdef QT_DEBUG
env->ExceptionDescribe();
#endif // QT_DEBUG
env->ExceptionClear();
}
if (c)
clazz = static_cast<jclass>(env->NewGlobalRef(c));
if (classObject.isValid())
clazz = static_cast<jclass>(env->NewGlobalRef(classObject.object()));
cachedClasses->insert(key, clazz);
} else {
clazz = it.value();
@ -160,10 +168,12 @@ QJNIEnvironmentPrivate::QJNIEnvironmentPrivate()
: jniEnv(0)
{
JavaVM *vm = QtAndroidPrivate::javaVM();
if (vm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) != JNI_EDETACHED)
return;
if (vm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) == JNI_EDETACHED) {
if (vm->AttachCurrentThread(&jniEnv, 0) < 0)
return;
}
if (vm->AttachCurrentThread(&jniEnv, 0) < 0)
if (!jniEnv)
return;
if (!refCount->hasLocalData())

View File

@ -45,6 +45,7 @@ QT_BEGIN_NAMESPACE
static JavaVM *g_javaVM = Q_NULLPTR;
static jobject g_jActivity = Q_NULLPTR;
static jobject g_jClassLoader = Q_NULLPTR;
static inline bool exceptionCheck(JNIEnv *env)
{
@ -79,6 +80,20 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
if (exceptionCheck(env))
return JNI_ERR;
jmethodID classLoaderMethodID = env->GetStaticMethodID(jQtNative,
"classLoader",
"()Ljava/lang/ClassLoader;");
if (exceptionCheck(env))
return JNI_ERR;
jobject classLoader = env->CallStaticObjectMethod(jQtNative, classLoaderMethodID);
if (exceptionCheck(env))
return JNI_ERR;
g_jClassLoader = env->NewGlobalRef(classLoader);
g_jActivity = env->NewGlobalRef(activity);
g_javaVM = vm;
@ -96,4 +111,9 @@ JavaVM *QtAndroidPrivate::javaVM()
return g_javaVM;
}
jobject QtAndroidPrivate::classLoader()
{
return g_jClassLoader;
}
QT_END_NAMESPACE

View File

@ -63,6 +63,7 @@ namespace QtAndroidPrivate
Q_CORE_EXPORT jobject activity();
Q_CORE_EXPORT JavaVM *javaVM();
Q_CORE_EXPORT jint initJNI(JavaVM *vm, JNIEnv *env);
jobject classLoader();
}
QT_END_NAMESPACE

View File

@ -91,7 +91,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment,
// Allocate additional space if array is growing
if (options & Grow)
capacity = qAllocMore(objectSize * capacity, headerSize) / int(objectSize);
capacity = qAllocMore(int(objectSize * capacity), int(headerSize)) / int(objectSize);
size_t allocSize = headerSize + objectSize * capacity;

View File

@ -166,6 +166,11 @@ static QString macTimeToString(const QTime &time, bool short_format)
return QCFString(CFDateFormatterCreateStringWithDate(0, myFormatter, myDate));
}
// Mac uses the Unicode CLDR format codes
// http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
// See also qtbase/util/local_database/dateconverter.py
// Makes the assumption that input formats are always well formed and consecutive letters
// never exceed the maximum for the format code.
static QString macToQtFormat(const QString &sys_fmt)
{
QString result;
@ -185,55 +190,97 @@ static QString macToQtFormat(const QString &sys_fmt)
int repeat = qt_repeatCount(sys_fmt, i);
switch (c.unicode()) {
case 'G': // Qt doesn't support these :(
case 'Y':
case 'D':
case 'F':
case 'w':
case 'W':
case 'g':
// Qt does not support the following options
case 'G': // Era (1..5): 4 = long, 1..3 = short, 5 = narrow
case 'Y': // Year of Week (1..n): 1..n = padded number
case 'U': // Cyclic Yar Name (1..5): 4 = long, 1..3 = short, 5 = narrow
case 'Q': // Quarter (1..4): 4 = long, 3 = short, 1..2 = padded number
case 'q': // Standalone Quarter (1..4): 4 = long, 3 = short, 1..2 = padded number
case 'w': // Week of Year (1..2): 1..2 = padded number
case 'W': // Week of Month (1): 1 = number
case 'D': // Day of Year (1..3): 1..3 = padded number
case 'F': // Day of Week in Month (1): 1 = number
case 'g': // Modified Julian Day (1..n): 1..n = padded number
case 'A': // Milliseconds in Day (1..n): 1..n = padded number
break;
case 'u': // extended year - use 'y'
if (repeat < 4)
case 'y': // Year (1..n): 2 = short year, 1 & 3..n = padded number
case 'u': // Extended Year (1..n): 2 = short year, 1 & 3..n = padded number
// Qt only supports long (4) or short (2) year, use long for all others
if (repeat == 2)
result += QLatin1String("yy");
else
result += QLatin1String("yyyy");
break;
case 'S': // fractional second
case 'M': // Month (1..5): 4 = long, 3 = short, 1..2 = number, 5 = narrow
case 'L': // Standalone Month (1..5): 4 = long, 3 = short, 1..2 = number, 5 = narrow
// Qt only supports long, short and number, use short for narrow
if (repeat == 5)
result += QLatin1String("MMM");
else
result += QString(repeat, QLatin1Char('M'));
break;
case 'd': // Day of Month (1..2): 1..2 padded number
result += QString(repeat, c);
break;
case 'E': // Day of Week (1..6): 4 = long, 1..3 = short, 5..6 = narrow
// Qt only supports long, short and padded number, use short for narrow
if (repeat == 4)
result += QLatin1String("dddd");
else
result += QLatin1String("ddd");
break;
case 'e': // Local Day of Week (1..6): 4 = long, 3 = short, 5..6 = narrow, 1..2 padded number
case 'c': // Standalone Local Day of Week (1..6): 4 = long, 3 = short, 5..6 = narrow, 1..2 padded number
// Qt only supports long, short and padded number, use short for narrow
if (repeat >= 5)
result += QLatin1String("ddd");
else
result += QString(repeat, QLatin1Char('d'));
break;
case 'a': // AM/PM (1): 1 = short
// Translate to Qt uppercase AM/PM
result += QLatin1String("AP");
break;
case 'h': // Hour [1..12] (1..2): 1..2 = padded number
case 'K': // Hour [0..11] (1..2): 1..2 = padded number
case 'j': // Local Hour [12 or 24] (1..2): 1..2 = padded number
// Qt h is local hour
result += QString(repeat, QLatin1Char('h'));
break;
case 'H': // Hour [0..23] (1..2): 1..2 = padded number
case 'k': // Hour [1..24] (1..2): 1..2 = padded number
// Qt H is 0..23 hour
result += QString(repeat, QLatin1Char('H'));
break;
case 'm': // Minutes (1..2): 1..2 = padded number
case 's': // Seconds (1..2): 1..2 = padded number
result += QString(repeat, c);
break;
case 'S': // Fractional second (1..n): 1..n = tuncates to decimal places
// Qt uses msecs either unpadded or padded to 3 places
if (repeat < 3)
result += QLatin1Char('z');
else
result += QLatin1String("zzz");
break;
case 'E':
if (repeat <= 3)
result += QLatin1String("ddd");
else
result += QLatin1String("dddd");
break;
case 'e':
if (repeat >= 2)
result += QLatin1String("dd");
else
result += QLatin1Char('d');
break;
case 'a':
result += QLatin1String("AP");
break;
case 'k':
result += QString(repeat, QLatin1Char('H'));
break;
case 'K':
result += QString(repeat, QLatin1Char('h'));
break;
case 'z':
case 'Z':
case 'v':
case 'z': // Time Zone (1..4)
case 'Z': // Time Zone (1..5)
case 'O': // Time Zone (1, 4)
case 'v': // Time Zone (1, 4)
case 'V': // Time Zone (1..4)
case 'X': // Time Zone (1..5)
case 'x': // Time Zone (1..5)
result += QLatin1Char('t');
break;
default:
result += QString(repeat, c);
// a..z and A..Z are reserved for format codes, so any occurrence of these not
// already processed are not known and so unsupported formats to be ignored.
// All other chars are allowed as literals.
if (c < QLatin1Char('A') || c > QLatin1Char('z') ||
(c > QLatin1Char('Z') && c < QLatin1Char('a'))) {
result += QString(repeat, c);
}
break;
}

View File

@ -3895,7 +3895,7 @@ static inline __m128i mergeQuestionMarks(__m128i chunk)
# else
// SSE has no compare instruction for unsigned comparison.
// The variables must be shiffted + 0x8000 to be compared
const __m128i signedBitOffset = _mm_set1_epi16(0x8000);
const __m128i signedBitOffset = _mm_set1_epi16(short(0x8000));
const __m128i thresholdMask = _mm_set1_epi16(short(0xff + 0x8000));
const __m128i signedChunk = _mm_add_epi16(chunk, signedBitOffset);

View File

@ -934,8 +934,8 @@ inline QString::~QString() { if (!d->ref.deref()) Data::deallocate(d); }
inline void QString::reserve(int asize)
{
if (d->ref.isShared() || uint(asize) + 1u > d->alloc)
reallocData(uint(asize) + 1u);
if (d->ref.isShared() || uint(asize) >= d->alloc)
reallocData(qMax(asize, d->size) + 1u);
if (!d->capacityReserved) {
// cannot set unconditionally, since d could be the shared_null/shared_empty (which is const)

View File

@ -618,7 +618,7 @@ void QTzTimeZonePrivate::init(const QByteArray &olsenId)
// Offsets are stored as total offset, want to know separate UTC and DST offsets
// so find the first non-dst transition to use as base UTC Offset
int utcOffset;
int utcOffset = 0;
foreach (const QTzTransition &tran, tranList) {
if (!typeList.at(tran.tz_typeind).tz_isdst) {
utcOffset = typeList.at(tran.tz_typeind).tz_gmtoff;

View File

@ -65,10 +65,10 @@ Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3(quint32 *dst, con
}
// Mask the 4 first colors of the RGB888 vector
const __m128i shuffleMask = _mm_set_epi8(0xff, 9, 10, 11, 0xff, 6, 7, 8, 0xff, 3, 4, 5, 0xff, 0, 1, 2);
const __m128i shuffleMask = _mm_set_epi8(char(0xff), 9, 10, 11, char(0xff), 6, 7, 8, char(0xff), 3, 4, 5, char(0xff), 0, 1, 2);
// Mask the 4 last colors of a RGB888 vector with an offset of 1 (so the last 3 bytes are RGB)
const __m128i shuffleMaskEnd = _mm_set_epi8(0xff, 13, 14, 15, 0xff, 10, 11, 12, 0xff, 7, 8, 9, 0xff, 4, 5, 6);
const __m128i shuffleMaskEnd = _mm_set_epi8(char(0xff), 13, 14, 15, char(0xff), 10, 11, 12, char(0xff), 7, 8, 9, char(0xff), 4, 5, 6);
// Mask to have alpha = 0xff
const __m128i alphaMask = _mm_set1_epi32(0xff000000);

View File

@ -742,6 +742,11 @@ static const struct XPMRGBData {
{ QRGB(139,139, 0), "yellow4" },
{ QRGB(154,205, 50), "yellowgreen" } };
#if defined(Q_CC_MSVC) && _MSC_VER < 1600
inline bool operator<(const XPMRGBData &data1, const XPMRGBData &data2)
{ return qstrcmp(data1.name, data2.name) < 0; }
#endif
inline bool operator<(const char *name, const XPMRGBData &data)
{ return qstrcmp(name, data.name) < 0; }
inline bool operator<(const XPMRGBData &data, const char *name)

View File

@ -89,12 +89,6 @@
#include <QDebug>
// ####TODO Properly #ifdef this class to use #define symbols actually defined
// by OpenGL/ES includes
#ifndef GL_FRAMEBUFFER_SRGB
#define GL_FRAMEBUFFER_SRGB 0x8DB9
#endif
QT_BEGIN_NAMESPACE
@ -1860,25 +1854,12 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
}
}
bool srgbFrameBufferEnabled = false;
if (funcs.hasOpenGLExtension(QOpenGLExtensions::SRGBFrameBuffer)) {
if (false)
{
glEnable(GL_FRAMEBUFFER_SRGB);
srgbFrameBufferEnabled = true;
}
}
#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#else
glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data());
#endif
if (srgbFrameBufferEnabled)
glDisable(GL_FRAMEBUFFER_SRGB);
}
void QOpenGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,

View File

@ -289,6 +289,11 @@ static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData);
#undef rgb
#if defined(Q_CC_MSVC) && _MSC_VER < 1600
inline bool operator<(const RGBData &data1, const RGBData &data2)
{ return qstrcmp(data1.name, data2.name) < 0; }
#endif
inline bool operator<(const char *name, const RGBData &data)
{ return qstrcmp(name, data.name) < 0; }
inline bool operator<(const RGBData &data, const char *name)

View File

@ -103,7 +103,7 @@ inline static void blend_pixel(quint32 &dst, const quint32 src)
if (!minusOffsetToAlignSrcOn16Bytes) {\
/* src is aligned, usual algorithm but with aligned operations.\
See the SSE2 version for more documentation on the algorithm itself. */\
const __m128i alphaShuffleMask = _mm_set_epi8(0xff,15,0xff,15,0xff,11,0xff,11,0xff,7,0xff,7,0xff,3,0xff,3);\
const __m128i alphaShuffleMask = _mm_set_epi8(char(0xff),15,char(0xff),15,char(0xff),11,char(0xff),11,char(0xff),7,char(0xff),7,char(0xff),3,char(0xff),3);\
for (; x < length-3; x += 4) { \
const __m128i srcVector = _mm_load_si128((__m128i *)&src[x]); \
const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask); \
@ -124,7 +124,7 @@ inline static void blend_pixel(quint32 &dst, const quint32 src)
__m128i srcVectorPrevLoaded = _mm_load_si128((__m128i *)&src[x - minusOffsetToAlignSrcOn16Bytes]);\
const int palignrOffset = minusOffsetToAlignSrcOn16Bytes << 2;\
\
const __m128i alphaShuffleMask = _mm_set_epi8(0xff,15,0xff,15,0xff,11,0xff,11,0xff,7,0xff,7,0xff,3,0xff,3);\
const __m128i alphaShuffleMask = _mm_set_epi8(char(0xff),15,char(0xff),15,char(0xff),11,char(0xff),11,char(0xff),7,char(0xff),7,char(0xff),3,char(0xff),3);\
switch (palignrOffset) {\
case 4:\
BLENDING_LOOP(4, length)\

View File

@ -347,6 +347,13 @@ static const QCssKnownValue styleFeatures[NumKnownStyleFeatures - 1] = {
{ "none", StyleFeature_None }
};
#if defined(Q_CC_MSVC) && _MSC_VER < 1600
Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCssKnownValue &prop1, const QCssKnownValue &prop2)
{
return QString::compare(QString::fromLatin1(prop1.name), QLatin1String(prop2.name), Qt::CaseInsensitive) < 0;
}
#endif
Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &name, const QCssKnownValue &prop)
{
return QString::compare(name, QLatin1String(prop.name), Qt::CaseInsensitive) < 0;

View File

@ -125,6 +125,11 @@ struct AGLEntry {
unsigned short index;
};
#if defined(Q_CC_MSVC) && _MSC_VER < 1600
inline bool operator<(AGLEntry entry1, AGLEntry entry2)
{ return entry1.uc < entry2.uc; }
#endif
inline bool operator<(unsigned short uc, AGLEntry entry)
{ return uc < entry.uc; }
inline bool operator<(AGLEntry entry, unsigned short uc)

View File

@ -324,6 +324,13 @@ static const struct QTextHtmlEntity { const char *name; quint16 code; } entities
{ "zwnj", 0x200c }
};
#if defined(Q_CC_MSVC) && _MSC_VER < 1600
bool operator<(const QTextHtmlEntity &entity1, const QTextHtmlEntity &entity2)
{
return QLatin1String(entity1.name) < QLatin1String(entity2.name);
}
#endif
Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &entityStr, const QTextHtmlEntity &entity)
{
return entityStr < QLatin1String(entity.name);
@ -443,6 +450,12 @@ static const QTextHtmlElement elements[Html_NumElements]= {
{ "var", Html_var, QTextHtmlElement::DisplayInline },
};
#if defined(Q_CC_MSVC) && _MSC_VER < 1600
Q_STATIC_GLOBAL_OPERATOR bool operator<(const QTextHtmlElement &e1, const QTextHtmlElement &e2)
{
return QLatin1String(e1.name) < QLatin1String(e2.name);
}
#endif
Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &str, const QTextHtmlElement &e)
{

View File

@ -86,12 +86,6 @@
#include <QDebug>
// ####TODO Properly #ifdef this class to use #define symbols actually defined
// by OpenGL/ES includes
#ifndef GL_FRAMEBUFFER_SRGB
#define GL_FRAMEBUFFER_SRGB 0x8DB9
#endif
QT_BEGIN_NAMESPACE
@ -1868,18 +1862,12 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
}
}
bool srgbFrameBufferEnabled = false;
#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#else
glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data());
#endif
if (srgbFrameBufferEnabled)
glDisable(GL_FRAMEBUFFER_SRGB);
}
void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,

View File

@ -254,16 +254,25 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
input_absinfo absInfo;
memset(&absInfo, 0, sizeof(input_absinfo));
if (ioctl(m_fd, EVIOCGABS(d->m_singleTouch ? ABS_X : ABS_MT_POSITION_X), &absInfo) >= 0) {
bool has_x_range = false, has_y_range = false;
if (ioctl(m_fd, EVIOCGABS((d->m_singleTouch ? ABS_X : ABS_MT_POSITION_X)), &absInfo) >= 0) {
qDebug("min X: %d max X: %d", absInfo.minimum, absInfo.maximum);
d->hw_range_x_min = absInfo.minimum;
d->hw_range_x_max = absInfo.maximum;
has_x_range = true;
}
if (ioctl(m_fd, EVIOCGABS(d->m_singleTouch ? ABS_Y : ABS_MT_POSITION_Y), &absInfo) >= 0) {
if (ioctl(m_fd, EVIOCGABS((d->m_singleTouch ? ABS_Y : ABS_MT_POSITION_Y)), &absInfo) >= 0) {
qDebug("min Y: %d max Y: %d", absInfo.minimum, absInfo.maximum);
d->hw_range_y_min = absInfo.minimum;
d->hw_range_y_max = absInfo.maximum;
has_y_range = true;
}
if (!has_x_range || !has_y_range)
qWarning("evdevtouch: Invalid ABS limits, behavior unspecified");
if (ioctl(m_fd, EVIOCGABS(ABS_PRESSURE), &absInfo) >= 0) {
qDebug("min pressure: %d max pressure: %d", absInfo.minimum, absInfo.maximum);
if (absInfo.maximum > absInfo.minimum) {
@ -271,6 +280,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
d->hw_pressure_max = absInfo.maximum;
}
}
char name[1024];
if (ioctl(m_fd, EVIOCGNAME(sizeof(name) - 1), name) >= 0) {
d->hw_name = QString::fromLocal8Bit(name);
@ -452,9 +462,6 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data)
}
addTouchPoint(contact, &combinedStates);
if (contact.state == Qt::TouchPointReleased)
it.remove();
}
// Now look for contacts that have disappeared since the last sync.
@ -469,6 +476,15 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data)
}
}
// Remove contacts that have just been reported as released.
it = m_contacts;
while (it.hasNext()) {
it.next();
Contact &contact(it.value());
if (contact.state == Qt::TouchPointReleased)
it.remove();
}
m_lastContacts = m_contacts;
if (!m_typeB && !m_singleTouch)
m_contacts.clear();

View File

@ -455,7 +455,7 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para
env->ReleaseStringUTFChars(environmentString, nativeString);
m_applicationParams=string.split('\t');
foreach (string, m_applicationParams) {
if (putenv(string.constData()))
if (!string.isEmpty() && putenv(string.constData()))
qWarning() << "Can't set environment" << string;
}

View File

@ -210,9 +210,10 @@ static void cleanupCocoaApplicationDelegate()
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
// The reflection delegate gets precedence
if (reflectionDelegate
&& [reflectionDelegate respondsToSelector:@selector(applicationShouldTerminate:)]) {
return [reflectionDelegate applicationShouldTerminate:sender];
if (reflectionDelegate) {
if ([reflectionDelegate respondsToSelector:@selector(applicationShouldTerminate:)])
return [reflectionDelegate applicationShouldTerminate:sender];
return NSTerminateNow;
}
if ([self canQuit]) {
@ -327,12 +328,11 @@ static void cleanupCocoaApplicationDelegate()
- (void)applicationDidBecomeActive:(NSNotification *)notification
{
Q_UNUSED(notification);
/*
if (reflectionDelegate
&& [reflectionDelegate respondsToSelector:@selector(applicationDidBecomeActive:)])
[reflectionDelegate applicationDidBecomeActive:notification];
/*
onApplicationChangedActivation(true);
if (!QWidget::mouseGrabber()){
@ -351,12 +351,11 @@ static void cleanupCocoaApplicationDelegate()
- (void)applicationDidResignActive:(NSNotification *)notification
{
Q_UNUSED(notification);
/*
if (reflectionDelegate
&& [reflectionDelegate respondsToSelector:@selector(applicationDidResignActive:)])
[reflectionDelegate applicationDidResignActive:notification];
/*
onApplicationChangedActivation(false);
if (!QWidget::mouseGrabber())

View File

@ -77,6 +77,8 @@ QPaintDevice *QCocoaBackingStore::paintDevice()
? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
m_qImage = QImage(m_requestedSize * scaleFactor, format);
m_qImage.setDevicePixelRatio(scaleFactor);
if (format == QImage::Format_ARGB32_Premultiplied)
m_qImage.fill(Qt::transparent);
}
return &m_qImage;
}

View File

@ -165,6 +165,7 @@ public:
bool currentExecIsNSAppRun;
bool nsAppRunCalledByQt;
bool cleanupModalSessionsNeeded;
uint processEventsCalled;
NSModalSession currentModalSessionCached;
NSModalSession currentModalSession();
void updateChildrenWorksWhenModal();

View File

@ -118,7 +118,7 @@ static Boolean runLoopSourceEqualCallback(const void *info1, const void *info2)
void QCocoaEventDispatcherPrivate::runLoopTimerCallback(CFRunLoopTimerRef, void *info)
{
QCocoaEventDispatcherPrivate *d = static_cast<QCocoaEventDispatcherPrivate *>(info);
if ((d->processEventsFlags & QEventLoop::EventLoopExec) == 0) {
if (d->processEventsCalled && (d->processEventsFlags & QEventLoop::EventLoopExec) == 0) {
// processEvents() was called "manually," ignore this source for now
d->maybeCancelWaitForMoreEvents();
return;
@ -364,6 +364,12 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
uint oldflags = d->processEventsFlags;
d->processEventsFlags = flags;
// Used to determine whether any eventloop has been exec'ed, and allow posted
// and timer events to be processed even if this function has never been called
// instead of being kept on hold for the next run of processEvents().
++d->processEventsCalled;
bool excludeUserEvents = d->processEventsFlags & QEventLoop::ExcludeUserInputEvents;
bool retVal = false;
forever {
@ -517,6 +523,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
}
d->processEventsFlags = oldflags;
--d->processEventsCalled;
// If we're interrupted, we need to interrupt the _current_
// recursion as well to check if it is still supposed to be
@ -770,6 +777,7 @@ QCocoaEventDispatcherPrivate::QCocoaEventDispatcherPrivate()
currentExecIsNSAppRun(false),
nsAppRunCalledByQt(false),
cleanupModalSessionsNeeded(false),
processEventsCalled(0),
currentModalSessionCached(0),
lastSerial(-1),
interrupt(false)
@ -893,7 +901,7 @@ void QCocoaEventDispatcherPrivate::firstLoopEntry(CFRunLoopObserverRef ref,
void QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void *info)
{
QCocoaEventDispatcherPrivate *d = static_cast<QCocoaEventDispatcherPrivate *>(info);
if ((d->processEventsFlags & QEventLoop::EventLoopExec) == 0) {
if (d->processEventsCalled && (d->processEventsFlags & QEventLoop::EventLoopExec) == 0) {
// processEvents() was called "manually," ignore this source for now
d->maybeCancelWaitForMoreEvents();
return;

View File

@ -45,6 +45,7 @@
#include <ApplicationServices/ApplicationServices.h>
#include <qpa/qplatformnativeinterface.h>
#include <QtGui/qpixmap.h>
QT_BEGIN_NAMESPACE
@ -91,6 +92,11 @@ private:
Needed by the native print dialog in the Qt Print Support module.
*/
Q_INVOKABLE void *NSPrintInfoForPrintEngine(QPrintEngine *printEngine);
/*
Function to return the default background pixmap.
Needed by QWizard in the Qt widget module.
*/
Q_INVOKABLE QPixmap defaultBackgroundPixmapForQWizard();
// QMacPastebardMime support. The mac pasteboard void pointers are
// QMacPastebardMime instances from the cocoa plugin or qtmacextras

View File

@ -50,6 +50,7 @@
#include <qbytearray.h>
#include <qwindow.h>
#include <qpixmap.h>
#include <qpa/qplatformwindow.h>
#include "qsurfaceformat.h"
#include <qpa/qplatformopenglcontext.h>
@ -133,7 +134,7 @@ void QCocoaNativeInterface::beep()
QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport()
{
#ifndef QT_NO_WIDGETS
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
return new QCocoaPrinterSupport();
#else
qFatal("Printing is not supported when Qt is configured with -no-widgets");
@ -143,7 +144,7 @@ QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport()
void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine)
{
#ifndef QT_NO_WIDGETS
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER)
QMacPrintEnginePrivate *macPrintEnginePriv = static_cast<QMacPrintEngine *>(printEngine)->d_func();
if (macPrintEnginePriv->state == QPrinter::Idle && !macPrintEnginePriv->isPrintSessionInitialized())
macPrintEnginePriv->initialize();
@ -154,6 +155,31 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine
#endif
}
QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard()
{
QCFType<CFURLRef> url;
const int ExpectedImageWidth = 242;
const int ExpectedImageHeight = 414;
if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"),
0, 0, &url) == noErr) {
QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url);
if (bundle) {
url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0);
if (url) {
QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0);
QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0);
if (image) {
int width = CGImageGetWidth(image);
int height = CGImageGetHeight(image);
if (width == ExpectedImageWidth && height == ExpectedImageHeight)
return QPixmap::fromImage(qt_mac_toQImage(image));
}
}
}
}
return QPixmap();
}
void QCocoaNativeInterface::onAppFocusWindowChanged(QWindow *window)
{
Q_UNUSED(window);

View File

@ -43,6 +43,7 @@
#define QCOCOAPRINTERSUPPORT_H
#include <qpa/qplatformprintersupport.h>
#ifndef QT_NO_PRINTER
#include "qt_mac_p.h"
@ -64,4 +65,5 @@ private:
QPrinterInfo printerInfoFromPMPrinter(const PMPrinter &printer);
};
#endif // QT_NO_PRINTER
#endif // QCOCOAPRINTERSUPPORT_H

View File

@ -40,6 +40,8 @@
****************************************************************************/
#include "qcocoaprintersupport.h"
#ifndef QT_NO_PRINTER
#include "qprintengine_mac_p.h"
#include <QtPrintSupport/QPrinter>
@ -169,3 +171,5 @@ QList<QPair<QString, QSizeF> > QCocoaPrinterSupport::supportedSizesWithNames(con
PMRelease(printer);
return returnValue;
}
#endif //QT_NO_PRINTER

View File

@ -204,9 +204,9 @@ static QTouchDevice *touchDevice = 0;
selector:@selector(windowNotification:)
name:nil // Get all notifications
object:newWindow];
} else {
[[NSNotificationCenter defaultCenter] removeObserver:self name:nil object:[self window]];
}
if ([self window])
[[NSNotificationCenter defaultCenter] removeObserver:self name:nil object:[self window]];
}
- (void)updateGeometry
{

View File

@ -117,8 +117,10 @@ static void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransfor
QMacCGContext::QMacCGContext(QPainter *p)
{
QPaintEngine *pe = p->paintEngine();
#ifndef QT_NO_PRINTER
if (pe->type() == QPaintEngine::MacPrinter)
pe = static_cast<QMacPrintEngine*>(pe)->paintEngine();
#endif
pe->syncState();
context = 0;
if (pe->type() == QPaintEngine::CoreGraphics)

View File

@ -168,11 +168,13 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
return translateMouseWheelEvent(window, hwnd, msg, result);
#ifndef Q_OS_WINCE
// Check for events synthesized from touch. Lower byte is touch index, 0 means pen.
static const bool passSynthesizedMouseEvents = QWindowsIntegration::instance()->options() & QWindowsIntegration::PassOsMouseEventsSynthesizedFromTouch;
if (!passSynthesizedMouseEvents) {
// Check for events synthesized from touch. Lower 7 bits are touch/pen index, bit 8 indicates touch.
// However, when tablet support is active, extraInfo is a packet serial number. This is not a problem
// since we do not want to ignore mouse events coming from a tablet.
const quint64 extraInfo = GetMessageExtraInfo();
const bool fromTouch = (extraInfo & signatureMask) == miWpSignature && (extraInfo & 0xff);
const bool fromTouch = (extraInfo & signatureMask) == miWpSignature && (extraInfo & 0x80);
if (fromTouch)
return false;
}

View File

@ -39,11 +39,12 @@
**
****************************************************************************/
#ifndef QT_NO_PRINTDIALOG
#include <Cocoa/Cocoa.h>
#include "qpagesetupdialog.h"
#ifndef QT_NO_PRINTDIALOG
#include "qpagesetupdialog_p.h"
#include <qpa/qplatformnativeinterface.h>

View File

@ -39,8 +39,6 @@
**
****************************************************************************/
#ifndef QT_NO_PRINTDIALOG
#include <Cocoa/Cocoa.h>
#include "qprintdialog.h"
@ -52,6 +50,8 @@
#include <QtPrintSupport/qprinter.h>
#include <QtPrintSupport/qprintengine.h>
#ifndef QT_NO_PRINTDIALOG
QT_BEGIN_NAMESPACE
class QPrintDialogPrivate : public QAbstractPrintDialogPrivate

View File

@ -1,31 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\externalpage http://www.cups.org/
\title Common Unix Printing System (CUPS)
*/

View File

@ -32,7 +32,3 @@
\externalpage http://blog.qt.digia.com/blog/2008/12/05/qtestlib-now-with-nice-graphs-pointing-upwards/
\title qtestlib-tools Announcement
*/
/*!
\externalpage http://qt.gitorious.org/qt-labs/qtestlib-tools
\title qtestlib-tools
*/

View File

@ -211,7 +211,7 @@ void QPlainTestLogger::outputMessage(const char *str)
#elif defined(Q_OS_WIN)
OutputDebugStringA(str);
#elif defined(Q_OS_ANDROID)
__android_log_print(ANDROID_LOG_INFO, "QTestLib", str);
__android_log_write(ANDROID_LOG_INFO, "QTestLib", str);
#endif
outputString(str);
}

View File

@ -1612,7 +1612,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
}
}
bool installedTestCoverage = installCoverageTool(QTestResult::currentAppname(), QTestResult::currentTestObjectName());
bool installedTestCoverage = installCoverageTool(QTestResult::currentAppName(), QTestResult::currentTestObjectName());
QTestLog::setInstalledTestCoverage(installedTestCoverage);
// If no loggers were created by the long version of the -o command-line
@ -2167,7 +2167,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
QTestResult::setCurrentTestObject(metaObject->className());
if (argc > 0)
QTestResult::setCurrentAppname(argv[0]);
QTestResult::setCurrentAppName(argv[0]);
qtest_qParseArgs(argc, argv, false);
@ -2520,6 +2520,14 @@ QTestData &QTest::newRow(const char *dataTag)
\sa QTest::newRow(), QFETCH(), QMetaType
*/
/*!
Returns the name of the binary that is currently executed.
*/
const char *QTest::currentAppName()
{
return QTestResult::currentAppName();
}
/*!
Returns the name of the test function that is currently executed.

View File

@ -200,6 +200,8 @@ namespace QTest
Q_TESTLIB_EXPORT void *qElementData(const char *elementName, int metaTypeId);
Q_TESTLIB_EXPORT QObject *testObject();
Q_TESTLIB_EXPORT const char *currentAppName();
Q_TESTLIB_EXPORT const char *currentTestFunction();
Q_TESTLIB_EXPORT const char *currentDataTag();
Q_TESTLIB_EXPORT bool currentTestFailed();

View File

@ -257,6 +257,7 @@ namespace QTest {
}
switch (type) {
case QtTraceMsg:
case QtDebugMsg:
QTest::TestLoggers::addMessage(QAbstractTestLogger::QDebug, msg);
break;
@ -393,7 +394,7 @@ void QTestLog::stopLogging()
QTest::TestLoggers::stopLogging();
QTest::TestLoggers::destroyLoggers();
QTest::loggerUsingStdout = false;
saveCoverageTool(QTestResult::currentAppname(), failCount() != 0, QTestLog::installedTestCoverage());
saveCoverageTool(QTestResult::currentAppName(), failCount() != 0, QTestLog::installedTestCoverage());
}
void QTestLog::addLogger(LogMode mode, const char *filename)

View File

@ -63,7 +63,7 @@ namespace QTest
static const char *expectFailComment = 0;
static int expectFailMode = 0;
static const char *currentAppname = 0;
static const char *currentAppName = 0;
}
void QTestResult::reset()
@ -318,14 +318,14 @@ bool QTestResult::skipCurrentTest()
return QTest::skipCurrentTest;
}
void QTestResult::setCurrentAppname(const char *appname)
void QTestResult::setCurrentAppName(const char *appName)
{
QTest::currentAppname = appname;
QTest::currentAppName = appName;
}
const char *QTestResult::currentAppname()
const char *QTestResult::currentAppName()
{
return QTest::currentAppname;
return QTest::currentAppName;
}
QT_END_NAMESPACE

View File

@ -93,8 +93,8 @@ public:
static void setSkipCurrentTest(bool value);
static bool skipCurrentTest();
static void setCurrentAppname(const char *appname);
static const char *currentAppname();
static void setCurrentAppName(const char *appName);
static const char *currentAppName();
private:
Q_DISABLE_COPY(QTestResult)

View File

@ -40,7 +40,6 @@
****************************************************************************/
#include <rcc.h>
#include "../../corelib/kernel/qcorecmdlineargs_p.h"
#include <qdebug.h>
#include <qdir.h>

View File

@ -4,7 +4,6 @@ CONFIG += force_bootstrap
DEFINES += QT_RCC QT_NO_CAST_FROM_ASCII
include(rcc.pri)
HEADERS += ../../corelib/kernel/qcorecmdlineargs_p.h
SOURCES += main.cpp
load(qt_tool)

View File

@ -59,9 +59,10 @@
#include "qset.h"
#include "qstyle.h"
#include "qvarlengtharray.h"
#if defined(Q_WS_MAC)
#include "private/qt_mac_p.h"
#include "qlibrary.h"
#if defined(Q_OS_MACX)
#include <QtCore/QMetaMethod>
#include <QtGui/QGuiApplication>
#include <qpa/qplatformnativeinterface.h>
#elif !defined(QT_NO_STYLE_WINDOWSVISTA)
#include "qwizard_win_p.h"
#include "qtimer.h"
@ -604,7 +605,7 @@ public:
void _q_updateButtonStates();
void _q_handleFieldObjectDestroyed(QObject *);
void setStyle(QStyle *style);
#ifdef Q_WS_MAC
#ifdef Q_OS_MACX
static QPixmap findDefaultBackgroundPixmap();
#endif
@ -1368,7 +1369,7 @@ bool QWizardPrivate::ensureButton(QWizard::WizardButton which) const
}
break;
}
#ifdef Q_WS_MAC
#ifdef Q_OS_MACX
pushButton->setAutoDefault(false);
#endif
pushButton->hide();
@ -1706,32 +1707,22 @@ void QWizardPrivate::setStyle(QStyle *style)
it.value()->setStyle(style);
}
#ifdef Q_WS_MAC
#ifdef Q_OS_MACX
QPixmap QWizardPrivate::findDefaultBackgroundPixmap()
{
QCFType<CFURLRef> url;
const int ExpectedImageWidth = 242;
const int ExpectedImageHeight = 414;
if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"),
0, 0, &url) == noErr) {
QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url);
if (bundle) {
url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("tif"), 0);
if (url) {
QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0);
QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0);
if (image) {
int width = CGImageGetWidth(image);
int height = CGImageGetHeight(image);
if (width == ExpectedImageWidth && height == ExpectedImageHeight)
return QPixmap::fromMacCGImageRef(image);
}
}
}
}
return QPixmap();
QGuiApplication *app = qobject_cast<QGuiApplication *>(QCoreApplication::instance());
if (!app)
return QPixmap();
QPlatformNativeInterface *platformNativeInterface = app->platformNativeInterface();
int at = platformNativeInterface->metaObject()->indexOfMethod("defaultBackgroundPixmapForQWizard()");
if (at == -1)
return QPixmap();
QMetaMethod defaultBackgroundPixmapForQWizard = platformNativeInterface->metaObject()->method(at);
QPixmap result;
if (!defaultBackgroundPixmapForQWizard.invoke(platformNativeInterface, Q_RETURN_ARG(QPixmap, result)))
return QPixmap();
return result;
}
#endif
@ -2842,7 +2833,7 @@ QPixmap QWizard::pixmap(WizardPixmap which) const
{
Q_D(const QWizard);
Q_ASSERT(uint(which) < NPixmaps);
#ifdef Q_WS_MAC
#ifdef Q_OS_MACX
if (which == BackgroundPixmap && d->defaultPixmaps[BackgroundPixmap].isNull())
d->defaultPixmaps[BackgroundPixmap] = d->findDefaultBackgroundPixmap();
#endif

View File

@ -59,7 +59,7 @@ void QKeySequenceEditPrivate::init()
prevKey = -1;
releaseTimer = 0;
layout = new QVBoxLayout(q);
QVBoxLayout *layout = new QVBoxLayout(q);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(lineEdit);

View File

@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_KEYSEQUENCEEDIT
class QLineEdit;
class QVBoxLayout;
class QKeySequenceEditPrivate : public QWidgetPrivate
{
@ -66,7 +65,6 @@ public:
void finishEditing();
QLineEdit *lineEdit;
QVBoxLayout *layout;
QKeySequence keySequence;
int keyNum;
int key[MaxKeyCount];

View File

@ -127,6 +127,7 @@ QMacNativeWidget::QMacNativeWidget(NSView *parentView)
setPalette(QPalette(Qt::transparent));
setAttribute(Qt::WA_SetPalette, false);
setAttribute(Qt::WA_LayoutUsesWidgetRect);
setAttribute(Qt::WA_TranslucentBackground);
}
/*!

View File

@ -324,7 +324,7 @@ void tst_QGlobal::qCoreAppStartupFunction()
{
QCOMPARE(qStartupFunctionValue, 0);
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qglobal") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QCOMPARE(qStartupFunctionValue, 124);
}

View File

@ -70,8 +70,7 @@ void tst_QProcessNoApplication::initializationDeadlock()
}
};
static char argv0[] = "tst_QProcessNoApplication";
char *argv[] = { argv0, 0 };
char *argv[] = { const_cast<char*>(QTest::currentAppName()), 0 };
int argc = 1;
QCoreApplication app(argc, argv);
MyThread thread;

View File

@ -88,7 +88,7 @@ public:
void tst_QCoreApplication::sendEventsOnProcessEvents()
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
EventSpy spy;
@ -110,7 +110,7 @@ void tst_QCoreApplication::getSetCheck()
// Test the property
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QCOMPARE(app.property("applicationVersion").toString(), v);
}
@ -135,7 +135,7 @@ void tst_QCoreApplication::argc()
{
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QCOMPARE(argc, 1);
QCOMPARE(app.arguments().count(), 1);
@ -143,7 +143,7 @@ void tst_QCoreApplication::argc()
{
int argc = 4;
char *argv[] = { const_cast<char*>("tst_qcoreapplication"),
char *argv[] = { const_cast<char*>(QTest::currentAppName()),
const_cast<char*>("arg1"),
const_cast<char*>("arg2"),
const_cast<char*>("arg3") };
@ -162,7 +162,7 @@ void tst_QCoreApplication::argc()
{
int argc = 2;
char *argv[] = { const_cast<char*>("tst_qcoreapplication"),
char *argv[] = { const_cast<char*>(QTest::currentAppName()),
const_cast<char*>("-qmljsdebugger=port:3768,block") };
QCoreApplication app(argc, argv);
QCOMPARE(argc, 1);
@ -196,7 +196,7 @@ public:
void tst_QCoreApplication::postEvent()
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
EventSpy spy;
@ -281,7 +281,7 @@ void tst_QCoreApplication::postEvent()
void tst_QCoreApplication::removePostedEvents()
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
EventSpy spy;
@ -460,7 +460,7 @@ public:
void tst_QCoreApplication::deliverInDefinedOrder()
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
DeliverInDefinedOrderObject obj(&app);
@ -500,7 +500,7 @@ public:
void tst_QCoreApplication::globalPostedEventsCount()
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QCoreApplication::sendPostedEvents();
@ -546,7 +546,7 @@ public:
void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents()
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
ProcessEventsAlwaysSendsPostedEventsObject object;
@ -564,7 +564,7 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents()
void tst_QCoreApplication::reexec()
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
// exec once
@ -579,7 +579,7 @@ void tst_QCoreApplication::reexec()
void tst_QCoreApplication::execAfterExit()
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
app.exit(1);
@ -590,7 +590,7 @@ void tst_QCoreApplication::execAfterExit()
void tst_QCoreApplication::eventLoopExecAfterExit()
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
// exec once and exit
@ -648,7 +648,7 @@ void tst_QCoreApplication::customEventDispatcher()
QVERIFY(!weak_ed.isNull());
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
// instantiating app should not overwrite the ED
QCOMPARE(QCoreApplication::eventDispatcher(), ed);
@ -763,7 +763,7 @@ private slots:
void tst_QCoreApplication::testQuitLock()
{
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QuitTester tester;
@ -782,7 +782,7 @@ void tst_QCoreApplication::QTBUG31606_QEventDestructorDeadLock()
};
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
EventSpy spy;

View File

@ -48,6 +48,9 @@ class tst_QCommandLineParser : public QObject
{
Q_OBJECT
public slots:
void initTestCase();
private slots:
void parsingModes_data();
@ -81,9 +84,15 @@ private slots:
void testQuoteEscaping();
};
static char *empty_argv[] = { const_cast<char*>("tst_qcommandlineparser") };
static char *empty_argv[] = { 0 };
static int empty_argc = 1;
void tst_QCommandLineParser::initTestCase()
{
Q_ASSERT(!empty_argv[0]);
empty_argv[0] = const_cast<char*>(QTest::currentAppName());
}
Q_DECLARE_METATYPE(QCommandLineParser::SingleDashWordOptionMode)
void tst_QCommandLineParser::parsingModes_data()

View File

@ -1407,10 +1407,7 @@ void tst_QLocale::macDefaultLocale()
QCOMPARE(locale.decimalPoint(), QChar('.'));
QCOMPARE(locale.groupSeparator(), QChar(','));
QCOMPARE(locale.dateFormat(QLocale::ShortFormat), QString("M/d/yy"));
if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_6)
QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, y"));
else
QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, yyyy"));
QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, yyyy"));
QCOMPARE(locale.timeFormat(QLocale::ShortFormat), QString("h:mm AP"));
QCOMPARE(locale.timeFormat(QLocale::LongFormat), QString("h:mm:ss AP t"));

View File

@ -5240,6 +5240,18 @@ void tst_QString::resizeAfterReserve()
s += "hello world";
s.resize(0);
QVERIFY(s.capacity() == 100);
// reserve() can't be used to truncate data
s.fill('x', 100);
s.reserve(50);
QVERIFY(s.capacity() == 100);
QVERIFY(s.size() == 100);
// even with increased ref count truncation isn't allowed
QString t = s;
s.reserve(50);
QVERIFY(s.capacity() == 100);
QVERIFY(s.size() == 100);
}
void tst_QString::resizeWithNegative() const

View File

@ -768,7 +768,7 @@ void tst_QGuiApplication::genericPluginsAndWindowSystemEvents()
testPluginInfo.rawMetaData = qt_plugin_query_metadata;
qRegisterStaticPluginFunction(testPluginInfo);
int argc = 3;
char *argv[] = { const_cast<char*>("tst_qguiapplication"), const_cast<char*>("-plugin"), const_cast<char*>("testplugin") };
char *argv[] = { const_cast<char*>(QTest::currentAppName()), const_cast<char*>("-plugin"), const_cast<char*>("testplugin") };
QGuiApplication app(argc, argv);
QVERIFY(QGuiApplication::primaryScreen());

View File

@ -1416,7 +1416,8 @@ void tst_QNetworkReply::initTestCase()
void tst_QNetworkReply::cleanupTestCase()
{
#if !defined Q_OS_WIN
QFile::remove(wronlyFileName);
if (!wronlyFileName.isNull())
QFile::remove(wronlyFileName);
#endif
#ifndef QT_NO_BEARERMANAGEMENT
if (networkSession && networkSession->isOpen()) {

View File

@ -114,8 +114,8 @@ void tst_QSql::cleanup()
void tst_QSql::basicDriverTest()
{
int argc = 1;
const char *argv[] = {"test"};
QGuiApplication app(argc, const_cast<char **>(argv), false);
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QGuiApplication app(argc, argv, false);
tst_Databases dbs;
dbs.open();
@ -155,10 +155,10 @@ void tst_QSql::open()
{
int i;
int argc = 1;
const char *argv[] = {"test"};
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
int count = -1;
for (i = 0; i < 10; ++i) {
QGuiApplication app(argc, const_cast<char **>(argv), false);
QGuiApplication app(argc, argv, false);
tst_Databases dbs;
dbs.open();
@ -184,8 +184,8 @@ void tst_QSql::openInvalid()
void tst_QSql::concurrentAccess()
{
int argc = 1;
const char *argv[] = {"test"};
QGuiApplication app(argc, const_cast<char **>(argv), false);
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QGuiApplication app(argc, argv, false);
tst_Databases dbs;
dbs.open();
@ -213,8 +213,8 @@ void tst_QSql::concurrentAccess()
void tst_QSql::openErrorRecovery()
{
int argc = 1;
const char *argv[] = {"test"};
QGuiApplication app(argc, const_cast<char **>(argv), false);
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QGuiApplication app(argc, argv, false);
tst_Databases dbs;
dbs.addDbs();
@ -261,8 +261,8 @@ void tst_QSql::openErrorRecovery()
void tst_QSql::registerSqlDriver()
{
int argc = 1;
const char *argv[] = {"test"};
QGuiApplication app(argc, const_cast<char **>(argv), false);
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QGuiApplication app(argc, argv, false);
QSqlDatabase::registerSqlDriver("QSQLTESTDRIVER", new QSqlDriverCreator<QSqlNullDriver>);
QVERIFY(QSqlDatabase::drivers().contains("QSQLTESTDRIVER"));

View File

@ -439,14 +439,8 @@ void tst_QWizard::setPixmap()
QVERIFY(wizard.pixmap(QWizard::BannerPixmap).isNull());
QVERIFY(wizard.pixmap(QWizard::LogoPixmap).isNull());
QVERIFY(wizard.pixmap(QWizard::WatermarkPixmap).isNull());
#ifdef Q_OS_MAC
if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_3) {
QEXPECT_FAIL("", "QTBUG-23701", Continue);
QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false);
} else {
// fall through since the image doesn't exist on a 10.3 system.
QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull());
}
#ifdef Q_OS_MACX
QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false);
#else
QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull());
#endif
@ -454,14 +448,8 @@ void tst_QWizard::setPixmap()
QVERIFY(page->pixmap(QWizard::BannerPixmap).isNull());
QVERIFY(page->pixmap(QWizard::LogoPixmap).isNull());
QVERIFY(page->pixmap(QWizard::WatermarkPixmap).isNull());
#ifdef Q_OS_MAC
if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_3) {
QEXPECT_FAIL("", "QTBUG-23701", Continue);
QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false);
} else {
// fall through since the image doesn't exist on a 10.3 system.
QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull());
}
#ifdef Q_OS_MACX
QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false);
#else
QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull());
#endif

View File

@ -1543,7 +1543,7 @@ void Configure::desc(const char *option, const char *description, bool skipInden
if (!skipIndent)
printf("%*s", optionIndent, "");
int remaining = descIndent - optionIndent - strlen(option);
int remaining = descIndent - optionIndent - int(strlen(option));
int wrapIndent = descIndent + qMax(0, 1 - remaining);
printf("%s", option);

View File

@ -347,7 +347,7 @@ int Environment::execute(QStringList arguments, const QStringList &additionalEnv
if (envStrings) {
int strLen = 0;
for (LPWSTR envString = envStrings; *(envString); envString += strLen + 1) {
strLen = wcslen(envString);
strLen = int(wcslen(envString));
QString str = QString((const QChar*)envString, strLen);
if (!str.startsWith("=")) { // These are added by the system
int sepIndex = str.indexOf('=');