From 0a98247f5df26d9865a03fc6e5ad1ef7b88f9803 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Tue, 8 Sep 2009 09:54:41 -0300 Subject: doc: Fix qmake-manual warn_on/warn_off references Signed-off-by: Ademar de Souza Reis Jr --- doc/src/development/qmake-manual.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index 9548848..549c801 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -1977,7 +1977,7 @@ distinction between shared and \section1 QMAKE_CFLAGS_WARN_OFF This variable is not empty if the warn_off - \l{#TEMPLATE}{TEMPLATE} option is specified. The value of this + \l{#CONFIG}{CONFIG} option is specified. The value of this variable is typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. @@ -1985,7 +1985,7 @@ distinction between shared and \section1 QMAKE_CFLAGS_WARN_ON This variable is not empty if the warn_on - \l{#TEMPLATE}{TEMPLATE} option is specified. + \l{#CONFIG}{CONFIG} option is specified. The value of this variable is typically handled by \c qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. -- cgit v0.12 From 8364bfd6c4be53fba4aad41d5cbbc16ca02b2597 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Tue, 15 Sep 2009 11:18:23 -0300 Subject: doc: Fix typo in QEvent::ignore() documentation Signed-off-by: Ademar de Souza Reis Jr --- src/corelib/kernel/qcoreevent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index 9098515..996c331 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -331,7 +331,7 @@ QEvent::~QEvent() equivalent of calling setAccepted(false). Clearing the accept parameter indicates that the event receiver - does not want the event. Unwanted events might be propgated to the + does not want the event. Unwanted events might be propagated to the parent widget. \sa accept() -- cgit v0.12 From af265e912fab8b7ed5369a4c91f5a7ffd516441b Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Fri, 6 Nov 2009 16:19:15 -0300 Subject: examples/dbus: update dbus-chat adaptor/interface files The example was outdated, thus causing some confusion for someone who tries to follow it. --- examples/dbus/dbus-chat/chat_adaptor.cpp | 6 +++--- examples/dbus/dbus-chat/chat_adaptor.h | 27 ++++++++++++--------------- examples/dbus/dbus-chat/chat_interface.cpp | 6 +++--- examples/dbus/dbus-chat/chat_interface.h | 10 +++++----- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/examples/dbus/dbus-chat/chat_adaptor.cpp b/examples/dbus/dbus-chat/chat_adaptor.cpp index dce5d07..9415e5a 100644 --- a/examples/dbus/dbus-chat/chat_adaptor.cpp +++ b/examples/dbus/dbus-chat/chat_adaptor.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -i chat_adaptor.h -a :chat_adaptor.cpp com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i chat_adaptor.h -a :chat_adaptor.cpp com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. diff --git a/examples/dbus/dbus-chat/chat_adaptor.h b/examples/dbus/dbus-chat/chat_adaptor.h index 3266cef..9f0ad24 100644 --- a/examples/dbus/dbus-chat/chat_adaptor.h +++ b/examples/dbus/dbus-chat/chat_adaptor.h @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -a chat_adaptor.h: com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -a chat_adaptor.h: com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments @@ -49,20 +49,17 @@ ** ****************************************************************************/ -#ifndef CHAT_ADAPTOR_H_142741156243605 -#define CHAT_ADAPTOR_H_142741156243605 +#ifndef CHAT_ADAPTOR_H_1257535021 +#define CHAT_ADAPTOR_H_1257535021 #include #include - -QT_BEGIN_NAMESPACE class QByteArray; template class QList; template class QMap; class QString; class QStringList; class QVariant; -QT_END_NAMESPACE /* * Adaptor class for interface com.trolltech.chat @@ -72,14 +69,14 @@ class ChatAdaptor: public QDBusAbstractAdaptor Q_OBJECT Q_CLASSINFO("D-Bus Interface", "com.trolltech.chat") Q_CLASSINFO("D-Bus Introspection", "" -" \n" -" \n" -" \n" -" \n" +" \n" +" \n" +" \n" +" \n" " \n" -" \n" -" \n" -" \n" +" \n" +" \n" +" \n" " \n" " \n" "") diff --git a/examples/dbus/dbus-chat/chat_interface.cpp b/examples/dbus/dbus-chat/chat_interface.cpp index bf652ea..3131ae9 100644 --- a/examples/dbus/dbus-chat/chat_interface.cpp +++ b/examples/dbus/dbus-chat/chat_interface.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -i chat_interface.h -p :chat_interface.cpp chat/com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i chat_interface.h -p :chat_interface.cpp com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments diff --git a/examples/dbus/dbus-chat/chat_interface.h b/examples/dbus/dbus-chat/chat_interface.h index 3962a23..e2798ed 100644 --- a/examples/dbus/dbus-chat/chat_interface.h +++ b/examples/dbus/dbus-chat/chat_interface.h @@ -38,18 +38,18 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -p chat_interface.h: com.trolltech.chat.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -p chat_interface.h: com.trolltech.chat.xml ** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. ** ****************************************************************************/ -#ifndef CHAT_INTERFACE_H_143021156243606 -#define CHAT_INTERFACE_H_143021156243606 +#ifndef CHAT_INTERFACE_H_1257535021 +#define CHAT_INTERFACE_H_1257535021 #include #include -- cgit v0.12 From 9fc350e8358f55c13169a9383bd2bd85592bb231 Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Fri, 6 Nov 2009 16:49:12 -0300 Subject: examples/dbus: update remotecontrolledcar example The example was outdated, thus causing some confusion for someone who tries to follow it. --- examples/dbus/remotecontrolledcar/car/car.pro | 2 +- .../dbus/remotecontrolledcar/car/car_adaptor.cpp | 22 ++-- .../dbus/remotecontrolledcar/car/car_adaptor_p.h | 97 ------------------ examples/dbus/remotecontrolledcar/car/main.cpp | 4 +- .../controller/car_interface.cpp | 15 ++- .../controller/car_interface_p.h | 114 --------------------- .../remotecontrolledcar/controller/controller.cpp | 4 +- .../remotecontrolledcar/controller/controller.h | 5 +- .../remotecontrolledcar/controller/controller.pro | 2 +- 9 files changed, 26 insertions(+), 239 deletions(-) delete mode 100644 examples/dbus/remotecontrolledcar/car/car_adaptor_p.h delete mode 100644 examples/dbus/remotecontrolledcar/controller/car_interface_p.h diff --git a/examples/dbus/remotecontrolledcar/car/car.pro b/examples/dbus/remotecontrolledcar/car/car.pro index 9b426d3..d362dc9 100644 --- a/examples/dbus/remotecontrolledcar/car/car.pro +++ b/examples/dbus/remotecontrolledcar/car/car.pro @@ -10,7 +10,7 @@ CONFIG += qdbus # Input # DBUS_ADAPTORS += car.xml -HEADERS += car.h car_adaptor_p.h +HEADERS += car.h car_adaptor.h SOURCES += car.cpp main.cpp car_adaptor.cpp # install diff --git a/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp b/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp index 58f2ef0..8654663 100644 --- a/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp +++ b/examples/dbus/remotecontrolledcar/car/car_adaptor.cpp @@ -38,17 +38,17 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i car_adaptor.h -a :car_adaptor.cpp car.xml ** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** Do not edit! All changes made to it will be lost. ** ****************************************************************************/ -#include "car_adaptor_p.h" +#include "car_adaptor.h" #include #include #include @@ -58,40 +58,40 @@ #include /* - * Implementation of adaptor class CarAdaptor + * Implementation of adaptor class CarInterfaceAdaptor */ -CarAdaptor::CarAdaptor(QObject *parent) +CarInterfaceAdaptor::CarInterfaceAdaptor(QObject *parent) : QDBusAbstractAdaptor(parent) { // constructor setAutoRelaySignals(true); } -CarAdaptor::~CarAdaptor() +CarInterfaceAdaptor::~CarInterfaceAdaptor() { // destructor } -void CarAdaptor::accelerate() +void CarInterfaceAdaptor::accelerate() { // handle method call com.trolltech.Examples.CarInterface.accelerate QMetaObject::invokeMethod(parent(), "accelerate"); } -void CarAdaptor::decelerate() +void CarInterfaceAdaptor::decelerate() { // handle method call com.trolltech.Examples.CarInterface.decelerate QMetaObject::invokeMethod(parent(), "decelerate"); } -void CarAdaptor::turnLeft() +void CarInterfaceAdaptor::turnLeft() { // handle method call com.trolltech.Examples.CarInterface.turnLeft QMetaObject::invokeMethod(parent(), "turnLeft"); } -void CarAdaptor::turnRight() +void CarInterfaceAdaptor::turnRight() { // handle method call com.trolltech.Examples.CarInterface.turnRight QMetaObject::invokeMethod(parent(), "turnRight"); diff --git a/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h b/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h deleted file mode 100644 index 6d98c5b..0000000 --- a/examples/dbus/remotecontrolledcar/car/car_adaptor_p.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** 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 examples 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$ -** -** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarAdaptor -a car_adaptor_p.h:car_adaptor.cpp car.xml -** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** This is an auto-generated file. -** This file may have been hand-edited. Look for HAND-EDIT comments -** before re-generating it. -** -****************************************************************************/ - -#ifndef CAR_ADAPTOR_P_H_1157030132 -#define CAR_ADAPTOR_P_H_1157030132 - -#include -#include - -QT_BEGIN_NAMESPACE -class QByteArray; -template class QList; -template class QMap; -class QString; -class QStringList; -class QVariant; -QT_END_NAMESPACE - -/* - * Adaptor class for interface com.trolltech.Examples.CarInterface - */ -class CarAdaptor: public QDBusAbstractAdaptor -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "com.trolltech.Examples.CarInterface") - Q_CLASSINFO("D-Bus Introspection", "" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" - "") -public: - CarAdaptor(QObject *parent); - virtual ~CarAdaptor(); - -public: // PROPERTIES -public Q_SLOTS: // METHODS - void accelerate(); - void decelerate(); - void turnLeft(); - void turnRight(); -Q_SIGNALS: // SIGNALS - void crashed(); -}; - -#endif diff --git a/examples/dbus/remotecontrolledcar/car/main.cpp b/examples/dbus/remotecontrolledcar/car/main.cpp index c2ef91c..456ff11 100644 --- a/examples/dbus/remotecontrolledcar/car/main.cpp +++ b/examples/dbus/remotecontrolledcar/car/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "car.h" -#include "car_adaptor_p.h" +#include "car_adaptor.h" #include #include #include @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) view.resize(400, 300); view.show(); - new CarAdaptor(car); + new CarInterfaceAdaptor(car); QDBusConnection connection = QDBusConnection::sessionBus(); connection.registerObject("/Car", car); connection.registerService("com.trolltech.CarExample"); diff --git a/examples/dbus/remotecontrolledcar/controller/car_interface.cpp b/examples/dbus/remotecontrolledcar/controller/car_interface.cpp index eeeb162..14258d6 100644 --- a/examples/dbus/remotecontrolledcar/controller/car_interface.cpp +++ b/examples/dbus/remotecontrolledcar/controller/car_interface.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarInterface -p car_interface_p.h:car_interface.cpp car.xml +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i car_interface.h -p :car_interface.cpp car.xml ** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** ** This is an auto-generated file. ** This file may have been hand-edited. Look for HAND-EDIT comments @@ -49,18 +49,17 @@ ** ****************************************************************************/ -#include "car_interface_p.h" - +#include "car_interface.h" /* - * Implementation of interface class CarInterface + * Implementation of interface class ComTrolltechExamplesCarInterfaceInterface */ -CarInterface::CarInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) +ComTrolltechExamplesCarInterfaceInterface::ComTrolltechExamplesCarInterfaceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) { } -CarInterface::~CarInterface() +ComTrolltechExamplesCarInterfaceInterface::~ComTrolltechExamplesCarInterfaceInterface() { } diff --git a/examples/dbus/remotecontrolledcar/controller/car_interface_p.h b/examples/dbus/remotecontrolledcar/controller/car_interface_p.h deleted file mode 100644 index f7e22ac..0000000 --- a/examples/dbus/remotecontrolledcar/controller/car_interface_p.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** 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 examples 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$ -** -** -** This file was generated by dbusxml2cpp version 0.6 -** Command line was: dbusxml2cpp -c CarInterface -p car_interface_p.h:car_interface.cpp car.xml -** -** dbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** This is an auto-generated file. -** Do not edit! All changes made to it will be lost. -** -****************************************************************************/ - -#ifndef CAR_INTERFACE_P_H_1156853585 -#define CAR_INTERFACE_P_H_1156853585 - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Proxy class for interface com.trolltech.Examples.CarInterface - */ -class CarInterface: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char *staticInterfaceName() - { return "com.trolltech.Examples.CarInterface"; } - -public: - CarInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~CarInterface(); - -public Q_SLOTS: // METHODS - inline QDBusReply accelerate() - { - QList argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("accelerate"), argumentList); - } - - inline QDBusReply decelerate() - { - QList argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("decelerate"), argumentList); - } - - inline QDBusReply turnLeft() - { - QList argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("turnLeft"), argumentList); - } - - inline QDBusReply turnRight() - { - QList argumentList; - return callWithArgumentList(QDBus::Block, QLatin1String("turnRight"), argumentList); - } - -Q_SIGNALS: // SIGNALS - void crashed(); -}; - -namespace com { - namespace trolltech { - namespace Examples { - typedef ::CarInterface CarInterface; - } - } -} -#endif diff --git a/examples/dbus/remotecontrolledcar/controller/controller.cpp b/examples/dbus/remotecontrolledcar/controller/controller.cpp index fd6aa13..a3d7c61 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.cpp +++ b/examples/dbus/remotecontrolledcar/controller/controller.cpp @@ -42,13 +42,13 @@ #include #include "controller.h" -#include "car_interface_p.h" +#include "car_interface.h" Controller::Controller(QWidget *parent) : QWidget(parent) { ui.setupUi(this); - car = new CarInterface("com.trolltech.CarExample", "/Car", + car = new com::trolltech::Examples::CarInterface("com.trolltech.CarExample", "/Car", QDBusConnection::sessionBus(), this); startTimer(1000); } diff --git a/examples/dbus/remotecontrolledcar/controller/controller.h b/examples/dbus/remotecontrolledcar/controller/controller.h index aa4cd43..b2265d2 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.h +++ b/examples/dbus/remotecontrolledcar/controller/controller.h @@ -43,8 +43,7 @@ #define CONTROLLER_H #include "ui_controller.h" - -class CarInterface; +#include "car_interface.h" class Controller : public QWidget { @@ -64,7 +63,7 @@ private slots: private: Ui::Controller ui; - CarInterface *car; + com::trolltech::Examples::CarInterface *car; }; #endif diff --git a/examples/dbus/remotecontrolledcar/controller/controller.pro b/examples/dbus/remotecontrolledcar/controller/controller.pro index 159e3b1..375b9d7 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.pro +++ b/examples/dbus/remotecontrolledcar/controller/controller.pro @@ -11,7 +11,7 @@ CONFIG += qdbus # Input # DBUS_INTERFACES += car.xml FORMS += controller.ui -HEADERS += car_interface_p.h controller.h +HEADERS += car_interface.h controller.h SOURCES += main.cpp car_interface.cpp controller.cpp # install -- cgit v0.12 From f0d24ba1eaa1079abef3a1da641b43437dc7df66 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Fri, 15 Jan 2010 13:38:12 +1000 Subject: Added new funcs to QAudioFormat and QAudioDeviceInfo class's. QAudioFormat::setChannelCount(), channelCount() QAudioFormat::setSampleRate(), sampleRate() QAudioDeviceInfo::supportedChannelCounts(), supportedSampleRates() Changed all instances to use these new functions instead of channels(),frequency(),setFrequency(),setChannels() supportedChannels(),supportedFrequencies() Old functions still exist but are marked obsolete. Reviewed-by:Justin McPherson --- doc/src/snippets/audio/main.cpp | 4 +- examples/multimedia/audiodevices/audiodevices.cpp | 16 +++--- examples/multimedia/audioinput/audioinput.cpp | 4 +- examples/multimedia/audiooutput/audiooutput.cpp | 4 +- src/multimedia/audio/qaudio_mac.cpp | 12 ++-- src/multimedia/audio/qaudiodeviceinfo.cpp | 32 ++++++++++- src/multimedia/audio/qaudiodeviceinfo.h | 2 + src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 26 ++++----- src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 8 +-- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 10 ++-- src/multimedia/audio/qaudioformat.cpp | 66 +++++++++++++++++++--- src/multimedia/audio/qaudioformat.h | 6 ++ src/multimedia/audio/qaudioinput.cpp | 4 +- src/multimedia/audio/qaudioinput_alsa_p.cpp | 8 +-- src/multimedia/audio/qaudioinput_mac_p.cpp | 2 +- src/multimedia/audio/qaudioinput_win32_p.cpp | 16 +++--- src/multimedia/audio/qaudiooutput.cpp | 4 +- src/multimedia/audio/qaudiooutput_alsa_p.cpp | 6 +- src/multimedia/audio/qaudiooutput_mac_p.cpp | 6 +- src/multimedia/audio/qaudiooutput_win32_p.cpp | 14 ++--- .../auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp | 16 +++--- tests/auto/qaudioformat/tst_qaudioformat.cpp | 10 ++-- tests/auto/qaudioinput/tst_qaudioinput.cpp | 8 +-- tests/auto/qaudiooutput/tst_qaudiooutput.cpp | 8 +-- 24 files changed, 189 insertions(+), 103 deletions(-) diff --git a/doc/src/snippets/audio/main.cpp b/doc/src/snippets/audio/main.cpp index 0910865..bf4b145 100644 --- a/doc/src/snippets/audio/main.cpp +++ b/doc/src/snippets/audio/main.cpp @@ -89,9 +89,9 @@ private: { //![1] QAudioFormat format; - format.setFrequency(44100); + format.setSampleRate(44100); //![1] - format.setChannels(2); + format.setChannelCount(2); format.setSampleSize(16); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index 4198605..bf6d2d0 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -108,8 +108,8 @@ void AudioTest::test() } else { QAudioFormat nearest = deviceInfo.nearestFormat(settings); logOutput->append(tr("Failed")); - nearestFreq->setText(QString("%1").arg(nearest.frequency())); - nearestChannel->setText(QString("%1").arg(nearest.channels())); + nearestFreq->setText(QString("%1").arg(nearest.sampleRate())); + nearestChannel->setText(QString("%1").arg(nearest.channelCount())); nearestCodec->setText(nearest.codec()); nearestSampleSize->setText(QString("%1").arg(nearest.sampleSize())); @@ -161,18 +161,18 @@ void AudioTest::deviceChanged(int idx) deviceInfo = deviceBox->itemData(idx).value(); frequencyBox->clear(); - QList freqz = deviceInfo.supportedFrequencies(); + QList freqz = deviceInfo.supportedSampleRates(); for(int i = 0; i < freqz.size(); ++i) frequencyBox->addItem(QString("%1").arg(freqz.at(i))); if(freqz.size()) - settings.setFrequency(freqz.at(0)); + settings.setSampleRate(freqz.at(0)); channelsBox->clear(); - QList chz = deviceInfo.supportedChannels(); + QList chz = deviceInfo.supportedChannelCounts(); for(int i = 0; i < chz.size(); ++i) channelsBox->addItem(QString("%1").arg(chz.at(i))); if(chz.size()) - settings.setChannels(chz.at(0)); + settings.setChannelCount(chz.at(0)); codecsBox->clear(); QStringList codecz = deviceInfo.supportedCodecs(); @@ -229,12 +229,12 @@ void AudioTest::deviceChanged(int idx) void AudioTest::freqChanged(int idx) { // freq has changed - settings.setFrequency(frequencyBox->itemText(idx).toInt()); + settings.setSampleRate(frequencyBox->itemText(idx).toInt()); } void AudioTest::channelChanged(int idx) { - settings.setChannels(channelsBox->itemText(idx).toInt()); + settings.setChannelCount(channelsBox->itemText(idx).toInt()); } void AudioTest::codecChanged(int idx) diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 3d537a2..3349d54 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -196,8 +196,8 @@ InputTest::InputTest() pullMode = true; // AudioInfo class only supports mono S16LE samples! - format.setFrequency(8000); - format.setChannels(1); + format.setSampleRate(8000); + format.setChannelCount(1); format.setSampleSize(16); format.setSampleType(QAudioFormat::SignedInt); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index c92bbaf..7a76c82 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -164,8 +164,8 @@ AudioTest::AudioTest() gen->start(); - settings.setFrequency(SYSTEM_FREQ); - settings.setChannels(1); + settings.setSampleRate(SYSTEM_FREQ); + settings.setChannelCount(1); settings.setSampleSize(16); settings.setCodec("audio/pcm"); settings.setByteOrder(QAudioFormat::LittleEndian); diff --git a/src/multimedia/audio/qaudio_mac.cpp b/src/multimedia/audio/qaudio_mac.cpp index 1cd9225..d876745 100644 --- a/src/multimedia/audio/qaudio_mac.cpp +++ b/src/multimedia/audio/qaudio_mac.cpp @@ -48,8 +48,8 @@ QT_BEGIN_NAMESPACE QDebug operator<<(QDebug dbg, const QAudioFormat& audioFormat) { dbg.nospace() << "QAudioFormat(" << - audioFormat.frequency() << "," << - audioFormat.channels() << "," << + audioFormat.sampleRate() << "," << + audioFormat.channelCount() << "," << audioFormat.sampleSize()<< "," << audioFormat.codec() << "," << audioFormat.byteOrder() << "," << @@ -64,8 +64,8 @@ QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf) { QAudioFormat audioFormat; - audioFormat.setFrequency(sf.mSampleRate); - audioFormat.setChannels(sf.mChannelsPerFrame); + audioFormat.setSampleRate(sf.mSampleRate); + audioFormat.setChannelCount(sf.mChannelsPerFrame); audioFormat.setSampleSize(sf.mBitsPerChannel); audioFormat.setCodec(QString::fromLatin1("audio/pcm")); audioFormat.setByteOrder(sf.mFormatFlags & kLinearPCMFormatFlagIsBigEndian != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian); @@ -84,9 +84,9 @@ AudioStreamBasicDescription toAudioStreamBasicDescription(QAudioFormat const& au AudioStreamBasicDescription sf; sf.mFormatFlags = kAudioFormatFlagIsPacked; - sf.mSampleRate = audioFormat.frequency(); + sf.mSampleRate = audioFormat.sampleRate(); sf.mFramesPerPacket = 1; - sf.mChannelsPerFrame = audioFormat.channels(); + sf.mChannelsPerFrame = audioFormat.channelCount(); sf.mBitsPerChannel = audioFormat.sampleSize(); sf.mBytesPerFrame = sf.mChannelsPerFrame * (sf.mBitsPerChannel / 8); sf.mBytesPerPacket = sf.mFramesPerPacket * sf.mBytesPerFrame; diff --git a/src/multimedia/audio/qaudiodeviceinfo.cpp b/src/multimedia/audio/qaudiodeviceinfo.cpp index dce2884..45e177e 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo.cpp @@ -100,13 +100,13 @@ public: You can also query each device for the formats it supports. A format in this context is a set consisting of a specific byte - order, channel, codec, frequency, sample rate, and sample type. A + order, channel, codec, sample rate, sample size and sample type. A format is represented by the QAudioFormat class. The values supported by the the device for each of these parameters can be fetched with - supportedByteOrders(), supportedChannels(), supportedCodecs(), - supportedFrequencies(), supportedSampleSizes(), and + supportedByteOrders(), supportedChannelCounts(), supportedCodecs(), + supportedSampleRates(), supportedSampleSizes(), and supportedSampleTypes(). The combinations supported are dependent on the platform, audio plugins installed and the audio device capabilities. If you need a specific format, you can check if the device supports it with isFormatSupported(), or fetch a @@ -259,6 +259,19 @@ QStringList QAudioDeviceInfo::supportedCodecs() const } /*! + Returns a list of supported sample rates. +*/ + +QList QAudioDeviceInfo::supportedSampleRates() const +{ + return supportedFrequencies(); +} + +/*! + \obsolete + + Use supportedSampleRates() instead. + Returns a list of supported frequencies. */ @@ -268,6 +281,19 @@ QList QAudioDeviceInfo::supportedFrequencies() const } /*! + Returns a list of supported channel counts. +*/ + +QList QAudioDeviceInfo::supportedChannelCounts() const +{ + return supportedChannels(); +} + +/*! + \obsolete + + Use supportedChannelCount() instead. + Returns a list of supported channels. */ diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h index 53b9904..134b688 100644 --- a/src/multimedia/audio/qaudiodeviceinfo.h +++ b/src/multimedia/audio/qaudiodeviceinfo.h @@ -84,7 +84,9 @@ public: QStringList supportedCodecs() const; QList supportedFrequencies() const; + QList supportedSampleRates() const; QList supportedChannels() const; + QList supportedChannelCounts() const; QList supportedSampleSizes() const; QList supportedByteOrders() const; QList supportedSampleTypes() const; diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index e828238..08c617b 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -78,20 +78,20 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const { QAudioFormat nearest; if(mode == QAudio::AudioOutput) { - nearest.setFrequency(44100); - nearest.setChannels(2); + nearest.setSampleRate(44100); + nearest.setChannelCount(2); nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(16); nearest.setCodec(QLatin1String("audio/pcm")); } else { - nearest.setFrequency(8000); - nearest.setChannels(1); + nearest.setSampleRate(8000); + nearest.setChannelCount(1); nearest.setSampleType(QAudioFormat::UnSignedInt); nearest.setSampleSize(8); nearest.setCodec(QLatin1String("audio/pcm")); if(!testSettings(nearest)) { - nearest.setChannels(2); + nearest.setChannelCount(2); nearest.setSampleSize(16); nearest.setSampleType(QAudioFormat::SignedInt); } @@ -234,8 +234,8 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const snd_pcm_hw_params_any( handle, params ); // set the values! - snd_pcm_hw_params_set_channels(handle,params,format.channels()); - snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); + snd_pcm_hw_params_set_channels(handle,params,format.channelCount()); + snd_pcm_hw_params_set_rate(handle,params,format.sampleRate(),dir); switch(format.sampleSize()) { case 8: if(format.sampleType() == QAudioFormat::SignedInt) @@ -276,18 +276,18 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const } else testCodec = true; - if(err>=0 && format.channels() != -1) { - err = snd_pcm_hw_params_test_channels(handle,params,format.channels()); + if(err>=0 && format.channelCount() != -1) { + err = snd_pcm_hw_params_test_channels(handle,params,format.channelCount()); if(err>=0) - err = snd_pcm_hw_params_set_channels(handle,params,format.channels()); + err = snd_pcm_hw_params_set_channels(handle,params,format.channelCount()); if(err>=0) testChannel = true; } - if(err>=0 && format.frequency() != -1) { - err = snd_pcm_hw_params_test_rate(handle,params,format.frequency(),0); + if(err>=0 && format.sampleRate() != -1) { + err = snd_pcm_hw_params_test_rate(handle,params,format.sampleRate(),0); if(err>=0) - err = snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir); + err = snd_pcm_hw_params_set_rate(handle,params,format.sampleRate(),dir); if(err>=0) testFreq = true; } diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp index ec07748..258132a 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -144,10 +144,10 @@ QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) rc.setCodec(QString::fromLatin1("audio/pcm")); - if (rc.frequency() != target.frequency()) - rc.setFrequency(target.frequency()); - if (rc.channels() != target.channels()) - rc.setChannels(target.channels()); + if (rc.sampleRate() != target.sampleRate()) + rc.setSampleRate(target.sampleRate()); + if (rc.channelCount() != target.channelCount()) + rc.setChannelCount(target.channelCount()); if (rc.sampleSize() != target.sampleSize()) rc.setSampleSize(target.sampleSize()); if (rc.byteOrder() != target.byteOrder()) diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index 69d5c94..f77efd0 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -95,14 +95,14 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const QAudioFormat nearest; if(mode == QAudio::AudioOutput) { nearest.setFrequency(44100); - nearest.setChannels(2); + nearest.setChannelCount(2); nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(16); nearest.setCodec(QLatin1String("audio/pcm")); } else { nearest.setFrequency(11025); - nearest.setChannels(1); + nearest.setChannelCount(1); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(8); nearest.setCodec(QLatin1String("audio/pcm")); @@ -180,12 +180,12 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const if(!format.codec().startsWith(QLatin1String("audio/pcm"))) failed = true; - if(!failed && !(format.channels() == 1 || format.channels() == 2)) + if(!failed && !(format.channelCount() == 1 || format.channelCount() == 2)) failed = true; if(!failed) { - if(!(format.frequency() == 8000 || format.frequency() == 11025 || format.frequency() == 22050 || - format.frequency() == 44100 || format.frequency() == 48000 || format.frequency() == 96000)) + if(!(format.sampleRate() == 8000 || format.sampleRate() == 11025 || format.sampleRate() == 22050 || + format.sampleRate() == 44100 || format.sampleRate() == 48000 || format.sampleRate() == 96000)) failed = true; } diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index 86fe85b..e31d2ec 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -111,7 +111,7 @@ public: \o Parameter \o Description \row - \o Frequency + \o Sample Rate \o Samples per second of audio data in Hertz. \row \o Number of channels @@ -143,8 +143,8 @@ public: Values are initialized as follows: \list - \o frequency() = -1 - \o channels() = -1 + \o sampleRate() = -1 + \o channelCount() = -1 \o sampleSize() = -1 \o byteOrder() = QAudioFormat::Endian(QSysInfo::ByteOrder) \o sampleType() = QAudioFormat::Unknown @@ -227,7 +227,20 @@ bool QAudioFormat::isNull() const } /*! - Sets the frequency to \a frequency. + Sets the sample rate to \a samplerate Hertz. +*/ + +void QAudioFormat::setSampleRate(int samplerate) +{ + d->frequency = samplerate; +} + +/*! + \obsolete + + Use setSampleRate() instead. + + Sets the frequency to \a frequency Hertz. */ void QAudioFormat::setFrequency(int frequency) @@ -236,7 +249,20 @@ void QAudioFormat::setFrequency(int frequency) } /*! - Returns the current frequency value. + Returns the current sample rate in Hertz. +*/ + +int QAudioFormat::sampleRate() const +{ + return d->frequency; +} + +/*! + \obsolete + + Use sampleRate() instead. + + Returns the current frequency in Hertz. */ int QAudioFormat::frequency() const @@ -245,7 +271,20 @@ int QAudioFormat::frequency() const } /*! - Sets the channels to \a channels. + Sets the channel count to \a channels. +*/ + +void QAudioFormat::setChannelCount(int channels) +{ + d->channels = channels; +} + +/*! + \obsolete + + Use setChannelCount() instead. + + Sets the no. of channels to \a channels. */ void QAudioFormat::setChannels(int channels) @@ -254,7 +293,20 @@ void QAudioFormat::setChannels(int channels) } /*! - Returns the current channel value. + Returns the current channel count value. +*/ + +int QAudioFormat::channelCount() const +{ + return d->channels; +} + +/*! + \obsolete + + Use channelCount() instead. + + Returns the no. of channels. */ int QAudioFormat::channels() const diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h index d5841ce..f64dd7e 100644 --- a/src/multimedia/audio/qaudioformat.h +++ b/src/multimedia/audio/qaudioformat.h @@ -76,6 +76,12 @@ public: void setFrequency(int frequency); int frequency() const; + void setSampleRate(int samplerate); + int sampleRate() const; + + void setChannelCount(int channels); + int channelCount() const; + void setChannels(int channels); int channels() const; diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index 7a3be23..8f2d75b 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -85,8 +85,8 @@ QT_BEGIN_NAMESPACE QAudioFormat format; // set up the format you want, eg. - format.setFrequency(8000); - format.setChannels(1); + format.setSampleRate(8000); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 9eb8cfb..b6fff64 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -256,7 +256,7 @@ bool QAudioInputPrivate::open() int dir; int err=-1; int count=0; - unsigned int freakuency=settings.frequency(); + unsigned int freakuency=settings.sampleRate(); QString dev = QString(QLatin1String(m_device.constData())); if(!dev.contains(QLatin1String("default"))) { @@ -323,7 +323,7 @@ bool QAudioInputPrivate::open() } } if ( !fatal ) { - err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channels() ); + err = snd_pcm_hw_params_set_channels( handle, hwparams, (unsigned int)settings.channelCount() ); if ( err < 0 ) { fatal = true; errMessage = QString::fromLatin1("QAudioInput: snd_pcm_hw_params_set_channels: err = %1").arg(err); @@ -496,7 +496,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) errorState = QAudio::NoError; deviceState = QAudio::IdleState; } else { - totalTimeValue += snd_pcm_bytes_to_frames(handle, err)*1000000/settings.frequency(); + totalTimeValue += snd_pcm_bytes_to_frames(handle, err)*1000000/settings.sampleRate(); resuming = false; errorState = QAudio::NoError; deviceState = QAudio::ActiveState; @@ -693,7 +693,7 @@ qint64 InputPrivate::readData( char* data, qint64 len) count++; } if(err > 0 && readFrames > 0) { - audioDevice->totalTimeValue += readFrames*1000/audioDevice->settings.frequency()*1000; + audioDevice->totalTimeValue += readFrames*1000/audioDevice->settings.sampleRate()*1000; audioDevice->deviceState = QAudio::ActiveState; return err; } diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp index cb05920..c88c558 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.cpp +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -814,7 +814,7 @@ int QAudioInputPrivate::notifyInterval() const qint64 QAudioInputPrivate::totalTime() const { - return totalFrames * 1000000 / audioFormat.frequency(); + return totalFrames * 1000000 / audioFormat.sampleRate(); } qint64 QAudioInputPrivate::clock() const diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index a059e76..ca0bc24 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -217,21 +217,21 @@ bool QAudioInputPrivate::open() header = 0; if(buffer_size == 0) { // Default buffer size, 100ms, default period size is 20ms - buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.1; + buffer_size = settings.sampleRate()*settings.channelCount()*(settings.sampleSize()/8)*0.1; period_size = buffer_size/5; } 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; + buffer_size = settings.sampleRate()*settings.channelCount()*(settings.sampleSize()/8)*0.04; period_size = buffer_size/2; #endif timeStamp.restart(); elapsedTimeOffset = 0; - wfx.nSamplesPerSec = settings.frequency(); + wfx.nSamplesPerSec = settings.sampleRate(); wfx.wBitsPerSample = settings.sampleSize(); - wfx.nChannels = settings.channels(); + wfx.nChannels = settings.channelCount(); wfx.cbSize = 0; wfx.wFormatTag = WAVE_FORMAT_PCM; @@ -367,8 +367,8 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) } else { totalTimeValue += waveBlocks[header].dwBytesRecorded - /((settings.channels()*settings.sampleSize()/8)) - *10000/settings.frequency()*100; + /((settings.channelCount()*settings.sampleSize()/8)) + *10000/settings.sampleRate()*100; errorState = QAudio::NoError; deviceState = QAudio::ActiveState; resuming = false; @@ -381,8 +381,8 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) qDebug()<<"IN: "< 0) { - totalTimeValue += err*1000000/settings.frequency(); + totalTimeValue += err*1000000/settings.sampleRate(); resuming = false; errorState = QAudio::NoError; deviceState = QAudio::ActiveState; diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp index f23db80..5bb872f 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.cpp +++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp @@ -87,8 +87,8 @@ public: m_device(0) { m_buffer = new QAudioRingBuffer(bufferSize + (bufferSize % maxPeriodSize == 0 ? 0 : maxPeriodSize - (bufferSize % maxPeriodSize))); - m_bytesPerFrame = (audioFormat.sampleSize() / 8) * audioFormat.channels(); - m_periodTime = m_maxPeriodSize / m_bytesPerFrame * 1000 / audioFormat.frequency(); + m_bytesPerFrame = (audioFormat.sampleSize() / 8) * audioFormat.channelCount(); + m_periodTime = m_maxPeriodSize / m_bytesPerFrame * 1000 / audioFormat.sampleRate(); m_fillTimer = new QTimer(this); connect(m_fillTimer, SIGNAL(timeout()), SLOT(fillBuffer())); @@ -546,7 +546,7 @@ int QAudioOutputPrivate::notifyInterval() const qint64 QAudioOutputPrivate::totalTime() const { - return totalFrames * 1000000 / audioFormat.frequency(); + return totalFrames * 1000000 / audioFormat.sampleRate(); } qint64 QAudioOutputPrivate::clock() const diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 1810ed2..4a77386 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -205,7 +205,7 @@ bool QAudioOutputPrivate::open() #endif if(buffer_size == 0) { // Default buffer size, 200ms, default period size is 40ms - buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2; + buffer_size = settings.sampleRate()*settings.channelCount()*(settings.sampleSize()/8)*0.2; period_size = buffer_size/5; } else { period_size = buffer_size/5; @@ -224,9 +224,9 @@ bool QAudioOutputPrivate::open() timeStamp.restart(); elapsedTimeOffset = 0; - wfx.nSamplesPerSec = settings.frequency(); + wfx.nSamplesPerSec = settings.sampleRate(); wfx.wBitsPerSample = settings.sampleSize(); - wfx.nChannels = settings.channels(); + wfx.nChannels = settings.channelCount(); wfx.cbSize = 0; wfx.wFormatTag = WAVE_FORMAT_PCM; @@ -281,8 +281,8 @@ void QAudioOutputPrivate::close() return; deviceState = QAudio::StopState; - int delay = (buffer_size-bytesFree())*1000/(settings.frequency() - *settings.channels()*(settings.sampleSize()/8)); + int delay = (buffer_size-bytesFree())*1000/(settings.sampleRate() + *settings.channelCount()*(settings.sampleSize()/8)); waveOutReset(hWaveOut); Sleep(delay+10); @@ -378,8 +378,8 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) LeaveCriticalSection(&waveOutCriticalSection); #endif totalTimeValue += current->dwBufferLength - /(settings.channels()*(settings.sampleSize()/8)) - *1000000/settings.frequency();; + /(settings.channelCount()*(settings.sampleSize()/8)) + *1000000/settings.sampleRate();; waveCurrentBlock++; waveCurrentBlock %= buffer_size/period_size; current = &waveBlocks[waveCurrentBlock]; diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp index 7b9a422..45ebc5f 100644 --- a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp +++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp @@ -128,7 +128,7 @@ void tst_QAudioDeviceInfo::codecs() void tst_QAudioDeviceInfo::channels() { if(available) { - QList avail = device->supportedChannels(); + QList avail = device->supportedChannelCounts(); QVERIFY(avail.size() > 0); } } @@ -160,7 +160,7 @@ void tst_QAudioDeviceInfo::sampleTypes() void tst_QAudioDeviceInfo::frequencies() { if(available) { - QList avail = device->supportedFrequencies(); + QList avail = device->supportedSampleRates(); QVERIFY(avail.size() > 0); } } @@ -169,8 +169,8 @@ void tst_QAudioDeviceInfo::isformat() { if(available) { QAudioFormat format; - format.setFrequency(44100); - format.setChannels(2); + format.setSampleRate(44100); + format.setChannelCount(2); format.setSampleType(QAudioFormat::SignedInt); format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleSize(16); @@ -185,8 +185,8 @@ void tst_QAudioDeviceInfo::preferred() { if(available) { QAudioFormat format = device->preferredFormat(); - QVERIFY(format.frequency() == 44100); - QVERIFY(format.channels() == 2); + QVERIFY(format.sampleRate() == 44100); + QVERIFY(format.channelCount() == 2); } } @@ -194,9 +194,9 @@ void tst_QAudioDeviceInfo::nearest() { if(available) { QAudioFormat format1, format2; - format1.setFrequency(8000); + format1.setSampleRate(8000); format2 = device->nearestFormat(format1); - QVERIFY(format2.frequency() == 44100); + QVERIFY(format2.sampleRate() == 44100); } } diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp index 286e63f..5d70fed 100644 --- a/tests/auto/qaudioformat/tst_qaudioformat.cpp +++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp @@ -92,7 +92,7 @@ void tst_QAudioFormat::checkFrequency() void tst_QAudioFormat::checkChannels() { QAudioFormat audioFormat; - audioFormat.setChannels(2); + audioFormat.setChannelCount(2); QVERIFY(audioFormat.channels() == 2); } @@ -135,14 +135,14 @@ void tst_QAudioFormat::checkEquality() // on filled formats audioFormat0.setFrequency(8000); - audioFormat0.setChannels(1); + audioFormat0.setChannelCount(1); audioFormat0.setSampleSize(8); audioFormat0.setCodec("audio/pcm"); audioFormat0.setByteOrder(QAudioFormat::LittleEndian); audioFormat0.setSampleType(QAudioFormat::UnSignedInt); audioFormat1.setFrequency(8000); - audioFormat1.setChannels(1); + audioFormat1.setChannelCount(1); audioFormat1.setSampleSize(8); audioFormat1.setCodec("audio/pcm"); audioFormat1.setByteOrder(QAudioFormat::LittleEndian); @@ -151,7 +151,7 @@ void tst_QAudioFormat::checkEquality() QVERIFY(audioFormat0 == audioFormat1); QVERIFY(!(audioFormat0 != audioFormat1)); - audioFormat0.setFrequency(44100); + audioFormat0.setSampleRate(44100); QVERIFY(audioFormat0 != audioFormat1); QVERIFY(!(audioFormat0 == audioFormat1)); } @@ -162,7 +162,7 @@ void tst_QAudioFormat::checkAssignment() QAudioFormat audioFormat1; audioFormat0.setFrequency(8000); - audioFormat0.setChannels(1); + audioFormat0.setChannelCount(1); audioFormat0.setSampleSize(8); audioFormat0.setCodec("audio/pcm"); audioFormat0.setByteOrder(QAudioFormat::LittleEndian); diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp index 3efc346..bb1ac70 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -68,8 +68,8 @@ private: void tst_QAudioInput::initTestCase() { - format.setFrequency(8000); - format.setChannels(1); + format.setSampleRate(8000); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); @@ -94,8 +94,8 @@ void tst_QAudioInput::settings() // Confirm the setting we added in the init function. QAudioFormat f = audio->format(); - QVERIFY(format.channels() == f.channels()); - QVERIFY(format.frequency() == f.frequency()); + QVERIFY(format.channelCount() == f.channelCount()); + QVERIFY(format.sampleRate() == f.sampleRate()); QVERIFY(format.sampleSize() == f.sampleSize()); QVERIFY(format.codec() == f.codec()); QVERIFY(format.byteOrder() == f.byteOrder()); diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp index b001af1..c3c25d3 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -71,8 +71,8 @@ private: void tst_QAudioOutput::initTestCase() { - format.setFrequency(8000); - format.setChannels(1); + format.setSampleRate(8000); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); @@ -95,8 +95,8 @@ void tst_QAudioOutput::settings() // Confirm the setting we added in the init function. QAudioFormat f = audio->format(); - QVERIFY(format.channels() == f.channels()); - QVERIFY(format.frequency() == f.frequency()); + QVERIFY(format.channelCount() == f.channelCount()); + QVERIFY(format.sampleRate() == f.sampleRate()); QVERIFY(format.sampleSize() == f.sampleSize()); QVERIFY(format.codec() == f.codec()); QVERIFY(format.byteOrder() == f.byteOrder()); -- cgit v0.12 From 7ad08868de4b3e481a51a3431504fcf42a4bbf6d Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 26 Jan 2010 13:42:48 +0100 Subject: Cocoa: qfiledialog test spits out memory warnings We need an auto release pool! --- src/gui/kernel/qt_cocoa_helpers_mac.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index e0dcaef..13c25fd 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -143,6 +143,9 @@ extern QPointer qt_button_down; //qapplication_mac.cpp void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds) { +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; +#endif OSWindowRef wnd = static_cast(window); if (wnd) { QWidget *widget; -- cgit v0.12 From d5a512b40190d4986be23bbebd2cbb53919e48ae Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 14:14:30 +0100 Subject: Add proper license headers to these files. This makes the headers:licenseCheck test pass. --- src/testlib/qbenchmarkmetric.cpp | 78 ++++++++++++++++----------------- tests/auto/qobject/oldnormalizeobject.h | 41 +++++++++++++++++ tests/benchmarks/qvector/outofline.cpp | 40 +++++++++++++++++ 3 files changed, 120 insertions(+), 39 deletions(-) diff --git a/src/testlib/qbenchmarkmetric.cpp b/src/testlib/qbenchmarkmetric.cpp index 614357c..75297c4 100644 --- a/src/testlib/qbenchmarkmetric.cpp +++ b/src/testlib/qbenchmarkmetric.cpp @@ -1,43 +1,43 @@ /**************************************************************************** - ** - ** 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 QtTest module of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ - ** No Commercial Usage - ** This file contains pre-release code and may not be distributed. - ** You may use this file in accordance with the terms and conditions - ** contained in the Technology Preview License Agreement accompanying - ** this package. - ** - ** GNU Lesser General Public License Usage - ** Alternatively, this file may be used under the terms of the GNU Lesser - ** General Public License version 2.1 as published by the Free Software - ** Foundation and appearing in the file LICENSE.LGPL included in the - ** packaging of this file. Please review the following information to - ** ensure the GNU Lesser General Public License version 2.1 requirements - ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. - ** - ** In addition, as a special exception, Nokia gives you certain additional - ** rights. These rights are described in the Nokia Qt LGPL Exception - ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. - ** - ** If you have questions regarding the use of this file, please contact - ** Nokia at qt-info@nokia.com. - ** - ** - ** - ** - ** - ** - ** - ** - ** $QT_END_LICENSE$ - ** - ****************************************************************************/ +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ #include diff --git a/tests/auto/qobject/oldnormalizeobject.h b/tests/auto/qobject/oldnormalizeobject.h index 8420a3a..3adf04d 100644 --- a/tests/auto/qobject/oldnormalizeobject.h +++ b/tests/auto/qobject/oldnormalizeobject.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 OLDNORMALIZEOBJECT_H #define OLDNORMALIZEOBJECT_H diff --git a/tests/benchmarks/qvector/outofline.cpp b/tests/benchmarks/qvector/outofline.cpp index d1d72b0..e8d036e 100644 --- a/tests/benchmarks/qvector/outofline.cpp +++ b/tests/benchmarks/qvector/outofline.cpp @@ -1,3 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ #include #include -- cgit v0.12 From 7b306a0534e4c1db40fbcf77612fd88ac672b6f7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 14:17:01 +0100 Subject: Remove the tests/auto/networkdata dir, since this causes the maketestselftest test fail --- tests/auto/networkdata/README | 1 - 1 file changed, 1 deletion(-) delete mode 100644 tests/auto/networkdata/README diff --git a/tests/auto/networkdata/README b/tests/auto/networkdata/README deleted file mode 100644 index e8748cc..0000000 --- a/tests/auto/networkdata/README +++ /dev/null @@ -1 +0,0 @@ -This directory contains network test data -- cgit v0.12 From c3619bce443e73430b1b8aa7ab4c0e712375b53b Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:46 +0100 Subject: fix regression introduced in 44766d2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit null fileNames returned by fileEngine must be cached too Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index e90529e..6eb864e 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -132,6 +132,8 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const if(data->cache_enabled && !data->fileNames[(int)name].isNull()) return data->fileNames[(int)name]; QString ret = data->fileEngine->fileName(name); + if (ret.isNull()) + ret = QLatin1String(""); if(data->cache_enabled) data->fileNames[(int)name] = ret; return ret; -- cgit v0.12 From 95f0dbd76f419ebc80e27f184d5e1199e91de4b7 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:47 +0100 Subject: QFileInfoPrivate::Data: don't call clear() from constructors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit causes Refresh of file engine's internal cache, since `fileEngine' member is set before clear() is called. Initialize members with default values instead. Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo_p.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index 065f860..7f8ab4e 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -81,12 +81,14 @@ public: CachedSize =0x08 }; struct Data { inline Data() - : ref(1), fileEngine(0), cache_enabled(1), fileSize(0) - { clear(); } + : ref(1), fileEngine(0), + cachedFlags(0), cache_enabled(1), fileFlags(0), fileSize(0) + {} inline Data(const Data ©) : ref(1), fileEngine(QAbstractFileEngine::create(copy.fileName)), - fileName(copy.fileName), cache_enabled(copy.cache_enabled), fileSize(copy.fileSize) - { clear(); } + fileName(copy.fileName), + cachedFlags(0), cache_enabled(copy.cache_enabled), fileFlags(0), fileSize(0) + {} inline ~Data() { delete fileEngine; } inline void clearFlags() { fileFlags = 0; -- cgit v0.12 From 3a5eb87965b60a3e249a16dc48cb06f4759dfb1b Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:48 +0100 Subject: QFileInfo: Don't re-stat files, when in caching mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Separated testing for permissions flags, in order to speedup QFileInfo on Windows with qt_ntfs_permission_lookup flag turned on (especially on network shares). In QFileInfoPrivate::getFileFlags, avoid multiple calls to the engine, by concatenating all requests. Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 74 +++++++++++++++++++++++++------------------- src/corelib/io/qfileinfo_p.h | 2 +- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 6eb864e..2260036 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -81,7 +81,8 @@ void QFileInfoPrivate::initFileEngine(const QString &file) bool QFileInfoPrivate::hasAccess(Access access) const { - if (!(getFileFlags(QAbstractFileEngine::FileInfoAll) & QAbstractFileEngine::LocalDiskFlag)) { + if (!(getFileFlags(QAbstractFileEngine::PermsMask + | QAbstractFileEngine::LocalDiskFlag) & QAbstractFileEngine::LocalDiskFlag)) { switch (access) { case ReadAccess: return getFileFlags(QAbstractFileEngine::ReadUserPerm); @@ -141,51 +142,62 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) const { - // We split the testing into tests for for LinkType, BundleType and the rest. + // We split the testing into tests for for LinkType, BundleType, PermsMask + // and the rest. + // Tests for file permissions on Windows can be slow, expecially on network + // paths and NTFS drives. // In order to determine if a file is a symlink or not, we have to lstat(). // If we're not interested in that information, we might as well avoid one // extra syscall. Bundle detecton on Mac can be slow, expecially on network // paths, so we separate out that as well. - QAbstractFileEngine::FileFlags flags; - if (!data->getCachedFlag(CachedFileFlags)) { - QAbstractFileEngine::FileFlags req = QAbstractFileEngine::FileInfoAll; - req &= (~QAbstractFileEngine::LinkType); - req &= (~QAbstractFileEngine::BundleType); + QAbstractFileEngine::FileFlags req = 0; + uint cachedFlags = 0; - flags = data->fileEngine->fileFlags(req); - data->setCachedFlag(CachedFileFlags); - data->fileFlags |= uint(flags); - } else { - flags = QAbstractFileEngine::FileFlags(data->fileFlags & request); - } + if (request & (QAbstractFileEngine::FlagsMask | QAbstractFileEngine::TypesMask)) { + if (!data->getCachedFlag(CachedFileFlags)) { + req |= QAbstractFileEngine::FlagsMask; + req |= QAbstractFileEngine::TypesMask; + req &= (~QAbstractFileEngine::LinkType); + req &= (~QAbstractFileEngine::BundleType); - if (request & QAbstractFileEngine::LinkType) { - if (!data->getCachedFlag(CachedLinkTypeFlag)) { - QAbstractFileEngine::FileFlags linkflag; - linkflag = data->fileEngine->fileFlags(QAbstractFileEngine::LinkType); + cachedFlags |= CachedFileFlags; + + if (request & QAbstractFileEngine::LinkType) { + if (!data->getCachedFlag(CachedLinkTypeFlag)) { + req |= QAbstractFileEngine::LinkType; + cachedFlags |= CachedLinkTypeFlag; + } + } - data->setCachedFlag(CachedLinkTypeFlag); - data->fileFlags |= uint(linkflag); - flags |= linkflag; + if (request & QAbstractFileEngine::BundleType) { + if (!data->getCachedFlag(CachedBundleTypeFlag)) { + req |= QAbstractFileEngine::BundleType; + cachedFlags |= CachedBundleTypeFlag; + } + } } } - if (request & QAbstractFileEngine::BundleType) { - if (!data->getCachedFlag(CachedBundleTypeFlag)) { - QAbstractFileEngine::FileFlags bundleflag; - bundleflag = data->fileEngine->fileFlags(QAbstractFileEngine::BundleType); - - data->setCachedFlag(CachedBundleTypeFlag); - data->fileFlags |= uint(bundleflag); - flags |= bundleflag; + if (request & QAbstractFileEngine::PermsMask) { + if (!data->getCachedFlag(CachedPerms)) { + req |= QAbstractFileEngine::PermsMask; + cachedFlags |= CachedPerms; } } - // no else branch - // if we had it cached, it was caught in the previous else branch + if (req) { + if (data->cache_enabled) + req &= (~QAbstractFileEngine::Refresh); + else + req |= QAbstractFileEngine::Refresh; + + QAbstractFileEngine::FileFlags flags = data->fileEngine->fileFlags(req); + data->fileFlags |= uint(flags); + data->setCachedFlag(cachedFlags); + } - return flags & request; + return data->fileFlags & request; } QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) const diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index 7f8ab4e..8e00909 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -78,7 +78,7 @@ public: enum { CachedFileFlags=0x01, CachedLinkTypeFlag=0x02, CachedBundleTypeFlag=0x04, CachedMTime=0x10, CachedCTime=0x20, CachedATime=0x40, - CachedSize =0x08 }; + CachedSize =0x08, CachedPerms=0x80 }; struct Data { inline Data() : ref(1), fileEngine(0), -- cgit v0.12 From d48fdf76f721b97e427073c665102e1b42398883 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:48 +0100 Subject: Simplify QFileInfoPrivate::getFileTime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit remove repeated code; improve readability Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 2260036..6616066 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -204,25 +204,18 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) { if (!data->cache_enabled) data->clearFlags(); - if(request == QAbstractFileEngine::CreationTime) { - if(data->getCachedFlag(CachedCTime)) - return data->fileTimes[request]; - data->setCachedFlag(CachedCTime); - return (data->fileTimes[request] = data->fileEngine->fileTime(request)); + uint cf; + if (request == QAbstractFileEngine::CreationTime) + cf = CachedCTime; + else if (request == QAbstractFileEngine::ModificationTime) + cf = CachedMTime; + else + cf = CachedATime; + if (!data->getCachedFlag(cf)) { + data->fileTimes[request] = data->fileEngine->fileTime(request); + data->setCachedFlag(cf); } - if(request == QAbstractFileEngine::ModificationTime) { - if(data->getCachedFlag(CachedMTime)) - return data->fileTimes[request]; - data->setCachedFlag(CachedMTime); - return (data->fileTimes[request] = data->fileEngine->fileTime(request)); - } - if(request == QAbstractFileEngine::AccessTime) { - if(data->getCachedFlag(CachedATime)) - return data->fileTimes[request]; - data->setCachedFlag(CachedATime); - return (data->fileTimes[request] = data->fileEngine->fileTime(request)); - } - return data->fileTimes[0]; //cannot really happen + return data->fileTimes[request]; } //************* QFileInfo -- cgit v0.12 From fbd0b8c0f6dce834b241f6beb755d2c2cb013305 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:49 +0100 Subject: qfileinfo_p.h: removed unnecessary dependency on QFSFileEngine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moved includes into proper place. Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 3 --- src/corelib/io/qfileinfo_p.h | 5 ++++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 6616066..f4e92a5 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -41,11 +41,8 @@ #include "qplatformdefs.h" #include "qfileinfo.h" -#include "qdatetime.h" -#include "qabstractfileengine.h" #include "qfsfileengine_p.h" #include "qglobal.h" -#include "qatomic.h" #include "qhash.h" #include "qdir.h" #include "qfileinfo_p.h" diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index 8e00909..bf02aaa 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -54,6 +54,9 @@ // #include "qfileinfo.h" +#include "qabstractfileengine.h" +#include "qdatetime.h" +#include "qatomic.h" QT_BEGIN_NAMESPACE @@ -94,7 +97,7 @@ public: fileFlags = 0; cachedFlags = 0; if (fileEngine) - (void)fileEngine->fileFlags(QFSFileEngine::Refresh); + (void)fileEngine->fileFlags(QAbstractFileEngine::Refresh); } inline void clear() { clearFlags(); -- cgit v0.12 From 3c8ac0ee7f09bbef4dc56a05de538df1aa16a596 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:50 +0100 Subject: QFileInfo: Implement additional caching of FileOwner strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reduce overhead of the uid/gid to user/group name conversion by caching results from QAbstractFileEngine::owner(). Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 16 ++++++++++++++-- src/corelib/io/qfileinfo_p.h | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index f4e92a5..d827f57 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -137,6 +137,18 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const return ret; } +QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const +{ + if (data->cache_enabled && !data->fileOwners[(int)own].isNull()) + return data->fileOwners[(int)own]; + QString ret = data->fileEngine->owner(own); + if (ret.isNull()) + ret = QLatin1String(""); + if (data->cache_enabled) + data->fileOwners[(int)own] = ret; + return ret; +} + uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) const { // We split the testing into tests for for LinkType, BundleType, PermsMask @@ -1089,7 +1101,7 @@ QString QFileInfo::owner() const Q_D(const QFileInfo); if(!d->data->fileEngine) return QLatin1String(""); - return d->data->fileEngine->owner(QAbstractFileEngine::OwnerUser); + return d->getFileOwner(QAbstractFileEngine::OwnerUser); } /*! @@ -1125,7 +1137,7 @@ QString QFileInfo::group() const Q_D(const QFileInfo); if(!d->data->fileEngine) return QLatin1String(""); - return d->data->fileEngine->owner(QAbstractFileEngine::OwnerGroup); + return d->getFileOwner(QAbstractFileEngine::OwnerGroup); } /*! diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index bf02aaa..d97a0cf 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -78,6 +78,7 @@ public: uint getFileFlags(QAbstractFileEngine::FileFlags) const; QDateTime &getFileTime(QAbstractFileEngine::FileTime) const; QString getFileName(QAbstractFileEngine::FileName) const; + QString getFileOwner(QAbstractFileEngine::FileOwner own) const; enum { CachedFileFlags=0x01, CachedLinkTypeFlag=0x02, CachedBundleTypeFlag=0x04, CachedMTime=0x10, CachedCTime=0x20, CachedATime=0x40, @@ -103,12 +104,15 @@ public: clearFlags(); for (int i = QAbstractFileEngine::NFileNames - 1 ; i >= 0 ; --i) fileNames[i].clear(); + fileOwners[1].clear(); + fileOwners[0].clear(); } mutable QAtomicInt ref; QAbstractFileEngine *fileEngine; mutable QString fileName; mutable QString fileNames[QAbstractFileEngine::NFileNames]; + mutable QString fileOwners[2]; mutable uint cachedFlags : 31; mutable uint cache_enabled : 1; -- cgit v0.12 From bde7b69f2f69bbb2cf9eecb5e3ad3501c1f2c62e Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:50 +0100 Subject: cleanups & styling fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `if(' -> `if (' `for(' -> `for (' remove needless qhash.h include Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 93 ++++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index d827f57..616f6f9 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -43,7 +43,6 @@ #include "qfileinfo.h" #include "qfsfileengine_p.h" #include "qglobal.h" -#include "qhash.h" #include "qdir.h" #include "qfileinfo_p.h" @@ -51,7 +50,7 @@ QT_BEGIN_NAMESPACE QFileInfoPrivate::QFileInfoPrivate(const QFileInfo *copy) { - if(copy) { + if (copy) { copy->d_func()->data->ref.ref(); data = copy->d_func()->data; } else { @@ -127,12 +126,12 @@ void QFileInfoPrivate::detach() QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const { - if(data->cache_enabled && !data->fileNames[(int)name].isNull()) + if (data->cache_enabled && !data->fileNames[(int)name].isNull()) return data->fileNames[(int)name]; QString ret = data->fileEngine->fileName(name); if (ret.isNull()) ret = QLatin1String(""); - if(data->cache_enabled) + if (data->cache_enabled) data->fileNames[(int)name] = ret; return ret; } @@ -411,19 +410,19 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) const Q_D(const QFileInfo); // ### Qt 5: understand long and short file names on Windows // ### (GetFullPathName()). - if(fileinfo.d_func()->data == d->data) + if (fileinfo.d_func()->data == d->data) return true; - if(!d->data->fileEngine || !fileinfo.d_func()->data->fileEngine) + if (!d->data->fileEngine || !fileinfo.d_func()->data->fileEngine) return false; - if(d->data->fileEngine->caseSensitive() != fileinfo.d_func()->data->fileEngine->caseSensitive()) + if (d->data->fileEngine->caseSensitive() != fileinfo.d_func()->data->fileEngine->caseSensitive()) return false; - if(fileinfo.size() == size()) { //if the size isn't the same... + if (fileinfo.size() == size()) { //if the size isn't the same... QString file1 = canonicalFilePath(), file2 = fileinfo.canonicalFilePath(); - if(file1.length() == file2.length()) { - if(!fileinfo.d_func()->data->fileEngine->caseSensitive()) { - for(int i = 0; i < file1.length(); i++) { - if(file1.at(i).toLower() != file2.at(i).toLower()) + if (file1.length() == file2.length()) { + if (!fileinfo.d_func()->data->fileEngine->caseSensitive()) { + for (int i = 0; i < file1.length(); i++) { + if (file1.at(i).toLower() != file2.at(i).toLower()) return false; } return true; @@ -544,7 +543,7 @@ void QFileInfo::setFile(const QDir &dir, const QString &file) QString QFileInfo::absoluteFilePath() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::AbsoluteName); } @@ -562,7 +561,7 @@ QString QFileInfo::absoluteFilePath() const QString QFileInfo::canonicalFilePath() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::CanonicalName); } @@ -611,7 +610,7 @@ QString QFileInfo::absolutePath() const QString QFileInfo::canonicalPath() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::CanonicalPathName); } @@ -630,7 +629,7 @@ QString QFileInfo::canonicalPath() const QString QFileInfo::path() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::PathName); } @@ -655,7 +654,7 @@ QString QFileInfo::path() const bool QFileInfo::isRelative() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return true; return d->data->fileEngine->isRelativePath(); } @@ -672,7 +671,7 @@ bool QFileInfo::isRelative() const bool QFileInfo::makeAbsolute() { Q_D(QFileInfo); - if(!d->data->fileEngine || !d->data->fileEngine->isRelativePath()) + if (!d->data->fileEngine || !d->data->fileEngine->isRelativePath()) return false; QString absFileName = d->getFileName(QAbstractFileEngine::AbsoluteName); d->initFileEngine(absFileName); @@ -689,7 +688,7 @@ bool QFileInfo::makeAbsolute() bool QFileInfo::exists() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::ExistsFlag); } @@ -718,7 +717,7 @@ void QFileInfo::refresh() QString QFileInfo::filePath() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::DefaultName); } @@ -738,7 +737,7 @@ QString QFileInfo::filePath() const QString QFileInfo::fileName() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::BaseName); } @@ -759,7 +758,7 @@ QString QFileInfo::fileName() const QString QFileInfo::bundleName() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::BundleName); } @@ -784,7 +783,7 @@ QString QFileInfo::bundleName() const QString QFileInfo::baseName() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::BaseName).section(QLatin1Char('.'), 0, 0); } @@ -804,7 +803,7 @@ QString QFileInfo::baseName() const QString QFileInfo::completeBaseName() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); QString name = d->getFileName(QAbstractFileEngine::BaseName); int index = name.lastIndexOf(QLatin1Char('.')); @@ -826,7 +825,7 @@ QString QFileInfo::completeBaseName() const QString QFileInfo::completeSuffix() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); QString fileName = d->getFileName(QAbstractFileEngine::BaseName); int firstDot = fileName.indexOf(QLatin1Char('.')); @@ -854,7 +853,7 @@ QString QFileInfo::completeSuffix() const QString QFileInfo::suffix() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); QString fileName = d->getFileName(QAbstractFileEngine::BaseName); int lastDot = fileName.lastIndexOf(QLatin1Char('.')); @@ -907,7 +906,7 @@ QDir QFileInfo::absoluteDir() const */ QDir QFileInfo::dir(bool absPath) const { - if(absPath) + if (absPath) return absoluteDir(); return dir(); } @@ -922,7 +921,7 @@ QDir QFileInfo::dir(bool absPath) const bool QFileInfo::isReadable() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->hasAccess(QFileInfoPrivate::ReadAccess); } @@ -936,7 +935,7 @@ bool QFileInfo::isReadable() const bool QFileInfo::isWritable() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->hasAccess(QFileInfoPrivate::WriteAccess); } @@ -950,7 +949,7 @@ bool QFileInfo::isWritable() const bool QFileInfo::isExecutable() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->hasAccess(QFileInfoPrivate::ExecuteAccess); } @@ -964,7 +963,7 @@ bool QFileInfo::isExecutable() const bool QFileInfo::isHidden() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::HiddenFlag); } @@ -980,7 +979,7 @@ bool QFileInfo::isHidden() const bool QFileInfo::isFile() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::FileType); } @@ -995,7 +994,7 @@ bool QFileInfo::isFile() const bool QFileInfo::isDir() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::DirectoryType); } @@ -1012,7 +1011,7 @@ bool QFileInfo::isDir() const bool QFileInfo::isBundle() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::BundleType); } @@ -1038,7 +1037,7 @@ bool QFileInfo::isBundle() const bool QFileInfo::isSymLink() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::LinkType); } @@ -1080,7 +1079,7 @@ bool QFileInfo::isRoot() const QString QFileInfo::readLink() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::LinkName); } @@ -1099,7 +1098,7 @@ QString QFileInfo::readLink() const QString QFileInfo::owner() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileOwner(QAbstractFileEngine::OwnerUser); } @@ -1116,7 +1115,7 @@ QString QFileInfo::owner() const uint QFileInfo::ownerId() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return 0; return d->data->fileEngine->ownerId(QAbstractFileEngine::OwnerUser); } @@ -1135,7 +1134,7 @@ uint QFileInfo::ownerId() const QString QFileInfo::group() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QLatin1String(""); return d->getFileOwner(QAbstractFileEngine::OwnerGroup); } @@ -1152,7 +1151,7 @@ QString QFileInfo::group() const uint QFileInfo::groupId() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return 0; return d->data->fileEngine->ownerId(QAbstractFileEngine::OwnerGroup); } @@ -1174,7 +1173,7 @@ uint QFileInfo::groupId() const bool QFileInfo::permission(QFile::Permissions permissions) const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return false; return d->getFileFlags(QAbstractFileEngine::FileFlags((int)permissions)) == (uint)permissions; } @@ -1187,7 +1186,7 @@ bool QFileInfo::permission(QFile::Permissions permissions) const QFile::Permissions QFileInfo::permissions() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return 0; return QFile::Permissions(d->getFileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask); } @@ -1203,9 +1202,9 @@ QFile::Permissions QFileInfo::permissions() const qint64 QFileInfo::size() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return 0; - if(!d->data->getCachedFlag(QFileInfoPrivate::CachedSize)) { + if (!d->data->getCachedFlag(QFileInfoPrivate::CachedSize)) { d->data->setCachedFlag(QFileInfoPrivate::CachedSize); d->data->fileSize = d->data->fileEngine->size(); } @@ -1229,7 +1228,7 @@ qint64 QFileInfo::size() const QDateTime QFileInfo::created() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QDateTime(); return d->getFileTime(QAbstractFileEngine::CreationTime); } @@ -1243,7 +1242,7 @@ QDateTime QFileInfo::created() const QDateTime QFileInfo::lastModified() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QDateTime(); return d->getFileTime(QAbstractFileEngine::ModificationTime); } @@ -1260,7 +1259,7 @@ QDateTime QFileInfo::lastModified() const QDateTime QFileInfo::lastRead() const { Q_D(const QFileInfo); - if(!d->data->fileEngine) + if (!d->data->fileEngine) return QDateTime(); return d->getFileTime(QAbstractFileEngine::AccessTime); } -- cgit v0.12 From a9d351f72582c06a979874619003da36214b010f Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 26 Jan 2010 17:26:51 +0100 Subject: Whitespace cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 446 Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 86 ++++++++++---------------------------------- 1 file changed, 18 insertions(+), 68 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 616f6f9..21ff708 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -320,7 +320,6 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) \sa setFile() */ - QFileInfo::QFileInfo() : d_ptr(new QFileInfoPrivate()) { } @@ -331,7 +330,6 @@ QFileInfo::QFileInfo() : d_ptr(new QFileInfoPrivate()) \sa setFile(), isRelative(), QDir::setCurrent(), QDir::isRelativePath() */ - QFileInfo::QFileInfo(const QString &file) : d_ptr(new QFileInfoPrivate()) { d_ptr->initFileEngine(file); @@ -346,7 +344,6 @@ QFileInfo::QFileInfo(const QString &file) : d_ptr(new QFileInfoPrivate()) \sa isRelative() */ - QFileInfo::QFileInfo(const QFile &file) : d_ptr(new QFileInfoPrivate()) { d_ptr->initFileEngine(file.fileName()); @@ -364,7 +361,6 @@ QFileInfo::QFileInfo(const QFile &file) : d_ptr(new QFileInfoPrivate()) \sa isRelative() */ - QFileInfo::QFileInfo(const QDir &dir, const QString &file) : d_ptr(new QFileInfoPrivate()) { d_ptr->initFileEngine(dir.filePath(file)); @@ -373,7 +369,6 @@ QFileInfo::QFileInfo(const QDir &dir, const QString &file) : d_ptr(new QFileInfo /*! Constructs a new QFileInfo that is a copy of the given \a fileinfo. */ - QFileInfo::QFileInfo(const QFileInfo &fileinfo) : d_ptr(new QFileInfoPrivate(&fileinfo)) { @@ -383,7 +378,6 @@ QFileInfo::QFileInfo(const QFileInfo &fileinfo) : d_ptr(new QFileInfoPrivate(&fi Destroys the QFileInfo and frees its resources. */ - QFileInfo::~QFileInfo() { } @@ -456,7 +450,6 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) /*! Makes a copy of the given \a fileinfo and assigns it to this QFileInfo. */ - QFileInfo &QFileInfo::operator=(const QFileInfo &fileinfo) { Q_D(QFileInfo); @@ -479,7 +472,6 @@ QFileInfo &QFileInfo::operator=(const QFileInfo &fileinfo) \sa isRelative(), QDir::setCurrent(), QDir::isRelativePath() */ - void QFileInfo::setFile(const QString &file) { *this = QFileInfo(file); @@ -496,7 +488,6 @@ void QFileInfo::setFile(const QString &file) \sa isRelative() */ - void QFileInfo::setFile(const QFile &file) { *this = QFileInfo(file.fileName()); @@ -513,7 +504,6 @@ void QFileInfo::setFile(const QFile &file) \sa isRelative() */ - void QFileInfo::setFile(const QDir &dir, const QString &file) { *this = QFileInfo(dir.filePath(file)); @@ -549,15 +539,14 @@ QString QFileInfo::absoluteFilePath() const } /*! - Returns the canonical path including the file name, i.e. an absolute - path without symbolic links or redundant "." or ".." elements. + Returns the canonical path including the file name, i.e. an absolute + path without symbolic links or redundant "." or ".." elements. - If the file does not exist, canonicalFilePath() returns an empty - string. + If the file does not exist, canonicalFilePath() returns an empty + string. - \sa filePath(), absoluteFilePath(), dir() + \sa filePath(), absoluteFilePath(), dir() */ - QString QFileInfo::canonicalFilePath() const { Q_D(const QFileInfo); @@ -584,7 +573,6 @@ QString QFileInfo::canonicalFilePath() const \sa absoluteFilePath(), path(), canonicalPath(), fileName(), isRelative() */ - QString QFileInfo::absolutePath() const { Q_D(const QFileInfo); @@ -606,7 +594,6 @@ QString QFileInfo::absolutePath() const \sa path(), absolutePath() */ - QString QFileInfo::canonicalPath() const { Q_D(const QFileInfo); @@ -615,7 +602,6 @@ QString QFileInfo::canonicalPath() const return d->getFileName(QAbstractFileEngine::CanonicalPathName); } - /*! Returns the file's path. This doesn't include the file name. @@ -625,7 +611,6 @@ QString QFileInfo::canonicalPath() const \sa filePath(), absolutePath(), canonicalPath(), dir(), fileName(), isRelative() */ - QString QFileInfo::path() const { Q_D(const QFileInfo); @@ -650,7 +635,6 @@ QString QFileInfo::path() const \sa isAbsolute() */ - bool QFileInfo::isRelative() const { Q_D(const QFileInfo); @@ -659,7 +643,6 @@ bool QFileInfo::isRelative() const return d->data->fileEngine->isRelativePath(); } - /*! Converts the file's path to an absolute path if it is not already in that form. Returns true to indicate that the path was converted; otherwise returns false @@ -667,7 +650,6 @@ bool QFileInfo::isRelative() const \sa filePath(), isRelative() */ - bool QFileInfo::makeAbsolute() { Q_D(QFileInfo); @@ -684,7 +666,6 @@ bool QFileInfo::makeAbsolute() \note If the file is a symlink that points to a non existing file, false is returned. */ - bool QFileInfo::exists() const { Q_D(const QFileInfo); @@ -700,7 +681,6 @@ bool QFileInfo::exists() const \note On Windows CE, there might be a delay for the file system driver to detect changes on the file. */ - void QFileInfo::refresh() { Q_D(QFileInfo); @@ -713,7 +693,6 @@ void QFileInfo::refresh() \sa absoluteFilePath(), canonicalFilePath(), isRelative() */ - QString QFileInfo::filePath() const { Q_D(const QFileInfo); @@ -733,7 +712,6 @@ QString QFileInfo::filePath() const \sa isRelative(), filePath(), baseName(), extension() */ - QString QFileInfo::fileName() const { Q_D(const QFileInfo); @@ -754,7 +732,6 @@ QString QFileInfo::fileName() const \sa isBundle(), filePath(), baseName(), extension() */ - QString QFileInfo::bundleName() const { Q_D(const QFileInfo); @@ -779,7 +756,6 @@ QString QFileInfo::bundleName() const \sa fileName(), suffix(), completeSuffix(), completeBaseName() */ - QString QFileInfo::baseName() const { Q_D(const QFileInfo); @@ -799,7 +775,6 @@ QString QFileInfo::baseName() const \sa fileName(), suffix(), completeSuffix(), baseName() */ - QString QFileInfo::completeBaseName() const { Q_D(const QFileInfo); @@ -821,7 +796,6 @@ QString QFileInfo::completeBaseName() const \sa fileName(), suffix(), baseName(), completeBaseName() */ - QString QFileInfo::completeSuffix() const { Q_D(const QFileInfo); @@ -849,7 +823,6 @@ QString QFileInfo::completeSuffix() const \sa fileName(), completeSuffix(), baseName(), completeBaseName() */ - QString QFileInfo::suffix() const { Q_D(const QFileInfo); @@ -864,24 +837,23 @@ QString QFileInfo::suffix() const /*! - Returns the path of the object's parent directory as a QDir object. + Returns the path of the object's parent directory as a QDir object. - \bold{Note:} The QDir returned always corresponds to the object's - parent directory, even if the QFileInfo represents a directory. + \bold{Note:} The QDir returned always corresponds to the object's + parent directory, even if the QFileInfo represents a directory. - For each of the follwing, dir() returns a QDir for - \c{"~/examples/191697"}. + For each of the follwing, dir() returns a QDir for + \c{"~/examples/191697"}. - \snippet doc/src/snippets/fileinfo/main.cpp 0 + \snippet doc/src/snippets/fileinfo/main.cpp 0 - For each of the follwing, dir() returns a QDir for - \c{"."}. + For each of the follwing, dir() returns a QDir for + \c{"."}. - \snippet doc/src/snippets/fileinfo/main.cpp 1 + \snippet doc/src/snippets/fileinfo/main.cpp 1 - \sa absolutePath(), filePath(), fileName(), isRelative(), absoluteDir() + \sa absolutePath(), filePath(), fileName(), isRelative(), absoluteDir() */ - QDir QFileInfo::dir() const { // ### Qt5: Maybe rename this to parentDirectory(), considering what it actually do? @@ -893,7 +865,6 @@ QDir QFileInfo::dir() const \sa dir(), filePath(), fileName(), isRelative() */ - QDir QFileInfo::absoluteDir() const { return QDir(absolutePath()); @@ -917,7 +888,6 @@ QDir QFileInfo::dir(bool absPath) const \sa isWritable(), isExecutable(), permission() */ - bool QFileInfo::isReadable() const { Q_D(const QFileInfo); @@ -931,7 +901,6 @@ bool QFileInfo::isReadable() const \sa isReadable(), isExecutable(), permission() */ - bool QFileInfo::isWritable() const { Q_D(const QFileInfo); @@ -945,7 +914,6 @@ bool QFileInfo::isWritable() const \sa isReadable(), isWritable(), permission() */ - bool QFileInfo::isExecutable() const { Q_D(const QFileInfo); @@ -975,7 +943,6 @@ bool QFileInfo::isHidden() const \sa isDir(), isSymLink(), isBundle() */ - bool QFileInfo::isFile() const { Q_D(const QFileInfo); @@ -990,7 +957,6 @@ bool QFileInfo::isFile() const \sa isFile(), isSymLink(), isBundle() */ - bool QFileInfo::isDir() const { Q_D(const QFileInfo); @@ -1007,7 +973,6 @@ bool QFileInfo::isDir() const \sa isDir(), isSymLink(), isFile() */ - bool QFileInfo::isBundle() const { Q_D(const QFileInfo); @@ -1033,7 +998,6 @@ bool QFileInfo::isBundle() const \sa isFile(), isDir(), symLinkTarget() */ - bool QFileInfo::isSymLink() const { Q_D(const QFileInfo); @@ -1043,11 +1007,10 @@ bool QFileInfo::isSymLink() const } /*! - Returns true if the object points to a directory or to a symbolic - link to a directory, and that directory is the root directory; otherwise - returns false. + Returns true if the object points to a directory or to a symbolic + link to a directory, and that directory is the root directory; otherwise + returns false. */ - bool QFileInfo::isRoot() const { Q_D(const QFileInfo); @@ -1094,7 +1057,6 @@ QString QFileInfo::readLink() const \sa ownerId(), group(), groupId() */ - QString QFileInfo::owner() const { Q_D(const QFileInfo); @@ -1111,7 +1073,6 @@ QString QFileInfo::owner() const \sa owner(), group(), groupId() */ - uint QFileInfo::ownerId() const { Q_D(const QFileInfo); @@ -1130,7 +1091,6 @@ uint QFileInfo::ownerId() const \sa groupId(), owner(), ownerId() */ - QString QFileInfo::group() const { Q_D(const QFileInfo); @@ -1147,7 +1107,6 @@ QString QFileInfo::group() const \sa group(), owner(), ownerId() */ - uint QFileInfo::groupId() const { Q_D(const QFileInfo); @@ -1169,7 +1128,6 @@ uint QFileInfo::groupId() const \sa isReadable(), isWritable(), isExecutable() */ - bool QFileInfo::permission(QFile::Permissions permissions) const { Q_D(const QFileInfo); @@ -1182,7 +1140,6 @@ bool QFileInfo::permission(QFile::Permissions permissions) const Returns the complete OR-ed together combination of QFile::Permissions for the file. */ - QFile::Permissions QFileInfo::permissions() const { Q_D(const QFileInfo); @@ -1198,7 +1155,6 @@ QFile::Permissions QFileInfo::permissions() const \sa exists() */ - qint64 QFileInfo::size() const { Q_D(const QFileInfo); @@ -1224,7 +1180,6 @@ qint64 QFileInfo::size() const \sa lastModified() lastRead() */ - QDateTime QFileInfo::created() const { Q_D(const QFileInfo); @@ -1238,7 +1193,6 @@ QDateTime QFileInfo::created() const \sa created() lastRead() */ - QDateTime QFileInfo::lastModified() const { Q_D(const QFileInfo); @@ -1255,7 +1209,6 @@ QDateTime QFileInfo::lastModified() const \sa created() lastModified() */ - QDateTime QFileInfo::lastRead() const { Q_D(const QFileInfo); @@ -1267,7 +1220,6 @@ QDateTime QFileInfo::lastRead() const /*! \internal Detaches all internal data. */ - void QFileInfo::detach() { Q_D(QFileInfo); @@ -1279,7 +1231,6 @@ void QFileInfo::detach() \sa setCaching(), refresh() */ - bool QFileInfo::caching() const { Q_D(const QFileInfo); @@ -1298,7 +1249,6 @@ bool QFileInfo::caching() const \sa refresh(), caching() */ - void QFileInfo::setCaching(bool enable) { Q_D(QFileInfo); -- cgit v0.12 From 8de4f6f16ec2b5b3e92e25aafd2649f076c0b31b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 14:50:18 +0100 Subject: Remove test binary left behind --- tests/auto/selftests/xunit/tst_xunit | Bin 11624 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 tests/auto/selftests/xunit/tst_xunit diff --git a/tests/auto/selftests/xunit/tst_xunit b/tests/auto/selftests/xunit/tst_xunit deleted file mode 100755 index 31d03a8..0000000 Binary files a/tests/auto/selftests/xunit/tst_xunit and /dev/null differ -- cgit v0.12 From 7461ed5227e3002c4a6f74d458aa0255b7c1217d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 17:32:25 +0100 Subject: Optimise QStringList::join by pre-allocating the final size. This avoids a number of reallocations due to appending. This patch was contributed to us. Task-number: QTBUG-3242 Reviewed-by: Thiago Macieira --- src/corelib/tools/qstringlist.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index 4b0f488..e9bdf57 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -404,7 +404,17 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegExp &r */ QString QtPrivate::QStringList_join(const QStringList *that, const QString &sep) { + int totalLength = 0; + const int size = that->size(); + + for (int i = 0; i < size; ++i) + totalLength += that->at(i).size(); + + if(size > 0) + totalLength += sep.size() * (size - 1); + QString res; + res.reserve(totalLength); for (int i = 0; i < that->size(); ++i) { if (i) res += sep; -- cgit v0.12 From abeeac820a1da1e1d32768904fa70e048a836c3f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 14:42:05 +0100 Subject: Make indexOfMethod not crash when going through a metaobject with methodCount == 0. Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qmetaobject.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index d391893..be1b2ae 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -492,10 +492,14 @@ static inline int indexOfMethodRelative(const QMetaObject **baseObject, const char *method, bool normalizeStringData) { - while (*baseObject) { + const QMetaObject *m; + for (m = *baseObject; m; m = *baseObject = m->d.superdata) { const QMetaObject *const m = *baseObject; int i = (MethodType == MethodSignal && priv(m->d.data)->revision >= 4) ? (priv(m->d.data)->signalCount - 1) : (priv(m->d.data)->methodCount - 1); + if (i < 0) + continue; + const int end = (MethodType == MethodSlot && priv(m->d.data)->revision >= 4) ? (priv(m->d.data)->signalCount) : 0; if (!normalizeStringData) { @@ -513,7 +517,6 @@ static inline int indexOfMethodRelative(const QMetaObject **baseObject, return i; } } - *baseObject = m->d.superdata; } return -1; } -- cgit v0.12 From 97f7c9afb295140a7d979203f41d91082ee73cd9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 15:40:55 +0100 Subject: Fix crash handler regression introduced by c7739f7dd. The crash handler is removed when the FatalSignalHandler object goes out of scope, which it did right inside that if. Reviewed-By: Harald Fernengel --- src/testlib/qtestcase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 98e9787..40daecb 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1671,8 +1671,9 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) #endif { #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) + QScopedPointer handler; if (!noCrashHandler) - FatalSignalHandler handler; + handler.reset(new FatalSignalHandler); #endif qInvokeTestMethods(testObject); } -- cgit v0.12 From b88141c7505e10ffaa25cc20b444da8e2cc6d9c7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 15:30:06 +0100 Subject: BenchLib: update the result format and self-test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since BenchLib now uses floating point for its calculations, we should format both the value per-iteration and the total the same way. Otherwise, it would output something like "2e+08" for the total. Reviewed-by: Morten Sørvig --- src/testlib/qplaintestlogger.cpp | 3 ++- tests/auto/selftests/expected_benchlibcallgrind.txt | 2 +- tests/auto/selftests/tst_selftests.cpp | 13 ++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index e244690..46431a8 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -362,9 +362,10 @@ namespace QTest { char buf3[1024]; Q_ASSERT(result.iterations > 0); + formatResult(resultBuffer, 100, result.value, countSignificantDigits(result.value)); QTest::qt_snprintf( buf3, sizeof(buf3), " (total: %s, iterations: %d)", - QByteArray::number(result.value).constData(), // no 64-bit qt_snprintf support + resultBuffer, result.iterations); char buf[1024]; diff --git a/tests/auto/selftests/expected_benchlibcallgrind.txt b/tests/auto/selftests/expected_benchlibcallgrind.txt index caf2424..f172711 100644 --- a/tests/auto/selftests/expected_benchlibcallgrind.txt +++ b/tests/auto/selftests/expected_benchlibcallgrind.txt @@ -2,7 +2,7 @@ Config: Using QTest library 4.5.0, Qt 4.5.0 PASS : tst_BenchlibCallgrind::initTestCase() RESULT : tst_BenchlibCallgrind::twoHundredMillionInstructions(): - 200,000,000 instr. loads per iteration (total: 200000000, iterations: 1) + 200,000,000 instruction reads per iteration (total: 200000000, iterations: 1) PASS : tst_BenchlibCallgrind::twoHundredMillionInstructions() PASS : tst_BenchlibCallgrind::cleanupTestCase() Totals: 3 passed, 0 failed, 0 skipped diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 89ece0f..6608439 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -97,7 +97,7 @@ inline bool qCompare if (r1.unit == "msec") { variance = 0.1; } - else if (r1.unit == "instr. loads") { + else if (r1.unit == "instruction reads") { variance = 0.001; } else if (r1.unit == "ticks") { @@ -434,7 +434,7 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) /* This code avoids using a QRegExp because QRegExp might be broken. */ - /* Sample format: 4,000 msec per iteration (total: 4000, iterations: 1) */ + /* Sample format: 4,000 msec per iteration (total: 4,000, iterations: 1) */ QString sFirstNumber; while (!remaining.isEmpty() && !remaining.at(0).isSpace()) { @@ -468,7 +468,7 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) remaining = remaining.mid(sizeof(periterbit)-1); - /* Remaining: 4000, iterations: 1) */ + /* Remaining: 4,000, iterations: 1) */ static const char itersbit[] = ", iterations: "; QString sTotal; while (!remaining.startsWith(itersbit) && !remaining.isEmpty()) { @@ -482,9 +482,12 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) remaining = remaining.mid(sizeof(itersbit)-1); - qint64 total = sTotal.toLongLong(&ok); + /* 4,000 -> 4000 */ + sTotal.remove(','); + + double total = sTotal.toDouble(&ok); if (!ok) { - if (error) *error = sTotal + " (total) is not a valid integer"; + if (error) *error = sTotal + " (total) is not a valid number"; return out; } -- cgit v0.12 From 2877e3510db0cceeb4483b032fcc8f3bd61d28d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 27 Jan 2010 18:15:06 +0100 Subject: Fix regressions introduced in 3a5eb87965b60a3e249a16dc48cb06f4759dfb1b Caching of LinkType and BundleType is independent of other file flags. --- src/corelib/io/qfileinfo.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 21ff708..625098e 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -170,19 +170,19 @@ uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) cons req &= (~QAbstractFileEngine::BundleType); cachedFlags |= CachedFileFlags; + } - if (request & QAbstractFileEngine::LinkType) { - if (!data->getCachedFlag(CachedLinkTypeFlag)) { - req |= QAbstractFileEngine::LinkType; - cachedFlags |= CachedLinkTypeFlag; - } + if (request & QAbstractFileEngine::LinkType) { + if (!data->getCachedFlag(CachedLinkTypeFlag)) { + req |= QAbstractFileEngine::LinkType; + cachedFlags |= CachedLinkTypeFlag; } + } - if (request & QAbstractFileEngine::BundleType) { - if (!data->getCachedFlag(CachedBundleTypeFlag)) { - req |= QAbstractFileEngine::BundleType; - cachedFlags |= CachedBundleTypeFlag; - } + if (request & QAbstractFileEngine::BundleType) { + if (!data->getCachedFlag(CachedBundleTypeFlag)) { + req |= QAbstractFileEngine::BundleType; + cachedFlags |= CachedBundleTypeFlag; } } } -- cgit v0.12 From 21e0423a5c9ecd9da8e141dcfba25e60b55f7fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 27 Jan 2010 20:26:26 +0100 Subject: Fix QDirIterator auto test The test depended on being run inside the source directory, because of a dummy file hierarchy present there. With these changes the needed hierarchy is generated on the fly and cleaned up at the end of the test. Also removed garbage at the end of tst_QDirIterator::stopLinkLoop. Cleanup is done in test destructor. --- tests/auto/qdiriterator/entrylist/directory/dummy | 0 tests/auto/qdiriterator/entrylist/file | 0 tests/auto/qdiriterator/foo/bar/readme.txt | 0 .../qdiriterator/recursiveDirs/dir1/aPage.html | 8 -- .../qdiriterator/recursiveDirs/dir1/textFileB.txt | 1 - .../auto/qdiriterator/recursiveDirs/textFileA.txt | 1 - tests/auto/qdiriterator/tst_qdiriterator.cpp | 129 ++++++++++++--------- 7 files changed, 76 insertions(+), 63 deletions(-) delete mode 100644 tests/auto/qdiriterator/entrylist/directory/dummy delete mode 100644 tests/auto/qdiriterator/entrylist/file delete mode 100644 tests/auto/qdiriterator/foo/bar/readme.txt delete mode 100644 tests/auto/qdiriterator/recursiveDirs/dir1/aPage.html delete mode 100644 tests/auto/qdiriterator/recursiveDirs/dir1/textFileB.txt delete mode 100644 tests/auto/qdiriterator/recursiveDirs/textFileA.txt diff --git a/tests/auto/qdiriterator/entrylist/directory/dummy b/tests/auto/qdiriterator/entrylist/directory/dummy deleted file mode 100644 index e69de29..0000000 diff --git a/tests/auto/qdiriterator/entrylist/file b/tests/auto/qdiriterator/entrylist/file deleted file mode 100644 index e69de29..0000000 diff --git a/tests/auto/qdiriterator/foo/bar/readme.txt b/tests/auto/qdiriterator/foo/bar/readme.txt deleted file mode 100644 index e69de29..0000000 diff --git a/tests/auto/qdiriterator/recursiveDirs/dir1/aPage.html b/tests/auto/qdiriterator/recursiveDirs/dir1/aPage.html deleted file mode 100644 index 51a2261..0000000 --- a/tests/auto/qdiriterator/recursiveDirs/dir1/aPage.html +++ /dev/null @@ -1,8 +0,0 @@ - - - A title - - -

Some text

- - diff --git a/tests/auto/qdiriterator/recursiveDirs/dir1/textFileB.txt b/tests/auto/qdiriterator/recursiveDirs/dir1/textFileB.txt deleted file mode 100644 index 5b1dd02..0000000 --- a/tests/auto/qdiriterator/recursiveDirs/dir1/textFileB.txt +++ /dev/null @@ -1 +0,0 @@ -Some Text diff --git a/tests/auto/qdiriterator/recursiveDirs/textFileA.txt b/tests/auto/qdiriterator/recursiveDirs/textFileA.txt deleted file mode 100644 index 5b1dd02..0000000 --- a/tests/auto/qdiriterator/recursiveDirs/textFileA.txt +++ /dev/null @@ -1 +0,0 @@ -Some Text diff --git a/tests/auto/qdiriterator/tst_qdiriterator.cpp b/tests/auto/qdiriterator/tst_qdiriterator.cpp index 6cdd1f7..f6fce32 100644 --- a/tests/auto/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/qdiriterator/tst_qdiriterator.cpp @@ -71,6 +71,39 @@ public: tst_QDirIterator(); virtual ~tst_QDirIterator(); +private: // convenience functions + QStringList createdDirectories; + QStringList createdFiles; + + QDir currentDir; + bool createDirectory(const QString &dirName) + { + if (currentDir.mkdir(dirName)) { + createdDirectories.prepend(dirName); + return true; + } + return false; + } + + bool createFile(const QString &fileName) + { + QFile file(fileName); + if (file.open(QIODevice::WriteOnly)) { + createdFiles << fileName; + return true; + } + return false; + } + + bool createLink(const QString &destination, const QString &linkName) + { + if (QFile::link(destination, linkName)) { + createdFiles << linkName; + return true; + } + return false; + } + private slots: void iterateRelativeDirectory_data(); void iterateRelativeDirectory(); @@ -96,41 +129,47 @@ tst_QDirIterator::tst_QDirIterator() QFile::remove("entrylist/directory/entrylist3.lnk"); QFile::remove("entrylist/directory/entrylist4.lnk"); + createDirectory("entrylist"); + createDirectory("entrylist/directory"); + createFile("entrylist/file"); + createFile("entrylist/writable"); + createFile("entrylist/directory/dummy"); + + createDirectory("recursiveDirs"); + createDirectory("recursiveDirs/dir1"); + createFile("recursiveDirs/textFileA.txt"); + createFile("recursiveDirs/dir1/aPage.html"); + createFile("recursiveDirs/dir1/textFileB.txt"); + + createDirectory("foo"); + createDirectory("foo/bar"); + createFile("foo/bar/readme.txt"); + #ifndef Q_NO_SYMLINKS # if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) // ### Sadly, this is a platform difference right now. - QFile::link("entrylist/file", "entrylist/linktofile.lnk"); + createLink("entrylist/file", "entrylist/linktofile.lnk"); # ifndef Q_NO_SYMLINKS_TO_DIRS - QFile::link("entrylist/directory", "entrylist/linktodirectory.lnk"); + createLink("entrylist/directory", "entrylist/linktodirectory.lnk"); # endif - QFile::link("entrylist/nothing", "entrylist/brokenlink.lnk"); + createLink("entrylist/nothing", "entrylist/brokenlink.lnk"); # else - QFile::link("file", "entrylist/linktofile.lnk"); + createLink("file", "entrylist/linktofile.lnk"); # ifndef Q_NO_SYMLINKS_TO_DIRS - QFile::link("directory", "entrylist/linktodirectory.lnk"); + createLink("directory", "entrylist/linktodirectory.lnk"); # endif - QFile::link("nothing", "entrylist/brokenlink.lnk"); + createLink("nothing", "entrylist/brokenlink.lnk"); # endif #endif - QFile("entrylist/writable").open(QIODevice::ReadWrite); } tst_QDirIterator::~tst_QDirIterator() { - QFile::remove("entrylist/directory"); - QFile::remove("entrylist/linktofile.lnk"); - QFile::remove("entrylist/linktodirectory.lnk"); - QFile::remove("entrylist/brokenlink.lnk"); - QFile::remove("entrylist/brokenlink"); - QFile::remove("entrylist/writable"); - QFile::remove("entrylist/entrylist1.lnk"); - QFile::remove("entrylist/entrylist2.lnk"); - QFile::remove("entrylist/entrylist3.lnk"); - QFile::remove("entrylist/entrylist4.lnk"); - QFile::remove("entrylist/directory/entrylist1.lnk"); - QFile::remove("entrylist/directory/entrylist2.lnk"); - QFile::remove("entrylist/directory/entrylist3.lnk"); - QFile::remove("entrylist/directory/entrylist4.lnk"); + Q_FOREACH(QString fileName, createdFiles) + QFile::remove(fileName); + + Q_FOREACH(QString dirName, createdDirectories) + currentDir.rmdir(dirName); } void tst_QDirIterator::iterateRelativeDirectory_data() @@ -298,23 +337,23 @@ void tst_QDirIterator::stopLinkLoop() { #ifdef Q_OS_WIN // ### Sadly, this is a platform difference right now. - QFile::link(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/entrylist1.lnk"); - QFile::link("entrylist/.", "entrylist/entrylist2.lnk"); - QFile::link("entrylist/../entrylist/.", "entrylist/entrylist3.lnk"); - QFile::link("entrylist/..", "entrylist/entrylist4.lnk"); - QFile::link(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/directory/entrylist1.lnk"); - QFile::link("entrylist/.", "entrylist/directory/entrylist2.lnk"); - QFile::link("entrylist/../directory/.", "entrylist/directory/entrylist3.lnk"); - QFile::link("entrylist/..", "entrylist/directory/entrylist4.lnk"); + createLink(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/entrylist1.lnk"); + createLink("entrylist/.", "entrylist/entrylist2.lnk"); + createLink("entrylist/../entrylist/.", "entrylist/entrylist3.lnk"); + createLink("entrylist/..", "entrylist/entrylist4.lnk"); + createLink(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/directory/entrylist1.lnk"); + createLink("entrylist/.", "entrylist/directory/entrylist2.lnk"); + createLink("entrylist/../directory/.", "entrylist/directory/entrylist3.lnk"); + createLink("entrylist/..", "entrylist/directory/entrylist4.lnk"); #else - QFile::link(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/entrylist1.lnk"); - QFile::link(".", "entrylist/entrylist2.lnk"); - QFile::link("../entrylist/.", "entrylist/entrylist3.lnk"); - QFile::link("..", "entrylist/entrylist4.lnk"); - QFile::link(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/directory/entrylist1.lnk"); - QFile::link(".", "entrylist/directory/entrylist2.lnk"); - QFile::link("../directory/.", "entrylist/directory/entrylist3.lnk"); - QFile::link("..", "entrylist/directory/entrylist4.lnk"); + createLink(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/entrylist1.lnk"); + createLink(".", "entrylist/entrylist2.lnk"); + createLink("../entrylist/.", "entrylist/entrylist3.lnk"); + createLink("..", "entrylist/entrylist4.lnk"); + createLink(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/directory/entrylist1.lnk"); + createLink(".", "entrylist/directory/entrylist2.lnk"); + createLink("../directory/.", "entrylist/directory/entrylist3.lnk"); + createLink("..", "entrylist/directory/entrylist4.lnk"); #endif QDirIterator it(QLatin1String("entrylist"), QDirIterator::Subdirectories | QDirIterator::FollowSymlinks); @@ -325,22 +364,6 @@ void tst_QDirIterator::stopLinkLoop() QVERIFY(max); // The goal of this test is only to ensure that the test above don't malfunction - -#ifdef Q_OS_WIN - // ### Sadly, this is a platform difference right now. - QFile::link(QDir::currentPath() + QLatin1String("/entrylist"), "entrylist/entrylist1.lnk"); - QFile::link("../../entrylist/.", "entrylist/entrylist2.lnk"); - QFile::link("entrylist/..", "entrylist/entrylist3.lnk"); -#else - QFile::remove("entrylist/entrylist1.lnk"); - QFile::remove("entrylist/entrylist2.lnk"); - QFile::remove("entrylist/entrylist3.lnk"); - QFile::remove("entrylist/entrylist4.lnk"); - QFile::remove("entrylist/directory/entrylist1.lnk"); - QFile::remove("entrylist/directory/entrylist2.lnk"); - QFile::remove("entrylist/directory/entrylist3.lnk"); - QFile::remove("entrylist/directory/entrylist4.lnk"); -#endif } class EngineWithNoIterator : public QFSFileEngine -- cgit v0.12 From e60ea3cef1dec60b0f00ddc8fa48ed639ea06ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 28 Jan 2010 11:01:57 +0100 Subject: Fix breakage introduced in 21e0423a5c9ecd9da8e141dcfba25e60b55f7fe5 Turns out two of the files removed were still required by the resource compiler. --- tests/auto/qdiriterator/entrylist/directory/dummy | 0 tests/auto/qdiriterator/entrylist/file | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/auto/qdiriterator/entrylist/directory/dummy create mode 100644 tests/auto/qdiriterator/entrylist/file diff --git a/tests/auto/qdiriterator/entrylist/directory/dummy b/tests/auto/qdiriterator/entrylist/directory/dummy new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/qdiriterator/entrylist/file b/tests/auto/qdiriterator/entrylist/file new file mode 100644 index 0000000..e69de29 -- cgit v0.12 From 5ed327e29906717d3b95b910e147de6314512a61 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 28 Jan 2010 10:40:41 +0100 Subject: Cocoa: implement usage of override cursors This have never worked in the Cocoa port, it seems. This patch gives it a try. Reviewed-by: msorvig --- src/gui/kernel/qapplication_mac.mm | 38 ++++++++++++++++++++++++++++++++-- src/gui/kernel/qapplication_p.h | 3 +++ src/gui/kernel/qeventdispatcher_mac.mm | 2 +- src/gui/kernel/qwidget_mac.mm | 3 +++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index e72194e..961a3f6 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -1337,12 +1337,39 @@ void QApplication::setMainWidget(QWidget *mainWidget) /***************************************************************************** QApplication cursor stack *****************************************************************************/ +#ifdef QT_MAC_USE_COCOA +void QApplicationPrivate::disableUsageOfCursorRects(bool disable) +{ + // In Cocoa there are two competing ways of setting the cursor; either + // by using cursor rects (see qcocoaview_mac.mm), or by pushing/popping + // the cursor manually. When we use override cursors, it makes most sense + // to use the latter. But then we need to tell cocoa to stop using the + // first approach so it doesn't change the cursor back when hovering over + // a cursor rect: + QWidgetList topLevels = qApp->topLevelWidgets(); + for (int i=0; ioverrideCursor()) + [static_cast(qt_mac_nsCursorForQCursor(*override)) set]; +} +#endif + void QApplication::setOverrideCursor(const QCursor &cursor) { qApp->d_func()->cursor_list.prepend(cursor); #ifdef QT_MAC_USE_COCOA QMacCocoaAutoReleasePool pool; + if (qApp->d_func()->cursor_list.size() == 1) + qApp->d_func()->disableUsageOfCursorRects(true); [static_cast(qt_mac_nsCursorForQCursor(cursor)) push]; #else if (qApp && qApp->activeWindow()) @@ -1359,6 +1386,8 @@ void QApplication::restoreOverrideCursor() #ifdef QT_MAC_USE_COCOA QMacCocoaAutoReleasePool pool; [NSCursor pop]; + if (qApp->d_func()->cursor_list.isEmpty()) + qApp->d_func()->disableUsageOfCursorRects(false); #else if (qApp && qApp->activeWindow()) { const QCursor def(Qt::ArrowCursor); @@ -2432,6 +2461,12 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event } #ifdef QT_MAC_USE_COCOA +void QApplicationPrivate::qt_initAfterNSAppStarted() +{ + setupAppleEvents(); + updateOverrideCursor(); +} + void QApplicationPrivate::setupAppleEvents() { // This function is called from the event dispatcher when NSApplication has @@ -2444,7 +2479,6 @@ void QApplicationPrivate::setupAppleEvents() forEventClass:kCoreEventClass andEventID:kAEQuitApplication]; [eventManager setEventHandler:newDelegate andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; - } #endif @@ -2995,7 +3029,7 @@ void onApplicationWindowChangedActivation(QWidget *widget, bool activated) } QMenuBar::macUpdateMenuBar(); - + QApplicationPrivate::updateOverrideCursor(); #else Q_UNUSED(widget); Q_UNUSED(activated); diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index a796048..59565d4 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -458,7 +458,10 @@ public: static OSStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long); static OSStatus tabletProximityCallback(EventHandlerCallRef, EventRef, void *); #ifdef QT_MAC_USE_COCOA + static void qt_initAfterNSAppStarted(); static void setupAppleEvents(); + static void updateOverrideCursor(); + static void disableUsageOfCursorRects(bool disable); #endif static bool qt_mac_apply_settings(); #endif diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index 84d37ae..2a1da41 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -1049,7 +1049,7 @@ void QEventDispatcherMacPrivate::firstLoopEntry(CFRunLoopObserverRef ref, Q_UNUSED(ref); Q_UNUSED(activity); #ifdef QT_MAC_USE_COCOA - QApplicationPrivate::setupAppleEvents(); + QApplicationPrivate::qt_initAfterNSAppStarted(); #endif processPostedEvents(static_cast(info), blockSendPostedEvents); } diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 20c0cde..5b5ab40 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2311,6 +2311,9 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin q->setAttribute(Qt::WA_WState_WindowOpacitySet, false); } + if (qApp->overrideCursor()) + [windowRef disableCursorRects]; + setWindowLevel(); macUpdateHideOnSuspend(); macUpdateOpaqueSizeGrip(); -- cgit v0.12 From 6f260fe99f742949bbfcfcf3eebc19486bd09a1e Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Thu, 28 Jan 2010 11:18:03 +0100 Subject: Add new QMetaObject test for signal lookup. --- tests/benchmarks/qmetaobject/main.cpp | 105 ++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/tests/benchmarks/qmetaobject/main.cpp b/tests/benchmarks/qmetaobject/main.cpp index c375a16..eef6020 100644 --- a/tests/benchmarks/qmetaobject/main.cpp +++ b/tests/benchmarks/qmetaobject/main.cpp @@ -42,6 +42,84 @@ #include #include +class LotsOfSignals : public QObject +{ + Q_OBJECT +public: + LotsOfSignals() {} + +signals: + void extraSignal1(); + void extraSignal2(); + void extraSignal3(); + void extraSignal4(); + void extraSignal5(); + void extraSignal6(); + void extraSignal7(); + void extraSignal8(); + void extraSignal9(); + void extraSignal10(); + void extraSignal12(); + void extraSignal13(); + void extraSignal14(); + void extraSignal15(); + void extraSignal16(); + void extraSignal17(); + void extraSignal18(); + void extraSignal19(); + void extraSignal20(); + void extraSignal21(); + void extraSignal22(); + void extraSignal23(); + void extraSignal24(); + void extraSignal25(); + void extraSignal26(); + void extraSignal27(); + void extraSignal28(); + void extraSignal29(); + void extraSignal30(); + void extraSignal31(); + void extraSignal32(); + void extraSignal33(); + void extraSignal34(); + void extraSignal35(); + void extraSignal36(); + void extraSignal37(); + void extraSignal38(); + void extraSignal39(); + void extraSignal40(); + void extraSignal41(); + void extraSignal42(); + void extraSignal43(); + void extraSignal44(); + void extraSignal45(); + void extraSignal46(); + void extraSignal47(); + void extraSignal48(); + void extraSignal49(); + void extraSignal50(); + void extraSignal51(); + void extraSignal52(); + void extraSignal53(); + void extraSignal54(); + void extraSignal55(); + void extraSignal56(); + void extraSignal57(); + void extraSignal58(); + void extraSignal59(); + void extraSignal60(); + void extraSignal61(); + void extraSignal62(); + void extraSignal63(); + void extraSignal64(); + void extraSignal65(); + void extraSignal66(); + void extraSignal67(); + void extraSignal68(); + void extraSignal69(); + void extraSignal70(); +}; + class tst_qmetaobject: public QObject { Q_OBJECT @@ -57,6 +135,9 @@ private slots: void indexOfSignal(); void indexOfSlot_data(); void indexOfSlot(); + + void unconnected_data(); + void unconnected(); }; void tst_qmetaobject::initTestCase() @@ -154,6 +235,30 @@ void tst_qmetaobject::indexOfSlot() } } +void tst_qmetaobject::unconnected_data() +{ + QTest::addColumn("signal_index"); + QTest::newRow("signal--9") << 9; + QTest::newRow("signal--32") << 32; + QTest::newRow("signal--33") << 33; + QTest::newRow("signal--64") << 64; + QTest::newRow("signal--65") << 65; + QTest::newRow("signal--70") << 70; +} + +void tst_qmetaobject::unconnected() +{ + LotsOfSignals *obj = new LotsOfSignals; + QFETCH(int, signal_index); + QVERIFY(obj->metaObject()->methodCount() == 73); + void *v; + QBENCHMARK { + //+1 because QObject has one slot + QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, signal_index+1, &v); + } + delete obj; +} + QTEST_MAIN(tst_qmetaobject) #include "main.moc" -- cgit v0.12 From c58ac55bbe65866db85ba1338642c00fe5cc2a70 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 28 Jan 2010 15:38:55 +0100 Subject: Fix header labels on mac with rtl The removed code simply reduces the size of the rect when running with RightToLeft without compensating anywhere else. It seems to be a leftover from a previously removed piece of code. Reviewed-by: richard Task-number: QTBUG-6882 --- src/gui/styles/qmacstyle_mac.mm | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 083f730..2313ac5 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -4320,8 +4320,6 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, rect.setY(0); rect.setHeight(widget->height()); } - if (opt->direction == Qt::RightToLeft) - rect.adjust(15, 0, -20, 0); } break; case SE_ProgressBarGroove: -- cgit v0.12 From f842ec12706b70f94ab5f634dc2aa025ba2cf3f2 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 29 Jan 2010 10:49:14 +0100 Subject: Carbon: crash problem in QWidgetPrivate::hide_sys The crash occurs because we at one point try to assign a widget that is marked as 'about to be deleted' to a QPointer, after clearguards has been called. The correct fix is to avoid such an assignment in the first place. Task-number: QTBUG-4227 Reviewed-by: Prasanth --- src/gui/kernel/qwidget_mac.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 5b5ab40..b942bdd 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3579,6 +3579,8 @@ void QWidgetPrivate::hide_sys() if (!QWidget::mouseGrabber()){ QWidget *enterWidget = QApplication::widgetAt(QCursor::pos()); + if (enterWidget->data->in_destructor) + enterWidget = 0; QApplicationPrivate::dispatchEnterLeave(enterWidget, qt_mouseover); qt_mouseover = enterWidget; } -- cgit v0.12 From ebf9c943b789bb4ce1e1222ed17cc37bd0b1f1fe Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 29 Jan 2010 11:47:02 +0100 Subject: Carbon: crash problem in QWidgetPrivate::hide_sys, v2 See change: f842ec12706. Needed some ekstra checks for the cocoa port as well. Task-number: QTBUG-4227 Reviewed-by: Prasanth --- src/gui/kernel/qcocoaview_mac.mm | 2 ++ src/gui/kernel/qwidget_mac.mm | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index b4bb8bf..8c5d166 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -602,6 +602,8 @@ extern "C" { - (void)mouseEntered:(NSEvent *)event { + if (qwidgetprivate->data.in_destructor) + return; QEvent enterEvent(QEvent::Enter); NSPoint windowPoint = [event locationInWindow]; NSPoint globalPoint = [[event window] convertBaseToScreen:windowPoint]; diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index b942bdd..3ff46f5 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3579,7 +3579,7 @@ void QWidgetPrivate::hide_sys() if (!QWidget::mouseGrabber()){ QWidget *enterWidget = QApplication::widgetAt(QCursor::pos()); - if (enterWidget->data->in_destructor) + if (enterWidget && enterWidget->data->in_destructor) enterWidget = 0; QApplicationPrivate::dispatchEnterLeave(enterWidget, qt_mouseover); qt_mouseover = enterWidget; -- cgit v0.12