summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Smith <msmith@trolltech.com>2010-01-04 09:48:39 +0100
committerMartin Smith <msmith@trolltech.com>2010-01-04 09:48:39 +0100
commitc855c61ed5c80a97f3a2858a15453f9e041db7f8 (patch)
tree68b86fe5adc7a5c19a237ee1e5bba147ccf92f23
parent65a0c8cc6d2c13cfb2cef22e8a23f4e3050fde25 (diff)
parent06bdf48e9194d73075041efecde5c70a144d6927 (diff)
downloadqt4-tools-c855c61ed5c80a97f3a2858a15453f9e041db7f8.tar.gz
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
-rw-r--r--config.tests/unix/neon/neon.cpp51
-rw-r--r--config.tests/unix/neon/neon.pro2
-rwxr-xr-xconfigure58
-rw-r--r--demos/embedded/anomaly/src/BrowserWindow.cpp5
-rw-r--r--demos/embedded/anomaly/src/flickcharm.cpp287
-rw-r--r--demos/embedded/fluidlauncher/fluidlauncher.pro5
-rw-r--r--mkspecs/features/symbian/platform_paths.prf22
-rw-r--r--mkspecs/features/symbian/qt.prf7
-rw-r--r--mkspecs/linux-g++-maemo/qmake.conf1
-rw-r--r--mkspecs/linux-g++/qplatformdefs.h1
-rw-r--r--mkspecs/solaris-cc-64-stlport/qmake.conf8
-rw-r--r--mkspecs/solaris-cc-64-stlport/qplatformdefs.h42
-rw-r--r--mkspecs/solaris-cc-stlport/qmake.conf8
-rw-r--r--mkspecs/solaris-cc-stlport/qplatformdefs.h42
-rw-r--r--qmake/generators/symbian/symmake.cpp25
-rw-r--r--qmake/generators/symbian/symmake.h1
-rw-r--r--qmake/generators/symbian/symmake_abld.cpp26
-rw-r--r--qmake/generators/symbian/symmake_sbsv2.cpp42
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-hebrew.c4
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp3
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/ChangeLog12
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/wtf/Assertions.h30
-rw-r--r--src/3rdparty/webkit/VERSION2
-rw-r--r--src/3rdparty/webkit/WebCore/ChangeLog86
-rw-r--r--src/3rdparty/webkit/WebCore/WebCore.pro27
-rw-r--r--src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h2
-rw-r--r--src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h10
-rw-r--r--src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h49
-rw-r--r--src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp73
-rw-r--r--src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp5
-rw-r--r--src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.h2
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp5
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp59
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebview.h5
-rw-r--r--src/3rdparty/webkit/WebKit/qt/ChangeLog86
-rw-r--r--src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp9
-rw-r--r--src/3rdparty/webkit/WebKit/qt/symbian/bwins/QtWebKitu.def (renamed from src/s60installs/bwins/QtWebKitu.def)0
-rw-r--r--src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def (renamed from src/s60installs/eabi/QtWebKitu.def)0
-rw-r--r--src/corelib/concurrent/qtconcurrentiteratekernel.cpp3
-rw-r--r--src/corelib/io/qdebug.h2
-rw-r--r--src/corelib/io/qfileinfo.cpp2
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp5
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp9
-rw-r--r--src/corelib/io/qurl.cpp14
-rw-r--r--src/corelib/thread/qthread_p.h2
-rw-r--r--src/corelib/thread/qthreadstorage.cpp97
-rw-r--r--src/dbus/qdbusabstractinterface.cpp10
-rw-r--r--src/dbus/qdbusconnection.cpp4
-rw-r--r--src/dbus/qdbusconnection_p.h22
-rw-r--r--src/dbus/qdbusintegrator.cpp114
-rw-r--r--src/dbus/qdbusmarshaller.cpp4
-rw-r--r--src/gui/embedded/qscreen_qws.cpp1
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp19
-rw-r--r--src/gui/image/qimagereader.cpp42
-rw-r--r--src/gui/image/qpixmap.cpp9
-rw-r--r--src/gui/image/qpixmap_raster.cpp2
-rw-r--r--src/gui/image/qpixmapfilter.cpp36
-rw-r--r--src/gui/image/qpnghandler.cpp5
-rw-r--r--src/gui/image/qppmhandler.cpp2
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.cpp33
-rw-r--r--src/gui/kernel/qapplication.cpp6
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm9
-rw-r--r--src/gui/kernel/qwidget.cpp11
-rw-r--r--src/gui/kernel/qwidget_mac.mm6
-rw-r--r--src/gui/painting/painting.pri7
-rw-r--r--src/gui/painting/qblendfunctions.cpp2
-rw-r--r--src/gui/painting/qdrawhelper.cpp16
-rw-r--r--src/gui/painting/qdrawhelper_neon.cpp260
-rw-r--r--src/gui/painting/qdrawhelper_neon_p.h76
-rw-r--r--src/gui/styles/qs60style.cpp226
-rw-r--r--src/gui/styles/qs60style_s60.cpp17
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp2
-rw-r--r--src/gui/text/qtextcontrol.cpp6
-rw-r--r--src/gui/util/qsystemtrayicon_p.h1
-rw-r--r--src/gui/widgets/qabstractspinbox.cpp4
-rw-r--r--src/gui/widgets/qlineedit.cpp6
-rw-r--r--src/gui/widgets/qplaintextedit.cpp2
-rw-r--r--src/gui/widgets/qtextedit.cpp2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp5
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp38
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp8
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager.cpp198
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager_p.h4
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadersource_p.h66
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp364
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h95
-rw-r--r--src/opengl/gl2paintengineex/qtriangulatingstroker.cpp10
-rw-r--r--src/opengl/qglshaderprogram.cpp67
-rw-r--r--src/opengl/qglshaderprogram.h4
-rw-r--r--src/opengl/qpaintengine_opengl.cpp14
-rw-r--r--src/opengl/qpixmapdata_gl.cpp15
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp11
-rw-r--r--src/plugins/imageformats/gif/qgifhandler.cpp40
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler.cpp407
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler.h4
-rw-r--r--src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro2
-rw-r--r--src/s60installs/bwins/QtGuiu.def13
-rw-r--r--src/s60installs/qt.iby26
-rw-r--r--src/s60installs/s60installs.pro9
-rw-r--r--src/s60main/qts60main.cpp58
-rw-r--r--src/s60main/qts60main_mcrt0.cpp52
-rw-r--r--src/svg/qsvghandler.cpp20
-rw-r--r--src/xml/sax/qxml.cpp4
-rw-r--r--src/xmlpatterns/api/api.pri116
-rw-r--r--src/xmlpatterns/api/qcoloringmessagehandler.cpp (renamed from tools/xmlpatterns/qcoloringmessagehandler.cpp)3
-rw-r--r--src/xmlpatterns/api/qcoloringmessagehandler_p.h (renamed from tools/xmlpatterns/qcoloringmessagehandler_p.h)0
-rw-r--r--src/xmlpatterns/api/qcoloroutput.cpp (renamed from tools/xmlpatterns/qcoloroutput.cpp)0
-rw-r--r--src/xmlpatterns/api/qcoloroutput_p.h (renamed from tools/xmlpatterns/qcoloroutput_p.h)0
-rw-r--r--src/xmlpatterns/api/qxmlpatternistcli_p.h74
-rw-r--r--src/xmlpatterns/xmlpatterns.pro34
-rw-r--r--tests/auto/headers/tst_headers.cpp4
-rw-r--r--tests/auto/modeltest/dynamictreemodel.cpp (renamed from tests/auto/qabstractitemmodel/dynamictreemodel.cpp)0
-rw-r--r--tests/auto/modeltest/dynamictreemodel.h (renamed from tests/auto/qabstractitemmodel/dynamictreemodel.h)0
-rw-r--r--tests/auto/modeltest/modeltest.cpp20
-rw-r--r--tests/auto/modeltest/modeltest.pro4
-rw-r--r--tests/auto/modeltest/tst_modeltest.cpp157
-rw-r--r--tests/auto/qabstractitemmodel/qabstractitemmodel.pro7
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp12
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp97
-rw-r--r--tests/auto/qimagereader/images/endless-anim.gifbin0 -> 819 bytes
-rw-r--r--tests/auto/qimagereader/images/four-frames.gifbin0 -> 427 bytes
-rw-r--r--tests/auto/qimagereader/qimagereader.qrc2
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp148
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp53
-rw-r--r--tests/auto/qurl/tst_qurl.cpp7
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp30
-rw-r--r--tests/auto/uiloader/baseline/css_qtbug6855.ui57
-rw-r--r--tests/benchmarks/benchmarks.pro4
-rw-r--r--tests/benchmarks/qhostinfo/main.cpp94
-rwxr-xr-xtests/benchmarks/qhostinfo/qhostinfo.pro13
-rw-r--r--tests/benchmarks/qthreadstorage/qthreadstorage.pro6
-rw-r--r--tests/benchmarks/qthreadstorage/tst_qthreadstorage.cpp124
-rw-r--r--tools/designer/src/components/objectinspector/objectinspector.pri8
-rw-r--r--tools/designer/src/components/propertyeditor/propertyeditor.pri11
-rw-r--r--tools/runonphone/main.cpp171
-rw-r--r--tools/runonphone/runonphone.pro19
-rw-r--r--tools/runonphone/serenum.h56
-rw-r--r--tools/runonphone/serenum_win.cpp114
-rw-r--r--tools/runonphone/trk/bluetoothlistener.cpp224
-rw-r--r--tools/runonphone/trk/bluetoothlistener.h101
-rw-r--r--tools/runonphone/trk/bluetoothlistener_gui.cpp111
-rw-r--r--tools/runonphone/trk/bluetoothlistener_gui.h87
-rw-r--r--tools/runonphone/trk/callback.h160
-rw-r--r--tools/runonphone/trk/communicationstarter.cpp260
-rw-r--r--tools/runonphone/trk/communicationstarter.h160
-rw-r--r--tools/runonphone/trk/launcher.cpp695
-rw-r--r--tools/runonphone/trk/launcher.h168
-rw-r--r--tools/runonphone/trk/trk.pri23
-rw-r--r--tools/runonphone/trk/trkdevice.cpp1073
-rw-r--r--tools/runonphone/trk/trkdevice.h133
-rw-r--r--tools/runonphone/trk/trkutils.cpp486
-rw-r--r--tools/runonphone/trk/trkutils.h189
-rw-r--r--tools/runonphone/trksignalhandler.cpp121
-rw-r--r--tools/runonphone/trksignalhandler.h68
-rw-r--r--tools/xmlpatterns/main.cpp2
-rw-r--r--tools/xmlpatterns/main.h10
-rw-r--r--tools/xmlpatterns/xmlpatterns.pro8
158 files changed, 7895 insertions, 1363 deletions
diff --git a/config.tests/unix/neon/neon.cpp b/config.tests/unix/neon/neon.cpp
new file mode 100644
index 0000000000..c31a9fd4e8
--- /dev/null
+++ b/config.tests/unix/neon/neon.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the config.tests of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <arm_neon.h>
+
+int main(int, char**)
+{
+ int32x4_t null = vdupq_n_s32(0x0);
+
+ int result;
+ vst1q_lane_s32(&result, null, 0);
+ return result;
+}
diff --git a/config.tests/unix/neon/neon.pro b/config.tests/unix/neon/neon.pro
new file mode 100644
index 0000000000..de20c4e0ab
--- /dev/null
+++ b/config.tests/unix/neon/neon.pro
@@ -0,0 +1,2 @@
+SOURCES = neon.cpp
+CONFIG -= x11 qt
diff --git a/configure b/configure
index 6547318cde..22e6bd4693 100755
--- a/configure
+++ b/configure
@@ -106,6 +106,28 @@ QMakeVar()
echo "$2" "$eq" "$3" >> "$QMAKE_VARS_FILE"
}
+# Helper function for getQMakeConf. It parses include statements in
+# qmake.conf and prints out the expanded file
+getQMakeConf1()
+{
+ while read line; do case "$line" in
+ include*)
+ inc_file=`echo "$line" | sed -n -e "/^include.*(.*)/s/include.*(\(.*\)).*$/\1/p"`
+ current_dir=`dirname "$1"`
+ conf_file="$current_dir/$inc_file"
+ if [ ! -e "$conf_file" ]; then
+ echo "WARNING: Unable to find file $conf_file" >&2
+ continue
+ fi
+ getQMakeConf1 "$conf_file"
+ ;;
+ *)
+ echo "$line"
+ ;;
+ esac; done < "$1"
+}
+
+
# relies on $QMAKESPEC being set correctly. parses include statements in
# qmake.conf and prints out the expanded file
getQMakeConf()
@@ -114,15 +136,7 @@ getQMakeConf()
if [ -n "$1" ]; then
tmpSPEC="$1"
fi
- $AWK -v "QMAKESPEC=$tmpSPEC" '
-/^include\(.+\)$/{
- fname = QMAKESPEC "/" substr($0, 9, length($0) - 9)
- while ((getline line < fname) > 0)
- print line
- close(fname)
- next
-}
-{ print }' "$tmpSPEC/qmake.conf"
+ getQMakeConf1 "$tmpSPEC/qmake.conf"
}
# relies on $TEST_COMPILER being set correctly
@@ -731,6 +745,7 @@ CFG_HOST_ENDIAN=auto
CFG_DOUBLEFORMAT=auto
CFG_ARMFPA=auto
CFG_IWMMXT=no
+CFG_NEON=auto
CFG_CLOCK_GETTIME=auto
CFG_CLOCK_MONOTONIC=auto
CFG_MREMAP=auto
@@ -1590,6 +1605,13 @@ while [ "$#" -gt 0 ]; do
iwmmxt)
CFG_IWMMXT="yes"
;;
+ neon)
+ if [ "$VAL" = "no" ]; then
+ CFG_NEON="$VAL"
+ else
+ UNKNOWN_OPT=yes
+ fi
+ ;;
reduce-relocations)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_REDUCE_RELOCATIONS="$VAL"
@@ -2926,6 +2948,10 @@ fi
QMAKE_CONF_COMPILER=`getQMakeConf "$XQMAKESPEC" | grep "^QMAKE_CXX[^_A-Z0-9]" | sed "s,.* *= *\(.*\)$,\1," | tail -1`
TEST_COMPILER="$CC"
[ -z "$TEST_COMPILER" ] && TEST_COMPILER=$QMAKE_CONF_COMPILER
+if [ -z "$TEST_COMPILER" ]; then
+ echo "ERROR: Cannot set the compiler for the configuration tests"
+ exit 1
+fi
# auto-detect precompiled header support
if [ "$CFG_PRECOMPILE" = "auto" ]; then
@@ -3871,6 +3897,7 @@ Qt for Embedded Linux only:
-iwmmxt ............ Compile using the iWMMXt instruction set
(available on some XScale CPUs).
+ -no-neon ........... Do not compile with use of NEON instructions.
EOF
fi
@@ -4491,6 +4518,15 @@ if [ "$CFG_IWMMXT" = "yes" ]; then
fi
fi
+# detect neon support
+if ([ "$CFG_ARCH" = "arm" ] || [ "$CFG_ARCH" = "armv6" ]) && [ "${CFG_NEON}" = "auto" ]; then
+ if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/neon "neon" $L_FLAGS $I_FLAGS $l_FLAGS "-mfpu=neon"; then
+ CFG_NEON=yes
+ else
+ CFG_NEON=no
+ fi
+fi
+
# detect zlib
if [ "$CFG_ZLIB" = "no" ]; then
# Note: Qt no longer support builds without zlib
@@ -6106,6 +6142,7 @@ fi
[ "$CFG_SSE" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG sse"
[ "$CFG_SSE2" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG sse2"
[ "$CFG_IWMMXT" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG iwmmxt"
+[ "$CFG_NEON" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG neon"
[ "$PLATFORM_MAC" = "yes" ] && QMAKE_CONFIG="$QMAKE_CONFIG $CFG_MAC_ARCHS"
if [ "$CFG_IPV6" = "yes" ]; then
QT_CONFIG="$QT_CONFIG ipv6"
@@ -7398,8 +7435,9 @@ echo "Declarative module .. $CFG_DECLARATIVE"
echo "STL support ......... $CFG_STL"
echo "PCH support ......... $CFG_PRECOMPILE"
echo "MMX/3DNOW/SSE/SSE2.. ${CFG_MMX}/${CFG_3DNOW}/${CFG_SSE}/${CFG_SSE2}"
-if [ "${CFG_ARCH}" = "arm" ]; then
+if [ "$CFG_ARCH" = "arm" ] || [ "$CFG_ARCH" = "armv6" ]; then
echo "iWMMXt support ...... ${CFG_IWMMXT}"
+ echo "NEON support ........ ${CFG_NEON}"
fi
[ "${PLATFORM_QWS}" != "yes" ] && echo "Graphics System ..... $CFG_GRAPHICS_SYSTEM"
echo "IPv6 support ........ $CFG_IPV6"
diff --git a/demos/embedded/anomaly/src/BrowserWindow.cpp b/demos/embedded/anomaly/src/BrowserWindow.cpp
index 1163b6a1a7..30b6b914b0 100644
--- a/demos/embedded/anomaly/src/BrowserWindow.cpp
+++ b/demos/embedded/anomaly/src/BrowserWindow.cpp
@@ -150,6 +150,9 @@ void BrowserWindow::keyReleaseEvent(QKeyEvent *event)
void BrowserWindow::resizeEvent(QResizeEvent *event)
{
+ const QSize oldSize = event->oldSize();
+ const qreal oldSlidingRatio = static_cast<qreal>(qAbs(m_homeView->x())) / oldSize.width();
+
const QSize newSize = event->size();
m_slidingSurface->resize(newSize.width() * 2, newSize.height());
@@ -159,7 +162,5 @@ void BrowserWindow::resizeEvent(QResizeEvent *event)
m_browserView->resize(newSize);
m_browserView->move(newSize.width(), 0);
- const QSize oldSize = event->oldSize();
- const qreal oldSlidingRatio = static_cast<qreal>(qAbs(m_slidingSurface->x())) / oldSize.width();
setSlideValue(oldSlidingRatio);
}
diff --git a/demos/embedded/anomaly/src/flickcharm.cpp b/demos/embedded/anomaly/src/flickcharm.cpp
index 0b9e68edf3..b7e215107b 100644
--- a/demos/embedded/anomaly/src/flickcharm.cpp
+++ b/demos/embedded/anomaly/src/flickcharm.cpp
@@ -49,20 +49,112 @@
#include <QList>
#include <QMouseEvent>
#include <QScrollBar>
+#include <QTime>
#include <QWebFrame>
#include <QWebView>
#include <QDebug>
+const int fingerAccuracyThreshold = 3;
+
struct FlickData {
- typedef enum { Steady, Pressed, ManualScroll, AutoScroll, Stop } State;
+ typedef enum {
+ Steady, // Interaction without scrolling
+ ManualScroll, // Scrolling manually with the finger on the screen
+ AutoScroll, // Scrolling automatically
+ AutoScrollAcceleration // Scrolling automatically but a finger is on the screen
+ } State;
State state;
QWidget *widget;
QPoint pressPos;
- QPoint offset;
- QPoint dragPos;
+ QPoint lastPos;
QPoint speed;
+ QTime speedTimer;
QList<QEvent*> ignored;
+ QTime accelerationTimer;
+ bool lastPosValid:1;
+ bool waitingAcceleration:1;
+
+ FlickData()
+ : lastPosValid(false)
+ , waitingAcceleration(false)
+ {}
+
+ void resetSpeed()
+ {
+ speed = QPoint();
+ lastPosValid = false;
+ }
+ void updateSpeed(const QPoint &newPosition)
+ {
+ if (lastPosValid) {
+ const int timeElapsed = speedTimer.elapsed();
+ if (timeElapsed) {
+ const QPoint newPixelDiff = (newPosition - lastPos);
+ const QPoint pixelsPerSecond = newPixelDiff * (1000 / timeElapsed);
+ // fingers are inacurates, we ignore small changes to avoid stopping the autoscroll because
+ // of a small horizontal offset when scrolling vertically
+ const int newSpeedY = (qAbs(pixelsPerSecond.y()) > fingerAccuracyThreshold) ? pixelsPerSecond.y() : 0;
+ const int newSpeedX = (qAbs(pixelsPerSecond.x()) > fingerAccuracyThreshold) ? pixelsPerSecond.x() : 0;
+ if (state == AutoScrollAcceleration) {
+ const int max = 4000; // px by seconds
+ const int oldSpeedY = speed.y();
+ const int oldSpeedX = speed.x();
+ if ((oldSpeedY <= 0 && newSpeedY <= 0) || (oldSpeedY >= 0 && newSpeedY >= 0)
+ && (oldSpeedX <= 0 && newSpeedX <= 0) || (oldSpeedX >= 0 && newSpeedX >= 0)) {
+ speed.setY(qBound(-max, (oldSpeedY + (newSpeedY / 4)), max));
+ speed.setX(qBound(-max, (oldSpeedX + (newSpeedX / 4)), max));
+ } else {
+ speed = QPoint();
+ }
+ } else {
+ const int max = 2500; // px by seconds
+ // we average the speed to avoid strange effects with the last delta
+ if (!speed.isNull()) {
+ speed.setX(qBound(-max, (speed.x() / 4) + (newSpeedX * 3 / 4), max));
+ speed.setY(qBound(-max, (speed.y() / 4) + (newSpeedY * 3 / 4), max));
+ } else {
+ speed = QPoint(newSpeedX, newSpeedY);
+ }
+ }
+ }
+ } else {
+ lastPosValid = true;
+ }
+ speedTimer.start();
+ lastPos = newPosition;
+ }
+
+ // scroll by dx, dy
+ // return true if the widget was scrolled
+ bool scrollWidget(const int dx, const int dy)
+ {
+ QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget);
+ if (scrollArea) {
+ const int x = scrollArea->horizontalScrollBar()->value();
+ const int y = scrollArea->verticalScrollBar()->value();
+ scrollArea->horizontalScrollBar()->setValue(x - dx);
+ scrollArea->verticalScrollBar()->setValue(y - dy);
+ return (scrollArea->horizontalScrollBar()->value() != x
+ || scrollArea->verticalScrollBar()->value() != y);
+ }
+
+ QWebView *webView = qobject_cast<QWebView*>(widget);
+ if (webView) {
+ QWebFrame *frame = webView->page()->mainFrame();
+ const QPoint position = frame->scrollPosition();
+ frame->setScrollPosition(position - QPoint(dx, dy));
+ return frame->scrollPosition() != position;
+ }
+ return false;
+ }
+
+ bool scrollTo(const QPoint &newPosition)
+ {
+ const QPoint delta = newPosition - lastPos;
+ updateSpeed(newPosition);
+ return scrollWidget(delta.x(), delta.y());
+ }
};
class FlickCharmPrivate
@@ -70,6 +162,13 @@ class FlickCharmPrivate
public:
QHash<QWidget*, FlickData*> flickData;
QBasicTimer ticker;
+ QTime timeCounter;
+ void startTicker(QObject *object)
+ {
+ if (!ticker.isActive())
+ ticker.start(15, object);
+ timeCounter.start();
+ }
};
FlickCharm::FlickCharm(QObject *parent): QObject(parent)
@@ -148,46 +247,14 @@ void FlickCharm::deactivateFrom(QWidget *widget)
}
}
-static QPoint scrollOffset(QWidget *widget)
+static QPoint deaccelerate(const QPoint &speed, const int deltatime)
{
- int x = 0, y = 0;
-
- QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget);
- if (scrollArea) {
- x = scrollArea->horizontalScrollBar()->value();
- y = scrollArea->verticalScrollBar()->value();
- }
-
- QWebView *webView = qobject_cast<QWebView*>(widget);
- if (webView) {
- QWebFrame *frame = webView->page()->mainFrame();
- x = frame->evaluateJavaScript("window.scrollX").toInt();
- y = frame->evaluateJavaScript("window.scrollY").toInt();
- }
-
- return QPoint(x, y);
-}
-
-static void setScrollOffset(QWidget *widget, const QPoint &p)
-{
- QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget);
- if (scrollArea) {
- scrollArea->horizontalScrollBar()->setValue(p.x());
- scrollArea->verticalScrollBar()->setValue(p.y());
- }
+ const int deltaSpeed = deltatime;
- QWebView *webView = qobject_cast<QWebView*>(widget);
- QWebFrame *frame = webView ? webView->page()->mainFrame() : 0;
- if (frame)
- frame->evaluateJavaScript(QString("window.scrollTo(%1,%2);").arg(p.x()).arg(p.y()));
-}
-
-static QPoint deaccelerate(const QPoint &speed, int a = 1, int max = 64)
-{
- int x = qBound(-max, speed.x(), max);
- int y = qBound(-max, speed.y(), max);
- x = (x == 0) ? x : (x > 0) ? qMax(0, x - a) : qMin(0, x + a);
- y = (y == 0) ? y : (y > 0) ? qMax(0, y - a) : qMin(0, y + a);
+ int x = speed.x();
+ int y = speed.y();
+ x = (x == 0) ? x : (x > 0) ? qMax(0, x - deltaSpeed) : qMin(0, x + deltaSpeed);
+ y = (y == 0) ? y : (y > 0) ? qMax(0, y - deltaSpeed) : qMin(0, y + deltaSpeed);
return QPoint(x, y);
}
@@ -196,22 +263,24 @@ bool FlickCharm::eventFilter(QObject *object, QEvent *event)
if (!object->isWidgetType())
return false;
- QEvent::Type type = event->type();
- if (type != QEvent::MouseButtonPress &&
- type != QEvent::MouseButtonRelease &&
- type != QEvent::MouseMove)
- return false;
+ const QEvent::Type type = event->type();
- QMouseEvent *mouseEvent = 0;
- switch (event->type()) {
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseMove:
- mouseEvent = static_cast<QMouseEvent*>(event);
- break;
+ switch (type) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonRelease:
+ break;
+ case QEvent::MouseButtonDblClick: // skip double click
+ return true;
+ default:
+ return false;
}
- if (!mouseEvent || mouseEvent->modifiers() != Qt::NoModifier)
+ QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
+ if (type == QEvent::MouseMove && mouseEvent->buttons() != Qt::LeftButton)
+ return false;
+
+ if (mouseEvent->modifiers() != Qt::NoModifier)
return false;
QWidget *viewport = qobject_cast<QWidget*>(object);
@@ -219,89 +288,83 @@ bool FlickCharm::eventFilter(QObject *object, QEvent *event)
if (!viewport || !data || data->ignored.removeAll(event))
return false;
+ const QPoint mousePos = mouseEvent->pos();
bool consumed = false;
switch (data->state) {
case FlickData::Steady:
- if (mouseEvent->type() == QEvent::MouseButtonPress)
- if (mouseEvent->buttons() == Qt::LeftButton) {
- consumed = true;
- data->state = FlickData::Pressed;
- data->pressPos = mouseEvent->pos();
- data->offset = scrollOffset(data->widget);
- }
- break;
-
- case FlickData::Pressed:
- if (mouseEvent->type() == QEvent::MouseButtonRelease) {
+ if (type == QEvent::MouseButtonPress) {
+ consumed = true;
+ data->pressPos = mousePos;
+ } else if (type == QEvent::MouseButtonRelease) {
consumed = true;
- data->state = FlickData::Steady;
-
QMouseEvent *event1 = new QMouseEvent(QEvent::MouseButtonPress,
data->pressPos, Qt::LeftButton,
Qt::LeftButton, Qt::NoModifier);
- QMouseEvent *event2 = new QMouseEvent(*mouseEvent);
+ QMouseEvent *event2 = new QMouseEvent(QEvent::MouseButtonRelease,
+ data->pressPos, Qt::LeftButton,
+ Qt::LeftButton, Qt::NoModifier);
data->ignored << event1;
data->ignored << event2;
QApplication::postEvent(object, event1);
QApplication::postEvent(object, event2);
- }
- if (mouseEvent->type() == QEvent::MouseMove) {
+ } else if (type == QEvent::MouseMove) {
consumed = true;
- data->state = FlickData::ManualScroll;
- data->dragPos = QCursor::pos();
- if (!d->ticker.isActive())
- d->ticker.start(20, this);
+ data->scrollTo(mousePos);
+
+ const QPoint delta = mousePos - data->pressPos;
+ if (delta.x() > fingerAccuracyThreshold || delta.y() > fingerAccuracyThreshold)
+ data->state = FlickData::ManualScroll;
}
break;
case FlickData::ManualScroll:
- if (mouseEvent->type() == QEvent::MouseMove) {
+ if (type == QEvent::MouseMove) {
consumed = true;
- QPoint delta = mouseEvent->pos() - data->pressPos;
- setScrollOffset(data->widget, data->offset - delta);
- }
- if (mouseEvent->type() == QEvent::MouseButtonRelease) {
+ data->scrollTo(mousePos);
+ } else if (type == QEvent::MouseButtonRelease) {
consumed = true;
data->state = FlickData::AutoScroll;
+ data->lastPosValid = false;
+ d->startTicker(this);
}
break;
case FlickData::AutoScroll:
- if (mouseEvent->type() == QEvent::MouseButtonPress) {
+ if (type == QEvent::MouseButtonPress) {
consumed = true;
- data->state = FlickData::Stop;
- data->speed = QPoint(0, 0);
- data->pressPos = mouseEvent->pos();
- data->offset = scrollOffset(data->widget);
- }
- if (mouseEvent->type() == QEvent::MouseButtonRelease) {
+ data->state = FlickData::AutoScrollAcceleration;
+ data->waitingAcceleration = true;
+ data->accelerationTimer.start();
+ data->updateSpeed(mousePos);
+ data->pressPos = mousePos;
+ } else if (type == QEvent::MouseButtonRelease) {
consumed = true;
data->state = FlickData::Steady;
- data->speed = QPoint(0, 0);
+ data->resetSpeed();
}
break;
- case FlickData::Stop:
- if (mouseEvent->type() == QEvent::MouseButtonRelease) {
+ case FlickData::AutoScrollAcceleration:
+ if (type == QEvent::MouseMove) {
consumed = true;
- data->state = FlickData::Steady;
- }
- if (mouseEvent->type() == QEvent::MouseMove) {
+ data->updateSpeed(mousePos);
+ data->accelerationTimer.start();
+ if (data->speed.isNull())
+ data->state = FlickData::ManualScroll;
+ } else if (type == QEvent::MouseButtonRelease) {
consumed = true;
- data->state = FlickData::ManualScroll;
- data->dragPos = QCursor::pos();
- if (!d->ticker.isActive())
- d->ticker.start(20, this);
+ data->state = FlickData::AutoScroll;
+ data->waitingAcceleration = false;
+ data->lastPosValid = false;
}
break;
-
default:
break;
}
-
- return consumed;
+ data->lastPos = mousePos;
+ return true;
}
void FlickCharm::timerEvent(QTimerEvent *event)
@@ -311,25 +374,29 @@ void FlickCharm::timerEvent(QTimerEvent *event)
while (item.hasNext()) {
item.next();
FlickData *data = item.value();
-
- if (data->state == FlickData::ManualScroll) {
- count++;
- data->speed = QCursor::pos() - data->dragPos;
- data->dragPos = QCursor::pos();
+ if (data->state == FlickData::AutoScrollAcceleration
+ && data->waitingAcceleration
+ && data->accelerationTimer.elapsed() > 40) {
+ data->state = FlickData::ManualScroll;
+ data->resetSpeed();
}
+ if (data->state == FlickData::AutoScroll || data->state == FlickData::AutoScrollAcceleration) {
+ const int timeElapsed = d->timeCounter.elapsed();
+ const QPoint delta = (data->speed) * timeElapsed / 1000;
+ bool hasScrolled = data->scrollWidget(delta.x(), delta.y());
- if (data->state == FlickData::AutoScroll) {
- count++;
- data->speed = deaccelerate(data->speed);
- QPoint p = scrollOffset(data->widget);
- setScrollOffset(data->widget, p - data->speed);
- if (data->speed == QPoint(0, 0))
+ if (data->speed.isNull() || !hasScrolled)
data->state = FlickData::Steady;
+ else
+ count++;
+ data->speed = deaccelerate(data->speed, timeElapsed);
}
}
if (!count)
d->ticker.stop();
+ else
+ d->timeCounter.start();
QObject::timerEvent(event);
}
diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro
index b47f6a0374..bb8835bc2b 100644
--- a/demos/embedded/fluidlauncher/fluidlauncher.pro
+++ b/demos/embedded/fluidlauncher/fluidlauncher.pro
@@ -163,6 +163,11 @@ symbian {
resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/anomaly.rsc
mifs.sources += \
$${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/anomaly.mif
+
+ # Since Fluidlauncher itself doesn't link webkit, we won't get dependency automatically
+ executables.pkg_prerules += \
+ "; Dependency to Qt Webkit" \
+ "(0x200267C2), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {\"QtWebKit\"}"
}
contains(QT_CONFIG, phonon) {
diff --git a/mkspecs/features/symbian/platform_paths.prf b/mkspecs/features/symbian/platform_paths.prf
index bec9811c4c..f5caae0121 100644
--- a/mkspecs/features/symbian/platform_paths.prf
+++ b/mkspecs/features/symbian/platform_paths.prf
@@ -216,10 +216,11 @@ exists($${EPOCROOT}epoc32/include/platform_paths.prf) {
OS_LAYER_SSL_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/openssl)
# stlportv5 is preferred over stlport as it has the throwing version of operator new
- exists($${EPOCROOT}epoc32/include/stdapis/stlportv5) {
- OS_LAYER_STDCPP_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/stlportv5)
- } else {
+ exists($${EPOCROOT}epoc32/include/stdapis/stlport) \
+ :!exists($${EPOCROOT}epoc32/include/stdapis/stlportv5) {
OS_LAYER_STDCPP_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/stlport)
+ } else {
+ OS_LAYER_STDCPP_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/stlportv5)
}
OS_LAYER_BOOST_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/boost)
@@ -427,12 +428,15 @@ exists($${EPOCROOT}epoc32/include/platform_paths.prf) {
/epoc32/include/stdapis/openssl
# stlportv5 is preferred over stlport as it has the throwing version of operator new
- exists($${EPOCROOT}epoc32/include/osextensions/stdapis/stlportv5)|exists($${EPOCROOT}epoc32/include/stdapis/stlportv5) {
- OS_LAYER_STDCPP_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/stlportv5) \
- /epoc32/include/stdapis/stlportv5
- } else {
- OS_LAYER_STDCPP_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/stlport) \
- /epoc32/include/stdapis/stlport
+ OS_LAYER_STDCPP_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/stlportv5) \
+ /epoc32/include/stdapis/stlportv5
+ exists($${EPOCROOT}epoc32/include/osextensions/stdapis/stlport) \
+ |exists($${EPOCROOT}epoc32/include/stdapis/stlport) {
+ !exists($${EPOCROOT}epoc32/include/osextensions/stdapis/stlportv5) \
+ :!exists($${EPOCROOT}epoc32/include/stdapis/stlportv5) {
+ OS_LAYER_STDCPP_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/stlport) \
+ /epoc32/include/stdapis/stlport
+ }
}
OS_LAYER_BOOST_SYSTEMINCLUDE = $$OS_LAYER_PUBLIC_EXPORT_PATH(stdapis/boost) \
diff --git a/mkspecs/features/symbian/qt.prf b/mkspecs/features/symbian/qt.prf
index 0f5b08b6a2..99f5ece067 100644
--- a/mkspecs/features/symbian/qt.prf
+++ b/mkspecs/features/symbian/qt.prf
@@ -28,6 +28,13 @@ contains(CONFIG, qt):!contains(TARGET.UID3, 0x2001E61C):!contains(TARGET.UID3, 0
default_deployment.pkg_prerules += \
"; Default dependency to Qt libraries" \
"(0x2001E61C), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {\"Qt\"}"
+
+ # Projects linking to webkit need dependency to webkit
+ contains(QT, webkit): {
+ default_deployment.pkg_prerules += \
+ "; Dependency to Qt Webkit" \
+ "(0x200267C2), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {\"QtWebKit\"}"
+ }
}
isEmpty(TARGET.EPOCSTACKSIZE):TARGET.EPOCSTACKSIZE = 0x14000
diff --git a/mkspecs/linux-g++-maemo/qmake.conf b/mkspecs/linux-g++-maemo/qmake.conf
index c39ba2c89c..b0f3ca31fa 100644
--- a/mkspecs/linux-g++-maemo/qmake.conf
+++ b/mkspecs/linux-g++-maemo/qmake.conf
@@ -5,6 +5,7 @@
MAKEFILE_GENERATOR = UNIX
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl
+CONFIG += nostrip
QT += core gui
QMAKE_INCREMENTAL_STYLE = sublib
diff --git a/mkspecs/linux-g++/qplatformdefs.h b/mkspecs/linux-g++/qplatformdefs.h
index ecfbc73881..00f1b51cf0 100644
--- a/mkspecs/linux-g++/qplatformdefs.h
+++ b/mkspecs/linux-g++/qplatformdefs.h
@@ -67,7 +67,6 @@
#include <grp.h>
#include <pwd.h>
#include <signal.h>
-#include <dlfcn.h>
#include <sys/types.h>
#include <sys/ioctl.h>
diff --git a/mkspecs/solaris-cc-64-stlport/qmake.conf b/mkspecs/solaris-cc-64-stlport/qmake.conf
new file mode 100644
index 0000000000..3437b8fd22
--- /dev/null
+++ b/mkspecs/solaris-cc-64-stlport/qmake.conf
@@ -0,0 +1,8 @@
+#
+# qmake configuration for solaris-cc-64-stlport
+#
+
+include(../solaris-cc-64/qmake.conf)
+
+QMAKE_CXXFLAGS += -library=stlport4
+QMAKE_LFLAGS += -library=stlport4
diff --git a/mkspecs/solaris-cc-64-stlport/qplatformdefs.h b/mkspecs/solaris-cc-64-stlport/qplatformdefs.h
new file mode 100644
index 0000000000..7c88722916
--- /dev/null
+++ b/mkspecs/solaris-cc-64-stlport/qplatformdefs.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the qmake spec of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "../solaris-cc-64/qplatformdefs.h"
diff --git a/mkspecs/solaris-cc-stlport/qmake.conf b/mkspecs/solaris-cc-stlport/qmake.conf
new file mode 100644
index 0000000000..b0df45e949
--- /dev/null
+++ b/mkspecs/solaris-cc-stlport/qmake.conf
@@ -0,0 +1,8 @@
+#
+# qmake configuration for solaris-cc-stlport
+#
+
+include(../solaris-cc/qmake.conf)
+
+QMAKE_CXXFLAGS += -library=stlport4
+QMAKE_LFLAGS += -library=stlport4
diff --git a/mkspecs/solaris-cc-stlport/qplatformdefs.h b/mkspecs/solaris-cc-stlport/qplatformdefs.h
new file mode 100644
index 0000000000..bb75c1f6ff
--- /dev/null
+++ b/mkspecs/solaris-cc-stlport/qplatformdefs.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the qmake spec of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "../solaris-cc/qplatformdefs.h"
diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp
index 8379ed975b..ddda848c43 100644
--- a/qmake/generators/symbian/symmake.cpp
+++ b/qmake/generators/symbian/symmake.cpp
@@ -1764,7 +1764,9 @@ void SymbianMakefileGenerator::writeSisTargets(QTextStream &t)
{
t << SIS_TARGET ": " RESTORE_BUILD_TARGET << endl;
QString siscommand = QString("\t$(if $(wildcard %1_template.%2),$(if $(wildcard %3)," \
- "$(MAKE) -s -f $(MAKEFILE) %4,$(MAKE) -s -f $(MAKEFILE) %5)," \
+ "$(MAKE) -s -f $(MAKEFILE) %4," \
+ "$(if $(QT_SIS_TARGET),$(MAKE) -s -f $(MAKEFILE) %4," \
+ "$(MAKE) -s -f $(MAKEFILE) %5))," \
"$(MAKE) -s -f $(MAKEFILE) %6)")
.arg(fixedTarget)
.arg("pkg")
@@ -1789,7 +1791,7 @@ void SymbianMakefileGenerator::writeSisTargets(QTextStream &t)
t << endl;
t << FAIL_SIS_NOCACHE_TARGET ":" << endl;
- t << "\t$(error Project has to be build before calling 'SIS' target)" << endl;
+ t << "\t$(error Project has to be built or QT_SIS_TARGET environment variable has to be set before calling 'SIS' target)" << endl;
t << endl;
@@ -1852,3 +1854,22 @@ void SymbianMakefileGenerator::generateDistcleanTargets(QTextStream& t)
t << "distclean: clean dodistclean" << endl;
t << endl;
}
+
+void SymbianMakefileGenerator::generateExecutionTargets(QTextStream& t, const QStringList& platforms)
+{
+ // create execution targets
+ if (targetType == TypeExe) {
+ if (platforms.contains("winscw")) {
+ t << "ifeq (\"DEBUG-winscw\", \"$(QT_SIS_TARGET)\")" << endl;
+ t << "run:" << endl;
+ t << "\t-call " << epocRoot() << "epoc32/release/winscw/udeb/" << fixedTarget << ".exe " << "$(QT_RUN_OPTIONS)" << endl;
+ t << "else" << endl;
+ }
+ t << "run: sis" << endl;
+ t << "\trunonphone --sis " << fixedTarget << "_$(QT_SIS_TARGET).sis " << fixedTarget << ".exe " << "$(QT_RUN_OPTIONS)" << endl;
+ if (platforms.contains("winscw")) {
+ t << "endif" << endl;
+ }
+ t << endl;
+ }
+}
diff --git a/qmake/generators/symbian/symmake.h b/qmake/generators/symbian/symmake.h
index 1a20e64107..6949842fec 100644
--- a/qmake/generators/symbian/symmake.h
+++ b/qmake/generators/symbian/symmake.h
@@ -148,6 +148,7 @@ protected:
void writeSisTargets(QTextStream &t);
void generateDistcleanTargets(QTextStream& t);
+ void generateExecutionTargets(QTextStream& t, const QStringList& platforms);
// Subclass implements
virtual void writeBldInfExtensionRulesPart(QTextStream& t, const QString &iconTargetFile) = 0;
diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp
index f2baf46a88..065af48523 100644
--- a/qmake/generators/symbian/symmake_abld.cpp
+++ b/qmake/generators/symbian/symmake_abld.cpp
@@ -372,11 +372,29 @@ void SymbianAbldMakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool
t << "\t-bldmake clean" << endl;
t << endl;
- // Create execution target
- if (debugPlatforms.contains("winscw") && targetType == TypeExe) {
- t << "run:" << endl;
- t << "\t-call " << epocRoot() << "epoc32\\release\\winscw\\udeb\\" << fixedTarget << ".exe" << endl << endl;
+ t << "clean-debug: $(ABLD)" << endl;
+ foreach(QString item, debugPlatforms) {
+ t << "\t$(ABLD)" << testClause << " reallyclean " << item << " udeb" << endl;
}
+ t << endl;
+ t << "clean-release: $(ABLD)" << endl;
+ foreach(QString item, releasePlatforms) {
+ t << "\t$(ABLD)" << testClause << " reallyclean " << item << " urel" << endl;
+ }
+ t << endl;
+
+ // For more specific builds, targets are in this form: clean-build-platform, e.g. clean-release-armv5
+ foreach(QString item, debugPlatforms) {
+ t << "clean-debug-" << item << ": $(ABLD)" << endl;
+ t << "\t$(ABLD)" << testClause << " reallyclean " << item << " udeb" << endl;
+ }
+ foreach(QString item, releasePlatforms) {
+ t << "clean-release-" << item << ": $(ABLD)" << endl;
+ t << "\t$(ABLD)" << testClause << " reallyclean " << item << " urel" << endl;
+ }
+ t << endl;
+
+ generateExecutionTargets(t, debugPlatforms);
}
void SymbianAbldMakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t, const QString &iconTargetFile)
diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp
index ad22cfd222..7d6119d1f2 100644
--- a/qmake/generators/symbian/symmake_sbsv2.cpp
+++ b/qmake/generators/symbian/symmake_sbsv2.cpp
@@ -171,18 +171,26 @@ void SymbianSbsv2MakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, boo
t << "\t$(QMAKE)" << endl;
t << endl;
+ QString winscw("winscw");
t << "debug: " << BLD_INF_FILENAME << endl;
+ t << "\t$(SBS)";
foreach(QString item, debugPlatforms) {
- t << "\t$(SBS) -c " << item << "_udeb" << testClause << endl;
+ if(QString::compare(item, winscw) == 0)
+ t << " -c " << item << "_udeb.mwccinc" << testClause;
+ else
+ t << " -c " << item << "_udeb" << testClause;
}
t << endl;
t << "release: " << BLD_INF_FILENAME << endl;
+ t << "\t$(SBS)";
foreach(QString item, releasePlatforms) {
- t << "\t$(SBS) -c " << item << "_urel" << testClause << endl;
+ if(QString::compare(item, winscw) == 0)
+ t << " -c " << item << "_urel.mwccinc" << testClause;
+ else
+ t << " -c " << item << "_urel" << testClause;
}
t << endl;
- QString winscw("winscw");
// For more specific builds, targets are in this form: build-platform, e.g. release-armv5
foreach(QString item, debugPlatforms) {
t << "debug-" << item << ": " << BLD_INF_FILENAME << endl;
@@ -231,11 +239,31 @@ void SymbianSbsv2MakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, boo
t << "\t-$(SBS) reallyclean" << endl;
t << endl;
- // create execution target
- if (debugPlatforms.contains("winscw") && targetType == TypeExe) {
- t << "run:" << endl;
- t << "\t-call " << epocRoot() << "epoc32/release/winscw/udeb/" << fixedTarget << ".exe" << endl << endl;
+ t << "clean-debug: " << BLD_INF_FILENAME << endl;
+ t << "\t$(SBS) reallyclean";
+ foreach(QString item, debugPlatforms) {
+ t << " -c " << item << "_udeb" << testClause;
+ }
+ t << endl;
+ t << "clean-release: " << BLD_INF_FILENAME << endl;
+ t << "\t$(SBS) reallyclean";
+ foreach(QString item, releasePlatforms) {
+ t << " -c " << item << "_urel" << testClause;
+ }
+ t << endl;
+
+ // For more specific builds, targets are in this form: clean-build-platform, e.g. clean-release-armv5
+ foreach(QString item, debugPlatforms) {
+ t << "clean-debug-" << item << ": " << BLD_INF_FILENAME << endl;
+ t << "\t$(SBS) reallyclean -c " << item << "_udeb" << testClause << endl;
}
+ foreach(QString item, releasePlatforms) {
+ t << "clean-release-" << item << ": " << BLD_INF_FILENAME << endl;
+ t << "\t$(SBS) reallyclean -c " << item << "_urel" << testClause << endl;
+ }
+ t << endl;
+
+ generateExecutionTargets(t, debugPlatforms);
}
void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t, const QString &iconTargetFile)
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-hebrew.c b/src/3rdparty/harfbuzz/src/harfbuzz-hebrew.c
index 2bda3868c6..67029be14f 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-hebrew.c
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-hebrew.c
@@ -56,8 +56,6 @@ HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item)
assert(shaper_item->item.script == HB_Script_Hebrew);
- HB_HeuristicSetGlyphAttributes(shaper_item);
-
#ifndef NO_OPENTYPE
if (HB_SelectScript(shaper_item, hebrew_features)) {
@@ -65,7 +63,7 @@ HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item)
if (!HB_ConvertStringToGlyphIndices(shaper_item))
return FALSE;
-
+ HB_HeuristicSetGlyphAttributes(shaper_item);
HB_OpenTypeShape(shaper_item, /*properties*/0);
return HB_OpenTypePosition(shaper_item, availableGlyphs, /*doLogClusters*/TRUE);
}
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
index bfb03ab432..bfc7bd47a8 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
@@ -980,6 +980,7 @@ HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc)
HB_Stream gdefStream;
gdefStream = getTableStream(font, tableFunc, TTAG_GDEF);
+ error = HB_Err_Not_Covered;
if (!gdefStream || (error = HB_Load_GDEF_Table(gdefStream, &face->gdef))) {
//DEBUG("error loading gdef table: %d", error);
face->gdef = 0;
@@ -987,6 +988,7 @@ HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc)
//DEBUG() << "trying to load gsub table";
stream = getTableStream(font, tableFunc, TTAG_GSUB);
+ error = HB_Err_Not_Covered;
if (!stream || (error = HB_Load_GSUB_Table(stream, &face->gsub, face->gdef, gdefStream))) {
face->gsub = 0;
if (error != HB_Err_Not_Covered) {
@@ -998,6 +1000,7 @@ HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc)
_hb_close_stream(stream);
stream = getTableStream(font, tableFunc, TTAG_GPOS);
+ error = HB_Err_Not_Covered;
if (!stream || (error = HB_Load_GPOS_Table(stream, &face->gpos, face->gdef, gdefStream))) {
face->gpos = 0;
DEBUG("error loading gpos table: %d", error);
diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog
index d7d2d57a61..50cff63c9b 100644
--- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog
+++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog
@@ -1,3 +1,15 @@
+2009-12-18 Yongjun Zhang <yongjun.zhang@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=32713
+ [Qt] make wtf/Assertions.h compile in winscw compiler.
+
+ Add string arg before ellipsis to help winscw compiler resolve variadic
+ macro definitions in wtf/Assertions.h.
+
+ * wtf/Assertions.h:
+
2009-11-30 Jan-Arve Sæther <jan-arve.saether@nokia.com>
Reviewed by Simon Hausmann.
diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Assertions.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Assertions.h
index f529a62eaa..aa72e5af45 100644
--- a/src/3rdparty/webkit/JavaScriptCore/wtf/Assertions.h
+++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Assertions.h
@@ -158,8 +158,8 @@ void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChann
#define ASSERT(assertion) ((void)0)
#if COMPILER(MSVC7)
#define ASSERT_WITH_MESSAGE(assertion) ((void)0)
-#elif PLATFORM(SYMBIAN)
-#define ASSERT_WITH_MESSAGE(assertion...) ((void)0)
+#elif COMPILER(WINSCW)
+#define ASSERT_WITH_MESSAGE(assertion, arg...) ((void)0)
#else
#define ASSERT_WITH_MESSAGE(assertion, ...) ((void)0)
#endif /* COMPILER(MSVC7) */
@@ -176,8 +176,8 @@ void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChann
while (0)
#if COMPILER(MSVC7)
#define ASSERT_WITH_MESSAGE(assertion) ((void)0)
-#elif PLATFORM(SYMBIAN)
-#define ASSERT_WITH_MESSAGE(assertion...) ((void)0)
+#elif COMPILER(WINSCW)
+#define ASSERT_WITH_MESSAGE(assertion, arg...) ((void)0)
#else
#define ASSERT_WITH_MESSAGE(assertion, ...) do \
if (!(assertion)) { \
@@ -219,11 +219,11 @@ while (0)
/* FATAL */
-#if FATAL_DISABLED && !COMPILER(MSVC7) && !PLATFORM(SYMBIAN)
+#if FATAL_DISABLED && !COMPILER(MSVC7) && !COMPILER(WINSCW)
#define FATAL(...) ((void)0)
#elif COMPILER(MSVC7)
#define FATAL() ((void)0)
-#elif PLATFORM(SYMBIAN)
+#elif COMPILER(WINSCW)
#define FATAL(args...) ((void)0)
#else
#define FATAL(...) do { \
@@ -234,24 +234,24 @@ while (0)
/* LOG_ERROR */
-#if ERROR_DISABLED && !COMPILER(MSVC7) && !PLATFORM(SYMBIAN)
+#if ERROR_DISABLED && !COMPILER(MSVC7) && !COMPILER(WINSCW)
#define LOG_ERROR(...) ((void)0)
#elif COMPILER(MSVC7)
#define LOG_ERROR() ((void)0)
-#elif PLATFORM(SYMBIAN)
-#define LOG_ERROR(args...) ((void)0)
+#elif COMPILER(WINSCW)
+#define LOG_ERROR(arg...) ((void)0)
#else
#define LOG_ERROR(...) WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, __VA_ARGS__)
#endif
/* LOG */
-#if LOG_DISABLED && !COMPILER(MSVC7) && !PLATFORM(SYMBIAN)
+#if LOG_DISABLED && !COMPILER(MSVC7) && !COMPILER(WINSCW)
#define LOG(channel, ...) ((void)0)
#elif COMPILER(MSVC7)
#define LOG() ((void)0)
-#elif PLATFORM(SYMBIAN)
-#define LOG(channel, args...) ((void)0)
+#elif COMPILER(WINSCW)
+#define LOG(arg...) ((void)0)
#else
#define LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
#define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel)
@@ -260,12 +260,12 @@ while (0)
/* LOG_VERBOSE */
-#if LOG_DISABLED && !COMPILER(MSVC7) && !PLATFORM(SYMBIAN)
+#if LOG_DISABLED && !COMPILER(MSVC7) && !COMPILER(WINSCW)
#define LOG_VERBOSE(channel, ...) ((void)0)
#elif COMPILER(MSVC7)
#define LOG_VERBOSE(channel) ((void)0)
-#elif PLATFORM(SYMBIAN)
-#define LOG_VERBOSE(channel, args...) ((void)0)
+#elif COMPILER(WINSCW)
+#define LOG_VERBOSE(channel, arg...) ((void)0)
#else
#define LOG_VERBOSE(channel, ...) WTFLogVerbose(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, &JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
#endif
diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION
index 62acbdf5ab..daa3be78b8 100644
--- a/src/3rdparty/webkit/VERSION
+++ b/src/3rdparty/webkit/VERSION
@@ -8,4 +8,4 @@ The commit imported was from the
and has the sha1 checksum
- 9de63cde0ac8aa08e207d4ffce2846df1a44a364
+ 70b5989bdeea2f73bd950099fc0f0e954550ef54
diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog
index 4f6146faa1..03bb1fbb7a 100644
--- a/src/3rdparty/webkit/WebCore/ChangeLog
+++ b/src/3rdparty/webkit/WebCore/ChangeLog
@@ -1,3 +1,89 @@
+2009-12-30 Janne Koskinen <janne.p.koskinen@digia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Add support for Symbian def files
+
+ * WebCore.pro:
+
+2009-12-30 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Unreviewed Qt/Symbian build fix.
+
+ Don't build network state notifier support when building inside of Qt.
+ Otherwise the Qt build depends on an external module that itself depends
+ on Qt again.
+
+ * WebCore.pro:
+
+2009-12-30 Laszlo Gombos <laszlo.1.gombos@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Turn off DataGrid support by default.
+
+ No new tests, as there is no new functionality.
+
+ * WebCore.pro:
+
+2009-12-17 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt] support navigator.onLine and ononline/onoffline events.
+ https://bugs.webkit.org/show_bug.cgi?id=32555
+
+ Hooked up Bearer Management to NetworkStateNotifier. This solution is available
+ only if QtMobility's Bearer Management is installed.
+
+ * WebCore.pro:
+ * platform/network/NetworkStateNotifier.h:
+ * platform/network/qt/NetworkStateNotifierPrivate.h: Added.
+ * platform/network/qt/NetworkStateNotifierQt.cpp: Added.
+ (WebCore::NetworkStateNotifierPrivate::NetworkStateNotifierPrivate):
+ (WebCore::NetworkStateNotifierPrivate::onlineStateChanged):
+ (WebCore::NetworkStateNotifierPrivate::~NetworkStateNotifierPrivate):
+ (WebCore::NetworkStateNotifier::updateState):
+ (WebCore::NetworkStateNotifier::NetworkStateNotifier):
+
+2009-12-17 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Reviewed by Tor Arne Vestbø.
+
+ [Qt] Symbian build fix: Don't include QtXml/qxmlstream.h but omit the prefix, to
+ make sure we pick up the header file from QtCore. That is where the implementation
+ is compiled.
+
+ * dom/XMLTokenizer.h:
+
+2009-12-14 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt] Add manual test for JavaScript prompt corner case
+ https://bugs.webkit.org/show_bug.cgi?id=30914
+
+ The patch is based on the work done by Gupta Manish.
+
+ Verify behavior of the JavaScript prompt function. Currently
+ Qt is not behaving like other WebKit ports and Firefox in
+ regards to accepting the prompt but not entering a text.
+
+ * manual-tests/qt/java-script-prompt.html: Added.
+
+2009-12-21 Andreas Kling <andreas.kling@nokia.com>
+
+ Reviewed by Darin Adler.
+
+ Fix assertion failure when dragging an SVG image.
+ https://bugs.webkit.org/show_bug.cgi?id=32511
+
+ Test: fast/images/drag-svg-as-image.html
+
+ * svg/graphics/SVGImage.cpp:
+ (WebCore::SVGImage::filenameExtension): Return "svg"
+ * svg/graphics/SVGImage.h:
+
2009-11-23 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Kenneth Rohde Christiansen.
diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro
index 92390898b2..be64e3b0fe 100644
--- a/src/3rdparty/webkit/WebCore/WebCore.pro
+++ b/src/3rdparty/webkit/WebCore/WebCore.pro
@@ -136,7 +136,7 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) {
!contains(DEFINES, ENABLE_SHARED_WORKERS=.): DEFINES += ENABLE_SHARED_WORKERS=1
!contains(DEFINES, ENABLE_WORKERS=.): DEFINES += ENABLE_WORKERS=1
!contains(DEFINES, ENABLE_XHTMLMP=.): DEFINES += ENABLE_XHTMLMP=0
-!contains(DEFINES, ENABLE_DATAGRID=.): DEFINES += ENABLE_DATAGRID=1
+!contains(DEFINES, ENABLE_DATAGRID=.): DEFINES += ENABLE_DATAGRID=0
# SVG support
!contains(DEFINES, ENABLE_SVG=0) {
@@ -180,6 +180,15 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) {
else:DEFINES += ENABLE_XSLT=0
}
+!CONFIG(QTDIR_build):!contains(DEFINES, ENABLE_QT_BEARER=.) {
+ symbian: {
+ exists($${EPOCROOT}epoc32/release/winscw/udeb/QtBearer.lib)| \
+ exists($${EPOCROOT}epoc32/release/armv5/lib/QtBearer.lib) {
+ DEFINES += ENABLE_QT_BEARER=1
+ }
+ }
+}
+
DEFINES += WTF_USE_JAVASCRIPTCORE_BINDINGS=1 WTF_CHANGES=1
# Used to compute defaults for the build-webkit script
@@ -2860,6 +2869,17 @@ contains(DEFINES, ENABLE_XHTMLMP=1) {
FEATURE_DEFINES_JAVASCRIPT += ENABLE_XHTMLMP=1
}
+contains(DEFINES, ENABLE_QT_BEARER=1) {
+ HEADERS += \
+ platform/network/qt/NetworkStateNotifierPrivate.h
+
+ SOURCES += \
+ platform/network/qt/NetworkStateNotifierQt.cpp
+
+ LIBS += -lQtBearer
+
+}
+
contains(DEFINES, ENABLE_SVG=1) {
FEATURE_DEFINES_JAVASCRIPT += ENABLE_SVG=1
@@ -3382,16 +3402,15 @@ CONFIG(QTDIR_build):isEqual(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 4
}
}
-# Temporary workaround to pick up the DEF file from the same place as all the others
symbian {
shared {
contains(MMP_RULES, defBlock) {
MMP_RULES -= defBlock
MMP_RULES += "$${LITERAL_HASH}ifdef WINSCW" \
- "DEFFILE ../../../s60installs/bwins/$${TARGET}.def" \
+ "DEFFILE ../WebKit/qt/symbian/bwins/$${TARGET}.def" \
"$${LITERAL_HASH}elif defined EABI" \
- "DEFFILE ../../../s60installs/eabi/$${TARGET}.def" \
+ "DEFFILE ../WebKit/qt/symbian/eabi/$${TARGET}.def" \
"$${LITERAL_HASH}endif"
}
}
diff --git a/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h b/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h
index e1ee09f047..a83e73af7c 100644
--- a/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h
+++ b/src/3rdparty/webkit/WebCore/dom/XMLTokenizer.h
@@ -34,7 +34,7 @@
#include <wtf/OwnPtr.h>
#if USE(QXMLSTREAM)
-#include <QtXml/qxmlstream.h>
+#include <qxmlstream.h>
#else
#include <libxml/tree.h>
#include <libxml/xmlstring.h>
diff --git a/src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h b/src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h
index 0189f5ff59..f8c56540f5 100644
--- a/src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h
+++ b/src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h
@@ -46,6 +46,10 @@ typedef const struct __SCDynamicStore * SCDynamicStoreRef;
namespace WebCore {
+#if (PLATFORM(QT) && ENABLE(QT_BEARER))
+class NetworkStateNotifierPrivate;
+#endif
+
class NetworkStateNotifier {
public:
NetworkStateNotifier();
@@ -78,10 +82,14 @@ private:
#elif PLATFORM(CHROMIUM)
NetworkStateNotifierPrivate p;
+
+#elif PLATFORM(QT) && ENABLE(QT_BEARER)
+ friend class NetworkStateNotifierPrivate;
+ NetworkStateNotifierPrivate* p;
#endif
};
-#if !PLATFORM(MAC) && !PLATFORM(WIN) && !PLATFORM(CHROMIUM)
+#if !PLATFORM(MAC) && !PLATFORM(WIN) && !PLATFORM(CHROMIUM) && !(PLATFORM(QT) && ENABLE(QT_BEARER))
inline NetworkStateNotifier::NetworkStateNotifier()
: m_isOnLine(true)
diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h b/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h
new file mode 100644
index 0000000000..7af6392120
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef NetworkStateNotifierPrivate_h
+#define NetworkStateNotifierPrivate_h
+
+#include <QObject>
+
+namespace QtMobility {
+class QNetworkConfigurationManager;
+}
+
+namespace WebCore {
+
+class NetworkStateNotifier;
+
+class NetworkStateNotifierPrivate : public QObject {
+ Q_OBJECT
+public:
+ NetworkStateNotifierPrivate(NetworkStateNotifier* notifier);
+ ~NetworkStateNotifierPrivate();
+public slots:
+ void onlineStateChanged(bool);
+
+public:
+ QtMobility::QNetworkConfigurationManager* m_configurationManager;
+ bool m_online;
+ NetworkStateNotifier* m_notifier;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp
new file mode 100644
index 0000000000..f74398b937
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp
@@ -0,0 +1,73 @@
+/*
+ Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "NetworkStateNotifier.h"
+
+#include "NetworkStateNotifierPrivate.h"
+#include "qnetworkconfigmanager.h"
+
+using namespace QtMobility;
+
+namespace WebCore {
+
+NetworkStateNotifierPrivate::NetworkStateNotifierPrivate(NetworkStateNotifier* notifier)
+ : m_configurationManager(new QNetworkConfigurationManager())
+ , m_online(m_configurationManager->isOnline())
+ , m_notifier(notifier)
+{
+ Q_ASSERT(notifier);
+ connect(m_configurationManager, SIGNAL(onlineStateChanged(bool)), this, SLOT(onlineStateChanged(bool)));
+}
+
+void NetworkStateNotifierPrivate::onlineStateChanged(bool isOnline)
+{
+ if (m_online == isOnline)
+ return;
+
+ m_online = isOnline;
+ m_notifier->updateState();
+}
+
+NetworkStateNotifierPrivate::~NetworkStateNotifierPrivate()
+{
+ delete m_configurationManager;
+}
+
+void NetworkStateNotifier::updateState()
+{
+ if (m_isOnLine == p->m_online)
+ return;
+
+ m_isOnLine = p->m_online;
+ if (m_networkStateChangedFunction)
+ m_networkStateChangedFunction();
+}
+
+NetworkStateNotifier::NetworkStateNotifier()
+ : m_isOnLine(true)
+ , m_networkStateChangedFunction(0)
+{
+ p = new NetworkStateNotifierPrivate(this);
+ m_isOnLine = p->m_online;
+}
+
+} // namespace WebCore
+
+#include "moc_NetworkStateNotifierPrivate.cpp"
diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp b/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp
index 0a506f85f5..b74e912278 100644
--- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp
+++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.cpp
@@ -267,6 +267,11 @@ bool SVGImage::dataChanged(bool allDataReceived)
return m_page;
}
+String SVGImage::filenameExtension() const
+{
+ return "svg";
+}
+
}
#endif // ENABLE(SVG)
diff --git a/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.h b/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.h
index 2cea91ac95..0f0542953f 100644
--- a/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.h
+++ b/src/3rdparty/webkit/WebCore/svg/graphics/SVGImage.h
@@ -47,6 +47,8 @@ namespace WebCore {
private:
virtual ~SVGImage();
+ virtual String filenameExtension() const;
+
virtual void setContainerSize(const IntSize&);
virtual bool usesContainerSize() const;
virtual bool hasRelativeWidth() const;
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp
index f43cbbfd5b..1145744c3f 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebinspector.cpp
@@ -139,6 +139,9 @@ QSize QWebInspector::sizeHint() const
/*! \reimp */
bool QWebInspector::event(QEvent* ev)
{
+ if (ev->type() == QEvent::Close && d->page)
+ d->page->d->inspectorController()->setWindowVisible(false);
+
return QWidget::event(ev);
}
@@ -159,8 +162,6 @@ void QWebInspector::showEvent(QShowEvent* event)
/*! \reimp */
void QWebInspector::hideEvent(QHideEvent* event)
{
- if (d->page)
- d->page->d->inspectorController()->setWindowVisible(false);
}
/*! \internal */
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
index 88b7271530..6d08c32a01 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
@@ -1849,7 +1849,8 @@ bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg)
The program may provide an optional message, \a msg, as well as a default value for the input in \a defaultValue.
If the prompt was cancelled by the user the implementation should return false; otherwise the
- result should be written to \a result and true should be returned.
+ result should be written to \a result and true should be returned. If the prompt was not cancelled by the
+ user, the implementation should return true and the result string must not be null.
The default implementation uses QInputDialog::getText.
*/
@@ -3080,7 +3081,7 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const
Q_UNUSED(url)
QString ua = QLatin1String("Mozilla/5.0 ("
- // Plastform
+ // Platform
#ifdef Q_WS_MAC
"Macintosh"
#elif defined Q_WS_QWS
@@ -3089,19 +3090,22 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const
"Windows"
#elif defined Q_WS_X11
"X11"
+#elif defined Q_OS_SYMBIAN
+ "SymbianOS"
#else
"Unknown"
#endif
- "; "
+ // Placeholder for Platform Version
+ "%1; "
// Placeholder for security strength (N or U)
- "%1; "
+ "%2; "
// Subplatform"
#ifdef Q_OS_AIX
"AIX"
#elif defined Q_OS_WIN32
- "%2"
+ "%3"
#elif defined Q_OS_DARWIN
#ifdef __i386__ || __x86_64__
"Intel Mac OS X"
@@ -3153,6 +3157,8 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const
"Sun Solaris"
#elif defined Q_OS_ULTRIX
"DEC Ultrix"
+#elif defined Q_WS_S60
+ "Series60"
#elif defined Q_OS_UNIX
"UNIX BSD/SYSV system"
#elif defined Q_OS_UNIXWARE
@@ -3160,7 +3166,28 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const
#else
"Unknown"
#endif
- "; ");
+ // Placeholder for SubPlatform Version
+ "%4; ");
+
+ // Platform Version
+ QString osVer;
+#ifdef Q_OS_SYMBIAN
+ QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion();
+ switch (symbianVersion) {
+ case QSysInfo::SV_9_2:
+ osVer = "/9.2";
+ break;
+ case QSysInfo::SV_9_3:
+ osVer = "/9.3";
+ break;
+ case QSysInfo::SV_9_4:
+ osVer = "/9.4";
+ break;
+ default:
+ osVer = "Unknown";
+ }
+#endif
+ ua = ua.arg(osVer);
QChar securityStrength(QLatin1Char('N'));
#if !defined(QT_NO_OPENSSL)
@@ -3224,6 +3251,26 @@ QString QWebPage::userAgentForUrl(const QUrl& url) const
ua = QString(ua).arg(ver);
#endif
+ // SubPlatform Version
+ QString subPlatformVer;
+#ifdef Q_OS_SYMBIAN
+ QSysInfo::S60Version s60Version = QSysInfo::s60Version();
+ switch (s60Version) {
+ case QSysInfo::SV_S60_3_1:
+ subPlatformVer = "/3.1";
+ break;
+ case QSysInfo::SV_S60_3_2:
+ subPlatformVer = "/3.2";
+ break;
+ case QSysInfo::SV_S60_5_0:
+ subPlatformVer = "/5.0";
+ break;
+ default:
+ subPlatformVer = " Unknown";
+ }
+#endif
+ ua = ua.arg(subPlatformVer);
+
// Language
QLocale locale;
if (view())
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.h
index e9c1ec8e05..0f79c704ff 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebview.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebview.h
@@ -51,12 +51,7 @@ class QWEBKIT_EXPORT QWebView : public QWidget {
Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false)
Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
-// FIXME: temporary work around for elftran issue that it couldn't find the QPainter::staticMetaObject
-// symbol from Qt lib; it should be reverted after the right symbol is exported.
-// See bug: http://qt.nokia.com/developer/task-tracker/index_html?method=entry&id=258893
-#if defined(Q_QDOC) || !defined(Q_OS_SYMBIAN)
Q_PROPERTY(QPainter::RenderHints renderHints READ renderHints WRITE setRenderHints)
-#endif
Q_FLAGS(QPainter::RenderHints)
public:
explicit QWebView(QWidget* parent = 0);
diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog
index 2f0bf17d60..4ab5bfbbd2 100644
--- a/src/3rdparty/webkit/WebKit/qt/ChangeLog
+++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog
@@ -1,3 +1,89 @@
+2009-12-30 Janne Koskinen <janne.p.koskinen@digia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Upstream Symbian def files from Qt 4.6.
+
+ These files define the ABI of QtWebKit on Symbian.
+
+ * symbian/bwins/QtWebKitu.def: Added.
+ * symbian/eabi/QtWebKitu.def: Added.
+
+2009-12-14 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt] Fix JavaScript prompt behavior for empty/null strings.
+ https://bugs.webkit.org/show_bug.cgi?id=30914
+
+ The patch is based on the work done by Gupta Manish.
+
+ In the default implementation of the JavaScript prompt
+ we are using a QInputDialog to get the text and this has
+ one quirk with regard to not entering any text.
+
+ In other WebKit ports and in Firefox an empty string is
+ returned but in the Qt case it is a null string.
+
+ Change the API documentation in QWebPage to mention we want to
+ have a non null string but do the fixup in the ChromeClientQt
+ to support existing code.
+
+ * Api/qwebpage.cpp:
+ (QWebPage::javaScriptPrompt): Change API documentation
+ * WebCoreSupport/ChromeClientQt.cpp:
+ (WebCore::ChromeClientQt::runJavaScriptPrompt): Fixup null QString
+
+2009-12-21 David Boddie <dboddie@trolltech.com>
+
+ Reviewed by Simon Hausmann.
+
+ Doc: Minor fixes to language.
+
+ * Api/qwebpage.cpp:
+
+2009-12-15 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by NOBODY (OOPS!).
+
+ [Qt] Do not disable the inspector on show and hide
+ https://bugs.webkit.org/show_bug.cgi?id=31851
+
+ On Qt/X11 with some window managers the window will be
+ hidden when switching windows. In this case all the results
+ are gone when coming back to the window.
+
+ Attempt to use the CloseEvent to figure out if the window
+ was closed and withdrawn as this is more friendly to the
+ user of the inspector client.
+
+ * Api/qwebinspector.cpp:
+ (QWebInspector::event):
+ (QWebInspector::hideEvent):
+
+2009-12-13 Simon Hausmann <hausmann@webkit.org>
+
+ Reviewed by Holger Freyther.
+
+ [Qt] Re-enable QWebView::renderHints property for Qt for Symbian
+
+ https://bugs.webkit.org/show_bug.cgi?id=28273
+
+ The bug in Qt's moc that triggered a linking error when declaring this
+ property has been fixed and we can remove the workaround.
+
+ * Api/qwebview.h:
+
+2009-11-30 Abhinav Mithal <abhinav.mithal@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt][Symbian] Report SymbianOS in user agent string for Symbian
+ https://bugs.webkit.org/show_bug.cgi?id=31961
+
+ * Api/qwebpage.cpp:
+ (QWebPage::userAgentForUrl):
+
2009-11-28 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Kenneth Rohde Christiansen.
diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index 26cf6f6b1f..c5d2792c3a 100644
--- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -278,7 +278,14 @@ bool ChromeClientQt::runJavaScriptPrompt(Frame* f, const String& message, const
QString x = result;
FrameLoaderClientQt *fl = static_cast<FrameLoaderClientQt*>(f->loader()->client());
bool rc = m_webPage->javaScriptPrompt(fl->webFrame(), (QString)message, (QString)defaultValue, &x);
- result = x;
+
+ // Fix up a quirk in the QInputDialog class. If no input happened the string should be empty
+ // but it is null. See https://bugs.webkit.org/show_bug.cgi?id=30914.
+ if (rc && result.isNull())
+ result = String("");
+ else
+ result = x;
+
return rc;
}
diff --git a/src/s60installs/bwins/QtWebKitu.def b/src/3rdparty/webkit/WebKit/qt/symbian/bwins/QtWebKitu.def
index e5631f848d..e5631f848d 100644
--- a/src/s60installs/bwins/QtWebKitu.def
+++ b/src/3rdparty/webkit/WebKit/qt/symbian/bwins/QtWebKitu.def
diff --git a/src/s60installs/eabi/QtWebKitu.def b/src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def
index 4aad884f1d..4aad884f1d 100644
--- a/src/s60installs/eabi/QtWebKitu.def
+++ b/src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def
diff --git a/src/corelib/concurrent/qtconcurrentiteratekernel.cpp b/src/corelib/concurrent/qtconcurrentiteratekernel.cpp
index 15b8ecdff6..e93394fc39 100644
--- a/src/corelib/concurrent/qtconcurrentiteratekernel.cpp
+++ b/src/corelib/concurrent/qtconcurrentiteratekernel.cpp
@@ -46,6 +46,9 @@
#include <mach/mach_time.h>
#include <unistd.h>
#elif defined(Q_OS_UNIX)
+#if defined(Q_OS_HURD)
+#include <sys/time.h>
+#endif
#include <time.h>
#include <unistd.h>
#elif defined(Q_OS_WIN)
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index ff8c6c874a..c1c7812661 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -93,7 +93,7 @@ public:
inline QDebug &maybeSpace() { if (stream->space) stream->ts << ' '; return *this; }
inline QDebug &operator<<(QChar t) { stream->ts << '\'' << t << '\''; return maybeSpace(); }
- inline QDebug &operator<<(QBool t) { stream->ts << (bool(t) ? "true" : "false"); return maybeSpace(); }
+ inline QDebug &operator<<(QBool t) { stream->ts << (bool(t != 0) ? "true" : "false"); return maybeSpace(); }
inline QDebug &operator<<(bool t) { stream->ts << (t ? "true" : "false"); return maybeSpace(); }
inline QDebug &operator<<(char t) { stream->ts << t; return maybeSpace(); }
inline QDebug &operator<<(signed short t) { stream->ts << t; return maybeSpace(); }
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 61081a1b93..0a435b9d94 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -573,6 +573,8 @@ QString QFileInfo::canonicalFilePath() const
QString QFileInfo::absolutePath() const
{
Q_D(const QFileInfo);
+ if (d->data->fileName.isEmpty())
+ qWarning("QFileInfo::absolutePath: Constructed with empty filename");
if(!d->data->fileEngine)
return QLatin1String("");
return d->getFileName(QAbstractFileEngine::AbsolutePathName);
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 71414ce00c..ea262bfe3c 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -825,10 +825,9 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const
ret |= RootFlag;
} else {
QString baseName = fileName(BaseName);
- if ((baseName.size() > 1
- && baseName.at(0) == QLatin1Char('.') && baseName.at(1) != QLatin1Char('.'))
+ if ((baseName.size() > 0 && baseName.at(0) == QLatin1Char('.'))
# if !defined(QWS) && defined(Q_OS_MAC)
- || _q_isMacHidden(d->filePath)
+ || _q_isMacHidden(d->filePath)
# endif
) {
ret |= HiddenFlag;
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index a6cb5a9f7a..a7719a8f7e 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -1595,13 +1595,10 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::Fil
ret |= LocalDiskFlag;
if (d->doStat()) {
ret |= ExistsFlag;
- if (d->filePath == QLatin1String("/") || isDriveRoot(d->filePath) || isUncRoot(d->filePath)) {
+ if (d->filePath == QLatin1String("/") || isDriveRoot(d->filePath) || isUncRoot(d->filePath))
ret |= RootFlag;
- } else if (d->fileAttrib & FILE_ATTRIBUTE_HIDDEN) {
- QString baseName = fileName(BaseName);
- if (baseName != QLatin1String(".") && baseName != QLatin1String(".."))
- ret |= HiddenFlag;
- }
+ else if (d->fileAttrib & FILE_ATTRIBUTE_HIDDEN)
+ ret |= HiddenFlag;
}
}
return ret;
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index fd51bcf50b..6ac64681d6 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -3864,14 +3864,18 @@ QByteArray QUrlPrivate::toEncoded(QUrl::FormattingOptions options) const
url += "//";
if ((options & QUrl::RemoveUserInfo) != QUrl::RemoveUserInfo) {
+ bool hasUserOrPass = false;
if (!userName.isEmpty()) {
url += encodedUserName;
- if (!(options & QUrl::RemovePassword) && !password.isEmpty()) {
- url += ':';
- url += encodedPassword;
- }
- url += '@';
+ hasUserOrPass = true;
}
+ if (!(options & QUrl::RemovePassword) && !password.isEmpty()) {
+ url += ':';
+ url += encodedPassword;
+ hasUserOrPass = true;
+ }
+ if (hasUserOrPass)
+ url += '@';
}
if (host.startsWith(QLatin1Char('['))) {
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index af684344bc..3db308f37c 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -202,7 +202,7 @@ public:
QStack<QEventLoop *> eventLoops;
QPostEventList postEventList;
bool canWait;
- QMap<int, void *> tls;
+ QVector<void *> tls;
QMutex mutex;
diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp
index 8b1f255e50..a7d53d052b 100644
--- a/src/corelib/thread/qthreadstorage.cpp
+++ b/src/corelib/thread/qthreadstorage.cpp
@@ -71,27 +71,32 @@ void qtsDebug(const char *fmt, ...)
# define DEBUG_MSG if(false)qDebug
#endif
-static QBasicAtomicInt idCounter = Q_BASIC_ATOMIC_INITIALIZER(INT_MAX);
Q_GLOBAL_STATIC(QMutex, mutex)
-typedef QMap<int, void (*)(void *)> DestructorMap;
+typedef QVector<void (*)(void *)> DestructorMap;
Q_GLOBAL_STATIC(DestructorMap, destructors)
QThreadStorageData::QThreadStorageData(void (*func)(void *))
- : id(idCounter.fetchAndAddRelaxed(-1))
{
QMutexLocker locker(mutex());
- destructors()->insert(id, func);
-
+ DestructorMap *destr = destructors();
+ for (id = 0; id < destr->count(); id++) {
+ if (destr->at(id) == 0)
+ break;
+ }
+ if (id == destr->count()) {
+ destr->append(func);
+ } else {
+ (*destr)[id] = func;
+ }
DEBUG_MSG("QThreadStorageData: Allocated id %d, destructor %p", id, func);
}
QThreadStorageData::~QThreadStorageData()
{
+ DEBUG_MSG("QThreadStorageData: Released id %d", id);
QMutexLocker locker(mutex());
if (destructors())
- destructors()->remove(id);
-
- DEBUG_MSG("QThreadStorageData: Released id %d", id);
+ (*destructors())[id] = 0;
}
void **QThreadStorageData::get() const
@@ -101,14 +106,17 @@ void **QThreadStorageData::get() const
qWarning("QThreadStorage::get: QThreadStorage can only be used with threads started with QThread");
return 0;
}
- QMap<int, void *>::const_iterator it = data->tls.constFind(id);
+ QVector<void *> &tls = data->tls;
+ if (tls.size() <= id)
+ tls.resize(id + 1);
+ void **v = &tls[id];
+
DEBUG_MSG("QThreadStorageData: Returning storage %d, data %p, for thread %p",
id,
- it != data->tls.end() ? it.value() : 0,
+ *v,
data->thread);
- // const_cast below is a bit evil - but we have to make sure not to detach here
- // otherwise we'll go bonkers in oom situations
- return it != data->tls.constEnd() && it.value() != 0 ? const_cast<void **>(&it.value()) : 0;
+
+ return *v ? v : 0;
}
void **QThreadStorageData::set(void *p)
@@ -118,51 +126,46 @@ void **QThreadStorageData::set(void *p)
qWarning("QThreadStorage::set: QThreadStorage can only be used with threads started with QThread");
return 0;
}
+ QVector<void *> &tls = data->tls;
+ if (tls.size() <= id)
+ tls.resize(id + 1);
+
+ void *&value = tls[id];
+ // delete any previous data
+ if (value != 0) {
+ DEBUG_MSG("QThreadStorageData: Deleting previous storage %d, data %p, for thread %p",
+ id,
+ value,
+ data->thread);
- QMap<int, void *>::iterator it = data->tls.find(id);
- if (it != data->tls.end()) {
- // delete any previous data
- if (it.value() != 0) {
- DEBUG_MSG("QThreadStorageData: Deleting previous storage %d, data %p, for thread %p",
- id,
- it.value(),
- data->thread);
-
- void *q = it.value();
- it.value() = 0;
-
- QMutexLocker locker(mutex());
- void (*destructor)(void *) = destructors()->value(id);
- locker.unlock();
+ QMutexLocker locker(mutex());
+ void (*destructor)(void *) = destructors()->value(id);
+ locker.unlock();
- destructor(q);
- }
+ void *q = value;
+ value = 0;
- // store new data
- it.value() = p;
- DEBUG_MSG("QThreadStorageData: Set storage %d for thread %p to %p", id, data->thread, p);
- } else {
- it = data->tls.insert(id, p);
- DEBUG_MSG("QThreadStorageData: Inserted storage %d, data %p, for thread %p", id, p, data->thread);
+ destructor(q);
}
- return &it.value();
+ // store new data
+ value = p;
+ DEBUG_MSG("QThreadStorageData: Set storage %d for thread %p to %p", id, data->thread, p);
+ return &value;
}
void QThreadStorageData::finish(void **p)
{
- QMap<int, void *> *tls = reinterpret_cast<QMap<int, void *> *>(p);
+ QVector<void *> *tls = reinterpret_cast<QVector<void *> *>(p);
if (!tls || tls->isEmpty() || !mutex())
return; // nothing to do
DEBUG_MSG("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread());
- QMap<int, void *>::iterator it = tls->begin();
- while (it != tls->end()) {
- int id = it.key();
- void *q = it.value();
- it.value() = 0;
- ++it;
+ for(int i = tls->size() - 1; i >= 0; i--) {
+ void *&value = (*tls)[i];
+ void *q = value;
+ value = 0;
if (!q) {
// data already deleted
@@ -170,16 +173,16 @@ void QThreadStorageData::finish(void **p)
}
QMutexLocker locker(mutex());
- void (*destructor)(void *) = destructors()->value(id);
+ void (*destructor)(void *) = destructors()->value(i);
locker.unlock();
if (!destructor) {
if (QThread::currentThread())
qWarning("QThreadStorage: Thread %p exited after QThreadStorage %d destroyed",
- QThread::currentThread(), id);
+ QThread::currentThread(), i);
continue;
}
- destructor(q);
+ destructor(q); //crash here might mean the thread exited after qthreadstorage was destroyed
}
tls->clear();
}
diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp
index 994da10390..ff0a93ed5d 100644
--- a/src/dbus/qdbusabstractinterface.cpp
+++ b/src/dbus/qdbusabstractinterface.cpp
@@ -561,13 +561,7 @@ void QDBusAbstractInterface::connectNotify(const char *signal)
QDBusConnectionPrivate *conn = d->connectionPrivate();
if (conn) {
- // do we know what our owner is?
- QString owner;
- if (!d->service.isEmpty() && d->currentOwner.isNull())
- owner = QLatin1String("");
- else
- owner = d->currentOwner;
- conn->connectRelay(d->service, owner, d->path, d->interface,
+ conn->connectRelay(d->service, d->path, d->interface,
this, signal);
}
}
@@ -585,7 +579,7 @@ void QDBusAbstractInterface::disconnectNotify(const char *signal)
QDBusConnectionPrivate *conn = d->connectionPrivate();
if (conn)
- conn->disconnectRelay(d->service, d->currentOwner, d->path, d->interface,
+ conn->disconnectRelay(d->service, d->path, d->interface,
this, signal);
}
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index d7088ff3ec..47893cc71a 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -619,10 +619,8 @@ bool QDBusConnection::connect(const QString &service, const QString &path, const
if (interface.isEmpty() && name.isEmpty())
return false;
- QString owner = d->getNameOwner(service); // we don't care if the owner is empty
- // it might get started later
QDBusWriteLocker locker(ConnectAction, d);
- return d->connectSignal(service, owner, path, interface, name, argumentMatch, signature, receiver, slot);
+ return d->connectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot);
}
/*!
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h
index d6f759819a..32e057caeb 100644
--- a/src/dbus/qdbusconnection_p.h
+++ b/src/dbus/qdbusconnection_p.h
@@ -119,7 +119,7 @@ public:
struct SignalHook
{
inline SignalHook() : obj(0), midx(-1) { }
- QString owner, service, path, signature;
+ QString service, path, signature;
QObject* obj;
int midx;
QList<int> params;
@@ -155,7 +155,13 @@ public:
typedef QMultiHash<QString, SignalHook> SignalHookHash;
typedef QHash<QString, QDBusMetaObject* > MetaObjectHash;
typedef QHash<QByteArray, int> MatchRefCountHash;
- typedef QHash<QString, int> WatchedServicesHash;
+
+ struct WatchedServiceData {
+ WatchedServiceData() : refcount(0) {}
+ QString owner;
+ int refcount;
+ };
+ typedef QHash<QString, WatchedServiceData> WatchedServicesHash;
public:
// public methods are entry points from other objects
@@ -177,7 +183,7 @@ public:
QDBusPendingCallPrivate *sendWithReplyAsync(const QDBusMessage &message, int timeout = -1);
int sendWithReplyAsync(const QDBusMessage &message, QObject *receiver,
const char *returnMethod, const char *errorMethod, int timeout = -1);
- bool connectSignal(const QString &service, const QString &owner, const QString &path, const QString& interface,
+ bool connectSignal(const QString &service, const QString &path, const QString& interface,
const QString &name, const QStringList &argumentMatch, const QString &signature,
QObject *receiver, const char *slot);
void connectSignal(const QString &key, const SignalHook &hook);
@@ -186,10 +192,10 @@ public:
const QString &name, const QStringList &argumentMatch, const QString &signature,
QObject *receiver, const char *slot);
void registerObject(const ObjectTreeNode *node);
- void connectRelay(const QString &service, const QString &currentOwner,
+ void connectRelay(const QString &service,
const QString &path, const QString &interface,
QDBusAbstractInterface *receiver, const char *signal);
- void disconnectRelay(const QString &service, const QString &currentOwner,
+ void disconnectRelay(const QString &service,
const QString &path, const QString &interface,
QDBusAbstractInterface *receiver, const char *signal);
@@ -223,6 +229,8 @@ private:
bool isServiceRegisteredByThread(const QString &serviceName) const;
+ QString getNameOwnerNoCache(const QString &service);
+
protected:
void customEvent(QEvent *e);
void timerEvent(QTimerEvent *e);
@@ -271,7 +279,7 @@ public:
QDBusError lastError;
QStringList serviceNames;
- WatchedServicesHash watchedServiceNames;
+ WatchedServicesHash watchedServices;
SignalHookHash signalHooks;
MatchRefCountHash matchRefCounts;
ObjectTreeNode rootNode;
@@ -284,7 +292,7 @@ public:
// static methods
static int findSlot(QObject *obj, const QByteArray &normalizedName, QList<int>& params);
static bool prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key,
- const QString &service, const QString &owner,
+ const QString &service,
const QString &path, const QString &interface, const QString &name,
const QStringList &argMatch,
QObject *receiver, const char *signal, int minMIdx,
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 40febc4638..ea02005624 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -390,7 +390,7 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v
} // extern "C"
-static QByteArray buildMatchRule(const QString &service, const QString & /*owner*/,
+static QByteArray buildMatchRule(const QString &service,
const QString &objectPath, const QString &interface,
const QString &member, const QStringList &argMatch, const QString & /*signature*/)
{
@@ -523,7 +523,7 @@ qDBusSignalFilter(DBusConnection *connection, DBusMessage *message, void *data)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
QDBusMessage amsg = QDBusMessagePrivate::fromDBusMessage(message);
- qDBusDebug() << QThread::currentThread() << "got message:" << amsg;
+ qDBusDebug() << d << "got message:" << amsg;
return d->handleMessage(amsg) ?
DBUS_HANDLER_RESULT_HANDLED :
@@ -913,7 +913,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
if (msg.isReplyRequired() && !msg.isDelayedReply()) {
if (!fail) {
// normal reply
- qDBusDebug() << QThread::currentThread() << "Automatically sending reply:" << outputArgs;
+ qDBusDebug() << this << "Automatically sending reply:" << outputArgs;
send(msg.createReply(outputArgs));
} else {
// generate internal error
@@ -947,7 +947,6 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
QDBusMetaTypeId::init();
rootNode.flags = 0;
- watchedServiceNames[QLatin1String(DBUS_SERVICE_DBUS)] = 1;
}
QDBusConnectionPrivate::~QDBusConnectionPrivate()
@@ -1179,11 +1178,15 @@ void QDBusConnectionPrivate::_q_serviceOwnerChanged(const QString &name,
{
Q_UNUSED(oldOwner);
QDBusWriteLocker locker(UpdateSignalHookOwnerAction, this);
- QMutableHashIterator<QString, SignalHook> it(signalHooks);
- it.toFront();
- while (it.hasNext())
- if (it.next().value().service == name)
- it.value().owner = newOwner;
+ WatchedServicesHash::Iterator it = watchedServices.find(name);
+ if (it == watchedServices.end())
+ return;
+ if (oldOwner != it->owner)
+ qWarning("QDBusConnection: name '%s' had owner '%s' but we thought it was '%s'",
+ qPrintable(name), qPrintable(oldOwner), qPrintable(it->owner));
+
+ qDBusDebug() << this << "Updating name" << name << "from" << oldOwner << "to" << newOwner;
+ it->owner = newOwner;
}
int QDBusConnectionPrivate::findSlot(QObject* obj, const QByteArray &normalizedName,
@@ -1201,7 +1204,7 @@ int QDBusConnectionPrivate::findSlot(QObject* obj, const QByteArray &normalizedN
}
bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key,
- const QString &service, const QString &owner,
+ const QString &service,
const QString &path, const QString &interface, const QString &name,
const QStringList &argMatch,
QObject *receiver, const char *signal, int minMIdx,
@@ -1220,7 +1223,6 @@ bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hoo
}
hook.service = service;
- hook.owner = owner; // we don't care if the service has an owner yet
hook.path = path;
hook.obj = receiver;
hook.argumentMatch = argMatch;
@@ -1245,7 +1247,7 @@ bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hoo
hook.signature += QLatin1String( QDBusMetaType::typeToSignature( hook.params.at(i) ) );
}
- hook.matchRule = buildMatchRule(service, owner, path, interface, mname, argMatch, hook.signature);
+ hook.matchRule = buildMatchRule(service, path, interface, mname, argMatch, hook.signature);
return true; // connect to this signal
}
@@ -1488,8 +1490,14 @@ void QDBusConnectionPrivate::handleSignal(const QString &key, const QDBusMessage
//qDBusDebug() << signalHooks.keys();
for ( ; it != end && it.key() == key; ++it) {
const SignalHook &hook = it.value();
- if (!hook.owner.isNull() && hook.owner != msg.service())
- continue;
+ if (!hook.service.isEmpty()) {
+ const QString owner =
+ shouldWatchService(hook.service) ?
+ watchedServices.value(hook.service).owner :
+ hook.service;
+ if (owner != msg.service())
+ continue;
+ }
if (!hook.path.isEmpty() && hook.path != msg.path())
continue;
if (!hook.signature.isEmpty() && hook.signature != msg.signature())
@@ -1652,15 +1660,18 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
}
QString busService = QLatin1String(DBUS_SERVICE_DBUS);
- connectSignal(busService, QString(), QString(), QString(), QLatin1String("NameAcquired"), QStringList(), QString(),
+ WatchedServicesHash::mapped_type &bus = watchedServices[busService];
+ bus.refcount = 1;
+ bus.owner = getNameOwnerNoCache(busService);
+ connectSignal(busService, QString(), QString(), QLatin1String("NameAcquired"), QStringList(), QString(),
this, SLOT(registerService(QString)));
- connectSignal(busService, QString(), QString(), QString(), QLatin1String("NameLost"), QStringList(), QString(),
+ connectSignal(busService, QString(), QString(), QLatin1String("NameLost"), QStringList(), QString(),
this, SLOT(unregisterService(QString)));
q_dbus_connection_add_filter(connection, qDBusSignalFilter, this, 0);
- //qDebug("base service: %s", service);
+ qDBusDebug() << this << ": connected successfully";
// schedule a dispatch:
QMetaObject::invokeMethod(this, "doDispatch", Qt::QueuedConnection);
@@ -1695,7 +1706,7 @@ void QDBusConnectionPrivate::processFinishedCall(QDBusPendingCallPrivate *call)
msg = QDBusMessagePrivate::fromDBusMessage(reply);
q_dbus_message_unref(reply);
}
- qDBusDebug() << QThread::currentThread() << "got message reply (async):" << msg;
+ qDBusDebug() << connection << "got message reply (async):" << msg;
// Check if the reply has the expected signature
call->checkReceivedSignature();
@@ -1763,7 +1774,7 @@ int QDBusConnectionPrivate::send(const QDBusMessage& message)
q_dbus_message_set_no_reply(msg, true); // the reply would not be delivered to anything
- qDBusDebug() << QThread::currentThread() << "sending message (no reply):" << message;
+ qDBusDebug() << this << "sending message (no reply):" << message;
checkThread();
bool isOk = q_dbus_connection_send(connection, msg, 0);
int serial = 0;
@@ -1795,7 +1806,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message,
return QDBusMessage::createError(err);
}
- qDBusDebug() << QThread::currentThread() << "sending message (blocking):" << message;
+ qDBusDebug() << this << "sending message (blocking):" << message;
QDBusErrorInternal error;
DBusMessage *reply = q_dbus_connection_send_with_reply_and_block(connection, msg, timeout, error);
@@ -1808,7 +1819,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message,
QDBusMessage amsg = QDBusMessagePrivate::fromDBusMessage(reply);
q_dbus_message_unref(reply);
- qDBusDebug() << QThread::currentThread() << "got message reply (blocking):" << amsg;
+ qDBusDebug() << this << "got message reply (blocking):" << amsg;
return amsg;
} else { // use the event loop
@@ -1835,7 +1846,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message,
QDBusMessage QDBusConnectionPrivate::sendWithReplyLocal(const QDBusMessage &message)
{
- qDBusDebug() << QThread::currentThread() << "sending message via local-loop:" << message;
+ qDBusDebug() << this << "sending message via local-loop:" << message;
QDBusMessage localCallMsg = QDBusMessagePrivate::makeLocal(*this, message);
bool handled = handleMessage(localCallMsg);
@@ -1862,7 +1873,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReplyLocal(const QDBusMessage &mess
}
// there is a reply
- qDBusDebug() << QThread::currentThread() << "got message via local-loop:" << localReplyMsg;
+ qDBusDebug() << this << "got message via local-loop:" << localReplyMsg;
return localReplyMsg;
}
@@ -1896,7 +1907,7 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM
return pcall;
}
- qDBusDebug() << QThread::currentThread() << "sending message (async):" << message;
+ qDBusDebug() << this << "sending message (async):" << message;
DBusPendingCall *pending = 0;
QDBusDispatchLocker locker(SendWithReplyAsyncAction, this);
@@ -1968,7 +1979,7 @@ int QDBusConnectionPrivate::sendWithReplyAsync(const QDBusMessage &message, QObj
return 1;
}
-bool QDBusConnectionPrivate::connectSignal(const QString &service, const QString &owner,
+bool QDBusConnectionPrivate::connectSignal(const QString &service,
const QString &path, const QString &interface, const QString &name,
const QStringList &argumentMatch, const QString &signature,
QObject *receiver, const char *slot)
@@ -1981,7 +1992,7 @@ bool QDBusConnectionPrivate::connectSignal(const QString &service, const QString
name2.detach();
hook.signature = signature;
- if (!prepareHook(hook, key, service, owner, path, interface, name, argumentMatch, receiver, slot, 0, false))
+ if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0, false))
return false; // don't connect
// avoid duplicating:
@@ -1990,7 +2001,6 @@ bool QDBusConnectionPrivate::connectSignal(const QString &service, const QString
for ( ; it != end && it.key() == key; ++it) {
const QDBusConnectionPrivate::SignalHook &entry = it.value();
if (entry.service == hook.service &&
- entry.owner == hook.owner &&
entry.path == hook.path &&
entry.signature == hook.signature &&
entry.obj == hook.obj &&
@@ -2035,16 +2045,19 @@ void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook
// Successfully connected the signal
// Do we need to watch for this name?
if (shouldWatchService(hook.service)) {
- WatchedServicesHash::Iterator it = watchedServiceNames.find(hook.service);
- if (it != watchedServiceNames.end()) {
+ WatchedServicesHash::mapped_type &data = watchedServices[hook.service];
+ if (data.refcount) {
// already watching
- ++it.value();
+ ++data.refcount;
} else {
// we need to watch for this service changing
QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS);
- connectSignal(dbusServerService, dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS),
+ connectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS),
QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(),
this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
+ data.owner = getNameOwnerNoCache(hook.service);
+ qDBusDebug() << this << "Watching service" << hook.service << "for owner changes (current owner:"
+ << data.owner << ")";
}
}
}
@@ -2064,7 +2077,7 @@ bool QDBusConnectionPrivate::disconnectSignal(const QString &service,
name2.detach();
hook.signature = signature;
- if (!prepareHook(hook, key, service, QString(), path, interface, name, argumentMatch, receiver, slot, 0, false))
+ if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0, false))
return false; // don't disconnect
// avoid duplicating:
@@ -2073,7 +2086,6 @@ bool QDBusConnectionPrivate::disconnectSignal(const QString &service,
for ( ; it != end && it.key() == key; ++it) {
const QDBusConnectionPrivate::SignalHook &entry = it.value();
if (entry.service == hook.service &&
- //entry.owner == hook.owner &&
entry.path == hook.path &&
entry.signature == hook.signature &&
entry.obj == hook.obj &&
@@ -2093,16 +2105,16 @@ QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it)
{
const SignalHook &hook = it.value();
- WatchedServicesHash::Iterator sit = watchedServiceNames.find(hook.service);
- if (sit != watchedServiceNames.end()) {
- if (sit.value() == 1) {
- watchedServiceNames.erase(sit);
+ WatchedServicesHash::Iterator sit = watchedServices.find(hook.service);
+ if (sit != watchedServices.end()) {
+ if (sit.value().refcount == 1) {
+ watchedServices.erase(sit);
QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS);
disconnectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS),
QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(),
this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
} else {
- --sit.value();
+ --sit.value().refcount;
}
}
@@ -2154,7 +2166,7 @@ void QDBusConnectionPrivate::registerObject(const ObjectTreeNode *node)
}
}
-void QDBusConnectionPrivate::connectRelay(const QString &service, const QString &owner,
+void QDBusConnectionPrivate::connectRelay(const QString &service,
const QString &path, const QString &interface,
QDBusAbstractInterface *receiver,
const char *signal)
@@ -2164,7 +2176,7 @@ void QDBusConnectionPrivate::connectRelay(const QString &service, const QString
SignalHook hook;
QString key;
- if (!prepareHook(hook, key, service, owner, path, interface, QString(), QStringList(), receiver, signal,
+ if (!prepareHook(hook, key, service, path, interface, QString(), QStringList(), receiver, signal,
QDBusAbstractInterface::staticMetaObject.methodCount(), true))
return; // don't connect
@@ -2175,7 +2187,6 @@ void QDBusConnectionPrivate::connectRelay(const QString &service, const QString
for ( ; it != end && it.key() == key; ++it) {
const SignalHook &entry = it.value();
if (entry.service == hook.service &&
- entry.owner == hook.owner &&
entry.path == hook.path &&
entry.signature == hook.signature &&
entry.obj == hook.obj &&
@@ -2186,7 +2197,7 @@ void QDBusConnectionPrivate::connectRelay(const QString &service, const QString
connectSignal(key, hook);
}
-void QDBusConnectionPrivate::disconnectRelay(const QString &service, const QString &owner,
+void QDBusConnectionPrivate::disconnectRelay(const QString &service,
const QString &path, const QString &interface,
QDBusAbstractInterface *receiver,
const char *signal)
@@ -2196,7 +2207,7 @@ void QDBusConnectionPrivate::disconnectRelay(const QString &service, const QStri
SignalHook hook;
QString key;
- if (!prepareHook(hook, key, service, owner, path, interface, QString(), QStringList(), receiver, signal,
+ if (!prepareHook(hook, key, service, path, interface, QString(), QStringList(), receiver, signal,
QDBusAbstractInterface::staticMetaObject.methodCount(), true))
return; // don't connect
@@ -2207,7 +2218,6 @@ void QDBusConnectionPrivate::disconnectRelay(const QString &service, const QStri
for ( ; it != end && it.key() == key; ++it) {
const SignalHook &entry = it.value();
if (entry.service == hook.service &&
- entry.owner == hook.owner &&
entry.path == hook.path &&
entry.signature == hook.signature &&
entry.obj == hook.obj &&
@@ -2225,9 +2235,23 @@ QString QDBusConnectionPrivate::getNameOwner(const QString& serviceName)
{
if (QDBusUtil::isValidUniqueConnectionName(serviceName))
return serviceName;
- if (!connection || !QDBusUtil::isValidBusName(serviceName))
+ if (!connection)
return QString();
+ {
+ // acquire a read lock for the cache
+ QReadLocker locker(&lock);
+ WatchedServicesHash::ConstIterator it = watchedServices.constFind(serviceName);
+ if (it != watchedServices.constEnd())
+ return it->owner;
+ }
+
+ // not cached
+ return getNameOwnerNoCache(serviceName);
+}
+
+QString QDBusConnectionPrivate::getNameOwnerNoCache(const QString &serviceName)
+{
QDBusMessage msg = QDBusMessage::createMethodCall(QLatin1String(DBUS_SERVICE_DBUS),
QLatin1String(DBUS_PATH_DBUS), QLatin1String(DBUS_INTERFACE_DBUS),
QLatin1String("GetNameOwner"));
diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp
index d732ad0096..28cec7df36 100644
--- a/src/dbus/qdbusmarshaller.cpp
+++ b/src/dbus/qdbusmarshaller.cpp
@@ -387,7 +387,6 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
switch (*signature) {
#ifdef __OPTIMIZE__
case DBUS_TYPE_BYTE:
- case DBUS_TYPE_BOOLEAN:
case DBUS_TYPE_INT16:
case DBUS_TYPE_UINT16:
case DBUS_TYPE_INT32:
@@ -397,6 +396,9 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
case DBUS_TYPE_DOUBLE:
qIterAppend(&iterator, ba, *signature, arg.constData());
return true;
+ case DBUS_TYPE_BOOLEAN:
+ append( arg.toBool() );
+ return true;
#else
case DBUS_TYPE_BYTE:
append( qvariant_cast<uchar>(arg) );
diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp
index ae5570febc..07bb258299 100644
--- a/src/gui/embedded/qscreen_qws.cpp
+++ b/src/gui/embedded/qscreen_qws.cpp
@@ -3150,6 +3150,7 @@ int QScreen::subScreenIndexAt(const QPoint &p) const
#if 0
#ifdef QT_LOADABLE_MODULES
+#include <dlfcn.h>
// ### needs update after driver init changes
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index fbfd8e6c10..726d57197c 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -2181,7 +2181,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
}
// Enable subfocus
- if (newVisible) {
+ if (scene && newVisible) {
QGraphicsItem *p = parent;
bool done = false;
while (p) {
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index ffe64aa884..3bb40fbe7a 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -1208,6 +1208,11 @@ void QGraphicsView::setTransformationAnchor(ViewportAnchor anchor)
{
Q_D(QGraphicsView);
d->transformationAnchor = anchor;
+
+ // Ensure mouse tracking is enabled in the case we are using AnchorUnderMouse
+ // in order to have up-to-date information for centering the view.
+ if (d->transformationAnchor == AnchorUnderMouse)
+ d->viewport->setMouseTracking(true);
}
/*!
@@ -1235,6 +1240,11 @@ void QGraphicsView::setResizeAnchor(ViewportAnchor anchor)
{
Q_D(QGraphicsView);
d->resizeAnchor = anchor;
+
+ // Ensure mouse tracking is enabled in the case we are using AnchorUnderMouse
+ // in order to have up-to-date information for centering the view.
+ if (d->resizeAnchor == AnchorUnderMouse)
+ d->viewport->setMouseTracking(true);
}
/*!
@@ -2597,9 +2607,12 @@ void QGraphicsView::setupViewport(QWidget *widget)
}
// We are only interested in mouse tracking if items
- // accept hover events or use non-default cursors.
- if (d->scene && (!d->scene->d_func()->allItemsIgnoreHoverEvents
- || !d->scene->d_func()->allItemsUseDefaultCursor)) {
+ // accept hover events or use non-default cursors or if
+ // AnchorUnderMouse is used as transformation or resize anchor.
+ if ((d->scene && (!d->scene->d_func()->allItemsIgnoreHoverEvents
+ || !d->scene->d_func()->allItemsUseDefaultCursor))
+ || d->transformationAnchor == AnchorUnderMouse
+ || d->resizeAnchor == AnchorUnderMouse) {
widget->setMouseTracking(true);
}
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index 074f3eb565..7580446b38 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -471,7 +471,6 @@ QImageReaderPrivate::QImageReaderPrivate(QImageReader *qq)
handler = 0;
quality = -1;
imageReaderError = QImageReader::UnknownError;
- errorString = QLatin1String(QT_TRANSLATE_NOOP(QImageReader, "Unknown error"));
q = qq;
}
@@ -1214,11 +1213,12 @@ bool QImageReader::jumpToImage(int imageNumber)
}
/*!
- For image formats that support animation, this function returns
- the number of times the animation should loop. Otherwise, it
- returns -1.
+ For image formats that support animation, this function returns the number
+ of times the animation should loop. If this function returns -1, it can
+ either mean the animation should loop forever, or that an error occurred.
+ If an error occurred, canRead() will return false.
- \sa supportsAnimation(), QImageIOHandler::loopCount()
+ \sa supportsAnimation(), QImageIOHandler::loopCount(), canRead()
*/
int QImageReader::loopCount() const
{
@@ -1228,13 +1228,13 @@ int QImageReader::loopCount() const
}
/*!
- For image formats that support animation, this function returns
- the total number of images in the animation.
+ For image formats that support animation, this function returns the total
+ number of images in the animation. If the format does not support
+ animation, 0 is returned.
- Certain animation formats do not support this feature, in which
- case 0 is returned.
+ This function returns -1 if an error occurred.
- \sa supportsAnimation(), QImageIOHandler::imageCount()
+ \sa supportsAnimation(), QImageIOHandler::imageCount(), canRead()
*/
int QImageReader::imageCount() const
{
@@ -1244,11 +1244,13 @@ int QImageReader::imageCount() const
}
/*!
- For image formats that support animation, this function returns
- the number of milliseconds to wait until displaying the next frame
- in the animation. Otherwise, 0 is returned.
+ For image formats that support animation, this function returns the number
+ of milliseconds to wait until displaying the next frame in the animation.
+ If the image format doesn't support animation, 0 is returned.
+
+ This function returns -1 if an error occurred.
- \sa supportsAnimation(), QImageIOHandler::nextImageDelay()
+ \sa supportsAnimation(), QImageIOHandler::nextImageDelay(), canRead()
*/
int QImageReader::nextImageDelay() const
{
@@ -1258,11 +1260,13 @@ int QImageReader::nextImageDelay() const
}
/*!
- For image formats that support animation, this function returns
- the sequence number of the current frame. Otherwise, -1 is
- returned.
+ For image formats that support animation, this function returns the
+ sequence number of the current frame. If the image format doesn't support
+ animation, 0 is returned.
+
+ This function returns -1 if an error occurred.
- \sa supportsAnimation(), QImageIOHandler::currentImageNumber()
+ \sa supportsAnimation(), QImageIOHandler::currentImageNumber(), canRead()
*/
int QImageReader::currentImageNumber() const
{
@@ -1302,6 +1306,8 @@ QImageReader::ImageReaderError QImageReader::error() const
*/
QString QImageReader::errorString() const
{
+ if (d->errorString.isEmpty())
+ return QLatin1String(QT_TRANSLATE_NOOP(QImageReader, "Unknown error"));
return d->errorString;
}
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 617cfe5f6b..7e4597e052 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -831,14 +831,13 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers
if (QPixmapCache::find(key, *this))
return true;
- if (!data)
- data = QPixmapData::create(0, 0, QPixmapData::PixmapType);
-
- if (data->fromFile(fileName, format, flags)) {
+ QPixmapData *tmp = QPixmapData::create(0, 0, QPixmapData::PixmapType);
+ if (tmp->fromFile(fileName, format, flags)) {
+ data = tmp;
QPixmapCache::insert(key, *this);
return true;
}
-
+ delete tmp;
return false;
}
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index 1b01e6f3bb..3c1d7e9a2d 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -375,7 +375,7 @@ int QRasterPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
case QPaintDevice::PdmWidthMM:
return qRound(d->width * 25.4 / qt_defaultDpiX());
case QPaintDevice::PdmHeightMM:
- return qRound(d->width * 25.4 / qt_defaultDpiY());
+ return qRound(d->height * 25.4 / qt_defaultDpiY());
case QPaintDevice::PdmNumColors:
return d->colortable.size();
case QPaintDevice::PdmDepth:
diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp
index caa07524c1..939b86d7b0 100644
--- a/src/gui/image/qpixmapfilter.cpp
+++ b/src/gui/image/qpixmapfilter.cpp
@@ -602,7 +602,7 @@ QRectF QPixmapBlurFilter::boundingRectFor(const QRectF &rect) const
}
template <int shift>
-static inline int static_shift(int value)
+inline int qt_static_shift(int value)
{
if (shift == 0)
return value;
@@ -613,15 +613,15 @@ static inline int static_shift(int value)
}
template<int aprec, int zprec>
-static inline void blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, int alpha)
+inline void qt_blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, int alpha)
{
QRgb *pixel = (QRgb *)bptr;
#define Z_MASK (0xff << zprec)
- const int A_zprec = static_shift<zprec - 24>(*pixel) & Z_MASK;
- const int R_zprec = static_shift<zprec - 16>(*pixel) & Z_MASK;
- const int G_zprec = static_shift<zprec - 8>(*pixel) & Z_MASK;
- const int B_zprec = static_shift<zprec>(*pixel) & Z_MASK;
+ const int A_zprec = qt_static_shift<zprec - 24>(*pixel) & Z_MASK;
+ const int R_zprec = qt_static_shift<zprec - 16>(*pixel) & Z_MASK;
+ const int G_zprec = qt_static_shift<zprec - 8>(*pixel) & Z_MASK;
+ const int B_zprec = qt_static_shift<zprec>(*pixel) & Z_MASK;
#undef Z_MASK
const int zR_zprec = zR >> aprec;
@@ -636,17 +636,17 @@ static inline void blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, in
#define ZA_MASK (0xff << (zprec + aprec))
*pixel =
- static_shift<24 - zprec - aprec>(zA & ZA_MASK)
- | static_shift<16 - zprec - aprec>(zR & ZA_MASK)
- | static_shift<8 - zprec - aprec>(zG & ZA_MASK)
- | static_shift<-zprec - aprec>(zB & ZA_MASK);
+ qt_static_shift<24 - zprec - aprec>(zA & ZA_MASK)
+ | qt_static_shift<16 - zprec - aprec>(zR & ZA_MASK)
+ | qt_static_shift<8 - zprec - aprec>(zG & ZA_MASK)
+ | qt_static_shift<-zprec - aprec>(zB & ZA_MASK);
#undef ZA_MASK
}
const int alphaIndex = (QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3);
template<int aprec, int zprec>
-static inline void blurinner_alphaOnly(uchar *bptr, int &z, int alpha)
+inline void qt_blurinner_alphaOnly(uchar *bptr, int &z, int alpha)
{
const int A_zprec = int(*(bptr)) << zprec;
const int z_zprec = z >> aprec;
@@ -655,7 +655,7 @@ static inline void blurinner_alphaOnly(uchar *bptr, int &z, int alpha)
}
template<int aprec, int zprec, bool alphaOnly>
-static inline void blurrow(QImage & im, int line, int alpha)
+inline void qt_blurrow(QImage & im, int line, int alpha)
{
uchar *bptr = im.scanLine(line);
@@ -668,9 +668,9 @@ static inline void blurrow(QImage & im, int line, int alpha)
const int im_width = im.width();
for (int index = 0; index < im_width; ++index) {
if (alphaOnly)
- blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha);
+ qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha);
else
- blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha);
+ qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha);
bptr += stride;
}
@@ -679,9 +679,9 @@ static inline void blurrow(QImage & im, int line, int alpha)
for (int index = im_width - 2; index >= 0; --index) {
bptr -= stride;
if (alphaOnly)
- blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha);
+ qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha);
else
- blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha);
+ qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha);
}
}
@@ -723,7 +723,7 @@ void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transp
int img_height = img.height();
for (int row = 0; row < img_height; ++row) {
for (int i = 0; i <= improvedQuality; ++i)
- blurrow<aprec, zprec, alphaOnly>(img, row, alpha);
+ qt_blurrow<aprec, zprec, alphaOnly>(img, row, alpha);
}
QImage temp(img.height(), img.width(), img.format());
@@ -756,7 +756,7 @@ void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transp
img_height = temp.height();
for (int row = 0; row < img_height; ++row) {
for (int i = 0; i <= improvedQuality; ++i)
- blurrow<aprec, zprec, alphaOnly>(temp, row, alpha);
+ qt_blurrow<aprec, zprec, alphaOnly>(temp, row, alpha);
}
if (transposed == 0) {
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index 14c863b2e3..1de0f32ff6 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -67,6 +67,9 @@ QT_BEGIN_NAMESPACE
# define Q_INTERNAL_WIN_NO_THROW
#endif
+// avoid going through QImage::scanLine() which calls detach
+#define FAST_SCAN_LINE(data, bpl, y) (data + (y) * bpl)
+
/*
All PNG files load to the minimal QImage equivalent.
@@ -510,7 +513,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage)
&& outImage->format() == QImage::Format_Indexed8) {
int color_table_size = outImage->colorCount();
for (int y=0; y<(int)height; ++y) {
- uchar *p = outImage->scanLine(y);
+ uchar *p = FAST_SCAN_LINE(data, bpl, y);
uchar *end = p + width;
while (p < end) {
if (*p >= color_table_size)
diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp
index 8ec9efbe08..f2d51f7e03 100644
--- a/src/gui/image/qppmhandler.cpp
+++ b/src/gui/image/qppmhandler.cpp
@@ -264,7 +264,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
bool gray = format == "pgm";
if (format == "pbm") {
- image = image.convertToFormat(QImage::Format_MonoLSB);
+ image = image.convertToFormat(QImage::Format_Mono);
} else if (image.depth() == 1) {
image = image.convertToFormat(QImage::Format_Indexed8);
} else {
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp
index fc82f30619..646a3a1352 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/gui/itemviews/qsortfilterproxymodel.cpp
@@ -734,6 +734,33 @@ void QSortFilterProxyModelPrivate::source_items_inserted(
}
}
+ if (model->rowCount(source_parent) == delta_item_count) {
+ // Items were inserted where there were none before.
+ // If it was new rows make sure to create mappings for columns so that a
+ // valid mapping can be retreived later and vice-versa.
+
+ QVector<int> &orthogonal_proxy_to_source = (orient == Qt::Horizontal) ? m->source_rows : m->source_columns;
+ QVector<int> &orthogonal_source_to_proxy = (orient == Qt::Horizontal) ? m->proxy_rows : m->proxy_columns;
+
+ if (orthogonal_source_to_proxy.isEmpty()) {
+ const int ortho_end = (orient == Qt::Horizontal) ? model->rowCount(source_parent) : model->columnCount(source_parent);
+
+ for (int ortho_item = 0; ortho_item < ortho_end; ++ortho_item) {
+ if ((orient == Qt::Horizontal) ? q->filterAcceptsRow(ortho_item, source_parent)
+ : q->filterAcceptsColumn(ortho_item, source_parent)) {
+ orthogonal_proxy_to_source.append(ortho_item);
+ }
+ }
+ orthogonal_source_to_proxy.resize(orthogonal_proxy_to_source.size());
+
+ if (orient == Qt::Horizontal) {
+ // We're reacting to columnsInserted, but we've just inserted new rows. Sort them.
+ sort_source_rows(orthogonal_proxy_to_source, source_parent);
+ }
+ build_source_to_proxy_mapping(orthogonal_proxy_to_source, orthogonal_source_to_proxy);
+ }
+ }
+
// Sort and insert the items
if (orient == Qt::Vertical) // Only sort rows
sort_source_rows(source_items, source_parent);
@@ -1171,9 +1198,10 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged()
{
Q_Q(QSortFilterProxyModel);
saved_persistent_indexes.clear();
+ emit q->layoutAboutToBeChanged();
if (persistent.indexes.isEmpty())
return;
- emit q->layoutAboutToBeChanged();
+
saved_persistent_indexes = store_persistent_indexes();
}
@@ -1181,7 +1209,8 @@ void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged()
{
Q_Q(QSortFilterProxyModel);
if (saved_persistent_indexes.isEmpty()) {
- q->invalidate();
+ clear_mapping();
+ emit q->layoutChanged();
return;
}
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index bd13423d91..4165c950ad 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -2096,7 +2096,11 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
if (prev) {
#ifdef QT_KEYPAD_NAVIGATION
if (QApplication::keypadNavigationEnabled()) {
- if (prev->hasEditFocus() && reason != Qt::PopupFocusReason)
+ if (prev->hasEditFocus() && reason != Qt::PopupFocusReason
+#ifdef Q_OS_SYMBIAN
+ && reason != Qt::ActiveWindowFocusReason
+#endif
+ )
prev->setEditFocus(false);
}
#endif
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 6c067460c2..3352dbd199 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -349,7 +349,9 @@ extern "C" {
// since we accepted the drag enter event, the widget expects
// future drage move events.
// ### check if we need to treat this like the drag enter event.
- nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDEEvent.dropAction());
+ nsActions = NSDragOperationNone;
+ // Save as ignored in the answer rect.
+ qDMEvent.setDropAction(Qt::IgnoreAction);
} else {
nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDMEvent.dropAction());
}
@@ -357,7 +359,6 @@ extern "C" {
return nsActions;
}
}
-
- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender
{
NSPoint windowPoint = [sender draggingLocation];
@@ -402,13 +403,15 @@ extern "C" {
qDMEvent.setDropAction(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction);
qDMEvent.accept();
QApplication::sendEvent(qwidget, &qDMEvent);
- qt_mac_copy_answer_rect(qDMEvent);
NSDragOperation operation = qt_mac_mapDropAction(qDMEvent.dropAction());
if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction) {
// ignore this event (we will still receive further notifications)
operation = NSDragOperationNone;
+ // Save as ignored in the answer rect.
+ qDMEvent.setDropAction(Qt::IgnoreAction);
}
+ qt_mac_copy_answer_rect(qDMEvent);
return operation;
}
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index e551a1d06d..81f38ec150 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -9774,13 +9774,12 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
}
#endif
- if (newParent) {
- if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {
+ if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {
+ if (newParent)
oldBs->removeDirtyWidget(this);
- // Move the widget and all its static children from
- // the old backing store to the new one.
- oldBs->moveStaticWidgets(this);
- }
+ // Move the widget and all its static children from
+ // the old backing store to the new one.
+ oldBs->moveStaticWidgets(this);
}
if ((QApplicationPrivate::app_compile_version < 0x040200
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 7dc4d85298..0213af9680 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -4493,10 +4493,14 @@ void QWidgetPrivate::createTLSysExtra()
void QWidgetPrivate::deleteTLSysExtra()
{
#ifndef QT_MAC_USE_COCOA
- if(extra->topextra->group) {
+ if (extra->topextra->group) {
qt_mac_release_window_group(extra->topextra->group);
extra->topextra->group = 0;
}
+ if (extra->topextra->windowIcon) {
+ ReleaseIconRef(extra->topextra->windowIcon);
+ extra->topextra->windowIcon = 0;
+ }
#endif
}
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 628a109c90..a6cc9c7ec9 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -379,6 +379,13 @@ symbian {
QMAKE_CXXFLAGS.ARMCC *= -O3
}
+neon {
+ DEFINES += QT_HAVE_NEON
+ HEADERS += painting/qdrawhelper_neon_p.h
+ SOURCES += painting/qdrawhelper_neon.cpp
+ QMAKE_CXXFLAGS *= -mfpu=neon
+}
+
contains(QT_CONFIG, zlib) {
INCLUDEPATH += ../3rdparty/zlib
} else:!contains(QT_CONFIG, no-zlib) {
diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp
index 1d15dac455..81d1515d7c 100644
--- a/src/gui/painting/qblendfunctions.cpp
+++ b/src/gui/painting/qblendfunctions.cpp
@@ -605,7 +605,7 @@ static void qt_blend_argb32_on_argb32(uchar *destPixels, int dbpl,
}
-static void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl,
+void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl,
const uchar *srcPixels, int sbpl,
int w, int h,
int const_alpha)
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 23236ece20..84cf5cc05a 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -44,6 +44,7 @@
#include <private/qpainter_p.h>
#include <private/qdrawhelper_x86_p.h>
#include <private/qdrawhelper_armv6_p.h>
+#include <private/qdrawhelper_neon_p.h>
#include <private/qmath_p.h>
#include <qmath.h>
@@ -7725,7 +7726,8 @@ enum CPUFeatures {
SSE = 0x10,
SSE2 = 0x20,
CMOV = 0x40,
- IWMMXT = 0x80
+ IWMMXT = 0x80,
+ NEON = 0x100
};
static uint detectCPUFeatures()
@@ -7751,6 +7753,9 @@ static uint detectCPUFeatures()
// runtime detection only available when running as a previlegied process
static const bool doIWMMXT = !qgetenv("QT_NO_IWMMXT").toInt();
return doIWMMXT ? IWMMXT : 0;
+#elif defined(QT_HAVE_NEON)
+ static const bool doNEON = !qgetenv("QT_NO_NEON").toInt();
+ return doNEON ? NEON : 0;
#else
uint features = 0;
#if defined(__x86_64__) || defined(Q_OS_WIN64)
@@ -8122,7 +8127,14 @@ void qInitDrawhelperAsm()
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_armv6;
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_armv6;
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_armv6;
-#endif // Q_CC_RVCT && QT_HAVE_ARMV6
+#elif defined(QT_HAVE_NEON)
+ if (features & NEON) {
+ qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon;
+ qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon;
+ qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_neon;
+ qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_neon;
+ }
+#endif
if (functionForModeSolidAsm) {
const int destinationMode = QPainter::CompositionMode_Destination;
diff --git a/src/gui/painting/qdrawhelper_neon.cpp b/src/gui/painting/qdrawhelper_neon.cpp
new file mode 100644
index 0000000000..7fe11bf4e3
--- /dev/null
+++ b/src/gui/painting/qdrawhelper_neon.cpp
@@ -0,0 +1,260 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qdrawhelper_p.h>
+
+#ifdef QT_HAVE_NEON
+
+#include <private/qdrawhelper_neon_p.h>
+#include <arm_neon.h>
+
+QT_BEGIN_NAMESPACE
+
+static inline int16x8_t qvdiv_255_s16(int16x8_t x, int16x8_t half)
+{
+ // result = (x + (x >> 8) + 0x80) >> 8
+
+ const int16x8_t temp = vshrq_n_s16(x, 8); // x >> 8
+ const int16x8_t sum_part = vaddq_s16(x, half); // x + 0x80
+ const int16x8_t sum = vaddq_s16(temp, sum_part);
+
+ return vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(sum), 8));
+}
+
+static inline int16x8_t qvbyte_mul_s16(int16x8_t x, int16x8_t alpha, int16x8_t half)
+{
+ // t = qRound(x * alpha / 255.0)
+
+ const int16x8_t t = vmulq_s16(x, alpha); // t
+ return qvdiv_255_s16(t, half);
+}
+
+static inline int16x8_t qvinterpolate_pixel_255(int16x8_t x, int16x8_t a, int16x8_t y, int16x8_t b, int16x8_t half)
+{
+ // t = x * a + y * b
+
+ const int16x8_t ta = vmulq_s16(x, a);
+ const int16x8_t tb = vmulq_s16(y, b);
+
+ return qvdiv_255_s16(vaddq_s16(ta, tb), half);
+}
+
+static inline int16x8_t qvsource_over_s16(int16x8_t src16, int16x8_t dst16, int16x8_t half, int16x8_t full)
+{
+ const int16x4_t alpha16_high = vdup_lane_s16(vget_high_s16(src16), 3);
+ const int16x4_t alpha16_low = vdup_lane_s16(vget_low_s16(src16), 3);
+
+ const int16x8_t alpha16 = vsubq_s16(full, vcombine_s16(alpha16_low, alpha16_high));
+
+ return vaddq_s16(src16, qvbyte_mul_s16(dst16, alpha16, half));
+}
+
+void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha)
+{
+ const uint *src = (const uint *) srcPixels;
+ uint *dst = (uint *) destPixels;
+ int16x8_t half = vdupq_n_s16(0x80);
+ int16x8_t full = vdupq_n_s16(0xff);
+ if (const_alpha == 256) {
+ for (int y = 0; y < h; ++y) {
+ int x = 0;
+ for (; x < w-3; x += 4) {
+ int32x4_t src32 = vld1q_s32((int32_t *)&src[x]);
+ if ((src[x] & src[x+1] & src[x+2] & src[x+3]) >= 0xff000000) {
+ // all opaque
+ vst1q_s32((int32_t *)&dst[x], src32);
+ } else if (src[x] | src[x+1] | src[x+2] | src[x+3]) {
+ int32x4_t dst32 = vld1q_s32((int32_t *)&dst[x]);
+
+ const uint8x16_t src8 = vreinterpretq_u8_s32(src32);
+ const uint8x16_t dst8 = vreinterpretq_u8_s32(dst32);
+
+ const uint8x8_t src8_low = vget_low_u8(src8);
+ const uint8x8_t dst8_low = vget_low_u8(dst8);
+
+ const uint8x8_t src8_high = vget_high_u8(src8);
+ const uint8x8_t dst8_high = vget_high_u8(dst8);
+
+ const int16x8_t src16_low = vreinterpretq_s16_u16(vmovl_u8(src8_low));
+ const int16x8_t dst16_low = vreinterpretq_s16_u16(vmovl_u8(dst8_low));
+
+ const int16x8_t src16_high = vreinterpretq_s16_u16(vmovl_u8(src8_high));
+ const int16x8_t dst16_high = vreinterpretq_s16_u16(vmovl_u8(dst8_high));
+
+ const int16x8_t result16_low = qvsource_over_s16(src16_low, dst16_low, half, full);
+ const int16x8_t result16_high = qvsource_over_s16(src16_high, dst16_high, half, full);
+
+ const int32x2_t result32_low = vreinterpret_s32_s8(vmovn_s16(result16_low));
+ const int32x2_t result32_high = vreinterpret_s32_s8(vmovn_s16(result16_high));
+
+ vst1q_s32((int32_t *)&dst[x], vcombine_s32(result32_low, result32_high));
+ }
+ }
+ for (; x<w; ++x) {
+ uint s = src[x];
+ if (s >= 0xff000000)
+ dst[x] = s;
+ else if (s != 0)
+ dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
+ }
+ dst = (quint32 *)(((uchar *) dst) + dbpl);
+ src = (const quint32 *)(((const uchar *) src) + sbpl);
+ }
+ } else if (const_alpha != 0) {
+ const_alpha = (const_alpha * 255) >> 8;
+ int16x8_t const_alpha16 = vdupq_n_s16(const_alpha);
+ for (int y = 0; y < h; ++y) {
+ int x = 0;
+ for (; x < w-3; x += 4) {
+ if (src[x] | src[x+1] | src[x+2] | src[x+3]) {
+ int32x4_t src32 = vld1q_s32((int32_t *)&src[x]);
+ int32x4_t dst32 = vld1q_s32((int32_t *)&dst[x]);
+
+ const uint8x16_t src8 = vreinterpretq_u8_s32(src32);
+ const uint8x16_t dst8 = vreinterpretq_u8_s32(dst32);
+
+ const uint8x8_t src8_low = vget_low_u8(src8);
+ const uint8x8_t dst8_low = vget_low_u8(dst8);
+
+ const uint8x8_t src8_high = vget_high_u8(src8);
+ const uint8x8_t dst8_high = vget_high_u8(dst8);
+
+ const int16x8_t src16_low = vreinterpretq_s16_u16(vmovl_u8(src8_low));
+ const int16x8_t dst16_low = vreinterpretq_s16_u16(vmovl_u8(dst8_low));
+
+ const int16x8_t src16_high = vreinterpretq_s16_u16(vmovl_u8(src8_high));
+ const int16x8_t dst16_high = vreinterpretq_s16_u16(vmovl_u8(dst8_high));
+
+ const int16x8_t srcalpha16_low = qvbyte_mul_s16(src16_low, const_alpha16, half);
+ const int16x8_t srcalpha16_high = qvbyte_mul_s16(src16_high, const_alpha16, half);
+
+ const int16x8_t result16_low = qvsource_over_s16(srcalpha16_low, dst16_low, half, full);
+ const int16x8_t result16_high = qvsource_over_s16(srcalpha16_high, dst16_high, half, full);
+
+ const int32x2_t result32_low = vreinterpret_s32_s8(vmovn_s16(result16_low));
+ const int32x2_t result32_high = vreinterpret_s32_s8(vmovn_s16(result16_high));
+
+ vst1q_s32((int32_t *)&dst[x], vcombine_s32(result32_low, result32_high));
+ }
+ }
+ for (; x<w; ++x) {
+ uint s = src[x];
+ if (s != 0) {
+ s = BYTE_MUL(s, const_alpha);
+ dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
+ }
+ }
+ dst = (quint32 *)(((uchar *) dst) + dbpl);
+ src = (const quint32 *)(((const uchar *) src) + sbpl);
+ }
+ }
+}
+
+// qblendfunctions.cpp
+void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha);
+
+void qt_blend_rgb32_on_rgb32_neon(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha)
+{
+ if (const_alpha != 256) {
+ if (const_alpha != 0) {
+ const uint *src = (const uint *) srcPixels;
+ uint *dst = (uint *) destPixels;
+ int16x8_t half = vdupq_n_s16(0x80);
+ const_alpha = (const_alpha * 255) >> 8;
+ int one_minus_const_alpha = 255 - const_alpha;
+ int16x8_t const_alpha16 = vdupq_n_s16(const_alpha);
+ int16x8_t one_minus_const_alpha16 = vdupq_n_s16(255 - const_alpha);
+ for (int y = 0; y < h; ++y) {
+ int x = 0;
+ for (; x < w-3; x += 4) {
+ int32x4_t src32 = vld1q_s32((int32_t *)&src[x]);
+ int32x4_t dst32 = vld1q_s32((int32_t *)&dst[x]);
+
+ const uint8x16_t src8 = vreinterpretq_u8_s32(src32);
+ const uint8x16_t dst8 = vreinterpretq_u8_s32(dst32);
+
+ const uint8x8_t src8_low = vget_low_u8(src8);
+ const uint8x8_t dst8_low = vget_low_u8(dst8);
+
+ const uint8x8_t src8_high = vget_high_u8(src8);
+ const uint8x8_t dst8_high = vget_high_u8(dst8);
+
+ const int16x8_t src16_low = vreinterpretq_s16_u16(vmovl_u8(src8_low));
+ const int16x8_t dst16_low = vreinterpretq_s16_u16(vmovl_u8(dst8_low));
+
+ const int16x8_t src16_high = vreinterpretq_s16_u16(vmovl_u8(src8_high));
+ const int16x8_t dst16_high = vreinterpretq_s16_u16(vmovl_u8(dst8_high));
+
+ const int16x8_t result16_low = qvinterpolate_pixel_255(src16_low, const_alpha16, dst16_low, one_minus_const_alpha16, half);
+ const int16x8_t result16_high = qvinterpolate_pixel_255(src16_high, const_alpha16, dst16_high, one_minus_const_alpha16, half);
+
+ const int32x2_t result32_low = vreinterpret_s32_s8(vmovn_s16(result16_low));
+ const int32x2_t result32_high = vreinterpret_s32_s8(vmovn_s16(result16_high));
+
+ vst1q_s32((int32_t *)&dst[x], vcombine_s32(result32_low, result32_high));
+ }
+ for (; x<w; ++x) {
+ uint s = src[x];
+ s = BYTE_MUL(s, const_alpha);
+ dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha);
+ }
+ dst = (quint32 *)(((uchar *) dst) + dbpl);
+ src = (const quint32 *)(((const uchar *) src) + sbpl);
+ }
+ }
+ } else {
+ qt_blend_rgb32_on_rgb32(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_HAVE_NEON
+
diff --git a/src/gui/painting/qdrawhelper_neon_p.h b/src/gui/painting/qdrawhelper_neon_p.h
new file mode 100644
index 0000000000..cb9a0d69ee
--- /dev/null
+++ b/src/gui/painting/qdrawhelper_neon_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDRAWHELPER_NEON_P_H
+#define QDRAWHELPER_NEON_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qdrawhelper_p.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifdef QT_HAVE_NEON
+
+void qt_blend_argb32_on_argb32_neon(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha);
+
+void qt_blend_rgb32_on_rgb32_neon(uchar *destPixels, int dbpl,
+ const uchar *srcPixels, int sbpl,
+ int w, int h,
+ int const_alpha);
+
+#endif // QT_HAVE_NEON
+
+QT_END_NAMESPACE
+
+#endif // QDRAWHELPER_NEON_P_H
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index ed86f5a044..bcc993abd3 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -310,8 +310,8 @@ QColor QS60StylePrivate::stateColor(const QColor &color, const QStyleOption *opt
QColor hsvColor = retColor.toHsv();
int colorSat = hsvColor.saturation();
int colorVal = hsvColor.value();
- colorSat = (colorSat!=0) ? (colorSat>>1) : 128;
- colorVal = (colorVal!=0) ? (colorVal>>1) : 128;
+ colorSat = (colorSat != 0) ? (colorSat >> 1) : 128;
+ colorVal = (colorVal != 0) ? (colorVal >> 1) : 128;
hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal);
retColor = hsvColor.toRgb();
}
@@ -339,7 +339,7 @@ QColor QS60StylePrivate::lighterColor(const QColor &baseColor)
bool QS60StylePrivate::drawsOwnThemeBackground(const QWidget *widget)
{
- return qobject_cast<const QDialog *> (widget);
+ return (widget ? (widget->windowType() == Qt::Dialog) : false);
}
QFont QS60StylePrivate::s60Font(
@@ -372,7 +372,6 @@ void QS60StylePrivate::clearCaches(CacheClearReason reason)
case CC_LayoutChange:
// when layout changes, the colors remain in cache, but graphics and fonts can change
m_mappedFontsCache.clear();
- deleteBackground();
QPixmapCache::clear();
break;
case CC_ThemeChange:
@@ -400,10 +399,10 @@ QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const
if (!cachedColorExists) {
const int frameCornerWidth = pixelMetric(PM_Custom_FrameCornerWidth);
const int frameCornerHeight = pixelMetric(PM_Custom_FrameCornerHeight);
- Q_ASSERT(2*frameCornerWidth<32);
- Q_ASSERT(2*frameCornerHeight<32);
+ Q_ASSERT(2 * frameCornerWidth < 32);
+ Q_ASSERT(2 * frameCornerHeight < 32);
- const QImage frameImage = QS60StylePrivate::frame(frame, QSize(32,32)).toImage();
+ const QImage frameImage = QS60StylePrivate::frame(frame, QSize(32, 32)).toImage();
Q_ASSERT(frameImage.bytesPerLine() > 0);
if (frameImage.isNull())
return Qt::black;
@@ -418,14 +417,14 @@ QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const
int skips = 0;
int estimations = 0;
- const int topBorderLastPixel = frameCornerHeight*frameImage.width()-1;
- const int bottomBorderFirstPixel = frameImage.width()*frameImage.height()-frameCornerHeight*frameImage.width()-1;
- const int rightBorderFirstPixel = frameImage.width()-frameCornerWidth;
+ const int topBorderLastPixel = frameCornerHeight*frameImage.width() - 1;
+ const int bottomBorderFirstPixel = frameImage.width() * frameImage.height() - frameCornerHeight*frameImage.width() - 1;
+ const int rightBorderFirstPixel = frameImage.width() - frameCornerWidth;
const int leftBorderLastPixel = frameCornerWidth;
while ((skips + estimations) < pixels) {
- if ((skips+estimations) > topBorderLastPixel &&
- (skips+estimations) < bottomBorderFirstPixel) {
+ if ((skips + estimations) > topBorderLastPixel &&
+ (skips + estimations) < bottomBorderFirstPixel) {
for (int rowIndex = 0; rowIndex < frameImage.width(); rowIndex++) {
if (rowIndex > leftBorderLastPixel &&
rowIndex < rightBorderFirstPixel) {
@@ -530,18 +529,18 @@ void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start,
endRect = startRect.translated(rect.width() - startRect.width(), 0);
middleRect.adjust(startRect.width(), 0, -startRect.width(), 0);
if (startRect.bottomRight().x() > endRect.topLeft().x()) {
- const int overlap = (startRect.bottomRight().x() - endRect.topLeft().x())>>1;
- startRect.setWidth(startRect.width()-overlap);
- endRect.adjust(overlap,0,0,0);
+ const int overlap = (startRect.bottomRight().x() - endRect.topLeft().x()) >> 1;
+ startRect.setWidth(startRect.width() - overlap);
+ endRect.adjust(overlap, 0, 0, 0);
}
} else {
startRect.setHeight(qMin((rect.height() >> 1) - 1, startRect.height()));
endRect = startRect.translated(0, rect.height() - startRect.height());
middleRect.adjust(0, startRect.height(), 0, -startRect.height());
if (startRect.topRight().y() > endRect.bottomLeft().y()) {
- const int overlap = (startRect.topRight().y() - endRect.bottomLeft().y())>>1;
- startRect.setHeight(startRect.height()-overlap);
- endRect.adjust(0,overlap,0,0);
+ const int overlap = (startRect.topRight().y() - endRect.bottomLeft().y()) >> 1;
+ startRect.setHeight(startRect.height() - overlap);
+ endRect.adjust(0, overlap, 0, 0);
}
}
@@ -809,13 +808,13 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag
case QS60StyleEnums::SP_QgnGrafTabActiveL:
//Returned QSize for tabs must not be square, but narrow rectangle with width:height
//ratio of 1:2 for horizontal tab bars (and 2:1 for vertical ones).
- result.setWidth(result.height()>>1);
+ result.setWidth(result.height() >> 1);
break;
case QS60StyleEnums::SP_QgnGrafNsliderEndLeft:
case QS60StyleEnums::SP_QgnGrafNsliderEndRight:
case QS60StyleEnums::SP_QgnGrafNsliderMiddle:
- result.setWidth(result.height()>>1);
+ result.setWidth(result.height() >> 1);
break;
case QS60StyleEnums::SP_QgnGrafNsliderMarker:
@@ -992,10 +991,11 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
buttonOption.QStyleOption::operator=(*cmb);
const int maxHeight = cmbxFrame.height();
const int maxWidth = cmbxFrame.width() - cmbxEditField.width();
- const int topLeftPoint = direction ? cmbxEditField.right()+1 : cmbxEditField.left()+1-maxWidth;
+ const int topLeftPoint = direction ?
+ (cmbxEditField.right() + 1) : (cmbxEditField.left() + 1 - maxWidth);
const QRect buttonRect(topLeftPoint, cmbxEditField.top(), maxWidth, maxHeight);
buttonOption.rect = buttonRect;
- buttonOption.state = cmb->state & (State_Enabled | State_MouseOver);
+ buttonOption.state = cmb->state;
drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget);
// draw label background - label itself is drawn separately
@@ -1381,9 +1381,9 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
const QModelIndex index = vopt->index;
//todo: Draw cell background only once - for the first cell.
QStyleOptionViewItemV4 voptAdj2 = voptAdj;
- const QModelIndex indexFirst = itemView->model()->index(0,0);
+ const QModelIndex indexFirst = itemView->model()->index(0, 0);
const QModelIndex indexLast = itemView->model()->index(
- itemView->model()->rowCount()-1,itemView->model()->columnCount()-1);
+ itemView->model()->rowCount() - 1, itemView->model()->columnCount() -1);
if (itemView->viewport())
voptAdj2.rect = QRect( itemView->visualRect(indexFirst).topLeft(),
itemView->visualRect(indexLast).bottomRight()).intersect(itemView->viewport()->rect());
@@ -1571,16 +1571,16 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
f.setPointSizeF(f.pointSizeF() * KTabFontMul);
painter->setFont(f);
- if (option->state & QStyle::State_Selected){
+ const bool selected = optionTab.state & State_Selected;
+ if (selected)
optionTab.palette.setColor(QPalette::Active, QPalette::WindowText,
QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 3, option));
- }
const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast
|| optionTab.shape == QTabBar::RoundedWest
|| optionTab.shape == QTabBar::TriangularEast
|| optionTab.shape == QTabBar::TriangularWest;
- const bool selected = optionTab.state & State_Selected;
+
if (verticalTabs) {
painter->save();
int newX, newY, newRotation;
@@ -1618,12 +1618,12 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QPixmap tabIcon = optionTab.icon.pixmap(iconSize,
(optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
if (tab->text.isEmpty())
- painter->drawPixmap(tr.center().x() - (tabIcon.height() >>1),
- tr.center().y() - (tabIcon.height() >>1),
+ painter->drawPixmap(tr.center().x() - (tabIcon.height() >> 1),
+ tr.center().y() - (tabIcon.height() >> 1),
tabIcon);
else
painter->drawPixmap(tr.left() + tabOverlap,
- tr.center().y() - (tabIcon.height() >>1),
+ tr.center().y() - (tabIcon.height() >> 1),
tabIcon);
tr.setLeft(tr.left() + iconSize.width() + 4);
}
@@ -1652,7 +1652,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (optionProgressBar->orientation == Qt::Horizontal) {
progressRect.setWidth(int(progressRect.width() * progressFactor));
if(optionProgressBar->direction == Qt::RightToLeft)
- progressRect.translate(optionProgressBar->rect.width()-progressRect.width(),0);
+ progressRect.translate(optionProgressBar->rect.width()-progressRect.width(), 0);
progressRect.adjust(1, 0, -1, 0);
} else {
progressRect.adjust(0, 1, 0, -1);
@@ -1718,18 +1718,18 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem);
optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth));
optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight));
- const int moveByX = optionCheckBox.rect.width()+vSpacing;
+ const int moveByX = optionCheckBox.rect.width() + vSpacing;
if (optionMenuItem.direction == Qt::LeftToRight) {
- textRect.translate(moveByX,0);
+ textRect.translate(moveByX, 0);
iconRect.translate(moveByX, 0);
- iconRect.setWidth(iconRect.width()+vSpacing);
- textRect.setWidth(textRect.width()-moveByX-vSpacing);
- optionCheckBox.rect.translate(vSpacing/2, hSpacing/2);
+ iconRect.setWidth(iconRect.width() + vSpacing);
+ textRect.setWidth(textRect.width() - moveByX - vSpacing);
+ optionCheckBox.rect.translate(vSpacing >> 1, hSpacing >> 1);
} else {
- textRect.setWidth(textRect.width()-moveByX);
- iconRect.setWidth(iconRect.width()+vSpacing);
- iconRect.translate(-optionCheckBox.rect.width()-vSpacing, 0);
- optionCheckBox.rect.translate(textRect.width()+iconRect.width(),0);
+ textRect.setWidth(textRect.width() - moveByX);
+ iconRect.setWidth(iconRect.width() + vSpacing);
+ iconRect.translate(-optionCheckBox.rect.width() - vSpacing, 0);
+ optionCheckBox.rect.translate(textRect.width() + iconRect.width(), 0);
}
drawPrimitive(PE_IndicatorMenuCheckMark, &optionCheckBox, painter, widget);
}
@@ -1740,9 +1740,9 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (itemWithIcon) {
drawItemPixmap(painter, iconRect, text_flags, pix);
if (optionMenuItem.direction == Qt::LeftToRight)
- textRect.translate(vSpacing,0);
+ textRect.translate(vSpacing, 0);
else
- textRect.translate(-vSpacing,0);
+ textRect.translate(-vSpacing, 0);
textRect.setWidth(textRect.width()-vSpacing);
}
@@ -1750,7 +1750,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (drawSubMenuIndicator) {
QStyleOptionMenuItem arrowOptions;
arrowOptions.QStyleOption::operator=(*menuItem);
- const int indicatorWidth = (pixelMetric(PM_ListViewIconSize, option, widget)>>1) +
+ const int indicatorWidth = (pixelMetric(PM_ListViewIconSize, option, widget) >> 1) +
pixelMetric(QStyle::PM_LayoutVerticalSpacing, option, widget);
if (optionMenuItem.direction == Qt::LeftToRight)
arrowOptions.rect.setLeft(textRect.right());
@@ -1795,8 +1795,8 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
painter->save();
QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header));
const int penWidth = (header->orientation == Qt::Horizontal) ?
- linePen.width()+QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth)
- : linePen.width()+QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth);
+ linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_BoldLineWidth)
+ : linePen.width() + QS60StylePrivate::pixelMetric(PM_Custom_ThinLineWidth);
linePen.setWidth(penWidth);
painter->setPen(linePen);
if (header->orientation == Qt::Horizontal){
@@ -1815,7 +1815,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
//Make cornerButton slightly smaller so that it is not on top of table border graphic.
QStyleOptionHeader subopt = *header;
const int borderTweak =
- QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth)>>1;
+ QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1;
if (subopt.direction == Qt::LeftToRight)
subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak);
else
@@ -1908,9 +1908,9 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
} else {
const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth);
if (option->direction == Qt::LeftToRight)
- headerRect.adjust(-2*frameWidth, 0, 0, 0);
+ headerRect.adjust(-2 * frameWidth, 0, 0, 0);
else
- headerRect.adjust(0, 0, 2*frameWidth, 0);
+ headerRect.adjust(0, 0, 2 * frameWidth, 0);
}
if (option->palette.brush(QPalette::Button).color() == Qt::transparent)
QS60StylePrivate::drawSkinElement(
@@ -2033,7 +2033,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
QRect tickRect = option->rect;
const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth);
// adjust tickmark rect to exclude frame border
- tickRect.adjust(0,-frameBorderWidth,0,-frameBorderWidth);
+ tickRect.adjust(0, -frameBorderWidth, 0, -frameBorderWidth);
QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd;
QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect,
(flags | QS60StylePrivate::SF_ColorSkinned));
@@ -2045,7 +2045,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_IndicatorRadioButton: {
QRect buttonRect = option->rect;
//there is empty (a. 33%) space in svg graphics for radiobutton
- const qreal reduceWidth = (qreal)buttonRect.width()/3.0;
+ const qreal reduceWidth = (qreal)buttonRect.width() / 3.0;
const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : 1.0;
// Try to occupy the full area
const qreal scaler = 1 + (reduceWidth/rectWidth);
@@ -2108,27 +2108,28 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_IndicatorSpinDown:
case PE_IndicatorSpinUp:
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- QStyleOptionSpinBox optionSpinBox = *spinBox;
- if (QS60StylePrivate::canDrawThemeBackground(optionSpinBox.palette.base())) {
+ if (QS60StylePrivate::canDrawThemeBackground(spinBox->palette.base())) {
+ QStyleOptionSpinBox optionSpinBox = *spinBox;
const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ?
QS60StyleEnums::SP_QgnGrafScrollArrowUp :
QS60StyleEnums::SP_QgnGrafScrollArrowDown;
- const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6;
- optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
- QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags);
+ const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1;
+ optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin );
+ QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect, flags);
} else {
commonStyleDraws = true;
}
}
+#endif //QT_NO_SPINBOX
#ifndef QT_NO_COMBOBOX
- else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
+ if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
if (QS60StylePrivate::canDrawThemeBackground( option->palette.base())) {
// We want to draw down arrow here for comboboxes as well.
+ QStyleOptionFrame optionsComboBox = *cmb;
const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown;
- QStyleOptionFrame comboBox = *cmb;
- const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6;
- comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
- QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags);
+ const int iconMargin = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth) >> 1;
+ optionsComboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? iconMargin : -iconMargin );
+ QS60StylePrivate::drawSkinPart(part, painter, optionsComboBox.rect, flags);
} else {
commonStyleDraws = true;
}
@@ -2146,12 +2147,11 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
// We want to draw down arrow here for comboboxes as well.
QStyleOptionFrame comboBox = *cmb;
const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth);
- comboBox.rect.adjust(0,frameWidth,0,-frameWidth);
+ comboBox.rect.adjust(0, frameWidth, 0, -frameWidth);
QCommonStyle::drawPrimitive(element, &comboBox, painter, widget);
}
#endif //QT_NO_COMBOBOX
break;
-#endif //QT_NO_SPINBOX
case PE_Widget:
if (QS60StylePrivate::drawsOwnThemeBackground(widget)
#ifndef QT_NO_COMBOBOX
@@ -2161,7 +2161,10 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
|| qobject_cast<const QMenu *> (widget)
#endif //QT_NO_MENU
) {
- if (QS60StylePrivate::canDrawThemeBackground(option->palette.base()))
+ //Need extra check since dialogs have their own theme background
+ if (QS60StylePrivate::canDrawThemeBackground(option->palette.base()) &&
+ option->palette.window().texture().cacheKey() ==
+ QS60StylePrivate::m_themePalette->window().texture().cacheKey())
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_OptionsMenu, painter, option->rect, flags);
else
commonStyleDraws = true;
@@ -2338,22 +2341,22 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
case CT_ToolButton:
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);
//FIXME properly - style should calculate the location of border frame-part
- sz += QSize(2*pixelMetric(PM_ButtonMargin), 2*pixelMetric(PM_ButtonMargin));
+ sz += QSize(2 * pixelMetric(PM_ButtonMargin), 2 * pixelMetric(PM_ButtonMargin));
if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(opt))
if (toolBtn->subControls & SC_ToolButtonMenu)
- sz += QSize(pixelMetric(PM_MenuButtonIndicator),0);
+ sz += QSize(pixelMetric(PM_MenuButtonIndicator), 0);
break;
case CT_PushButton:
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);
//FIXME properly - style should calculate the location of border frame-part
- sz += QSize(2*pixelMetric(PM_ButtonMargin), 2*pixelMetric(PM_ButtonMargin));
+ sz += QSize(2 * pixelMetric(PM_ButtonMargin), 2 * pixelMetric(PM_ButtonMargin));
if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget)))
if (buttonWidget->isCheckable())
sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0);
break;
case CT_LineEdit:
if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt))
- sz += QSize(2*f->lineWidth, 4*f->lineWidth);
+ sz += QSize(2 * f->lineWidth, 4 * f->lineWidth);
break;
case CT_TabBarTab:
{
@@ -2368,7 +2371,7 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
if (QS60StylePrivate::isTouchSupported())
//Make itemview easier to use in touch devices
//QCommonStyle does not adjust height with horizontal margin, it only adjusts width
- sz.setHeight(sz.height() + 2*pixelMetric(QStyle::PM_FocusFrameVMargin));
+ sz.setHeight(sz.height() + 2 * pixelMetric(QStyle::PM_FocusFrameVMargin));
break;
default:
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);
@@ -2384,10 +2387,10 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
int retValue = -1;
switch (sh) {
case SH_Table_GridLineColor:
- retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors,2,0).rgba());
+ retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 2, 0).rgba());
break;
case SH_GroupBox_TextLabelColor:
- retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors,6,0).rgba());
+ retValue = int(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0).rgba());
break;
case SH_ScrollBar_ScrollWhenPointerLeavesControl:
retValue = true;
@@ -2469,7 +2472,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
sliderlen = (qint64(scrollbarOption->pageStep) * maxlen) / (range + scrollbarOption->pageStep);
const int slidermin = pixelMetric(PM_ScrollBarSliderMin, scrollbarOption, widget);
- if (sliderlen < slidermin || range > (INT_MAX>>1))
+ if (sliderlen < slidermin || range > (INT_MAX >> 1))
sliderlen = slidermin;
if (sliderlen > maxlen)
sliderlen = maxlen;
@@ -2520,39 +2523,40 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
const int buttonMargin = spinbox->frame ? 2 : 0;
- const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize) + 2*buttonMargin;
+ const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize) + 2 * buttonMargin;
QSize buttonSize;
buttonSize.setHeight(qMax(8, spinbox->rect.height() - frameThickness));
- buttonSize.setWidth(buttonWidth);
+ //width should at least be equal to height
+ buttonSize.setWidth(qMax(buttonSize.height(), buttonWidth));
buttonSize = buttonSize.expandedTo(QApplication::globalStrut());
const int y = frameThickness + spinbox->rect.y();
- const int x = spinbox->rect.x() + spinbox->rect.width() - frameThickness - 2*buttonSize.width();
+ const int x = spinbox->rect.x() + spinbox->rect.width() - frameThickness - 2 * buttonSize.width();
switch (scontrol) {
case SC_SpinBoxUp:
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
return QRect();
- ret = QRect(x, y, buttonWidth, buttonSize.height());
+ ret = QRect(x, y, buttonSize.width(), buttonSize.height());
break;
case SC_SpinBoxDown:
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
return QRect();
- ret = QRect(x+buttonSize.width(), y, buttonWidth, buttonSize.height());
+ ret = QRect(x + buttonSize.width(), y, buttonSize.width(), buttonSize.height());
break;
case SC_SpinBoxEditField:
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
ret = QRect(
frameThickness,
frameThickness,
- spinbox->rect.width() - 2*frameThickness,
- spinbox->rect.height() - 2*frameThickness);
+ spinbox->rect.width() - 2 * frameThickness,
+ spinbox->rect.height() - 2 * frameThickness);
else
ret = QRect(
frameThickness,
frameThickness,
x - frameThickness,
- spinbox->rect.height() - 2*frameThickness);
+ spinbox->rect.height() - 2 * frameThickness);
break;
case SC_SpinBoxFrame:
ret = spinbox->rect;
@@ -2568,29 +2572,29 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
ret = cmb->rect;
const int width = cmb->rect.width();
const int height = cmb->rect.height();
+ const int buttonIconSize = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize);
const int buttonMargin = cmb->frame ? 2 : 0;
// lets use spinbox frame here as well, as no combobox specific value available.
const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0;
- const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize);
+ const int buttonWidth = qMax(cmb->rect.height(), buttonIconSize);
+ const int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth;
+ const int ypos = cmb->rect.y();
QSize buttonSize;
- buttonSize.setHeight(qMax(8, (cmb->rect.height()>>1) - frameThickness)); //minimum of 8 pixels
- buttonSize.setWidth(buttonWidth+2*buttonMargin);
+ buttonSize.setWidth(buttonWidth + 2 * buttonMargin);
+ buttonSize.setHeight(qMax(8, (cmb->rect.height() >> 1) - frameThickness)); //buttons should be squares
buttonSize = buttonSize.expandedTo(QApplication::globalStrut());
switch (scontrol) {
case SC_ComboBoxArrow:
- ret.setRect(
- ret.x() + ret.width() - buttonMargin - buttonWidth,
- ret.y() + buttonMargin,
- buttonWidth,
- height - 2*buttonMargin);
+ ret.setRect(xposMod, ypos + buttonMargin, buttonWidth, height - 2 * buttonMargin);
break;
case SC_ComboBoxEditField: {
- ret.setRect(
- ret.x() + frameThickness,
- ret.y() + frameThickness,
- ret.width() - 2*frameThickness - buttonSize.width(),
- ret.height() - 2*frameThickness);
+ const int withFrameX = cmb->rect.x() + cmb->rect.width() - frameThickness - buttonSize.width();
+ ret = QRect(
+ frameThickness,
+ frameThickness,
+ withFrameX - frameThickness,
+ cmb->rect.height() - 2 * frameThickness);
}
break;
default:
@@ -2607,7 +2611,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
//slightly indent text and boxes, so that dialog border does not mess with them.
const int horizontalSpacing =
QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
- ret.adjust(2,horizontalSpacing-3,0,0);
+ ret.adjust(2, horizontalSpacing - 3, 0, 0);
}
break;
case SC_GroupBoxFrame: {
@@ -2615,7 +2619,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
const int tbHeight = textBox.height();
ret.translate(0, -ret.y());
// include title to within the groupBox frame
- ret.setHeight(ret.height()+tbHeight);
+ ret.setHeight(ret.height() + tbHeight);
if (widget && ret.bottom() > widget->rect().bottom())
ret.setBottom(widget->rect().bottom());
}
@@ -2627,7 +2631,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
break;
case CC_ToolButton:
if (const QStyleOptionToolButton *toolButton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- const int indicatorRect = pixelMetric(PM_MenuButtonIndicator) + 2*pixelMetric(PM_ButtonMargin);
+ const int indicatorRect = pixelMetric(PM_MenuButtonIndicator) + 2 * pixelMetric(PM_ButtonMargin);
const int border = pixelMetric(PM_ButtonMargin) + pixelMetric(PM_DefaultFrameWidth);
ret = toolButton->rect;
const bool popup = (toolButton->features &
@@ -2665,13 +2669,13 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
// in S60 the input text box doesn't start from line Edit's TL, but
// a bit indented.
QRect lineEditRect = opt->rect;
- const int adjustment = opt->rect.height()>>2;
- lineEditRect.adjust(adjustment,0,0,0);
+ const int adjustment = opt->rect.height() >> 2;
+ lineEditRect.adjust(adjustment, 0, 0, 0);
ret = lineEditRect;
}
break;
case SE_TabBarTearIndicator:
- ret = QRect(0,0,0,0);
+ ret = QRect(0, 0, 0, 0);
break;
case SE_TabWidgetTabBar:
if (const QStyleOptionTabWidgetFrame *optionTab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
@@ -2693,12 +2697,12 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
// make sure that gain does not set the rect outside of widget boundaries
if (twf->direction == Qt::RightToLeft) {
if ((ret.left() - gain) < widget->rect().left())
- gain = widget->rect().left()-ret.left();
- ret.adjust(-gain,0,0,0);
+ gain = widget->rect().left() - ret.left();
+ ret.adjust(-gain, 0, 0, 0);
} else {
if ((ret.right() + gain) > widget->rect().right())
- gain = widget->rect().right()-ret.right();
- ret.adjust(0,0,gain,0);
+ gain = widget->rect().right() - ret.right();
+ ret.adjust(0, 0, gain, 0);
}
}
break;
@@ -2706,8 +2710,8 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
default: {
if (widget) {
if ((ret.bottom() + gain) > widget->rect().bottom())
- gain = widget->rect().bottom()-ret.bottom();
- ret.adjust(0,0,0,gain);
+ gain = widget->rect().bottom() - ret.bottom();
+ ret.adjust(0, 0, 0, gain);
}
break;
}
@@ -2733,7 +2737,7 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing);
//const int horizontalSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
const int checkBoxRectWidth = subElementRect(SE_ItemViewItemCheckIndicator, opt, widget).width();
- ret.adjust(-checkBoxRectWidth-verticalSpacing,0,-checkBoxRectWidth-verticalSpacing,0);
+ ret.adjust(-checkBoxRectWidth - verticalSpacing, 0, -checkBoxRectWidth - verticalSpacing, 0);
}
} else if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
@@ -2758,9 +2762,9 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu){
// submenu indicator is very small, so lets halve the rect
if (menuItem->direction == Qt::LeftToRight)
- ret.adjust(0,0,-(indicatorWidth >> 1),0);
+ ret.adjust(0, 0, -(indicatorWidth >> 1), 0);
else
- ret.adjust((indicatorWidth >> 1),0,0,0);
+ ret.adjust((indicatorWidth >> 1), 0, 0, 0);
}
}
}
@@ -2784,14 +2788,14 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
const int itemHeight = opt->rect.height();
int heightOffset = 0;
if (indicatorHeight < itemHeight)
- heightOffset = ((itemHeight - indicatorHeight)>>1);
+ heightOffset = ((itemHeight - indicatorHeight) >> 1);
if (checkBoxOnly) {
// Move rect and make it slightly smaller, so that
// a) highlight border does not cross the rect
// b) in s60 list checkbox is smaller than normal checkbox
//todo; magic three
- ret.setRect(opt->rect.left()+3, opt->rect.top() + heightOffset,
- indicatorWidth-3, indicatorHeight-3);
+ ret.setRect(opt->rect.left() + 3, opt->rect.top() + heightOffset,
+ indicatorWidth - 3, indicatorHeight - 3);
} else {
ret.setRect(opt->rect.right() - indicatorWidth - spacing, opt->rect.top() + heightOffset,
indicatorWidth, indicatorHeight);
@@ -2955,7 +2959,7 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon,
const QStyleOption *option, const QWidget *widget) const
{
const int iconDimension = QS60StylePrivate::pixelMetric(QStyle::PM_ToolBarIconSize);
- const QRect iconSize = (!option) ? QRect(0,0,iconDimension,iconDimension) : option->rect;
+ const QRect iconSize = (!option) ? QRect(0, 0, iconDimension, iconDimension) : option->rect;
QS60StyleEnums::SkinParts part;
QS60StylePrivate::SkinElementFlags adjustedFlags;
if (option)
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index 13ac301c93..fb9665a623 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -1133,9 +1133,21 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size, Skin
QPixmap QS60StylePrivate::backgroundTexture()
{
+ bool createNewBackground = false;
if (!m_background) {
+ createNewBackground = true;
+ } else {
+ //if background brush does not match screensize, re-create it
+ if (m_background->width() != S60->screenWidthInPixels ||
+ m_background->height() != S60->screenHeightInPixels) {
+ delete m_background;
+ createNewBackground = true;
+ }
+ }
+
+ if (createNewBackground) {
QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen,
- QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), 0, SkinElementFlags());
+ QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), 0, SkinElementFlags());
m_background = new QPixmap(background);
}
return *m_background;
@@ -1143,8 +1155,7 @@ QPixmap QS60StylePrivate::backgroundTexture()
QSize QS60StylePrivate::screenSize()
{
- const TSize screenSize = QS60Data::screenDevice()->SizeInPixels();
- return QSize(screenSize.iWidth, screenSize.iHeight);
+ return QSize(S60->screenWidthInPixels, S60->screenHeightInPixels);
}
QS60Style::QS60Style()
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 8b409312d3..aff3ac0127 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -1065,7 +1065,7 @@ QRect QRenderRule::boxRect(const QRect& cr, int flags) const
r.adjust(-p[LeftEdge], -p[TopEdge], p[RightEdge], p[BottomEdge]);
}
}
- if (!hasNativeBorder() && (flags & Border)) {
+ if (hasBorder() && (flags & Border)) {
const int *b = border()->borders;
r.adjust(-b[LeftEdge], -b[TopEdge], b[RightEdge], b[BottomEdge]);
}
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index f96f66b531..f523226349 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -1938,7 +1938,11 @@ void QTextControlPrivate::focusEvent(QFocusEvent *e)
emit q->updateRequest(q->selectionRect());
if (e->gotFocus()) {
#ifdef QT_KEYPAD_NAVIGATION
- if (!QApplication::keypadNavigationEnabled() || (hasEditFocus && e->reason() == Qt::PopupFocusReason)) {
+ if (!QApplication::keypadNavigationEnabled() || (hasEditFocus && (e->reason() == Qt::PopupFocusReason
+#ifdef Q_OS_SYMBIAN
+ || e->reason() == Qt::ActiveWindowFocusReason
+#endif
+ ))) {
#endif
cursorOn = (interactionFlags & Qt::TextSelectableByKeyboard);
if (interactionFlags & Qt::TextEditable) {
diff --git a/src/gui/util/qsystemtrayicon_p.h b/src/gui/util/qsystemtrayicon_p.h
index 86de3668a2..029a259c53 100644
--- a/src/gui/util/qsystemtrayicon_p.h
+++ b/src/gui/util/qsystemtrayicon_p.h
@@ -94,6 +94,7 @@ public:
class QBalloonTip : public QWidget
{
+ Q_OBJECT
public:
static void showBalloon(QSystemTrayIcon::MessageIcon icon, const QString& title,
const QString& msg, QSystemTrayIcon *trayIcon,
diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp
index c036c32f72..e26d5c30a0 100644
--- a/src/gui/widgets/qabstractspinbox.cpp
+++ b/src/gui/widgets/qabstractspinbox.cpp
@@ -1180,12 +1180,10 @@ static int getKeyboardAutoRepeatRate() {
TTimeIntervalMicroSeconds32 time;
S60->wsSession().GetKeyboardRepeatRate(initialTime, time);
ret = time.Int() / 1000; // msecs
-#elif defined(Q_OS_WIN)
+#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
DWORD time;
if (SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &time, 0) != FALSE)
ret = static_cast<int>(1000 / static_cast<int>(time)); // msecs
-#else
-#pragma message("Using default guesstimated value for keyboard repeat rate")
#endif
return ret; // msecs
}
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 15dcda266e..573b2b5cff 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1761,7 +1761,11 @@ void QLineEdit::focusInEvent(QFocusEvent *e)
d->clickCausedFocus = 1;
}
#ifdef QT_KEYPAD_NAVIGATION
- if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason)){
+ if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && ( e->reason() == Qt::PopupFocusReason
+#ifdef Q_OS_SYMBIAN
+ || e->reason() == Qt::ActiveWindowFocusReason
+#endif
+ ))) {
#endif
d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
QStyleOptionFrameV2 opt;
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 5e7d06e75e..a3624d6338 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -765,7 +765,7 @@ void QPlainTextEditPrivate::init(const QString &txt)
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(_q_cursorPositionChanged()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
- QObject::connect(control, SIGNAL(textChanged(const QString &)), q, SLOT(updateMicroFocus()));
+ QObject::connect(control, SIGNAL(textChanged()), q, SLOT(updateMicroFocus()));
// set a null page size initially to avoid any relayouting until the textedit
// is shown. relayoutDocument() will take care of setting the page size to the
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index 63fac2a5a6..5d8f134e7a 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -158,7 +158,7 @@ void QTextEditPrivate::init(const QString &html)
QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
- QObject::connect(control, SIGNAL(textChanged(const QString &)), q, SLOT(updateMicroFocus()));
+ QObject::connect(control, SIGNAL(textChanged()), q, SLOT(updateMicroFocus()));
QTextDocument *doc = control->document();
// set a null page size initially to avoid any relayouting until the textedit
diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
index 9645fa8e61..f58f5be66c 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
@@ -403,6 +403,7 @@ void QAudioDeviceInfoInternal::updateLists()
QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
{
+ QList<QByteArray> allDevices;
QList<QByteArray> devices;
QByteArray filter;
@@ -430,6 +431,7 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
if((name != NULL) && (descr != NULL) && ((io == NULL) || (io == filter))) {
QString deviceName = QLatin1String(name);
QString deviceDescription = QLatin1String(descr);
+ allDevices.append(deviceName.toLocal8Bit().constData());
if(deviceDescription.contains(QLatin1String("Default Audio Device")))
devices.append(deviceName.toLocal8Bit().constData());
}
@@ -457,6 +459,9 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
if (idx > 0)
devices.append("default");
#endif
+ if (devices.size() == 0 && allDevices.size() > 0)
+ return allDevices;
+
return devices;
}
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index b7f9ffd823..f50a5473e1 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -153,6 +153,14 @@ WAVEHDR* QAudioInputPrivate::allocateBlocks(int size, int count)
void QAudioInputPrivate::freeBlocks(WAVEHDR* blockArray)
{
+ WAVEHDR* blocks = blockArray;
+
+ int count = buffer_size/period_size;
+
+ for(int i = 0; i < count; i++) {
+ waveInUnprepareHeader(hWaveIn,&blocks[i], sizeof(WAVEHDR));
+ blocks+=sizeof(WAVEHDR);
+ }
HeapFree(GetProcessHeap(), 0, blockArray);
}
@@ -222,11 +230,6 @@ bool QAudioInputPrivate::open()
} else {
period_size = buffer_size/5;
}
-#ifdef Q_OS_WINCE
- // For wince reduce size to 40ms for buffer size and 20ms period
- buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.04;
- period_size = buffer_size/2;
-#endif
timeStamp.restart();
elapsedTimeOffset = 0;
wfx.nSamplesPerSec = settings.frequency();
@@ -317,7 +320,7 @@ void QAudioInputPrivate::close()
deviceState = QAudio::StoppedState;
int count = 0;
- while(!finished && count < 100) {
+ while(!finished && count < 500) {
count++;
Sleep(10);
}
@@ -349,9 +352,10 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
char* p = data;
qint64 l = 0;
qint64 written = 0;
+
while(!done) {
// Read in some audio data
- if(waveBlocks[header].dwBytesRecorded > 0) {
+ if(waveBlocks[header].dwBytesRecorded > 0 && waveBlocks[header].dwFlags & WHDR_DONE) {
if(pullMode) {
l = audioSource->write(waveBlocks[header].lpData,
waveBlocks[header].dwBytesRecorded);
@@ -394,6 +398,9 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
//no data, not ready yet, next time
return 0;
}
+
+ waveInUnprepareHeader(hWaveIn,&waveBlocks[header], sizeof(WAVEHDR));
+
EnterCriticalSection(&waveInCriticalSection);
waveFreeBlockCount++;
LeaveCriticalSection(&waveInCriticalSection);
@@ -401,17 +408,22 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
waveBlocks[header].dwFlags = 0L;
result = waveInPrepareHeader(hWaveIn,&waveBlocks[header], sizeof(WAVEHDR));
if(result != MMSYSERR_NOERROR) {
+ result = waveInPrepareHeader(hWaveIn,&waveBlocks[header], sizeof(WAVEHDR));
qWarning("QAudioInput: failed to prepare block %d,err=%d",header,result);
- errorState = QAudio::OpenError;
- deviceState = QAudio::StoppedState;
- emit stateChanged(deviceState);
+ errorState = QAudio::IOError;
+ EnterCriticalSection(&waveInCriticalSection);
+ waveFreeBlockCount--;
+ LeaveCriticalSection(&waveInCriticalSection);
+ return 0;
}
result = waveInAddBuffer(hWaveIn, &waveBlocks[header], sizeof(WAVEHDR));
if(result != MMSYSERR_NOERROR) {
qWarning("QAudioInput: failed to setup block %d,err=%d",header,result);
- errorState = QAudio::OpenError;
- deviceState = QAudio::StoppedState;
- emit stateChanged(deviceState);
+ errorState = QAudio::IOError;
+ EnterCriticalSection(&waveInCriticalSection);
+ waveFreeBlockCount--;
+ LeaveCriticalSection(&waveInCriticalSection);
+ return 0;
}
header++;
if(header >= buffer_size/period_size)
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index 2cfc472d65..02c8cfe046 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -147,6 +147,14 @@ WAVEHDR* QAudioOutputPrivate::allocateBlocks(int size, int count)
void QAudioOutputPrivate::freeBlocks(WAVEHDR* blockArray)
{
+ WAVEHDR* blocks = blockArray;
+
+ int count = buffer_size/period_size;
+
+ for(int i = 0; i < count; i++) {
+ waveOutUnprepareHeader(hWaveOut,&blocks[i], sizeof(WAVEHDR));
+ blocks+=sizeof(WAVEHDR);
+ }
HeapFree(GetProcessHeap(), 0, blockArray);
}
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
index 8a8f4835e8..d28d5f31cb 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
@@ -170,13 +170,15 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context)
source.append(qShaderSnippets[MainVertexShader]);
source.append(qShaderSnippets[PositionOnlyVertexShader]);
vertexShader = new QGLShader(QGLShader::Vertex, context, this);
- vertexShader->compileSourceCode(source);
+ if (!vertexShader->compileSourceCode(source))
+ qWarning("Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile");
source.clear();
source.append(qShaderSnippets[MainFragmentShader]);
source.append(qShaderSnippets[ShockingPinkSrcFragmentShader]);
fragShader = new QGLShader(QGLShader::Fragment, context, this);
- fragShader->compileSourceCode(source);
+ if (!fragShader->compileSourceCode(source))
+ qWarning("Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile");
simpleShaderProg = new QGLShaderProgram(context, this);
simpleShaderProg->addShader(vertexShader);
@@ -193,13 +195,15 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context)
source.append(qShaderSnippets[MainWithTexCoordsVertexShader]);
source.append(qShaderSnippets[UntransformedPositionVertexShader]);
vertexShader = new QGLShader(QGLShader::Vertex, context, this);
- vertexShader->compileSourceCode(source);
+ if (!vertexShader->compileSourceCode(source))
+ qWarning("Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile");
source.clear();
source.append(qShaderSnippets[MainFragmentShader]);
source.append(qShaderSnippets[ImageSrcFragmentShader]);
fragShader = new QGLShader(QGLShader::Fragment, context, this);
- fragShader->compileSourceCode(source);
+ if (!fragShader->compileSourceCode(source))
+ qWarning("Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile");
blitShaderProg = new QGLShaderProgram(context, this);
blitShaderProg->addShader(vertexShader);
@@ -234,84 +238,95 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS
}
}
- QByteArray source;
- source.append(qShaderSnippets[prog.mainFragShader]);
- source.append(qShaderSnippets[prog.srcPixelFragShader]);
- if (prog.srcPixelFragShader == CustomImageSrcFragmentShader)
- source.append(prog.customStageSource);
- if (prog.compositionFragShader)
- source.append(qShaderSnippets[prog.compositionFragShader]);
- if (prog.maskFragShader)
- source.append(qShaderSnippets[prog.maskFragShader]);
- QGLShader* fragShader = new QGLShader(QGLShader::Fragment, ctxGuard.context(), this);
- fragShader->compileSourceCode(source);
-
- source.clear();
- source.append(qShaderSnippets[prog.mainVertexShader]);
- source.append(qShaderSnippets[prog.positionVertexShader]);
- QGLShader* vertexShader = new QGLShader(QGLShader::Vertex, ctxGuard.context(), this);
- vertexShader->compileSourceCode(source);
+ QGLShader *vertexShader = 0;
+ QGLShader *fragShader = 0;
+ QGLEngineShaderProg *newProg = 0;
+ bool success = false;
+
+ do {
+ QByteArray source;
+ source.append(qShaderSnippets[prog.mainFragShader]);
+ source.append(qShaderSnippets[prog.srcPixelFragShader]);
+ if (prog.srcPixelFragShader == CustomImageSrcFragmentShader)
+ source.append(prog.customStageSource);
+ if (prog.compositionFragShader)
+ source.append(qShaderSnippets[prog.compositionFragShader]);
+ if (prog.maskFragShader)
+ source.append(qShaderSnippets[prog.maskFragShader]);
+ fragShader = new QGLShader(QGLShader::Fragment, ctxGuard.context(), this);
+ QByteArray description;
+#if defined(QT_DEBUG)
+ // Name the shader for easier debugging
+ description.append("Fragment shader: main=");
+ description.append(snippetNameStr(prog.mainFragShader));
+ description.append(", srcPixel=");
+ description.append(snippetNameStr(prog.srcPixelFragShader));
+ if (prog.compositionFragShader) {
+ description.append(", composition=");
+ description.append(snippetNameStr(prog.compositionFragShader));
+ }
+ if (prog.maskFragShader) {
+ description.append(", mask=");
+ description.append(snippetNameStr(prog.maskFragShader));
+ }
+ fragShader->setObjectName(QString::fromLatin1(description));
+#endif
+ if (!fragShader->compileSourceCode(source)) {
+ qWarning() << "Warning:" << description << "failed to compile!";
+ break;
+ }
+ source.clear();
+ source.append(qShaderSnippets[prog.mainVertexShader]);
+ source.append(qShaderSnippets[prog.positionVertexShader]);
+ vertexShader = new QGLShader(QGLShader::Vertex, ctxGuard.context(), this);
#if defined(QT_DEBUG)
- // Name the shaders for easier debugging
- QByteArray description;
- description.append("Fragment shader: main=");
- description.append(snippetNameStr(prog.mainFragShader));
- description.append(", srcPixel=");
- description.append(snippetNameStr(prog.srcPixelFragShader));
- if (prog.compositionFragShader) {
- description.append(", composition=");
- description.append(snippetNameStr(prog.compositionFragShader));
- }
- if (prog.maskFragShader) {
- description.append(", mask=");
- description.append(snippetNameStr(prog.maskFragShader));
- }
- fragShader->setObjectName(QString::fromLatin1(description));
-
- description.clear();
- description.append("Vertex shader: main=");
- description.append(snippetNameStr(prog.mainVertexShader));
- description.append(", position=");
- description.append(snippetNameStr(prog.positionVertexShader));
- vertexShader->setObjectName(QString::fromLatin1(description));
+ // Name the shader for easier debugging
+ description.clear();
+ description.append("Vertex shader: main=");
+ description.append(snippetNameStr(prog.mainVertexShader));
+ description.append(", position=");
+ description.append(snippetNameStr(prog.positionVertexShader));
+ vertexShader->setObjectName(QString::fromLatin1(description));
#endif
+ if (!vertexShader->compileSourceCode(source)) {
+ qWarning() << "Warning:" << description << "failed to compile!";
+ break;
+ }
- QGLEngineShaderProg* newProg = new QGLEngineShaderProg(prog);
-
- // If the shader program's not found in the cache, create it now.
- newProg->program = new QGLShaderProgram(ctxGuard.context(), this);
- newProg->program->addShader(vertexShader);
- newProg->program->addShader(fragShader);
-
- // We have to bind the vertex attribute names before the program is linked:
- newProg->program->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
- if (newProg->useTextureCoords)
- newProg->program->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
- if (newProg->useOpacityAttribute)
- newProg->program->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR);
-
- newProg->program->link();
- if (!newProg->program->isLinked()) {
- QLatin1String none("none");
- QLatin1String br("\n");
- QString error;
- error = QLatin1String("Shader program failed to link,")
+ newProg = new QGLEngineShaderProg(prog);
+
+ // If the shader program's not found in the cache, create it now.
+ newProg->program = new QGLShaderProgram(ctxGuard.context(), this);
+ newProg->program->addShader(vertexShader);
+ newProg->program->addShader(fragShader);
+
+ // We have to bind the vertex attribute names before the program is linked:
+ newProg->program->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
+ if (newProg->useTextureCoords)
+ newProg->program->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
+ if (newProg->useOpacityAttribute)
+ newProg->program->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR);
+
+ newProg->program->link();
+ if (!newProg->program->isLinked()) {
+ QLatin1String none("none");
+ QLatin1String br("\n");
+ QString error;
+ error = QLatin1String("Shader program failed to link,")
#if defined(QT_DEBUG)
- + br
- + QLatin1String(" Shaders Used:") + br
- + QLatin1String(" ") + vertexShader->objectName() + QLatin1String(": ") + br
- + QLatin1String(vertexShader->sourceCode()) + br
- + QLatin1String(" ") + fragShader->objectName() + QLatin1String(": ") + br
- + QLatin1String(fragShader->sourceCode()) + br
+ + br
+ + QLatin1String(" Shaders Used:") + br
+ + QLatin1String(" ") + vertexShader->objectName() + QLatin1String(": ") + br
+ + QLatin1String(vertexShader->sourceCode()) + br
+ + QLatin1String(" ") + fragShader->objectName() + QLatin1String(": ") + br
+ + QLatin1String(fragShader->sourceCode()) + br
#endif
- + QLatin1String(" Error Log:\n")
- + QLatin1String(" ") + newProg->program->log();
- qWarning() << error;
- delete newProg; // Deletes the QGLShaderProgram in it's destructor
- newProg = 0;
- }
- else {
+ + QLatin1String(" Error Log:\n")
+ + QLatin1String(" ") + newProg->program->log();
+ qWarning() << error;
+ break;
+ }
if (cachedPrograms.count() > 30) {
// The cache is full, so delete the last 5 programs in the list.
// These programs will be least used, as a program us bumped to
@@ -323,6 +338,22 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS
}
cachedPrograms.insert(0, newProg);
+
+ success = true;
+ } while (false);
+
+ // Clean up everything if we weren't successful
+ if (!success) {
+ if (newProg) {
+ delete newProg; // Also deletes the QGLShaderProgram which in turn deletes the QGLShaders
+ newProg = 0;
+ }
+ else {
+ if (vertexShader)
+ delete vertexShader;
+ if (fragShader)
+ delete fragShader;
+ }
}
return newProg;
@@ -362,8 +393,11 @@ QGLEngineShaderManager::~QGLEngineShaderManager()
removeCustomStage();
}
-uint QGLEngineShaderManager::getUniformLocation(Uniform id)
+GLuint QGLEngineShaderManager::getUniformLocation(Uniform id)
{
+ if (!currentShaderProg)
+ return 0;
+
QVector<uint> &uniformLocations = currentShaderProg->uniformLocations;
if (uniformLocations.isEmpty())
uniformLocations.fill(GLuint(-1), NumUniforms);
@@ -394,9 +428,9 @@ uint QGLEngineShaderManager::getUniformLocation(Uniform id)
}
-void QGLEngineShaderManager::optimiseForBrushTransform(const QTransform &transform)
+void QGLEngineShaderManager::optimiseForBrushTransform(QTransform::TransformationType transformType)
{
- Q_UNUSED(transform); // Currently ignored
+ Q_UNUSED(transformType); // Currently ignored
}
void QGLEngineShaderManager::setDirty()
@@ -406,6 +440,7 @@ void QGLEngineShaderManager::setDirty()
void QGLEngineShaderManager::setSrcPixelType(Qt::BrushStyle style)
{
+ Q_ASSERT(style != Qt::NoBrush);
if (srcPixelType == PixelSrcType(style))
return;
@@ -467,7 +502,10 @@ void QGLEngineShaderManager::removeCustomStage()
QGLShaderProgram* QGLEngineShaderManager::currentProgram()
{
- return currentShaderProg->program;
+ if (currentShaderProg)
+ return currentShaderProg->program;
+ else
+ return simpleProgram();
}
QGLShaderProgram* QGLEngineShaderManager::simpleProgram()
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
index 50c14326dc..1ec4cdcabb 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
@@ -454,7 +454,7 @@ public:
// There are optimisations we can do, depending on the brush transform:
// 1) May not have to apply perspective-correction
// 2) Can use lower precision for matrix
- void optimiseForBrushTransform(const QTransform &transform);
+ void optimiseForBrushTransform(QTransform::TransformationType transformType);
void setSrcPixelType(Qt::BrushStyle);
void setSrcPixelType(PixelSrcType); // For non-brush sources, like pixmaps & images
void setOpacityMode(OpacityMode);
@@ -463,7 +463,7 @@ public:
void setCustomStage(QGLCustomShaderStage* stage);
void removeCustomStage();
- uint getUniformLocation(Uniform id);
+ GLuint getUniformLocation(Uniform id);
void setDirty(); // someone has manually changed the current shader program
bool useCorrectShaderProg(); // returns true if the shader program needed to be changed
diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
index 2407979e31..46de124bd8 100644
--- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
@@ -99,12 +99,15 @@ static const char* const qglslMainWithTexCoordsAndOpacityVertexShader = "\
opacity = opacityArray; \
}";
+// NOTE: We let GL do the perspective correction so texture lookups in the fragment
+// shader are also perspective corrected.
static const char* const qglslPositionOnlyVertexShader = "\
- attribute highp vec4 vertexCoordsArray;\
- uniform highp mat4 pmvMatrix;\
+ attribute highp vec2 vertexCoordsArray;\
+ uniform highp mat3 pmvMatrix;\
void setPosition(void)\
{\
- gl_Position = pmvMatrix * vertexCoordsArray;\
+ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \
+ gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \
}";
static const char* const qglslUntransformedPositionVertexShader = "\
@@ -116,20 +119,19 @@ static const char* const qglslUntransformedPositionVertexShader = "\
// Pattern Brush - This assumes the texture size is 8x8 and thus, the inverted size is 0.125
static const char* const qglslPositionWithPatternBrushVertexShader = "\
- attribute highp vec4 vertexCoordsArray; \
- uniform highp mat4 pmvMatrix; \
+ attribute highp vec2 vertexCoordsArray; \
+ uniform highp mat3 pmvMatrix; \
uniform mediump vec2 halfViewportSize; \
uniform highp vec2 invertedTextureSize; \
uniform highp mat3 brushTransform; \
varying highp vec2 patternTexCoords; \
void setPosition(void) { \
- gl_Position = pmvMatrix * vertexCoordsArray;\
- gl_Position.xy = gl_Position.xy / gl_Position.w; \
+ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \
+ gl_Position.xy = transformedPos.xy / transformedPos.z; \
mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \
- mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \
+ mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1.0); \
mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \
- gl_Position.xy = gl_Position.xy * invertedHTexCoordsZ; \
- gl_Position.w = invertedHTexCoordsZ; \
+ gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \
patternTexCoords.xy = (hTexCoords.xy * 0.125) * invertedHTexCoordsZ; \
}";
@@ -147,20 +149,19 @@ static const char* const qglslPatternBrushSrcFragmentShader = "\
// Linear Gradient Brush
static const char* const qglslPositionWithLinearGradientBrushVertexShader = "\
- attribute highp vec4 vertexCoordsArray; \
- uniform highp mat4 pmvMatrix; \
+ attribute highp vec2 vertexCoordsArray; \
+ uniform highp mat3 pmvMatrix; \
uniform mediump vec2 halfViewportSize; \
uniform highp vec3 linearData; \
uniform highp mat3 brushTransform; \
varying mediump float index; \
void setPosition() { \
- gl_Position = pmvMatrix * vertexCoordsArray;\
- gl_Position.xy = gl_Position.xy / gl_Position.w; \
+ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \
+ gl_Position.xy = transformedPos.xy / transformedPos.z; \
mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \
mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \
mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \
- gl_Position.xy = gl_Position.xy * invertedHTexCoordsZ; \
- gl_Position.w = invertedHTexCoordsZ; \
+ gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \
index = (dot(linearData.xy, hTexCoords.xy) * linearData.z) * invertedHTexCoordsZ; \
}";
@@ -178,20 +179,19 @@ static const char* const qglslLinearGradientBrushSrcFragmentShader = "\
// Conical Gradient Brush
static const char* const qglslPositionWithConicalGradientBrushVertexShader = "\
- attribute highp vec4 vertexCoordsArray;\
- uniform highp mat4 pmvMatrix;\
+ attribute highp vec2 vertexCoordsArray;\
+ uniform highp mat3 pmvMatrix;\
uniform mediump vec2 halfViewportSize; \
uniform highp mat3 brushTransform; \
varying highp vec2 A; \
void setPosition(void)\
{\
- gl_Position = pmvMatrix * vertexCoordsArray;\
- gl_Position.xy = gl_Position.xy / gl_Position.w; \
+ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \
+ gl_Position.xy = transformedPos.xy / transformedPos.z; \
mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \
mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \
mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \
- gl_Position.xy = gl_Position.xy * invertedHTexCoordsZ; \
- gl_Position.w = invertedHTexCoordsZ; \
+ gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \
A = hTexCoords.xy * invertedHTexCoordsZ; \
}";
@@ -215,8 +215,8 @@ static const char* const qglslConicalGradientBrushSrcFragmentShader = "\n\
// Radial Gradient Brush
static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\
- attribute highp vec4 vertexCoordsArray;\
- uniform highp mat4 pmvMatrix;\
+ attribute highp vec2 vertexCoordsArray;\
+ uniform highp mat3 pmvMatrix;\
uniform mediump vec2 halfViewportSize; \
uniform highp mat3 brushTransform; \
uniform highp vec2 fmp; \
@@ -224,13 +224,12 @@ static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\
varying highp vec2 A; \
void setPosition(void) \
{\
- gl_Position = pmvMatrix * vertexCoordsArray;\
- gl_Position.xy = gl_Position.xy / gl_Position.w; \
+ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \
+ gl_Position.xy = transformedPos.xy / transformedPos.z; \
mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \
mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \
mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \
- gl_Position.xy = gl_Position.xy * invertedHTexCoordsZ; \
- gl_Position.w = invertedHTexCoordsZ; \
+ gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \
A = hTexCoords.xy * invertedHTexCoordsZ; \
b = 2.0 * dot(A, fmp); \
}";
@@ -253,20 +252,19 @@ static const char* const qglslRadialGradientBrushSrcFragmentShader = "\
// Texture Brush
static const char* const qglslPositionWithTextureBrushVertexShader = "\
- attribute highp vec4 vertexCoordsArray; \
- uniform highp mat4 pmvMatrix; \
+ attribute highp vec2 vertexCoordsArray; \
+ uniform highp mat3 pmvMatrix; \
uniform mediump vec2 halfViewportSize; \
uniform highp vec2 invertedTextureSize; \
uniform highp mat3 brushTransform; \
varying highp vec2 textureCoords; \
void setPosition(void) { \
- gl_Position = pmvMatrix * vertexCoordsArray;\
- gl_Position.xy = gl_Position.xy / gl_Position.w; \
+ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \
+ gl_Position.xy = transformedPos.xy / transformedPos.z; \
mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \
mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \
mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \
- gl_Position.xy = gl_Position.xy * invertedHTexCoordsZ; \
- gl_Position.w = invertedHTexCoordsZ; \
+ gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \
textureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \
}";
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index fb9bcb40f6..d3a9547824 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -358,10 +358,10 @@ QGL2PaintEngineExPrivate::~QGL2PaintEngineExPrivate()
void QGL2PaintEngineExPrivate::updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id)
{
// glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); //### Is it always this texture unit?
- if (id != GLuint(-1) && id == lastTexture)
+ if (id != GLuint(-1) && id == lastTextureUsed)
return;
- lastTexture = id;
+ lastTextureUsed = id;
if (smoothPixmapTransform) {
glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -386,19 +386,28 @@ inline QColor qt_premultiplyColor(QColor c, GLfloat opacity)
}
-void QGL2PaintEngineExPrivate::setBrush(const QBrush* brush)
+void QGL2PaintEngineExPrivate::setBrush(const QBrush& brush)
{
+ if (qbrush_fast_equals(currentBrush, brush))
+ return;
+
+ const Qt::BrushStyle newStyle = qbrush_style(brush);
+ Q_ASSERT(newStyle != Qt::NoBrush);
+
currentBrush = brush;
- brushTextureDirty = true;
- brushUniformsDirty = true;
- if (currentBrush->style() == Qt::TexturePattern
- && qHasPixmapTexture(*brush) && brush->texture().isQBitmap())
+ brushUniformsDirty = true; // All brushes have at least one uniform
+
+ if (newStyle > Qt::SolidPattern)
+ brushTextureDirty = true;
+
+ if (currentBrush.style() == Qt::TexturePattern
+ && qHasPixmapTexture(brush) && brush.texture().isQBitmap())
{
shaderManager->setSrcPixelType(QGLEngineShaderManager::TextureSrcWithPattern);
} else {
- shaderManager->setSrcPixelType(currentBrush->style());
+ shaderManager->setSrcPixelType(newStyle);
}
- shaderManager->optimiseForBrushTransform(currentBrush->transform());
+ shaderManager->optimiseForBrushTransform(currentBrush.transform().type());
}
@@ -420,7 +429,7 @@ void QGL2PaintEngineExPrivate::updateBrushTexture()
{
Q_Q(QGL2PaintEngineEx);
// qDebug("QGL2PaintEngineExPrivate::updateBrushTexture()");
- Qt::BrushStyle style = currentBrush->style();
+ Qt::BrushStyle style = currentBrush.style();
if ( (style >= Qt::Dense1Pattern) && (style <= Qt::DiagCrossPattern) ) {
// Get the image data for the pattern
@@ -433,7 +442,7 @@ void QGL2PaintEngineExPrivate::updateBrushTexture()
else if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) {
// Gradiant brush: All the gradiants use the same texture
- const QGradient* g = currentBrush->gradient();
+ const QGradient* g = currentBrush.gradient();
// We apply global opacity in the fragment shaders, so we always pass 1.0
// for opacity to the cache.
@@ -450,7 +459,7 @@ void QGL2PaintEngineExPrivate::updateBrushTexture()
updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, q->state()->renderHints & QPainter::SmoothPixmapTransform);
}
else if (style == Qt::TexturePattern) {
- const QPixmap& texPixmap = currentBrush->texture();
+ const QPixmap& texPixmap = currentBrush.texture();
glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT);
QGLTexture *tex = ctx->d_func()->bindTexture(texPixmap, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption);
@@ -464,15 +473,15 @@ void QGL2PaintEngineExPrivate::updateBrushTexture()
void QGL2PaintEngineExPrivate::updateBrushUniforms()
{
// qDebug("QGL2PaintEngineExPrivate::updateBrushUniforms()");
- Qt::BrushStyle style = currentBrush->style();
+ Qt::BrushStyle style = currentBrush.style();
if (style == Qt::NoBrush)
return;
- QTransform brushQTransform = currentBrush->transform();
+ QTransform brushQTransform = currentBrush.transform();
if (style == Qt::SolidPattern) {
- QColor col = qt_premultiplyColor(currentBrush->color(), (GLfloat)q->state()->opacity);
+ QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity);
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::FragmentColor), col);
}
else {
@@ -480,7 +489,7 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
QPointF translationPoint;
if (style <= Qt::DiagCrossPattern) {
- QColor col = qt_premultiplyColor(currentBrush->color(), (GLfloat)q->state()->opacity);
+ QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity);
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col);
@@ -488,7 +497,7 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize);
}
else if (style == Qt::LinearGradientPattern) {
- const QLinearGradient *g = static_cast<const QLinearGradient *>(currentBrush->gradient());
+ const QLinearGradient *g = static_cast<const QLinearGradient *>(currentBrush.gradient());
QPointF realStart = g->start();
QPointF realFinal = g->finalStop();
@@ -508,7 +517,7 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize);
}
else if (style == Qt::ConicalGradientPattern) {
- const QConicalGradient *g = static_cast<const QConicalGradient *>(currentBrush->gradient());
+ const QConicalGradient *g = static_cast<const QConicalGradient *>(currentBrush.gradient());
translationPoint = g->center();
GLfloat angle = -(g->angle() * 2 * Q_PI) / 360.0;
@@ -519,7 +528,7 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize);
}
else if (style == Qt::RadialGradientPattern) {
- const QRadialGradient *g = static_cast<const QRadialGradient *>(currentBrush->gradient());
+ const QRadialGradient *g = static_cast<const QRadialGradient *>(currentBrush.gradient());
QPointF realCenter = g->center();
QPointF realFocal = g->focalPoint();
qreal realRadius = g->radius();
@@ -537,10 +546,10 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize);
}
else if (style == Qt::TexturePattern) {
- const QPixmap& texPixmap = currentBrush->texture();
+ const QPixmap& texPixmap = currentBrush.texture();
- if (qHasPixmapTexture(*currentBrush) && currentBrush->texture().isQBitmap()) {
- QColor col = qt_premultiplyColor(currentBrush->color(), (GLfloat)q->state()->opacity);
+ if (qHasPixmapTexture(currentBrush) && currentBrush.texture().isQBitmap()) {
+ QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity);
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col);
}
@@ -561,7 +570,7 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
QTransform gl_to_qt(1, 0, 0, -1, 0, height);
QTransform inv_matrix;
if (style == Qt::TexturePattern && textureInvertedY == -1)
- inv_matrix = gl_to_qt * (QTransform(1, 0, 0, -1, 0, currentBrush->texture().height()) * brushQTransform * matrix).inverted() * translate;
+ inv_matrix = gl_to_qt * (QTransform(1, 0, 0, -1, 0, currentBrush.texture().height()) * brushQTransform * matrix).inverted() * translate;
else
inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate;
@@ -577,37 +586,43 @@ void QGL2PaintEngineExPrivate::updateMatrix()
{
// qDebug("QGL2PaintEngineExPrivate::updateMatrix()");
- // We set up the 4x4 transformation matrix on the vertex shaders to
- // be the equivalent of glOrtho(0, w, h, 0, -1, 1) * transform:
+ const QTransform& transform = q->state()->matrix;
+
+ // The projection matrix converts from Qt's coordinate system to GL's coordinate system
+ // * GL's viewport is 2x2, Qt's is width x height
+ // * GL has +y -> -y going from bottom -> top, Qt is the other way round
+ // * GL has [0,0] in the center, Qt has it in the top-left
//
- // | 2/width 0 0 -1 | | m11 m21 0 dx |
- // | 0 -2/height 0 1 | | m12 m22 0 dy |
- // | 0 0 -1 0 | * | 0 0 1 0 |
- // | 0 0 0 1 | | m13 m23 0 m33 |
+ // This results in the Projection matrix below, which is multiplied by the painter's
+ // transformation matrix, as shown below:
//
- // We expand out the multiplication to save the cost of a full 4x4
- // matrix multiplication as most of the components are trivial.
- const QTransform& transform = q->state()->matrix;
+ // Projection Matrix Painter Transform
+ // ------------------------------------------------ ------------------------
+ // | 2.0 / width | 0.0 | -1.0 | | m11 | m21 | dx |
+ // | 0.0 | -2.0 / height | 1.0 | * | m12 | m22 | dy |
+ // | 0.0 | 0.0 | 1.0 | | m13 | m23 | m33 |
+ // ------------------------------------------------ ------------------------
+ //
+ // NOTE: The resultant matrix is also transposed, as GL expects column-major matracies
- qreal wfactor = 2.0 / width;
- qreal hfactor = -2.0 / height;
-
- pmvMatrix[0][0] = wfactor * transform.m11() - transform.m13();
- pmvMatrix[0][1] = hfactor * transform.m12() + transform.m13();
- pmvMatrix[0][2] = 0.0;
- pmvMatrix[0][3] = transform.m13();
- pmvMatrix[1][0] = wfactor * transform.m21() - transform.m23();
- pmvMatrix[1][1] = hfactor * transform.m22() + transform.m23();
- pmvMatrix[1][2] = 0.0;
- pmvMatrix[1][3] = transform.m23();
- pmvMatrix[2][0] = 0.0;
- pmvMatrix[2][1] = 0.0;
- pmvMatrix[2][2] = -1.0;
- pmvMatrix[2][3] = 0.0;
- pmvMatrix[3][0] = wfactor * transform.dx() - transform.m33();
- pmvMatrix[3][1] = hfactor * transform.dy() + transform.m33();
- pmvMatrix[3][2] = 0.0;
- pmvMatrix[3][3] = transform.m33();
+ const GLfloat wfactor = 2.0f / width;
+ const GLfloat hfactor = -2.0f / height;
+
+ if (addOffset) {
+ pmvMatrix[2][0] = (wfactor * (transform.dx() + 0.49f)) - transform.m33();
+ pmvMatrix[2][1] = (hfactor * (transform.dy() + 0.49f)) + transform.m33();
+ } else {
+ pmvMatrix[2][0] = (wfactor * transform.dx()) - transform.m33();
+ pmvMatrix[2][1] = (hfactor * transform.dy()) + transform.m33();
+ }
+
+ pmvMatrix[0][0] = (wfactor * transform.m11()) - transform.m13();
+ pmvMatrix[1][0] = (wfactor * transform.m21()) - transform.m23();
+ pmvMatrix[0][1] = (hfactor * transform.m12()) + transform.m13();
+ pmvMatrix[1][1] = (hfactor * transform.m22()) + transform.m23();
+ pmvMatrix[0][2] = transform.m13();
+ pmvMatrix[1][2] = transform.m23();
+ pmvMatrix[2][2] = transform.m33();
// 1/10000 == 0.0001, so we have good enough res to cover curves
// that span the entire widget...
@@ -694,7 +709,14 @@ static inline void setCoords(GLfloat *coords, const QGLRect &rect)
void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern)
{
// Setup for texture drawing
+ currentBrush = noBrush;
shaderManager->setSrcPixelType(pattern ? QGLEngineShaderManager::PatternSrc : QGLEngineShaderManager::ImageSrc);
+
+ if (addOffset) {
+ addOffset = false;
+ matrixDirty = true;
+ }
+
if (prepareForDraw(opaque))
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT);
@@ -749,7 +771,7 @@ void QGL2PaintEngineEx::beginNativePainting()
Q_UNUSED(ctx);
#endif
- d->lastTexture = GLuint(-1);
+ d->lastTextureUsed = GLuint(-1);
d->dirtyStencilRegion = QRect(0, 0, d->width, d->height);
d->resetGLState();
@@ -776,12 +798,6 @@ void QGL2PaintEngineEx::endNativePainting()
d->needsSync = true;
}
-const QGLContext *QGL2PaintEngineEx::context()
-{
- Q_D(QGL2PaintEngineEx);
- return d->ctx;
-}
-
void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode)
{
if (newMode == mode)
@@ -792,7 +808,7 @@ void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode)
glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
glDisableVertexAttribArray(QT_OPACITY_ATTR);
- lastTexture = GLuint(-1);
+ lastTextureUsed = GLuint(-1);
}
if (newMode == TextDrawingMode) {
@@ -840,13 +856,14 @@ struct QGL2PEVectorPathCache
qreal iscale;
};
-void qopengl2paintengine_cleanup_vectorpath(QPaintEngineEx *engine, void *data)
+void QGL2PaintEngineExPrivate::cleanupVectorPath(QPaintEngineEx *engine, void *data)
{
QGL2PEVectorPathCache *c = (QGL2PEVectorPathCache *) data;
#ifdef QT_OPENGL_CACHE_AS_VBOS
- QGL2PaintEngineExPrivate *d = QGL2PaintEngineExPrivate::getData((QGL2PaintEngineEx *) engine);
- d->unusedVBOSToClean << c->vbo;
+ Q_ASSERT(engine->type() == QPaintEngine::OpenGL2);
+ static_cast<QGL2PaintEngineEx *>(engine)->d_func()->unusedVBOSToClean << c->vbo;
#else
+ Q_UNUSED(engine);
qFree(c->vertices);
#endif
delete c;
@@ -857,6 +874,16 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
{
transferMode(BrushDrawingMode);
+ const QOpenGL2PaintEngineState *s = q->state();
+ const bool newAddOffset = !(s->renderHints & QPainter::Antialiasing) &&
+ (qbrush_style(currentBrush) == Qt::SolidPattern) &&
+ !multisamplingAlwaysEnabled;
+
+ if (addOffset != newAddOffset) {
+ addOffset = newAddOffset;
+ matrixDirty = true;
+ }
+
// Might need to call updateMatrix to re-calculate inverseScale
if (matrixDirty)
updateMatrix();
@@ -866,7 +893,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
// Check to see if there's any hints
if (path.shape() == QVectorPath::RectangleHint) {
QGLRect rect(points[0].x(), points[0].y(), points[2].x(), points[2].y());
- prepareForDraw(currentBrush->isOpaque());
+ prepareForDraw(currentBrush.isOpaque());
composite(rect);
} else if (path.isConvex()) {
@@ -892,7 +919,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
} else {
cache = new QGL2PEVectorPathCache;
cache->vertexCount = 0;
- data = const_cast<QVectorPath &>(path).addCacheData(q, cache, qopengl2paintengine_cleanup_vectorpath);
+ data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath);
}
// Flatten the path at the current scale factor and fill it into the cache struct.
@@ -914,7 +941,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
#endif
}
- prepareForDraw(currentBrush->isOpaque());
+ prepareForDraw(currentBrush.isOpaque());
glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
#ifdef QT_OPENGL_CACHE_AS_VBOS
glBindBuffer(GL_ARRAY_BUFFER, cache->vbo);
@@ -933,7 +960,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
path.makeCacheable();
vertexCoordinateArray.clear();
vertexCoordinateArray.addPath(path, inverseScale, false);
- prepareForDraw(currentBrush->isOpaque());
+ prepareForDraw(currentBrush.isOpaque());
drawVertexArrays(vertexCoordinateArray, GL_TRIANGLE_FAN);
}
@@ -958,7 +985,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
glStencilFunc(GL_NOTEQUAL, 0, GL_STENCIL_HIGH_BIT);
}
- prepareForDraw(currentBrush->isOpaque());
+ prepareForDraw(currentBrush.isOpaque());
if (inRenderText)
prepareDepthRangeForRenderText();
@@ -1155,10 +1182,10 @@ bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque)
: QGLEngineShaderManager::NoOpacity;
if (stateHasOpacity && (mode != ImageDrawingMode)) {
// Using a brush
- bool brushIsPattern = (currentBrush->style() >= Qt::Dense1Pattern) &&
- (currentBrush->style() <= Qt::DiagCrossPattern);
+ bool brushIsPattern = (currentBrush.style() >= Qt::Dense1Pattern) &&
+ (currentBrush.style() <= Qt::DiagCrossPattern);
- if ((currentBrush->style() == Qt::SolidPattern) || brushIsPattern)
+ if ((currentBrush.style() == Qt::SolidPattern) || brushIsPattern)
opacityMode = QGLEngineShaderManager::NoOpacity; // Global opacity handled by srcPixel shader
}
}
@@ -1268,31 +1295,14 @@ void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush)
{
Q_D(QGL2PaintEngineEx);
- Qt::BrushStyle style = qbrush_style(brush);
- if (style == Qt::NoBrush)
+ if (qbrush_style(brush) == Qt::NoBrush)
return;
+
if (!d->inRenderText)
ensureActive();
- QOpenGL2PaintEngineState *s = state();
- bool doOffset = !(s->renderHints & QPainter::Antialiasing) &&
- (style == Qt::SolidPattern) &&
- !d->multisamplingAlwaysEnabled;
-
- if (doOffset) {
- d->temporaryTransform = s->matrix;
- QTransform tx = QTransform::fromTranslate(.49, .49);
- s->matrix = s->matrix * tx;
- d->matrixDirty = true;
- }
-
- d->setBrush(&brush);
+ d->setBrush(brush);
d->fill(path);
-
- if (doOffset) {
- s->matrix = d->temporaryTransform;
- d->matrixDirty = true;
- }
}
extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
@@ -1302,9 +1312,8 @@ void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
{
Q_D(QGL2PaintEngineEx);
- Qt::PenStyle penStyle = qpen_style(pen);
const QBrush &penBrush = qpen_brush(pen);
- if (penStyle == Qt::NoPen || qbrush_style(penBrush) == Qt::NoBrush)
+ if (qpen_style(pen) == Qt::NoPen || qbrush_style(penBrush) == Qt::NoBrush)
return;
QOpenGL2PaintEngineState *s = state();
@@ -1315,45 +1324,47 @@ void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
}
ensureActive();
+ d->setBrush(penBrush);
+ d->stroke(path, pen);
+}
- bool doOffset = !(s->renderHints & QPainter::Antialiasing) && !d->multisamplingAlwaysEnabled;
- if (doOffset) {
- d->temporaryTransform = s->matrix;
- QTransform tx = QTransform::fromTranslate(0.49, .49);
- s->matrix = s->matrix * tx;
- d->matrixDirty = true;
+void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen)
+{
+ const QOpenGL2PaintEngineState *s = q->state();
+ const bool newAddOffset = !(s->renderHints & QPainter::Antialiasing) && !multisamplingAlwaysEnabled;
+ if (addOffset != newAddOffset) {
+ addOffset = newAddOffset;
+ matrixDirty = true;
}
- bool opaque = penBrush.isOpaque() && s->opacity > 0.99;
- d->setBrush(&penBrush);
- d->transferMode(BrushDrawingMode);
+ const Qt::PenStyle penStyle = qpen_style(pen);
+ const QBrush &penBrush = qpen_brush(pen);
+ const bool opaque = penBrush.isOpaque() && s->opacity > 0.99;
+
+ transferMode(BrushDrawingMode);
// updateMatrix() is responsible for setting the inverse scale on
// the strokers, so we need to call it here and not wait for
// prepareForDraw() down below.
- d->updateMatrix();
+ updateMatrix();
if (penStyle == Qt::SolidLine) {
- d->stroker.process(path, pen);
+ stroker.process(path, pen);
} else { // Some sort of dash
- d->dasher.process(path, pen);
+ dasher.process(path, pen);
- QVectorPath dashStroke(d->dasher.points(),
- d->dasher.elementCount(),
- d->dasher.elementTypes());
- d->stroker.process(dashStroke, pen);
+ QVectorPath dashStroke(dasher.points(),
+ dasher.elementCount(),
+ dasher.elementTypes());
+ stroker.process(dashStroke, pen);
}
-
- QGLContext *ctx = d->ctx;
- Q_UNUSED(ctx);
-
if (opaque) {
- d->prepareForDraw(opaque);
+ prepareForDraw(opaque);
glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
- glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, false, 0, d->stroker.vertices());
- glDrawArrays(GL_TRIANGLE_STRIP, 0, d->stroker.vertexCount() / 2);
+ glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, false, 0, stroker.vertices());
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, stroker.vertexCount() / 2);
// QBrush b(Qt::green);
// d->setBrush(&b);
@@ -1371,30 +1382,25 @@ void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
: width;
if (pen.isCosmetic())
- extra = extra * d->inverseScale;
+ extra = extra * inverseScale;
QRectF bounds = path.controlPointRect().adjusted(-extra, -extra, extra, extra);
- d->fillStencilWithVertexArray(d->stroker.vertices(), d->stroker.vertexCount() / 2,
+ fillStencilWithVertexArray(stroker.vertices(), stroker.vertexCount() / 2,
0, 0, bounds, QGL2PaintEngineExPrivate::TriStripStrokeFillMode);
glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
// Pass when any bit is set, replace stencil value with 0
glStencilFunc(GL_NOTEQUAL, 0, GL_STENCIL_HIGH_BIT);
- d->prepareForDraw(false);
+ prepareForDraw(false);
// Stencil the brush onto the dest buffer
- d->composite(bounds);
+ composite(bounds);
glStencilMask(0);
- d->updateClipScissorTest();
- }
-
- if (doOffset) {
- s->matrix = d->temporaryTransform;
- d->matrixDirty = true;
+ updateClipScissorTest();
}
}
@@ -1434,7 +1440,7 @@ void QGL2PaintEngineEx::renderHintsChanged()
#endif
Q_D(QGL2PaintEngineEx);
- d->lastTexture = GLuint(-1);
+ d->lastTextureUsed = GLuint(-1);
d->brushTextureDirty = true;
// qDebug("QGL2PaintEngineEx::renderHintsChanged() not implemented!");
}
@@ -1603,8 +1609,13 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly
if (textureCoordinateArray.data() != oldTextureCoordinateDataPtr)
glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray.data());
+ if (addOffset) {
+ addOffset = false;
+ matrixDirty = true;
+ }
+
QBrush pensBrush = q->state()->pen.brush();
- setBrush(&pensBrush);
+ setBrush(pensBrush);
if (inRenderText)
prepareDepthRangeForRenderText();
@@ -1649,7 +1660,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly
q->state()->opacity = 1;
opacityUniformDirty = true;
pensBrush = Qt::white;
- setBrush(&pensBrush);
+ setBrush(pensBrush);
}
compositionModeDirty = false; // I can handle this myself, thank you very much
@@ -1670,7 +1681,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly
q->state()->opacity = oldOpacity;
opacityUniformDirty = true;
pensBrush = q->state()->pen.brush();
- setBrush(&pensBrush);
+ setBrush(pensBrush);
}
compositionModeDirty = false;
@@ -1700,20 +1711,31 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly
void QGL2PaintEngineEx::drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints)
{
+ Q_D(QGL2PaintEngineEx);
// Use fallback for extended composition modes.
if (state()->composition_mode > QPainter::CompositionMode_Plus) {
QPaintEngineEx::drawPixmaps(drawingData, dataCount, pixmap, hints);
return;
}
- Q_D(QGL2PaintEngineEx);
+ ensureActive();
+ d->drawPixmaps(drawingData, dataCount, pixmap, hints);
+}
+
+void QGL2PaintEngineExPrivate::drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints)
+{
GLfloat dx = 1.0f / pixmap.size().width();
GLfloat dy = 1.0f / pixmap.size().height();
- d->vertexCoordinateArray.clear();
- d->textureCoordinateArray.clear();
- d->opacityArray.reset();
+ vertexCoordinateArray.clear();
+ textureCoordinateArray.clear();
+ opacityArray.reset();
+
+ if (addOffset) {
+ addOffset = false;
+ matrixDirty = true;
+ }
bool allOpaque = true;
@@ -1730,31 +1752,28 @@ void QGL2PaintEngineEx::drawPixmaps(const QDrawPixmaps::Data *drawingData, int d
QGLPoint bottomRight(right * c - bottom * s, right * s + bottom * c);
QGLPoint bottomLeft(-right * c - bottom * s, -right * s + bottom * c);
- d->vertexCoordinateArray.lineToArray(bottomRight.x + drawingData[i].point.x(), bottomRight.y + drawingData[i].point.y());
- d->vertexCoordinateArray.lineToArray(-bottomLeft.x + drawingData[i].point.x(), -bottomLeft.y + drawingData[i].point.y());
- d->vertexCoordinateArray.lineToArray(-bottomRight.x + drawingData[i].point.x(), -bottomRight.y + drawingData[i].point.y());
- d->vertexCoordinateArray.lineToArray(-bottomRight.x + drawingData[i].point.x(), -bottomRight.y + drawingData[i].point.y());
- d->vertexCoordinateArray.lineToArray(bottomLeft.x + drawingData[i].point.x(), bottomLeft.y + drawingData[i].point.y());
- d->vertexCoordinateArray.lineToArray(bottomRight.x + drawingData[i].point.x(), bottomRight.y + drawingData[i].point.y());
+ vertexCoordinateArray.lineToArray(bottomRight.x + drawingData[i].point.x(), bottomRight.y + drawingData[i].point.y());
+ vertexCoordinateArray.lineToArray(-bottomLeft.x + drawingData[i].point.x(), -bottomLeft.y + drawingData[i].point.y());
+ vertexCoordinateArray.lineToArray(-bottomRight.x + drawingData[i].point.x(), -bottomRight.y + drawingData[i].point.y());
+ vertexCoordinateArray.lineToArray(-bottomRight.x + drawingData[i].point.x(), -bottomRight.y + drawingData[i].point.y());
+ vertexCoordinateArray.lineToArray(bottomLeft.x + drawingData[i].point.x(), bottomLeft.y + drawingData[i].point.y());
+ vertexCoordinateArray.lineToArray(bottomRight.x + drawingData[i].point.x(), bottomRight.y + drawingData[i].point.y());
QGLRect src(drawingData[i].source.left() * dx, drawingData[i].source.top() * dy,
drawingData[i].source.right() * dx, drawingData[i].source.bottom() * dy);
- d->textureCoordinateArray.lineToArray(src.right, src.bottom);
- d->textureCoordinateArray.lineToArray(src.right, src.top);
- d->textureCoordinateArray.lineToArray(src.left, src.top);
- d->textureCoordinateArray.lineToArray(src.left, src.top);
- d->textureCoordinateArray.lineToArray(src.left, src.bottom);
- d->textureCoordinateArray.lineToArray(src.right, src.bottom);
+ textureCoordinateArray.lineToArray(src.right, src.bottom);
+ textureCoordinateArray.lineToArray(src.right, src.top);
+ textureCoordinateArray.lineToArray(src.left, src.top);
+ textureCoordinateArray.lineToArray(src.left, src.top);
+ textureCoordinateArray.lineToArray(src.left, src.bottom);
+ textureCoordinateArray.lineToArray(src.right, src.bottom);
- qreal opacity = drawingData[i].opacity * state()->opacity;
- d->opacityArray << opacity << opacity << opacity << opacity << opacity << opacity;
+ qreal opacity = drawingData[i].opacity * q->state()->opacity;
+ opacityArray << opacity << opacity << opacity << opacity << opacity << opacity;
allOpaque &= (opacity >= 0.99f);
}
- ensureActive();
-
- QGLContext *ctx = d->ctx;
glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
QGLTexture *texture = ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA,
QGLContext::InternalBindOption
@@ -1762,27 +1781,28 @@ void QGL2PaintEngineEx::drawPixmaps(const QDrawPixmaps::Data *drawingData, int d
if (texture->options & QGLContext::InvertedYBindOption) {
// Flip texture y-coordinate.
- QGLPoint *data = d->textureCoordinateArray.data();
+ QGLPoint *data = textureCoordinateArray.data();
for (int i = 0; i < 6 * dataCount; ++i)
data[i].y = 1 - data[i].y;
}
- d->transferMode(ImageArrayDrawingMode);
+ transferMode(ImageArrayDrawingMode);
bool isBitmap = pixmap.isQBitmap();
bool isOpaque = !isBitmap && (!pixmap.hasAlphaChannel() || (hints & QDrawPixmaps::OpaqueHint)) && allOpaque;
- d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,
- state()->renderHints & QPainter::SmoothPixmapTransform, texture->id);
+ updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,
+ q->state()->renderHints & QPainter::SmoothPixmapTransform, texture->id);
// Setup for texture drawing
- d->shaderManager->setSrcPixelType(isBitmap ? QGLEngineShaderManager::PatternSrc : QGLEngineShaderManager::ImageSrc);
- if (d->prepareForDraw(isOpaque))
- d->shaderManager->currentProgram()->setUniformValue(d->location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT);
+ currentBrush = noBrush;
+ shaderManager->setSrcPixelType(isBitmap ? QGLEngineShaderManager::PatternSrc : QGLEngineShaderManager::ImageSrc);
+ if (prepareForDraw(isOpaque))
+ shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT);
if (isBitmap) {
- QColor col = qt_premultiplyColor(state()->pen.color(), (GLfloat)state()->opacity);
- d->shaderManager->currentProgram()->setUniformValue(d->location(QGLEngineShaderManager::PatternColor), col);
+ QColor col = qt_premultiplyColor(q->state()->pen.color(), (GLfloat)q->state()->opacity);
+ shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col);
}
glDrawArrays(GL_TRIANGLES, 0, 6 * dataCount);
@@ -1814,7 +1834,8 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
d->compositionModeDirty = true;
d->opacityUniformDirty = true;
d->needsSync = true;
- d->use_system_clip = !systemClip().isEmpty();
+ d->useSystemClip = !systemClip().isEmpty();
+ d->currentBrush = QBrush();
d->dirtyStencilRegion = QRect(0, 0, d->width, d->height);
d->stencilClean = true;
@@ -1934,12 +1955,12 @@ void QGL2PaintEngineExPrivate::updateClipScissorTest()
#else
QRect bounds = q->state()->rectangleClip;
if (!q->state()->clipEnabled) {
- if (use_system_clip)
+ if (useSystemClip)
bounds = systemClip.boundingRect();
else
bounds = QRect(0, 0, width, height);
} else {
- if (use_system_clip)
+ if (useSystemClip)
bounds = bounds.intersected(systemClip.boundingRect());
else
bounds = bounds.intersected(QRect(0, 0, width, height));
@@ -1994,6 +2015,11 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint value)
{
transferMode(BrushDrawingMode);
+ if (addOffset) {
+ addOffset = false;
+ matrixDirty = true;
+ }
+
if (matrixDirty)
updateMatrix();
@@ -2093,7 +2119,7 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op)
switch (op) {
case Qt::NoClip:
- if (d->use_system_clip) {
+ if (d->useSystemClip) {
state()->clipTestEnabled = true;
state()->currentClip = 1;
} else {
@@ -2165,13 +2191,13 @@ void QGL2PaintEngineExPrivate::systemStateChanged()
q->state()->clipChanged = true;
if (systemClip.isEmpty()) {
- use_system_clip = false;
+ useSystemClip = false;
} else {
if (q->paintDevice()->devType() == QInternal::Widget && currentClipWidget) {
QWidgetPrivate *widgetPrivate = qt_widget_private(currentClipWidget->window());
- use_system_clip = widgetPrivate->extra && widgetPrivate->extra->inRenderWithPainter;
+ useSystemClip = widgetPrivate->extra && widgetPrivate->extra->inRenderWithPainter;
} else {
- use_system_clip = true;
+ useSystemClip = true;
}
}
@@ -2181,19 +2207,19 @@ void QGL2PaintEngineExPrivate::systemStateChanged()
q->state()->currentClip = 1;
maxClip = 1;
- q->state()->rectangleClip = use_system_clip ? systemClip.boundingRect() : QRect(0, 0, width, height);
+ q->state()->rectangleClip = useSystemClip ? systemClip.boundingRect() : QRect(0, 0, width, height);
updateClipScissorTest();
if (systemClip.rectCount() == 1) {
if (systemClip.boundingRect() == QRect(0, 0, width, height))
- use_system_clip = false;
+ useSystemClip = false;
#ifndef QT_GL_NO_SCISSOR_TEST
// scissoring takes care of the system clip
return;
#endif
}
- if (use_system_clip) {
+ if (useSystemClip) {
clearClip(0);
QPainterPath path;
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index 77ca3a86f0..c94c4f48a4 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -105,13 +105,8 @@ public:
~QGL2PaintEngineEx();
bool begin(QPaintDevice *device);
- bool end();
-
void ensureActive();
-
- virtual void fill(const QVectorPath &path, const QBrush &brush);
- virtual void stroke(const QVectorPath &path, const QPen &pen);
- virtual void clip(const QVectorPath &path, Qt::ClipOperation op);
+ bool end();
virtual void clipEnabledChanged();
virtual void penChanged();
@@ -122,20 +117,21 @@ public:
virtual void renderHintsChanged();
virtual void transformChanged();
-
+ virtual void drawTexture(const QRectF &r, GLuint textureId, const QSize &size, const QRectF &sr);
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
+ virtual void drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints);
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
Qt::ImageConversionFlags flags = Qt::AutoColor);
- virtual void drawTexture(const QRectF &r, GLuint textureId, const QSize &size, const QRectF &sr);
-
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem);
+ virtual void fill(const QVectorPath &path, const QBrush &brush);
+ virtual void stroke(const QVectorPath &path, const QPen &pen);
+ virtual void clip(const QVectorPath &path, Qt::ClipOperation op);
- virtual void drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints);
Type type() const { return OpenGL2; }
- void setState(QPainterState *s);
- QPainterState *createState(QPainterState *orig) const;
+ virtual void setState(QPainterState *s);
+ virtual QPainterState *createState(QPainterState *orig) const;
inline QOpenGL2PaintEngineState *state() {
return static_cast<QOpenGL2PaintEngineState *>(QPaintEngineEx::state());
}
@@ -146,8 +142,6 @@ public:
void beginNativePainting();
void endNativePainting();
- const QGLContext* context();
-
QPixmapFilter *pixmapFilter(int type, const QPixmapFilter *prototype);
void setRenderTextActive(bool);
@@ -169,11 +163,12 @@ public:
QGL2PaintEngineExPrivate(QGL2PaintEngineEx *q_ptr) :
q(q_ptr),
+ shaderManager(0),
width(0), height(0),
ctx(0),
- currentBrush(0),
+ useSystemClip(true),
+ addOffset(false),
inverseScale(1),
- shaderManager(0),
inRenderText(false)
{ }
@@ -185,45 +180,62 @@ public:
void updateCompositionMode();
void updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id = -1);
- void setBrush(const QBrush* brush);
-
- void transferMode(EngineMode newMode);
void resetGLState();
- // fill, drawOutline, drawTexture & drawCachedGlyphs are the rendering entry points:
+ // fill, stroke, drawTexture, drawPixmaps & drawCachedGlyphs are the main rendering entry-points,
+ // however writeClip can also be thought of as en entry point as it does similar things.
void fill(const QVectorPath &path);
+ void stroke(const QVectorPath &path, const QPen &pen);
void drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern = false);
+ void drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints);
void drawCachedGlyphs(const QPointF &p, QFontEngineGlyphCache::Type glyphType, const QTextItemInt &ti);
+ // draws whatever is in the vertex array:
void drawVertexArrays(const float *data, int *stops, int stopCount, GLenum primitive);
void drawVertexArrays(QGL2PEXVertexArray &vertexArray, GLenum primitive) {
drawVertexArrays((const float *) vertexArray.data(), vertexArray.stops(), vertexArray.stopCount(), primitive);
}
- // ^ draws whatever is in the vertex array
+ // Composites the bounding rect onto dest buffer:
void composite(const QGLRect& boundingRect);
- // ^ Composites the bounding rect onto dest buffer
+ // Calls drawVertexArrays to render into stencil buffer:
void fillStencilWithVertexArray(const float *data, int count, int *stops, int stopCount, const QGLRect &bounds, StencilFillMode mode);
void fillStencilWithVertexArray(QGL2PEXVertexArray& vertexArray, bool useWindingFill) {
fillStencilWithVertexArray((const float *) vertexArray.data(), 0, vertexArray.stops(), vertexArray.stopCount(),
vertexArray.boundingRect(),
useWindingFill ? WindingFillMode : OddEvenFillMode);
}
- // ^ Calls drawVertexArrays to render into stencil buffer
-
- bool prepareForDraw(bool srcPixelsAreOpaque);
- // ^ returns whether the current program changed or not
+ void setBrush(const QBrush& brush);
+ void transferMode(EngineMode newMode);
+ bool prepareForDraw(bool srcPixelsAreOpaque); // returns true if the program has changed
inline void useSimpleShader();
+ inline GLuint location(const QGLEngineShaderManager::Uniform uniform) {
+ return shaderManager->getUniformLocation(uniform);
+ }
+
void prepareDepthRangeForRenderText();
void restoreDepthRangeForRenderText();
+ void clearClip(uint value);
+ void writeClip(const QVectorPath &path, uint value);
+ void resetClipIfNeeded();
+
+ void updateClipScissorTest();
+ void setScissor(const QRect &rect);
+ void regenerateClip();
+ void systemStateChanged();
+
+
static QGLEngineShaderManager* shaderManagerForEngine(QGL2PaintEngineEx *engine) { return engine->d_func()->shaderManager; }
static QGL2PaintEngineExPrivate *getData(QGL2PaintEngineEx *engine) { return engine->d_func(); }
+ static void cleanupVectorPath(QPaintEngineEx *engine, void *data);
+
QGL2PaintEngineEx* q;
+ QGLEngineShaderManager* shaderManager;
QGLPaintDevice* device;
int width, height;
QGLContext *ctx;
@@ -240,41 +252,25 @@ public:
bool opacityUniformDirty;
bool stencilClean; // Has the stencil not been used for clipping so far?
+ bool useSystemClip;
QRegion dirtyStencilRegion;
QRect currentScissorBounds;
uint maxClip;
- const QBrush* currentBrush; // May not be the state's brush!
-
- GLfloat inverseScale;
+ QBrush currentBrush; // May not be the state's brush!
+ const QBrush noBrush;
QGL2PEXVertexArray vertexCoordinateArray;
QGL2PEXVertexArray textureCoordinateArray;
QDataBuffer<GLfloat> opacityArray;
-
GLfloat staticVertexCoordinateArray[8];
GLfloat staticTextureCoordinateArray[8];
- GLfloat pmvMatrix[4][4];
-
- QGLEngineShaderManager* shaderManager;
-
- void clearClip(uint value);
- void writeClip(const QVectorPath &path, uint value);
- void resetClipIfNeeded();
-
- void updateClipScissorTest();
- void setScissor(const QRect &rect);
- void regenerateClip();
- void systemStateChanged();
- uint use_system_clip : 1;
-
- uint location(QGLEngineShaderManager::Uniform uniform)
- {
- return shaderManager->getUniformLocation(uniform);
- }
+ bool addOffset; // When enabled, adds a 0.49,0.49 offset to matrix in updateMatrix
+ GLfloat pmvMatrix[3][3];
+ GLfloat inverseScale;
- GLuint lastTexture;
+ GLuint lastTextureUsed;
bool needsSync;
bool inRenderText;
@@ -286,7 +282,6 @@ public:
QTriangulatingStroker stroker;
QDashedStrokeProcessor dasher;
- QTransform temporaryTransform;
QScopedPointer<QPixmapFilter> convolutionFilter;
QScopedPointer<QPixmapFilter> colorizeFilter;
diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
index 6082f49d86..395b8a3b36 100644
--- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
+++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
@@ -62,8 +62,14 @@ void QTriangulatingStroker::endCapOrJoinClosed(const qreal *start, const qreal *
endCap(cur);
}
int count = m_vertices.size();
- m_vertices.add(m_vertices.at(count-2));
- m_vertices.add(m_vertices.at(count-1));
+
+ // Copy the (x, y) values because QDataBuffer::add(const float& t)
+ // may resize the buffer, which will leave t pointing at the
+ // previous buffer's memory region if we don't copy first.
+ float x = m_vertices.at(count-2);
+ float y = m_vertices.at(count-1);
+ m_vertices.add(x);
+ m_vertices.add(y);
}
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index b4191dcc3b..f9737a5612 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -2275,6 +2275,42 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x4& value
\overload
Sets the uniform variable at \a location in the current context
+ to a 2x2 matrix \a value. The matrix elements must be specified
+ in column-major order.
+
+ \sa setAttributeValue()
+ \since 4.6.2
+*/
+void QGLShaderProgram::setUniformValue(int location, const GLfloat value[2][2])
+{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
+ if (location != -1)
+ glUniformMatrix2fv(location, 1, GL_FALSE, value[0]);
+}
+
+/*!
+ \overload
+
+ Sets the uniform variable at \a location in the current context
+ to a 3x3 matrix \a value. The matrix elements must be specified
+ in column-major order.
+
+ \sa setAttributeValue()
+ \since 4.6.2
+*/
+void QGLShaderProgram::setUniformValue(int location, const GLfloat value[3][3])
+{
+ Q_D(QGLShaderProgram);
+ Q_UNUSED(d);
+ if (location != -1)
+ glUniformMatrix3fv(location, 1, GL_FALSE, value[0]);
+}
+
+/*!
+ \overload
+
+ Sets the uniform variable at \a location in the current context
to a 4x4 matrix \a value. The matrix elements must be specified
in column-major order.
@@ -2288,6 +2324,37 @@ void QGLShaderProgram::setUniformValue(int location, const GLfloat value[4][4])
glUniformMatrix4fv(location, 1, GL_FALSE, value[0]);
}
+
+/*!
+ \overload
+
+ Sets the uniform variable called \a name in the current context
+ to a 2x2 matrix \a value. The matrix elements must be specified
+ in column-major order.
+
+ \sa setAttributeValue()
+ \since 4.6.2
+*/
+void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[2][2])
+{
+ setUniformValue(uniformLocation(name), value);
+}
+
+/*!
+ \overload
+
+ Sets the uniform variable called \a name in the current context
+ to a 3x3 matrix \a value. The matrix elements must be specified
+ in column-major order.
+
+ \sa setAttributeValue()
+ \since 4.6.2
+*/
+void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[3][3])
+{
+ setUniformValue(uniformLocation(name), value);
+}
+
/*!
\overload
diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h
index deeaee2bf2..4eb80dde8e 100644
--- a/src/opengl/qglshaderprogram.h
+++ b/src/opengl/qglshaderprogram.h
@@ -216,6 +216,8 @@ public:
void setUniformValue(int location, const QMatrix4x2& value);
void setUniformValue(int location, const QMatrix4x3& value);
void setUniformValue(int location, const QMatrix4x4& value);
+ void setUniformValue(int location, const GLfloat value[2][2]);
+ void setUniformValue(int location, const GLfloat value[3][3]);
void setUniformValue(int location, const GLfloat value[4][4]);
void setUniformValue(int location, const QTransform& value);
@@ -242,6 +244,8 @@ public:
void setUniformValue(const char *name, const QMatrix4x2& value);
void setUniformValue(const char *name, const QMatrix4x3& value);
void setUniformValue(const char *name, const QMatrix4x4& value);
+ void setUniformValue(const char *name, const GLfloat value[2][2]);
+ void setUniformValue(const char *name, const GLfloat value[3][3]);
void setUniformValue(const char *name, const GLfloat value[4][4]);
void setUniformValue(const char *name, const QTransform& value);
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index ed7fdff167..8dae02a4bd 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -4522,6 +4522,12 @@ typedef QHash<QFontEngine*, QGLGlyphHash*> QGLFontGlyphHash;
typedef QHash<quint64, QGLFontTexture*> QGLFontTexHash;
typedef QHash<const QGLContext*, QGLFontGlyphHash*> QGLContextHash;
+static inline void qt_delete_glyph_hash(QGLGlyphHash *hash)
+{
+ qDeleteAll(*hash);
+ delete hash;
+}
+
class QGLGlyphCache : public QObject
{
Q_OBJECT
@@ -4562,7 +4568,7 @@ void QGLGlyphCache::fontEngineDestroyed(QObject *o)
if (font_cache->find(fe) != font_cache->end()) {
ctx = keys.at(i);
QGLGlyphHash *cache = font_cache->take(fe);
- delete cache;
+ qt_delete_glyph_hash(cache);
break;
}
}
@@ -4599,7 +4605,7 @@ void QGLGlyphCache::cleanupContext(const QGLContext *ctx)
QList<QFontEngine *> keys = font_cache->keys();
for (int i=0; i < keys.size(); ++i) {
QFontEngine *fe = keys.at(i);
- delete font_cache->take(fe);
+ qt_delete_glyph_hash(font_cache->take(fe));
quint64 font_key = (reinterpret_cast<quint64>(ctx) << 32) | reinterpret_cast<quint64>(fe);
QGLFontTexture *font_tex = qt_font_textures.take(font_key);
if (font_tex) {
@@ -4640,7 +4646,9 @@ void QGLGlyphCache::cleanCache()
QList<const QGLContext *> keys = qt_context_cache.keys();
for (int i=0; i < keys.size(); ++i) {
QGLFontGlyphHash *font_cache = qt_context_cache.value(keys.at(i));
- qDeleteAll(*font_cache);
+ QGLFontGlyphHash::Iterator it = font_cache->begin();
+ for (; it != font_cache->end(); ++it)
+ qt_delete_glyph_hash(it.value());
font_cache->clear();
}
qDeleteAll(qt_context_cache);
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
index 4e1d50d32c..92c990b482 100644
--- a/src/opengl/qpixmapdata_gl.cpp
+++ b/src/opengl/qpixmapdata_gl.cpp
@@ -341,22 +341,11 @@ void QGLPixmapData::ensureCreated() const
if (!m_source.isNull()) {
if (external_format == GL_RGB) {
- QImage tx = m_source.convertToFormat(QImage::Format_RGB32);
-
- QVector<uchar> pixelData(w * h * 3);
- uchar *p = &pixelData[0];
- QRgb *src = (QRgb *)tx.bits();
-
- for (int i = 0; i < w * h; ++i) {
- *p++ = qRed(*src);
- *p++ = qGreen(*src);
- *p++ = qBlue(*src);
- ++src;
- }
+ const QImage tx = m_source.convertToFormat(QImage::Format_RGB888);
glBindTexture(target, m_texture.id);
glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
- GL_UNSIGNED_BYTE, &pixelData[0]);
+ GL_UNSIGNED_BYTE, tx.bits());
} else {
const QImage tx = ctx->d_func()->convertToGLFormat(m_source, true, external_format);
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index 4744eb6851..bb26d2926d 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -1063,7 +1063,7 @@ static inline bool setIntOption(const QStringList &arguments, const QString &var
static inline QColor colorFromName(const QString &name)
{
- QRegExp rx("#([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])");
+ QRegExp rx(QLatin1String("#([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])"));
rx.setCaseSensitivity(Qt::CaseInsensitive);
if (rx.exactMatch(name)) {
Q_ASSERT(rx.captureCount() == 4);
@@ -1278,7 +1278,14 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
#ifdef QT_NO_DIRECTFB_WM
result = d_ptr->primarySurface->GetSize(d_ptr->primarySurface, &w, &h);
#elif (Q_DIRECTFB_VERSION >= 0x010000)
- result = d_ptr->dfbScreen->GetSize(d_ptr->dfbScreen, &w, &h);
+ IDirectFBSurface *layerSurface;
+ if (d_ptr->dfbLayer->GetSurface(d_ptr->dfbLayer, &layerSurface) != DFB_OK) {
+ result = layerSurface->GetSize(layerSurface, &w, &h);
+ layerSurface->Release(layerSurface);
+ }
+ if (w <= 0 || h <= 0) {
+ result = d_ptr->dfbScreen->GetSize(d_ptr->dfbScreen, &w, &h);
+ }
#else
qWarning("QDirectFBScreen::connect: DirectFB versions prior to 1.0 do not offer a way\n"
"query the size of the primary surface in windowed mode. You have to specify\n"
diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp
index c95b63ca72..dee0e526c9 100644
--- a/src/plugins/imageformats/gif/qgifhandler.cpp
+++ b/src/plugins/imageformats/gif/qgifhandler.cpp
@@ -54,6 +54,10 @@ QT_BEGIN_NAMESPACE
#define Q_TRANSPARENT 0x00ffffff
+// avoid going through QImage::scanLine() which calls detach
+#define FAST_SCAN_LINE(bits, bpl, y) (bits + (y) * bpl)
+
+
/*
Incremental image decoder for GIF image format.
@@ -135,7 +139,7 @@ private:
int frame;
bool out_of_bounds;
bool digress;
- void nextY(QImage *image);
+ void nextY(unsigned char *bits, int bpl);
void disposePrevious(QImage *image);
};
@@ -232,6 +236,10 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
// CompuServe Incorporated. GIF(sm) is a Service Mark property of
// CompuServe Incorporated."
+ image->detach();
+ int bpl = image->bytesPerLine();
+ unsigned char *bits = image->bits();
+
#define LM(l, m) (((m)<<8)|l)
digress = false;
const int initial = length;
@@ -335,7 +343,9 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
QImage::Format format = trans_index >= 0 ? QImage::Format_ARGB32 : QImage::Format_RGB32;
if (image->isNull()) {
(*image) = QImage(swidth, sheight, format);
- memset(image->bits(), 0, image->byteCount());
+ bpl = image->bytesPerLine();
+ bits = image->bits();
+ memset(bits, 0, image->byteCount());
// ### size of the upcoming frame, should rather
// be known before decoding it.
@@ -393,11 +403,13 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
backingstore = QImage(qMax(backingstore.width(), w),
qMax(backingstore.height(), h),
QImage::Format_RGB32);
- memset(image->bits(), 0, image->byteCount());
+ memset(bits, 0, image->byteCount());
}
+ const int dest_bpl = backingstore.bytesPerLine();
+ unsigned char *dest_data = backingstore.bits();
for (int ln=0; ln<h; ln++) {
- memcpy(backingstore.scanLine(ln),
- image->scanLine(t+ln)+l, w*sizeof(QRgb));
+ memcpy(FAST_SCAN_LINE(dest_data, dest_bpl, ln),
+ FAST_SCAN_LINE(bits, bpl, t+ln) + l, w*sizeof(QRgb));
}
}
@@ -470,14 +482,14 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
if (needfirst) {
firstcode=oldcode=code;
if (!out_of_bounds && image->height() > y && firstcode!=trans_index)
- ((QRgb*)image->scanLine(y))[x] = color(firstcode);
+ ((QRgb*)FAST_SCAN_LINE(bits, bpl, y))[x] = color(firstcode);
x++;
if (x>=swidth) out_of_bounds = true;
needfirst=false;
if (x>=left+width) {
x=left;
out_of_bounds = left>=swidth || y>=sheight;
- nextY(image);
+ nextY(bits, bpl);
}
} else {
incode=code;
@@ -515,7 +527,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
const QRgb *map = lcmap ? localcmap : globalcmap;
QRgb *line = 0;
if (!out_of_bounds && h > y)
- line = (QRgb*)image->scanLine(y);
+ line = (QRgb*)FAST_SCAN_LINE(bits, bpl, y);
while (sp>stack) {
const uchar index = *(--sp);
if (!out_of_bounds && h > y && index!=trans_index) {
@@ -529,9 +541,9 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
if (x>=left+width) {
x=left;
out_of_bounds = left>=swidth || y>=sheight;
- nextY(image);
+ nextY(bits, bpl);
if (!out_of_bounds && h > y)
- line = (QRgb*)image->scanLine(y);
+ line = (QRgb*)FAST_SCAN_LINE(bits, bpl, y);
}
}
}
@@ -644,7 +656,7 @@ void QGIFFormat::fillRect(QImage *image, int col, int row, int w, int h, QRgb co
}
}
-void QGIFFormat::nextY(QImage *image)
+void QGIFFormat::nextY(unsigned char *bits, int bpl)
{
int my;
switch (interlace) {
@@ -660,7 +672,7 @@ void QGIFFormat::nextY(QImage *image)
// Don't dup with transparency
if (trans_index < 0) {
for (i=1; i<=my; i++) {
- memcpy(image->scanLine(y+i)+left*sizeof(QRgb), image->scanLine(y)+left*sizeof(QRgb),
+ memcpy(FAST_SCAN_LINE(bits, bpl, y+i)+left*sizeof(QRgb), FAST_SCAN_LINE(bits, bpl, y)+left*sizeof(QRgb),
(right-left+1)*sizeof(QRgb));
}
}
@@ -689,7 +701,7 @@ void QGIFFormat::nextY(QImage *image)
// Don't dup with transparency
if (trans_index < 0) {
for (i=1; i<=my; i++) {
- memcpy(image->scanLine(y+i)+left*sizeof(QRgb), image->scanLine(y)+left*sizeof(QRgb),
+ memcpy(FAST_SCAN_LINE(bits, bpl, y+i)+left*sizeof(QRgb), FAST_SCAN_LINE(bits, bpl, y)+left*sizeof(QRgb),
(right-left+1)*sizeof(QRgb));
}
}
@@ -713,7 +725,7 @@ void QGIFFormat::nextY(QImage *image)
// Don't dup with transparency
if (trans_index < 0) {
for (i=1; i<=my; i++) {
- memcpy(image->scanLine(y+i)+left*sizeof(QRgb), image->scanLine(y)+left*sizeof(QRgb),
+ memcpy(FAST_SCAN_LINE(bits, bpl, y+i)+left*sizeof(QRgb), FAST_SCAN_LINE(bits, bpl, y)+left*sizeof(QRgb),
(right-left+1)*sizeof(QRgb));
}
}
diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
index 54bbcda26b..11608ef8d5 100644
--- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp
+++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
@@ -84,15 +84,12 @@ class QImageSmoothScaler
public:
QImageSmoothScaler(const int w, const int h, const QImage &src);
QImageSmoothScaler(const int srcWidth, const int srcHeight,
- const char *parameters);
+ const int dstWidth, const int dstHeight);
virtual ~QImageSmoothScaler(void);
QImage scale();
-protected:
- int scaledWidth(void) const;
-
private:
QImageSmoothScalerPrivate *d;
virtual QRgb *scanLine(const int line = 0, const QImage *src = 0);
@@ -123,33 +120,9 @@ QImageSmoothScaler::QImageSmoothScaler(const int w, const int h,
}
QImageSmoothScaler::QImageSmoothScaler(const int srcWidth, const int srcHeight,
- const char *parameters)
+ const int dstWidth, const int dstHeight)
{
- char sModeStr[1024];
- int t1;
- int t2;
- int dstWidth;
- int dstHeight;
-
- sModeStr[0] = '\0';
-
d = new QImageSmoothScalerPrivate;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && defined(_MSC_VER) && _MSC_VER >= 1400
- sscanf_s(parameters, "Scale( %i, %i, %1023s )", &dstWidth, &dstHeight, sModeStr, sizeof(sModeStr));
-#else
- sscanf(parameters, "Scale( %i, %i, %s )", &dstWidth, &dstHeight, sModeStr);
-#endif
- QString sModeQStr = QString::fromLatin1(sModeStr);
-
- t1 = srcWidth * dstHeight;
- t2 = srcHeight * dstWidth;
-
- if (((sModeQStr == QLatin1String("ScaleMin")) && (t1 > t2)) || ((sModeQStr == QLatin1String("ScaleMax")) && (t2 < t2))) {
- dstHeight = t2 / srcWidth;
- } else if (sModeQStr != QLatin1String("ScaleFree")) {
- dstWidth = t1 / srcHeight;
- }
-
d->setup(srcWidth, srcHeight, dstWidth, dstHeight, 0);
}
@@ -164,11 +137,6 @@ void QImageSmoothScalerPrivate::setup(const int srcWidth, const int srcHeight,
hasAlpha = hasAlphaChannel;
}
-int QImageSmoothScaler::scaledWidth() const
-{
- return d->cols;
-}
-
QImageSmoothScaler::~QImageSmoothScaler()
{
delete d;
@@ -467,20 +435,18 @@ QImage QImageSmoothScaler::scale()
class jpegSmoothScaler : public QImageSmoothScaler
{
public:
- jpegSmoothScaler(struct jpeg_decompress_struct *info, const char *params):
- QImageSmoothScaler(info->output_width, info->output_height, params)
+ jpegSmoothScaler(struct jpeg_decompress_struct *info, const QSize& dstSize, const QRect& clipRect)
+ : QImageSmoothScaler(clipRect.width(), clipRect.height(),
+ dstSize.width(), dstSize.height())
{
- cinfo = info;
- cols24Bit = scaledWidth() * 3;
-
- cacheHeight = 1;
- imageCache = QImage( info->output_width, cacheHeight, QImage::Format_RGB32 );
+ cinfo = info;
+ clip = clipRect;
+ imageCache = QImage(info->output_width, 1, QImage::Format_RGB32);
}
private:
- int cols24Bit;
+ QRect clip;
QImage imageCache;
- int cacheHeight;
struct jpeg_decompress_struct *cinfo;
QRgb *scanLine(const int line = 0, const QImage *src = 0)
@@ -492,33 +458,42 @@ private:
Q_UNUSED(src);
uchar* data = imageCache.bits();
+
+ // Read ahead if we haven't reached the first clipped scanline yet.
+ while (int(cinfo->output_scanline) < clip.y() &&
+ cinfo->output_scanline < cinfo->output_height)
+ jpeg_read_scanlines(cinfo, &data, 1);
+
+ // Read the next scanline. We assume that "line"
+ // will never be >= clip.height().
jpeg_read_scanlines(cinfo, &data, 1);
- out = (QRgb*)imageCache.scanLine(0);
+ if (cinfo->output_scanline == cinfo->output_height)
+ jpeg_finish_decompress(cinfo);
+
+ out = ((QRgb*)data) + clip.x();
//
// The smooth scale algorithm only works on 32-bit images;
// convert from (8|24) bits to 32.
//
if (cinfo->output_components == 1) {
- in = (uchar*)out + scaledWidth();
- for (uint i = scaledWidth(); i--; ) {
- in--;
+ in = data + clip.right();
+ for (int i = clip.width(); i--; ) {
out[i] = qRgb(*in, *in, *in);
+ in--;
}
- } else if (cinfo->out_color_space == JCS_CMYK) {
- int cols32Bit = scaledWidth() * 4;
- in = (uchar*)out + cols32Bit;
- for (uint i = scaledWidth(); i--; ) {
- in -= 4;
- int k = in[3];
- out[i] = qRgb(k * in[0] / 255, k * in[1] / 255, k * in[2] / 255);
- //out[i] = qRgb(in[0], in[1], in[2]);
- }
- } else {
- in = (uchar*)out + cols24Bit;
- for (uint i = scaledWidth(); i--; ) {
- in -= 3;
+ } else if (cinfo->out_color_space == JCS_CMYK) {
+ in = data + clip.right() * 4;
+ for (int i = clip.width(); i--; ) {
+ int k = in[3];
+ out[i] = qRgb(k * in[0] / 255, k * in[1] / 255, k * in[2] / 255);
+ in -= 4;
+ }
+ } else {
+ in = data + clip.right() * 3;
+ for (int i = clip.width(); i--; ) {
out[i] = qRgb(in[0], in[1], in[2]);
+ in -= 3;
}
}
@@ -637,18 +612,6 @@ inline my_jpeg_source_mgr::my_jpeg_source_mgr(QIODevice *device)
}
-static void scaleSize(int &reqW, int &reqH, int imgW, int imgH, Qt::AspectRatioMode mode)
-{
- if (mode == Qt::IgnoreAspectRatio)
- return;
- int t1 = imgW * reqH;
- int t2 = reqW * imgH;
- if ((mode == Qt::KeepAspectRatio && (t1 > t2)) || (mode == Qt::KeepAspectRatioByExpanding && (t1 < t2)))
- reqH = t2 / imgW;
- else
- reqW = t1 / imgH;
-}
-
static bool read_jpeg_size(QIODevice *device, int &w, int &h)
{
bool rt = false;
@@ -729,7 +692,7 @@ static bool read_jpeg_format(QIODevice *device, QImage::Format &format)
}
static bool ensureValidImage(QImage *dest, struct jpeg_decompress_struct *info,
- bool dummy = false)
+ const QSize& size)
{
QImage::Format format;
switch (info->output_components) {
@@ -744,13 +707,8 @@ static bool ensureValidImage(QImage *dest, struct jpeg_decompress_struct *info,
return false; // unsupported format
}
- const QSize size(info->output_width, info->output_height);
if (dest->size() != size || dest->format() != format) {
- static uchar dummyImage[1];
- if (dummy) // Create QImage but don't read the pixels
- *dest = QImage(dummyImage, size.width(), size.height(), format);
- else
- *dest = QImage(size, format);
+ *dest = QImage(size, format);
if (format == QImage::Format_Indexed8) {
dest->setColorCount(256);
@@ -763,13 +721,9 @@ static bool ensureValidImage(QImage *dest, struct jpeg_decompress_struct *info,
}
static bool read_jpeg_image(QIODevice *device, QImage *outImage,
- const QByteArray &parameters, QSize scaledSize,
- int inQuality )
+ QSize scaledSize, QRect scaledClipRect,
+ QRect clipRect, int inQuality )
{
-#ifdef QT_NO_IMAGE_SMOOTHSCALE
- Q_UNUSED( scaledSize );
-#endif
-
struct jpeg_decompress_struct cinfo;
struct my_jpeg_source_mgr *iod_src = new my_jpeg_source_mgr(device);
@@ -794,18 +748,53 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
if (quality < 0)
quality = 75;
- QString params = QString::fromLatin1(parameters);
- params.simplified();
- int sWidth = 0, sHeight = 0;
- char sModeStr[1024] = "";
- Qt::AspectRatioMode sMode;
+ // If possible, merge the scaledClipRect into either scaledSize
+ // or clipRect to avoid doing a separate scaled clipping pass.
+ // Best results are achieved by clipping before scaling, not after.
+ if (!scaledClipRect.isEmpty()) {
+ if (scaledSize.isEmpty() && clipRect.isEmpty()) {
+ // No clipping or scaling before final clip.
+ clipRect = scaledClipRect;
+ scaledClipRect = QRect();
+ } else if (scaledSize.isEmpty()) {
+ // Clipping, but no scaling: combine the clip regions.
+ scaledClipRect.translate(clipRect.topLeft());
+ clipRect = scaledClipRect.intersected(clipRect);
+ scaledClipRect = QRect();
+ } else if (clipRect.isEmpty()) {
+ // No clipping, but scaling: if we can map back to an
+ // integer pixel boundary, then clip before scaling.
+ if ((cinfo.image_width % scaledSize.width()) == 0 &&
+ (cinfo.image_height % scaledSize.height()) == 0) {
+ int x = scaledClipRect.x() * cinfo.image_width /
+ scaledSize.width();
+ int y = scaledClipRect.y() * cinfo.image_height /
+ scaledSize.height();
+ int width = (scaledClipRect.right() + 1) *
+ cinfo.image_width / scaledSize.width() - x;
+ int height = (scaledClipRect.bottom() + 1) *
+ cinfo.image_height / scaledSize.height() - y;
+ clipRect = QRect(x, y, width, height);
+ scaledSize = scaledClipRect.size();
+ scaledClipRect = QRect();
+ }
+ } else {
+ // Clipping and scaling: too difficult to figure out,
+ // and not a likely use case, so do it the long way.
+ }
+ }
-#ifndef QT_NO_IMAGE_SMOOTHSCALE
- // If high quality not required, shrink image during decompression
- if (scaledSize.isValid() && !scaledSize.isEmpty() && quality < HIGH_QUALITY_THRESHOLD
- && !params.contains(QLatin1String("GetHeaderInformation")) ) {
- cinfo.scale_denom = qMin(cinfo.image_width / scaledSize.width(),
- cinfo.image_width / scaledSize.height());
+ // Determine the scale factor to pass to libjpeg for quick downscaling.
+ if (!scaledSize.isEmpty()) {
+ if (clipRect.isEmpty()) {
+ cinfo.scale_denom =
+ qMin(cinfo.image_width / scaledSize.width(),
+ cinfo.image_height / scaledSize.height());
+ } else {
+ cinfo.scale_denom =
+ qMin(clipRect.width() / scaledSize.width(),
+ clipRect.height() / scaledSize.height());
+ }
if (cinfo.scale_denom < 2) {
cinfo.scale_denom = 1;
} else if (cinfo.scale_denom < 4) {
@@ -816,9 +805,19 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
cinfo.scale_denom = 8;
}
cinfo.scale_num = 1;
+ if (!clipRect.isEmpty()) {
+ // Correct the scale factor so that we clip accurately.
+ // It is recommended that the clip rectangle be aligned
+ // on an 8-pixel boundary for best performance.
+ while (cinfo.scale_denom > 1 &&
+ ((clipRect.x() % cinfo.scale_denom) != 0 ||
+ (clipRect.y() % cinfo.scale_denom) != 0 ||
+ (clipRect.width() % cinfo.scale_denom) != 0 ||
+ (clipRect.height() % cinfo.scale_denom) != 0)) {
+ cinfo.scale_denom /= 2;
+ }
+ }
}
-#endif
-
// If high quality not required, use fast decompression
if( quality < HIGH_QUALITY_THRESHOLD ) {
@@ -826,132 +825,102 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
cinfo.do_fancy_upsampling = FALSE;
}
+ (void) jpeg_calc_output_dimensions(&cinfo);
- (void) jpeg_start_decompress(&cinfo);
+ // Determine the clip region to extract.
+ QRect imageRect(0, 0, cinfo.output_width, cinfo.output_height);
+ QRect clip;
+ if (clipRect.isEmpty()) {
+ clip = imageRect;
+ } else if (cinfo.scale_denom == 1) {
+ clip = clipRect.intersected(imageRect);
+ } else {
+ // The scale factor was corrected above to ensure that
+ // we don't miss pixels when we scale the clip rectangle.
+ clip = QRect(clipRect.x() / int(cinfo.scale_denom),
+ clipRect.y() / int(cinfo.scale_denom),
+ clipRect.width() / int(cinfo.scale_denom),
+ clipRect.height() / int(cinfo.scale_denom));
+ clip = clip.intersected(imageRect);
+ }
- if (params.contains(QLatin1String("GetHeaderInformation"))) {
- if (!ensureValidImage(outImage, &cinfo, true))
- longjmp(jerr.setjmp_buffer, 1);
- } else if (params.contains(QLatin1String("Scale"))) {
-#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
- sscanf_s(params.toLatin1().data(), "Scale(%i, %i, %1023s)",
- &sWidth, &sHeight, sModeStr, sizeof(sModeStr));
-#else
- sscanf(params.toLatin1().data(), "Scale(%i, %i, %1023s)",
- &sWidth, &sHeight, sModeStr);
-#endif
+#ifndef QT_NO_IMAGE_SMOOTHSCALE
+ if (scaledSize.isValid() && scaledSize != clip.size()
+ && quality >= HIGH_QUALITY_THRESHOLD) {
- QString sModeQStr(QString::fromLatin1(sModeStr));
- if (sModeQStr == QLatin1String("IgnoreAspectRatio")) {
- sMode = Qt::IgnoreAspectRatio;
- } else if (sModeQStr == QLatin1String("KeepAspectRatio")) {
- sMode = Qt::KeepAspectRatio;
- } else if (sModeQStr == QLatin1String("KeepAspectRatioByExpanding")) {
- sMode = Qt::KeepAspectRatioByExpanding;
- } else {
- qDebug("read_jpeg_image: invalid aspect ratio mode \"%s\", see QImage::AspectRatioMode documentation", sModeStr);
- sMode = Qt::KeepAspectRatio;
- }
+ (void) jpeg_start_decompress(&cinfo);
-// qDebug("Parameters ask to scale the image to %i x %i AspectRatioMode: %s", sWidth, sHeight, sModeStr);
- scaleSize(sWidth, sHeight, cinfo.output_width, cinfo.output_height, sMode);
-// qDebug("Scaling the jpeg to %i x %i", sWidth, sHeight, sModeStr);
-
- if (cinfo.output_components == 3 || cinfo.output_components == 4) {
- if (outImage->size() != QSize(sWidth, sHeight) || outImage->format() != QImage::Format_RGB32)
- *outImage = QImage(sWidth, sHeight, QImage::Format_RGB32);
- } else if (cinfo.output_components == 1) {
- if (outImage->size() != QSize(sWidth, sHeight) || outImage->format() != QImage::Format_Indexed8)
- *outImage = QImage(sWidth, sHeight, QImage::Format_Indexed8);
- outImage->setColorCount(256);
- for (int i = 0; i < 256; ++i)
- outImage->setColor(i, qRgb(i,i,i));
- } else {
- // Unsupported format
- }
- if (outImage->isNull())
+ jpegSmoothScaler scaler(&cinfo, scaledSize, clip);
+ *outImage = scaler.scale();
+ } else
+#endif
+ {
+ // Allocate memory for the clipped QImage.
+ if (!ensureValidImage(outImage, &cinfo, clip.size()))
longjmp(jerr.setjmp_buffer, 1);
- if (!outImage->isNull()) {
- QImage tmpImage(cinfo.output_width, 1, QImage::Format_RGB32);
- uchar* inData = tmpImage.bits();
- uchar* outData = outImage->bits();
- int out_bpl = outImage->bytesPerLine();
+ // Avoid memcpy() overhead if grayscale with no clipping.
+ bool quickGray = (cinfo.output_components == 1 &&
+ clip == imageRect);
+ if (!quickGray) {
+ // Ask the jpeg library to allocate a temporary row.
+ // The library will automatically delete it for us later.
+ // The libjpeg docs say we should do this before calling
+ // jpeg_start_decompress(). We can't use "new" here
+ // because we are inside the setjmp() block and an error
+ // in the jpeg input stream would cause a memory leak.
+ JSAMPARRAY rows = (cinfo.mem->alloc_sarray)
+ ((j_common_ptr)&cinfo, JPOOL_IMAGE,
+ cinfo.output_width * cinfo.output_components, 1);
+
+ (void) jpeg_start_decompress(&cinfo);
+
while (cinfo.output_scanline < cinfo.output_height) {
- int outputLine = sHeight * cinfo.output_scanline / cinfo.output_height;
- (void) jpeg_read_scanlines(&cinfo, &inData, 1);
+ int y = int(cinfo.output_scanline) - clip.y();
+ if (y >= clip.height())
+ break; // We've read the entire clip region, so abort.
+
+ (void) jpeg_read_scanlines(&cinfo, rows, 1);
+
+ if (y < 0)
+ continue; // Haven't reached the starting line yet.
+
if (cinfo.output_components == 3) {
- uchar *in = inData;
- QRgb *out = (QRgb*)outData + outputLine * out_bpl;
- for (uint i=0; i<cinfo.output_width; i++) {
-// ### Only scaling down an image works, I don't think scaling up will work at the moment
-// ### An idea I have to make this a smooth scale is to progressively add the pixel values up
-// When scaling down, multiple values are being over drawn in to the output buffer.
-// Instead, a weighting based on the distance the line or pixel is from the output pixel determines
-// the weight of it when added to the output buffer. At present it is a non-smooth scale which is
-// inefficently implemented, it still uncompresses all the jpeg, an optimization for progressive
-// jpegs could be made if scaling by say 50% or some other special cases
- out[sWidth * i / cinfo.output_width] = qRgb(in[0], in[1], in[2]);
+ // Expand 24->32 bpp.
+ uchar *in = rows[0] + clip.x() * 3;
+ QRgb *out = (QRgb*)outImage->scanLine(y);
+ for (int i = 0; i < clip.width(); ++i) {
+ *out++ = qRgb(in[0], in[1], in[2]);
in += 3;
}
- } else {
-// ### Need to test the case where the jpeg is grayscale, need some black and white jpegs to test
-// this code. (also only scales down and probably won't scale to a larger size)
- uchar *in = inData;
- uchar *out = outData + outputLine*out_bpl;
- for (uint i=0; i<cinfo.output_width; i++) {
- out[sWidth * i / cinfo.output_width] = in[i];
+ } else if (cinfo.out_color_space == JCS_CMYK) {
+ // Convert CMYK->RGB.
+ uchar *in = rows[0] + clip.x() * 4;
+ QRgb *out = (QRgb*)outImage->scanLine(y);
+ for (int i = 0; i < clip.width(); ++i) {
+ int k = in[3];
+ *out++ = qRgb(k * in[0] / 255, k * in[1] / 255,
+ k * in[2] / 255);
+ in += 4;
}
+ } else if (cinfo.output_components == 1) {
+ // Grayscale.
+ memcpy(outImage->scanLine(y),
+ rows[0] + clip.x(), clip.width());
}
}
- (void) jpeg_finish_decompress(&cinfo);
- }
-#ifndef QT_NO_IMAGE_SMOOTHSCALE
- } else if (scaledSize.isValid() && scaledSize != QSize(cinfo.output_width, cinfo.output_height)
- && quality >= HIGH_QUALITY_THRESHOLD) {
-
- jpegSmoothScaler scaler(&cinfo, QString().sprintf("Scale( %d, %d, ScaleFree )",
- scaledSize.width(),
- scaledSize.height()).toLatin1().data());
- *outImage = scaler.scale();
-#endif
- } else {
- if (!ensureValidImage(outImage, &cinfo))
- longjmp(jerr.setjmp_buffer, 1);
-
- uchar* data = outImage->bits();
- int bpl = outImage->bytesPerLine();
- while (cinfo.output_scanline < cinfo.output_height) {
- uchar *d = data + cinfo.output_scanline * bpl;
- (void) jpeg_read_scanlines(&cinfo,
- &d,
- 1);
+ } else {
+ // Load unclipped grayscale data directly into the QImage.
+ (void) jpeg_start_decompress(&cinfo);
+ while (cinfo.output_scanline < cinfo.output_height) {
+ uchar *row = outImage->scanLine(cinfo.output_scanline);
+ (void) jpeg_read_scanlines(&cinfo, &row, 1);
+ }
}
- (void) jpeg_finish_decompress(&cinfo);
- if (cinfo.output_components == 3) {
- // Expand 24->32 bpp.
- for (uint j=0; j<cinfo.output_height; j++) {
- uchar *in = outImage->scanLine(j) + cinfo.output_width * 3;
- QRgb *out = (QRgb*)outImage->scanLine(j);
+ if (cinfo.output_scanline == cinfo.output_height)
+ (void) jpeg_finish_decompress(&cinfo);
- for (uint i=cinfo.output_width; i--;) {
- in-=3;
- out[i] = qRgb(in[0], in[1], in[2]);
- }
- }
- } else if (cinfo.out_color_space == JCS_CMYK) {
- for (uint j = 0; j < cinfo.output_height; ++j) {
- uchar *in = outImage->scanLine(j) + cinfo.output_width * 4;
- QRgb *out = (QRgb*)outImage->scanLine(j);
-
- for (uint i = cinfo.output_width; i--; ) {
- in-=4;
- int k = in[3];
- out[i] = qRgb(k * in[0] / 255, k * in[1] / 255, k * in[2] / 255);
- }
- }
- }
if (cinfo.density_unit == 1) {
outImage->setDotsPerMeterX(int(100. * cinfo.X_density / 2.54));
outImage->setDotsPerMeterY(int(100. * cinfo.Y_density / 2.54));
@@ -960,13 +929,15 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
outImage->setDotsPerMeterY(int(100. * cinfo.Y_density));
}
- if (scaledSize.isValid() && scaledSize != QSize(cinfo.output_width, cinfo.output_height))
+ if (scaledSize.isValid() && scaledSize != clip.size())
*outImage = outImage->scaled(scaledSize, Qt::IgnoreAspectRatio, Qt::FastTransformation);
}
}
jpeg_destroy_decompress(&cinfo);
delete iod_src;
+ if (!scaledClipRect.isEmpty())
+ *outImage = outImage->copy(scaledClipRect);
return !outImage->isNull();
}
@@ -1224,7 +1195,7 @@ bool QJpegHandler::read(QImage *image)
{
if (!canRead())
return false;
- return read_jpeg_image(device(), image, parameters, scaledSize, quality);
+ return read_jpeg_image(device(), image, scaledSize, scaledClipRect, clipRect, quality);
}
bool QJpegHandler::write(const QImage &image)
@@ -1235,9 +1206,9 @@ bool QJpegHandler::write(const QImage &image)
bool QJpegHandler::supportsOption(ImageOption option) const
{
return option == Quality
-#ifndef QT_NO_IMAGE_SMOOTHSCALE
|| option == ScaledSize
-#endif
+ || option == ScaledClipRect
+ || option == ClipRect
|| option == Size
|| option == ImageFormat;
}
@@ -1246,10 +1217,12 @@ QVariant QJpegHandler::option(ImageOption option) const
{
if (option == Quality) {
return quality;
-#ifndef QT_NO_IMAGE_SMOOTHSCALE
} else if (option == ScaledSize) {
return scaledSize;
-#endif
+ } else if (option == ScaledClipRect) {
+ return scaledClipRect;
+ } else if (option == ClipRect) {
+ return clipRect;
} else if (option == Size) {
if (canRead() && !device()->isSequential()) {
qint64 pos = device()->pos();
@@ -1276,10 +1249,12 @@ void QJpegHandler::setOption(ImageOption option, const QVariant &value)
{
if (option == Quality)
quality = value.toInt();
-#ifndef QT_NO_IMAGE_SMOOTHSCALE
else if ( option == ScaledSize )
scaledSize = value.toSize();
-#endif
+ else if ( option == ScaledClipRect )
+ scaledClipRect = value.toRect();
+ else if ( option == ClipRect )
+ clipRect = value.toRect();
}
QByteArray QJpegHandler::name() const
diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.h b/src/plugins/imageformats/jpeg/qjpeghandler.h
index 654c078f7d..6870cd600e 100644
--- a/src/plugins/imageformats/jpeg/qjpeghandler.h
+++ b/src/plugins/imageformats/jpeg/qjpeghandler.h
@@ -44,6 +44,7 @@
#include <QtGui/qimageiohandler.h>
#include <QtCore/QSize>
+#include <QtCore/QRect>
QT_BEGIN_NAMESPACE
@@ -66,8 +67,9 @@ public:
private:
int quality;
- QByteArray parameters;
QSize scaledSize;
+ QRect scaledClipRect;
+ QRect clipRect;
};
QT_END_NAMESPACE
diff --git a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro
index 9687908ab9..691cce1327 100644
--- a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro
+++ b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro
@@ -3,7 +3,7 @@ TEMPLATE = subdirs
# We just want to export the sqlite3 binaries for Symbian for platforms that do not have them.
symbian {
- !exists($${EPOCROOT}epoc32/release/armv5/lib/sqlite3.dso) {
+ !symbian_no_export_sqlite:!exists($${EPOCROOT}epoc32/release/armv5/lib/sqlite3.dso) {
BLD_INF_RULES.prj_exports += ":zip SQLite3_v9.2.zip"
}
}
diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def
index d50e85f621..7a629d72c3 100644
--- a/src/s60installs/bwins/QtGuiu.def
+++ b/src/s60installs/bwins/QtGuiu.def
@@ -2503,7 +2503,7 @@ EXPORTS
?cacheMode@QMovie@@QAE?AW4CacheMode@1@XZ @ 2502 NONAME ; enum QMovie::CacheMode QMovie::cacheMode(void)
?cacheMode@QMovie@@QBE?AW4CacheMode@1@XZ @ 2503 NONAME ; enum QMovie::CacheMode QMovie::cacheMode(void) const
?cacheStatistics@QFont@@SAXXZ @ 2504 NONAME ; void QFont::cacheStatistics(void)
- ?cacheType@QTextureGlyphCache@@QBE?AW4Type@QFontEngineGlyphCache@@XZ @ 2505 NONAME ; enum QFontEngineGlyphCache::Type QTextureGlyphCache::cacheType(void) const
+ ?cacheType@QTextureGlyphCache@@QBE?AW4Type@QFontEngineGlyphCache@@XZ @ 2505 NONAME ABSENT ; enum QFontEngineGlyphCache::Type QTextureGlyphCache::cacheType(void) const
?calcEffectiveOpacity@QGraphicsItemPrivate@@QBEMXZ @ 2506 NONAME ; float QGraphicsItemPrivate::calcEffectiveOpacity(void) const
?calculateTabWidth@QTextEngine@@QBE?AUQFixed@@HU2@@Z @ 2507 NONAME ; struct QFixed QTextEngine::calculateTabWidth(int, struct QFixed) const
?calendarPopup@QDateTimeEdit@@QBE_NXZ @ 2508 NONAME ; bool QDateTimeEdit::calendarPopup(void) const
@@ -4299,7 +4299,7 @@ EXPORTS
?expandingDirections@QSpacerItem@@UBE?AV?$QFlags@W4Orientation@Qt@@@@XZ @ 4298 NONAME ; class QFlags<enum Qt::Orientation> QSpacerItem::expandingDirections(void) const
?expandingDirections@QWidgetItem@@UBE?AV?$QFlags@W4Orientation@Qt@@@@XZ @ 4299 NONAME ; class QFlags<enum Qt::Orientation> QWidgetItem::expandingDirections(void) const
?expandsOnDoubleClick@QTreeView@@QBE_NXZ @ 4300 NONAME ; bool QTreeView::expandsOnDoubleClick(void) const
- ?expireGlyphCache@QFontEngine@@AAEXXZ @ 4301 NONAME ; void QFontEngine::expireGlyphCache(void)
+ ?expireGlyphCache@QFontEngine@@AAEXXZ @ 4301 NONAME ABSENT ; void QFontEngine::expireGlyphCache(void)
?extension@QDialog@@QBEPAVQWidget@@XZ @ 4302 NONAME ; class QWidget * QDialog::extension(void) const
?extension@QGraphicsEllipseItem@@MBE?AVQVariant@@ABV2@@Z @ 4303 NONAME ; class QVariant QGraphicsEllipseItem::extension(class QVariant const &) const
?extension@QGraphicsItem@@MBE?AVQVariant@@ABV2@@Z @ 4304 NONAME ; class QVariant QGraphicsItem::extension(class QVariant const &) const
@@ -4933,8 +4933,8 @@ EXPORTS
?globalY@QMouseEvent@@QBEHXZ @ 4932 NONAME ; int QMouseEvent::globalY(void) const
?globalY@QTabletEvent@@QBEHXZ @ 4933 NONAME ; int QTabletEvent::globalY(void) const
?globalY@QWheelEvent@@QBEHXZ @ 4934 NONAME ; int QWheelEvent::globalY(void) const
- ?glyphCache@QFontEngine@@QBEPAVQFontEngineGlyphCache@@PAXABVQTransform@@@Z @ 4935 NONAME ; class QFontEngineGlyphCache * QFontEngine::glyphCache(void *, class QTransform const &) const
- ?glyphCache@QFontEngine@@QBEPAVQFontEngineGlyphCache@@W4Type@2@ABVQTransform@@@Z @ 4936 NONAME ; class QFontEngineGlyphCache * QFontEngine::glyphCache(enum QFontEngineGlyphCache::Type, class QTransform const &) const
+ ?glyphCache@QFontEngine@@QBEPAVQFontEngineGlyphCache@@PAXABVQTransform@@@Z @ 4935 NONAME ABSENT ; class QFontEngineGlyphCache * QFontEngine::glyphCache(void *, class QTransform const &) const
+ ?glyphCache@QFontEngine@@QBEPAVQFontEngineGlyphCache@@W4Type@2@ABVQTransform@@@Z @ 4936 NONAME ABSENT ; class QFontEngineGlyphCache * QFontEngine::glyphCache(enum QFontEngineGlyphCache::Type, class QTransform const &) const
?glyphCount@QFontEngine@@UBEHXZ @ 4937 NONAME ; int QFontEngine::glyphCount(void) const
?glyphMargin@QTextureGlyphCache@@UBEHXZ @ 4938 NONAME ; int QTextureGlyphCache::glyphMargin(void) const
?gotFocus@QFocusEvent@@QBE_NXZ @ 4939 NONAME ; bool QFocusEvent::gotFocus(void) const
@@ -9103,7 +9103,7 @@ EXPORTS
?setGestureCancelPolicy@QGesture@@QAEXW4GestureCancelPolicy@1@@Z @ 9102 NONAME ; void QGesture::setGestureCancelPolicy(enum QGesture::GestureCancelPolicy)
?setGlobalStrut@QApplication@@SAXABVQSize@@@Z @ 9103 NONAME ; void QApplication::setGlobalStrut(class QSize const &)
?setGlyphCache@QFontEngine@@QAEXPAXPAVQFontEngineGlyphCache@@@Z @ 9104 NONAME ; void QFontEngine::setGlyphCache(void *, class QFontEngineGlyphCache *)
- ?setGlyphCache@QFontEngine@@QAEXW4Type@QFontEngineGlyphCache@@PAV3@@Z @ 9105 NONAME ; void QFontEngine::setGlyphCache(enum QFontEngineGlyphCache::Type, class QFontEngineGlyphCache *)
+ ?setGlyphCache@QFontEngine@@QAEXW4Type@QFontEngineGlyphCache@@PAV3@@Z @ 9105 NONAME ABSENT ; void QFontEngine::setGlyphCache(enum QFontEngineGlyphCache::Type, class QFontEngineGlyphCache *)
?setGraphicsEffect@QGraphicsItem@@QAEXPAVQGraphicsEffect@@@Z @ 9106 NONAME ; void QGraphicsItem::setGraphicsEffect(class QGraphicsEffect *)
?setGraphicsEffect@QWidget@@QAEXPAVQGraphicsEffect@@@Z @ 9107 NONAME ; void QWidget::setGraphicsEffect(class QGraphicsEffect *)
?setGraphicsEffectSource@QGraphicsEffectPrivate@@QAEXPAVQGraphicsEffectSource@@@Z @ 9108 NONAME ; void QGraphicsEffectPrivate::setGraphicsEffectSource(class QGraphicsEffectSource *)
@@ -12522,4 +12522,7 @@ EXPORTS
?addCacheData@QVectorPath@@QBEPAUCacheEntry@1@PAVQPaintEngineEx@@PAXP6AX01@Z@Z @ 12521 NONAME ; struct QVectorPath::CacheEntry * QVectorPath::addCacheData(class QPaintEngineEx *, void *, void (*)(class QPaintEngineEx *, void *)) const
?discardUpdateRequest@QGraphicsItemPrivate@@QBE_N_N00@Z @ 12522 NONAME ; bool QGraphicsItemPrivate::discardUpdateRequest(bool, bool, bool) const
?makeCacheable@QVectorPath@@QBEXXZ @ 12523 NONAME ; void QVectorPath::makeCacheable(void) const
+ ??0Tab@QTextOption@@QAE@ABU01@@Z @ 12524 NONAME ; QTextOption::Tab::Tab(struct QTextOption::Tab const &)
+ ?effectiveBoundingRect@QGraphicsItemPrivate@@QBE?AVQRectF@@ABV2@@Z @ 12525 NONAME ; class QRectF QGraphicsItemPrivate::effectiveBoundingRect(class QRectF const &) const
+ ?glyphCache@QFontEngine@@QBEPAVQFontEngineGlyphCache@@PAXW4Type@2@ABVQTransform@@@Z @ 12526 NONAME ; class QFontEngineGlyphCache * QFontEngine::glyphCache(void *, enum QFontEngineGlyphCache::Type, class QTransform const &) const
diff --git a/src/s60installs/qt.iby b/src/s60installs/qt.iby
index 41eb5621ce..f24ac4b141 100644
--- a/src/s60installs/qt.iby
+++ b/src/s60installs/qt.iby
@@ -90,27 +90,27 @@ file=ABI_DIR\BUILD_DIR\qts60plugin_5_0.dll SHARED_LIB_DIR\qts60plugin_5_0.dll
S60_APP_RESOURCE(s60main)
// imageformats stubs
-data=\epoc32\winscw\c\resource\qt\plugins\imageformats\qgif.qtplugin resource\qt\plugins\imageformats\qgif.qtplugin
-data=\epoc32\winscw\c\resource\qt\plugins\imageformats\qico.qtplugin resource\qt\plugins\imageformats\qico.qtplugin
-data=\epoc32\winscw\c\resource\qt\plugins\imageformats\qjpeg.qtplugin resource\qt\plugins\imageformats\qjpeg.qtplugin
-data=\epoc32\winscw\c\resource\qt\plugins\imageformats\qmng.qtplugin resource\qt\plugins\imageformats\qmng.qtplugin
-data=\epoc32\winscw\c\resource\qt\plugins\imageformats\qsvg.qtplugin resource\qt\plugins\imageformats\qsvg.qtplugin
-data=\epoc32\winscw\c\resource\qt\plugins\imageformats\qtiff.qtplugin resource\qt\plugins\imageformats\qtiff.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\qgif.qtplugin resource\qt\plugins\imageformats\qgif.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\qico.qtplugin resource\qt\plugins\imageformats\qico.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\qjpeg.qtplugin resource\qt\plugins\imageformats\qjpeg.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\qmng.qtplugin resource\qt\plugins\imageformats\qmng.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\qsvg.qtplugin resource\qt\plugins\imageformats\qsvg.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\qtiff.qtplugin resource\qt\plugins\imageformats\qtiff.qtplugin
// codecs stubs
-data=\epoc32\winscw\c\resource\qt\plugins\codecs\qcncodecs.qtplugin resource\qt\plugins\codecs\qcncodecs.qtplugin
-data=\epoc32\winscw\c\resource\qt\plugins\codecs\qjpcodecs.qtplugin resource\qt\plugins\codecs\qjpcodecs.qtplugin
-data=\epoc32\winscw\c\resource\qt\plugins\codecs\qkrcodecs.qtplugin resource\qt\plugins\codecs\qkrcodecs.qtplugin
-data=\epoc32\winscw\c\resource\qt\plugins\codecs\qtwcodecs.qtplugin resource\qt\plugins\codecs\qtwcodecs.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\qcncodecs.qtplugin resource\qt\plugins\codecs\qcncodecs.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\qjpcodecs.qtplugin resource\qt\plugins\codecs\qjpcodecs.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\qkrcodecs.qtplugin resource\qt\plugins\codecs\qkrcodecs.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\qtwcodecs.qtplugin resource\qt\plugins\codecs\qtwcodecs.qtplugin
// iconengines stubs
-data=\epoc32\winscw\c\resource\qt\plugins\iconengines\qsvgicon.qtplugin resource\qt\plugins\iconengines\qsvgicon.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\qsvgicon.qtplugin resource\qt\plugins\iconengines\qsvgicon.qtplugin
// Phonon MMF backend
-data=\epoc32\winscw\c\resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\phonon_mmf.qtplugin resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin
// graphicssystems
-data=\epoc32\winscw\c\resource\qt\plugins\graphicssystems\qvggraphicssystem.qtplugin resource\qt\plugins\graphicssystems\qvggraphicssystem.qtplugin
+data=\epoc32\data\qt\qtlibspluginstubs\qvggraphicssystem.qtplugin resource\qt\plugins\graphicssystems\qvggraphicssystem.qtplugin
// Stub sis file
data=ZSYSTEM\install\qt.sis System\Install\qt.sis
diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro
index 37adfa9778..e024396bdc 100644
--- a/src/s60installs/s60installs.pro
+++ b/src/s60installs/s60installs.pro
@@ -105,10 +105,6 @@ symbian: {
qtlibraries.sources += QtDeclarative.dll
}
- contains(QT_CONFIG, webkit): {
- qtlibraries.sources += QtWebKit.dll
- }
-
graphicssystems_plugins.path = c:$$QT_PLUGINS_BASE_DIR/graphicssystems
contains(QT_CONFIG, openvg) {
qtlibraries.sources += QtOpenVG.dll
@@ -117,4 +113,9 @@ symbian: {
BLD_INF_RULES.prj_exports += "qt.iby $$CORE_MW_LAYER_IBY_EXPORT_PATH(qt.iby)"
BLD_INF_RULES.prj_exports += "qtdemoapps.iby $$CORE_APP_LAYER_IBY_EXPORT_PATH(qtdemoapps.iby)"
+ PLUGIN_STUBS = $$files(qmakepluginstubs/*)
+ for(STUB, PLUGIN_STUBS) {
+ STUB_FILENAME = $$basename(STUB)
+ BLD_INF_RULES.prj_exports += "qmakepluginstubs/$${STUB_FILENAME} /epoc32/data/qt/qtlibspluginstubs/$${STUB_FILENAME}"
+ }
}
diff --git a/src/s60main/qts60main.cpp b/src/s60main/qts60main.cpp
index 725b17c799..8923fb9ab2 100644
--- a/src/s60main/qts60main.cpp
+++ b/src/s60main/qts60main.cpp
@@ -6,35 +6,33 @@
**
** This file is part of the Symbian application wrapper of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
+** $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 Nokia Corporation 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$
**
****************************************************************************/
@@ -54,7 +52,7 @@ GLDEF_C TInt E32Main()
{
CTrapCleanup *cleanupStack = q_check_ptr(CTrapCleanup::New());
TInt err = 0;
- TRAP(err, QtMainWrapper());
+ TRAP(err, err = QtMainWrapper());
delete cleanupStack;
return err;
diff --git a/src/s60main/qts60main_mcrt0.cpp b/src/s60main/qts60main_mcrt0.cpp
index edc2fb88de..b9a720b571 100644
--- a/src/s60main/qts60main_mcrt0.cpp
+++ b/src/s60main/qts60main_mcrt0.cpp
@@ -6,35 +6,33 @@
**
** This file is part of the Symbian application wrapper of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
+** $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 Nokia Corporation 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$
**
****************************************************************************/
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index ac220bd3b3..21c947b5be 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -2864,14 +2864,8 @@ static QSvgNode *createPolygonNode(QSvgNode *parent,
const QChar *s = pointsStr.constData();
QVector<qreal> points = parseNumbersList(s);
QPolygonF poly(points.count()/2);
- int i = 0;
- QVector<qreal>::const_iterator itr = points.constBegin();
- while (itr != points.constEnd()) {
- qreal one = *itr; ++itr;
- qreal two = *itr; ++itr;
- poly[i] = QPointF(one, two);
- ++i;
- }
+ for (int i = 0; i < poly.size(); ++i)
+ poly[i] = QPointF(points.at(2 * i), points.at(2 * i + 1));
QSvgNode *polygon = new QSvgPolygon(parent, poly);
return polygon;
}
@@ -2886,14 +2880,8 @@ static QSvgNode *createPolylineNode(QSvgNode *parent,
const QChar *s = pointsStr.constData();
QVector<qreal> points = parseNumbersList(s);
QPolygonF poly(points.count()/2);
- int i = 0;
- QVector<qreal>::const_iterator itr = points.constBegin();
- while (itr != points.constEnd()) {
- qreal one = *itr; ++itr;
- qreal two = *itr; ++itr;
- poly[i] = QPointF(one, two);
- ++i;
- }
+ for (int i = 0; i < poly.size(); ++i)
+ poly[i] = QPointF(points.at(2 * i), points.at(2 * i + 1));
QSvgNode *line = new QSvgPolyline(parent, poly);
return line;
diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp
index 0a874128b0..27ec3bdf40 100644
--- a/src/xml/sax/qxml.cpp
+++ b/src/xml/sax/qxml.cpp
@@ -3063,11 +3063,11 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing()
Aspects of the parsing behavior can be adapted using setFeature()
and setProperty().
+ \snippet doc/src/snippets/code/src_xml_sax_qxml.cpp 0
+
QXmlSimpleReader is not reentrant. If you want to use the class
in threaded code, lock the code using QXmlSimpleReader with a
locking mechanism, such as a QMutex.
-
- \snippet doc/src/snippets/code/src_xml_sax_qxml.cpp 0
*/
static inline bool is_S(QChar ch)
diff --git a/src/xmlpatterns/api/api.pri b/src/xmlpatterns/api/api.pri
index 9fcc2f53e6..a0adf75e51 100644
--- a/src/xmlpatterns/api/api.pri
+++ b/src/xmlpatterns/api/api.pri
@@ -1,59 +1,57 @@
-HEADERS += $$PWD/qabstractxmlforwarditerator_p.h \
- $$PWD/qabstractmessagehandler.h \
- $$PWD/qabstracturiresolver.h \
- $$PWD/qabstractxmlnodemodel.h \
- $$PWD/qabstractxmlnodemodel_p.h \
- $$PWD/qabstractxmlpullprovider_p.h \
- $$PWD/qabstractxmlreceiver.h \
- $$PWD/qabstractxmlreceiver_p.h \
- $$PWD/qdeviceresourceloader_p.h \
- $$PWD/qiodevicedelegate_p.h \
- $$PWD/qnetworkaccessdelegator_p.h \
- $$PWD/qpullbridge_p.h \
- $$PWD/qresourcedelegator_p.h \
- $$PWD/qsimplexmlnodemodel.h \
- $$PWD/qsourcelocation.h \
- $$PWD/quriloader_p.h \
- $$PWD/qvariableloader_p.h \
- $$PWD/qxmlformatter.h \
- $$PWD/qxmlname.h \
- $$PWD/qxmlnamepool.h \
- $$PWD/qxmlquery.h \
- $$PWD/qxmlquery_p.h \
- $$PWD/qxmlresultitems.h \
- $$PWD/qxmlresultitems_p.h \
- $$PWD/qxmlschema.h \
- $$PWD/qxmlschema_p.h \
- $$PWD/qxmlschemavalidator.h \
- $$PWD/qxmlschemavalidator_p.h \
- $$PWD/qxmlserializer.h \
- $$PWD/qxmlserializer_p.h \
- $$PWD/../../../tools/xmlpatterns/qcoloringmessagehandler_p.h \
- $$PWD/../../../tools/xmlpatterns/qcoloroutput_p.h
-
-SOURCES += $$PWD/qvariableloader.cpp \
- $$PWD/qabstractmessagehandler.cpp \
- $$PWD/qabstracturiresolver.cpp \
- $$PWD/qabstractxmlnodemodel.cpp \
- $$PWD/qabstractxmlpullprovider.cpp \
- $$PWD/qabstractxmlreceiver.cpp \
- $$PWD/qiodevicedelegate.cpp \
- $$PWD/qnetworkaccessdelegator.cpp \
- $$PWD/qpullbridge.cpp \
- $$PWD/qresourcedelegator.cpp \
- $$PWD/qsimplexmlnodemodel.cpp \
- $$PWD/qsourcelocation.cpp \
- $$PWD/quriloader.cpp \
- $$PWD/qxmlformatter.cpp \
- $$PWD/qxmlname.cpp \
- $$PWD/qxmlnamepool.cpp \
- $$PWD/qxmlquery.cpp \
- $$PWD/qxmlresultitems.cpp \
- $$PWD/qxmlschema.cpp \
- $$PWD/qxmlschema_p.cpp \
- $$PWD/qxmlschemavalidator.cpp \
- $$PWD/qxmlserializer.cpp \
- $$PWD/../../../tools/xmlpatterns/qcoloringmessagehandler.cpp \
- $$PWD/../../../tools/xmlpatterns/qcoloroutput.cpp
-
-INCLUDEPATH += $$PWD/../../../tools/xmlpatterns/
+HEADERS += $$PWD/qabstractxmlforwarditerator_p.h \
+ $$PWD/qabstractmessagehandler.h \
+ $$PWD/qabstracturiresolver.h \
+ $$PWD/qabstractxmlnodemodel.h \
+ $$PWD/qabstractxmlnodemodel_p.h \
+ $$PWD/qabstractxmlpullprovider_p.h \
+ $$PWD/qabstractxmlreceiver.h \
+ $$PWD/qabstractxmlreceiver_p.h \
+ $$PWD/qdeviceresourceloader_p.h \
+ $$PWD/qiodevicedelegate_p.h \
+ $$PWD/qnetworkaccessdelegator_p.h \
+ $$PWD/qpullbridge_p.h \
+ $$PWD/qresourcedelegator_p.h \
+ $$PWD/qsimplexmlnodemodel.h \
+ $$PWD/qsourcelocation.h \
+ $$PWD/quriloader_p.h \
+ $$PWD/qvariableloader_p.h \
+ $$PWD/qxmlformatter.h \
+ $$PWD/qxmlname.h \
+ $$PWD/qxmlnamepool.h \
+ $$PWD/qxmlquery.h \
+ $$PWD/qxmlquery_p.h \
+ $$PWD/qxmlresultitems.h \
+ $$PWD/qxmlresultitems_p.h \
+ $$PWD/qxmlschema.h \
+ $$PWD/qxmlschema_p.h \
+ $$PWD/qxmlschemavalidator.h \
+ $$PWD/qxmlschemavalidator_p.h \
+ $$PWD/qxmlserializer.h \
+ $$PWD/qxmlserializer_p.h \
+ $$PWD/qcoloringmessagehandler_p.h \
+ $$PWD/qcoloroutput_p.h \
+ $$PWD/qxmlpatternistcli_p.h
+SOURCES += $$PWD/qvariableloader.cpp \
+ $$PWD/qabstractmessagehandler.cpp \
+ $$PWD/qabstracturiresolver.cpp \
+ $$PWD/qabstractxmlnodemodel.cpp \
+ $$PWD/qabstractxmlpullprovider.cpp \
+ $$PWD/qabstractxmlreceiver.cpp \
+ $$PWD/qiodevicedelegate.cpp \
+ $$PWD/qnetworkaccessdelegator.cpp \
+ $$PWD/qpullbridge.cpp \
+ $$PWD/qresourcedelegator.cpp \
+ $$PWD/qsimplexmlnodemodel.cpp \
+ $$PWD/qsourcelocation.cpp \
+ $$PWD/quriloader.cpp \
+ $$PWD/qxmlformatter.cpp \
+ $$PWD/qxmlname.cpp \
+ $$PWD/qxmlnamepool.cpp \
+ $$PWD/qxmlquery.cpp \
+ $$PWD/qxmlresultitems.cpp \
+ $$PWD/qxmlschema.cpp \
+ $$PWD/qxmlschema_p.cpp \
+ $$PWD/qxmlschemavalidator.cpp \
+ $$PWD/qxmlserializer.cpp \
+ $$PWD/qcoloringmessagehandler.cpp \
+ $$PWD/qcoloroutput.cpp
diff --git a/tools/xmlpatterns/qcoloringmessagehandler.cpp b/src/xmlpatterns/api/qcoloringmessagehandler.cpp
index a639ddd836..7d3eb6fff1 100644
--- a/tools/xmlpatterns/qcoloringmessagehandler.cpp
+++ b/src/xmlpatterns/api/qcoloringmessagehandler.cpp
@@ -41,9 +41,8 @@
#include <QXmlStreamReader>
-#include "main.h"
-
#include "qcoloringmessagehandler_p.h"
+#include "qxmlpatternistcli_p.h"
QT_BEGIN_NAMESPACE
diff --git a/tools/xmlpatterns/qcoloringmessagehandler_p.h b/src/xmlpatterns/api/qcoloringmessagehandler_p.h
index 3e8d18bafc..3e8d18bafc 100644
--- a/tools/xmlpatterns/qcoloringmessagehandler_p.h
+++ b/src/xmlpatterns/api/qcoloringmessagehandler_p.h
diff --git a/tools/xmlpatterns/qcoloroutput.cpp b/src/xmlpatterns/api/qcoloroutput.cpp
index 4f27fd5fee..4f27fd5fee 100644
--- a/tools/xmlpatterns/qcoloroutput.cpp
+++ b/src/xmlpatterns/api/qcoloroutput.cpp
diff --git a/tools/xmlpatterns/qcoloroutput_p.h b/src/xmlpatterns/api/qcoloroutput_p.h
index 1917ec7efc..1917ec7efc 100644
--- a/tools/xmlpatterns/qcoloroutput_p.h
+++ b/src/xmlpatterns/api/qcoloroutput_p.h
diff --git a/src/xmlpatterns/api/qxmlpatternistcli_p.h b/src/xmlpatterns/api/qxmlpatternistcli_p.h
new file mode 100644
index 0000000000..072e4aa2d1
--- /dev/null
+++ b/src/xmlpatterns/api/qxmlpatternistcli_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the XMLPatterns module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+
+#ifndef Patternist_Cli_h
+#define Patternist_Cli_h
+
+#include <QCoreApplication>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QXmlPatternistCLI
+{
+public:
+ Q_DECLARE_TR_FUNCTIONS(QXmlPatternistCLI)
+private:
+ inline QXmlPatternistCLI();
+ Q_DISABLE_COPY(QXmlPatternistCLI)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/xmlpatterns/xmlpatterns.pro b/src/xmlpatterns/xmlpatterns.pro
index 1df497d3bb..a2247625ab 100644
--- a/src/xmlpatterns/xmlpatterns.pro
+++ b/src/xmlpatterns/xmlpatterns.pro
@@ -1,15 +1,14 @@
-TARGET = QtXmlPatterns
-QPRO_PWD = $$PWD
-QT = core network
-DEFINES += QT_BUILD_XMLPATTERNS_LIB QT_NO_USING_NAMESPACE
+TARGET = QtXmlPatterns
+QPRO_PWD = $$PWD
+QT = core \
+ network
+DEFINES += QT_BUILD_XMLPATTERNS_LIB \
+ QT_NO_USING_NAMESPACE
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x61000000
-
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtNetwork
-
+unix:QMAKE_PKGCONFIG_REQUIRES = QtCore \
+ QtNetwork
include(../qbase.pri)
-
PRECOMPILED_HEADER = ../corelib/global/qt_pch.h
-
include($$PWD/common.pri)
include($$PWD/acceltree/acceltree.pri)
include($$PWD/api/api.pri)
@@ -25,14 +24,13 @@ include($$PWD/schema/schema.pri)
include($$PWD/type/type.pri)
include($$PWD/utils/utils.pri)
include($$PWD/qobjectmodel/qobjectmodel.pri, "", true)
+wince*:# The Microsoft MIPS compiler crashes if /Og is specified
+:
-wince*: {
- # The Microsoft MIPS compiler crashes if /Og is specified
- # -O2/1 expands to /Og plus additional arguments.
- contains(DEFINES, MIPS): {
- QMAKE_CXXFLAGS_RELEASE ~= s/-O2/-Oi -Ot -Oy -Ob2/
- QMAKE_CXXFLAGS_RELEASE ~= s/-O1/-Os -Oy -Ob2/
- }
+# -O2/1 expands to /Og plus additional arguments.
+contains(DEFINES, MIPS): {
+ QMAKE_CXXFLAGS_RELEASE ~= s/-O2/-Oi -Ot -Oy -Ob2/
+ QMAKE_CXXFLAGS_RELEASE ~= s/-O1/-Os -Oy -Ob2/
}
-
-symbian:TARGET.UID3=0x2001E62B
+symbian:TARGET.UID3 = 0x2001E62B
+HEADERS +=
diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp
index 36d25fe054..329143d5bb 100644
--- a/tests/auto/headers/tst_headers.cpp
+++ b/tests/auto/headers/tst_headers.cpp
@@ -217,8 +217,8 @@ void tst_Headers::licenseCheck()
QCOMPARE(content.at(i++), QString("/****************************************************************************"));
if (licenseType != "3RDPARTY") {
QCOMPARE(content.at(i++), QString("**"));
- if (sourceFile.endsWith("/tests/auto/qabstractitemmodel/dynamictreemodel.cpp")
- || sourceFile.endsWith("/tests/auto/qabstractitemmodel/dynamictreemodel.h")
+ if (sourceFile.endsWith("/tests/auto/modeltest/dynamictreemodel.cpp")
+ || sourceFile.endsWith("/tests/auto/modeltest/dynamictreemodel.h")
|| sourceFile.endsWith("/src/network/kernel/qnetworkproxy_p.h"))
{
// These files are not copyrighted by Nokia.
diff --git a/tests/auto/qabstractitemmodel/dynamictreemodel.cpp b/tests/auto/modeltest/dynamictreemodel.cpp
index 24d3ab3ce6..24d3ab3ce6 100644
--- a/tests/auto/qabstractitemmodel/dynamictreemodel.cpp
+++ b/tests/auto/modeltest/dynamictreemodel.cpp
diff --git a/tests/auto/qabstractitemmodel/dynamictreemodel.h b/tests/auto/modeltest/dynamictreemodel.h
index 3f0d90d4ea..3f0d90d4ea 100644
--- a/tests/auto/qabstractitemmodel/dynamictreemodel.h
+++ b/tests/auto/modeltest/dynamictreemodel.h
diff --git a/tests/auto/modeltest/modeltest.cpp b/tests/auto/modeltest/modeltest.cpp
index 39d00f632c..0ca9e141ee 100644
--- a/tests/auto/modeltest/modeltest.cpp
+++ b/tests/auto/modeltest/modeltest.cpp
@@ -475,8 +475,8 @@ void ModelTest::data()
void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, int end )
{
// Q_UNUSED(end);
- qDebug() << "rowsAboutToBeInserted" << "start=" << start << "end=" << end << "parent=" << model->data ( parent ).toString()
- << "current count of parent=" << model->rowCount ( parent ); // << "display of last=" << model->data( model->index(start-1, 0, parent) );
+// qDebug() << "rowsAboutToBeInserted" << "start=" << start << "end=" << end << "parent=" << model->data ( parent ).toString()
+// << "current count of parent=" << model->rowCount ( parent ); // << "display of last=" << model->data( model->index(start-1, 0, parent) );
// qDebug() << model->index(start-1, 0, parent) << model->data( model->index(start-1, 0, parent) );
Changing c;
c.parent = parent;
@@ -495,14 +495,14 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end )
{
Changing c = insert.pop();
Q_ASSERT ( c.parent == parent );
- qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize
- << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent );
-
- for (int ii=start; ii <= end; ii++)
- {
- qDebug() << "itemWasInserted:" << ii << model->data ( model->index ( ii, 0, parent ));
- }
- qDebug();
+// qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize
+// << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent );
+
+// for (int ii=start; ii <= end; ii++)
+// {
+// qDebug() << "itemWasInserted:" << ii << model->data ( model->index ( ii, 0, parent ));
+// }
+// qDebug();
Q_ASSERT ( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) );
Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
diff --git a/tests/auto/modeltest/modeltest.pro b/tests/auto/modeltest/modeltest.pro
index 6655d85dc2..f157da0cee 100644
--- a/tests/auto/modeltest/modeltest.pro
+++ b/tests/auto/modeltest/modeltest.pro
@@ -1,6 +1,6 @@
load(qttest_p4)
-SOURCES += tst_modeltest.cpp modeltest.cpp
-HEADERS += modeltest.h
+SOURCES += tst_modeltest.cpp modeltest.cpp dynamictreemodel.cpp
+HEADERS += modeltest.h dynamictreemodel.h
diff --git a/tests/auto/modeltest/tst_modeltest.cpp b/tests/auto/modeltest/tst_modeltest.cpp
index a719168880..262b966ddd 100644
--- a/tests/auto/modeltest/tst_modeltest.cpp
+++ b/tests/auto/modeltest/tst_modeltest.cpp
@@ -44,6 +44,7 @@
#include <QtGui/QtGui>
#include "modeltest.h"
+#include "dynamictreemodel.h"
class tst_ModelTest : public QObject
@@ -64,6 +65,8 @@ private slots:
void stringListModel();
void treeWidgetModel();
void standardItemModel();
+ void testInsertThroughProxy();
+ void moveSourceItems();
};
@@ -92,15 +95,15 @@ void tst_ModelTest::stringListModel()
{
QStringListModel model;
QSortFilterProxyModel proxy;
-
+
ModelTest t1(&model);
ModelTest t2(&proxy);
-
+
proxy.setSourceModel(&model);
-
+
model.setStringList(QStringList() << "2" << "3" << "1");
model.setStringList(QStringList() << "a" << "e" << "plop" << "b" << "c" );
-
+
proxy.setDynamicSortFilter(true);
proxy.setFilterRegExp(QRegExp("[^b]"));
}
@@ -110,7 +113,7 @@ void tst_ModelTest::treeWidgetModel()
QTreeWidget widget;
ModelTest t1(widget.model());
-
+
QTreeWidgetItem *root = new QTreeWidgetItem(&widget, QStringList("root"));
for (int i = 0; i < 20; ++i) {
new QTreeWidgetItem(root, QStringList(QString::number(i)));
@@ -120,7 +123,7 @@ void tst_ModelTest::treeWidgetModel()
QTreeWidgetItem *parent = new QTreeWidgetItem(&widget, QStringList("parent"));
new QTreeWidgetItem(parent, QStringList("child"));
widget.setItemHidden(parent, true);
-
+
widget.sortByColumn(0);
}
@@ -128,23 +131,153 @@ void tst_ModelTest::standardItemModel()
{
QStandardItemModel model(10,10);
QSortFilterProxyModel proxy;
-
-
+
+
ModelTest t1(&model);
ModelTest t2(&proxy);
-
+
proxy.setSourceModel(&model);
-
+
model.insertRows(2, 5);
model.removeRows(4, 5);
model.insertColumns(2, 5);
model.removeColumns(4, 5);
-
+
model.insertRows(0,5, model.index(1,1));
model.insertColumns(0,5, model.index(1,3));
-
}
+void tst_ModelTest::testInsertThroughProxy()
+{
+ DynamicTreeModel *model = new DynamicTreeModel(this);
+
+ QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
+ proxy->setSourceModel(model);
+
+ new ModelTest(proxy, this);
+
+ ModelInsertCommand *insertCommand = new ModelInsertCommand(model, this);
+ insertCommand->setNumCols(4);
+ insertCommand->setStartRow(0);
+ insertCommand->setEndRow(9);
+ // Parent is QModelIndex()
+ insertCommand->doCommand();
+
+ insertCommand = new ModelInsertCommand(model, this);
+ insertCommand->setNumCols(4);
+ insertCommand->setAncestorRowNumbers(QList<int>() << 5);
+ insertCommand->setStartRow(0);
+ insertCommand->setEndRow(9);
+ insertCommand->doCommand();
+
+ ModelMoveCommand *moveCommand = new ModelMoveCommand(model, this);
+ moveCommand->setNumCols(4);
+ moveCommand->setStartRow(0);
+ moveCommand->setEndRow(0);
+ moveCommand->setDestRow(9);
+ moveCommand->setDestAncestors(QList<int>() << 5);
+ moveCommand->doCommand();
+}
+
+/**
+ Makes the persistent index list publicly accessible
+*/
+class AccessibleProxyModel : public QSortFilterProxyModel
+{
+ Q_OBJECT
+public:
+ AccessibleProxyModel(QObject *parent = 0) : QSortFilterProxyModel(parent) {}
+
+ QModelIndexList persistent()
+ {
+ return persistentIndexList();
+ }
+};
+
+class ObservingObject : public QObject
+{
+ Q_OBJECT
+public:
+ ObservingObject(AccessibleProxyModel *proxy, QObject *parent = 0)
+ : QObject(parent),
+ m_proxy(proxy)
+ {
+ connect(m_proxy, SIGNAL(layoutAboutToBeChanged()), SLOT(storePersistent()));
+ connect(m_proxy, SIGNAL(layoutChanged()), SLOT(checkPersistent()));
+ }
+
+public slots:
+
+ void storePersistent(const QModelIndex &parent)
+ {
+ for (int row = 0; row < m_proxy->rowCount(parent); ++row) {
+ QModelIndex proxyIndex = m_proxy->index(row, 0, parent);
+ QModelIndex sourceIndex = m_proxy->mapToSource(proxyIndex);
+ Q_ASSERT(proxyIndex.isValid());
+ Q_ASSERT(sourceIndex.isValid());
+ m_persistentSourceIndexes.append(sourceIndex);
+ m_persistentProxyIndexes.append(proxyIndex);
+ if (m_proxy->hasChildren(proxyIndex))
+ storePersistent(proxyIndex);
+ }
+ }
+
+ void storePersistent()
+ {
+ m_persistentSourceIndexes.clear();
+ m_persistentProxyIndexes.clear();
+ Q_ASSERT(m_proxy->persistent().isEmpty());
+ storePersistent(QModelIndex());
+ Q_ASSERT(!m_proxy->persistent().isEmpty());
+ }
+
+ void checkPersistent()
+ {
+ for (int row = 0; row < m_persistentProxyIndexes.size(); ++row) {
+ QModelIndex updatedProxy = m_persistentProxyIndexes.at(row);
+ QModelIndex updatedSource = m_persistentSourceIndexes.at(row);
+ }
+ for (int row = 0; row < m_persistentProxyIndexes.size(); ++row) {
+ QModelIndex updatedProxy = m_persistentProxyIndexes.at(row);
+ QModelIndex updatedSource = m_persistentSourceIndexes.at(row);
+ QCOMPARE(m_proxy->mapToSource(updatedProxy), updatedSource);
+ }
+ }
+
+private:
+ AccessibleProxyModel *m_proxy;
+ QList<QPersistentModelIndex> m_persistentSourceIndexes;
+ QList<QPersistentModelIndex> m_persistentProxyIndexes;
+};
+
+void tst_ModelTest::moveSourceItems()
+{
+ DynamicTreeModel *model = new DynamicTreeModel(this);
+ AccessibleProxyModel *proxy = new AccessibleProxyModel(this);
+ proxy->setSourceModel(model);
+
+ ModelInsertCommand *insertCommand = new ModelInsertCommand(model, this);
+ insertCommand->setStartRow(0);
+ insertCommand->setEndRow(2);
+ insertCommand->doCommand();
+
+ insertCommand = new ModelInsertCommand(model, this);
+ insertCommand->setAncestorRowNumbers(QList<int>() << 1);
+ insertCommand->setStartRow(0);
+ insertCommand->setEndRow(2);
+ insertCommand->doCommand();
+
+ ObservingObject observer(proxy);
+
+ ModelMoveCommand *moveCommand = new ModelMoveCommand(model, this);
+ moveCommand->setStartRow(0);
+ moveCommand->setEndRow(0);
+ moveCommand->setDestAncestors(QList<int>() << 1);
+ moveCommand->setDestRow(0);
+ moveCommand->doCommand();
+}
+
+
QTEST_MAIN(tst_ModelTest)
#include "tst_modeltest.moc"
diff --git a/tests/auto/qabstractitemmodel/qabstractitemmodel.pro b/tests/auto/qabstractitemmodel/qabstractitemmodel.pro
index a31868b48d..52c4e96f99 100644
--- a/tests/auto/qabstractitemmodel/qabstractitemmodel.pro
+++ b/tests/auto/qabstractitemmodel/qabstractitemmodel.pro
@@ -1,6 +1,9 @@
load(qttest_p4)
-SOURCES += tst_qabstractitemmodel.cpp dynamictreemodel.cpp
-HEADERS += dynamictreemodel.h
+
+INCLUDEPATH += $$PWD/../modeltest
+
+SOURCES += tst_qabstractitemmodel.cpp ../modeltest/dynamictreemodel.cpp ../modeltest/modeltest.cpp
+HEADERS += ../modeltest/dynamictreemodel.h ../modeltest/modeltest.h
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index 1445f5b4e3..5ea710005f 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -1074,8 +1074,8 @@ void tst_QFileInfo::isHidden_data()
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
QTest::newRow("C:/RECYCLER") << QString::fromLatin1("C:/RECYCLER") << true;
- QTest::newRow("C:/RECYCLER/.") << QString::fromLatin1("C:/RECYCLER/.") << false;
- QTest::newRow("C:/RECYCLER/..") << QString::fromLatin1("C:/RECYCLER/..") << false;
+ QTest::newRow("C:/RECYCLER/.") << QString::fromLatin1("C:/RECYCLER/.") << true;
+ QTest::newRow("C:/RECYCLER/..") << QString::fromLatin1("C:/RECYCLER/..") << true;
#endif
#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
@@ -1083,13 +1083,9 @@ void tst_QFileInfo::isHidden_data()
&& !QDir().mkdir("./.hidden-directory"))
qWarning("Unable to create directory './.hidden-directory'. Some tests will fail.");
- QTest::newRow("./.hidden-directory") << QString("./.hidden-directory") << true;
- QTest::newRow("./.hidden-directory/.") << QString("./.hidden-directory/.") << false;
- QTest::newRow("./.hidden-directory/..") << QString("./.hidden-directory/..") << false;
-
QTest::newRow("/path/to/.hidden-directory") << QDir::currentPath() + QString("/.hidden-directory") << true;
- QTest::newRow("/path/to/.hidden-directory/.") << QDir::currentPath() + QString("/.hidden-directory/.") << false;
- QTest::newRow("/path/to/.hidden-directory/..") << QDir::currentPath() + QString("/.hidden-directory/..") << false;
+ QTest::newRow("/path/to/.hidden-directory/.") << QDir::currentPath() + QString("/.hidden-directory/.") << true;
+ QTest::newRow("/path/to/.hidden-directory/..") << QDir::currentPath() + QString("/.hidden-directory/..") << true;
#endif
#if defined(Q_OS_MAC)
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 69df39b1f8..9e4321b9e6 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -211,6 +211,7 @@ private slots:
void centerOnDirtyItem();
void mouseTracking();
void mouseTracking2();
+ void mouseTracking3();
void render();
void exposeRegion();
void update_data();
@@ -3403,6 +3404,102 @@ void tst_QGraphicsView::mouseTracking2()
QCOMPARE(spy.count(), 1);
}
+void tst_QGraphicsView::mouseTracking3()
+{
+ // Mouse tracking should be automatically enabled if AnchorUnderMouse is used for
+ // view transform or resize. We never disable mouse tracking if it is already enabled.
+
+ { // Make sure we enable mouse tracking when using AnchorUnderMouse for view transformation.
+ QGraphicsScene scene(-10000, -10000, 20000, 20000);
+ QGraphicsView view(&scene);
+ QVERIFY(!view.viewport()->hasMouseTracking());
+
+ view.setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
+ QVERIFY(view.viewport()->hasMouseTracking());
+ }
+
+ { // Make sure we enable mouse tracking when using AnchorUnderMouse for view resizing.
+ QGraphicsScene scene(-10000, -10000, 20000, 20000);
+ QGraphicsView view(&scene);
+ QVERIFY(!view.viewport()->hasMouseTracking());
+
+ view.setResizeAnchor(QGraphicsView::AnchorUnderMouse);
+ QVERIFY(view.viewport()->hasMouseTracking());
+ }
+
+ { // Make sure we don't disable mouse tracking in setViewport/setScene (transformation anchor).
+ QGraphicsView view;
+ view.setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
+ QVERIFY(view.viewport()->hasMouseTracking());
+
+ QWidget *viewport = new QWidget;
+ view.setViewport(viewport);
+ QVERIFY(viewport->hasMouseTracking());
+
+ QGraphicsScene scene(-10000, -10000, 20000, 20000);
+ view.setScene(&scene);
+ QVERIFY(viewport->hasMouseTracking());
+ }
+
+ { // Make sure we don't disable mouse tracking in setViewport/setScene (resize anchor).
+ QGraphicsView view;
+ view.setResizeAnchor(QGraphicsView::AnchorUnderMouse);
+ QVERIFY(view.viewport()->hasMouseTracking());
+
+ QWidget *viewport = new QWidget;
+ view.setViewport(viewport);
+ QVERIFY(viewport->hasMouseTracking());
+
+ QGraphicsScene scene(-10000, -10000, 20000, 20000);
+ view.setScene(&scene);
+ QVERIFY(viewport->hasMouseTracking());
+ }
+
+ // Make sure we don't disable mouse tracking when adding an item (transformation anchor).
+ { // Adding an item to the scene before the scene is set on the view.
+ QGraphicsScene scene(-10000, -10000, 20000, 20000);
+ QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10);
+ scene.addItem(item);
+
+ QGraphicsView view;
+ view.setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
+ view.setScene(&scene);
+ QVERIFY(view.viewport()->hasMouseTracking());
+ }
+
+ { // Adding an item to the scene after the scene is set on the view.
+ QGraphicsScene scene(-10000, -10000, 20000, 20000);
+ QGraphicsView view(&scene);
+ view.setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
+
+ QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10);
+ scene.addItem(item);
+ QVERIFY(view.viewport()->hasMouseTracking());
+ }
+
+ // Make sure we don't disable mouse tracking when adding an item (resize anchor).
+ { // Adding an item to the scene before the scene is set on the view.
+ QGraphicsScene scene(-10000, -10000, 20000, 20000);
+ QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10);
+ scene.addItem(item);
+
+ QGraphicsView view;
+ view.setResizeAnchor(QGraphicsView::AnchorUnderMouse);
+ view.setScene(&scene);
+ QVERIFY(view.viewport()->hasMouseTracking());
+ }
+
+ { // Adding an item to the scene after the scene is set on the view.
+ QGraphicsScene scene(-10000, -10000, 20000, 20000);
+ QGraphicsView view(&scene);
+ view.setResizeAnchor(QGraphicsView::AnchorUnderMouse);
+
+ QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10);
+ scene.addItem(item);
+ QVERIFY(view.viewport()->hasMouseTracking());
+ }
+}
+
class RenderTester : public QGraphicsRectItem
{
public:
diff --git a/tests/auto/qimagereader/images/endless-anim.gif b/tests/auto/qimagereader/images/endless-anim.gif
new file mode 100644
index 0000000000..00df8da786
--- /dev/null
+++ b/tests/auto/qimagereader/images/endless-anim.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/four-frames.gif b/tests/auto/qimagereader/images/four-frames.gif
new file mode 100644
index 0000000000..6aff2e0af2
--- /dev/null
+++ b/tests/auto/qimagereader/images/four-frames.gif
Binary files differ
diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc
index 11b9406114..58f2f74c7f 100644
--- a/tests/auto/qimagereader/qimagereader.qrc
+++ b/tests/auto/qimagereader/qimagereader.qrc
@@ -57,5 +57,7 @@
<file>images/qt6.gif</file>
<file>images/qt7.gif</file>
<file>images/qt8.gif</file>
+ <file>images/endless-anim.gif</file>
+ <file>images/four-frames.gif</file>
</qresource>
</RCC>
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index 15b1c1c540..8cfaac51ae 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -141,6 +141,7 @@ private slots:
#if defined QTEST_HAVE_GIF
void gifHandlerBugs();
void animatedGif();
+ void gifImageCount();
#endif
void readCorruptImage_data();
@@ -322,7 +323,15 @@ void tst_QImageReader::setScaledSize_data()
QTest::newRow("PPM: test") << "test.ppm" << QSize(10, 10) << QByteArray("ppm");
QTest::newRow("XBM: gnus") << "gnus" << QSize(200, 200) << QByteArray("xbm");
#ifdef QTEST_HAVE_JPEG
- QTest::newRow("JPEG: beavis") << "beavis" << QSize(200, 200) << QByteArray("jpeg");
+ QTest::newRow("JPEG: beavis A") << "beavis" << QSize(200, 200) << QByteArray("jpeg");
+ QTest::newRow("JPEG: beavis B") << "beavis" << QSize(175, 175) << QByteArray("jpeg");
+ QTest::newRow("JPEG: beavis C") << "beavis" << QSize(100, 100) << QByteArray("jpeg");
+ QTest::newRow("JPEG: beavis D") << "beavis" << QSize(100, 200) << QByteArray("jpeg");
+ QTest::newRow("JPEG: beavis E") << "beavis" << QSize(200, 100) << QByteArray("jpeg");
+ QTest::newRow("JPEG: beavis F") << "beavis" << QSize(87, 87) << QByteArray("jpeg");
+ QTest::newRow("JPEG: beavis G") << "beavis" << QSize(50, 45) << QByteArray("jpeg");
+ QTest::newRow("JPEG: beavis H") << "beavis" << QSize(43, 43) << QByteArray("jpeg");
+ QTest::newRow("JPEG: beavis I") << "beavis" << QSize(25, 25) << QByteArray("jpeg");
#endif // QTEST_HAVE_JPEG
#ifdef QTEST_HAVE_GIF
QTest::newRow("GIF: earth") << "earth" << QSize(200, 200) << QByteArray("gif");
@@ -717,6 +726,13 @@ void tst_QImageReader::gifHandlerBugs()
QVERIFY(!im1.isNull()); QVERIFY(!im2.isNull());
QCOMPARE(im1.convertToFormat(QImage::Format_ARGB32), im2.convertToFormat(QImage::Format_ARGB32));
}
+
+ // Check the undocumented feature.
+ {
+ QImageReader io(prefix + "endless-anim.gif");
+ QVERIFY(io.canRead());
+ QCOMPARE(io.loopCount(), -1);
+ }
}
void tst_QImageReader::animatedGif()
@@ -731,6 +747,136 @@ void tst_QImageReader::animatedGif()
image = io.read();
}
}
+
+// http://bugreports.qt.nokia.com/browse/QTBUG-6696
+// Check the count of images in various call orders...
+void tst_QImageReader::gifImageCount()
+{
+ // just read every frame... and see how much we got..
+ {
+ QImageReader io(":images/four-frames.gif");
+
+ QVERIFY(io.canRead());
+ QImage blackFrame = io.read();
+
+ QVERIFY(io.canRead());
+ QImage whiteFrame = io.read();
+
+ QVERIFY(io.canRead());
+ QImage greenFrame = io.read();
+
+ QVERIFY(io.canRead());
+ QImage blueFrame = io.read();
+
+ QVERIFY(!io.canRead());
+ QImage emptyFrame = io.read();
+
+ QVERIFY(!io.canRead());
+ QCOMPARE(blackFrame.pixel(0,0), qRgb(0, 0, 0));
+ QCOMPARE(blackFrame.size(), QSize(64,64));
+
+ QCOMPARE(whiteFrame.pixel(0,0), qRgb(0xff, 0xff, 0xff));
+ QCOMPARE(whiteFrame.size(), QSize(64,64));
+
+ QCOMPARE(greenFrame.pixel(0,0), qRgb(0x0, 0xff, 0x0));
+ QCOMPARE(greenFrame.size(), QSize(64,64));
+
+ QCOMPARE(blueFrame.pixel(0,0), qRgb(0x0, 0x0, 0xff));
+ QCOMPARE(blueFrame.size(), QSize(64,64));
+ QVERIFY(emptyFrame.isNull());
+ }
+
+ // Read and get the size
+ {
+ QImageReader io(":images/four-frames.gif");
+
+ QVERIFY(io.canRead());
+ QCOMPARE(io.size(), QSize(64,64));
+
+ QVERIFY(io.canRead());
+ QCOMPARE(io.size(), QSize(64,64));
+ QCOMPARE(io.size(), QSize(64,64));
+ QVERIFY(io.canRead());
+ QImage blackFrame = io.read();
+
+ QVERIFY(io.canRead());
+ QCOMPARE(io.size(), QSize(64,64));
+ QCOMPARE(io.size(), QSize(64,64));
+ QVERIFY(io.canRead());
+ QImage whiteFrame = io.read();
+
+ QVERIFY(io.canRead());
+ QCOMPARE(io.size(), QSize(64,64));
+ QCOMPARE(io.size(), QSize(64,64));
+ QVERIFY(io.canRead());
+ QImage greenFrame = io.read();
+
+ QVERIFY(io.canRead());
+ QCOMPARE(io.size(), QSize(64,64));
+ QCOMPARE(io.size(), QSize(64,64));
+ QVERIFY(io.canRead());
+ QImage blueFrame = io.read();
+
+ QVERIFY(!io.canRead());
+ QCOMPARE(io.size(), QSize());
+ QCOMPARE(io.size(), QSize());
+ QVERIFY(!io.canRead());
+ QImage emptyFrame = io.read();
+
+ QVERIFY(!io.canRead());
+ QCOMPARE(blackFrame.pixel(0,0), qRgb(0, 0, 0));
+ QCOMPARE(blackFrame.size(), QSize(64,64));
+
+ QCOMPARE(whiteFrame.pixel(0,0), qRgb(0xff, 0xff, 0xff));
+ QCOMPARE(whiteFrame.size(), QSize(64,64));
+
+ QCOMPARE(greenFrame.pixel(0,0), qRgb(0x0, 0xff, 0x0));
+ QCOMPARE(greenFrame.size(), QSize(64,64));
+
+ QCOMPARE(blueFrame.pixel(0,0), qRgb(0x0, 0x0, 0xff));
+ QCOMPARE(blueFrame.size(), QSize(64,64));
+ QVERIFY(emptyFrame.isNull());
+ }
+
+ // Do a Size query as substitute for canRead
+ {
+ QImageReader io(":images/four-frames.gif");
+
+ QCOMPARE(io.size(), QSize(64,64));
+ QCOMPARE(io.size(), QSize(64,64));
+ QImage blackFrame = io.read();
+
+ QCOMPARE(io.size(), QSize(64,64));
+ QCOMPARE(io.size(), QSize(64,64));
+ QImage whiteFrame = io.read();
+
+ QCOMPARE(io.size(), QSize(64,64));
+ QCOMPARE(io.size(), QSize(64,64));
+ QImage greenFrame = io.read();
+
+ QCOMPARE(io.size(), QSize(64,64));
+ QCOMPARE(io.size(), QSize(64,64));
+ QImage blueFrame = io.read();
+
+ QCOMPARE(io.size(), QSize());
+ QVERIFY(!io.canRead());
+ QImage emptyFrame = io.read();
+
+ QVERIFY(!io.canRead());
+ QCOMPARE(blackFrame.pixel(0,0), qRgb(0, 0, 0));
+ QCOMPARE(blackFrame.size(), QSize(64,64));
+
+ QCOMPARE(whiteFrame.pixel(0,0), qRgb(0xff, 0xff, 0xff));
+ QCOMPARE(whiteFrame.size(), QSize(64,64));
+
+ QCOMPARE(greenFrame.pixel(0,0), qRgb(0x0, 0xff, 0x0));
+ QCOMPARE(greenFrame.size(), QSize(64,64));
+
+ QCOMPARE(blueFrame.pixel(0,0), qRgb(0x0, 0x0, 0xff));
+ QCOMPARE(blueFrame.size(), QSize(64,64));
+ QVERIFY(emptyFrame.isNull());
+ }
+}
#endif
class Server : public QObject
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index 4f89708a17..1d39c67ee0 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -768,9 +768,7 @@ void tst_QSqlDatabase::checkValues(const FieldDef fieldDefs[], QSqlDatabase db)
rec->setValue(fieldDefs[ i ].fieldName(), fieldDefs[ i ].val);
// qDebug(QString("inserting %1 into %2").arg(fieldDefs[ i ].val.toString()).arg(fieldDefs[ i ].fieldName()));
}
- if (!cur.insert()) {
- QFAIL(QString("Couldn't insert record: %1 %2").arg(cur.lastError().databaseText()).arg(cur.lastError().driverText()));
- }
+ QVERIFY_SQL(cur, insert());
cur.setForwardOnly(true);
QVERIFY_SQL(cur, select("id = " + QString::number(pkey - 1)));
QVERIFY_SQL(cur, next());
@@ -833,9 +831,7 @@ void tst_QSqlDatabase::checkNullValues(const FieldDef fieldDefs[], QSqlDatabase
else
rec->setValue(fieldDefs[ i ].fieldName(), fieldDefs[ i ].val);
}
- if (!cur.insert()) {
- QFAIL(QString("Couldn't insert record: %1 %2").arg(cur.lastError().databaseText()).arg(cur.lastError().driverText()));
- }
+ QVERIFY_SQL(cur, insert());
cur.setForwardOnly(true);
QVERIFY_SQL(cur, select("id = " + QString::number(pkey - 1)));
QVERIFY_SQL(cur, next());
@@ -907,12 +903,8 @@ void tst_QSqlDatabase::recordOCI()
CHECK_DATABASE(db);
// runtime check for Oracle version since V8 doesn't support TIMESTAMPs
- if (tst_Databases::getOraVersion(db) >= 9) {
- qDebug("Detected Oracle >= 9, TIMESTAMP test enabled");
- hasTimeStamp = true;
- } else {
- qDebug("Detected Oracle < 9, TIMESTAMP test disabled");
- }
+ if (tst_Databases::getOraVersion(db) >= 9)
+ hasTimeStamp = true;
FieldDef tsdef;
FieldDef tstzdef;
@@ -923,11 +915,11 @@ void tst_QSqlDatabase::recordOCI()
static const QDateTime dt(QDate::currentDate(), QTime(1, 2, 3, 0));
if (hasTimeStamp) {
- tsdef = FieldDef("timestamp", QVariant::DateTime, dt);
- tstzdef = FieldDef("timestamp with time zone", QVariant::DateTime, dt);
- tsltzdef = FieldDef("timestamp with local time zone", QVariant::DateTime, dt);
- intytm = FieldDef("interval year to month", QVariant::String, QString("+01-01"));
- intdts = FieldDef("interval day to second", QVariant::String, QString("+01 00:00:01.000000"));
+ tsdef = FieldDef("timestamp", QVariant::DateTime, dt);
+ tstzdef = FieldDef("timestamp with time zone", QVariant::DateTime, dt);
+ tsltzdef = FieldDef("timestamp with local time zone", QVariant::DateTime, dt);
+ intytm = FieldDef("interval year to month", QVariant::String, QString("+01-01"));
+ intdts = FieldDef("interval day to second", QVariant::String, QString("+01 00:00:01.000000"));
}
const FieldDef fieldDefs[] = {
@@ -937,21 +929,19 @@ void tst_QSqlDatabase::recordOCI()
FieldDef("nvarchar2(20)", QVariant::String, QString("blah4")),
FieldDef("number(10,5)", QVariant::Double, 1.1234567),
FieldDef("date", QVariant::DateTime, dt),
-#ifdef QT3_SUPPORT
-//X? FieldDef("long raw", QVariant::ByteArray, QByteArray(Q3CString("blah5"))),
- FieldDef("raw(2000)", QVariant::ByteArray, QByteArray(Q3CString("blah6")), false),
- FieldDef("blob", QVariant::ByteArray, QByteArray(Q3CString("blah7"))),
-#endif
+ FieldDef("long raw", QVariant::ByteArray, QByteArray("blah5")),
+ FieldDef("raw(2000)", QVariant::ByteArray, QByteArray("blah6"), false),
+ FieldDef("blob", QVariant::ByteArray, QByteArray("blah7")),
FieldDef("clob", QVariant::String, QString("blah8")),
FieldDef("nclob", QVariant::String, QString("blah9")),
- FieldDef("bfile", QVariant::ByteArray, QByteArray("blah10")),
+// FieldDef("bfile", QVariant::ByteArray, QByteArray("blah10")),
- intytm,
- intdts,
- tsdef,
- tstzdef,
- tsltzdef,
- FieldDef()
+ intytm,
+ intdts,
+ tsdef,
+ tstzdef,
+ tsltzdef,
+ FieldDef()
};
const int fieldCount = createFieldTable(fieldDefs, db);
@@ -959,9 +949,8 @@ void tst_QSqlDatabase::recordOCI()
commonFieldTest(fieldDefs, db, fieldCount);
checkNullValues(fieldDefs, db);
- for (int i = 0; i < ITERATION_COUNT; ++i) {
- checkValues(fieldDefs, db);
- }
+ for (int i = 0; i < ITERATION_COUNT; ++i)
+ checkValues(fieldDefs, db);
// some additional tests
QSqlRecord rec = db.record(qTableName("qtestfields"));
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 03e77aa94f..70cfb61f77 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -1682,6 +1682,12 @@ void tst_QUrl::toString_constructed_data()
<< QByteArray("//qt.nokia.com/index.html");
QTest::newRow("data2") << QString::fromLatin1("file") << n << n << n << -1 << QString::fromLatin1("/root") << QByteArray()
<< n << QString::fromLatin1("file:///root") << QByteArray("file:///root");
+ QTest::newRow("userAndPass") << QString::fromLatin1("http") << QString::fromLatin1("dfaure") << QString::fromLatin1("kde")
+ << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n
+ << QString::fromLatin1("http://dfaure:kde@kde.org:443/") << QByteArray("http://dfaure:kde@kde.org:443/");
+ QTest::newRow("PassWithoutUser") << QString::fromLatin1("http") << n << QString::fromLatin1("kde")
+ << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n
+ << QString::fromLatin1("http://:kde@kde.org:443/") << QByteArray("http://:kde@kde.org:443/");
}
void tst_QUrl::toString_constructed()
@@ -1717,6 +1723,7 @@ void tst_QUrl::toString_constructed()
QVERIFY(url.isValid());
QCOMPARE(url.toString(), asString);
+ QCOMPARE(QString::fromLatin1(url.toEncoded()), QString::fromLatin1(asEncoded)); // readable in case of differences
QCOMPARE(url.toEncoded(), asEncoded);
}
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 3e14b5619d..2d04cc50c4 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -66,6 +66,8 @@
#include <private/qapplication_p.h>
#include <qcalendarwidget.h>
#include <qmainwindow.h>
+#include <qdockwidget.h>
+#include <qtoolbar.h>
#include <QtGui/qpaintengine.h>
#include <private/qbackingstore_p.h>
@@ -356,6 +358,7 @@ private slots:
void paintOnScreenPossible();
#endif
void reparentStaticWidget();
+ void QTBUG6883_reparentStaticWidget2();
#ifdef Q_WS_QWS
void updateOutsideSurfaceClip();
#endif
@@ -8728,6 +8731,31 @@ void tst_QWidget::reparentStaticWidget()
// Please don't crash.
paintOnScreen.resize(paintOnScreen.size() + QSize(2, 2));
QTest::qWait(20);
+
+}
+
+void tst_QWidget::QTBUG6883_reparentStaticWidget2()
+{
+ QMainWindow mw;
+ QDockWidget *one = new QDockWidget("one", &mw);
+ mw.addDockWidget(Qt::LeftDockWidgetArea, one , Qt::Vertical);
+
+ QWidget *child = new QWidget();
+ child->setPalette(Qt::red);
+ child->setAutoFillBackground(true);
+ child->setAttribute(Qt::WA_StaticContents);
+ child->resize(100, 100);
+ one->setWidget(child);
+
+ QToolBar *mainTools = mw.addToolBar("Main Tools");
+ mainTools->addWidget(new QLineEdit);
+
+ mw.show();
+ QTest::qWaitForWindowShown(&mw);
+
+ one->setFloating(true);
+ QTest::qWait(20);
+ //do not crash
}
#ifdef Q_WS_QWS
@@ -9726,7 +9754,7 @@ public:
void deleteBackingStore()
{
if (static_cast<QWidgetPrivate*>(d_ptr.data())->maybeBackingStore()) {
- delete static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore;
+ delete static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore;
static_cast<QWidgetPrivate*>(d_ptr.data())->topData()->backingStore = 0;
}
}
diff --git a/tests/auto/uiloader/baseline/css_qtbug6855.ui b/tests/auto/uiloader/baseline/css_qtbug6855.ui
new file mode 100644
index 0000000000..0727f6ba99
--- /dev/null
+++ b/tests/auto/uiloader/baseline/css_qtbug6855.ui
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>212</width>
+ <height>108</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">QPushButton { padding: 20px; }</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QPushButton" name="pushButton">
+ <property name="text">
+ <string>Text not cropped</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>258</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>218</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro
index bffa009976..0f760a17d1 100644
--- a/tests/benchmarks/benchmarks.pro
+++ b/tests/benchmarks/benchmarks.pro
@@ -5,6 +5,7 @@ SUBDIRS = containers-associative \
qbytearray \
qfileinfo \
qfile_vs_qnetworkaccessmanager \
+ qhostinfo \
qpainter \
qtestlib-simple events \
qiodevice \
@@ -36,7 +37,8 @@ SUBDIRS = containers-associative \
qstringbuilder \
qstylesheetstyle \
qsvgrenderer \
- qtableview
+ qtableview \
+ qthreadstorage
diff --git a/tests/benchmarks/qhostinfo/main.cpp b/tests/benchmarks/qhostinfo/main.cpp
new file mode 100644
index 0000000000..389443b5c5
--- /dev/null
+++ b/tests/benchmarks/qhostinfo/main.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QDebug>
+#include <QHostInfo>
+#include <QStringList>
+#include <QString>
+
+#include <qtest.h>
+#include <qtesteventloop.h>
+
+class tst_qhostinfo : public QObject
+{
+ Q_OBJECT
+private slots:
+ void lookupSpeed();
+};
+
+class SignalReceiver : public QObject
+{
+ Q_OBJECT
+public:
+ SignalReceiver(int nrc) : receiveCount(0), neededReceiveCount(nrc) {};
+ int receiveCount;
+ int neededReceiveCount;
+public slots:
+ void resultsReady(const QHostInfo) {
+ receiveCount++;
+ if (receiveCount == neededReceiveCount)
+ QTestEventLoop::instance().exitLoop();
+ }
+};
+
+void tst_qhostinfo::lookupSpeed()
+{
+ QStringList hostnameList;
+ hostnameList << "www.ovi.com" << "www.nokia.com" << "qt.nokia.com" << "www.trolltech.com" << "troll.no"
+ << "www.qtcentre.org" << "forum.nokia.com" << "www.forum.nokia.com" << "wiki.forum.nokia.com"
+ << "www.nokia.no" << "nokia.de" << "127.0.0.1" << "----";
+ // also add some duplicates:
+ hostnameList << "www.nokia.com" << "127.0.0.1" << "www.trolltech.com";
+ const int COUNT = hostnameList.size();
+
+ SignalReceiver receiver(COUNT);
+
+ QBENCHMARK {
+ for (int i = 0; i < hostnameList.size(); i++)
+ QHostInfo::lookupHost(hostnameList.at(i), &receiver, SLOT(resultsReady(const QHostInfo)));
+ QTestEventLoop::instance().enterLoop(20);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ }
+}
+
+
+QTEST_MAIN(tst_qhostinfo)
+
+#include "main.moc"
diff --git a/tests/benchmarks/qhostinfo/qhostinfo.pro b/tests/benchmarks/qhostinfo/qhostinfo.pro
new file mode 100755
index 0000000000..f18d6d7a68
--- /dev/null
+++ b/tests/benchmarks/qhostinfo/qhostinfo.pro
@@ -0,0 +1,13 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qhostinfo
+DEPENDPATH += .
+INCLUDEPATH += .
+
+QT -= gui
+QT += network
+
+CONFIG += release
+
+# Input
+SOURCES += main.cpp
diff --git a/tests/benchmarks/qthreadstorage/qthreadstorage.pro b/tests/benchmarks/qthreadstorage/qthreadstorage.pro
new file mode 100644
index 0000000000..f9c1978b73
--- /dev/null
+++ b/tests/benchmarks/qthreadstorage/qthreadstorage.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qthreadstorage
+
+SOURCES += tst_qthreadstorage.cpp
+
diff --git a/tests/benchmarks/qthreadstorage/tst_qthreadstorage.cpp b/tests/benchmarks/qthreadstorage/tst_qthreadstorage.cpp
new file mode 100644
index 0000000000..c00bf5ab4a
--- /dev/null
+++ b/tests/benchmarks/qthreadstorage/tst_qthreadstorage.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QtCore>
+
+//TESTED_FILES=
+
+QThreadStorage<int *> dummy[8];
+
+QThreadStorage<QString *> tls1;
+
+class tst_QThreadStorage : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QThreadStorage();
+ virtual ~tst_QThreadStorage();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void construct();
+ void get();
+ void set();
+};
+
+tst_QThreadStorage::tst_QThreadStorage()
+{
+}
+
+tst_QThreadStorage::~tst_QThreadStorage()
+{
+}
+
+void tst_QThreadStorage::init()
+{
+ dummy[1].setLocalData(new int(5));
+ dummy[2].setLocalData(new int(4));
+ dummy[3].setLocalData(new int(3));
+ tls1.setLocalData(new QString());
+}
+
+void tst_QThreadStorage::cleanup()
+{
+}
+
+void tst_QThreadStorage::construct()
+{
+ QBENCHMARK {
+ QThreadStorage<int *> ts;
+ }
+}
+
+
+void tst_QThreadStorage::get()
+{
+ QThreadStorage<int *> ts;
+ ts.setLocalData(new int(45));
+
+ int count = 0;
+ QBENCHMARK {
+ int *i = ts.localData();
+ count += *i;
+ }
+ ts.setLocalData(0);
+}
+
+void tst_QThreadStorage::set()
+{
+ QThreadStorage<int *> ts;
+
+ int count = 0;
+ QBENCHMARK {
+ ts.setLocalData(new int(count));
+ count++;
+ }
+ ts.setLocalData(0);
+}
+
+
+QTEST_MAIN(tst_QThreadStorage)
+#include "tst_qthreadstorage.moc"
diff --git a/tools/designer/src/components/objectinspector/objectinspector.pri b/tools/designer/src/components/objectinspector/objectinspector.pri
index 280a1dc9e7..733c4b37ae 100644
--- a/tools/designer/src/components/objectinspector/objectinspector.pri
+++ b/tools/designer/src/components/objectinspector/objectinspector.pri
@@ -1,4 +1,10 @@
-include($$QT_SOURCE_TREE/tools/shared/findwidget/findwidget.pri)
+# --- The Find widget is also linked into the designer_shared library.
+# Avoid conflict when linking statically
+contains(CONFIG, static) {
+ INCLUDEPATH *= $$QT_SOURCE_TREE/tools/shared/findwidget
+} else {
+ include($$QT_SOURCE_TREE/tools/shared/findwidget/findwidget.pri)
+}
INCLUDEPATH += $$PWD
diff --git a/tools/designer/src/components/propertyeditor/propertyeditor.pri b/tools/designer/src/components/propertyeditor/propertyeditor.pri
index d3e44a57b1..a8ed37e81d 100644
--- a/tools/designer/src/components/propertyeditor/propertyeditor.pri
+++ b/tools/designer/src/components/propertyeditor/propertyeditor.pri
@@ -4,8 +4,15 @@
INCLUDEPATH += $$PWD
-include($$QT_SOURCE_TREE/tools/shared/qtpropertybrowser/qtpropertybrowser.pri)
-include($$QT_SOURCE_TREE/tools/shared/qtgradienteditor/qtcolorbutton.pri)
+# --- Property browser is also linked into the designer_shared library.
+# Avoid conflict when linking statically
+contains(CONFIG, static) {
+ INCLUDEPATH *= $$QT_SOURCE_TREE/tools/shared/qtpropertybrowser
+ INCLUDEPATH *= $$QT_SOURCE_TREE/tools/shared/qtgradienteditor
+} else {
+ include($$QT_SOURCE_TREE/tools/shared/qtpropertybrowser/qtpropertybrowser.pri)
+ include($$QT_SOURCE_TREE/tools/shared/qtgradienteditor/qtcolorbutton.pri)
+}
FORMS += $$PWD/paletteeditor.ui \
$$PWD/stringlisteditor.ui \
diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp
new file mode 100644
index 0000000000..58d8c3b4ff
--- /dev/null
+++ b/tools/runonphone/main.cpp
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QCoreApplication>
+#include <QDebug>
+#include <QStringList>
+#include <QScopedPointer>
+#include "trkutils.h"
+#include "trkdevice.h"
+#include "launcher.h"
+
+#include "trksignalhandler.h"
+#include "serenum.h"
+
+void printUsage()
+{
+ qDebug() << "runtest [options] <program> [program arguments]" << endl
+ << "-s, --sis <file> specify sis file to install" << endl
+ << "-p, --portname <COMx> specify COM port to use by device name" << endl
+ << "-f, --portfriendlyname <substring> specify COM port to use by friendly name" << endl
+ << endl
+ << "USB COM ports can usually be autodetected" << endl;
+}
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication a(argc, argv);
+
+ QString serialPortName;
+ QString serialPortFriendlyName;
+ QString sisFile;
+ QString exeFile;
+ QString cmdLine;
+ QStringList args = QCoreApplication::arguments();
+ for (int i=1;i<args.size();i++) {
+ QString arg = args.at(i);
+ if (arg.startsWith("-")) {
+ if (args.size() < i+2) {
+ qWarning("Command line missing argument parameters");
+ return 1;
+ }
+ i++;
+ QString param = args.at(i);
+ if(arg.compare("--portname", Qt::CaseSensitive) == 0
+ || arg.compare("-p", Qt::CaseSensitive) == 0)
+ serialPortName = param;
+ else if(arg.compare("--portfriendlyname", Qt::CaseSensitive) == 0
+ || arg.compare("-f", Qt::CaseSensitive) == 0)
+ serialPortFriendlyName = param;
+ else if(arg.compare("--sis", Qt::CaseSensitive) == 0
+ || arg.compare("-s", Qt::CaseSensitive) == 0)
+ sisFile = param;
+ else
+ qWarning() << "unknown command line option " << arg;
+ } else {
+ exeFile = arg;
+ i++;
+ for(;i<args.size();i++) {
+ cmdLine.append(args.at(i));
+ if(i + 1 < args.size()) cmdLine.append(' ');
+ }
+ }
+ }
+
+ if(exeFile.isEmpty()) {
+ printUsage();
+ return 1;
+ }
+
+ if(serialPortName.isEmpty()) {
+ qDebug() << "Detecting serial ports" << endl;
+ QList <SerialPortId> ports = enumerateSerialPorts();
+ foreach(SerialPortId id, ports) {
+ qDebug() << "Port Name: " << id.portName << ", "
+ << "Friendly Name:" << id.friendlyName << endl;
+ if(serialPortName.isEmpty()) {
+ if(id.friendlyName.isEmpty() &&
+ (id.friendlyName.contains("symbian", Qt::CaseInsensitive) ||
+ id.friendlyName.contains("s60", Qt::CaseInsensitive) ||
+ id.friendlyName.contains("nokia", Qt::CaseInsensitive)))
+ serialPortName = id.portName;
+ else if (!id.friendlyName.isEmpty() &&
+ id.friendlyName.contains(serialPortFriendlyName))
+ serialPortName = id.portName;
+ }
+ }
+ }
+
+ QScopedPointer<trk::Launcher> launcher;
+
+ if(sisFile.isEmpty()) {
+ launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyRun));
+ launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + exeFile);
+ qDebug() << "System TRK required to copy EXE, use --sis if using Application TRK" << endl;
+ } else {
+ launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyInstallRun));
+ launcher->addStartupActions(trk::Launcher::ActionInstall);
+ launcher->setCopyFileName(sisFile, "c:\\data\\testtemp.sis");
+ launcher->setInstallFileName("c:\\data\\testtemp.sis");
+ }
+ qDebug() << "Connecting to target via " << serialPortName << endl;
+ launcher->setTrkServerName(QString("\\\\.\\") + serialPortName);
+
+ launcher->setFileName(QString("c:\\sys\\bin\\") + exeFile);
+ launcher->setCommandLineArgs(cmdLine);
+
+ TrkSignalHandler handler;
+
+ QObject::connect(launcher.data(), SIGNAL(copyingStarted()), &handler, SLOT(copyingStarted()));
+ QObject::connect(launcher.data(), SIGNAL(canNotConnect(const QString &)), &handler, SLOT(canNotConnect(const QString &)));
+ QObject::connect(launcher.data(), SIGNAL(canNotCreateFile(const QString &, const QString &)), &handler, SLOT(canNotCreateFile(const QString &, const QString &)));
+ QObject::connect(launcher.data(), SIGNAL(canNotWriteFile(const QString &, const QString &)), &handler, SLOT(canNotWriteFile(const QString &, const QString &)));
+ QObject::connect(launcher.data(), SIGNAL(canNotCloseFile(const QString &, const QString &)), &handler, SLOT(canNotCloseFile(const QString &, const QString &)));
+ QObject::connect(launcher.data(), SIGNAL(installingStarted()), &handler, SLOT(installingStarted()));
+ QObject::connect(launcher.data(), SIGNAL(canNotInstall(const QString &, const QString &)), &handler, SLOT(canNotInstall(const QString &, const QString &)));
+ QObject::connect(launcher.data(), SIGNAL(installingFinished()), &handler, SLOT(installingFinished()));
+ QObject::connect(launcher.data(), SIGNAL(startingApplication()), &handler, SLOT(startingApplication()));
+ QObject::connect(launcher.data(), SIGNAL(applicationRunning(uint)), &handler, SLOT(applicationRunning(uint)));
+ QObject::connect(launcher.data(), SIGNAL(canNotRun(const QString &)), &handler, SLOT(canNotRun(const QString &)));
+ QObject::connect(launcher.data(), SIGNAL(applicationOutputReceived(const QString &)), &handler, SLOT(applicationOutputReceived(const QString &)));
+ QObject::connect(launcher.data(), SIGNAL(copyProgress(int)), &handler, SLOT(copyProgress(int)));
+ QObject::connect(launcher.data(), SIGNAL(stateChanged(int)), &handler, SLOT(stateChanged(int)));
+ QObject::connect(launcher.data(), SIGNAL(finished()), &handler, SLOT(finished()));
+
+ QString errorMessage;
+ if(!launcher->startServer(&errorMessage)) {
+ qWarning() << errorMessage;
+ return 1;
+ }
+
+ return a.exec();
+}
+
diff --git a/tools/runonphone/runonphone.pro b/tools/runonphone/runonphone.pro
new file mode 100644
index 0000000000..d243121af1
--- /dev/null
+++ b/tools/runonphone/runonphone.pro
@@ -0,0 +1,19 @@
+TEMPLATE = app
+
+QT -= gui
+CONFIG += console
+CONFIG -= app_bundle
+
+include(trk/trk.pri)
+
+SOURCES += main.cpp \
+ trksignalhandler.cpp
+
+HEADERS += trksignalhandler.h \
+ serenum.h
+
+windows {
+ SOURCES += serenum_win.cpp
+ LIBS += -lsetupapi \
+ -luuid
+}
diff --git a/tools/runonphone/serenum.h b/tools/runonphone/serenum.h
new file mode 100644
index 0000000000..e7ab2d12b0
--- /dev/null
+++ b/tools/runonphone/serenum.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WIN32SERENUM_H
+#define WIN32SERENUM_H
+
+#include <QString>
+#include <QList>
+
+struct SerialPortId
+{
+ QString portName;
+ QString friendlyName;
+};
+
+QList<SerialPortId> enumerateSerialPorts();
+
+#endif // WIN32SERENUM_H
diff --git a/tools/runonphone/serenum_win.cpp b/tools/runonphone/serenum_win.cpp
new file mode 100644
index 0000000000..ec11c3cad1
--- /dev/null
+++ b/tools/runonphone/serenum_win.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "serenum.h"
+#include <QByteArray>
+#include <QString>
+#include <QDebug>
+#include <windows.h>
+#include <windef.h>
+#include <setupapi.h>
+#include <devguid.h>
+#include <winreg.h>
+#include <shlwapi.h>
+
+//{4d36e978-e325-11ce-bfc1-08002be10318}
+//DEFINE_GUID(GUID_DEVCLASS_PORTS, 0x4D36E978, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18 );
+
+QList<SerialPortId> enumerateSerialPorts()
+{
+ DWORD index=0;
+ SP_DEVINFO_DATA info;
+ GUID guid = GUID_DEVCLASS_PORTS;
+ HDEVINFO infoset = SetupDiGetClassDevs(&guid, 0, 0, DIGCF_PRESENT);
+ QString valueName(16384, 0);
+ QList<SerialPortId> list;
+
+ for (index=0;;index++) {
+ ZeroMemory(&info, sizeof(SP_DEVINFO_DATA));
+ info.cbSize = sizeof(SP_DEVINFO_DATA);
+ if (!SetupDiEnumDeviceInfo(infoset, index, &info))
+ break;
+ QString friendlyName;
+ QString portName;
+ DWORD size=0;
+ SetupDiGetDeviceRegistryProperty(infoset, &info, SPDRP_FRIENDLYNAME, 0, 0, 0, &size);
+ QByteArray ba(size, 0);
+ if(SetupDiGetDeviceRegistryProperty(infoset, &info, SPDRP_FRIENDLYNAME, 0, (BYTE*)(ba.data()), size, 0)) {
+ friendlyName = QString((const QChar*)(ba.constData()), ba.size() / 2 - 1);
+ }
+ HKEY key = SetupDiOpenDevRegKey(infoset, &info, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ);
+ if(key != INVALID_HANDLE_VALUE) {
+#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600
+ //RegGetValue not supported on XP, SHRegGetValue not supported by mingw :(
+ for (DWORD dwi=0;;dwi++) {
+ DWORD vsize = valueName.size();
+ if (ERROR_SUCCESS == RegEnumValue(key, dwi, (WCHAR*)(valueName.data()), &vsize, 0, 0, 0, &size)) {
+ if (valueName.startsWith("PortName")) {
+ QByteArray ba(size, 0);
+ vsize = valueName.size();
+ if(ERROR_SUCCESS == RegEnumValue(key, dwi, (WCHAR*)(valueName.data()), &vsize, 0, 0, (BYTE*)(ba.data()), &size)) {
+ portName = QString((const QChar*)(ba.constData()), ba.size() / 2 - 1);
+ }
+ }
+ } else {
+ break;
+ }
+ }
+#else
+ if (ERROR_SUCCESS == SHRegGetValue(key, 0, "PortName", SRRF_RT_REG_SZ, 0, &size)) {
+ QByteArray ba(size, 0);
+ if (ERROR_SUCCESS == RegGetValue(key, 0, "PortName", SRRF_RT_REG_SZ, (BYTE*)(ba.data()), &size)) {
+ portName = QString((const QChar*)(ba.constData()), ba.size() / 2 - 1);
+ }
+ }
+#endif
+ RegCloseKey(key);
+ }
+ SerialPortId id;
+ id.portName = portName;
+ id.friendlyName = friendlyName;
+ list.append(id);
+ }
+ SetupDiDestroyDeviceInfoList(infoset);
+ return list;
+}
+
diff --git a/tools/runonphone/trk/bluetoothlistener.cpp b/tools/runonphone/trk/bluetoothlistener.cpp
new file mode 100644
index 0000000000..73be9f4203
--- /dev/null
+++ b/tools/runonphone/trk/bluetoothlistener.cpp
@@ -0,0 +1,224 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bluetoothlistener.h"
+#include "trkdevice.h"
+
+#include <QtCore/QDebug>
+
+#ifdef Q_OS_UNIX
+# include <unistd.h>
+# include <signal.h>
+#else
+# include <windows.h>
+#endif
+
+// Process id helpers.
+#ifdef Q_OS_WIN
+inline DWORD processId(const QProcess &p)
+{
+ if (const Q_PID processInfoStruct = p.pid())
+ return processInfoStruct->dwProcessId;
+ return 0;
+}
+#else
+inline Q_PID processId(const QProcess &p)
+{
+ return p.pid();
+}
+#endif
+
+
+enum { debug = 0 };
+
+namespace trk {
+
+struct BluetoothListenerPrivate {
+ BluetoothListenerPrivate();
+ QString device;
+ QProcess process;
+#ifdef Q_OS_WIN
+ DWORD pid;
+#else
+ Q_PID pid;
+#endif
+ bool printConsoleMessages;
+ BluetoothListener::Mode mode;
+};
+
+BluetoothListenerPrivate::BluetoothListenerPrivate() :
+ pid(0),
+ printConsoleMessages(false),
+ mode(BluetoothListener::Listen)
+{
+}
+
+BluetoothListener::BluetoothListener(QObject *parent) :
+ QObject(parent),
+ d(new BluetoothListenerPrivate)
+{
+ d->process.setProcessChannelMode(QProcess::MergedChannels);
+
+ connect(&d->process, SIGNAL(readyReadStandardError()),
+ this, SLOT(slotStdError()));
+ connect(&d->process, SIGNAL(readyReadStandardOutput()),
+ this, SLOT(slotStdOutput()));
+ connect(&d->process, SIGNAL(finished(int, QProcess::ExitStatus)),
+ this, SLOT(slotProcessFinished(int,QProcess::ExitStatus)));
+ connect(&d->process, SIGNAL(error(QProcess::ProcessError)),
+ this, SLOT(slotProcessError(QProcess::ProcessError)));
+}
+
+BluetoothListener::~BluetoothListener()
+{
+ const int trc = terminateProcess();
+ if (debug)
+ qDebug() << "~BluetoothListener: terminated" << trc;
+ delete d;
+}
+
+BluetoothListener::Mode BluetoothListener::mode() const
+{
+ return d->mode;
+}
+
+void BluetoothListener::setMode(Mode m)
+{
+ d->mode = m;
+}
+
+bool BluetoothListener::printConsoleMessages() const
+{
+ return d->printConsoleMessages;
+}
+
+void BluetoothListener::setPrintConsoleMessages(bool p)
+{
+ d->printConsoleMessages = p;
+}
+
+int BluetoothListener::terminateProcess()
+{
+ enum { TimeOutMS = 200 };
+ if (debug)
+ qDebug() << "terminateProcess" << d->process.pid() << d->process.state();
+ if (d->process.state() == QProcess::NotRunning)
+ return -1;
+ emitMessage(tr("%1: Stopping listener %2...").arg(d->device).arg(processId(d->process)));
+ // When listening, the process should terminate by itself after closing the connection
+ if (mode() == Listen && d->process.waitForFinished(TimeOutMS))
+ return 0;
+#ifdef Q_OS_UNIX
+ kill(d->process.pid(), SIGHUP); // Listens for SIGHUP
+ if (d->process.waitForFinished(TimeOutMS))
+ return 1;
+#endif
+ d->process.terminate();
+ if (d->process.waitForFinished(TimeOutMS))
+ return 2;
+ d->process.kill();
+ return 3;
+}
+
+bool BluetoothListener::start(const QString &device, QString *errorMessage)
+{
+ if (d->process.state() != QProcess::NotRunning) {
+ *errorMessage = QLatin1String("Internal error: Still running.");
+ return false;
+ }
+ d->device = device;
+ const QString binary = QLatin1String("rfcomm");
+ QStringList arguments;
+ arguments << QLatin1String("-r")
+ << (d->mode == Listen ? QLatin1String("listen") : QLatin1String("watch"))
+ << device << QString(QLatin1Char('1'));
+ if (debug)
+ qDebug() << binary << arguments;
+ emitMessage(tr("%1: Starting Bluetooth listener %2...").arg(device, binary));
+ d->pid = 0;
+ d->process.start(binary, arguments);
+ if (!d->process.waitForStarted()) {
+ *errorMessage = tr("Unable to run '%1': %2").arg(binary, d->process.errorString());
+ return false;
+ }
+ d->pid = processId(d->process); // Forgets it after crash/termination
+ emitMessage(tr("%1: Bluetooth listener running (%2).").arg(device).arg(processId(d->process)));
+ return true;
+}
+
+void BluetoothListener::slotStdOutput()
+{
+ emitMessage(QString::fromLocal8Bit(d->process.readAllStandardOutput()));
+}
+
+void BluetoothListener::emitMessage(const QString &m)
+{
+ if (d->printConsoleMessages || debug)
+ qDebug("%s\n", qPrintable(m));
+ emit message(m);
+}
+
+void BluetoothListener::slotStdError()
+{
+ emitMessage(QString::fromLocal8Bit(d->process.readAllStandardError()));
+}
+
+void BluetoothListener::slotProcessFinished(int ex, QProcess::ExitStatus state)
+{
+ switch (state) {
+ case QProcess::NormalExit:
+ emitMessage(tr("%1: Process %2 terminated with exit code %3.")
+ .arg(d->device).arg(d->pid).arg(ex));
+ break;
+ case QProcess::CrashExit:
+ emitMessage(tr("%1: Process %2 crashed.").arg(d->device).arg(d->pid));
+ break;
+ }
+ emit terminated();
+}
+
+void BluetoothListener::slotProcessError(QProcess::ProcessError error)
+{
+ emitMessage(tr("%1: Process error %2: %3")
+ .arg(d->device).arg(error).arg(d->process.errorString()));
+}
+
+} // namespace trk
diff --git a/tools/runonphone/trk/bluetoothlistener.h b/tools/runonphone/trk/bluetoothlistener.h
new file mode 100644
index 0000000000..0baec74e3c
--- /dev/null
+++ b/tools/runonphone/trk/bluetoothlistener.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BLUETOOTHLISTENER_H
+#define BLUETOOTHLISTENER_H
+
+#include <QtCore/QObject>
+#include <QtCore/QProcess>
+
+namespace trk {
+struct BluetoothListenerPrivate;
+
+/* BluetoothListener: Starts a helper process watching connections on a
+ * Bluetooth device, Linux only:
+ * The rfcomm command is used. It process can be started in the background
+ * while connection attempts (TrkDevice::open()) are made in the foreground. */
+
+class BluetoothListener : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(BluetoothListener)
+public:
+ // The Mode property must be set before calling start().
+ enum Mode {
+ Listen, /* Terminate after client closed (read: Trk app
+ * on the phone terminated or disconnected).*/
+ Watch // Keep running, watch for next connection from client
+ };
+
+ explicit BluetoothListener(QObject *parent = 0);
+ virtual ~BluetoothListener();
+
+ Mode mode() const;
+ void setMode(Mode m);
+
+ bool start(const QString &device, QString *errorMessage);
+
+ // Print messages on the console.
+ bool printConsoleMessages() const;
+ void setPrintConsoleMessages(bool p);
+
+signals:
+ void terminated();
+ void message(const QString &);
+
+public slots:
+ void emitMessage(const QString &m); // accessed by starter
+
+private slots:
+ void slotStdOutput();
+ void slotStdError();
+ void slotProcessFinished(int, QProcess::ExitStatus);
+ void slotProcessError(QProcess::ProcessError error);
+
+private:
+ int terminateProcess();
+
+ BluetoothListenerPrivate *d;
+};
+
+} // namespace trk
+
+#endif // BLUETOOTHLISTENER_H
diff --git a/tools/runonphone/trk/bluetoothlistener_gui.cpp b/tools/runonphone/trk/bluetoothlistener_gui.cpp
new file mode 100644
index 0000000000..d2fd72d029
--- /dev/null
+++ b/tools/runonphone/trk/bluetoothlistener_gui.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bluetoothlistener_gui.h"
+#include "bluetoothlistener.h"
+#include "communicationstarter.h"
+
+#include <QtGui/QMessageBox>
+#include <QtGui/QPushButton>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
+
+namespace trk {
+
+PromptStartCommunicationResult
+ promptStartCommunication(BaseCommunicationStarter &starter,
+ const QString &msgBoxTitle,
+ const QString &msgBoxText,
+ QWidget *msgBoxParent,
+ QString *errorMessage)
+{
+ errorMessage->clear();
+ // Initial connection attempt.
+ switch (starter.start()) {
+ case BaseCommunicationStarter::Started:
+ break;
+ case BaseCommunicationStarter::ConnectionSucceeded:
+ return PromptStartCommunicationConnected;
+ case BaseCommunicationStarter::StartError:
+ *errorMessage = starter.errorString();
+ return PromptStartCommunicationError;
+ }
+ // Run the starter with the event loop of a message box, have the box
+ // closed by the signals of the starter.
+ QMessageBox messageBox(QMessageBox::Information, msgBoxTitle, msgBoxText, QMessageBox::Cancel, msgBoxParent);
+ QObject::connect(&starter, SIGNAL(connected()), &messageBox, SLOT(close()));
+ QObject::connect(&starter, SIGNAL(timeout()), &messageBox, SLOT(close()));
+ messageBox.exec();
+ // Only starter.state() is reliable here to obtain the state.
+ switch (starter.state()) {
+ case AbstractBluetoothStarter::Running:
+ *errorMessage = QCoreApplication::translate("trk::promptStartCommunication", "Connection on %1 canceled.").arg(starter.device());
+ return PromptStartCommunicationCanceled;
+ case AbstractBluetoothStarter::TimedOut:
+ *errorMessage = starter.errorString();
+ return PromptStartCommunicationError;
+ case AbstractBluetoothStarter::Connected:
+ break;
+ }
+ return PromptStartCommunicationConnected;
+}
+
+PromptStartCommunicationResult
+ promptStartSerial(BaseCommunicationStarter &starter,
+ QWidget *msgBoxParent,
+ QString *errorMessage)
+{
+ const QString title = QCoreApplication::translate("trk::promptStartCommunication", "Waiting for App TRK");
+ const QString message = QCoreApplication::translate("trk::promptStartCommunication", "Waiting for App TRK to start on %1...").arg(starter.device());
+ return promptStartCommunication(starter, title, message, msgBoxParent, errorMessage);
+}
+
+PromptStartCommunicationResult
+ promptStartBluetooth(BaseCommunicationStarter &starter,
+ QWidget *msgBoxParent,
+ QString *errorMessage)
+{
+ const QString title = QCoreApplication::translate("trk::promptStartCommunication", "Waiting for Bluetooth Connection");
+ const QString message = QCoreApplication::translate("trk::promptStartCommunication", "Connecting to %1...").arg(starter.device());
+ return promptStartCommunication(starter, title, message, msgBoxParent, errorMessage);
+}
+
+} // namespace trk
diff --git a/tools/runonphone/trk/bluetoothlistener_gui.h b/tools/runonphone/trk/bluetoothlistener_gui.h
new file mode 100644
index 0000000000..3b2ec17274
--- /dev/null
+++ b/tools/runonphone/trk/bluetoothlistener_gui.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BLUETOOTHLISTENER_GUI_H
+#define BLUETOOTHLISTENER_GUI_H
+
+#include <QtCore/QtGlobal>
+
+QT_BEGIN_NAMESPACE
+class QWidget;
+QT_END_NAMESPACE
+
+namespace trk {
+class BaseCommunicationStarter;
+
+/* promptStartCommunication(): Convenience functions that
+ * prompt the user to start a communication (launching or
+ * connecting TRK) using a modal message box in which they can cancel.
+ * Pass in the starter with device and parameters set up. */
+
+enum PromptStartCommunicationResult {
+ PromptStartCommunicationConnected,
+ PromptStartCommunicationCanceled,
+ PromptStartCommunicationError
+};
+
+PromptStartCommunicationResult
+ promptStartCommunication(BaseCommunicationStarter &starter,
+ const QString &msgBoxTitle,
+ const QString &msgBoxText,
+ QWidget *msgBoxParent,
+ QString *errorMessage);
+
+// Convenience to start a serial connection (messages prompting
+// to launch Trk).
+PromptStartCommunicationResult
+ promptStartSerial(BaseCommunicationStarter &starter,
+ QWidget *msgBoxParent,
+ QString *errorMessage);
+
+// Convenience to start blue tooth connection (messages
+// prompting to connect).
+PromptStartCommunicationResult
+ promptStartBluetooth(BaseCommunicationStarter &starter,
+ QWidget *msgBoxParent,
+ QString *errorMessage);
+} // namespace trk
+
+#endif // BLUETOOTHLISTENER_GUI_H
diff --git a/tools/runonphone/trk/callback.h b/tools/runonphone/trk/callback.h
new file mode 100644
index 0000000000..4e12c5e4a5
--- /dev/null
+++ b/tools/runonphone/trk/callback.h
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DEBUGGER_CALLBACK_H
+#define DEBUGGER_CALLBACK_H
+
+#include <QtCore/QtGlobal>
+
+namespace trk {
+namespace Internal {
+
+/* Helper class for the 1-argument functor:
+ * Cloneable base class for the implementation which is
+ * invokeable with the argument. */
+template <class Argument>
+class CallbackImplBase
+{
+ Q_DISABLE_COPY(CallbackImplBase)
+public:
+ CallbackImplBase() {}
+ virtual CallbackImplBase *clone() const = 0;
+ virtual void invoke(Argument a) = 0;
+ virtual ~CallbackImplBase() {}
+};
+
+/* Helper class for the 1-argument functor: Implementation for
+ * a class instance with a member function pointer. */
+template <class Class, class Argument>
+class CallbackMemberPtrImpl : public CallbackImplBase<Argument>
+{
+public:
+ typedef void (Class::*MemberFuncPtr)(Argument);
+
+ CallbackMemberPtrImpl(Class *instance,
+ MemberFuncPtr memberFunc) :
+ m_instance(instance),
+ m_memberFunc(memberFunc) {}
+
+ virtual CallbackImplBase<Argument> *clone() const
+ {
+ return new CallbackMemberPtrImpl<Class, Argument>(m_instance, m_memberFunc);
+ }
+
+ virtual void invoke(Argument a)
+ { (m_instance->*m_memberFunc)(a); }
+private:
+ Class *m_instance;
+ MemberFuncPtr m_memberFunc;
+};
+
+} // namespace Internal
+
+/* Default-constructible, copyable 1-argument functor providing an
+ * operator()(Argument) that invokes a member function of a class:
+ * \code
+class Foo {
+public:
+ void print(const std::string &);
+};
+...
+Foo foo;
+Callback<const std::string &> f1(&foo, &Foo::print);
+f1("test");
+\endcode */
+
+template <class Argument>
+class Callback
+{
+public:
+ Callback() : m_impl(0) {}
+
+ template <class Class>
+ Callback(Class *instance, void (Class::*memberFunc)(Argument)) :
+ m_impl(new Internal::CallbackMemberPtrImpl<Class,Argument>(instance, memberFunc))
+ {}
+
+ ~Callback()
+ {
+ clean();
+ }
+
+ Callback(const Callback &rhs) :
+ m_impl(0)
+ {
+ if (rhs.m_impl)
+ m_impl = rhs.m_impl->clone();
+ }
+
+ Callback &operator=(const Callback &rhs)
+ {
+ if (this != &rhs) {
+ clean();
+ if (rhs.m_impl)
+ m_impl = rhs.m_impl->clone();
+ }
+ return *this;
+ }
+
+ bool isNull() const { return m_impl == 0; }
+ operator bool() const { return !isNull(); }
+
+ void operator()(Argument a)
+ {
+ if (m_impl)
+ m_impl->invoke(a);
+ }
+
+private:
+ void clean()
+ {
+ if (m_impl) {
+ delete m_impl;
+ m_impl = 0;
+ }
+ }
+
+ Internal::CallbackImplBase<Argument> *m_impl;
+};
+
+} // namespace trk
+
+#endif // DEBUGGER_CALLBACK_H
diff --git a/tools/runonphone/trk/communicationstarter.cpp b/tools/runonphone/trk/communicationstarter.cpp
new file mode 100644
index 0000000000..0251976afd
--- /dev/null
+++ b/tools/runonphone/trk/communicationstarter.cpp
@@ -0,0 +1,260 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "communicationstarter.h"
+#include "bluetoothlistener.h"
+#include "trkdevice.h"
+
+#include <QtCore/QTimer>
+#include <QtCore/QEventLoop>
+
+namespace trk {
+
+// --------------- AbstractBluetoothStarter
+struct BaseCommunicationStarterPrivate {
+ explicit BaseCommunicationStarterPrivate(const BaseCommunicationStarter::TrkDevicePtr &d);
+
+ const BaseCommunicationStarter::TrkDevicePtr trkDevice;
+ BluetoothListener *listener;
+ QTimer *timer;
+ int intervalMS;
+ int attempts;
+ int n;
+ QString device;
+ QString errorString;
+ BaseCommunicationStarter::State state;
+};
+
+BaseCommunicationStarterPrivate::BaseCommunicationStarterPrivate(const BaseCommunicationStarter::TrkDevicePtr &d) :
+ trkDevice(d),
+ listener(0),
+ timer(0),
+ intervalMS(1000),
+ attempts(-1),
+ n(0),
+ device(QLatin1String("/dev/rfcomm0")),
+ state(BaseCommunicationStarter::TimedOut)
+{
+}
+
+BaseCommunicationStarter::BaseCommunicationStarter(const TrkDevicePtr &trkDevice, QObject *parent) :
+ QObject(parent),
+ d(new BaseCommunicationStarterPrivate(trkDevice))
+{
+}
+
+BaseCommunicationStarter::~BaseCommunicationStarter()
+{
+ stopTimer();
+ delete d;
+}
+
+void BaseCommunicationStarter::stopTimer()
+{
+ if (d->timer && d->timer->isActive())
+ d->timer->stop();
+}
+
+bool BaseCommunicationStarter::initializeStartupResources(QString *errorMessage)
+{
+ errorMessage->clear();
+ return true;
+}
+
+BaseCommunicationStarter::StartResult BaseCommunicationStarter::start()
+{
+ if (state() == Running) {
+ d->errorString = QLatin1String("Internal error, attempt to re-start BaseCommunicationStarter.\n");
+ return StartError;
+ }
+ // Before we instantiate timers, and such, try to open the device,
+ // which should succeed if another listener is already running in
+ // 'Watch' mode
+ if (d->trkDevice->open(d->device , &(d->errorString)))
+ return ConnectionSucceeded;
+ // Pull up resources for next attempt
+ d->n = 0;
+ if (!initializeStartupResources(&(d->errorString)))
+ return StartError;
+ // Start timer
+ if (!d->timer) {
+ d->timer = new QTimer;
+ connect(d->timer, SIGNAL(timeout()), this, SLOT(slotTimer()));
+ }
+ d->timer->setInterval(d->intervalMS);
+ d->timer->setSingleShot(false);
+ d->timer->start();
+ d->state = Running;
+ return Started;
+}
+
+BaseCommunicationStarter::State BaseCommunicationStarter::state() const
+{
+ return d->state;
+}
+
+int BaseCommunicationStarter::intervalMS() const
+{
+ return d->intervalMS;
+}
+
+void BaseCommunicationStarter::setIntervalMS(int i)
+{
+ d->intervalMS = i;
+ if (d->timer)
+ d->timer->setInterval(i);
+}
+
+int BaseCommunicationStarter::attempts() const
+{
+ return d->attempts;
+}
+
+void BaseCommunicationStarter::setAttempts(int a)
+{
+ d->attempts = a;
+}
+
+QString BaseCommunicationStarter::device() const
+{
+ return d->device;
+}
+
+void BaseCommunicationStarter::setDevice(const QString &dv)
+{
+ d->device = dv;
+}
+
+QString BaseCommunicationStarter::errorString() const
+{
+ return d->errorString;
+}
+
+void BaseCommunicationStarter::slotTimer()
+{
+ ++d->n;
+ // Check for timeout
+ if (d->attempts >= 0 && d->n >= d->attempts) {
+ stopTimer();
+ d->errorString = tr("%1: timed out after %n attempts using an interval of %2ms.", 0, d->n)
+ .arg(d->device).arg(d->intervalMS);
+ d->state = TimedOut;
+ emit timeout();
+ } else {
+ // Attempt n to connect?
+ if (d->trkDevice->open(d->device , &(d->errorString))) {
+ stopTimer();
+ const QString msg = tr("%1: Connection attempt %2 succeeded.").arg(d->device).arg(d->n);
+ emit message(msg);
+ d->state = Connected;
+ emit connected();
+ } else {
+ const QString msg = tr("%1: Connection attempt %2 failed: %3 (retrying)...")
+ .arg(d->device).arg(d->n).arg(d->errorString);
+ emit message(msg);
+ }
+ }
+}
+
+// --------------- AbstractBluetoothStarter
+
+AbstractBluetoothStarter::AbstractBluetoothStarter(const TrkDevicePtr &trkDevice, QObject *parent) :
+ BaseCommunicationStarter(trkDevice, parent)
+{
+}
+
+bool AbstractBluetoothStarter::initializeStartupResources(QString *errorMessage)
+{
+ // Create the listener and forward messages to it.
+ BluetoothListener *listener = createListener();
+ connect(this, SIGNAL(message(QString)), listener, SLOT(emitMessage(QString)));
+ return listener->start(device(), errorMessage);
+}
+
+// -------- ConsoleBluetoothStarter
+ConsoleBluetoothStarter::ConsoleBluetoothStarter(const TrkDevicePtr &trkDevice,
+ QObject *listenerParent,
+ QObject *parent) :
+AbstractBluetoothStarter(trkDevice, parent),
+m_listenerParent(listenerParent)
+{
+}
+
+BluetoothListener *ConsoleBluetoothStarter::createListener()
+{
+ BluetoothListener *rc = new BluetoothListener(m_listenerParent);
+ rc->setMode(BluetoothListener::Listen);
+ rc->setPrintConsoleMessages(true);
+ return rc;
+}
+
+bool ConsoleBluetoothStarter::startBluetooth(const TrkDevicePtr &trkDevice,
+ QObject *listenerParent,
+ const QString &device,
+ int attempts,
+ QString *errorMessage)
+{
+ // Set up a console starter to print to stdout.
+ ConsoleBluetoothStarter starter(trkDevice, listenerParent);
+ starter.setDevice(device);
+ starter.setAttempts(attempts);
+ switch (starter.start()) {
+ case Started:
+ break;
+ case ConnectionSucceeded:
+ return true;
+ case StartError:
+ *errorMessage = starter.errorString();
+ return false;
+ }
+ // Run the starter with an event loop. @ToDo: Implement
+ // some asynchronous keypress read to cancel.
+ QEventLoop eventLoop;
+ connect(&starter, SIGNAL(connected()), &eventLoop, SLOT(quit()));
+ connect(&starter, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
+ eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
+ if (starter.state() != AbstractBluetoothStarter::Connected) {
+ *errorMessage = starter.errorString();
+ return false;
+ }
+ return true;
+}
+} // namespace trk
diff --git a/tools/runonphone/trk/communicationstarter.h b/tools/runonphone/trk/communicationstarter.h
new file mode 100644
index 0000000000..08defdea47
--- /dev/null
+++ b/tools/runonphone/trk/communicationstarter.h
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COMMUNICATIONSTARTER_H
+#define COMMUNICATIONSTARTER_H
+
+#include <QtCore/QSharedPointer>
+#include <QtCore/QObject>
+
+namespace trk {
+class TrkDevice;
+class BluetoothListener;
+struct BaseCommunicationStarterPrivate;
+
+/* BaseCommunicationStarter: A QObject that repeatedly tries to open a
+ * trk device until a connection succeeds or a timeout occurs (emitting
+ * signals), allowing to do something else in the foreground (local event loop
+ * [say QMessageBox] or some asynchronous operation). If the initial
+ * connection attempt in start() fails, the
+ * virtual initializeStartupResources() is called to initialize resources
+ * required to pull up the communication (namely Bluetooth listeners).
+ * The base class can be used as is to prompt the user to launch App TRK for a
+ * serial communication as this requires no further resource setup. */
+
+class BaseCommunicationStarter : public QObject {
+ Q_OBJECT
+ Q_DISABLE_COPY(BaseCommunicationStarter)
+public:
+ typedef QSharedPointer<TrkDevice> TrkDevicePtr;
+
+ enum State { Running, Connected, TimedOut };
+
+ explicit BaseCommunicationStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0);
+ virtual ~BaseCommunicationStarter();
+
+ int intervalMS() const;
+ void setIntervalMS(int i);
+
+ int attempts() const;
+ void setAttempts(int a);
+
+ QString device() const;
+ void setDevice(const QString &);
+
+ State state() const;
+ QString errorString() const;
+
+ enum StartResult {
+ Started, // Starter is now running.
+ ConnectionSucceeded, /* Initial connection attempt succeeded,
+ * no need to keep running. */
+ StartError // Error occurred during start.
+ };
+
+ StartResult start();
+
+signals:
+ void connected();
+ void timeout();
+ void message(const QString &);
+
+private slots:
+ void slotTimer();
+
+protected:
+ virtual bool initializeStartupResources(QString *errorMessage);
+
+private:
+ inline void stopTimer();
+
+ BaseCommunicationStarterPrivate *d;
+};
+
+/* AbstractBluetoothStarter: Repeatedly tries to open a trk Bluetooth
+ * device. Note that in case a Listener is already running mode, the
+ * connection will succeed immediately.
+ * initializeStartupResources() is implemented to fire up the listener.
+ * Introduces a new virtual createListener() that derived classes must
+ * implement as a factory function that creates and sets up the
+ * listener (mode, message connection, etc). */
+
+class AbstractBluetoothStarter : public BaseCommunicationStarter {
+ Q_OBJECT
+ Q_DISABLE_COPY(AbstractBluetoothStarter)
+public:
+
+protected:
+ explicit AbstractBluetoothStarter(const TrkDevicePtr& trkDevice, QObject *parent = 0);
+
+ // Implemented to fire up the listener.
+ virtual bool initializeStartupResources(QString *errorMessage);
+ // New virtual: Overwrite to create and parametrize the listener.
+ virtual BluetoothListener *createListener() = 0;
+};
+
+/* ConsoleBluetoothStarter: Convenience class for console processes. Creates a
+ * listener in "Listen" mode with the messages redirected to standard output. */
+
+class ConsoleBluetoothStarter : public AbstractBluetoothStarter {
+ Q_OBJECT
+ Q_DISABLE_COPY(ConsoleBluetoothStarter)
+public:
+ static bool startBluetooth(const TrkDevicePtr& trkDevice,
+ QObject *listenerParent,
+ const QString &device,
+ int attempts,
+ QString *errorMessage);
+
+protected:
+ virtual BluetoothListener *createListener();
+
+private:
+ explicit ConsoleBluetoothStarter(const TrkDevicePtr& trkDevice,
+ QObject *listenerParent,
+ QObject *parent = 0);
+
+ QObject *m_listenerParent;
+};
+
+} // namespace trk
+
+#endif // COMMUNICATIONSTARTER_H
diff --git a/tools/runonphone/trk/launcher.cpp b/tools/runonphone/trk/launcher.cpp
new file mode 100644
index 0000000000..90ad60271b
--- /dev/null
+++ b/tools/runonphone/trk/launcher.cpp
@@ -0,0 +1,695 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "launcher.h"
+#include "trkutils.h"
+#include "trkdevice.h"
+#include "bluetoothlistener.h"
+
+#include <QtCore/QTimer>
+#include <QtCore/QDateTime>
+#include <QtCore/QVariant>
+#include <QtCore/QDebug>
+#include <QtCore/QQueue>
+#include <QtCore/QFile>
+#include <QtCore/QScopedPointer>
+
+namespace trk {
+
+struct LauncherPrivate {
+ struct CopyState {
+ QString sourceFileName;
+ QString destinationFileName;
+ uint copyFileHandle;
+ QScopedPointer<QByteArray> data;
+ int position;
+ };
+
+ explicit LauncherPrivate(const TrkDevicePtr &d);
+
+ TrkDevicePtr m_device;
+ QString m_trkServerName;
+ QByteArray m_trkReadBuffer;
+ Launcher::State m_state;
+
+ void logMessage(const QString &msg);
+ // Debuggee state
+ Session m_session; // global-ish data (process id, target information)
+
+ CopyState m_copyState;
+ QString m_fileName;
+ QString m_commandLineArgs;
+ QString m_installFileName;
+ int m_verbose;
+ Launcher::Actions m_startupActions;
+ bool m_closeDevice;
+};
+
+LauncherPrivate::LauncherPrivate(const TrkDevicePtr &d) :
+ m_device(d),
+ m_state(Launcher::Disconnected),
+ m_verbose(0),
+ m_closeDevice(true)
+{
+ if (m_device.isNull())
+ m_device = TrkDevicePtr(new TrkDevice);
+}
+
+Launcher::Launcher(Actions startupActions,
+ const TrkDevicePtr &dev,
+ QObject *parent) :
+ QObject(parent),
+ d(new LauncherPrivate(dev))
+{
+ d->m_startupActions = startupActions;
+ connect(d->m_device.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult)));
+ connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close()));
+}
+
+Launcher::~Launcher()
+{
+ logMessage("Shutting down.\n");
+ delete d;
+}
+
+Launcher::State Launcher::state() const
+{
+ return d->m_state;
+}
+
+void Launcher::setState(State s)
+{
+ if (s != d->m_state) {
+ d->m_state = s;
+ emit stateChanged(s);
+ }
+}
+
+void Launcher::addStartupActions(trk::Launcher::Actions startupActions)
+{
+ d->m_startupActions = Actions(d->m_startupActions | startupActions);
+}
+
+void Launcher::setTrkServerName(const QString &name)
+{
+ d->m_trkServerName = name;
+}
+
+QString Launcher::trkServerName() const
+{
+ return d->m_trkServerName;
+}
+
+TrkDevicePtr Launcher::trkDevice() const
+{
+ return d->m_device;
+}
+
+void Launcher::setFileName(const QString &name)
+{
+ d->m_fileName = name;
+}
+
+void Launcher::setCopyFileName(const QString &srcName, const QString &dstName)
+{
+ d->m_copyState.sourceFileName = srcName;
+ d->m_copyState.destinationFileName = dstName;
+}
+
+void Launcher::setInstallFileName(const QString &name)
+{
+ d->m_installFileName = name;
+}
+
+void Launcher::setCommandLineArgs(const QString &args)
+{
+ d->m_commandLineArgs = args;
+}
+
+void Launcher::setSerialFrame(bool b)
+{
+ d->m_device->setSerialFrame(b);
+}
+
+bool Launcher::serialFrame() const
+{
+ return d->m_device->serialFrame();
+}
+
+
+bool Launcher::closeDevice() const
+{
+ return d->m_closeDevice;
+}
+
+void Launcher::setCloseDevice(bool c)
+{
+ d->m_closeDevice = c;
+}
+
+bool Launcher::startServer(QString *errorMessage)
+{
+ errorMessage->clear();
+ if (d->m_verbose) {
+ const QString msg = QString::fromLatin1("Port=%1 Executable=%2 Package=%3 Remote Package=%4 Install file=%5")
+ .arg(d->m_trkServerName, d->m_fileName, d->m_copyState.sourceFileName, d->m_copyState.destinationFileName, d->m_installFileName);
+ logMessage(msg);
+ }
+ if (d->m_startupActions & ActionCopy) {
+ if (d->m_copyState.sourceFileName.isEmpty()) {
+ qWarning("No local filename given for copying package.");
+ return false;
+ } else if (d->m_copyState.destinationFileName.isEmpty()) {
+ qWarning("No remote filename given for copying package.");
+ return false;
+ }
+ }
+ if (d->m_startupActions & ActionInstall && d->m_installFileName.isEmpty()) {
+ qWarning("No package name given for installing.");
+ return false;
+ }
+ if (d->m_startupActions & ActionRun && d->m_fileName.isEmpty()) {
+ qWarning("No remote executable given for running.");
+ return false;
+ }
+ if (!d->m_device->isOpen() && !d->m_device->open(d->m_trkServerName, errorMessage))
+ return false;
+ if (d->m_closeDevice) {
+ connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close()));
+ } else {
+ disconnect(this, SIGNAL(finished()), d->m_device.data(), 0);
+ }
+ setState(Connecting);
+ // Set up the temporary 'waiting' state if we do not get immediate connection
+ QTimer::singleShot(1000, this, SLOT(slotWaitingForTrk()));
+ d->m_device->sendTrkInitialPing();
+ d->m_device->sendTrkMessage(TrkDisconnect); // Disconnect, as trk might be still connected
+ d->m_device->sendTrkMessage(TrkSupported, TrkCallback(this, &Launcher::handleSupportMask));
+ d->m_device->sendTrkMessage(TrkCpuType, TrkCallback(this, &Launcher::handleCpuType));
+ d->m_device->sendTrkMessage(TrkVersions, TrkCallback(this, &Launcher::handleTrkVersion));
+ if (d->m_startupActions != ActionPingOnly)
+ d->m_device->sendTrkMessage(TrkConnect, TrkCallback(this, &Launcher::handleConnect));
+ return true;
+}
+
+void Launcher::slotWaitingForTrk()
+{
+ // Set temporary state if we are still in connected state
+ if (state() == Connecting)
+ setState(WaitingForTrk);
+}
+
+void Launcher::handleConnect(const TrkResult &result)
+{
+ if (result.errorCode()) {
+ emit canNotConnect(result.errorString());
+ return;
+ }
+ setState(Connected);
+ if (d->m_startupActions & ActionCopy)
+ copyFileToRemote();
+ else if (d->m_startupActions & ActionInstall)
+ installRemotePackageSilently();
+ else if (d->m_startupActions & ActionRun)
+ startInferiorIfNeeded();
+}
+
+void Launcher::setVerbose(int v)
+{
+ d->m_verbose = v;
+ d->m_device->setVerbose(v);
+}
+
+void Launcher::logMessage(const QString &msg)
+{
+ if (d->m_verbose)
+ qDebug() << "LAUNCHER: " << qPrintable(msg);
+}
+
+void Launcher::terminate()
+{
+ switch (state()) {
+ case DeviceDescriptionReceived:
+ case Connected:
+ if (d->m_session.pid) {
+ QByteArray ba;
+ appendShort(&ba, 0x0000, TargetByteOrder);
+ appendInt(&ba, d->m_session.pid, TargetByteOrder);
+ d->m_device->sendTrkMessage(TrkDeleteItem, TrkCallback(this, &Launcher::handleRemoteProcessKilled), ba);
+ return;
+ }
+ if (d->m_copyState.copyFileHandle)
+ closeRemoteFile(true);
+ disconnectTrk();
+ break;
+ case Disconnected:
+ break;
+ case Connecting:
+ case WaitingForTrk:
+ setState(Disconnected);
+ emit finished();
+ break;
+ }
+}
+
+void Launcher::handleRemoteProcessKilled(const TrkResult &result)
+{
+ Q_UNUSED(result)
+ disconnectTrk();
+}
+
+void Launcher::handleResult(const TrkResult &result)
+{
+ QByteArray prefix = "READ BUF: ";
+ QByteArray str = result.toString().toUtf8();
+ if (result.isDebugOutput) { // handle application output
+ logMessage("APPLICATION OUTPUT: " + result.data);
+ emit applicationOutputReceived(result.data);
+ return;
+ }
+ switch (result.code) {
+ case TrkNotifyAck:
+ break;
+ case TrkNotifyNak: { // NAK
+ logMessage(prefix + "NAK: " + str);
+ //logMessage(prefix << "TOKEN: " << result.token);
+ logMessage(prefix + "ERROR: " + errorMessage(result.data.at(0)));
+ break;
+ }
+ case TrkNotifyStopped: { // Notified Stopped
+ logMessage(prefix + "NOTE: STOPPED " + str);
+ // 90 01 78 6a 40 40 00 00 07 23 00 00 07 24 00 00
+ //const char *data = result.data.data();
+// uint addr = extractInt(data); //code address: 4 bytes; code base address for the library
+// uint pid = extractInt(data + 4); // ProcessID: 4 bytes;
+// uint tid = extractInt(data + 8); // ThreadID: 4 bytes
+ //logMessage(prefix << " ADDR: " << addr << " PID: " << pid << " TID: " << tid);
+ d->m_device->sendTrkAck(result.token);
+ break;
+ }
+ case TrkNotifyException: { // Notify Exception (obsolete)
+ logMessage(prefix + "NOTE: EXCEPTION " + str);
+ d->m_device->sendTrkAck(result.token);
+ break;
+ }
+ case TrkNotifyInternalError: { //
+ logMessage(prefix + "NOTE: INTERNAL ERROR: " + str);
+ d->m_device->sendTrkAck(result.token);
+ break;
+ }
+
+ // target->host OS notification
+ case TrkNotifyCreated: { // Notify Created
+ /*
+ const char *data = result.data.data();
+ byte error = result.data.at(0);
+ byte type = result.data.at(1); // type: 1 byte; for dll item, this value is 2.
+ uint pid = extractInt(data + 2); // ProcessID: 4 bytes;
+ uint tid = extractInt(data + 6); //threadID: 4 bytes
+ uint codeseg = extractInt(data + 10); //code address: 4 bytes; code base address for the library
+ uint dataseg = extractInt(data + 14); //data address: 4 bytes; data base address for the library
+ uint len = extractShort(data + 18); //length: 2 bytes; length of the library name string to follow
+ QByteArray name = result.data.mid(20, len); // name: library name
+
+ logMessage(prefix + "NOTE: LIBRARY LOAD: " + str);
+ logMessage(prefix + "TOKEN: " + result.token);
+ logMessage(prefix + "ERROR: " + int(error));
+ logMessage(prefix + "TYPE: " + int(type));
+ logMessage(prefix + "PID: " + pid);
+ logMessage(prefix + "TID: " + tid);
+ logMessage(prefix + "CODE: " + codeseg);
+ logMessage(prefix + "DATA: " + dataseg);
+ logMessage(prefix + "LEN: " + len);
+ logMessage(prefix + "NAME: " + name);
+ */
+
+ if (result.data.size() < 10)
+ break;
+ QByteArray ba;
+ ba.append(result.data.mid(2, 8));
+ d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE");
+ //d->m_device->sendTrkAck(result.token)
+ break;
+ }
+ case TrkNotifyDeleted: { // NotifyDeleted
+ const ushort itemType = (unsigned char)result.data.at(1);
+ const ushort len = result.data.size() > 12 ? extractShort(result.data.data() + 10) : ushort(0);
+ const QString name = len ? QString::fromAscii(result.data.mid(12, len)) : QString();
+ logMessage(QString::fromLatin1("%1 %2 UNLOAD: %3").
+ arg(QString::fromAscii(prefix)).arg(itemType ? QLatin1String("LIB") : QLatin1String("PROCESS")).
+ arg(name));
+ d->m_device->sendTrkAck(result.token);
+ if (itemType == 0 // process
+ && result.data.size() >= 10
+ && d->m_session.pid == extractInt(result.data.data() + 6)) {
+ disconnectTrk();
+ }
+ break;
+ }
+ case TrkNotifyProcessorStarted: { // NotifyProcessorStarted
+ logMessage(prefix + "NOTE: PROCESSOR STARTED: " + str);
+ d->m_device->sendTrkAck(result.token);
+ break;
+ }
+ case TrkNotifyProcessorStandBy: { // NotifyProcessorStandby
+ logMessage(prefix + "NOTE: PROCESSOR STANDBY: " + str);
+ d->m_device->sendTrkAck(result.token);
+ break;
+ }
+ case TrkNotifyProcessorReset: { // NotifyProcessorReset
+ logMessage(prefix + "NOTE: PROCESSOR RESET: " + str);
+ d->m_device->sendTrkAck(result.token);
+ break;
+ }
+ default: {
+ logMessage(prefix + "INVALID: " + str);
+ break;
+ }
+ }
+}
+
+QString Launcher::deviceDescription(unsigned verbose) const
+{
+ return d->m_session.deviceDescription(verbose);
+}
+
+void Launcher::handleTrkVersion(const TrkResult &result)
+{
+ if (result.errorCode() || result.data.size() < 5) {
+ if (d->m_startupActions == ActionPingOnly) {
+ setState(Disconnected);
+ emit finished();
+ }
+ return;
+ }
+ d->m_session.trkAppVersion.trkMajor = result.data.at(1);
+ d->m_session.trkAppVersion.trkMinor = result.data.at(2);
+ d->m_session.trkAppVersion.protocolMajor = result.data.at(3);
+ d->m_session.trkAppVersion.protocolMinor = result.data.at(4);
+ setState(DeviceDescriptionReceived);
+ // Ping mode: Log & Terminate
+ if (d->m_startupActions == ActionPingOnly) {
+ qWarning("%s", qPrintable(deviceDescription()));
+ setState(Disconnected);
+ emit finished();
+ }
+}
+
+void Launcher::handleFileCreation(const TrkResult &result)
+{
+ if (result.errorCode() || result.data.size() < 6) {
+ emit canNotCreateFile(d->m_copyState.destinationFileName, result.errorString());
+ disconnectTrk();
+ return;
+ }
+ const char *data = result.data.data();
+ d->m_copyState.copyFileHandle = extractInt(data + 2);
+ QFile file(d->m_copyState.sourceFileName);
+ file.open(QIODevice::ReadOnly);
+ d->m_copyState.data.reset(new QByteArray(file.readAll()));
+ d->m_copyState.position = 0;
+ file.close();
+ continueCopying();
+}
+
+void Launcher::handleCopy(const TrkResult &result)
+{
+ if (result.errorCode() || result.data.size() < 4) {
+ closeRemoteFile(true);
+ emit canNotWriteFile(d->m_copyState.destinationFileName, result.errorString());
+ disconnectTrk();
+ } else {
+ continueCopying(extractShort(result.data.data() + 2));
+ }
+}
+
+void Launcher::continueCopying(uint lastCopiedBlockSize)
+{
+ int size = d->m_copyState.data->length();
+ d->m_copyState.position += lastCopiedBlockSize;
+ if (size == 0)
+ emit copyProgress(100);
+ else {
+ int percent = qMin((d->m_copyState.position*100)/size, 100);
+ emit copyProgress(percent);
+ }
+ if (d->m_copyState.position < size) {
+ QByteArray ba;
+ appendInt(&ba, d->m_copyState.copyFileHandle, TargetByteOrder);
+ appendString(&ba, d->m_copyState.data->mid(d->m_copyState.position, 2048), TargetByteOrder, false);
+ d->m_device->sendTrkMessage(TrkWriteFile, TrkCallback(this, &Launcher::handleCopy), ba);
+ } else {
+ closeRemoteFile();
+ }
+}
+
+void Launcher::closeRemoteFile(bool failed)
+{
+ QByteArray ba;
+ appendInt(&ba, d->m_copyState.copyFileHandle, TargetByteOrder);
+ appendDateTime(&ba, QDateTime::currentDateTime(), TargetByteOrder);
+ d->m_device->sendTrkMessage(TrkCloseFile,
+ failed ? TrkCallback() : TrkCallback(this, &Launcher::handleFileCopied),
+ ba);
+ d->m_copyState.data.reset();
+ d->m_copyState.copyFileHandle = 0;
+ d->m_copyState.position = 0;
+}
+
+void Launcher::handleFileCopied(const TrkResult &result)
+{
+ if (result.errorCode())
+ emit canNotCloseFile(d->m_copyState.destinationFileName, result.errorString());
+ if (d->m_startupActions & ActionInstall)
+ installRemotePackageSilently();
+ else if (d->m_startupActions & ActionRun)
+ startInferiorIfNeeded();
+ else
+ disconnectTrk();
+}
+
+void Launcher::handleCpuType(const TrkResult &result)
+{
+ logMessage("HANDLE CPU TYPE: " + result.toString());
+ if(result.errorCode() || result.data.size() < 7)
+ return;
+ //---TRK------------------------------------------------------
+ // Command: 0x80 Acknowledge
+ // Error: 0x00
+ // [80 03 00 04 00 00 04 00 00 00]
+ d->m_session.cpuMajor = result.data.at(1);
+ d->m_session.cpuMinor = result.data.at(2);
+ d->m_session.bigEndian = result.data.at(3);
+ d->m_session.defaultTypeSize = result.data.at(4);
+ d->m_session.fpTypeSize = result.data.at(5);
+ d->m_session.extended1TypeSize = result.data.at(6);
+ //d->m_session.extended2TypeSize = result.data[6];
+}
+
+void Launcher::handleCreateProcess(const TrkResult &result)
+{
+ if (result.errorCode()) {
+ emit canNotRun(result.errorString());
+ disconnectTrk();
+ return;
+ }
+ // 40 00 00]
+ //logMessage(" RESULT: " + result.toString());
+ // [80 08 00 00 00 01 B5 00 00 01 B6 78 67 40 00 00 40 00 00]
+ const char *data = result.data.data();
+ d->m_session.pid = extractInt(data + 1);
+ d->m_session.tid = extractInt(data + 5);
+ d->m_session.codeseg = extractInt(data + 9);
+ d->m_session.dataseg = extractInt(data + 13);
+ if (d->m_verbose) {
+ const QString msg = QString::fromLatin1("Process id: %1 Thread id: %2 code: 0x%3 data: 0x%4").
+ arg(d->m_session.pid).arg(d->m_session.tid).arg(d->m_session.codeseg, 0, 16).
+ arg(d->m_session.dataseg, 0 ,16);
+ logMessage(msg);
+ }
+ emit applicationRunning(d->m_session.pid);
+ QByteArray ba;
+ appendInt(&ba, d->m_session.pid);
+ appendInt(&ba, d->m_session.tid);
+ d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE");
+}
+
+void Launcher::handleWaitForFinished(const TrkResult &result)
+{
+ logMessage(" FINISHED: " + stringFromArray(result.data));
+ setState(Disconnected);
+ emit finished();
+}
+
+void Launcher::handleSupportMask(const TrkResult &result)
+{
+ if (result.errorCode() || result.data.size() < 32)
+ return;
+ const char *data = result.data.data() + 1;
+
+ QByteArray str;
+ for (int i = 0; i < 32; ++i) {
+ //str.append(" [" + formatByte(data[i]) + "]: ");
+ for (int j = 0; j < 8; ++j)
+ if (data[i] & (1 << j))
+ str.append(QByteArray::number(i * 8 + j, 16) + " ");
+ }
+ logMessage("SUPPORTED: " + str);
+}
+
+
+void Launcher::cleanUp()
+{
+ //
+ //---IDE------------------------------------------------------
+ // Command: 0x41 Delete Item
+ // Sub Cmd: Delete Process
+ //ProcessID: 0x0000071F (1823)
+ // [41 24 00 00 00 00 07 1F]
+ QByteArray ba;
+ appendByte(&ba, 0x00);
+ appendByte(&ba, 0x00);
+ appendInt(&ba, d->m_session.pid);
+ d->m_device->sendTrkMessage(TrkDeleteItem, TrkCallback(), ba, "Delete process");
+
+ //---TRK------------------------------------------------------
+ // Command: 0x80 Acknowledge
+ // Error: 0x00
+ // [80 24 00]
+
+ //---IDE------------------------------------------------------
+ // Command: 0x1C Clear Break
+ // [1C 25 00 00 00 0A 78 6A 43 40]
+
+ //---TRK------------------------------------------------------
+ // Command: 0xA1 Notify Deleted
+ // [A1 09 00 00 00 00 00 00 00 00 07 1F]
+ //---IDE------------------------------------------------------
+ // Command: 0x80 Acknowledge
+ // Error: 0x00
+ // [80 09 00]
+
+ //---TRK------------------------------------------------------
+ // Command: 0x80 Acknowledge
+ // Error: 0x00
+ // [80 25 00]
+
+ //---IDE------------------------------------------------------
+ // Command: 0x1C Clear Break
+ // [1C 26 00 00 00 0B 78 6A 43 70]
+ //---TRK------------------------------------------------------
+ // Command: 0x80 Acknowledge
+ // Error: 0x00
+ // [80 26 00]
+
+
+ //---IDE------------------------------------------------------
+ // Command: 0x02 Disconnect
+ // [02 27]
+// sendTrkMessage(0x02, TrkCallback(this, &Launcher::handleDisconnect));
+ //---TRK------------------------------------------------------
+ // Command: 0x80 Acknowledge
+ // Error: 0x00
+}
+
+void Launcher::disconnectTrk()
+{
+ d->m_device->sendTrkMessage(TrkDisconnect, TrkCallback(this, &Launcher::handleWaitForFinished));
+}
+
+void Launcher::copyFileToRemote()
+{
+ emit copyingStarted();
+ QByteArray ba;
+ appendByte(&ba, 0x10);
+ appendString(&ba, d->m_copyState.destinationFileName.toLocal8Bit(), TargetByteOrder, false);
+ d->m_device->sendTrkMessage(TrkOpenFile, TrkCallback(this, &Launcher::handleFileCreation), ba);
+}
+
+void Launcher::installRemotePackageSilently()
+{
+ emit installingStarted();
+ QByteArray ba;
+ appendByte(&ba, 'C');
+ appendString(&ba, d->m_installFileName.toLocal8Bit(), TargetByteOrder, false);
+ d->m_device->sendTrkMessage(TrkInstallFile, TrkCallback(this, &Launcher::handleInstallPackageFinished), ba);
+}
+
+void Launcher::handleInstallPackageFinished(const TrkResult &result)
+{
+ if (result.errorCode()) {
+ emit canNotInstall(d->m_installFileName, result.errorString());
+ disconnectTrk();
+ return;
+ } else {
+ emit installingFinished();
+ }
+ if (d->m_startupActions & ActionRun) {
+ startInferiorIfNeeded();
+ } else {
+ disconnectTrk();
+ }
+}
+
+void Launcher::startInferiorIfNeeded()
+{
+ emit startingApplication();
+ if (d->m_session.pid != 0) {
+ logMessage("Process already 'started'");
+ return;
+ }
+ // It's not started yet
+ QByteArray ba;
+ appendShort(&ba, 0, TargetByteOrder); // create new process
+ appendByte(&ba, 0); // options - currently unused
+
+ if(d->m_commandLineArgs.isEmpty()) {
+ appendString(&ba, d->m_fileName.toLocal8Bit(), TargetByteOrder);
+ } else {
+ QByteArray ba2;
+ ba2.append(d->m_fileName.toLocal8Bit());
+ ba2.append('\0');
+ ba2.append(d->m_commandLineArgs.toLocal8Bit());
+ appendString(&ba, ba2, TargetByteOrder);
+ }
+ d->m_device->sendTrkMessage(TrkCreateItem, TrkCallback(this, &Launcher::handleCreateProcess), ba); // Create Item
+}
+} // namespace trk
diff --git a/tools/runonphone/trk/launcher.h b/tools/runonphone/trk/launcher.h
new file mode 100644
index 0000000000..29ee967d6b
--- /dev/null
+++ b/tools/runonphone/trk/launcher.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LAUNCHER_H
+#define LAUNCHER_H
+
+#include "trkdevice.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QVariant>
+#include <QtCore/QSharedPointer>
+
+namespace trk {
+
+struct TrkResult;
+struct TrkMessage;
+struct LauncherPrivate;
+
+typedef QSharedPointer<TrkDevice> TrkDevicePtr;
+
+class Launcher : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(Launcher)
+public:
+ typedef void (Launcher::*TrkCallBack)(const TrkResult &);
+
+ enum Actions {
+ ActionPingOnly = 0x0,
+ ActionCopy = 0x1,
+ ActionInstall = 0x2,
+ ActionCopyInstall = ActionCopy | ActionInstall,
+ ActionRun = 0x4,
+ ActionCopyRun = ActionCopy | ActionRun,
+ ActionInstallRun = ActionInstall | ActionRun,
+ ActionCopyInstallRun = ActionCopy | ActionInstall | ActionRun
+ };
+
+ enum State { Disconnected, Connecting, Connected,
+ WaitingForTrk, // This occurs only if the initial ping times out after
+ // a reasonable timeout, indicating that Trk is not
+ // running. Note that this will never happen with
+ // Bluetooth as communication immediately starts
+ // after connecting.
+ DeviceDescriptionReceived };
+
+ explicit Launcher(trk::Launcher::Actions startupActions = trk::Launcher::ActionPingOnly,
+ const TrkDevicePtr &trkDevice = TrkDevicePtr(),
+ QObject *parent = 0);
+ ~Launcher();
+
+ State state() const;
+
+ void addStartupActions(trk::Launcher::Actions startupActions);
+ void setTrkServerName(const QString &name);
+ QString trkServerName() const;
+ void setFileName(const QString &name);
+ void setCopyFileName(const QString &srcName, const QString &dstName);
+ void setInstallFileName(const QString &name);
+ void setCommandLineArgs(const QString &args);
+ bool startServer(QString *errorMessage);
+ void setVerbose(int v);
+ void setSerialFrame(bool b);
+ bool serialFrame() const;
+ // Close device or leave it open
+ bool closeDevice() const;
+ void setCloseDevice(bool c);
+
+ TrkDevicePtr trkDevice() const;
+
+ // becomes valid after successful execution of ActionPingOnly
+ QString deviceDescription(unsigned verbose = 0u) const;
+
+signals:
+ void copyingStarted();
+ void canNotConnect(const QString &errorMessage);
+ void canNotCreateFile(const QString &filename, const QString &errorMessage);
+ void canNotWriteFile(const QString &filename, const QString &errorMessage);
+ void canNotCloseFile(const QString &filename, const QString &errorMessage);
+ void installingStarted();
+ void canNotInstall(const QString &packageFilename, const QString &errorMessage);
+ void installingFinished();
+ void startingApplication();
+ void applicationRunning(uint pid);
+ void canNotRun(const QString &errorMessage);
+ void finished();
+ void applicationOutputReceived(const QString &output);
+ void copyProgress(int percent);
+ void stateChanged(int);
+
+public slots:
+ void terminate();
+
+private slots:
+ void handleResult(const trk::TrkResult &data);
+ void slotWaitingForTrk();
+
+private:
+ // kill process and breakpoints
+ void cleanUp();
+ void disconnectTrk();
+
+ void handleRemoteProcessKilled(const TrkResult &result);
+ void handleConnect(const TrkResult &result);
+ void handleFileCreation(const TrkResult &result);
+ void handleCopy(const TrkResult &result);
+ void continueCopying(uint lastCopiedBlockSize = 0);
+ void closeRemoteFile(bool failed = false);
+ void handleFileCopied(const TrkResult &result);
+ void handleInstallPackageFinished(const TrkResult &result);
+ void handleCpuType(const TrkResult &result);
+ void handleCreateProcess(const TrkResult &result);
+ void handleWaitForFinished(const TrkResult &result);
+ void handleStop(const TrkResult &result);
+ void handleSupportMask(const TrkResult &result);
+ void handleTrkVersion(const TrkResult &result);
+
+ void copyFileToRemote();
+ void installRemotePackageSilently();
+ void startInferiorIfNeeded();
+
+ void logMessage(const QString &msg);
+ void setState(State s);
+
+ LauncherPrivate *d;
+};
+
+} // namespace Trk
+
+#endif // LAUNCHER_H
diff --git a/tools/runonphone/trk/trk.pri b/tools/runonphone/trk/trk.pri
new file mode 100644
index 0000000000..2ce17c0a6c
--- /dev/null
+++ b/tools/runonphone/trk/trk.pri
@@ -0,0 +1,23 @@
+INCLUDEPATH *= $$PWD
+
+# Input
+HEADERS += $$PWD/callback.h \
+ $$PWD/trkutils.h \
+ $$PWD/trkdevice.h \
+ $$PWD/launcher.h \
+ $$PWD/bluetoothlistener.h \
+ $$PWD/communicationstarter.h
+
+SOURCES += $$PWD/trkutils.cpp \
+ $$PWD/trkdevice.cpp \
+ $$PWD/launcher.cpp \
+ $$PWD/bluetoothlistener.cpp \
+ $$PWD/communicationstarter.cpp
+
+# Tests/trklauncher is a console application
+contains(QT, gui) {
+ HEADERS += $$PWD/bluetoothlistener_gui.h
+ SOURCES += $$PWD/bluetoothlistener_gui.cpp
+} else {
+ message(Trk: Console ...)
+}
diff --git a/tools/runonphone/trk/trkdevice.cpp b/tools/runonphone/trk/trkdevice.cpp
new file mode 100644
index 0000000000..d31fff108c
--- /dev/null
+++ b/tools/runonphone/trk/trkdevice.cpp
@@ -0,0 +1,1073 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "trkdevice.h"
+#include "trkutils.h"
+
+#include <QtCore/QString>
+#include <QtCore/QDebug>
+#include <QtCore/QQueue>
+#include <QtCore/QHash>
+#include <QtCore/QMap>
+#include <QtCore/QThread>
+#include <QtCore/QMutex>
+#include <QtCore/QWaitCondition>
+#include <QtCore/QSharedPointer>
+#include <QtCore/QMetaType>
+
+#ifdef Q_OS_WIN
+# include <windows.h>
+#else
+# include <QtCore/QFile>
+
+# include <stdio.h>
+# include <sys/ioctl.h>
+# include <sys/types.h>
+# include <termios.h>
+# include <errno.h>
+# include <string.h>
+# include <unistd.h>
+/* Required headers for select() according to POSIX.1-2001 */
+# include <sys/select.h>
+/* Required headers for select() according to earlier standards:
+ #include <sys/time.h>
+ #include <sys/types.h>
+ #include <unistd.h>
+*/
+#endif
+
+#ifdef Q_OS_WIN
+
+// Format windows error from GetLastError() value:
+// TODO: Use the one provided by the utils lib.
+QString winErrorMessage(unsigned long error)
+{
+ QString rc = QString::fromLatin1("#%1: ").arg(error);
+ ushort *lpMsgBuf;
+
+ const int len = FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER
+ | FORMAT_MESSAGE_FROM_SYSTEM
+ | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
+ if (len) {
+ rc = QString::fromUtf16(lpMsgBuf, len);
+ LocalFree(lpMsgBuf);
+ } else {
+ rc += QString::fromLatin1("<unknown error>");
+ }
+ return rc;
+}
+
+#endif
+
+namespace trk {
+
+///////////////////////////////////////////////////////////////////////
+//
+// TrkMessage
+//
+///////////////////////////////////////////////////////////////////////
+
+/* A message to be send to TRK, triggering a callback on receipt
+ * of the answer. */
+struct TrkMessage
+{
+ explicit TrkMessage(byte code = 0u, byte token = 0u,
+ TrkCallback callback = TrkCallback());
+
+ byte code;
+ byte token;
+ QByteArray data;
+ QVariant cookie;
+ TrkCallback callback;
+};
+
+TrkMessage::TrkMessage(byte c, byte t, TrkCallback cb) :
+ code(c),
+ token(t),
+ callback(cb)
+{
+}
+
+} // namespace trk
+
+Q_DECLARE_METATYPE(trk::TrkMessage)
+Q_DECLARE_METATYPE(trk::TrkResult)
+
+namespace trk {
+
+///////////////////////////////////////////////////////////////////////
+//
+// TrkWriteQueue: Mixin class that manages a write queue of Trk messages.
+// pendingMessage()/notifyWriteResult() should be called from a worked/timer
+// that writes the messages. The class does not take precautions for multithreading.
+// A no-op message is simply taken off the queue. The calling class
+// can use the helper invokeNoopMessage() to trigger its callback.
+//
+///////////////////////////////////////////////////////////////////////
+
+class TrkWriteQueue
+{
+ Q_DISABLE_COPY(TrkWriteQueue)
+public:
+ explicit TrkWriteQueue();
+
+ // Enqueue messages.
+ void queueTrkMessage(byte code, TrkCallback callback,
+ const QByteArray &data, const QVariant &cookie);
+ void queueTrkInitialPing();
+
+ // Call this from the device read notification with the results.
+ void slotHandleResult(const TrkResult &result, QMutex *mutex = 0);
+
+ // pendingMessage() can be called periodically in a timer to retrieve
+ // the pending messages to be sent.
+ enum PendingMessageResult {
+ NoMessage, // No message in queue.
+ PendingMessage, /* There is a queued message. The calling class
+ * can write it out and use notifyWriteResult()
+ * to notify about the result. */
+ NoopMessageDequeued // A no-op message has been dequeued. see invokeNoopMessage().
+ };
+
+ PendingMessageResult pendingMessage(TrkMessage *message);
+ // Notify the queue about the success of the write operation
+ // after taking the pendingMessage off.
+ enum WriteResult {
+ WriteOk,
+ WriteFailedDiscard, // Discard failed message
+ WriteFailedKeep, // Keep failed message
+ };
+ void notifyWriteResult(WriteResult ok);
+
+ // Helper function that invokes the callback of a no-op message
+ static void invokeNoopMessage(trk::TrkMessage);
+
+private:
+ typedef QMap<byte, TrkMessage> TokenMessageMap;
+
+ byte nextTrkWriteToken();
+
+ byte m_trkWriteToken;
+ QQueue<TrkMessage> m_trkWriteQueue;
+ TokenMessageMap m_writtenTrkMessages;
+ bool m_trkWriteBusy;
+};
+
+TrkWriteQueue::TrkWriteQueue() :
+ m_trkWriteToken(0),
+ m_trkWriteBusy(false)
+{
+}
+
+byte TrkWriteQueue::nextTrkWriteToken()
+{
+ ++m_trkWriteToken;
+ if (m_trkWriteToken == 0)
+ ++m_trkWriteToken;
+ return m_trkWriteToken;
+}
+
+void TrkWriteQueue::queueTrkMessage(byte code, TrkCallback callback,
+ const QByteArray &data, const QVariant &cookie)
+{
+ const byte token = code == TRK_WRITE_QUEUE_NOOP_CODE ?
+ byte(0) : nextTrkWriteToken();
+ TrkMessage msg(code, token, callback);
+ msg.data = data;
+ msg.cookie = cookie;
+ m_trkWriteQueue.append(msg);
+}
+
+TrkWriteQueue::PendingMessageResult TrkWriteQueue::pendingMessage(TrkMessage *message)
+{
+ // Invoked from timer, try to flush out message queue
+ if (m_trkWriteBusy || m_trkWriteQueue.isEmpty())
+ return NoMessage;
+ // Handle the noop message, just invoke CB in slot (ower thread)
+ if (m_trkWriteQueue.front().code == TRK_WRITE_QUEUE_NOOP_CODE) {
+ *message = m_trkWriteQueue.dequeue();
+ return NoopMessageDequeued;
+ }
+ // Insert into map fir answers (as reading threads might get an
+ // answer before notifyWriteResult(true)) is called.
+ *message = m_trkWriteQueue.front();
+ m_writtenTrkMessages.insert(message->token, *message);
+ m_trkWriteBusy = true;
+ return PendingMessage;
+}
+
+void TrkWriteQueue::invokeNoopMessage(trk::TrkMessage noopMessage)
+{
+ TrkResult result;
+ result.code = noopMessage.code;
+ result.token = noopMessage.token;
+ result.data = noopMessage.data;
+ result.cookie = noopMessage.cookie;
+ noopMessage.callback(result);
+}
+
+void TrkWriteQueue::notifyWriteResult(WriteResult wr)
+{
+ // On success, dequeue message and await result
+ const byte token = m_trkWriteQueue.front().token;
+ switch (wr) {
+ case WriteOk:
+ m_trkWriteQueue.dequeue();
+ break;
+ case WriteFailedKeep:
+ case WriteFailedDiscard:
+ m_writtenTrkMessages.remove(token);
+ m_trkWriteBusy = false;
+ if (wr == WriteFailedDiscard)
+ m_trkWriteQueue.dequeue();
+ break;
+ }
+}
+
+void TrkWriteQueue::slotHandleResult(const TrkResult &result, QMutex *mutex)
+{
+ // Find which request the message belongs to and invoke callback
+ // if ACK or on NAK if desired.
+ if (mutex)
+ mutex->lock();
+ m_trkWriteBusy = false;
+ const TokenMessageMap::iterator it = m_writtenTrkMessages.find(result.token);
+ if (it == m_writtenTrkMessages.end()) {
+ if (mutex)
+ mutex->unlock();
+ return;
+ }
+ TrkCallback callback = it.value().callback;
+ const QVariant cookie = it.value().cookie;
+ m_writtenTrkMessages.erase(it);
+ if (mutex)
+ mutex->unlock();
+ // Invoke callback
+ if (callback) {
+ TrkResult result1 = result;
+ result1.cookie = cookie;
+ callback(result1);
+ }
+}
+
+void TrkWriteQueue::queueTrkInitialPing()
+{
+ // Ping, reset sequence count
+ m_trkWriteToken = 0;
+ m_trkWriteQueue.append(TrkMessage(TrkPing, 0));
+}
+
+///////////////////////////////////////////////////////////////////////
+//
+// DeviceContext to be shared between threads
+//
+///////////////////////////////////////////////////////////////////////
+
+struct DeviceContext {
+ DeviceContext();
+#ifdef Q_OS_WIN
+ HANDLE device;
+ OVERLAPPED readOverlapped;
+ OVERLAPPED writeOverlapped;
+#else
+ QFile file;
+#endif
+ bool serialFrame;
+ QMutex mutex;
+};
+
+DeviceContext::DeviceContext() :
+#ifdef Q_OS_WIN
+ device(INVALID_HANDLE_VALUE),
+#endif
+ serialFrame(true)
+{
+}
+
+///////////////////////////////////////////////////////////////////////
+//
+// TrkWriterThread: A thread operating a TrkWriteQueue.
+// with exception of the handling of the TRK_WRITE_QUEUE_NOOP_CODE
+// synchronization message. The invocation of the callback is then
+// done by the thread owning the TrkWriteQueue, while pendingMessage() is called
+// from another thread. This happens via a Qt::BlockingQueuedConnection.
+
+///////////////////////////////////////////////////////////////////////
+
+class WriterThread : public QThread {
+ Q_OBJECT
+ Q_DISABLE_COPY(WriterThread)
+public:
+ explicit WriterThread(const QSharedPointer<DeviceContext> &context);
+
+ // Enqueue messages.
+ void queueTrkMessage(byte code, TrkCallback callback,
+ const QByteArray &data, const QVariant &cookie);
+ void queueTrkInitialPing();
+
+ // Call this from the device read notification with the results.
+ void slotHandleResult(const TrkResult &result);
+
+ virtual void run();
+
+signals:
+ void error(const QString &);
+ void internalNoopMessageDequeued(const trk::TrkMessage&);
+
+public slots:
+ bool trkWriteRawMessage(const TrkMessage &msg);
+ void terminate();
+ void tryWrite();
+
+private slots:
+ void invokeNoopMessage(const trk::TrkMessage &);
+
+private:
+ bool write(const QByteArray &data, QString *errorMessage);
+ inline int writePendingMessage();
+
+ const QSharedPointer<DeviceContext> m_context;
+ QMutex m_dataMutex;
+ QMutex m_waitMutex;
+ QWaitCondition m_waitCondition;
+ TrkWriteQueue m_queue;
+ bool m_terminate;
+};
+
+WriterThread::WriterThread(const QSharedPointer<DeviceContext> &context) :
+ m_context(context),
+ m_terminate(false)
+{
+ static const int trkMessageMetaId = qRegisterMetaType<trk::TrkMessage>();
+ Q_UNUSED(trkMessageMetaId)
+ connect(this, SIGNAL(internalNoopMessageDequeued(trk::TrkMessage)),
+ this, SLOT(invokeNoopMessage(trk::TrkMessage)), Qt::BlockingQueuedConnection);
+}
+
+void WriterThread::run()
+{
+ while (writePendingMessage() == 0) ;
+}
+
+int WriterThread::writePendingMessage()
+{
+ enum { MaxAttempts = 100, RetryIntervalMS = 200 };
+
+ // Wait. Use a timeout in case something is already queued before we
+ // start up or some weird hanging exit condition
+ m_waitMutex.lock();
+ m_waitCondition.wait(&m_waitMutex, 100);
+ m_waitMutex.unlock();
+ if (m_terminate)
+ return 1;
+ // Send off message
+ m_dataMutex.lock();
+ TrkMessage message;
+ const TrkWriteQueue::PendingMessageResult pr = m_queue.pendingMessage(&message);
+ m_dataMutex.unlock();
+ switch (pr) {
+ case TrkWriteQueue::NoMessage:
+ break;
+ case TrkWriteQueue::PendingMessage: {
+ // Untested: try to re-send a few times
+ bool success = false;
+ for (int r = 0; !success && (r < MaxAttempts); r++) {
+ success = trkWriteRawMessage(message);
+ if (!success) {
+ emit error(QString::fromLatin1("Write failure, attempt %1 of %2.").arg(r).arg(int(MaxAttempts)));
+ if (m_terminate)
+ return 1;
+ QThread::msleep(RetryIntervalMS);
+ }
+ }
+ // Notify queue. If still failed, give up.
+ m_dataMutex.lock();
+ m_queue.notifyWriteResult(success ? TrkWriteQueue::WriteOk : TrkWriteQueue::WriteFailedDiscard);
+ m_dataMutex.unlock();
+ }
+ break;
+ case TrkWriteQueue::NoopMessageDequeued:
+ // Sync with thread that owns us via a blocking signal
+ emit internalNoopMessageDequeued(message);
+ break;
+ } // switch
+ return 0;
+}
+
+void WriterThread::invokeNoopMessage(const trk::TrkMessage &msg)
+{
+ TrkWriteQueue::invokeNoopMessage(msg);
+}
+
+void WriterThread::terminate()
+{
+ m_terminate = true;
+ m_waitCondition.wakeAll();
+ wait();
+ m_terminate = false;
+}
+
+#ifdef Q_OS_WIN
+
+static inline QString msgTerminated(int size)
+{
+ return QString::fromLatin1("Terminated with %1 bytes pending.").arg(size);
+}
+
+// Interruptible synchronous write function.
+static inline bool overlappedSyncWrite(HANDLE file,
+ const bool &terminateFlag,
+ const char *data,
+ DWORD size, DWORD *charsWritten,
+ OVERLAPPED *overlapped,
+ QString *errorMessage)
+{
+ if (WriteFile(file, data, size, charsWritten, overlapped))
+ return true;
+ const DWORD writeError = GetLastError();
+ if (writeError != ERROR_IO_PENDING) {
+ *errorMessage = QString::fromLatin1("WriteFile failed: %1").arg(winErrorMessage(writeError));
+ return false;
+ }
+ // Wait for written or thread terminated
+ const DWORD timeoutMS = 200;
+ const unsigned maxAttempts = 20;
+ DWORD wr = WaitForSingleObject(overlapped->hEvent, timeoutMS);
+ for (unsigned n = 0; wr == WAIT_TIMEOUT && n < maxAttempts && !terminateFlag;
+ wr = WaitForSingleObject(overlapped->hEvent, timeoutMS), n++);
+ if (terminateFlag) {
+ *errorMessage = msgTerminated(size);
+ return false;
+ }
+ switch (wr) {
+ case WAIT_OBJECT_0:
+ break;
+ case WAIT_TIMEOUT:
+ *errorMessage = QString::fromLatin1("Write timed out.");
+ return false;
+ default:
+ *errorMessage = QString::fromLatin1("Error while waiting for WriteFile results: %1").arg(winErrorMessage(GetLastError()));
+ return false;
+ }
+ if (!GetOverlappedResult(file, overlapped, charsWritten, TRUE)) {
+ *errorMessage = QString::fromLatin1("Error writing %1 bytes: %2").arg(size).arg(winErrorMessage(GetLastError()));
+ return false;
+ }
+ return true;
+}
+#endif
+
+bool WriterThread::write(const QByteArray &data, QString *errorMessage)
+{
+ QMutexLocker locker(&m_context->mutex);
+#ifdef Q_OS_WIN
+ DWORD charsWritten;
+ if (!overlappedSyncWrite(m_context->device, m_terminate, data.data(), data.size(), &charsWritten, &m_context->writeOverlapped, errorMessage)) {
+ return false;
+ }
+ FlushFileBuffers(m_context->device);
+ return true;
+#else
+ if (m_context->file.write(data) == -1 || !m_context->file.flush()) {
+ *errorMessage = QString::fromLatin1("Cannot write: %1").arg(m_context->file.errorString());
+ return false;
+ }
+ return true;
+#endif
+}
+
+bool WriterThread::trkWriteRawMessage(const TrkMessage &msg)
+{
+ const QByteArray ba = frameMessage(msg.code, msg.token, msg.data, m_context->serialFrame);
+ QString errorMessage;
+ const bool rc = write(ba, &errorMessage);
+ if (!rc) {
+ qWarning("%s\n", qPrintable(errorMessage));
+ emit error(errorMessage);
+ }
+ return rc;
+}
+
+void WriterThread::tryWrite()
+{
+ m_waitCondition.wakeAll();
+}
+
+void WriterThread::queueTrkMessage(byte code, TrkCallback callback,
+ const QByteArray &data, const QVariant &cookie)
+{
+ m_dataMutex.lock();
+ m_queue.queueTrkMessage(code, callback, data, cookie);
+ m_dataMutex.unlock();
+ tryWrite();
+}
+
+void WriterThread::queueTrkInitialPing()
+{
+ m_dataMutex.lock();
+ m_queue.queueTrkInitialPing();
+ m_dataMutex.unlock();
+ tryWrite();
+}
+
+// Call this from the device read notification with the results.
+void WriterThread::slotHandleResult(const TrkResult &result)
+{
+ m_queue.slotHandleResult(result, &m_dataMutex);
+ tryWrite(); // Have messages been enqueued in-between?
+}
+
+///////////////////////////////////////////////////////////////////////
+//
+// ReaderThreadBase: Base class for a thread that reads data from
+// the device, decodes the messages and emit signals for the messages.
+// A Qt::BlockingQueuedConnection should be used for the message signal
+// to ensure messages are processed in the correct sequence.
+//
+///////////////////////////////////////////////////////////////////////
+
+class ReaderThreadBase : public QThread {
+ Q_OBJECT
+ Q_DISABLE_COPY(ReaderThreadBase)
+public:
+
+signals:
+ void messageReceived(const trk::TrkResult &result, const QByteArray &rawData);
+
+protected:
+ explicit ReaderThreadBase(const QSharedPointer<DeviceContext> &context);
+ void processData(const QByteArray &a);
+ void processData(char c);
+
+ const QSharedPointer<DeviceContext> m_context;
+
+private:
+ void readMessages();
+
+ QByteArray m_trkReadBuffer;
+};
+
+ReaderThreadBase::ReaderThreadBase(const QSharedPointer<DeviceContext> &context) :
+ m_context(context)
+{
+ static const int trkResultMetaId = qRegisterMetaType<trk::TrkResult>();
+ Q_UNUSED(trkResultMetaId)
+}
+
+void ReaderThreadBase::processData(const QByteArray &a)
+{
+ m_trkReadBuffer += a;
+ readMessages();
+}
+
+void ReaderThreadBase::processData(char c)
+{
+ m_trkReadBuffer += c;
+ if (m_trkReadBuffer.size() > 1)
+ readMessages();
+}
+
+void ReaderThreadBase::readMessages()
+{
+ TrkResult r;
+ QByteArray rawData;
+ while (extractResult(&m_trkReadBuffer, m_context->serialFrame, &r, &rawData)) {
+ emit messageReceived(r, rawData);
+ }
+}
+
+#ifdef Q_OS_WIN
+///////////////////////////////////////////////////////////////////////
+//
+// WinReaderThread: A thread reading from the device using Windows API.
+// Waits on an overlapped I/O handle and an event that tells the thread to
+// terminate.
+//
+///////////////////////////////////////////////////////////////////////
+
+class WinReaderThread : public ReaderThreadBase {
+ Q_OBJECT
+ Q_DISABLE_COPY(WinReaderThread)
+public:
+ explicit WinReaderThread(const QSharedPointer<DeviceContext> &context);
+ ~WinReaderThread();
+
+ virtual void run();
+
+signals:
+ void error(const QString &);
+
+public slots:
+ void terminate();
+
+private:
+ enum Handles { FileHandle, TerminateEventHandle, HandleCount };
+
+ inline int tryRead();
+
+ HANDLE m_handles[HandleCount];
+};
+
+WinReaderThread::WinReaderThread(const QSharedPointer<DeviceContext> &context) :
+ ReaderThreadBase(context)
+{
+ m_handles[FileHandle] = NULL;
+ m_handles[TerminateEventHandle] = CreateEvent(NULL, FALSE, FALSE, NULL);
+}
+
+WinReaderThread::~WinReaderThread()
+{
+ CloseHandle(m_handles[TerminateEventHandle]);
+}
+
+// Return 0 to continue or error code
+int WinReaderThread::tryRead()
+{
+ enum { BufSize = 1024 };
+ char buffer[BufSize];
+ // Check if there are already bytes waiting. If not, wait for first byte
+ COMSTAT comStat;
+ if (!ClearCommError(m_context->device, NULL, &comStat)){
+ emit error(QString::fromLatin1("ClearCommError failed: %1").arg(winErrorMessage(GetLastError())));
+ return -7;
+ }
+ const DWORD bytesToRead = qMax(DWORD(1), qMin(comStat.cbInQue, DWORD(BufSize)));
+ // Trigger read
+ DWORD bytesRead = 0;
+ if (ReadFile(m_context->device, &buffer, bytesToRead, &bytesRead, &m_context->readOverlapped)) {
+ if (bytesRead == 1) {
+ processData(buffer[0]);
+ } else {
+ processData(QByteArray(buffer, bytesRead));
+ }
+ return 0;
+ }
+ const DWORD readError = GetLastError();
+ if (readError != ERROR_IO_PENDING) {
+ emit error(QString::fromLatin1("Read error: %1").arg(winErrorMessage(readError)));
+ return -1;
+ }
+ // Wait for either termination or data
+ const DWORD wr = WaitForMultipleObjects(HandleCount, m_handles, false, INFINITE);
+ if (wr == WAIT_FAILED) {
+ emit error(QString::fromLatin1("Wait failed: %1").arg(winErrorMessage(GetLastError())));
+ return -2;
+ }
+ if (wr - WAIT_OBJECT_0 == TerminateEventHandle) {
+ return 1; // Terminate
+ }
+ // Check data
+ if (!GetOverlappedResult(m_context->device, &m_context->readOverlapped, &bytesRead, true)) {
+ emit error(QString::fromLatin1("GetOverlappedResult failed: %1").arg(winErrorMessage(GetLastError())));
+ return -3;
+ }
+ if (bytesRead == 1) {
+ processData(buffer[0]);
+ } else {
+ processData(QByteArray(buffer, bytesRead));
+ }
+ return 0;
+}
+
+void WinReaderThread::run()
+{
+ m_handles[FileHandle] = m_context->readOverlapped.hEvent;
+ while ( tryRead() == 0) ;
+}
+
+void WinReaderThread::terminate()
+{
+ SetEvent(m_handles[TerminateEventHandle]);
+ wait();
+}
+
+typedef WinReaderThread ReaderThread;
+
+#else
+
+///////////////////////////////////////////////////////////////////////
+//
+// UnixReaderThread: A thread reading from the device.
+// Uses select() to wait and a special ioctl() to find out the number
+// of bytes queued. For clean termination, the self-pipe trick is used.
+// The class maintains a pipe, on whose read end the select waits besides
+// the device file handle. To terminate, a byte is written to the pipe.
+//
+///////////////////////////////////////////////////////////////////////
+
+static inline QString msgUnixCallFailedErrno(const char *func, int errorNumber)
+{
+ return QString::fromLatin1("Call to %1() failed: %2").arg(QLatin1String(func), QString::fromLocal8Bit(strerror(errorNumber)));
+}
+
+class UnixReaderThread : public ReaderThreadBase {
+ Q_OBJECT
+ Q_DISABLE_COPY(UnixReaderThread)
+public:
+ explicit UnixReaderThread(const QSharedPointer<DeviceContext> &context);
+ ~UnixReaderThread();
+
+ virtual void run();
+
+signals:
+ void error(const QString &);
+
+public slots:
+ void terminate();
+
+private:
+ inline int tryRead();
+
+ int m_terminatePipeFileDescriptors[2];
+};
+
+UnixReaderThread::UnixReaderThread(const QSharedPointer<DeviceContext> &context) :
+ ReaderThreadBase(context)
+{
+ m_terminatePipeFileDescriptors[0] = m_terminatePipeFileDescriptors[1] = -1;
+ // Set up pipes for termination. Should not fail
+ if (pipe(m_terminatePipeFileDescriptors) < 0)
+ qWarning("%s\n", qPrintable(msgUnixCallFailedErrno("pipe", errno)));
+}
+
+UnixReaderThread::~UnixReaderThread()
+{
+ close(m_terminatePipeFileDescriptors[0]);
+ close(m_terminatePipeFileDescriptors[1]);
+}
+
+int UnixReaderThread::tryRead()
+{
+ fd_set readSet, tempReadSet, tempExceptionSet;
+ struct timeval timeOut;
+ const int fileDescriptor = m_context->file.handle();
+ FD_ZERO(&readSet);
+ FD_SET(fileDescriptor, &readSet);
+ FD_SET(m_terminatePipeFileDescriptors[0], &readSet);
+ const int maxFileDescriptor = qMax(m_terminatePipeFileDescriptors[0], fileDescriptor);
+ int result = 0;
+ do {
+ memcpy(&tempReadSet, &readSet, sizeof(fd_set));
+ memcpy(&tempExceptionSet, &readSet, sizeof(fd_set));
+ timeOut.tv_sec = 1;
+ timeOut.tv_usec = 0;
+ result = select(maxFileDescriptor + 1, &tempReadSet, NULL, &tempExceptionSet, &timeOut);
+ } while ( result < 0 && errno == EINTR );
+ // Timeout?
+ if (result == 0)
+ return 0;
+ // Something wrong?
+ if (result < 0) {
+ emit error(msgUnixCallFailedErrno("select", errno));
+ return -1;
+ }
+ // Did the exception set trigger on the device?
+ if (FD_ISSET(fileDescriptor,&tempExceptionSet)) {
+ emit error(QLatin1String("An Exception occurred on the device."));
+ return -2;
+ }
+ // Check termination pipe.
+ if (FD_ISSET(m_terminatePipeFileDescriptors[0], &tempReadSet)
+ || FD_ISSET(m_terminatePipeFileDescriptors[0], &tempExceptionSet))
+ return 1;
+
+ // determine number of pending bytes and read
+ int numBytes;
+ if (ioctl(fileDescriptor, FIONREAD, &numBytes) < 0) {
+ emit error(msgUnixCallFailedErrno("ioctl", errno));
+ return -1;
+ }
+ m_context->mutex.lock();
+ const QByteArray data = m_context->file.read(numBytes);
+ m_context->mutex.unlock();
+ processData(data);
+ return 0;
+}
+
+void UnixReaderThread::run()
+{
+ // Read loop
+ while (tryRead() == 0)
+ ;
+}
+
+void UnixReaderThread::terminate()
+{
+ // Trigger select() by writing to the pipe
+ char c = 0;
+ write(m_terminatePipeFileDescriptors[1], &c, 1);
+ wait();
+}
+
+typedef UnixReaderThread ReaderThread;
+
+#endif
+
+///////////////////////////////////////////////////////////////////////
+//
+// TrkDevicePrivate
+//
+///////////////////////////////////////////////////////////////////////
+
+struct TrkDevicePrivate
+{
+ TrkDevicePrivate();
+
+ QSharedPointer<DeviceContext> deviceContext;
+ QSharedPointer<WriterThread> writerThread;
+ QSharedPointer<ReaderThread> readerThread;
+
+ QByteArray trkReadBuffer;
+ int verbose;
+ QString errorString;
+};
+
+///////////////////////////////////////////////////////////////////////
+//
+// TrkDevice
+//
+///////////////////////////////////////////////////////////////////////
+
+TrkDevicePrivate::TrkDevicePrivate() :
+ deviceContext(new DeviceContext),
+ verbose(0)
+{
+}
+
+///////////////////////////////////////////////////////////////////////
+//
+// TrkDevice
+//
+///////////////////////////////////////////////////////////////////////
+
+TrkDevice::TrkDevice(QObject *parent) :
+ QObject(parent),
+ d(new TrkDevicePrivate)
+{}
+
+TrkDevice::~TrkDevice()
+{
+ close();
+ delete d;
+}
+
+bool TrkDevice::open(const QString &port, QString *errorMessage)
+{
+ if (d->verbose)
+ qDebug() << "Opening" << port << "is open: " << isOpen() << " serialFrame=" << serialFrame();
+ close();
+#ifdef Q_OS_WIN
+ d->deviceContext->device = CreateFile(port.toStdWString().c_str(),
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL|FILE_FLAG_NO_BUFFERING|FILE_FLAG_OVERLAPPED,
+ NULL);
+
+ if (INVALID_HANDLE_VALUE == d->deviceContext->device) {
+ *errorMessage = QString::fromLatin1("Could not open device '%1': %2").arg(port, winErrorMessage(GetLastError()));
+ return false;
+ }
+ memset(&d->deviceContext->readOverlapped, 0, sizeof(OVERLAPPED));
+ d->deviceContext->readOverlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ memset(&d->deviceContext->writeOverlapped, 0, sizeof(OVERLAPPED));
+ d->deviceContext->writeOverlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if (d->deviceContext->readOverlapped.hEvent == NULL || d->deviceContext->writeOverlapped.hEvent == NULL) {
+ *errorMessage = QString::fromLatin1("Failed to create events: %1").arg(winErrorMessage(GetLastError()));
+ return false;
+ }
+#else
+ d->deviceContext->file.setFileName(port);
+ if (!d->deviceContext->file.open(QIODevice::ReadWrite|QIODevice::Unbuffered)) {
+ *errorMessage = QString::fromLatin1("Cannot open %1: %2").arg(port, d->deviceContext->file.errorString());
+ return false;
+ }
+
+ struct termios termInfo;
+ if (tcgetattr(d->deviceContext->file.handle(), &termInfo) < 0) {
+ *errorMessage = QString::fromLatin1("Unable to retrieve terminal settings: %1 %2").arg(errno).arg(QString::fromAscii(strerror(errno)));
+ return false;
+ }
+ // Turn off terminal echo as not get messages back, among other things
+ termInfo.c_cflag |= CREAD|CLOCAL;
+ termInfo.c_lflag &= (~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
+ termInfo.c_iflag &= (~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
+ termInfo.c_oflag &= (~OPOST);
+ termInfo.c_cc[VMIN] = 0;
+ termInfo.c_cc[VINTR] = _POSIX_VDISABLE;
+ termInfo.c_cc[VQUIT] = _POSIX_VDISABLE;
+ termInfo.c_cc[VSTART] = _POSIX_VDISABLE;
+ termInfo.c_cc[VSTOP] = _POSIX_VDISABLE;
+ termInfo.c_cc[VSUSP] = _POSIX_VDISABLE;
+ if (tcsetattr(d->deviceContext->file.handle(), TCSAFLUSH, &termInfo) < 0) {
+ *errorMessage = QString::fromLatin1("Unable to apply terminal settings: %1 %2").arg(errno).arg(QString::fromAscii(strerror(errno)));
+ return false;
+ }
+#endif
+ d->readerThread = QSharedPointer<ReaderThread>(new ReaderThread(d->deviceContext));
+ connect(d->readerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)),
+ Qt::QueuedConnection);
+ connect(d->readerThread.data(), SIGNAL(messageReceived(trk::TrkResult,QByteArray)),
+ this, SLOT(slotMessageReceived(trk::TrkResult,QByteArray)),
+ Qt::QueuedConnection);
+ d->readerThread->start();
+
+ d->writerThread = QSharedPointer<WriterThread>(new WriterThread(d->deviceContext));
+ connect(d->writerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)),
+ Qt::QueuedConnection);
+ d->writerThread->start();
+
+ if (d->verbose)
+ qDebug() << "Opened" << port;
+ return true;
+}
+
+void TrkDevice::close()
+{
+ if (!isOpen())
+ return;
+ if (d->readerThread)
+ d->readerThread->terminate();
+ if (d->writerThread)
+ d->writerThread->terminate();
+#ifdef Q_OS_WIN
+ CloseHandle(d->deviceContext->device);
+ d->deviceContext->device = INVALID_HANDLE_VALUE;
+ CloseHandle(d->deviceContext->readOverlapped.hEvent);
+ CloseHandle(d->deviceContext->writeOverlapped.hEvent);
+ d->deviceContext->readOverlapped.hEvent = d->deviceContext->writeOverlapped.hEvent = NULL;
+#else
+ d->deviceContext->file.close();
+#endif
+ if (d->verbose)
+ emitLogMessage("Close");
+}
+
+bool TrkDevice::isOpen() const
+{
+#ifdef Q_OS_WIN
+ return d->deviceContext->device != INVALID_HANDLE_VALUE;
+#else
+ return d->deviceContext->file.isOpen();
+#endif
+}
+
+QString TrkDevice::errorString() const
+{
+ return d->errorString;
+}
+
+bool TrkDevice::serialFrame() const
+{
+ return d->deviceContext->serialFrame;
+}
+
+void TrkDevice::setSerialFrame(bool f)
+{
+ d->deviceContext->serialFrame = f;
+}
+
+int TrkDevice::verbose() const
+{
+ return d->verbose;
+}
+
+void TrkDevice::setVerbose(int b)
+{
+ d->verbose = b;
+}
+
+void TrkDevice::slotMessageReceived(const trk::TrkResult &result, const QByteArray &rawData)
+{
+ d->writerThread->slotHandleResult(result);
+ emit messageReceived(result);
+ if (!rawData.isEmpty())
+ emit rawDataReceived(rawData);
+}
+
+void TrkDevice::emitError(const QString &s)
+{
+ d->errorString = s;
+ qWarning("%s\n", qPrintable(s));
+ emit error(s);
+}
+
+void TrkDevice::sendTrkMessage(byte code, TrkCallback callback,
+ const QByteArray &data, const QVariant &cookie)
+{
+ if (!d->writerThread.isNull()) {
+ if (d->verbose > 1)
+ qDebug() << "Sending " << code << data.toHex();
+ d->writerThread->queueTrkMessage(code, callback, data, cookie);
+ }
+}
+
+void TrkDevice::sendTrkInitialPing()
+{
+ if (!d->writerThread.isNull())
+ d->writerThread->queueTrkInitialPing();
+}
+
+bool TrkDevice::sendTrkAck(byte token)
+{
+ if (d->writerThread.isNull())
+ return false;
+ // The acknowledgement must not be queued!
+ TrkMessage msg(0x80, token);
+ msg.token = token;
+ msg.data.append('\0');
+ return d->writerThread->trkWriteRawMessage(msg);
+ // 01 90 00 07 7e 80 01 00 7d 5e 7e
+}
+
+void TrkDevice::emitLogMessage(const QString &msg)
+{
+ if (d->verbose)
+ qDebug("%s\n", qPrintable(msg));
+ emit logMessage(msg);
+}
+
+} // namespace trk
+
+#include "trkdevice.moc"
diff --git a/tools/runonphone/trk/trkdevice.h b/tools/runonphone/trk/trkdevice.h
new file mode 100644
index 0000000000..41e7a6eb92
--- /dev/null
+++ b/tools/runonphone/trk/trkdevice.h
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TRKDEVICE_H
+#define TRKDEVICE_H
+
+#include "callback.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QVariant>
+#include <QtCore/QByteArray>
+#include <QtCore/QSharedPointer>
+
+QT_BEGIN_NAMESPACE
+class QIODevice;
+QT_END_NAMESPACE
+
+namespace trk {
+
+struct TrkResult;
+struct TrkMessage;
+struct TrkDevicePrivate;
+
+/* TrkDevice: Implements a Windows COM or Linux device for
+ * Trk communications. Provides synchronous write and asynchronous
+ * read operation.
+ * The serialFrames property specifies whether packets are encapsulated in
+ * "0x90 <length>" frames, which is currently the case for serial ports.
+ * Contains a write message queue allowing
+ * for queueing messages with a notification callback. If the message receives
+ * an ACK, the callback is invoked.
+ * The special message TRK_WRITE_QUEUE_NOOP_CODE code can be used for synchronisation.
+ * The respective message will not be sent, the callback is just invoked. */
+
+enum { TRK_WRITE_QUEUE_NOOP_CODE = 0x7f };
+
+typedef trk::Callback<const TrkResult &> TrkCallback;
+
+class TrkDevice : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool serialFrame READ serialFrame WRITE setSerialFrame)
+ Q_PROPERTY(bool verbose READ verbose WRITE setVerbose)
+public:
+ explicit TrkDevice(QObject *parent = 0);
+ virtual ~TrkDevice();
+
+ bool open(const QString &port, QString *errorMessage);
+ bool isOpen() const;
+
+ QString errorString() const;
+
+ bool serialFrame() const;
+ void setSerialFrame(bool f);
+
+ int verbose() const;
+ void setVerbose(int b);
+
+ // Enqueue a message with a notification callback.
+ void sendTrkMessage(unsigned char code,
+ TrkCallback callBack = TrkCallback(),
+ const QByteArray &data = QByteArray(),
+ const QVariant &cookie = QVariant());
+
+ // Enqeue an initial ping
+ void sendTrkInitialPing();
+
+ // Send an Ack synchronously, bypassing the queue
+ bool sendTrkAck(unsigned char token);
+
+signals:
+ void messageReceived(const trk::TrkResult &result);
+ // Emitted with the contents of messages enclosed in 07e, not for log output
+ void rawDataReceived(const QByteArray &data);
+ void error(const QString &msg);
+ void logMessage(const QString &msg);
+
+private slots:
+ void slotMessageReceived(const trk::TrkResult &result, const QByteArray &a);
+
+protected slots:
+ void emitError(const QString &msg);
+ void emitLogMessage(const QString &msg);
+
+public slots:
+ void close();
+
+private:
+ void readMessages();
+ TrkDevicePrivate *d;
+};
+
+} // namespace trk
+
+#endif // TRKDEVICE_H
diff --git a/tools/runonphone/trk/trkutils.cpp b/tools/runonphone/trk/trkutils.cpp
new file mode 100644
index 0000000000..4fb4f1be61
--- /dev/null
+++ b/tools/runonphone/trk/trkutils.cpp
@@ -0,0 +1,486 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "trkutils.h"
+#include <ctype.h>
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
+#include <QtCore/QDate>
+#include <QtCore/QDateTime>
+#include <QtCore/QTime>
+
+#define logMessage(s) do { qDebug() << "TRKCLIENT: " << s; } while (0)
+
+namespace trk {
+
+TrkAppVersion::TrkAppVersion()
+{
+ reset();
+}
+
+void TrkAppVersion::reset()
+{
+ trkMajor = trkMinor= protocolMajor = protocolMinor = 0;
+}
+
+Session::Session()
+{
+ reset();
+}
+
+void Session::reset()
+{
+ cpuMajor = 0;
+ cpuMinor = 0;
+ bigEndian = 0;
+ defaultTypeSize = 0;
+ fpTypeSize = 0;
+ extended1TypeSize = 0;
+ extended2TypeSize = 0;
+ pid = 0;
+ tid = 0;
+ codeseg = 0;
+ dataseg = 0;
+
+ currentThread = 0;
+ libraries.clear();
+ trkAppVersion.reset();
+}
+
+QString formatCpu(int major, int minor)
+{
+ //: CPU description of an S60 device
+ //: %1 major verison, %2 minor version
+ //: %3 real name of major verison, %4 real name of minor version
+ const QString str = QCoreApplication::translate("trk::Session", "CPU: v%1.%2%3%4");
+ QString majorStr;
+ QString minorStr;
+ switch (major) {
+ case 0x04:
+ majorStr = " ARM";
+ break;
+ }
+ switch (minor) {
+ case 0x00:
+ minorStr = " 920T";
+ break;
+ }
+ return str.arg(major).arg(minor).arg(majorStr).arg(minorStr);
+ }
+
+QString formatTrkVersion(const TrkAppVersion &version)
+{
+ QString str = QCoreApplication::translate("trk::Session",
+ "App TRK: v%1.%2 TRK protocol: v%3.%4");
+ str = str.arg(version.trkMajor).arg(version.trkMinor);
+ return str.arg(version.protocolMajor).arg(version.protocolMinor);
+}
+
+QString Session::deviceDescription(unsigned verbose) const
+{
+ if (!cpuMajor)
+ return QString();
+
+ //: s60description
+ //: description of an S60 device
+ //: %1 CPU description, %2 endianness
+ //: %3 default type size (if any), %4 float size (if any)
+ //: %5 TRK version
+ QString msg = QCoreApplication::translate("trk::Session", "%1, %2%3%4, %5");
+ QString endianness = bigEndian
+ ? QCoreApplication::translate("trk::Session", "big endian")
+ : QCoreApplication::translate("trk::Session", "little endian");
+ msg = msg.arg(formatCpu(cpuMajor, cpuMinor)).arg(endianness);
+ //: The separator in a list of strings
+ QString defaultTypeSizeStr;
+ QString fpTypeSizeStr;
+ if (verbose && defaultTypeSize)
+ //: will be inserted into s60description
+ defaultTypeSizeStr = QCoreApplication::translate("trk::Session", ", type size: %1").arg(defaultTypeSize);
+ if (verbose && fpTypeSize)
+ //: will be inserted into s60description
+ fpTypeSizeStr = QCoreApplication::translate("trk::Session", ", float size: %1").arg(fpTypeSize);
+ msg = msg.arg(defaultTypeSizeStr).arg(fpTypeSizeStr);
+ return msg.arg(formatTrkVersion(trkAppVersion));
+}
+
+
+// FIXME: Use the QByteArray based version below?
+QString stringFromByte(byte c)
+{
+ return QString("%1 ").arg(c, 2, 16, QChar('0'));
+}
+
+QString stringFromArray(const QByteArray &ba, int maxLen)
+{
+ QString str;
+ QString ascii;
+ const int size = maxLen == -1 ? ba.size() : qMin(ba.size(), maxLen);
+ for (int i = 0; i < size; ++i) {
+ //if (i == 5 || i == ba.size() - 2)
+ // str += " ";
+ int c = byte(ba.at(i));
+ str += QString("%1 ").arg(c, 2, 16, QChar('0'));
+ if (i >= 8 && i < ba.size() - 2)
+ ascii += QChar(c).isPrint() ? QChar(c) : QChar('.');
+ }
+ if (size != ba.size()) {
+ str += "...";
+ ascii += "...";
+ }
+ return str + " " + ascii;
+}
+
+QByteArray hexNumber(uint n, int digits)
+{
+ QByteArray ba = QByteArray::number(n, 16);
+ if (digits == 0 || ba.size() == digits)
+ return ba;
+ return QByteArray(digits - ba.size(), '0') + ba;
+}
+
+QByteArray hexxNumber(uint n, int digits)
+{
+ return "0x" + hexNumber(n, digits);
+}
+
+TrkResult::TrkResult() :
+ code(0),
+ token(0),
+ isDebugOutput(false)
+{
+}
+
+void TrkResult::clear()
+{
+ code = token= 0;
+ isDebugOutput = false;
+ data.clear();
+ cookie = QVariant();
+}
+
+QString TrkResult::toString() const
+{
+ QString res = stringFromByte(code) + "[" + stringFromByte(token);
+ res.chop(1);
+ return res + "] " + stringFromArray(data);
+}
+
+QByteArray frameMessage(byte command, byte token, const QByteArray &data, bool serialFrame)
+{
+ byte s = command + token;
+ for (int i = 0; i != data.size(); ++i)
+ s += data.at(i);
+ byte checksum = 255 - (s & 0xff);
+ //int x = s + ~s;
+ //logMessage("check: " << s << checksum << x;
+
+ QByteArray response;
+ response.reserve(data.size() + 3);
+ response.append(char(command));
+ response.append(char(token));
+ response.append(data);
+ response.append(char(checksum));
+
+ QByteArray encodedData = encode7d(response);
+
+ QByteArray ba;
+ ba.reserve(encodedData.size() + 6);
+ if (serialFrame) {
+ ba.append(char(0x01));
+ ba.append(char(0x90));
+ const ushort encodedSize = encodedData.size() + 2; // 2 x 0x7e
+ appendShort(&ba, encodedSize, BigEndian);
+ }
+ ba.append(char(0x7e));
+ ba.append(encodedData);
+ ba.append(char(0x7e));
+
+ return ba;
+}
+
+/* returns 0 if array doesn't represent a result,
+otherwise returns the length of the result data */
+ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame)
+{
+ if (serialFrame) {
+ // Serial protocol with length info
+ if (buffer.length() < 4)
+ return 0;
+ if (buffer.at(0) != 0x01 || byte(buffer.at(1)) != 0x90)
+ return 0;
+ const ushort len = extractShort(buffer.data() + 2);
+ return (buffer.size() >= len + 4) ? len : ushort(0);
+ }
+ // Frameless protocol without length info
+ const char delimiter = char(0x7e);
+ const int firstDelimiterPos = buffer.indexOf(delimiter);
+ // Regular message delimited by 0x7e..0x7e
+ if (firstDelimiterPos == 0) {
+ const int endPos = buffer.indexOf(delimiter, firstDelimiterPos + 1);
+ return endPos != -1 ? endPos + 1 - firstDelimiterPos : 0;
+ }
+ // Some ASCII log message up to first delimiter or all
+ return firstDelimiterPos != -1 ? firstDelimiterPos : buffer.size();
+}
+
+bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *result, QByteArray *rawData)
+{
+ result->clear();
+ if(rawData)
+ rawData->clear();
+ const ushort len = isValidTrkResult(*buffer, serialFrame);
+ if (!len)
+ return false;
+ // handle receiving application output, which is not a regular command
+ const int delimiterPos = serialFrame ? 4 : 0;
+ if (buffer->at(delimiterPos) != 0x7e) {
+ result->isDebugOutput = true;
+ result->data = buffer->mid(delimiterPos, len);
+ result->data.replace("\r\n", "\n");
+ *buffer->remove(0, delimiterPos + len);
+ return true;
+ }
+ // FIXME: what happens if the length contains 0xfe?
+ // Assume for now that it passes unencoded!
+ const QByteArray data = decode7d(buffer->mid(delimiterPos + 1, len - 2));
+ if(rawData)
+ *rawData = data;
+ *buffer->remove(0, delimiterPos + len);
+
+ byte sum = 0;
+ for (int i = 0; i < data.size(); ++i) // 3 = 2 * 0xfe + sum
+ sum += byte(data.at(i));
+ if (sum != 0xff)
+ logMessage("*** CHECKSUM ERROR: " << byte(sum));
+
+ result->code = data.at(0);
+ result->token = data.at(1);
+ result->data = data.mid(2, data.size() - 3);
+ //logMessage(" REST BUF: " << stringFromArray(*buffer));
+ //logMessage(" CURR DATA: " << stringFromArray(data));
+ //QByteArray prefix = "READ BUF: ";
+ //logMessage((prefix + "HEADER: " + stringFromArray(header).toLatin1()).data());
+ return true;
+}
+
+ushort extractShort(const char *data)
+{
+ return byte(data[0]) * 256 + byte(data[1]);
+}
+
+uint extractInt(const char *data)
+{
+ uint res = byte(data[0]);
+ res *= 256; res += byte(data[1]);
+ res *= 256; res += byte(data[2]);
+ res *= 256; res += byte(data[3]);
+ return res;
+}
+
+QString quoteUnprintableLatin1(const QByteArray &ba)
+{
+ QString res;
+ char buf[10];
+ for (int i = 0, n = ba.size(); i != n; ++i) {
+ const byte c = ba.at(i);
+ if (isprint(c)) {
+ res += c;
+ } else {
+ qsnprintf(buf, sizeof(buf) - 1, "\\%x", int(c));
+ res += buf;
+ }
+ }
+ return res;
+}
+
+QByteArray decode7d(const QByteArray &ba)
+{
+ QByteArray res;
+ res.reserve(ba.size());
+ for (int i = 0; i < ba.size(); ++i) {
+ byte c = byte(ba.at(i));
+ if (c == 0x7d) {
+ ++i;
+ c = 0x20 ^ byte(ba.at(i));
+ }
+ res.append(c);
+ }
+ //if (res != ba)
+ // logMessage("DECODED: " << stringFromArray(ba)
+ // << " -> " << stringFromArray(res));
+ return res;
+}
+
+QByteArray encode7d(const QByteArray &ba)
+{
+ QByteArray res;
+ res.reserve(ba.size() + 2);
+ for (int i = 0; i < ba.size(); ++i) {
+ byte c = byte(ba.at(i));
+ if (c == 0x7e || c == 0x7d) {
+ res.append(0x7d);
+ res.append(0x20 ^ c);
+ } else {
+ res.append(c);
+ }
+ }
+ //if (res != ba)
+ // logMessage("ENCODED: " << stringFromArray(ba)
+ // << " -> " << stringFromArray(res));
+ return res;
+}
+
+void appendByte(QByteArray *ba, byte b)
+{
+ ba->append(b);
+}
+
+void appendShort(QByteArray *ba, ushort s, Endianness endian)
+{
+ if (endian == BigEndian) {
+ ba->append(s / 256);
+ ba->append(s % 256);
+ } else {
+ ba->append(s % 256);
+ ba->append(s / 256);
+ }
+}
+
+void appendInt(QByteArray *ba, uint i, Endianness endian)
+{
+ const uchar b3 = i % 256; i /= 256;
+ const uchar b2 = i % 256; i /= 256;
+ const uchar b1 = i % 256; i /= 256;
+ const uchar b0 = i;
+ ba->reserve(ba->size() + 4);
+ if (endian == BigEndian) {
+ ba->append(b0);
+ ba->append(b1);
+ ba->append(b2);
+ ba->append(b3);
+ } else {
+ ba->append(b3);
+ ba->append(b2);
+ ba->append(b1);
+ ba->append(b0);
+ }
+}
+
+void appendString(QByteArray *ba, const QByteArray &str, Endianness endian, bool appendNullTerminator)
+{
+ const int fullSize = str.size() + (appendNullTerminator ? 1 : 0);
+ appendShort(ba, fullSize, endian); // count the terminating \0
+ ba->append(str);
+ if (appendNullTerminator)
+ ba->append('\0');
+}
+
+void appendDateTime(QByteArray *ba, QDateTime dateTime, Endianness endian)
+{
+ // convert the QDateTime to UTC and append its representation to QByteArray
+ // format is the same as in FAT file system
+ dateTime = dateTime.toUTC();
+ const QTime utcTime = dateTime.time();
+ const QDate utcDate = dateTime.date();
+ uint fatDateTime = (utcTime.hour() << 11 | utcTime.minute() << 5 | utcTime.second()/2) << 16;
+ fatDateTime |= (utcDate.year()-1980) << 9 | utcDate.month() << 5 | utcDate.day();
+ appendInt(ba, fatDateTime, endian);
+}
+
+QByteArray errorMessage(byte code)
+{
+ switch (code) {
+ case 0x00: return "No error";
+ case 0x01: return "Generic error in CWDS message";
+ case 0x02: return "Unexpected packet size in send msg";
+ case 0x03: return "Internal error occurred in CWDS";
+ case 0x04: return "Escape followed by frame flag";
+ case 0x05: return "Bad FCS in packet";
+ case 0x06: return "Packet too long";
+ case 0x07: return "Sequence ID not expected (gap in sequence)";
+
+ case 0x10: return "Command not supported";
+ case 0x11: return "Command param out of range";
+ case 0x12: return "An option was not supported";
+ case 0x13: return "Read/write to invalid memory";
+ case 0x14: return "Read/write invalid registers";
+ case 0x15: return "Exception occurred in CWDS";
+ case 0x16: return "Targeted system or thread is running";
+ case 0x17: return "Breakpoint resources (HW or SW) exhausted";
+ case 0x18: return "Requested breakpoint conflicts with existing one";
+
+ case 0x20: return "General OS-related error";
+ case 0x21: return "Request specified invalid process";
+ case 0x22: return "Request specified invalid thread";
+ }
+ return "Unknown error";
+}
+
+uint swapEndian(uint in)
+{
+ return (in>>24) | ((in<<8) & 0x00FF0000) | ((in>>8) & 0x0000FF00) | (in<<24);
+}
+
+int TrkResult::errorCode() const
+{
+ // NAK means always error, else data sized 1 with a non-null element
+ const bool isNAK = code == 0xff;
+ if (data.size() != 1 && !isNAK)
+ return 0;
+ if (const int errorCode = data.at(0))
+ return errorCode;
+ return isNAK ? 0xff : 0;
+}
+
+QString TrkResult::errorString() const
+{
+ // NAK means always error, else data sized 1 with a non-null element
+ if (code == 0xff)
+ return "NAK";
+ if (data.size() < 1)
+ return "Unknown error packet";
+ return errorMessage(data.at(0));
+}
+
+} // namespace trk
+
diff --git a/tools/runonphone/trk/trkutils.h b/tools/runonphone/trk/trkutils.h
new file mode 100644
index 0000000000..632c0d894f
--- /dev/null
+++ b/tools/runonphone/trk/trkutils.h
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DEBUGGER_TRK_UTILS
+#define DEBUGGER_TRK_UTILS
+
+#include <QtCore/QByteArray>
+#include <QtCore/QHash>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+
+typedef unsigned char byte;
+
+QT_BEGIN_NAMESPACE
+class QDateTime;
+QT_END_NAMESPACE
+
+namespace trk {
+
+enum Command {
+ TrkPing = 0x00,
+ TrkConnect = 0x01,
+ TrkDisconnect = 0x02,
+ TrkVersions = 0x04,
+ TrkSupported = 0x05,
+ TrkCpuType = 0x06,
+ TrkHostVersions = 0x09,
+ TrkContinue = 0x18,
+ TrkCreateItem = 0x40,
+ TrkDeleteItem = 0x41,
+
+ TrkWriteFile = 0x48,
+ TrkOpenFile = 0x4a,
+ TrkCloseFile = 0x4b,
+ TrkInstallFile = 0x4d,
+ TrkInstallFile2 = 0x4e,
+
+ TrkNotifyAck = 0x80,
+ TrkNotifyNak = 0xff,
+ TrkNotifyStopped = 0x90,
+ TrkNotifyException = 0x91,
+ TrkNotifyInternalError = 0x92,
+ TrkNotifyCreated = 0xa0,
+ TrkNotifyDeleted = 0xa1,
+ TrkNotifyProcessorStarted = 0xa2,
+ TrkNotifyProcessorStandBy = 0xa6,
+ TrkNotifyProcessorReset = 0xa7
+};
+
+QByteArray decode7d(const QByteArray &ba);
+QByteArray encode7d(const QByteArray &ba);
+
+inline byte extractByte(const char *data) { return *data; }
+ushort extractShort(const char *data);
+uint extractInt(const char *data);
+
+QString quoteUnprintableLatin1(const QByteArray &ba);
+
+// produces "xx xx xx "
+QString stringFromArray(const QByteArray &ba, int maxLen = - 1);
+
+enum Endianness
+{
+ LittleEndian,
+ BigEndian,
+ TargetByteOrder = BigEndian,
+};
+
+void appendByte(QByteArray *ba, byte b);
+void appendShort(QByteArray *ba, ushort s, Endianness = TargetByteOrder);
+void appendInt(QByteArray *ba, uint i, Endianness = TargetByteOrder);
+void appendString(QByteArray *ba, const QByteArray &str, Endianness = TargetByteOrder, bool appendNullTerminator = true);
+void appendDateTime(QByteArray *ba, QDateTime dateTime, Endianness = TargetByteOrder);
+
+struct Library
+{
+ Library() {}
+
+ QByteArray name;
+ uint codeseg;
+ uint dataseg;
+};
+
+struct TrkAppVersion {
+ TrkAppVersion();
+ void reset();
+
+ int trkMajor;
+ int trkMinor;
+ int protocolMajor;
+ int protocolMinor;
+};
+
+struct Session
+{
+ Session();
+ void reset();
+ QString deviceDescription(unsigned verbose) const;
+
+ // Trk feedback
+ byte cpuMajor;
+ byte cpuMinor;
+ byte bigEndian;
+ byte defaultTypeSize;
+ byte fpTypeSize;
+ byte extended1TypeSize;
+ byte extended2TypeSize;
+ TrkAppVersion trkAppVersion;
+ uint pid;
+ uint tid;
+ uint codeseg;
+ uint dataseg;
+ QHash<uint, uint> addressToBP;
+
+ typedef QList<Library> Libraries;
+ Libraries libraries;
+
+ // Gdb request
+ uint currentThread;
+ QStringList modules;
+};
+
+struct TrkResult
+{
+ TrkResult();
+ void clear();
+ QString toString() const;
+ // 0 for no error.
+ int errorCode() const;
+ QString errorString() const;
+
+ byte code;
+ byte token;
+ QByteArray data;
+ QVariant cookie;
+ bool isDebugOutput;
+};
+
+// returns a QByteArray containing optionally
+// the serial frame [0x01 0x90 <len>] and 0x7e encoded7d(ba) 0x7e
+QByteArray frameMessage(byte command, byte token, const QByteArray &data, bool serialFrame);
+ushort isValidTrkResult(const QByteArray &buffer, bool serialFrame);
+bool extractResult(QByteArray *buffer, bool serialFrame, TrkResult *r, QByteArray *rawData = 0);
+QByteArray errorMessage(byte code);
+QByteArray hexNumber(uint n, int digits = 0);
+QByteArray hexxNumber(uint n, int digits = 0); // prepends '0x', too
+uint swapEndian(uint in);
+
+} // namespace trk
+
+#endif // DEBUGGER_TRK_UTILS
diff --git a/tools/runonphone/trksignalhandler.cpp b/tools/runonphone/trksignalhandler.cpp
new file mode 100644
index 0000000000..afb1918aef
--- /dev/null
+++ b/tools/runonphone/trksignalhandler.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include <QCoreApplication>
+#include "trksignalhandler.h"
+
+void TrkSignalHandler::copyingStarted()
+{
+ qDebug() << "Copying...\n";
+}
+
+void TrkSignalHandler::canNotConnect(const QString &errorMessage)
+{
+ qWarning() << "Cannot Connect - " << errorMessage;
+}
+
+void TrkSignalHandler::canNotCreateFile(const QString &filename, const QString &errorMessage)
+{
+ qWarning() << "Cannot create file (" << filename << ") - " << errorMessage << "\n";
+}
+
+void TrkSignalHandler::canNotWriteFile(const QString &filename, const QString &errorMessage)
+{
+ qWarning() << "Cannot write file (" << filename << ") - " << errorMessage << "\n";
+}
+
+void TrkSignalHandler::canNotCloseFile(const QString &filename, const QString &errorMessage)
+{
+ qWarning() << "Cannot close file (" << filename << ") - " << errorMessage << "\n";
+}
+
+void TrkSignalHandler::installingStarted()
+{
+ qDebug() << "Installing...\n";
+}
+
+void TrkSignalHandler::canNotInstall(const QString &packageFilename, const QString &errorMessage)
+{
+ qWarning() << "Cannot install file (" << packageFilename << ") - " << errorMessage << "\n";
+}
+
+void TrkSignalHandler::installingFinished()
+{
+ qDebug() << "Installing finished\n";
+}
+
+void TrkSignalHandler::startingApplication()
+{
+ qDebug() << "Starting app...\n";
+}
+
+void TrkSignalHandler::applicationRunning(uint pid)
+{
+ qDebug() << "Running...\n";
+}
+
+void TrkSignalHandler::canNotRun(const QString &errorMessage)
+{
+ qWarning() << "Cannot run - " << errorMessage << "\n";
+}
+
+void TrkSignalHandler::finished()
+{
+ qDebug() << "Done.\n";
+ QCoreApplication::quit();
+}
+
+void TrkSignalHandler::applicationOutputReceived(const QString &output)
+{
+ qDebug() << "> " << output;
+}
+
+void TrkSignalHandler::copyProgress(int percent)
+{
+ qDebug() << percent << "%";
+}
+
+void TrkSignalHandler::stateChanged(int state)
+{
+ qDebug() << "State" << state;
+}
+
diff --git a/tools/runonphone/trksignalhandler.h b/tools/runonphone/trksignalhandler.h
new file mode 100644
index 0000000000..2b3f3a0245
--- /dev/null
+++ b/tools/runonphone/trksignalhandler.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TRKSIGNALHANDLER_H
+#define TRKSIGNALHANDLER_H
+#include <QObject>
+#include <QString>
+
+class TrkSignalHandler : public QObject
+{
+ Q_OBJECT
+public slots:
+ void copyingStarted();
+ void canNotConnect(const QString &errorMessage);
+ void canNotCreateFile(const QString &filename, const QString &errorMessage);
+ void canNotWriteFile(const QString &filename, const QString &errorMessage);
+ void canNotCloseFile(const QString &filename, const QString &errorMessage);
+ void installingStarted();
+ void canNotInstall(const QString &packageFilename, const QString &errorMessage);
+ void installingFinished();
+ void startingApplication();
+ void applicationRunning(uint pid);
+ void canNotRun(const QString &errorMessage);
+ void finished();
+ void applicationOutputReceived(const QString &output);
+ void copyProgress(int percent);
+ void stateChanged(int);
+};
+
+#endif // TRKSIGNALHANDLER_H
diff --git a/tools/xmlpatterns/main.cpp b/tools/xmlpatterns/main.cpp
index 604523b225..76853b5ac5 100644
--- a/tools/xmlpatterns/main.cpp
+++ b/tools/xmlpatterns/main.cpp
@@ -49,6 +49,7 @@
#include <QtCore/QUrl>
#include <QtCore/QVariant>
#include <QtCore/QVector>
+#include <QtCore/QCoreApplication>
#include <QtXmlPatterns/QXmlFormatter>
#include <QtXmlPatterns/QXmlItem>
@@ -58,7 +59,6 @@
#include "private/qautoptr_p.h"
#include "qapplicationargument_p.h"
#include "qapplicationargumentparser_p.h"
-#include "qcoloringmessagehandler_p.h"
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
/* Needed for opening stdout with _fdopen & friends. io.h seems to not be
diff --git a/tools/xmlpatterns/main.h b/tools/xmlpatterns/main.h
index cdef999157..76b7097bb0 100644
--- a/tools/xmlpatterns/main.h
+++ b/tools/xmlpatterns/main.h
@@ -54,21 +54,13 @@
#include <QCoreApplication>
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
class QXmlPatternistCLI
{
public:
- Q_DECLARE_TR_FUNCTIONS(QXmlPatternistCLI)
+ Q_DECLARE_TR_FUNCTIONS(QXmlPatternistCLI)
private:
inline QXmlPatternistCLI();
Q_DISABLE_COPY(QXmlPatternistCLI)
};
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
#endif
diff --git a/tools/xmlpatterns/xmlpatterns.pro b/tools/xmlpatterns/xmlpatterns.pro
index 47f5a48e5b..8cd321c3b7 100644
--- a/tools/xmlpatterns/xmlpatterns.pro
+++ b/tools/xmlpatterns/xmlpatterns.pro
@@ -17,16 +17,12 @@ CONFIG -= app_bundle
# in libQtXmlPatterns. See src/xmlpatterns/api/api.pri.
SOURCES = main.cpp \
qapplicationargument.cpp \
- qapplicationargumentparser.cpp \
- qcoloringmessagehandler.cpp \
- qcoloroutput.cpp
+ qapplicationargumentparser.cpp
HEADERS = main.h \
qapplicationargument.cpp \
- qapplicationargumentparser.cpp \
- qcoloringmessagehandler_p.h \
- qcoloroutput_p.h
+ qapplicationargumentparser.cpp
symbian: TARGET.UID3 = 0xA000D7C9