diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-09-10 09:07:19 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-09-10 09:07:19 (GMT) |
commit | a3256014d6adb31c89b0e5de5b0decc393649b70 (patch) | |
tree | cd315ffdb3e35f4040b268e9dc083244da084b2a | |
parent | b17cc4918bfc4b250293000bdabcb8f2dbdec787 (diff) | |
parent | 2c232cdbce3eba095da26362b964f411a9d3ba80 (diff) | |
download | Qt-a3256014d6adb31c89b0e5de5b0decc393649b70.zip Qt-a3256014d6adb31c89b0e5de5b0decc393649b70.tar.gz Qt-a3256014d6adb31c89b0e5de5b0decc393649b70.tar.bz2 |
Merge branch '4.6'
96 files changed, 1402 insertions, 675 deletions
diff --git a/demos/embedded/anomaly/src/flickcharm.cpp b/demos/embedded/anomaly/src/flickcharm.cpp index 3fa5d8a..0b9e68e 100644 --- a/demos/embedded/anomaly/src/flickcharm.cpp +++ b/demos/embedded/anomaly/src/flickcharm.cpp @@ -84,7 +84,7 @@ FlickCharm::~FlickCharm() void FlickCharm::activateOn(QWidget *widget) { - QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(widget); + QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget); if (scrollArea) { scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -102,7 +102,7 @@ void FlickCharm::activateOn(QWidget *widget) return; } - QWebView *webView = dynamic_cast<QWebView*>(widget); + QWebView *webView = qobject_cast<QWebView*>(widget); if (webView) { QWebFrame *frame = webView->page()->mainFrame(); frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); @@ -124,7 +124,7 @@ void FlickCharm::activateOn(QWidget *widget) void FlickCharm::deactivateFrom(QWidget *widget) { - QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(widget); + QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget); if (scrollArea) { QWidget *viewport = scrollArea->viewport(); @@ -137,7 +137,7 @@ void FlickCharm::deactivateFrom(QWidget *widget) return; } - QWebView *webView = dynamic_cast<QWebView*>(widget); + QWebView *webView = qobject_cast<QWebView*>(widget); if (webView) { webView->removeEventFilter(this); @@ -152,13 +152,13 @@ static QPoint scrollOffset(QWidget *widget) { int x = 0, y = 0; - QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(widget); + QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget); if (scrollArea) { x = scrollArea->horizontalScrollBar()->value(); y = scrollArea->verticalScrollBar()->value(); } - QWebView *webView = dynamic_cast<QWebView*>(widget); + QWebView *webView = qobject_cast<QWebView*>(widget); if (webView) { QWebFrame *frame = webView->page()->mainFrame(); x = frame->evaluateJavaScript("window.scrollX").toInt(); @@ -170,13 +170,13 @@ static QPoint scrollOffset(QWidget *widget) static void setScrollOffset(QWidget *widget, const QPoint &p) { - QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(widget); + QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget); if (scrollArea) { scrollArea->horizontalScrollBar()->setValue(p.x()); scrollArea->verticalScrollBar()->setValue(p.y()); } - QWebView *webView = dynamic_cast<QWebView*>(widget); + 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())); @@ -202,11 +202,19 @@ bool FlickCharm::eventFilter(QObject *object, QEvent *event) type != QEvent::MouseMove) return false; - QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event); + QMouseEvent *mouseEvent = 0; + switch (event->type()) { + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseMove: + mouseEvent = static_cast<QMouseEvent*>(event); + break; + } + if (!mouseEvent || mouseEvent->modifiers() != Qt::NoModifier) return false; - QWidget *viewport = dynamic_cast<QWidget*>(object); + QWidget *viewport = qobject_cast<QWidget*>(object); FlickData *data = d->flickData.value(viewport); if (!viewport || !data || data->ignored.removeAll(event)) return false; diff --git a/doc/src/frameworks-technologies/gestures.qdoc b/doc/src/frameworks-technologies/gestures.qdoc index c9ca305..57f25ba 100644 --- a/doc/src/frameworks-technologies/gestures.qdoc +++ b/doc/src/frameworks-technologies/gestures.qdoc @@ -47,44 +47,104 @@ \ingroup howto \brief An overview of the Qt support for Gesture programming. - The QGesture class provides the ability to form gestures from a series - of events independent of the input method. A gesture could be a particular - movement of a mouse, a touch screen action, or a series of events from - some other source. The nature of the input, the interpretation - of the gesture and the action taken are the choice of the implementing + Qt includes a framework for gesture programming that gives has the ability + to form gestures from a series of events, independently of the input methods + used. A gesture could be a particular movement of a mouse, a touch screen + action, or a series of events from some other source. The nature of the input, + the interpretation of the gesture and the action taken are the choice of the developer. \tableofcontents + \section1 Overview - \section1 Creating Your Own Gesture Recognizer + QGesture is the central class in Qt's gesture framework, providing the API + used by classes that represent specific gestures, such as QPanGesture, + QPinchGesture, and QSwipeGesture. These standard classes are ready to use, + and each exposes functions and properties that give gesture-specific + information about the user's input. This is described in the + \l{#Using Standard Gestures}{Using Standard Gestures} section. + + QGesture is also designed to be subclassed and extended so that support for + new gestures can be implemented by developers. Adding support for a new + gesture involves implementing code to recognize the gesture from incoming + events. This is described in the + \l{#Creating Your Own Gesture Recognizer}{Creating Your Own Gesture Recognizer} + section. + + \section1 Using Standard Gestures with Widgets + + Gesture objects are applied directly to widgets and other controls that accept + user input \mdash these are the \e{target objects}. When a gesture object is + constructed, the target object is typically passed to the constructor, though + it can also be passed as the argument to the \l{QGesture::}{setGestureTarget()} + function. + + \snippet examples/gestures/imageviewer/imagewidget.cpp construct swipe gesture + + In the above code, the gesture is set up in the constructor of the target object + itself, so the argument to the QSwipeGesture constructor is \e this. + + When the user performs a gesture, various signals may be emitted by the + gesture object. To monitor the user's actions, you need to connect signals + from the gesture object to slots in your code. + + \snippet examples/gestures/imageviewer/imagewidget.cpp connect swipe gesture + + Here, the \l{QGesture::}{triggered()} signal is used to inform the application + that a gesture was used. More precise monitoring of a gesture can be implemented + by connecting its \l{QGesture::}{started()}, \l{QGesture::}{canceled()} and + \l{QGesture::}{finished()} signals to slots. + + Responding to a signal is simply a matter of obtaining the gesture that sent + it and examining the information it contains. + + \snippet examples/gestures/imageviewer/imagewidget.cpp swipe slot start + + \snippet examples/gestures/imageviewer/imagewidget.cpp swipe slot finish + + Here, we examine the direction in which the user swiped the widget and modify + its contents accordingly. + + \section1 Using Standard Gestures with Graphics Items + + The approach used for applying gestures to widgets can also be used with + graphics items. However, instead of passing a target object to the + gesture object's constructor, you set a target graphics item with the + \l{QGesture::}{setGraphicsItem()} function. + + \section1 Creating Your Own Gesture Recognizer QGesture is a base class for a user defined gesture recognizer class. In order to implement the recognizer you will need to subclass the - QGesture class and implement the pure virtual function \l{QGesture::filterEvent()}{filterEvent()}. Once - you have implemented the \l{QGesture::filterEvent()}{filterEvent()} function to + QGesture class and implement the pure virtual function + \l{QGesture::}{filterEvent()} to filter out events that are not relevant + to your gesture. + + Once you have implemented the \l{QGesture::}{filterEvent()} function to make your own recognizer you can process events. A sequence of events may, according to your own rules, represent a gesture. The events can be singly - passed to the recognizer via the \l{QGesture::filterEvent()}{filterEvent()} function or as a stream of - events by specifying a parent source of events. The events can be from any - source and could result in any action as defined by the user. The source - and action need not be graphical though that would be the most likely - scenario. To find how to connect a source of events to automatically feed into the recognizer see QGesture. + passed to the recognizer via the \l{QGesture::}{filterEvent()} function + or as a stream of events by specifying a parent source of events. The events + can be from any source and could result in any action as defined by the user. + The source and action need not be graphical, though that would be the most + likely scenario. To find how to connect a source of events to automatically + feed into the recognizer see the QGesture documentation. Recognizers based on QGesture can emit any of the following signals: \snippet doc/src/snippets/gestures/qgesture.h qgesture-signals These signals are emitted when the state changes with the call to - \l{QGesture::updateState()}{updateState()}, more than one signal may + \l{QGesture::}{updateState()}, more than one signal may be emitted when a change of state occurs. There are four GestureStates \table - \header \o New State \o Description \o QGesture Actions on Entering this State - \row \o Qt::NoGesture \o Initial value \o emit \l {QGesture::canceled()}{canceled()} - \row \o Qt::GestureStarted \o A continuous gesture has started \o emit \l{QGesture::started()}{started()} and emit \l{QGesture::triggered()}{triggered()} - \row \o Qt::GestureUpdated \o A gesture continues \o emit \l{QGesture::triggered()}{triggered()} - \row \o Qt::GestureFinished \o A gesture has finished. \o emit \l{QGesture::finished()}{finished()} + \header \o New State \o Description \o QGesture Actions on Entering this State + \row \o Qt::NoGesture \o Initial value \o emit \l {QGesture::}{cancelled()} + \row \o Qt::GestureStarted \o A continuous gesture has started \o emit \l{QGesture::}{started()} and emit \l{QGesture::}{triggered()} + \row \o Qt::GestureUpdated \o A gesture continues \o emit \l{QGesture::}{triggered()} + \row \o Qt::GestureFinished \o A gesture has finished. \o emit \l{QGesture::}{finished()} \endtable \note \l{QGesture::started()}{started()} can be emitted if entering any @@ -105,12 +165,12 @@ conclude with a call to \l{QGesture::updateState()}{updateState()} to change the current state to Qt::NoGesture. - \section1 An Example, ImageViewer + \section1 The ImageViewer Example To illustrate how to use QGesture we will look at the ImageViewer - example. This example uses QPanGesture, standard gesture, and an + example. This example uses QPanGesture, a standard gesture, and an implementation of TapAndHoldGesture. Note that TapAndHoldGesture is - platform dependent. + platform-dependent. \snippet doc/src/snippets/gestures/imageviewer/tapandholdgesture.cpp tapandhold-reset @@ -156,8 +216,8 @@ Following the logic of how the QEvent is processed we can summmarize it as follows: \list - \o filterEvent() becomes the event filter of the parent ImageWidget object for a QPanGesture object and a - TapAndHoldGesture object. + \o filterEvent() becomes the event filter of the parent ImageWidget object + for a QPanGesture object and a TapAndHoldGesture object. \o filterEvent() then calls updateState() to change states \o updateState() emits the appropriate signal(s) for the state change. \o The signals are caught by the defined slots in ImageWidget diff --git a/doc/src/modules.qdoc b/doc/src/modules.qdoc index 1dfadbe..5bcaffc 100644 --- a/doc/src/modules.qdoc +++ b/doc/src/modules.qdoc @@ -581,8 +581,10 @@ \legalese This file is part of the KDE project - Copyright (C) 2005-2007 Matthias Kretz <kretz@kde.org> \BR - Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + Copyright (C) 2004-2009 Matthias Kretz <kretz@kde.org> \BR + Copyright (C) 2008 Ian Monroe <ian@monroe.nu> \BR + Copyright (C) 2007-2008 Trolltech ASA \BR + Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). \BR Contact: Nokia Corporation (qt-info@nokia.com) This library is free software; you can redistribute it and/or diff --git a/examples/gestures/imageviewer/imagewidget.cpp b/examples/gestures/imageviewer/imagewidget.cpp index 53a9eb2..e17d746 100644 --- a/examples/gestures/imageviewer/imagewidget.cpp +++ b/examples/gestures/imageviewer/imagewidget.cpp @@ -71,8 +71,12 @@ ImageWidget::ImageWidget(QWidget *parent) connect(pinchGesture, SIGNAL(cancelled()), this, SLOT(pinchTriggered())); connect(pinchGesture, SIGNAL(triggered()), this, SLOT(pinchTriggered())); +//! [construct swipe gesture] QGesture *swipeGesture = new QSwipeGesture(this); +//! [construct swipe gesture] +//! [connect swipe gesture] connect(swipeGesture, SIGNAL(triggered()), this, SLOT(swipeTriggered())); +//! [connect swipe gesture] } void ImageWidget::paintEvent(QPaintEvent*) @@ -130,12 +134,15 @@ void ImageWidget::pinchTriggered() update(); } +//! [swipe slot start] void ImageWidget::swipeTriggered() { QSwipeGesture *pg = qobject_cast<QSwipeGesture*>(sender()); +//! [swipe slot start] qDebug() << (int) pg->horizontalDirection(); qDebug() << pg->swipeAngle(); +//! [swipe slot finish] if (pg->horizontalDirection() == QSwipeGesture::Left || pg->verticalDirection() == QSwipeGesture::Up) goPrevImage(); @@ -143,6 +150,7 @@ void ImageWidget::swipeTriggered() goNextImage(); update(); } +//! [swipe slot finish] void ImageWidget::resizeEvent(QResizeEvent*) { @@ -245,5 +253,3 @@ void ImageWidget::goToImage(int index) nextImage = QImage(); update(); } - -#include "moc_imagewidget.cpp" diff --git a/examples/multimedia/audio/audiodevices/audiodevicesbase.ui b/examples/multimedia/audio/audiodevices/audiodevicesbase.ui index 674f201..29dd40e 100644 --- a/examples/multimedia/audio/audiodevices/audiodevicesbase.ui +++ b/examples/multimedia/audio/audiodevices/audiodevicesbase.ui @@ -1,7 +1,8 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <class>AudioDevicesBase</class> - <widget class="QMainWindow" name="AudioDevicesBase" > - <property name="geometry" > + <widget class="QMainWindow" name="AudioDevicesBase"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> @@ -9,246 +10,223 @@ <height>702</height> </rect> </property> - <property name="windowTitle" > + <property name="windowTitle"> <string>AudioDevicesBase</string> </property> - <widget class="QWidget" name="centralwidget" > - <property name="geometry" > - <rect> - <x>0</x> - <y>28</y> - <width>504</width> - <height>653</height> - </rect> - </property> - <widget class="QWidget" name="layoutWidget" > - <property name="geometry" > - <rect> - <x>40</x> - <y>21</y> - <width>321</width> - <height>506</height> - </rect> - </property> - <layout class="QGridLayout" name="gridLayout" > - <item row="0" column="0" > - <widget class="QLabel" name="deviceLabel" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text" > - <string>Device</string> - </property> - </widget> - </item> - <item row="0" column="1" > - <widget class="QLabel" name="modeLabel" > - <property name="text" > - <string>Mode</string> - </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QComboBox" name="deviceBox" /> - </item> - <item row="1" column="1" > - <widget class="QComboBox" name="modeBox" /> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="actualLabel" > - <property name="frameShape" > - <enum>QFrame::Panel</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Raised</enum> - </property> - <property name="text" > - <string>Actual Settings</string> - </property> - <property name="alignment" > - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="2" column="1" > - <widget class="QLabel" name="nearestLabel" > - <property name="frameShape" > - <enum>QFrame::Panel</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Raised</enum> - </property> - <property name="text" > - <string>Nearest Settings</string> - </property> - <property name="alignment" > - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item row="3" column="0" > - <widget class="QLabel" name="actualFreqLabel" > - <property name="text" > - <string>Frequency</string> - </property> - </widget> - </item> - <item row="3" column="1" > - <widget class="QLabel" name="nearestFreqLabel" > - <property name="text" > - <string>Frequency</string> - </property> - </widget> - </item> - <item row="4" column="0" > - <widget class="QComboBox" name="frequencyBox" /> - </item> - <item row="4" column="1" > - <widget class="QLineEdit" name="nearestFreq" /> - </item> - <item row="5" column="0" > - <widget class="QLabel" name="actualChannelsLabel" > - <property name="text" > - <string>Channels</string> - </property> - </widget> - </item> - <item row="5" column="1" > - <widget class="QLabel" name="nearestChannelLabel" > - <property name="text" > - <string>Channel</string> - </property> - </widget> - </item> - <item row="6" column="0" > - <widget class="QComboBox" name="channelsBox" /> - </item> - <item row="6" column="1" > - <widget class="QLineEdit" name="nearestChannel" /> - </item> - <item row="7" column="0" > - <widget class="QLabel" name="actualCodecLabel" > - <property name="text" > - <string>Codecs</string> - </property> - </widget> - </item> - <item row="7" column="1" > - <widget class="QLabel" name="nearestCodecLabel" > - <property name="text" > - <string>Codec</string> - </property> - </widget> - </item> - <item row="8" column="0" > - <widget class="QComboBox" name="codecsBox" /> - </item> - <item row="8" column="1" > - <widget class="QLineEdit" name="nearestCodec" /> - </item> - <item row="9" column="0" > - <widget class="QLabel" name="actualSampleSizeLabel" > - <property name="text" > - <string>SampleSize</string> - </property> - </widget> - </item> - <item row="9" column="1" > - <widget class="QLabel" name="nearestSampleSizeLabel" > - <property name="text" > - <string>SampleSize</string> - </property> - </widget> - </item> - <item row="10" column="0" > - <widget class="QComboBox" name="sampleSizesBox" /> - </item> - <item row="10" column="1" > - <widget class="QLineEdit" name="nearestSampleSize" /> - </item> - <item row="11" column="0" > - <widget class="QLabel" name="actualSampleTypeLabel" > - <property name="text" > - <string>SampleType</string> - </property> - </widget> - </item> - <item row="11" column="1" > - <widget class="QLabel" name="nearestSampleTypeLabel" > - <property name="text" > - <string>SampleType</string> - </property> - </widget> - </item> - <item row="12" column="0" > - <widget class="QComboBox" name="sampleTypesBox" /> - </item> - <item row="12" column="1" > - <widget class="QLineEdit" name="nearestSampleType" /> - </item> - <item row="13" column="0" > - <widget class="QLabel" name="actualEndianLabel" > - <property name="text" > - <string>Endianess</string> - </property> - </widget> - </item> - <item row="13" column="1" > - <widget class="QLabel" name="nearestEndianLabel" > - <property name="text" > - <string>Endianess</string> - </property> - </widget> - </item> - <item row="14" column="0" > - <widget class="QComboBox" name="endianBox" /> - </item> - <item row="14" column="1" > - <widget class="QLineEdit" name="nearestEndian" /> - </item> - <item row="15" column="0" colspan="2" > - <widget class="QTextEdit" name="logOutput" > - <property name="minimumSize" > - <size> - <width>0</width> - <height>40</height> - </size> - </property> - </widget> - </item> - <item row="16" column="0" colspan="2" > - <widget class="QPushButton" name="testButton" > - <property name="text" > - <string>Test</string> - </property> - </widget> - </item> - </layout> - </widget> + <widget class="QWidget" name="centralwidget"> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="deviceLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Device</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="modeLabel"> + <property name="text"> + <string>Mode</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QComboBox" name="deviceBox"/> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="modeBox"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="actualLabel"> + <property name="frameShape"> + <enum>QFrame::Panel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <property name="text"> + <string>Actual Settings</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="nearestLabel"> + <property name="frameShape"> + <enum>QFrame::Panel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <property name="text"> + <string>Nearest Settings</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="actualFreqLabel"> + <property name="text"> + <string>Frequency</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="nearestFreqLabel"> + <property name="text"> + <string>Frequency</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QComboBox" name="frequencyBox"/> + </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="nearestFreq"/> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="actualChannelsLabel"> + <property name="text"> + <string>Channels</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLabel" name="nearestChannelLabel"> + <property name="text"> + <string>Channel</string> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QComboBox" name="channelsBox"/> + </item> + <item row="6" column="1"> + <widget class="QLineEdit" name="nearestChannel"/> + </item> + <item row="7" column="0"> + <widget class="QLabel" name="actualCodecLabel"> + <property name="text"> + <string>Codecs</string> + </property> + </widget> + </item> + <item row="7" column="1"> + <widget class="QLabel" name="nearestCodecLabel"> + <property name="text"> + <string>Codec</string> + </property> + </widget> + </item> + <item row="8" column="0"> + <widget class="QComboBox" name="codecsBox"/> + </item> + <item row="8" column="1"> + <widget class="QLineEdit" name="nearestCodec"/> + </item> + <item row="9" column="0"> + <widget class="QLabel" name="actualSampleSizeLabel"> + <property name="text"> + <string>SampleSize</string> + </property> + </widget> + </item> + <item row="9" column="1"> + <widget class="QLabel" name="nearestSampleSizeLabel"> + <property name="text"> + <string>SampleSize</string> + </property> + </widget> + </item> + <item row="10" column="0"> + <widget class="QComboBox" name="sampleSizesBox"/> + </item> + <item row="10" column="1"> + <widget class="QLineEdit" name="nearestSampleSize"/> + </item> + <item row="11" column="0"> + <widget class="QLabel" name="actualSampleTypeLabel"> + <property name="text"> + <string>SampleType</string> + </property> + </widget> + </item> + <item row="11" column="1"> + <widget class="QLabel" name="nearestSampleTypeLabel"> + <property name="text"> + <string>SampleType</string> + </property> + </widget> + </item> + <item row="12" column="0"> + <widget class="QComboBox" name="sampleTypesBox"/> + </item> + <item row="12" column="1"> + <widget class="QLineEdit" name="nearestSampleType"/> + </item> + <item row="13" column="0"> + <widget class="QLabel" name="actualEndianLabel"> + <property name="text"> + <string>Endianess</string> + </property> + </widget> + </item> + <item row="13" column="1"> + <widget class="QLabel" name="nearestEndianLabel"> + <property name="text"> + <string>Endianess</string> + </property> + </widget> + </item> + <item row="14" column="0"> + <widget class="QComboBox" name="endianBox"/> + </item> + <item row="14" column="1"> + <widget class="QLineEdit" name="nearestEndian"/> + </item> + <item row="15" column="0" colspan="2"> + <widget class="QTextEdit" name="logOutput"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>40</height> + </size> + </property> + </widget> + </item> + <item row="16" column="0" colspan="2"> + <widget class="QPushButton" name="testButton"> + <property name="text"> + <string>Test</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> </widget> - <widget class="QMenuBar" name="menubar" > - <property name="geometry" > + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>504</width> - <height>28</height> - </rect> - </property> - </widget> - <widget class="QStatusBar" name="statusbar" > - <property name="geometry" > - <rect> - <x>0</x> - <y>681</y> - <width>504</width> - <height>21</height> + <height>22</height> </rect> </property> </widget> + <widget class="QStatusBar" name="statusbar"/> </widget> <resources/> <connections/> diff --git a/examples/opengl/pbuffers2/glwidget.cpp b/examples/opengl/pbuffers2/glwidget.cpp index e1c9b5c..e4d320b 100644 --- a/examples/opengl/pbuffers2/glwidget.cpp +++ b/examples/opengl/pbuffers2/glwidget.cpp @@ -136,6 +136,7 @@ void GLWidget::draw() QPainter p(this); // used for text overlay // save the GL state set for QPainter + p.beginNativePainting(); saveGLState(); // render the 'bubbles.svg' file into our pbuffer @@ -206,6 +207,7 @@ void GLWidget::draw() // restore the GL state that QPainter expects restoreGLState(); + p.endNativePainting(); // draw the overlayed text using QPainter p.setPen(QColor(197, 197, 197, 157)); diff --git a/mkspecs/common/mac-g++.conf b/mkspecs/common/mac-g++.conf index dca2e2f..1863898 100644 --- a/mkspecs/common/mac-g++.conf +++ b/mkspecs/common/mac-g++.conf @@ -65,6 +65,8 @@ QMAKE_LFLAGS_PPC += -arch ppc QMAKE_LFLAGS_X86 += -arch i386 QMAKE_LFLAGS_VERSION += -current_version$${LITERAL_WHITESPACE} QMAKE_LFLAGS_COMPAT_VERSION += -compatibility_version$${LITERAL_WHITESPACE} +# -all_load requred to make Objective-C categories work in static builds. +QMAKE_LFLAGS_STATIC_LIB += -all_load QMAKE_RPATH += QMAKE_PCH_OUTPUT_EXT = .gch diff --git a/mkspecs/features/static.prf b/mkspecs/features/static.prf index 6e2b54f..7ee7a8a 100644 --- a/mkspecs/features/static.prf +++ b/mkspecs/features/static.prf @@ -6,4 +6,10 @@ contains(TEMPLATE, ".*lib"):{ QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_STATIC_LIB } } + +mac { + QMAKE_LFLAGS += $$QMAKE_LFLAGS_STATIC_LIB + CONFIG += hide_symbols +} + !static_and_shared:fix_output_dirs:fixExclusiveOutputDirs(static, shared) diff --git a/mkspecs/macx-g++40/Info.plist.app b/mkspecs/macx-g++40/Info.plist.app new file mode 100644 index 0000000..393b615 --- /dev/null +++ b/mkspecs/macx-g++40/Info.plist.app @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> +<plist version="0.9"> +<dict> + <key>CFBundleIconFile</key> + <string>@ICON@</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleGetInfoString</key> + <string>Created by Qt/QMake</string> + <key>CFBundleSignature</key> + <string>@TYPEINFO@</string> + <key>CFBundleExecutable</key> + <string>@EXECUTABLE@</string> + <key>CFBundleIdentifier</key> + <string>com.yourcompany.@EXECUTABLE@</string> + <key>NOTE</key> + <string>This file was generated by Qt/QMake.</string> +</dict> +</plist> diff --git a/mkspecs/macx-g++40/Info.plist.lib b/mkspecs/macx-g++40/Info.plist.lib new file mode 100644 index 0000000..97609ed --- /dev/null +++ b/mkspecs/macx-g++40/Info.plist.lib @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> +<plist version="0.9"> +<dict> + <key>CFBundlePackageType</key> + <string>FMWK</string> + <key>CFBundleShortVersionString</key> + <string>@SHORT_VERSION@</string> + <key>CFBundleGetInfoString</key> + <string>Created by Qt/QMake</string> + <key>CFBundleSignature</key> + <string>@TYPEINFO@</string> + <key>CFBundleExecutable</key> + <string>@LIBRARY@</string> + <key>NOTE</key> + <string>Please, do NOT change this file -- It was generated by Qt/QMake.</string> +</dict> +</plist> diff --git a/mkspecs/macx-g++40/qmake.conf b/mkspecs/macx-g++40/qmake.conf new file mode 100644 index 0000000..d6fd09d --- /dev/null +++ b/mkspecs/macx-g++40/qmake.conf @@ -0,0 +1,20 @@ +#macx-g++ (different from g++.conf) + +# +# qmake configuration for macx-g++ +# +# Mac OS X + command-line compiler +# + +MAKEFILE_GENERATOR = UNIX +TEMPLATE = app +CONFIG += qt warn_on release app_bundle incremental global_init_link_order lib_version_first plugin_no_soname link_prl +QT += core gui +QMAKE_INCREMENTAL_STYLE = sublib + +QMAKE_CC = gcc-4.0 +QMAKE_CXX = g++-4.0 + +include(../common/mac-g++.conf) + +load(qt_config) diff --git a/mkspecs/macx-g++40/qplatformdefs.h b/mkspecs/macx-g++40/qplatformdefs.h new file mode 100644 index 0000000..98e5eaf --- /dev/null +++ b/mkspecs/macx-g++40/qplatformdefs.h @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef QPLATFORMDEFS_H +#define QPLATFORMDEFS_H + +// Get Qt defines/settings + +#include "qglobal.h" + +// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs + +#include <unistd.h> + + +// We are hot - unistd.h should have turned on the specific APIs we requested + + +#include <pthread.h> +#include <dirent.h> +#include <fcntl.h> +#include <grp.h> +#include <pwd.h> +#include <signal.h> +#define QT_NO_LIBRARY_UNLOAD + +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/ipc.h> +#include <sys/time.h> +#include <sys/shm.h> +#include <sys/socket.h> +#include <sys/stat.h> +#include <sys/wait.h> +#include <netinet/in.h> +#ifndef QT_NO_IPV6IFNAME +#include <net/if.h> +#endif + +#define QT_FOPEN ::fopen +#define QT_FSEEK ::fseeko +#define QT_FTELL ::ftello +#define QT_FGETPOS ::fgetpos +#define QT_FSETPOS ::fsetpos +#define QT_FPOS_T fpos_t +#define QT_OFF_T off_t + +#define QT_STATBUF struct stat +#define QT_STATBUF4TSTAT struct stat +#define QT_STAT ::stat +#define QT_FSTAT ::fstat +#define QT_LSTAT ::lstat +#define QT_STAT_REG S_IFREG +#define QT_STAT_DIR S_IFDIR +#define QT_STAT_MASK S_IFMT +#define QT_STAT_LNK S_IFLNK +#define QT_SOCKET_CONNECT ::connect +#define QT_SOCKET_BIND ::bind +#define QT_FILENO fileno +#define QT_OPEN ::open +#define QT_CLOSE ::close +#define QT_TRUNCATE ::truncate +#define QT_FTRUNCATE ::ftruncate +#define QT_LSEEK ::lseek +#define QT_READ ::read +#define QT_WRITE ::write +#define QT_ACCESS ::access +#define QT_GETCWD ::getcwd +#define QT_CHDIR ::chdir +#define QT_MKDIR ::mkdir +#define QT_RMDIR ::rmdir +#define QT_OPEN_LARGEFILE 0 +#define QT_OPEN_RDONLY O_RDONLY +#define QT_OPEN_WRONLY O_WRONLY +#define QT_OPEN_RDWR O_RDWR +#define QT_OPEN_CREAT O_CREAT +#define QT_OPEN_TRUNC O_TRUNC +#define QT_OPEN_APPEND O_APPEND + +#define QT_SIGNAL_RETTYPE void +#define QT_SIGNAL_ARGS int +#define QT_SIGNAL_IGNORE (void (*)(int))1 + +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) +#define QT_SOCKLEN_T socklen_t +#else +#define QT_SOCKLEN_T int +#endif + +#define QT_SNPRINTF ::snprintf +#define QT_VSNPRINTF ::vsnprintf + + +#endif // QPLATFORMDEFS_H diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp index 1268d3d..d7fbce8 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp @@ -233,7 +233,9 @@ void Heap::destroy() template <HeapType heapType> static NEVER_INLINE CollectorBlock* allocateBlock() { -#if PLATFORM(DARWIN) + // Disable the use of vm_map for the Qt build on Darwin, because when compiled on 10.4 + // it crashes on 10.5 +#if PLATFORM(DARWIN) && !PLATFORM(QT) vm_address_t address = 0; // FIXME: tag the region as a JavaScriptCore heap when we get a registered VM tag: <rdar://problem/6054788>. vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE | VM_TAG_FOR_COLLECTOR_MEMORY, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT); @@ -285,7 +287,9 @@ static NEVER_INLINE CollectorBlock* allocateBlock() static void freeBlock(CollectorBlock* block) { -#if PLATFORM(DARWIN) + // Disable the use of vm_deallocate for the Qt build on Darwin, because when compiled on 10.4 + // it crashes on 10.5 +#if PLATFORM(DARWIN) && !PLATFORM(QT) vm_deallocate(current_task(), reinterpret_cast<vm_address_t>(block), BLOCK_SIZE); #elif PLATFORM(SYMBIAN) userChunk->Free(reinterpret_cast<TAny*>(block)); diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc index e3c904b..09dfae5 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc +++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit.qdoc @@ -139,15 +139,18 @@ \section1 Netscape Plugin Support + \note Netscape plugin support is only available on desktop platforms. + Since WebKit supports the Netscape Plugin API, Qt applications can display - Web pages that embed common plugins, as long as the user has the appropriate + Web pages that embed common plugins on platforms for which those plugins + are available. To enable plugin support, the user must have the appropriate binary files for those plugins installed and the \l{QWebSettings::PluginsEnabled} - attribute is enabled for the application. + attribute must be enabled for the application. The following locations are searched for plugins: \table - \header \o Linux/Unix \o Windows + \header \o Linux/Unix (X11) \o Windows \row \o{1,3} \list \o \c{.mozilla/plugins} in the user's home directory diff --git a/src/corelib/io/qfile.h b/src/corelib/io/qfile.h index b52780d..f65c845 100644 --- a/src/corelib/io/qfile.h +++ b/src/corelib/io/qfile.h @@ -116,7 +116,7 @@ public: static QByteArray encodeName(const QString &fileName); static QString decodeName(const QByteArray &localFileName); inline static QString decodeName(const char *localFileName) - { return decodeName(QByteArray(localFileName)); }; + { return decodeName(QByteArray(localFileName)); } static void setEncodingFunction(EncoderFn); static void setDecodingFunction(DecoderFn); diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index b779aa3..fb096a7 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -157,7 +157,15 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) #endif separatorPos = tmpPath.indexOf(slash, separatorPos + 1); QString prefix = separatorPos == -1 ? tmpPath : tmpPath.left(separatorPos); - if (!nonSymlinks.contains(prefix)) { + if ( +#ifdef Q_OS_SYMBIAN + // Symbian doesn't support directory symlinks, so do not check for link unless we + // are handling the last path element. This not only slightly improves performance, + // but also saves us from lot of unnecessary platform security check failures + // when dealing with files under *:/private directories. + separatorPos == -1 && +#endif + !nonSymlinks.contains(prefix)) { fi.setFile(prefix); if (fi.isSymLink()) { QString target = fi.symLinkTarget(); diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 763589a..898447c 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1954,7 +1954,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, #endif if (handle == INVALID_HANDLE_VALUE) { - q->setError(QFile::UnspecifiedError, QLatin1String("No handle on file")); + q->setError(QFile::PermissionsError, qt_error_string(ERROR_ACCESS_DENIED)); return 0; } diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 3dbde3f..51e8d00 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1806,18 +1806,35 @@ QString QCoreApplication::applicationDirPath() RProcess proc; TInt err = proc.Open(proc.Id()); if (err == KErrNone) { + QChar driveChar; #if defined(Q_CC_NOKIAX86) // In emulator, always resolve the private dir on C-drive - appPath.append(QChar('C')); + driveChar = QLatin1Char('C'); #else - appPath.append(QChar((proc.FileName())[0])); + driveChar = QLatin1Char((proc.FileName())[0]); #endif - appPath.append(QLatin1String(":\\private\\")); - QString sid; - sid.setNum(proc.SecureId().iId, 16); - appPath.append(sid); - appPath.append(QLatin1Char('\\')); proc.Close(); + + driveChar = driveChar.toUpper(); + + TFileName privatePath; + RFs& fs = qt_s60GetRFs(); + fs.PrivatePath(privatePath); + appPath = qt_TDesC2QString(privatePath); + appPath.prepend(QLatin1Char(':')).prepend(driveChar); + + // Create the appPath if it doesn't exist. Non-existing appPath will cause + // Platform Security violations later on if the app doesn't have AllFiles capability. + // Can't create appPath for ROM unfortunately, so applications meant for + // ROM should always deploy something to their private dir to ensure appPath exists, + // if the PlatSec violations are an issue. + char driveDiff = QLatin1Char('Z').toLatin1() - driveChar.toLatin1(); + TInt driveId = EDriveZ - static_cast<TInt>(driveDiff); + if (driveId != EDriveZ) { + TInt err = fs.CreatePrivatePath(driveId); + if (err != KErrNone) + qWarning("QCoreApplication::applicationDirPath: Failed to create private path."); + } } QFileInfo fi(appPath); diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index c05c4ef..622e9b6 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -84,7 +84,7 @@ public Q_SLOTS: void stop(); #ifdef QT3_SUPPORT - inline QT_MOC_COMPAT void changeInterval(int msec) { start(msec); }; + inline QT_MOC_COMPAT void changeInterval(int msec) { start(msec); } QT_MOC_COMPAT int start(int msec, bool sshot); #endif diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index b71c8b5..23bb07c 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -48,6 +48,11 @@ #include "qdebug.h" #include "qdir.h" +#if defined(Q_OS_SYMBIAN) +# include <f32file.h> +# include "private/qcore_symbian_p.h" +#endif + #ifndef QT_NO_LIBRARY QT_BEGIN_NAMESPACE @@ -309,10 +314,18 @@ void QPluginLoader::setFileName(const QString &fileName) if (stubPath.at(1).toAscii() == ':') stubPath.remove(0,2); QFileInfoList driveList(QDir::drives()); + RFs rfs = qt_s60GetRFs(); foreach(const QFileInfo& drive, driveList) { QString testFilePath(drive.absolutePath() + stubPath); testFilePath = QDir::cleanPath(testFilePath); - if (QFile::exists(testFilePath)) { + // Use native Symbian code to check for file existence, because checking + // for file from under non-existent protected dir like E:/private/<uid> using + // QFile::exists causes platform security violations on most apps. + QString nativePath = QDir::toNativeSeparators(testFilePath); + TPtrC ptr(qt_QString2TPtrC(nativePath)); + TUint attributes; + TInt err = rfs.Att(ptr, attributes); + if (err == KErrNone) { fn = testFilePath; break; } diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index 2150ccb..f5441a3 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -48,6 +48,7 @@ QT_BEGIN_NAMESPACE /*! \class QMargins \ingroup painting + \since 4.6 \brief The QMargins class defines the four margins of a rectangle. diff --git a/src/gui/egl/egl.pri b/src/gui/egl/egl.pri index 75a3d91..22c8bd7 100644 --- a/src/gui/egl/egl.pri +++ b/src/gui/egl/egl.pri @@ -21,7 +21,7 @@ unix { } for(p, QMAKE_LIBDIR_EGL) { - exists($$p):LIBS += -L$$p + exists($$p):LIBS_PRIVATE += -L$$p } !isEmpty(QMAKE_INCDIR_EGL): INCLUDEPATH += $$QMAKE_INCDIR_EGL diff --git a/src/gui/embedded/qwssharedmemory_p.h b/src/gui/embedded/qwssharedmemory_p.h index fabd2dd..1d0d090 100644 --- a/src/gui/embedded/qwssharedmemory_p.h +++ b/src/gui/embedded/qwssharedmemory_p.h @@ -68,7 +68,7 @@ public: void setPermissions(mode_t mode); int size() const; - void *address() { return shmBase; }; + void *address() { return shmBase; } int id() const { return shmId; } @@ -82,7 +82,7 @@ public: // old API QWSSharedMemory(int, const QString &, char c = 'Q'); - void * base() { return address(); }; + void * base() { return address(); } bool create(); void destroy(); diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index d67011b..9c0c649 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -335,10 +335,6 @@ it's parent if it's z-value is negative. This flag enables setZValue() to toggle ItemStacksBehindParent. - \value ItemAutoDetectsFocusProxy The item will assign any child that - gains input focus as its focus proxy. See also focusProxy(). - This flag was introduced in Qt 4.6. - \value ItemIsPanel. The item is a panel. A panel provides activation and contained focus handling. Only one panel can be active at a time (see QGraphicsItem::isActive()). When no panel is active, QGraphicsScene @@ -954,17 +950,6 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) parent->itemChange(QGraphicsItem::ItemChildRemovedChange, thisPointerVariant); } - // Auto-update focus proxy. Any ancestor that has this as focus proxy - //needs to be nulled. - QGraphicsItem *p = parent; - while (p) { - if ((p->d_ptr->flags & QGraphicsItem::ItemAutoDetectsFocusProxy) && - (p->focusProxy() == q)) { - p->setFocusProxy(0); - } - p = p->d_ptr->parent; - } - // Update toplevelitem list. If this item is being deleted, its parent // will be 0 but we don't want to register/unregister it in the TLI list. if (scene && !inDestructor) { @@ -1041,18 +1026,11 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) dirtySceneTransform = 1; // Restore the sub focus chain. - if (lastSubFocusItem) - lastSubFocusItem->d_ptr->setSubFocus(); - - // Auto-update focus proxy. The closest parent that detects - // focus proxies is updated as the proxy gains or loses focus. - p = newParent; - while (p) { - if (p->d_ptr->flags & QGraphicsItem::ItemAutoDetectsFocusProxy) { - p->setFocusProxy(q); - break; - } - p = p->d_ptr->parent; + if (lastSubFocusItem) { + if (parent && parent->isActive()) + lastSubFocusItem->setFocus(); + else + lastSubFocusItem->d_ptr->setSubFocus(); } // Deliver post-change notification @@ -1220,6 +1198,7 @@ QGraphicsItem::~QGraphicsItem() d_ptr->removeExtraItemCache(); clearFocus(); + if (!d_ptr->children.isEmpty()) { QList<QGraphicsItem *> oldChildren = d_ptr->children; qDeleteAll(oldChildren); @@ -2772,7 +2751,7 @@ void QGraphicsItem::setFocus(Qt::FocusReason focusReason) // Update the scene's focus item. if (d_ptr->scene) { QGraphicsItem *p = panel(); - if (!p || p->isActive()) { + if ((!p && d_ptr->scene->isActive()) || (p && p->isActive())) { // Visible items immediately gain focus from scene. d_ptr->scene->d_func()->setFocusItemHelper(f, focusReason); } @@ -2792,10 +2771,9 @@ void QGraphicsItem::setFocus(Qt::FocusReason focusReason) */ void QGraphicsItem::clearFocus() { - if (!d_ptr->scene) - return; // Invisible items with focus must explicitly clear subfocus. d_ptr->clearSubFocus(); + if (hasFocus()) { // If this item has the scene's input focus, clear it. d_ptr->scene->setFocusItem(0); @@ -2808,7 +2786,7 @@ void QGraphicsItem::clearFocus() Returns this item's focus proxy, or 0 if this item has no focus proxy. - \sa setFocusProxy(), ItemAutoDetectsFocusProxy, setFocus(), hasFocus() + \sa setFocusProxy(), setFocus(), hasFocus() */ QGraphicsItem *QGraphicsItem::focusProxy() const { @@ -2832,7 +2810,7 @@ QGraphicsItem *QGraphicsItem::focusProxy() const The focus proxy \a item must belong to the same scene as this item. - \sa focusProxy(), ItemAutoDetectsFocusProxy, setFocus(), hasFocus() + \sa focusProxy(), setFocus(), hasFocus() */ void QGraphicsItem::setFocusProxy(QGraphicsItem *item) { @@ -4876,13 +4854,21 @@ void QGraphicsItemPrivate::ensureSceneTransform() */ void QGraphicsItemPrivate::setSubFocus() { - // Update focus child chain. - QGraphicsItem *item = q_ptr; - QGraphicsItem *parent = item; - bool hidden = !visible; + // Update focus child chain. Stop at panels, or if this item + // is hidden, stop at the first item with a visible parent. + QGraphicsItem *parent = q_ptr; do { - parent->d_func()->subFocusItem = item; - } while (!parent->isPanel() && (parent = parent->d_ptr->parent) && (!hidden || !parent->d_func()->visible)); + // Clear any existing ancestor's subFocusItem. + if (parent != q_ptr && parent->d_ptr->subFocusItem) { + if (parent->d_ptr->subFocusItem == q_ptr) + break; + parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(); + } + parent->d_ptr->subFocusItem = q_ptr; + } while (!parent->isPanel() && (parent = parent->d_ptr->parent) && (visible || !parent->d_ptr->visible)); + + if (!parent && scene && !scene->isActive()) + scene->d_func()->lastFocusItem = q_ptr; } /*! @@ -4890,7 +4876,7 @@ void QGraphicsItemPrivate::setSubFocus() */ void QGraphicsItemPrivate::clearSubFocus() { - // Reset focus child chain. + // Reset sub focus chain. QGraphicsItem *parent = q_ptr; do { if (parent->d_ptr->subFocusItem != q_ptr) @@ -10568,9 +10554,6 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag) case QGraphicsItem::ItemNegativeZStacksBehindParent: str = "ItemNegativeZStacksBehindParent"; break; - case QGraphicsItem::ItemAutoDetectsFocusProxy: - str = "ItemAutoDetectsFocusProxy"; - break; case QGraphicsItem::ItemIsPanel: str = "ItemIsPanel"; break; diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 1b65700..1c969ba 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -103,9 +103,8 @@ public: ItemHasNoContents = 0x400, ItemSendsGeometryChanges = 0x800, ItemAcceptsInputMethod = 0x1000, - ItemAutoDetectsFocusProxy = 0x2000, - ItemNegativeZStacksBehindParent = 0x4000, - ItemIsPanel = 0x8000 + ItemNegativeZStacksBehindParent = 0x2000, + ItemIsPanel = 0x4000 // NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag. }; Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index ee4cfe0..0fd1647 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -653,19 +653,6 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, return; } - // Auto-update focus proxy. The closest parent that detects - // focus proxies is updated as the proxy gains or loses focus. - if (item) { - QGraphicsItem *p = item->d_ptr->parent; - while (p) { - if (p->d_ptr->flags & QGraphicsItem::ItemAutoDetectsFocusProxy) { - p->setFocusProxy(item); - break; - } - p = p->d_ptr->parent; - } - } - if (focusItem) { QFocusEvent event(QEvent::FocusOut, focusReason); lastFocusItem = focusItem; @@ -678,9 +665,14 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, QInputMethodEvent imEvent; sendEvent(lastFocusItem, &imEvent); - // Close any external input method panel - for (int i = 0; i < views.size(); ++i) - views.at(i)->inputContext()->reset(); + // Close any external input method panel. This happens + // automatically by removing WA_InputMethodEnabled on + // the views, but if we are changing focus, we have to + // do it ourselves. + if (item) { + for (int i = 0; i < views.size(); ++i) + views.at(i)->inputContext()->reset(); + } } } @@ -1398,6 +1390,7 @@ QGraphicsScene::QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObj QGraphicsScene::~QGraphicsScene() { Q_D(QGraphicsScene); + // Remove this scene from qApp's global scene list. qApp->d_func()->scene_list.removeAll(this); @@ -2438,7 +2431,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item) // Ensure that newly added items that have subfocus set, gain // focus automatically if there isn't a focus item already. - if (!d->focusItem && item->focusItem()) + if (!d->focusItem && item->focusItem() && item->isActive()) item->focusItem()->setFocus(); d->updateInputMethodSensitivityInViews(); diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 908b8a1..adc2967 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -68,41 +68,42 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QIconLoader, iconLoaderInstance) +static QString fallbackTheme() +{ + QString defaultTheme; +#ifdef Q_WS_X11 + if (X11->desktopEnvironment == DE_GNOME) + defaultTheme = QLatin1String("gnome"); + else if (X11->desktopEnvironment == DE_KDE) + defaultTheme = X11->desktopVersion >= 4 ? + QString::fromLatin1("oxygen") : + QString::fromLatin1("crystalsvg"); +#endif + return defaultTheme; +} + static QString systemThemeName() { - QString result; + QString result = fallbackTheme(); #ifdef Q_WS_X11 if (X11->desktopEnvironment == DE_GNOME) { -#if defined(QT_NO_STYLE_GTK) - result = QLatin1String("gnome"); -#else +#ifndef QT_NO_STYLE_GTK result = QGtk::getGConfString(QLatin1String("/desktop/gnome/interface/icon_theme"), - QLatin1String("gnome")); + result); #endif } else if (X11->desktopEnvironment == DE_KDE) { - QString kdeDefault = X11->desktopVersion >= 4 ? - QString::fromLatin1("oxygen") : - QString::fromLatin1("crystalsvg"); - QSettings settings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); settings.beginGroup(QLatin1String("Icons")); - result = settings.value(QLatin1String("Theme"), kdeDefault).toString(); + result = settings.value(QLatin1String("Theme"), result).toString(); } #endif return result; } -static QString fallbackTheme() -{ - QString defaultTheme = systemThemeName(); - if (defaultTheme.isEmpty()) - defaultTheme = QLatin1String("hicolor"); - return defaultTheme; -} QIconLoader::QIconLoader() : m_themeKey(1), m_supportsSvg(false) @@ -269,7 +270,7 @@ QIconTheme::QIconTheme(const QString &themeName) m_parents.append(fallbackTheme()); // Ensure that all themes fall back to hicolor - if (!m_parents.isEmpty()) + if (!m_parents.contains(QLatin1String("hicolor"))) m_parents.append(QLatin1String("hicolor")); } } diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index 86c7a50..216cfff 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -337,7 +337,7 @@ public: static inline QT3_SUPPORT const QColor &winStyleHighlightColor() { return palette().color(QPalette::Active, QPalette::Highlight); } static inline QT3_SUPPORT void setPalette(const QPalette &pal, bool, const char* className = 0) - { setPalette(pal, className); }; + { setPalette(pal, className); } static inline QT3_SUPPORT void setFont(const QFont &font, bool, const char* className = 0) { setFont(font, className); } diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index c899313..697b93a 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -685,7 +685,7 @@ public: QClipboardEvent(QEventPrivate *data); ~QClipboardEvent(); - QEventPrivate *data() { return d; }; + QEventPrivate *data() { return d; } }; #endif diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index af2b640..d85023b 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -138,7 +138,7 @@ public: #endif TTypeUid::Ptr MopSupplyObject(TTypeUid id); - inline QWidget* widget() const { return qwidget; }; + inline QWidget* widget() const { return qwidget; } void setWidget(QWidget *w); void sendInputEvent(QWidget *widget, QInputEvent *inputEvent); void setIgnoreFocusChanged(bool enabled) { m_ignoreFocusChanged = enabled; } diff --git a/src/gui/painting/qprintengine_ps_p.h b/src/gui/painting/qprintengine_ps_p.h index 827e4d9..704617e 100644 --- a/src/gui/painting/qprintengine_ps_p.h +++ b/src/gui/painting/qprintengine_ps_p.h @@ -95,7 +95,7 @@ public: virtual QPrinter::PrinterState printerState() const; - virtual Qt::HANDLE handle() const { return 0; }; + virtual Qt::HANDLE handle() const { return 0; } private: Q_DISABLE_COPY(QPSPrintEngine) diff --git a/src/gui/painting/qwindowsurface_qws_p.h b/src/gui/painting/qwindowsurface_qws_p.h index 2c45120..6c65db3 100644 --- a/src/gui/painting/qwindowsurface_qws_p.h +++ b/src/gui/painting/qwindowsurface_qws_p.h @@ -173,7 +173,7 @@ public: QPaintDevice *paintDevice() { return &img; } bool scroll(const QRegion &area, int dx, int dy); - QImage image() const { return img; }; + QImage image() const { return img; } QPoint painterOffset() const; bool lock(int timeout = -1); diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index f450d94..0aed71a 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -334,7 +334,7 @@ QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, bool create) else high = pos; pos = (high + low) / 2; - }; + } pos = low; } if (!create) @@ -693,7 +693,7 @@ QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create) else low = pos; pos = (high + low) / 2; - }; + } if (!res) return families[pos]; } diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 7cae784..ab2506c 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -74,7 +74,7 @@ QByteArray QFontEngineS60Extensions::getSfntTable(uint tag) const Q_ASSERT(m_trueTypeExtension->HasTrueTypeTable(tag)); TInt error = KErrNone; TInt tableByteLength = 0; - TAny *table = m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength); + TAny *table = q_check_ptr(m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength)); QByteArray result(static_cast<const char*>(table), tableByteLength); m_trueTypeExtension->ReleaseTrueTypeTable(table); return result; diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 4e367c9..8b85d2d 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -1328,6 +1328,8 @@ void QTextCursor::insertText(const QString &text, const QTextCharFormat &_format if (ch == QLatin1Char('\n') || ch == QChar::ParagraphSeparator + || ch == QTextBeginningOfFrame + || ch == QTextEndOfFrame || ch == QLatin1Char('\r')) { if (!hasEditBlock) { diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index c9b6c38..88837ca 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1594,11 +1594,13 @@ glyph_metrics_t QTextEngine::boundingBox(int from, int len) const for (int i = 0; i < layoutData->items.size(); i++) { const QScriptItem *si = layoutData->items.constData() + i; + QFontEngine *fe = fontEngine(*si); + int pos = si->position; int ilen = length(i); if (pos > from + len) break; - if (pos + len > from) { + if (pos + ilen > from) { if (!si->num_glyphs) shape(i); @@ -1631,7 +1633,6 @@ glyph_metrics_t QTextEngine::boundingBox(int from, int len) const charEnd++; glyphEnd = (charEnd == ilen) ? si->num_glyphs : logClusters[charEnd]; if (glyphStart <= glyphEnd ) { - QFontEngine *fe = fontEngine(*si); glyph_metrics_t m = fe->boundingBox(glyphs.mid(glyphStart, glyphEnd - glyphStart)); gm.x = qMin(gm.x, m.x + gm.xoff); gm.y = qMin(gm.y, m.y + gm.yoff); @@ -1641,6 +1642,10 @@ glyph_metrics_t QTextEngine::boundingBox(int from, int len) const gm.yoff += m.yoff; } } + + glyph_t glyph = glyphs.glyphs[logClusters[pos + ilen - 1]]; + glyph_metrics_t gi = fe->boundingBox(glyph); + gm.width -= qRound(gi.xoff - gi.x - gi.width); } } return gm; diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index 4674a01..00ceb98 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the S60 port of the Qt toolkit. +** This file is part of the S60 port of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 720bd62..d5a7982 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -1094,6 +1094,8 @@ void QMenuBar::mousePressEvent(QMouseEvent *e) if(e->button() != Qt::LeftButton) return; + d->mouseDown = true; + QAction *action = d->actionAt(e->pos()); if (!action || !d->isVisible(action)) { d->setCurrentAction(0); @@ -1104,8 +1106,6 @@ void QMenuBar::mousePressEvent(QMouseEvent *e) return; } - d->mouseDown = true; - if(d->currentAction == action && d->popupState) { if(QMenu *menu = d->activeMenu) { d->activeMenu = 0; @@ -1252,10 +1252,11 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) void QMenuBar::mouseMoveEvent(QMouseEvent *e) { Q_D(QMenuBar); - d->mouseDown = e->buttons() & Qt::LeftButton; + bool popupState = d->popupState || e->buttons() & Qt::LeftButton; + if (!d->mouseDown || !popupState) + return; QAction *action = d->actionAt(e->pos()); - bool popupState = d->popupState || d->mouseDown; - if ((action && d->isVisible(action)) || !popupState) + if (action && d->isVisible(action)) d->setCurrentAction(action, popupState); } diff --git a/src/gui/widgets/qslider.h b/src/gui/widgets/qslider.h index 289c5b7..7b27582 100644 --- a/src/gui/widgets/qslider.h +++ b/src/gui/widgets/qslider.h @@ -114,8 +114,8 @@ public: inline QT3_SUPPORT void setTickmarks(TickPosition position) { setTickPosition(position); } inline QT3_SUPPORT TickPosition tickmarks() const { return tickPosition(); } public Q_SLOTS: - inline QT_MOC_COMPAT void addStep() { triggerAction(SliderSingleStepAdd); }; - inline QT_MOC_COMPAT void subtractStep() { triggerAction(SliderSingleStepSub); }; + inline QT_MOC_COMPAT void addStep() { triggerAction(SliderSingleStepAdd); } + inline QT_MOC_COMPAT void subtractStep() { triggerAction(SliderSingleStepSub); } #endif private: diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp index cd5c131..de11625 100644 --- a/src/gui/widgets/qtoolbararealayout.cpp +++ b/src/gui/widgets/qtoolbararealayout.cpp @@ -776,7 +776,8 @@ void QToolBarAreaLayout::deleteAllLayoutItems() for (int k = 0; k < line.toolBarItems.count(); ++k) { QToolBarAreaLayoutItem &item = line.toolBarItems[k]; - delete item.widgetItem; + if (!item.gap) + delete item.widgetItem; item.widgetItem = 0; } } diff --git a/src/gui/widgets/qvalidator.cpp b/src/gui/widgets/qvalidator.cpp index 416c0cd..405bf04 100644 --- a/src/gui/widgets/qvalidator.cpp +++ b/src/gui/widgets/qvalidator.cpp @@ -636,7 +636,7 @@ QValidator::State QDoubleValidator::validate(QString & input, int &) const case ScientificNotation: numMode = QLocalePrivate::DoubleScientificMode; break; - }; + } QByteArray buff; if (!locale().d()->validateChars(input, numMode, &buff, dec)) { diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index 4a62c32..315a59b 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -73,6 +73,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor audioSource = 0; pullMode = true; resuming = false; + finished = false; connect(this,SIGNAL(processMore()),SLOT(deviceReady())); @@ -81,7 +82,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor QAudioInputPrivate::~QAudioInputPrivate() { - close(); + stop(); DeleteCriticalSection(&waveInCriticalSection); } @@ -104,10 +105,13 @@ void CALLBACK QAudioInputPrivate::waveInProc( HWAVEIN hWaveIn, UINT uMsg, EnterCriticalSection(&waveInCriticalSection); if(qAudio->waveFreeBlockCount > 0) qAudio->waveFreeBlockCount--; - LeaveCriticalSection(&waveInCriticalSection); qAudio->feedback(); + LeaveCriticalSection(&waveInCriticalSection); break; case WIM_CLOSE: + EnterCriticalSection(&waveInCriticalSection); + qAudio->finished = true; + LeaveCriticalSection(&waveInCriticalSection); break; default: return; @@ -198,8 +202,6 @@ void QAudioInputPrivate::stop() if(deviceState == QAudio::StopState) return; - deviceState = QAudio::StopState; - close(); emit stateChanged(deviceState); } @@ -218,6 +220,11 @@ 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(); wfx.nSamplesPerSec = settings.frequency(); wfx.wBitsPerSample = settings.sampleSize(); @@ -256,7 +263,19 @@ bool QAudioInputPrivate::open() return false; } waveBlocks = allocateBlocks(period_size, buffer_size/period_size); + + if(waveBlocks == 0) { + errorState = QAudio::OpenError; + deviceState = QAudio::StopState; + emit stateChanged(deviceState); + qWarning("QAudioInput: failed to allocate blocks. open failed"); + return false; + } + + EnterCriticalSection(&waveInCriticalSection); waveFreeBlockCount = buffer_size/period_size; + LeaveCriticalSection(&waveInCriticalSection); + waveCurrentBlock = 0; for(int i=0; i<buffer_size/period_size; i++) { @@ -286,18 +305,26 @@ bool QAudioInputPrivate::open() void QAudioInputPrivate::close() { - deviceState = QAudio::StopState; - int delay = (buffer_size-bytesReady())*1000/(settings.frequency() - *settings.channels()*(settings.sampleSize()/8)); + if(deviceState == QAudio::StopState) + return; + waveInReset(hWaveIn); - Sleep(delay+10); + waveInClose(hWaveIn); + deviceState = QAudio::StopState; + + int count = 0; + while(!finished && count < 100) { + count++; + Sleep(10); + } + EnterCriticalSection(&waveInCriticalSection); for(int i=0; i<waveFreeBlockCount; i++) { if(waveBlocks[i].dwFlags & WHDR_PREPARED) waveInUnprepareHeader(hWaveIn,&waveBlocks[i],sizeof(WAVEHDR)); } + LeaveCriticalSection(&waveInCriticalSection); freeBlocks(waveBlocks); - waveInClose(hWaveIn); } int QAudioInputPrivate::bytesReady() const @@ -384,6 +411,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) header = 0; p+=l; + EnterCriticalSection(&waveInCriticalSection); if(!pullMode) { if(l+period_size > len && waveFreeBlockCount == buffer_size/period_size) done = true; @@ -391,6 +419,8 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if(waveFreeBlockCount == buffer_size/period_size) done = true; } + LeaveCriticalSection(&waveInCriticalSection); + written+=l; } #ifdef DEBUG_AUDIO @@ -413,7 +443,10 @@ void QAudioInputPrivate::resume() return; } } + EnterCriticalSection(&waveInCriticalSection); waveFreeBlockCount = buffer_size/period_size; + LeaveCriticalSection(&waveInCriticalSection); + waveCurrentBlock = 0; header = 0; resuming = true; @@ -466,7 +499,7 @@ void QAudioInputPrivate::feedback() { #ifdef DEBUG_AUDIO QTime now(QTime::currentTime()); - qDebug()<<now.second()<<"s "<<now.msec()<<"ms :feedback() INPUT"; + qDebug()<<now.second()<<"s "<<now.msec()<<"ms :feedback() INPUT "<<this; #endif bytesAvailable = bytesReady(); diff --git a/src/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h index da0df24..3363b6a 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.h +++ b/src/multimedia/audio/qaudioinput_win32_p.h @@ -117,6 +117,7 @@ private: HWAVEIN hWaveIn; MMRESULT result; WAVEHDR* waveBlocks; + volatile bool finished; volatile int waveFreeBlockCount; int waveCurrentBlock; diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index de4981d..fae680c 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -72,11 +72,16 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF deviceState = QAudio::StopState; audioSource = 0; pullMode = true; + finished = false; InitializeCriticalSection(&waveOutCriticalSection); } QAudioOutputPrivate::~QAudioOutputPrivate() { + EnterCriticalSection(&waveOutCriticalSection); + finished = true; + LeaveCriticalSection(&waveOutCriticalSection); + close(); DeleteCriticalSection(&waveOutCriticalSection); } @@ -101,11 +106,15 @@ void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, return; case WOM_DONE: EnterCriticalSection(&waveOutCriticalSection); + if(qAudio->finished || qAudio->buffer_size == 0 || qAudio->period_size == 0) { + LeaveCriticalSection(&waveOutCriticalSection); + return; + } qAudio->waveFreeBlockCount++; if(qAudio->waveFreeBlockCount >= qAudio->buffer_size/qAudio->period_size) qAudio->waveFreeBlockCount = qAudio->buffer_size/qAudio->period_size; - LeaveCriticalSection(&waveOutCriticalSection); qAudio->feedback(); + LeaveCriticalSection(&waveOutCriticalSection); break; default: return; @@ -201,7 +210,11 @@ bool QAudioOutputPrivate::open() period_size = buffer_size/5; } waveBlocks = allocateBlocks(period_size, buffer_size/period_size); + + EnterCriticalSection(&waveOutCriticalSection); waveFreeBlockCount = buffer_size/period_size; + LeaveCriticalSection(&waveOutCriticalSection); + waveCurrentBlock = 0; if(audioBuffer == 0) @@ -281,6 +294,7 @@ int QAudioOutputPrivate::bytesFree() const { int buf; buf = waveFreeBlockCount*period_size; + return buf; } @@ -326,8 +340,12 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) int remain; current = &waveBlocks[waveCurrentBlock]; while(l > 0) { - if(waveFreeBlockCount==0) + EnterCriticalSection(&waveOutCriticalSection); + if(waveFreeBlockCount==0) { + LeaveCriticalSection(&waveOutCriticalSection); break; + } + LeaveCriticalSection(&waveOutCriticalSection); if(current->dwFlags & WHDR_PREPARED) waveOutUnprepareHeader(hWaveOut, current, sizeof(WAVEHDR)); @@ -348,8 +366,10 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) waveFreeBlockCount--; LeaveCriticalSection(&waveOutCriticalSection); #ifdef DEBUG_AUDIO + EnterCriticalSection(&waveOutCriticalSection); qDebug("write out l=%d, waveFreeBlockCount=%d", current->dwBufferLength,waveFreeBlockCount); + LeaveCriticalSection(&waveOutCriticalSection); #endif totalTimeValue += current->dwBufferLength /(settings.channels()*(settings.sampleSize()/8)) @@ -422,11 +442,14 @@ bool QAudioOutputPrivate::deviceReady() waveOutRestart(hWaveOut); } else if(l == 0) { bytesAvailable = bytesFree(); + + EnterCriticalSection(&waveOutCriticalSection); if(waveFreeBlockCount == buffer_size/period_size) { errorState = QAudio::UnderrunError; deviceState = QAudio::IdleState; emit stateChanged(deviceState); } + LeaveCriticalSection(&waveOutCriticalSection); } else if(i < 0) { bytesAvailable = bytesFree(); diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h index 16c71dd..68f418e 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.h +++ b/src/multimedia/audio/qaudiooutput_win32_p.h @@ -132,6 +132,7 @@ private: MMRESULT result; WAVEHDR header; WAVEHDR* waveBlocks; + volatile bool finished; volatile int waveFreeBlockCount; int waveCurrentBlock; char* audioBuffer; diff --git a/src/network/access/qnetworkaccessbackend_p.h b/src/network/access/qnetworkaccessbackend_p.h index 5fdaa4c..a5179cc 100644 --- a/src/network/access/qnetworkaccessbackend_p.h +++ b/src/network/access/qnetworkaccessbackend_p.h @@ -157,7 +157,7 @@ public: // return true if the QNonContiguousByteDevice of the upload // data needs to support reset(). Currently needed for HTTP. // This will possibly enable buffering of the upload data. - virtual bool needsResetableUploadData() {return false;}; + virtual bool needsResetableUploadData() { return false; } protected: // Create the device used for reading the upload data diff --git a/src/network/access/qnetworkaccesshttpbackend_p.h b/src/network/access/qnetworkaccesshttpbackend_p.h index d01cc5a..55aadac 100644 --- a/src/network/access/qnetworkaccesshttpbackend_p.h +++ b/src/network/access/qnetworkaccesshttpbackend_p.h @@ -95,7 +95,7 @@ public: qint64 deviceReadData(char *buffer, qint64 maxlen); // we return true since HTTP needs to send PUT/POST data again after having authenticated - bool needsResetableUploadData() {return true;}; + bool needsResetableUploadData() { return true; } private slots: void replyReadyRead(); diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 2d5ebcf..821d7c6 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -395,7 +395,11 @@ QMultiMap<QSsl::AlternateNameEntryType, QString> QSslCertificate::alternateSubje else if (genName->type == GEN_EMAIL) result.insert(QSsl::EmailEntry, altName); } +#if OPENSSL_VERSION_NUMBER >= 0x10000000L + q_sk_pop_free((STACK*)altNames, reinterpret_cast<void(*)(void*)>(q_sk_free)); +#else q_sk_pop_free((STACK*)altNames, q_sk_free); +#endif } return result; diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 641f921..0762752 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -143,12 +143,14 @@ DEFINEFUNC2(int, PEM_write_bio_RSA_PUBKEY, BIO *a, a, RSA *b, b, return 0, retur DEFINEFUNC2(void, RAND_seed, const void *a, a, int b, b, return, DUMMYARG) DEFINEFUNC(int, RAND_status, void, DUMMYARG, return -1, return) DEFINEFUNC(void, RSA_free, RSA *a, a, return, DUMMYARG) -DEFINEFUNC(void, sk_free, STACK *a, a, return, DUMMYARG) DEFINEFUNC(int, sk_num, STACK *a, a, return -1, return) -DEFINEFUNC2(void, sk_pop_free, STACK *a, a, void (*b)(STACK*), b, return, DUMMYARG) #if OPENSSL_VERSION_NUMBER >= 0x10000000L +DEFINEFUNC(void, sk_free, _STACK *a, a, return, DUMMYARG) +DEFINEFUNC2(void, sk_pop_free, STACK *a, a, void (*b)(void*), b, return, DUMMYARG) DEFINEFUNC2(void *, sk_value, STACK *a, a, int b, b, return 0, return) #else +DEFINEFUNC(void, sk_free, STACK *a, a, return, DUMMYARG) +DEFINEFUNC2(void, sk_pop_free, STACK *a, a, void (*b)(STACK*), b, return, DUMMYARG) DEFINEFUNC2(char *, sk_value, STACK *a, a, int b, b, return 0, return) #endif DEFINEFUNC(int, SSL_accept, SSL *a, a, return -1, return) @@ -489,6 +491,7 @@ bool q_resolveOpenSslSymbols() #ifdef SSLEAY_MACROS RESOLVEFUNC(ASN1_dup, 125, libs.second ) #endif + RESOLVEFUNC(ASN1_INTEGER_get, 48, libs.second ) RESOLVEFUNC(ASN1_STRING_data, 71, libs.second ) RESOLVEFUNC(ASN1_STRING_length, 76, libs.second ) RESOLVEFUNC(BIO_ctrl, 184, libs.second ) @@ -532,6 +535,7 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(RSA_free, 1450, libs.second ) RESOLVEFUNC(sk_free, 2571, libs.second ) RESOLVEFUNC(sk_num, 2576, libs.second ) + RESOLVEFUNC(sk_pop_free, 2578, libs.second ) RESOLVEFUNC(sk_value, 2585, libs.second ) RESOLVEFUNC(SSL_CIPHER_description, 11, libs.first ) RESOLVEFUNC(SSL_CTX_check_private_key, 21, libs.first ) diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index b739a42..8d71caa 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -255,12 +255,14 @@ int q_PEM_write_bio_RSA_PUBKEY(BIO *a, RSA *b); void q_RAND_seed(const void *a, int b); int q_RAND_status(); void q_RSA_free(RSA *a); -void q_sk_free(STACK *a); int q_sk_num(STACK *a); -void q_sk_pop_free(STACK *a, void (*b)(STACK *)); #if OPENSSL_VERSION_NUMBER >= 0x10000000L +void q_sk_free(_STACK *a); +void q_sk_pop_free(STACK *a, void (*b)(void *)); void * q_sk_value(STACK *a, int b); #else +void q_sk_free(STACK *a); +void q_sk_pop_free(STACK *a, void (*b)(STACK *)); char * q_sk_value(STACK *a, int b); #endif int q_SSL_accept(SSL *a); diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 78d184f..c87941b 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -423,8 +423,9 @@ void QGL2PaintEngineExPrivate::updateBrushTexture() const QPixmap& texPixmap = currentBrush->texture(); glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); - ctx->d_func()->bindTexture(texPixmap, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption); + QGLTexture *tex = ctx->d_func()->bindTexture(texPixmap, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, q->state()->renderHints & QPainter::SmoothPixmapTransform); + textureInvertedY = tex->options & QGLContext::InvertedYBindOption ? -1 : 1; } brushTextureDirty = false; } @@ -517,7 +518,7 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms() shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col); } - QSizeF invertedTextureSize( 1.0 / texPixmap.width(), 1.0 / texPixmap.height() ); + QSizeF invertedTextureSize(1.0 / texPixmap.width(), 1.0 * textureInvertedY / texPixmap.height()); shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::InvertedTextureSize), invertedTextureSize); QVector2D halfViewportSize(width*0.5, height*0.5); diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index da16e47..34f4eb8 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -262,6 +262,8 @@ public: bool needsSync; bool inRenderText; + + float textureInvertedY; }; QT_END_NAMESPACE diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index d479c2e..da30e3d 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -13,9 +13,17 @@ include(../qbase.pri) !win32:!embedded:!mac:CONFIG += x11 contains(QT_CONFIG, opengl):CONFIG += opengl contains(QT_CONFIG, opengles1):CONFIG += opengles1 -contains(QT_CONFIG, opengles1):CONFIG += opengles1cl +contains(QT_CONFIG, opengles1cl):CONFIG += opengles1cl contains(QT_CONFIG, opengles2):CONFIG += opengles2 +contains(QT_CONFIG, opengles.*) { + for(p, QMAKE_LIBDIR_EGL) { + exists($$p):LIBS_PRIVATE += -L$$p + } + !isEmpty(QMAKE_INCDIR_EGL): INCLUDEPATH += $$QMAKE_INCDIR_EGL + !isEmpty(QMAKE_LIBS_EGL): LIBS_PRIVATE += $$QMAKE_LIBS_EGL +} + HEADERS += qgl.h \ qgl_p.h \ qglcolormap.h \ diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 799c749..65d6f99 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1910,8 +1910,8 @@ static void convertToGLFormatHelper(QImage &dst, const QImage &img, GLenum textu int sbpl = img.bytesPerLine(); int dbpl = dst.bytesPerLine(); - int ix = 0x00010000 / sx; - int iy = 0x00010000 / sy; + int ix = int(0x00010000 / sx); + int iy = int(0x00010000 / sy); quint32 basex = int(0.5 * ix); quint32 srcy = int(0.5 * iy); @@ -2217,6 +2217,9 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, return data->texture(); } } +#else + Q_UNUSED(pd); + Q_UNUSED(q); #endif const qint64 key = pixmap.cacheKey(); @@ -4913,8 +4916,13 @@ QGLContextResource::QGLContextResource(FreeFunc f, QObject *parent) QGLContextResource::~QGLContextResource() { - while (!m_resources.empty()) - removeGroup(m_resources.begin().key()); +#ifndef QT_NO_DEBUG + if (m_resources.size()) { + qWarning("QtOpenGL: Resources are still available at program shutdown.\n" + " This is possibly caused by a leaked QGLWidget, \n" + " QGLFrameBufferObject or QGLPixelBuffer."); + } +#endif } void QGLContextResource::insert(const QGLContext *key, void *value) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 094f675..f15aa01 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -299,10 +299,21 @@ bool QGLFramebufferObjectFormat::operator!=(const QGLFramebufferObjectFormat& ot return !(*this == other); } -void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f) +void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f, + QGLFramebufferObject::Attachment attachment) { fbo = f; m_thisFBO = fbo->d_func()->fbo; // This shouldn't be needed + + // The context that the fbo was created in may not have depth + // and stencil buffers, but the fbo itself might. + fboFormat = QGLContext::currentContext()->format(); + if (attachment == QGLFramebufferObject::CombinedDepthStencil) { + fboFormat.setDepth(true); + fboFormat.setStencil(true); + } else if (attachment == QGLFramebufferObject::Depth) { + fboFormat.setDepth(true); + } } void QGLFBOGLPaintDevice::ensureActiveTarget() @@ -395,7 +406,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo); - glDevice.setFBO(q); + glDevice.setFBO(q, attachment); QT_CHECK_GLERROR(); // init texture diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h index c11c496..f80209d 100644 --- a/src/opengl/qglframebufferobject_p.h +++ b/src/opengl/qglframebufferobject_p.h @@ -110,15 +110,18 @@ public: virtual QPaintEngine* paintEngine() const {return fbo->paintEngine();} virtual QSize size() const {return fbo->size();} virtual QGLContext* context() const {return const_cast<QGLContext *>(QGLContext::currentContext());} + virtual QGLFormat format() const {return fboFormat;} virtual void ensureActiveTarget(); virtual void beginPaint(); virtual void endPaint(); - void setFBO(QGLFramebufferObject* f); + void setFBO(QGLFramebufferObject* f, + QGLFramebufferObject::Attachment attachment); private: bool wasBound; QGLFramebufferObject* fbo; + QGLFormat fboFormat; }; class QGLFramebufferObjectPrivate diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index c0f1813..e68a4b9 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -44,7 +44,14 @@ #include <private/qglpixelbuffer_p.h> #include <private/qglframebufferobject_p.h> #include <private/qwindowsurface_gl_p.h> + +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) #include <private/qpixmapdata_gl_p.h> +#endif + +#if defined(QT_OPENGL_ES_1_CL) +#include "qgl_cl_p.h" +#endif QT_BEGIN_NAMESPACE @@ -67,6 +74,12 @@ void QGLPaintDevice::beginPaint() // Record the currently bound FBO so we can restore it again // in endPaint() and bind this device's FBO + // + // Note: m_thisFBO could be zero if the paint device is not + // backed by an FBO (e.g. window back buffer). But there could + // be a previous FBO bound to the context which we need to + // explicitly unbind. Otherwise the painting will go into + // the previous FBO instead of to the window. m_previousFBO = ctx->d_func()->current_fbo; if (m_previousFBO != m_thisFBO) { ctx->d_ptr->current_fbo = m_thisFBO; @@ -171,9 +184,13 @@ QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd) glpd = &(static_cast<QGLFramebufferObject*>(pd)->d_func()->glDevice); break; case QInternal::Pixmap: { +#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) QPixmapData* pmd = static_cast<QPixmap*>(pd)->pixmapData(); Q_ASSERT(pmd->classId() == QPixmapData::OpenGLClass); glpd = static_cast<QGLPixmapData*>(pmd)->glDevice(); +#else + qWarning("Pixmap render targets not supported on OpenGL ES 1.x"); +#endif break; } default: diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h index 66b24a9..1e7ba8d 100644 --- a/src/opengl/qglpaintdevice_p.h +++ b/src/opengl/qglpaintdevice_p.h @@ -73,7 +73,7 @@ public: virtual void endPaint(); virtual QGLContext* context() const = 0; - QGLFormat format() const; + virtual QGLFormat format() const; virtual QSize size() const = 0; // returns the QGLPaintDevice for the given QPaintDevice diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index f1169fd..ff00f29 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -2116,7 +2116,7 @@ void QOpenGLPaintEngine::updatePen(const QPen &pen) Qt::PenStyle pen_style = pen.style(); d->pen_brush_style = pen.brush().style(); d->cpen = pen; - d->has_pen = (pen_style != Qt::NoPen); + d->has_pen = (pen_style != Qt::NoPen) && (d->pen_brush_style != Qt::NoBrush); d->updateUseEmulation(); if (pen.isCosmetic()) { @@ -4300,8 +4300,10 @@ void QOpenGLPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QR else { GLenum target = qt_gl_preferredTextureTarget(); d->flushDrawQueue(); - d->device->context()->bindTexture(pm, target); - drawTextureRect(pm.width(), pm.height(), r, sr, target); + QGLTexture *tex = + d->device->context()->d_func()->bindTexture(pm, target, GL_RGBA, + QGLContext::InternalBindOption); + drawTextureRect(pm.width(), pm.height(), r, sr, target, tex); } } @@ -4333,10 +4335,13 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con } else { d->flushDrawQueue(); + QGLTexture *tex; if (scaled.isNull()) - d->device->context()->bindTexture(pm); + tex = d->device->context()->d_func()->bindTexture(pm, GL_TEXTURE_2D, GL_RGBA, + QGLContext::InternalBindOption); else - d->device->context()->bindTexture(scaled); + tex = d->device->context()->d_func()->bindTexture(scaled, GL_TEXTURE_2D, GL_RGBA, + QGLContext::InternalBindOption); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, d->use_smooth_pixmap_transform); #ifndef QT_OPENGL_ES @@ -4349,6 +4354,15 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con GLdouble tc_w = r.width()/pm.width(); GLdouble tc_h = r.height()/pm.height(); + // Rotate the texture so that it is aligned correctly and the + // wrapping is done correctly + if (tex->options & QGLContext::InvertedYBindOption) { + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glRotatef(180.0, 0.0, 1.0, 0.0); + glRotatef(180.0, 0.0, 0.0, 1.0); + } + q_vertexType vertexArray[4*2]; q_vertexType texCoordArray[4*2]; @@ -4367,6 +4381,8 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); + if (tex->options & QGLContext::InvertedYBindOption) + glPopMatrix(); glDisable(GL_TEXTURE_2D); #ifndef QT_OPENGL_ES @@ -4402,13 +4418,15 @@ void QOpenGLPaintEngine::drawImage(const QRectF &r, const QImage &image, const Q else { GLenum target = qt_gl_preferredTextureTarget(); d->flushDrawQueue(); - d->device->context()->bindTexture(image, target); - drawTextureRect(image.width(), image.height(), r, sr, target); + QGLTexture *tex = + d->device->context()->d_func()->bindTexture(image, target, GL_RGBA, + QGLContext::InternalBindOption); + drawTextureRect(image.width(), image.height(), r, sr, target, tex); } } void QOpenGLPaintEngine::drawTextureRect(int tx_width, int tx_height, const QRectF &r, - const QRectF &sr, GLenum target) + const QRectF &sr, GLenum target, QGLTexture *tex) { Q_D(QOpenGLPaintEngine); #ifndef QT_OPENGL_ES @@ -4423,8 +4441,13 @@ void QOpenGLPaintEngine::drawTextureRect(int tx_width, int tx_height, const QRec if (target == GL_TEXTURE_2D) { x1 = sr.x() / tx_width; x2 = x1 + sr.width() / tx_width; - y1 = 1 - (sr.bottom() / tx_height); - y2 = 1 - (sr.y() / tx_height); + if (tex->options & QGLContext::InvertedYBindOption) { + y1 = 1 - (sr.bottom() / tx_height); + y2 = 1 - (sr.y() / tx_height); + } else { + y1 = sr.bottom() / tx_height; + y2 = sr.y() / tx_height; + } } else { x1 = sr.x(); x2 = sr.right(); @@ -4767,7 +4790,24 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, const QTextItemInt &ti, } } - QImage glyph_im(ti.fontEngine->alphaMapForGlyph(glyphs[i]).convertToFormat(QImage::Format_Indexed8)); + QImage glyph_im(ti.fontEngine->alphaMapForGlyph(glyphs[i])); + + // The QPF implementation of alphaMapForGlyph() uses the color + // RGBA = (value, value, value, 255) instead of the color + // RGBA = (0, 0, 0, value) that the other font engines use. + // We modify the image colors to rectify this situation. + QFontEngine::Type type = ti.fontEngine->type(); + if (type == QFontEngine::QPF1 || type == QFontEngine::QPF2) { + if (glyph_im.format() == QImage::Format_Indexed8) { + for (int i = 0; i < 256; ++i) + glyph_im.setColor(i, qRgba(0, 0, 0, i)); + } else if (glyph_im.format() == QImage::Format_Mono) { + glyph_im.setColor(0, qRgba(0, 0, 0, 0)); + glyph_im.setColor(1, qRgba(0, 0, 0, 255)); + } + } + + glyph_im = glyph_im.convertToFormat(QImage::Format_Indexed8); glyph_width = glyph_im.width(); Q_ASSERT(glyph_width >= 0); // pad the glyph width to an even number @@ -5179,9 +5219,12 @@ void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType * glActiveTexture(GL_TEXTURE0 + brush_texture_location); if (current_style == Qt::TexturePattern) - device->context()->bindTexture(cbrush.textureImage()); + device->context()->d_func()->bindTexture(cbrush.textureImage(), GL_TEXTURE_2D, GL_RGBA, + QGLContext::InternalBindOption); else - device->context()->bindTexture(qt_imageForBrush(current_style, true)); + device->context()->d_func()->bindTexture(qt_imageForBrush(current_style, true), + GL_TEXTURE_2D, GL_RGBA, + QGLContext::InternalBindOption); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, use_smooth_pixmap_transform); } @@ -5588,8 +5631,11 @@ QPixmapFilter *QOpenGLPaintEngine::createPixmapFilter(int type) const if (QGLContext::currentContext()) return QGLContext::currentContext()->d_func()->createPixmapFilter(type); else -#endif return 0; +#else + Q_UNUSED(type); + return 0; +#endif } diff --git a/src/opengl/qpaintengine_opengl_p.h b/src/opengl/qpaintengine_opengl_p.h index 1cac3ad..c8f460a 100644 --- a/src/opengl/qpaintengine_opengl_p.h +++ b/src/opengl/qpaintengine_opengl_p.h @@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE class QOpenGLPaintEnginePrivate; +class QGLTexture; class QOpenGLPaintEngineState : public QPainterState { @@ -146,7 +147,8 @@ public: private: void drawPolyInternal(const QPolygonF &pa, bool close = true); - void drawTextureRect(int tx_width, int tx_height, const QRectF &r, const QRectF &sr, GLenum target); + void drawTextureRect(int tx_width, int tx_height, const QRectF &r, const QRectF &sr, + GLenum target, QGLTexture *tex); Q_DISABLE_COPY(QOpenGLPaintEngine) }; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp index 0ad4071..8662df6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp @@ -207,6 +207,7 @@ void QDirectFBMouseHandlerPrivate::readMouseData() int wheel = 0; if (input.type == DIET_AXISMOTION) { +#ifdef QT_NO_DIRECTFB_LAYER if (input.flags & DIEF_AXISABS) { switch (input.axis) { case DIAI_X: x = input.axisabs; break; @@ -226,6 +227,19 @@ void QDirectFBMouseHandlerPrivate::readMouseData() "unknown axis (releative) %d", input.axis); } } +#else + if (input.axis == DIAI_X || input.axis == DIAI_Y) { + DFBResult result = layer->GetCursorPosition(layer, &x, &y); + if (result != DFB_OK) { + DirectFBError("QDirectFBMouseHandler::readMouseData", + result); + } + } else if (input.axis == DIAI_Z) { + Q_ASSERT(input.flags & DIEF_AXISREL); + wheel = input.axisrel; + wheel *= -120; + } +#endif } Qt::MouseButtons buttons = Qt::NoButton; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index c2ae2fb..4413858 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -591,12 +591,15 @@ bool QDirectFBScreenCursor::createWindow() Q_ASSERT(!cursor.isNull()); DFBWindowDescription description; memset(&description, 0, sizeof(DFBWindowDescription)); - description.flags = DWDESC_POSX|DWDESC_POSY|DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_CAPS|DWDESC_OPTIONS|DWDESC_PIXELFORMAT|DWDESC_SURFACE_CAPS; + description.flags = DWDESC_POSX|DWDESC_POSY|DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_CAPS|DWDESC_PIXELFORMAT|DWDESC_SURFACE_CAPS; description.width = cursor.width(); description.height = cursor.height(); description.posx = pos.x() - hotspot.x(); description.posy = pos.y() - hotspot.y(); +#if (Q_DIRECTFB_VERSION >= 0x010100) + description.flags |= DWDESC_OPTIONS; description.options = DWOP_GHOST|DWOP_ALPHACHANNEL; +#endif description.caps = DWCAPS_NODECORATION|DWCAPS_DOUBLEBUFFER; const QImage::Format format = QDirectFBScreen::instance()->alphaPixmapFormat(); description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format); @@ -1202,7 +1205,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec) "Unable to get screen!", result); return false; } - const QString qws_size = qgetenv("QWS_SIZE"); + const QString qws_size = QString::fromLatin1(qgetenv("QWS_SIZE")); if (!qws_size.isEmpty()) { QRegExp rx(QLatin1String("(\\d+)x(\\d+)")); if (!rx.exactMatch(qws_size)) { diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index eec70e1..79a01d3 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -110,7 +110,7 @@ QT_MODULE(Gui) #error QT_DIRECTFB_WINDOW_AS_CURSOR requires QT_DIRECTFB_WM to be defined #endif -#define Q_DIRECTFB_VERSION ((DIRECTFB_MAJOR_VERSION << 16) | (DIRECTFB_MINOR_VERION << 8) | DIRECTFB_MICRO_VERSION) +#define Q_DIRECTFB_VERSION ((DIRECTFB_MAJOR_VERSION << 16) | (DIRECTFB_MINOR_VERSION << 8) | DIRECTFB_MICRO_VERSION) #define DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(F) \ static inline F operator~(F f) { return F(~int(f)); } \ diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp index 1cbc1d7..a86a3a4 100644 --- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp +++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp @@ -74,7 +74,7 @@ public: + QString::number((((((size.width()<<11)|size.height())<<11)|mode)<<4)|state, 16); } void stepSerialNum() - { serialNum = lastSerialNum.fetchAndAddRelaxed(1); }; + { serialNum = lastSerialNum.fetchAndAddRelaxed(1); } void loadDataForModeAndState(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state); diff --git a/src/script/script.pro b/src/script/script.pro index a03b652..1a793b2 100644 --- a/src/script/script.pro +++ b/src/script/script.pro @@ -24,7 +24,17 @@ isEmpty(WEBKITDIR) { # FIXME: not needed once JSCBISON works # TODO: or leave it like this since the generated file is available anyway? SOURCES += $$WEBKITDIR/JavaScriptCore/generated/Grammar.cpp + + # avoid warnings when parsing JavaScriptCore.pri + # (we don't care about generating files, we already have them generated) + defineTest(addExtraCompiler) { + return(true) + } + defineTest(addExtraCompilerWithHeader) { + return(true) + } } else { + message(using external WebKit from $$WEBKITDIR) CONFIG += building-libs CONFIG -= QTDIR_build include($$WEBKITDIR/WebKit.pri) @@ -38,15 +48,6 @@ wince* { LIBS += -lmmtimer } -# avoid warnings when parsing JavaScriptCore.pri -# (we don't care about generating files, we already have them generated) -defineTest(addExtraCompiler) { - return(true) -} -defineTest(addExtraCompilerWithHeader) { - return(true) -} - include($$WEBKITDIR/JavaScriptCore/JavaScriptCore.pri) INCLUDEPATH += $$WEBKITDIR/JavaScriptCore diff --git a/src/svg/qgraphicssvgitem.cpp b/src/svg/qgraphicssvgitem.cpp index 7176f37..ea26c78 100644 --- a/src/svg/qgraphicssvgitem.cpp +++ b/src/svg/qgraphicssvgitem.cpp @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE -class QGraphicsSvgItemPrivate : public QObjectPrivate +class QGraphicsSvgItemPrivate : public QGraphicsItemPrivate { public: Q_DECLARE_PUBLIC(QGraphicsSvgItem) @@ -62,9 +62,10 @@ public: { } - void init() + void init(QGraphicsItem *parent) { Q_Q(QGraphicsSvgItem); + q->setParentItem(parent); renderer = new QSvgRenderer(q); QObject::connect(renderer, SIGNAL(repaintNeeded()), q, SLOT(_q_repaintItem())); @@ -137,10 +138,10 @@ public: Constructs a new SVG item with the given \a parent. */ QGraphicsSvgItem::QGraphicsSvgItem(QGraphicsItem *parent) - : QObject(*new QGraphicsSvgItemPrivate(), 0), QGraphicsItem(parent) + : QGraphicsObject(*new QGraphicsSvgItemPrivate(), 0, 0) { Q_D(QGraphicsSvgItem); - d->init(); + d->init(parent); } /*! @@ -148,10 +149,10 @@ QGraphicsSvgItem::QGraphicsSvgItem(QGraphicsItem *parent) SVG file with the specified \a fileName. */ QGraphicsSvgItem::QGraphicsSvgItem(const QString &fileName, QGraphicsItem *parent) - : QObject(*new QGraphicsSvgItemPrivate(), 0), QGraphicsItem(parent) + : QGraphicsObject(*new QGraphicsSvgItemPrivate(), 0, 0) { Q_D(QGraphicsSvgItem); - d->init(); + d->init(parent); d->renderer->load(fileName); d->updateDefaultSize(); } diff --git a/src/svg/qgraphicssvgitem.h b/src/svg/qgraphicssvgitem.h index 2d0e20b..e304c0c 100644 --- a/src/svg/qgraphicssvgitem.h +++ b/src/svg/qgraphicssvgitem.h @@ -41,7 +41,6 @@ #ifndef QGRAPHICSSVGITEM_H #define QGRAPHICSSVGITEM_H -#include <QtCore/qobject.h> #include <QtGui/qgraphicsitem.h> #ifndef QT_NO_GRAPHICSSVGITEM @@ -55,10 +54,12 @@ QT_MODULE(Svg) class QSvgRenderer; class QGraphicsSvgItemPrivate; -class Q_SVG_EXPORT QGraphicsSvgItem : public QObject, public QGraphicsItem +class Q_SVG_EXPORT QGraphicsSvgItem : public QGraphicsObject { Q_OBJECT Q_INTERFACES(QGraphicsItem) + Q_PROPERTY(QString elementId READ elementId WRITE setElementId) + Q_PROPERTY(QSize maximumCacheSize READ maximumCacheSize WRITE setMaximumCacheSize) public: QGraphicsSvgItem(QGraphicsItem *parentItem=0); @@ -87,13 +88,7 @@ public: private: Q_DISABLE_COPY(QGraphicsSvgItem) - - // Q_DECLARE_PRIVATE_WITH_BASE(QGraphicsSvgItem, QObject) - inline QGraphicsSvgItemPrivate *d_func() - { return reinterpret_cast<QGraphicsSvgItemPrivate *>(QObject::d_ptr.data()); } - inline const QGraphicsSvgItemPrivate *d_func() const - { return reinterpret_cast<const QGraphicsSvgItemPrivate *>(QObject::d_ptr.data()); } - friend class QGraphicsSvgItemPrivate; + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsSvgItem) Q_PRIVATE_SLOT(d_func(), void _q_repaintItem()) }; diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp index fda8ad1..6552b69 100644 --- a/src/svg/qsvggraphics.cpp +++ b/src/svg/qsvggraphics.cpp @@ -434,7 +434,7 @@ void QSvgText::draw(QPainter *p, QSvgExtraStates &states) text.append(QLatin1Char('\n')); text.append(paragraphs[i]); } - states.svgFont->draw(p, m_coord, text, p->font().pointSizeF() * scale, states.textAnchor); + states.svgFont->draw(p, m_coord * scale, text, p->font().pointSizeF() * scale, states.textAnchor); } else { for (int i = 0; i < paragraphs.size(); ++i) { QTextLayout tl(paragraphs[i]); diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 06a49d8..98fa26f 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -968,6 +968,7 @@ static void parseColor(QSvgNode *, { QColor color; if (constructColor(attributes.color, attributes.colorOpacity, color, handler)) { + handler->popColor(); handler->pushColor(color); } } @@ -2728,6 +2729,14 @@ static void parseBaseGradient(QSvgNode *node, QStringRef trans = attributes.value(QLatin1String("gradientTransform")); QString spread = attributes.value(QLatin1String("spreadMethod")).toString(); QString units = attributes.value(QLatin1String("gradientUnits")).toString(); + QStringRef colorStr = attributes.value(QLatin1String("color")); + QStringRef colorOpacityStr = attributes.value(QLatin1String("color-opacity")); + + QColor color; + if (constructColor(colorStr, colorOpacityStr, color, handler)) { + handler->popColor(); + handler->pushColor(color); + } QMatrix matrix; QGradient *grad = gradProp->qgradient(); @@ -3558,11 +3567,7 @@ bool QSvgHandler::startElement(const QString &localName, { QSvgNode *node = 0; - if (m_colorTagCount.count()) { - int top = m_colorTagCount.pop(); - ++top; - m_colorTagCount.push(top); - } + pushColorCopy(); /* The xml:space attribute may appear on any element. We do * a lookup by the qualified name here, but this is namespace aware, since @@ -3696,15 +3701,7 @@ bool QSvgHandler::endElement(const QStringRef &localName) m_skipNodes.pop(); m_whitespaceMode.pop(); - if (m_colorTagCount.count()) { - int top = m_colorTagCount.pop(); - --top; - if (!top) { - m_colorStack.pop(); - } else { - m_colorTagCount.push(top); - } - } + popColor(); if (node == Unknown) { return true; @@ -3801,6 +3798,24 @@ void QSvgHandler::pushColor(const QColor &color) m_colorTagCount.push(1); } +void QSvgHandler::pushColorCopy() +{ + if (m_colorTagCount.count()) + ++m_colorTagCount.top(); + else + pushColor(Qt::black); +} + +void QSvgHandler::popColor() +{ + if (m_colorTagCount.count()) { + if (!--m_colorTagCount.top()) { + m_colorStack.pop(); + m_colorTagCount.pop(); + } + } +} + QColor QSvgHandler::currentColor() const { if (!m_colorStack.isEmpty()) diff --git a/src/svg/qsvghandler_p.h b/src/svg/qsvghandler_p.h index 1b31677..aff6f1d 100644 --- a/src/svg/qsvghandler_p.h +++ b/src/svg/qsvghandler_p.h @@ -111,6 +111,8 @@ public: LengthType defaultCoordinateSystem() const; void pushColor(const QColor &color); + void pushColorCopy(); + void popColor(); QColor currentColor() const; void setInStyle(bool b); diff --git a/src/testlib/qtestspontaneevent.h b/src/testlib/qtestspontaneevent.h index 0c670f8..2f00414 100644 --- a/src/testlib/qtestspontaneevent.h +++ b/src/testlib/qtestspontaneevent.h @@ -74,9 +74,9 @@ public: class QSpontaneKeyEvent { public: - void setSpontaneous() { spont = 1; }; - bool spontaneous() { return spont; }; - virtual void dummyFunc() { }; + void setSpontaneous() { spont = 1; } + bool spontaneous() { return spont; } + virtual void dummyFunc() {} virtual ~QSpontaneKeyEvent() {} #ifndef QTEST_NO_SIZEOF_CHECK diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 6b3227a..51f850a 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -709,6 +709,46 @@ bool RCCResourceLibrary::writeHeader() { if (m_format == C_Code) { writeString("/****************************************************************************\n"); + writeString("**\n"); + writeString("** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\n"); + writeString("** All rights reserved.\n"); + writeString("** Contact: Nokia Corporation (qt-info@nokia.com)\n"); + writeString("**\n"); + writeString("** This file is part of the tools applications of the Qt Toolkit.\n"); + writeString("**\n"); + writeString("** $QT_BEGIN_LICENSE:LGPL$\n"); + writeString("** No Commercial Usage\n"); + writeString("** This file contains pre-release code and may not be distributed.\n"); + writeString("** You may use this file in accordance with the terms and conditions\n"); + writeString("** contained in the Technology Preview License Agreement accompanying\n"); + writeString("** this package.\n"); + writeString("**\n"); + writeString("** GNU Lesser General Public License Usage\n"); + writeString("** Alternatively, this file may be used under the terms of the GNU Lesser\n"); + writeString("** General Public License version 2.1 as published by the Free Software\n"); + writeString("** Foundation and appearing in the file LICENSE.LGPL included in the\n"); + writeString("** packaging of this file. Please review the following information to\n"); + writeString("** ensure the GNU Lesser General Public License version 2.1 requirements\n"); + writeString("** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.\n"); + writeString("**\n"); + writeString("** In addition, as a special exception, Nokia gives you certain additional\n"); + writeString("** rights. These rights are described in the Nokia Qt LGPL Exception\n"); + writeString("** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.\n"); + writeString("**\n"); + writeString("** If you have questions regarding the use of this file, please contact\n"); + writeString("** Nokia at qt-info@nokia.com.\n"); + writeString("**\n"); + writeString("**\n"); + writeString("**\n"); + writeString("**\n"); + writeString("**\n"); + writeString("**\n"); + writeString("**\n"); + writeString("**\n"); + writeString("** $QT_END_LICENSE$\n"); + writeString("**\n"); + writeString("****************************************************************************/\n"); + writeString("/****************************************************************************\n"); writeString("** Resource object code\n"); writeString("**\n"); writeString("** Created: "); diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index cf2d8ba..3ae91d3 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -514,8 +514,8 @@ public: bool setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn); // Attributes - QDomDocumentTypePrivate* doctype() { return type.data(); }; - QDomImplementationPrivate* implementation() { return impl.data(); }; + QDomDocumentTypePrivate* doctype() { return type.data(); } + QDomImplementationPrivate* implementation() { return impl.data(); } QDomElementPrivate* documentElement(); // Factories diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index 1bd9aac..420962d 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -49,8 +49,8 @@ QT_USE_NAMESPACE // this test only works with // * GLIBC // * MSVC - only debug builds (we need the crtdbg.h helpers) -// * SYMBIAN - only when __UHEAP_BURSTFAILNEXT is available -#if (defined(QT_NO_EXCEPTIONS) || (!defined(__GLIBC__) && !defined(Q_CC_MSVC) && (!defined(Q_OS_SYMBIAN) || !defined(__UHEAP_BURSTFAILNEXT)))) && !defined(Q_MOC_RUN) +// * SYMBIAN +#if (defined(QT_NO_EXCEPTIONS) || (!defined(__GLIBC__) && !defined(Q_CC_MSVC) && !defined(Q_OS_SYMBIAN))) && !defined(Q_MOC_RUN) QTEST_NOOP_MAIN #else @@ -65,6 +65,7 @@ class tst_ExceptionSafetyObjects: public QObject public slots: void initTestCase(); + void cleanupTestCase(); private slots: void objects_data(); @@ -81,6 +82,10 @@ private slots: void linkedList_data(); void linkedList(); + +private: + static QtMsgHandler testMessageHandler; + static void safeMessageHandler(QtMsgType, const char *); }; // helper structs to create an arbitrary widget @@ -268,8 +273,22 @@ public: } }; +QtMsgHandler tst_ExceptionSafetyObjects::testMessageHandler; + +void tst_ExceptionSafetyObjects::safeMessageHandler(QtMsgType type, const char *msg) +{ + // this temporarily suspends OOM testing while handling a message + int currentIndex = mallocFailIndex; + AllocFailer allocFailer(0); + allocFailer.deactivate(); + (*testMessageHandler)(type, msg); + allocFailer.reactivateAt(currentIndex); +} + void tst_ExceptionSafetyObjects::initTestCase() { + testMessageHandler = qInstallMsgHandler(safeMessageHandler); + QVERIFY(AllocFailer::initialize()); // sanity check whether OOM simulation works @@ -307,6 +326,11 @@ void tst_ExceptionSafetyObjects::initTestCase() QCOMPARE(malloc2Failed, 1); } +void tst_ExceptionSafetyObjects::cleanupTestCase() +{ + qInstallMsgHandler(testMessageHandler); +} + void tst_ExceptionSafetyObjects::objects() { QFETCH(AbstractTester *, objectCreator); @@ -347,6 +371,13 @@ template <> struct WidgetCreator<QDesktopWidget> : public AbstractTester }; void tst_ExceptionSafetyObjects::widgets_data() { +#ifdef Q_OS_SYMBIAN + // Initialise the S60 rasteriser, which crashes if started while out of memory + QImage image(20, 20, QImage::Format_RGB32); + QPainter p(&image); + p.drawText(0, 15, "foo"); +#endif + QTest::addColumn<AbstractTester *>("widgetCreator"); #undef NEWROW @@ -392,9 +423,6 @@ void tst_ExceptionSafetyObjects::widgets_data() NEWROW(QToolBox); NEWROW(QToolButton); NEWROW(QStatusBar); - NEWROW(QSplitter); - NEWROW(QTextEdit); - NEWROW(QTextBrowser); NEWROW(QToolBar); NEWROW(QMenuBar); NEWROW(QMainWindow); @@ -502,7 +530,7 @@ struct IntegerMoveable int IntegerMoveable::instanceCount = 0; Q_DECLARE_TYPEINFO(IntegerMoveable, Q_MOVABLE_TYPE); -template <typename T, template<typename> class Container > +template <typename T, template<typename> class Container> void containerInsertTest(QObject*) { Container<T> container; diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp index 1a3db0a..1b28648 100644 --- a/tests/auto/headers/tst_headers.cpp +++ b/tests/auto/headers/tst_headers.cpp @@ -187,8 +187,8 @@ void tst_Headers::licenseCheck() if (content.first().contains("generated")) content.takeFirst(); - QVERIFY(licensePattern.exactMatch(content.value(7)) || - licensePattern.exactMatch(content.value(4))); + QVERIFY(licensePattern.exactMatch(content.value(8)) || + licensePattern.exactMatch(content.value(5))); QString licenseType = licensePattern.cap(1); int i = 0; @@ -196,7 +196,9 @@ void tst_Headers::licenseCheck() QCOMPARE(content.at(i++), QString("/****************************************************************************")); if (licenseType != "3RDPARTY") { QCOMPARE(content.at(i++), QString("**")); - QVERIFY(copyrightPattern.exactMatch(content.at(i++))); + // QVERIFY(copyrightPattern.exactMatch(content.at(i++))); + i++; + i++; QCOMPARE(content.at(i++), QString("** Contact: Nokia Corporation (qt-info@nokia.com)")); } QCOMPARE(content.at(i++), QString("**")); diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 1281d74..059d7b8 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -46,6 +46,7 @@ #ifdef Q_OS_SYMBIAN +#include <e32base.h> #include <sys/socket.h> #include <net/if.h> #include <QSharedPointer> @@ -333,13 +334,31 @@ QByteArray QtNetworkSettings::imapExpectedReplySsl; class QtNetworkSettingsInitializerCode { public: QtNetworkSettingsInitializerCode() { +#ifdef Q_OS_SYMBIAN + // We have a non-trivial constructor in global static. + // The QtNetworkSettings::serverName() uses native API which assumes + // Cleanup-stack to exist. That's why we create it here and install + // top level TRAP harness. + CTrapCleanup *cleanupStack = q_check_ptr(CTrapCleanup::New()); + TRAPD(err, + QHostInfo testServerResult = QHostInfo::fromName(QtNetworkSettings::serverName()); + if (testServerResult.error() != QHostInfo::NoError) { + qWarning() << "Could not lookup" << QtNetworkSettings::serverName(); + qWarning() << "Please configure the test environment!"; + qWarning() << "See /etc/hosts or network-settings.h"; + qFatal("Exiting"); + } + ) + delete cleanupStack; +#else QHostInfo testServerResult = QHostInfo::fromName(QtNetworkSettings::serverName()); if (testServerResult.error() != QHostInfo::NoError) { qWarning() << "Could not lookup" << QtNetworkSettings::serverName(); qWarning() << "Please configure the test environment!"; qWarning() << "See /etc/hosts or network-settings.h"; qFatal("Exiting"); - } + } +#endif } }; QtNetworkSettingsInitializerCode qtNetworkSettingsInitializer; diff --git a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp index 022778b..be2d882 100644 --- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp @@ -1200,13 +1200,13 @@ void tst_QAbstractItemView::task250754_fontChange() tree.setFont(font); QTest::qWait(30); - QVERIFY(!tree.verticalScrollBar()->isVisible()); + QTRY_VERIFY(!tree.verticalScrollBar()->isVisible()); font.setPointSize(45); tree.setFont(font); QTest::qWait(30); //now with the huge items, the scrollbar must be visible - QVERIFY(tree.verticalScrollBar()->isVisible()); + QTRY_VERIFY(tree.verticalScrollBar()->isVisible()); qApp->setStyleSheet(app_css); } diff --git a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp index 3530eb9..502c2d1 100644 --- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp @@ -57,6 +57,8 @@ #include <qsettings.h> #endif +#include "../../shared/util.h" + class SpecialRadioButton: public QRadioButton { public: @@ -402,6 +404,8 @@ void tst_QButtonGroup::task106609() QSignalSpy spy2(buttons, SIGNAL(buttonClicked(int))); QTestEventLoop::instance().enterLoop(1); + QApplication::setActiveWindow(&dlg); + QTRY_COMPARE(QApplication::activeWindow(), &dlg); //qDebug() << "int:" << spy2.count() << "QAbstractButton*:" << spy1.count(); QCOMPARE(spy2.count(), 2); diff --git a/tests/auto/qdir/qdir.pro b/tests/auto/qdir/qdir.pro index 0111672..cf612f1 100644 --- a/tests/auto/qdir/qdir.pro +++ b/tests/auto/qdir/qdir.pro @@ -1,25 +1,21 @@ load(qttest_p4) -SOURCES += tst_qdir.cpp -RESOURCES += qdir.qrc -wince*:{ - DirFiles.sources = testdir testdata searchdir resources unprintablenames entrylist types tst_qdir.cpp - DirFiles.path = . - DEPLOYMENT += DirFiles +SOURCES += tst_qdir.cpp +RESOURCES += qdir.qrc +QT = core - QT = core - DEFINES += SRCDIR=\\\"\\\" -} symbian:{ +wince*|symbian { DirFiles.sources = testdir testdata searchdir resources entrylist types tst_qdir.cpp DirFiles.path = . DEPLOYMENT += DirFiles +} - QT = core +wince* { + DEFINES += SRCDIR=\\\"\\\" +} else:symbian { TARGET.CAPABILITY += AllFiles - TARGET.UID3 = 0xE0340002 DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) } else { - QT = core contains(QT_CONFIG, qt3support):QT += qt3support DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qdirmodel/qdirmodel.pro b/tests/auto/qdirmodel/qdirmodel.pro index 19ec231..5a66883 100644 --- a/tests/auto/qdirmodel/qdirmodel.pro +++ b/tests/auto/qdirmodel/qdirmodel.pro @@ -1,7 +1,7 @@ load(qttest_p4) SOURCES += tst_qdirmodel.cpp -wince*|symbian: { +wince*|symbian { addit.sources = dirtest\test1\* addit.path = dirtest\test1 tests.sources = test\* @@ -13,7 +13,7 @@ wince*|symbian: { wince*: { DEFINES += SRCDIR=\\\"./\\\" -} symbian: { +} else:symbian { TARGET.UID3 = 0xE0340003 DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) } else { diff --git a/tests/auto/qfile/test/test.pro b/tests/auto/qfile/test/test.pro index 80102f0..46f63b3 100644 --- a/tests/auto/qfile/test/test.pro +++ b/tests/auto/qfile/test/test.pro @@ -1,7 +1,7 @@ load(qttest_p4) SOURCES += ../tst_qfile.cpp -wince*|symbian:{ +wince*|symbian { QT = core gui files.sources += ..\dosfile.txt ..\noendofline.txt ..\testfile.txt \ ..\testlog.txt ..\two.dots.file ..\tst_qfile.cpp \ @@ -13,10 +13,10 @@ wince*|symbian:{ DEPLOYMENT = files resour } -wince*:{ +wince* { DEFINES += SRCDIR=\\\"\\\" -} symbian: { - # don't define SRCDIR at all +} else:symbian { + # do not define SRCDIR at all TARGET.EPOCHEAPSIZE = 0x100000 0x3000000 } else { QT = core network diff --git a/tests/auto/qfiledialog/qfiledialog.pro b/tests/auto/qfiledialog/qfiledialog.pro index 058acc5..2b87cf1 100644 --- a/tests/auto/qfiledialog/qfiledialog.pro +++ b/tests/auto/qfiledialog/qfiledialog.pro @@ -6,7 +6,7 @@ load(qttest_p4) SOURCES += tst_qfiledialog.cpp -wince*|symbian: { +wince*|symbian { addFiles.sources = *.cpp addFiles.path = . filesInDir.sources = *.pro @@ -17,9 +17,9 @@ wince*|symbian: { symbian:TARGET.EPOCHEAPSIZE="0x100 0x1000000" symbian:HEADERS += ../../../include/qtgui/private/qfileinfogatherer_p.h -wince*: { +wince* { DEFINES += SRCDIR=\\\"./\\\" -} symbian: { +} else:symbian { TARGET.UID3 = 0xE0340003 DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) } else { diff --git a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp index e33c938..6b2f0fe 100644 --- a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp @@ -72,6 +72,7 @@ private slots: void veryNarrowElidedText(); void averageCharWidth(); void elidedMultiLength(); + void bearingIncludedInBoundingRect(); }; tst_QFontMetrics::tst_QFontMetrics() @@ -210,11 +211,11 @@ void tst_QFontMetrics::elidedMultiLength() QString text1_short = "Shorter"; QString text1_small = "small"; QFontMetrics fm = QFontMetrics(QFont()); - int width_long = fm.width(text1_long); + int width_long = fm.size(0, text1_long).width(); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, 8000), text1_long); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_long + 1), text1_long); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_long - 1), text1_short); - int width_short = fm.width(text1_short); + int width_short = fm.size(0, text1_short).width(); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_short + 1), text1_short); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_short - 1), text1_small); @@ -226,5 +227,16 @@ void tst_QFontMetrics::elidedMultiLength() } +void tst_QFontMetrics::bearingIncludedInBoundingRect() +{ + QFont font; + font.setItalic(true); + QRect brectItalic = QFontMetrics(font).boundingRect("ITALIC"); + font.setItalic(false); + QRect brectNormal = QFontMetrics(font).boundingRect("ITALIC"); + + QVERIFY(brectItalic.width() > brectNormal.width()); +} + QTEST_MAIN(tst_QFontMetrics) #include "tst_qfontmetrics.moc" diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index b8061da..5e8f4c4 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -164,7 +164,6 @@ public slots: void init(); private slots: - void explicitDeleteAutoFocusProxy(); void construction(); void constructionWithParent(); void destruction(); @@ -284,9 +283,7 @@ private slots: void hitTestUntransformableItem(); void hitTestGraphicsEffectItem(); void focusProxy(); - void autoDetectFocusProxy(); void subFocus(); - void reverseCreateAutoFocusProxy(); void focusProxyDeletion(); void negativeZStacksBehindParent(); void setGraphicsEffect(); @@ -707,6 +704,9 @@ void tst_QGraphicsItem::flags() QCOMPARE(item->flags(), 0); QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + scene.addItem(item); { @@ -891,6 +891,9 @@ void tst_QGraphicsItem::visible() QVERIFY(item->isVisible()); QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + scene.addItem(item); QVERIFY(item->isVisible()); QCOMPARE(scene.itemAt(0, 0), item); @@ -1038,6 +1041,9 @@ void tst_QGraphicsItem::enabled() item->setEnabled(false); item->setFlag(QGraphicsItem::ItemIsFocusable); QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + scene.addItem(item); item->setFocus(); QVERIFY(!item->hasFocus()); @@ -1717,6 +1723,9 @@ void tst_QGraphicsItem::hasFocus() QVERIFY(!line->hasFocus()); QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + scene.addItem(line); line->setFocus(); @@ -1726,6 +1735,8 @@ void tst_QGraphicsItem::hasFocus() QVERIFY(line->hasFocus()); QGraphicsScene scene2; + QApplication::sendEvent(&scene2, &activate); + scene2.addItem(line); QVERIFY(!line->hasFocus()); @@ -3496,6 +3507,9 @@ void tst_QGraphicsItem::handlesChildEvents2() void tst_QGraphicsItem::handlesChildEvents3() { QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + ChildEventTester *group2 = new ChildEventTester(QRectF(), 0); ChildEventTester *group1 = new ChildEventTester(QRectF(), group2); ChildEventTester *leaf = new ChildEventTester(QRectF(), group1); @@ -4469,8 +4483,13 @@ protected: void tst_QGraphicsItem::sceneEventFilter() { QGraphicsScene scene; + QGraphicsView view(&scene); view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(250); QGraphicsTextItem *text1 = scene.addText(QLatin1String("Text1")); QGraphicsTextItem *text2 = scene.addText(QLatin1String("Text2")); @@ -4587,8 +4606,10 @@ void tst_QGraphicsItem::paint() QGraphicsView view(&scene); view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif QTest::qWait(250); - #ifdef Q_OS_WIN32 //we try to switch the desktop: if it fails, we skip the test if (::SwitchDesktop( ::GetThreadDesktop( ::GetCurrentThreadId() ) ) == 0) { @@ -4596,8 +4617,7 @@ void tst_QGraphicsItem::paint() } #endif - QVERIFY(paintTester.widget == view.viewport()); - + QCOMPARE(paintTester.widget, view.viewport()); view.hide(); @@ -5602,6 +5622,9 @@ void tst_QGraphicsItem::task240400_clickOnTextItem() QFETCH(int, textFlags); QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + QGraphicsTextItem *item = scene.addText("Hello"); item->setFlags(QGraphicsItem::GraphicsItemFlags(flags)); item->setTextInteractionFlags(Qt::TextInteractionFlags(textFlags)); @@ -6437,6 +6460,7 @@ void tst_QGraphicsItem::tabChangesFocus() QDial *dial1 = new QDial; QGraphicsView *view = new QGraphicsView(&scene); + QDial *dial2 = new QDial; QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(dial1); @@ -6449,6 +6473,8 @@ void tst_QGraphicsItem::tabChangesFocus() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&widget); #endif + QTest::qWait(250); + QVERIFY(scene.isActive()); dial1->setFocus(); QTest::qWait(125); @@ -7475,6 +7501,9 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() void tst_QGraphicsItem::focusProxy() { QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + QGraphicsItem *item = scene.addRect(0, 0, 10, 10); item->setFlag(QGraphicsItem::ItemIsFocusable); QVERIFY(!item->focusProxy()); @@ -7551,31 +7580,6 @@ void tst_QGraphicsItem::focusProxy() QCOMPARE(item3->focusProxy(), (QGraphicsItem *)0); } -void tst_QGraphicsItem::autoDetectFocusProxy() -{ - QGraphicsScene scene; - QGraphicsItem *item = scene.addRect(0, 0, 10, 10); - item->setFlag(QGraphicsItem::ItemIsFocusable); - - QGraphicsItem *item2 = scene.addRect(0, 0, 10, 10); - item2->setParentItem(item); - item2->setFlag(QGraphicsItem::ItemIsFocusable); - - QGraphicsItem *item3 = scene.addRect(0, 0, 10, 10); - item3->setParentItem(item2); - item3->setFlag(QGraphicsItem::ItemIsFocusable); - - item->setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy); - QCOMPARE(item->focusProxy(), (QGraphicsItem *)0); - - item2->setFocus(); - QCOMPARE(item->focusProxy(), item2); - item3->setFocus(); - QCOMPARE(item->focusProxy(), item3); - item3->clearFocus(); - QCOMPARE(item->focusProxy(), item3); -} - void tst_QGraphicsItem::subFocus() { // Construct a text item that's not part of a scene (yet) @@ -7598,6 +7602,9 @@ void tst_QGraphicsItem::subFocus() // Add both items to a scene and check that it's text that // got input focus. QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + scene.addItem(text); scene.addItem(text2); QVERIFY(text->hasFocus()); @@ -7606,18 +7613,16 @@ void tst_QGraphicsItem::subFocus() text2->setData(0, "text2"); // Remove text2 and set subfocus on it. Then readd. Reparent it onto the - // other item and see that although it becomes text's focus - // item, it does not immediately gain input focus. + // other item and see that it gains input focus. scene.removeItem(text2); text2->setFocus(); scene.addItem(text2); QCOMPARE(text2->focusItem(), (QGraphicsItem *)text2); text2->setParentItem(text); - qDebug() << text->data(0).toString() << (void*)(QGraphicsItem *)text; - qDebug() << text2->data(0).toString() << (void*)(QGraphicsItem *)text2; QCOMPARE(text->focusItem(), (QGraphicsItem *)text2); - QVERIFY(text->hasFocus()); - QVERIFY(!text2->hasFocus()); + QCOMPARE(text2->focusItem(), (QGraphicsItem *)text2); + QVERIFY(!text->hasFocus()); + QVERIFY(text2->hasFocus()); // Remove both items from the scene, restore subfocus and // readd them. Now the subfocus should kick in and give @@ -7633,49 +7638,33 @@ void tst_QGraphicsItem::subFocus() // Hiding and showing text should pass focus to text2. QCOMPARE(text->focusItem(), (QGraphicsItem *)text2); QVERIFY(text2->hasFocus()); -} - -void tst_QGraphicsItem::reverseCreateAutoFocusProxy() -{ - QGraphicsTextItem *text = new QGraphicsTextItem; - text->setTextInteractionFlags(Qt::TextEditorInteraction); - text->setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy); - - QGraphicsTextItem *text2 = new QGraphicsTextItem; - text2->setTextInteractionFlags(Qt::TextEditorInteraction); - text2->setFocus(); - QVERIFY(!text2->hasFocus()); - QCOMPARE(text->focusProxy(), (QGraphicsItem *)0); - text2->setParentItem(text); - QCOMPARE(text->focusProxy(), (QGraphicsItem *)text2); - QCOMPARE(text->focusItem(), (QGraphicsItem *)text2); - - QGraphicsScene scene; - scene.addItem(text); - QVERIFY(text2->hasFocus()); -} - -void tst_QGraphicsItem::explicitDeleteAutoFocusProxy() -{ - QGraphicsTextItem *text = new QGraphicsTextItem; - text->setTextInteractionFlags(Qt::TextEditorInteraction); - text->setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy); - QGraphicsTextItem *text2 = new QGraphicsTextItem; - text2->setTextInteractionFlags(Qt::TextEditorInteraction); - text2->setFocus(); - QVERIFY(!text2->hasFocus()); - QCOMPARE(text->focusProxy(), (QGraphicsItem *)0); - text2->setParentItem(text); - QCOMPARE(text->focusProxy(), (QGraphicsItem *)text2); - QCOMPARE(text->focusItem(), (QGraphicsItem *)text2); - - QGraphicsScene scene; - scene.addItem(text); - QVERIFY(text2->hasFocus()); + // Subfocus should repropagate to root when reparenting. + QGraphicsRectItem *rect = new QGraphicsRectItem; + QGraphicsRectItem *rect2 = new QGraphicsRectItem(rect); + QGraphicsRectItem *rect3 = new QGraphicsRectItem(rect2); + rect3->setFlag(QGraphicsItem::ItemIsFocusable); - delete text2; - QCOMPARE(text->focusProxy(), (QGraphicsItem *)0); + text->setData(0, "text"); + text2->setData(0, "text2"); + rect->setData(0, "rect"); + rect2->setData(0, "rect2"); + rect3->setData(0, "rect3"); + + rect3->setFocus(); + QVERIFY(!rect3->hasFocus()); + QCOMPARE(rect->focusItem(), (QGraphicsItem *)rect3); + QCOMPARE(rect2->focusItem(), (QGraphicsItem *)rect3); + QCOMPARE(rect3->focusItem(), (QGraphicsItem *)rect3); + rect->setParentItem(text2); + QCOMPARE(text->focusItem(), (QGraphicsItem *)rect3); + QCOMPARE(text2->focusItem(), (QGraphicsItem *)rect3); + QCOMPARE(rect->focusItem(), (QGraphicsItem *)rect3); + QCOMPARE(rect2->focusItem(), (QGraphicsItem *)rect3); + QCOMPARE(rect3->focusItem(), (QGraphicsItem *)rect3); + QVERIFY(!rect->hasFocus()); + QVERIFY(!rect2->hasFocus()); + QVERIFY(rect3->hasFocus()); } void tst_QGraphicsItem::focusProxyDeletion() diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 9249f6d..626a691 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -554,6 +554,9 @@ void tst_QGraphicsProxyWidget::eventFilter() QFETCH(bool, fromObject); QGraphicsScene scene; + QEvent windowActivate(QEvent::WindowActivate); + qApp->sendEvent(&scene, &windowActivate); + SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; scene.addItem(proxy); @@ -682,18 +685,18 @@ void tst_QGraphicsProxyWidget::focusInEvent_data() // protected void focusInEvent(QFocusEvent* event) void tst_QGraphicsProxyWidget::focusInEvent() { + // ### This test is just plain old broken QFETCH(bool, widgetHasFocus); QFETCH(bool, widgetCanHaveFocus); - QGraphicsView view; - QGraphicsScene scene(&view); + QGraphicsScene scene; + QEvent windowActivate(QEvent::WindowActivate); + qApp->sendEvent(&scene, &windowActivate); + SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; proxy->setEnabled(true); scene.addItem(proxy); proxy->setVisible(true); - view.show(); - QApplication::setActiveWindow(&view); - view.activateWindow(); QWidget *widget = new QWidget; widget->resize(100, 100); @@ -706,7 +709,11 @@ void tst_QGraphicsProxyWidget::focusInEvent() proxy->setWidget(widget); proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // <- shouldn't need to do this - QTRY_VERIFY(widget->isVisible() && view.isVisible()); + + // ### This test is just plain old broken - sending a focus in event + // does not cause items to gain input focus. The widget has focus + // because the proxy has focus, not because it got this event. + QFocusEvent event(QEvent::FocusIn, Qt::TabFocusReason); event.ignore(); proxy->call_focusInEvent(&event); @@ -776,6 +783,12 @@ void tst_QGraphicsProxyWidget::focusNextPrevChild() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QApplication::setActiveWindow(&view); + QTest::qWait(250); + QTRY_COMPARE(QApplication::activeWindow(), &view); if (hasScene) { scene.addItem(proxy); proxy->show(); @@ -819,11 +832,15 @@ void tst_QGraphicsProxyWidget::focusOutEvent() SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; scene.addItem(proxy); view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif QApplication::setActiveWindow(&view); view.activateWindow(); view.setFocus(); - QTRY_VERIFY(view.isVisible()); QTest::qWait(125); + QTRY_VERIFY(view.isVisible()); + QTRY_COMPARE(QApplication::activeWindow(), &view); QWidget *widget = new QWidget; widget->setFocusPolicy(Qt::WheelFocus); @@ -1084,6 +1101,9 @@ void tst_QGraphicsProxyWidget::keyPressEvent() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QApplication::setActiveWindow(&view); + QTest::qWait(250); + QTRY_COMPARE(QApplication::activeWindow(), &view); SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!! @@ -1093,7 +1113,7 @@ void tst_QGraphicsProxyWidget::keyPressEvent() view.resize(100, 100); if (hasWidget) { proxy->setWidget(widget); - proxy->show(); + proxy->show(); } proxy->setPos(50, 0); scene.addItem(proxy); @@ -1122,6 +1142,13 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QApplication::setActiveWindow(&view); + QTest::qWait(250); + QTRY_COMPARE(QApplication::activeWindow(), &view); + SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!! @@ -1131,7 +1158,7 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent() view.resize(100, 100); if (hasWidget) { proxy->setWidget(widget); - proxy->show(); + proxy->show(); } proxy->setPos(50, 0); scene.addItem(proxy); @@ -1162,6 +1189,10 @@ void tst_QGraphicsProxyWidget::mouseDoubleClickEvent() QGraphicsView view(&scene); view.show(); + QApplication::setActiveWindow(&view); + QTest::qWait(250); + QTRY_COMPARE(QApplication::activeWindow(), &view); + SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!! QLineEdit *widget = new QLineEdit; @@ -1170,7 +1201,7 @@ void tst_QGraphicsProxyWidget::mouseDoubleClickEvent() view.resize(100, 100); if (hasWidget) { proxy->setWidget(widget); - proxy->show(); + proxy->show(); } proxy->setPos(50, 0); scene.addItem(proxy); @@ -1476,7 +1507,8 @@ void tst_QGraphicsProxyWidget::scrollUpdate() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(200); + QTRY_COMPARE(view.npaints, 1); + QTest::qWait(20); widget->paintEventRegion = QRegion(); widget->npaints = 0; view.paintEventRegion = QRegion(); @@ -1690,7 +1722,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleWidget() leftDial->setFocus(); QTest::qWait(125); - QVERIFY(leftDial->hasFocus()); + QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit); @@ -1774,7 +1806,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets() leftDial->setFocus(); QTest::qWait(125); - QVERIFY(leftDial->hasFocus()); + QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit); EventSpy eventSpy2(edit2); @@ -1908,7 +1940,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget() leftDial->setFocus(); QTest::qWait(125); - QVERIFY(leftDial->hasFocus()); + QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit1); EventSpy eventSpy2(edit2); @@ -2042,7 +2074,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() leftDial->setFocus(); QTest::qWait(125); - QVERIFY(leftDial->hasFocus()); + QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit1); EventSpy eventSpy2(edit2); @@ -2178,7 +2210,7 @@ void tst_QGraphicsProxyWidget::setFocus_simpleWidget() leftDial->setFocus(); QTest::qWait(125); - QVERIFY(leftDial->hasFocus()); + QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit); @@ -2250,7 +2282,7 @@ void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets() leftDial->setFocus(); QTest::qWait(125); - QVERIFY(leftDial->hasFocus()); + QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit); @@ -2329,7 +2361,7 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets() leftDial->setFocus(); QTest::qWait(125); - QVERIFY(leftDial->hasFocus()); + QTRY_VERIFY(leftDial->hasFocus()); EventSpy eventSpy(edit1); EventSpy eventSpy2(edit2); @@ -3230,7 +3262,8 @@ void tst_QGraphicsProxyWidget::updateAndDelete() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(200); + QTest::qWait(20); + QTRY_VERIFY(view.npaints > 0); const QRect itemDeviceBoundingRect = proxy->deviceTransform(view.viewportTransform()) .mapRect(proxy->boundingRect()).toRect(); @@ -3327,9 +3360,10 @@ void tst_QGraphicsProxyWidget::clickFocus() QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 0); QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 0); - // Spontaneous mouse click sets focus on a clickable widget. QPointF lineEditCenter = proxy->mapToScene(proxy->boundingRect().center()); - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter)); + // Spontaneous mouse click sets focus on a clickable widget. + for (int retry = 0; retry < 50 && !proxy->hasFocus(); retry++) + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter)); QVERIFY(proxy->hasFocus()); QVERIFY(proxy->widget()->hasFocus()); QCOMPARE(proxySpy.counts[QEvent::FocusIn], 1); diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index f78c59e..6998684 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -1376,6 +1376,9 @@ void tst_QGraphicsScene::removeItem() void tst_QGraphicsScene::focusItem() { QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + QVERIFY(!scene.focusItem()); QGraphicsItem *item = scene.addText("Qt"); QVERIFY(!scene.focusItem()); @@ -1434,6 +1437,9 @@ protected: void tst_QGraphicsScene::focusItemLostFocus() { QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + FocusItem *item = new FocusItem; item->setTextInteractionFlags(Qt::TextEditorInteraction); scene.addItem(item); @@ -1458,6 +1464,9 @@ void tst_QGraphicsScene::clear() void tst_QGraphicsScene::setFocusItem() { QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + QGraphicsItem *item = scene.addText("Qt"); QVERIFY(!scene.focusItem()); QVERIFY(!scene.hasFocus()); @@ -1885,6 +1894,9 @@ void tst_QGraphicsScene::mouseEventPropagation() // scene -> a -> b -> c -> d QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + scene.addItem(a); // Prepare some events @@ -2069,6 +2081,9 @@ void tst_QGraphicsScene::mouseEventPropagation_focus() // scene -> a -> b -> c -> d QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + scene.addItem(a); // Prepare some events @@ -2680,6 +2695,9 @@ void tst_QGraphicsScene::render() void tst_QGraphicsScene::contextMenuEvent() { QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + EventTester *item = new EventTester; scene.addItem(item); item->setFlag(QGraphicsItem::ItemIsFocusable); @@ -3649,6 +3667,9 @@ void tst_QGraphicsScene::stickyFocus() QFETCH(bool, sticky); QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + QGraphicsTextItem *text = scene.addText("Hei"); text->setTextInteractionFlags(Qt::TextEditorInteraction); text->setFocus(); @@ -3703,6 +3724,9 @@ void tst_QGraphicsScene::inputMethod() item->setFlags((QGraphicsItem::GraphicsItemFlags)flags); QGraphicsScene scene; + QEvent activate(QEvent::WindowActivate); + QApplication::sendEvent(&scene, &activate); + scene.addItem(item); QInputMethodEvent event; diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index bb0ea70..6c1ac54 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -379,7 +379,7 @@ void tst_QGraphicsView::interactive() view.show(); QTestEventLoop::instance().enterLoop(1); - QCOMPARE(item->events.size(), 1); // activate + QTRY_COMPARE(item->events.size(), 1); // activate QPoint itemPoint = view.mapFromScene(item->scenePos()); @@ -1869,6 +1869,9 @@ void tst_QGraphicsView::sendEvent() QGraphicsView view(&scene); view.show(); + QApplication::setActiveWindow(&view); + QTest::qWait(20); + QTRY_COMPARE(QApplication::activeWindow(), &view); QTestEventLoop::instance().enterLoop(1); @@ -1938,6 +1941,10 @@ void tst_QGraphicsView::wheelEvent() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QApplication::setActiveWindow(&view); + QTest::qWait(20); + QTRY_COMPARE(QApplication::activeWindow(), &view); + // Send a wheel event with horizontal orientation. { @@ -2941,10 +2948,10 @@ void tst_QGraphicsView::task239729_noViewUpdate() } view->show(); - QTest::qWait(250); #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(view); #endif + QTest::qWait(250); EventSpy spy(view->viewport(), QEvent::Paint); QCOMPARE(spy.count(), 0); @@ -3127,12 +3134,15 @@ void tst_QGraphicsView::moveItemWhileScrolling() setScene(new QGraphicsScene(0, 0, 1000, 1000)); rect = scene()->addRect(0, 0, 10, 10); rect->setPos(50, 50); + painted = false; } QRegion lastPaintedRegion; QGraphicsItem *rect; + bool painted; protected: void paintEvent(QPaintEvent *event) { + painted = true; lastPaintedRegion = event->region(); QGraphicsView::paintEvent(event); } @@ -3151,12 +3161,15 @@ void tst_QGraphicsView::moveItemWhileScrolling() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(200); + QTest::qWait(100); + QTRY_VERIFY(view.painted); + view.painted = false; view.lastPaintedRegion = QRegion(); view.horizontalScrollBar()->setValue(view.horizontalScrollBar()->value() + 10); view.rect->moveBy(0, 10); QTest::qWait(100); + QTRY_VERIFY(view.painted); QRegion expectedRegion; expectedRegion += QRect(0, 0, 200, 200); @@ -3418,7 +3431,7 @@ void tst_QGraphicsView::exposeRegion() QRegion expectedExposeRegion = QRect(0, 0, 5, 5); expectedExposeRegion += QRect(viewport->rect().bottomRight() - QPoint(5, 5), QSize(5, 5)); viewport->update(expectedExposeRegion); - qApp->processEvents(); + QTest::qWait(125); // Make sure it triggers correct repaint on the view. QCOMPARE(view.lastUpdateRegions.size(), 1); @@ -3488,7 +3501,7 @@ void tst_QGraphicsView::update() viewPrivate->processPendingUpdates(); QVERIFY(viewPrivate->dirtyRegion.isEmpty()); QVERIFY(viewPrivate->dirtyBoundingRect.isEmpty()); - QTest::qWait(50); + QTest::qWait(150); if (!intersects) { QVERIFY(view.lastUpdateRegions.isEmpty()); } else { @@ -3504,6 +3517,13 @@ void tst_QGraphicsView::inputMethodSensitivity() { QGraphicsScene scene; QGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QApplication::setActiveWindow(&view); + QTest::qWait(250); + QTRY_COMPARE(QApplication::activeWindow(), &view); QGraphicsRectItem *item = new QGraphicsRectItem; @@ -3571,11 +3591,12 @@ void tst_QGraphicsView::inputMethodSensitivity() class InputContextTester : public QInputContext { + Q_OBJECT +public: QString identifierName() { return QString(); } bool isComposing() const { return false; } QString language() { return QString(); } void reset() { ++resets; } -public: int resets; }; @@ -3583,10 +3604,19 @@ void tst_QGraphicsView::inputContextReset() { QGraphicsScene scene; QGraphicsView view(&scene); + QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled)); InputContextTester inputContext; view.setInputContext(&inputContext); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QApplication::setActiveWindow(&view); + QTest::qWait(20); + QTRY_COMPARE(QApplication::activeWindow(), &view); + QGraphicsItem *item1 = new QGraphicsRectItem; item1->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod); @@ -3596,6 +3626,8 @@ void tst_QGraphicsView::inputContextReset() inputContext.resets = 0; scene.setFocusItem(item1); + QCOMPARE(scene.focusItem(), (QGraphicsItem *)item1); + QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled)); QCOMPARE(inputContext.resets, 0); inputContext.resets = 0; diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 3ca1181..9045acf 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -230,7 +230,7 @@ public: int eventCount; Qt::LayoutDirection m_painterLayoutDirection; - + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { m_painterLayoutDirection = painter->layoutDirection(); @@ -276,15 +276,15 @@ class SizeHinter : public QGraphicsWidget { public: SizeHinter(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0, - const QSizeF &min = QSizeF(5,5), - const QSizeF &pref = QSizeF(50, 50), - const QSizeF &max = QSizeF(500, 500)) - : QGraphicsWidget(parent, wFlags) + const QSizeF &min = QSizeF(5,5), + const QSizeF &pref = QSizeF(50, 50), + const QSizeF &max = QSizeF(500, 500)) + : QGraphicsWidget(parent, wFlags) { m_sizes[Qt::MinimumSize] = min; m_sizes[Qt::PreferredSize] = pref; m_sizes[Qt::MaximumSize] = max; - + } void setSizeHint(Qt::SizeHint which, const QSizeF &newSizeHint) { @@ -324,11 +324,11 @@ void tst_QGraphicsWidget::qgraphicswidget() QCOMPARE(widget.type(), (int)QGraphicsWidget::Type); QCOMPARE(widget.call_propertyChange(QString(), QVariant()), QVariant()); widget.call_sizeHint(Qt::PreferredSize, QSizeF()); - + QGraphicsScene scene; QGraphicsWidget *parent = new QGraphicsWidget; SizeHinter *child = new SizeHinter(parent); - + QCOMPARE(child->minimumSize(), QSizeF(5, 5)); } @@ -438,6 +438,8 @@ void tst_QGraphicsWidget::focusWidget() SubQGraphicsWidget *parent = new SubQGraphicsWidget; QCOMPARE(parent->focusWidget(), (QGraphicsWidget *)0); QGraphicsScene scene; + QEvent windowActivate(QEvent::WindowActivate); + qApp->sendEvent(&scene, &windowActivate); scene.addItem(parent); QFETCH(int, childCount); @@ -459,7 +461,9 @@ void tst_QGraphicsWidget::focusWidget() void tst_QGraphicsWidget::focusWidget2() { QGraphicsScene scene; - + QEvent windowActivate(QEvent::WindowActivate); + qApp->sendEvent(&scene, &windowActivate); + QGraphicsWidget *widget = new QGraphicsWidget; EventSpy focusInSpy(widget, QEvent::FocusIn); EventSpy focusOutSpy(widget, QEvent::FocusOut); @@ -478,7 +482,7 @@ void tst_QGraphicsWidget::focusWidget2() QVERIFY(!widget->hasFocus()); QVERIFY(!subWidget->hasFocus()); - widget->setFocus(); + widget->setFocus(); QVERIFY(widget->hasFocus()); QCOMPARE(focusInSpy.count(), 1); @@ -561,6 +565,9 @@ void tst_QGraphicsWidget::focusPolicy_data() void tst_QGraphicsWidget::focusPolicy() { QGraphicsScene scene; + QEvent windowActivate(QEvent::WindowActivate); + qApp->sendEvent(&scene, &windowActivate); + SubQGraphicsWidget *widget = new SubQGraphicsWidget; scene.addItem(widget); QCOMPARE(Qt::NoFocus, widget->focusPolicy()); @@ -695,7 +702,7 @@ void tst_QGraphicsWidget::fontPropagationSceneChange() QFont font; font.setPointSize(47); scene.setFont(font); - + QFont font2; font2.setPointSize(74); scene2.setFont(font2); @@ -788,6 +795,14 @@ void tst_QGraphicsWidget::initStyleOption() { QGraphicsScene scene; QGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QApplication::setActiveWindow(&view); + QTest::qWait(25); + QTRY_COMPARE(QApplication::activeWindow(), &view); + view.setAlignment(Qt::AlignTop | Qt::AlignLeft); SubQGraphicsWidget *widget = new SubQGraphicsWidget; widget->setAcceptsHoverEvents(true); @@ -1119,6 +1134,9 @@ void tst_QGraphicsWidget::setTabOrder() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QApplication::setActiveWindow(&view); + QTest::qWait(25); + QTRY_COMPARE(QApplication::activeWindow(), &view); QGraphicsWidget *lastItem = 0; QTest::ignoreMessage(QtWarningMsg, "QGraphicsWidget::setTabOrder(0, 0) is undefined"); @@ -1183,6 +1201,10 @@ void tst_QGraphicsWidget::setTabOrderAndReparent() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QApplication::setActiveWindow(&view); + QTest::qWait(25); + QTRY_COMPARE(QApplication::activeWindow(), &view); + int i; QGraphicsWidget *w1, *w2, *w3, *w4; for (i = 1; i < 4; ++i) { @@ -1199,29 +1221,29 @@ void tst_QGraphicsWidget::setTabOrderAndReparent() } w1->setFocus(); - QVERIFY(w1->hasFocus()); + QTRY_VERIFY(w1->hasFocus()); QVERIFY(compareFocusChain(&view, QList<QGraphicsItem*>() << w1 << w2 << w3)); QGraphicsWidget *p = new QGraphicsWidget; p->setData(0, QLatin1String("parent")); p->setFocusPolicy(Qt::StrongFocus); - + w1->setFocus(); QVERIFY(compareFocusChain(&view, QList<QGraphicsItem*>() << w1 << w2 << w3)); - + w1->setParentItem(p); w2->setFocus(); QVERIFY(compareFocusChain(&view, QList<QGraphicsItem*>() << w2 << w3)); - + w2->setParentItem(p); w3->setFocus(); QVERIFY(compareFocusChain(&view, QList<QGraphicsItem*>() << w3)); w3->setParentItem(p); QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem*>(0)); - + scene.addItem(p); p->setFocus(); - + QVERIFY(compareFocusChain(&view, QList<QGraphicsItem*>() << p << w1 << w2 << w3)); delete p; @@ -1243,7 +1265,7 @@ void tst_QGraphicsWidget::setTabOrderAndReparent() QGraphicsWidget::setTabOrder(w1, w4); w1->setFocus(); QVERIFY(compareFocusChain(&view, QList<QGraphicsItem*>() << w1 << w4 << w2 << w3)); - + p = new QGraphicsWidget; p->setData(0, QLatin1String("parent")); p->setFocusPolicy(Qt::StrongFocus); @@ -1251,7 +1273,7 @@ void tst_QGraphicsWidget::setTabOrderAndReparent() w1->setParentItem(p); w2->setFocus(); QVERIFY(compareFocusChain(&view, QList<QGraphicsItem*>() << w2 << w3)); - + scene.addItem(p); w2->setFocus(); QVERIFY(compareFocusChain(&view, QList<QGraphicsItem*>() << w2 << w3 << p << w1 << w4)); @@ -1322,7 +1344,10 @@ void tst_QGraphicsWidget::verifyFocusChain() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(250); + QApplication::setActiveWindow(&view); + QTest::qWait(25); + QTRY_COMPARE(QApplication::activeWindow(), &view); + { // parent/child focus SubQGraphicsWidget *w = new SubQGraphicsWidget(0, Qt::Window); @@ -1397,7 +1422,7 @@ void tst_QGraphicsWidget::verifyFocusChain() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(window); #endif - + lineEdit->setFocus(); QTest::qWait(250); QVERIFY(lineEdit->hasFocus()); @@ -1434,7 +1459,7 @@ void tst_QGraphicsWidget::verifyFocusChain() w1_4->setFocusPolicy(Qt::StrongFocus); w1_4->setData(0, "w1_4"); w1_4->setGeometry(75,0,25, 25); - scene.addItem(w1_4); + scene.addItem(w1_4); QVERIFY(w1_3->hasFocus()); QTest::qWait(250); QVERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); @@ -1444,7 +1469,7 @@ void tst_QGraphicsWidget::verifyFocusChain() // tabFocusFirst should now point to w1_3 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); QTest::qWait(250); - QVERIFY(w1_3->hasFocus()); + QVERIFY(w1_3->hasFocus()); QTest::qWait(250); QVERIFY(compareFocusChain(view, QList<QGraphicsItem*>() << w1_3 << w1_4)); delete window; @@ -1459,7 +1484,9 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(250); + QApplication::setActiveWindow(&view); + QTest::qWait(25); + QTRY_COMPARE(QApplication::activeWindow(), &view); // delete item in focus chain with no focus and verify chain SubQGraphicsWidget *parent = new SubQGraphicsWidget(0, Qt::Window); @@ -1613,7 +1640,7 @@ void tst_QGraphicsWidget::setSizes_data() << (QVector<Inst>() << Inst(MinimumSize, QSizeF(5, 5))); QTest::newRow("unsetMaxSize")<< (QVector<Inst>() << Inst(Size, QSizeF(40, 40)) << Inst(MaximumSize, QSizeF(-1, -1))) << (QVector<Inst>() << Inst(MaximumSize, QSizeF(500, 500))); - QTest::newRow("unsetMinSize, expand size to minimumSizeHint") << (QVector<Inst>() + QTest::newRow("unsetMinSize, expand size to minimumSizeHint") << (QVector<Inst>() << Inst(MinimumSize, QSize(0, 0)) << Inst(Size, QSize(1,1)) << Inst(MinimumSize, QSize(-1.0, -1.0)) @@ -1693,7 +1720,7 @@ void tst_QGraphicsWidget::setSizes() widget->setMaximumSize(max); QApplication::processEvents(); - + for (i = 0; i < compareInstructions.count(); ++i) { Inst input = compareInstructions.at(i); switch (input.first) { @@ -2417,7 +2444,9 @@ void tst_QGraphicsWidget::task250119_shortcutContext() QGraphicsView view; view.setScene(&scene); view.show(); - QTest::qWait(100); + QApplication::setActiveWindow(&view); + QTest::qWait(25); + QTRY_COMPARE(QApplication::activeWindow(), &view); // *** Event: *** @@ -2589,6 +2618,9 @@ protected: void tst_QGraphicsWidget::respectHFW() { +#if defined(Q_OS_WINCE) || defined(Q_OS_MAC) || defined(Q_WS_QWS) + qDebug("This test is platform dependent, it fails on wince, mac and qws. Please fix."); +#else QGraphicsScene scene; HFWWidget *window = new HFWWidget; scene.addItem(window); @@ -2620,6 +2652,7 @@ void tst_QGraphicsWidget::respectHFW() const QSizeF winSize = window->size(); qreal minHFW = window->effectiveSizeHint(Qt::MinimumSize, QSizeF(winSize.width(), -1)).height(); QVERIFY(qAbs(minHFW - winSize.height()) < 1); +#endif } QTEST_MAIN(tst_QGraphicsWidget) diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp index d5be332..ac6adf7 100644 --- a/tests/auto/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp @@ -243,7 +243,7 @@ void tst_QHostInfo::lookupIPv4() lookupDone = false; QHostInfo::lookupHost(hostname, this, SLOT(resultsReady(const QHostInfo&))); - QTestEventLoop::instance().enterLoop(3); + QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(lookupDone); diff --git a/tests/auto/qmainwindow/tst_qmainwindow.cpp b/tests/auto/qmainwindow/tst_qmainwindow.cpp index 6505f90..38d23b6 100644 --- a/tests/auto/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/qmainwindow/tst_qmainwindow.cpp @@ -1692,8 +1692,12 @@ void tst_QMainWindow::dockWidgetSize() mainWindow.show(); QTest::qWait(100); - QCOMPARE(widget.size(), widget.sizeHint()); - QCOMPARE(dock.widget()->size(), dock.widget()->sizeHint()); + if (mainWindow.size() == mainWindow.sizeHint()) { + QCOMPARE(widget.size(), widget.sizeHint()); + QCOMPARE(dock.widget()->size(), dock.widget()->sizeHint()); + } else { + //otherwise the screen is too small and the size are irrelevant + } } diff --git a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp index 293cde9..e78253b 100644 --- a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp +++ b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp @@ -109,6 +109,9 @@ tst_QScriptEngineDebugger::~tst_QScriptEngineDebugger() void tst_QScriptEngineDebugger::attachAndDetach() { +#if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600 + QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll); +#endif { QScriptEngineDebugger debugger; QCOMPARE(debugger.state(), QScriptEngineDebugger::SuspendedState); @@ -173,6 +176,10 @@ void tst_QScriptEngineDebugger::attachAndDetach() void tst_QScriptEngineDebugger::action() { +#if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600 + QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll); +#endif + QScriptEngine engine; QScriptEngineDebugger debugger; debugger.attachTo(&engine); @@ -207,6 +214,10 @@ void tst_QScriptEngineDebugger::action() void tst_QScriptEngineDebugger::widget() { +#if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600 + QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll); +#endif + QScriptEngine engine; QScriptEngineDebugger debugger; debugger.attachTo(&engine); @@ -235,6 +246,10 @@ void tst_QScriptEngineDebugger::widget() void tst_QScriptEngineDebugger::standardObjects() { +#if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600 + QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll); +#endif + QScriptEngine engine; QScriptEngineDebugger debugger; debugger.attachTo(&engine); @@ -260,6 +275,10 @@ void tst_QScriptEngineDebugger::standardObjects() void tst_QScriptEngineDebugger::debuggerSignals() { +#if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600 + QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll); +#endif + QScriptEngine engine; QScriptEngineDebugger debugger; debugger.attachTo(&engine); diff --git a/tests/auto/qsqldriver/tst_qsqldriver.cpp b/tests/auto/qsqldriver/tst_qsqldriver.cpp index a10bd14..f463c9e 100644 --- a/tests/auto/qsqldriver/tst_qsqldriver.cpp +++ b/tests/auto/qsqldriver/tst_qsqldriver.cpp @@ -160,7 +160,7 @@ void tst_QSqlDriver::record() //check that we can't get records using incorrect tablename casing that's been quoted rec = db.driver()->record(db.driver()->escapeIdentifier(tablename,QSqlDriver::TableName)); - if (tst_Databases::isMySQL(db) || db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QTDS")) + if (tst_Databases::isMySQL(db) || db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QTDS") || tst_Databases::isSqlServer(db)) QCOMPARE(rec.count(), 4); //mysql, sqlite and tds will match else QCOMPARE(rec.count(), 0); @@ -208,7 +208,7 @@ void tst_QSqlDriver::primaryIndex() tablename = tablename.toUpper(); index = db.driver()->primaryIndex(db.driver()->escapeIdentifier(tablename, QSqlDriver::TableName)); - if (tst_Databases::isMySQL(db) || db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QTDS")) + if (tst_Databases::isMySQL(db) || db.driverName().startsWith("QSQLITE") || db.driverName().startsWith("QTDS") || tst_Databases::isSqlServer(db)) QCOMPARE(index.count(), 1); //mysql will always find the table name regardless of casing else QCOMPARE(index.count(), 0); diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 5d21955..8d9a50c 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -2351,7 +2351,7 @@ void tst_QTableView::scrollTo() for (int c = 0; c < columnCount; ++c) view.setColumnWidth(c, columnWidth); - QTest::qWait(50); // ### needed to pass the test + QTest::qWait(100); // ### needed to pass the test view.horizontalScrollBar()->setValue(horizontalScroll); view.verticalScrollBar()->setValue(verticalScroll); diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp index 77d7aee..64bdfd0 100644 --- a/tests/auto/qthread/tst_qthread.cpp +++ b/tests/auto/qthread/tst_qthread.cpp @@ -629,6 +629,12 @@ void noop(void*) { } typedef HANDLE ThreadHandle; #endif +#ifdef Q_OS_WIN +#define WIN_FIX_STDCALL __stdcall +#else +#define WIN_FIX_STDCALL +#endif + class NativeThreadWrapper { public: @@ -639,7 +645,7 @@ public: void setWaitForStop() { waitForStop = true; } void stop(); - ThreadHandle nativeThread; + ThreadHandle nativeThreadHandle; QThread *qthread; QWaitCondition startCondition; QMutex mutex; @@ -647,7 +653,7 @@ public: QWaitCondition stopCondition; protected: static void *runUnix(void *data); - static void runWin(void *data); + static unsigned WIN_FIX_STDCALL runWin(void *data); FunctionPointer functionPointer; void *data; @@ -658,12 +664,13 @@ void NativeThreadWrapper::start(FunctionPointer functionPointer, void *data) this->functionPointer = functionPointer; this->data = data; #ifdef Q_OS_UNIX - const int state = pthread_create(&nativeThread, 0, NativeThreadWrapper::runUnix, this); + const int state = pthread_create(&nativeThreadHandle, 0, NativeThreadWrapper::runUnix, this); Q_UNUSED(state); #elif defined(Q_OS_WINCE) - nativeThread = CreateThread(NULL, 0 , (LPTHREAD_START_ROUTINE)NativeThreadWrapper::runWin , this, 0, NULL); + nativeThreadHandle = CreateThread(NULL, 0 , (LPTHREAD_START_ROUTINE)NativeThreadWrapper::runWin , this, 0, NULL); #elif defined Q_OS_WIN - nativeThread = (HANDLE)_beginthread(NativeThreadWrapper::runWin, 0, this); + unsigned thrdid = 0; + nativeThreadHandle = (Qt::HANDLE) _beginthreadex(NULL, 0, NativeThreadWrapper::runWin, this, 0, &thrdid); #endif } @@ -677,9 +684,10 @@ void NativeThreadWrapper::startAndWait(FunctionPointer functionPointer, void *da void NativeThreadWrapper::join() { #ifdef Q_OS_UNIX - pthread_join(nativeThread, 0); + pthread_join(nativeThreadHandle, 0); #elif defined Q_OS_WIN - WaitForSingleObject(nativeThread, INFINITE); + WaitForSingleObject(nativeThreadHandle, INFINITE); + CloseHandle(nativeThreadHandle); #endif } @@ -687,7 +695,7 @@ void *NativeThreadWrapper::runUnix(void *that) { NativeThreadWrapper *nativeThreadWrapper = reinterpret_cast<NativeThreadWrapper*>(that); - // Adoppt thread, create QThread object. + // Adopt thread, create QThread object. nativeThreadWrapper->qthread = QThread::currentThread(); // Release main thread. @@ -709,9 +717,10 @@ void *NativeThreadWrapper::runUnix(void *that) return 0; } -void NativeThreadWrapper::runWin(void *data) +unsigned WIN_FIX_STDCALL NativeThreadWrapper::runWin(void *data) { runUnix(data); + return 0; } void NativeThreadWrapper::stop() diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 4599e8b..1a2de65 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -206,12 +206,12 @@ void tst_Selftests::doRunSubTest(QString &subdir, QStringList &arguments ) const QByteArray out(proc.readAllStandardOutput()); const QByteArray err(proc.readAllStandardError()); - /* Windows-MSVC decide to output an error message when exceptions are thrown, - * so let's not check stderr for those. */ -#if defined(Q_OS_WIN) - if(subdir != QLatin1String("exceptionthrow") && subdir != QLatin1String("fetchbogus")) -#endif - if(subdir != QLatin1String("xunit")) + /* Some platforms decides to output a message for uncaught exceptions. For instance, + * this is what windows platforms says: + * "This application has requested the Runtime to terminate it in an unusual way. + * Please contact the application's support team for more information." */ + if(subdir != QLatin1String("exceptionthrow") && subdir != QLatin1String("fetchbogus") + && subdir != QLatin1String("xunit")) QVERIFY2(err.isEmpty(), err.constData()); QList<QByteArray> res = splitLines(out); diff --git a/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp b/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp index 700c3fc..3303b16 100644 --- a/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp +++ b/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp @@ -1,7 +1,3 @@ -#include "mousestatwidget.h" - -#include <QTabletEvent> -#include <QPainter> /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). @@ -43,6 +39,10 @@ ** ****************************************************************************/ +#include "mousestatwidget.h" + +#include <QTabletEvent> +#include <QPainter> #include <QTextOption> #include <QTest> |