From 2c4f51cec3aaa219ff0b14afdeafd726cbf8a4db Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 18 Dec 2009 14:41:15 +0100 Subject: Doc: Made corrections to documentation style and clarified some points. Reviewed-by: Trust Me --- src/multimedia/audio/qaudioformat.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index b2bbe14..eb5dde3 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -120,7 +120,7 @@ public: \row \o Sample size \o How much data is stored in each sample (typically 8 - or 16) + or 16 bits) \row \o Sample type \o Numerical representation of sample (typically signed integer, @@ -224,7 +224,7 @@ bool QAudioFormat::isValid() const } /*! - Sets the frequency to \a frequency. + Sets the frequency (sample rate) to \a frequency. */ void QAudioFormat::setFrequency(int frequency) @@ -233,7 +233,7 @@ void QAudioFormat::setFrequency(int frequency) } /*! - Returns the current frequency value. + Returns the current frequency (sample rate) value. */ int QAudioFormat::frequency() const @@ -242,7 +242,7 @@ int QAudioFormat::frequency() const } /*! - Sets the channels to \a channels. + Sets the number of channels to the \a channels value specified. */ void QAudioFormat::setChannels(int channels) @@ -251,7 +251,7 @@ void QAudioFormat::setChannels(int channels) } /*! - Returns the current channel value. + Returns the current number of channels. */ int QAudioFormat::channels() const @@ -260,7 +260,7 @@ int QAudioFormat::channels() const } /*! - Sets the sampleSize to \a sampleSize. + Sets the sample size to the \a sampleSize specified. */ void QAudioFormat::setSampleSize(int sampleSize) @@ -269,7 +269,7 @@ void QAudioFormat::setSampleSize(int sampleSize) } /*! - Returns the current sampleSize value. + Returns the current sample size value. */ int QAudioFormat::sampleSize() const -- cgit v0.12 From ba7927c84e0e1ed4df197e60b1c9eeec8ce1475c Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 18 Dec 2009 14:49:48 +0100 Subject: Doc: Fixed comments in a code snippet. Reviewed-by: Trust Me --- doc/src/snippets/audio/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/snippets/audio/main.cpp b/doc/src/snippets/audio/main.cpp index 0910865..396872f 100644 --- a/doc/src/snippets/audio/main.cpp +++ b/doc/src/snippets/audio/main.cpp @@ -112,7 +112,7 @@ public slots: switch (newState) { case QAudio::StopState: if (output->error() != QAudio::NoError) { - // Do your error handlin + // Perform error handling } else { // Normal stop } -- cgit v0.12 From f124538ef4840c3d24b4c7e9e7221adb52bdee2c Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 6 Jan 2010 10:16:02 +1000 Subject: Added setChannelCount() to QAudioFormat. Added setChannelCount() and updated docs/examples/tests to use it instead of setChannels(). Reviewed-by:Justin McPherson --- doc/src/snippets/audio/main.cpp | 2 +- examples/multimedia/audiodevices/audiodevices.cpp | 4 ++-- examples/multimedia/audioinput/audioinput.cpp | 2 +- examples/multimedia/audiooutput/audiooutput.cpp | 2 +- src/multimedia/audio/qaudio_mac.cpp | 2 +- src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 6 +++--- src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 2 +- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 4 ++-- src/multimedia/audio/qaudioformat.cpp | 9 +++++++++ src/multimedia/audio/qaudioformat.h | 1 + src/multimedia/audio/qaudioinput.cpp | 2 +- src/multimedia/audio/qaudiooutput.cpp | 2 +- tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp | 2 +- tests/auto/qaudioformat/tst_qaudioformat.cpp | 10 +++++----- tests/auto/qaudioinput/tst_qaudioinput.cpp | 2 +- tests/auto/qaudiooutput/tst_qaudiooutput.cpp | 2 +- 16 files changed, 32 insertions(+), 22 deletions(-) diff --git a/doc/src/snippets/audio/main.cpp b/doc/src/snippets/audio/main.cpp index 0910865..1e6242d 100644 --- a/doc/src/snippets/audio/main.cpp +++ b/doc/src/snippets/audio/main.cpp @@ -91,7 +91,7 @@ private: QAudioFormat format; format.setFrequency(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 e205e03..4f4a95f 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -172,7 +172,7 @@ void AudioTest::deviceChanged(int idx) 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(); @@ -234,7 +234,7 @@ void AudioTest::freqChanged(int idx) 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 75bddd6..e6ebe95 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -196,7 +196,7 @@ InputTest::InputTest() pullMode = true; format.setFrequency(8000); - format.setChannels(1); + 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 b6047db..e822064 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -165,7 +165,7 @@ AudioTest::AudioTest() gen->start(); settings.setFrequency(SYSTEM_FREQ); - settings.setChannels(1); + 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..635377c 100644 --- a/src/multimedia/audio/qaudio_mac.cpp +++ b/src/multimedia/audio/qaudio_mac.cpp @@ -65,7 +65,7 @@ QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf) QAudioFormat audioFormat; audioFormat.setFrequency(sf.mSampleRate); - audioFormat.setChannels(sf.mChannelsPerFrame); + audioFormat.setChannelCount(sf.mChannelsPerFrame); audioFormat.setSampleSize(sf.mBitsPerChannel); audioFormat.setCodec(QString::fromLatin1("audio/pcm")); audioFormat.setByteOrder(sf.mFormatFlags & kLinearPCMFormatFlagIsBigEndian != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian); diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index f58f5be..3bcf05b 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -79,19 +79,19 @@ 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(8000); - nearest.setChannels(1); + 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); } diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp index 8905119..c8b0196 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -147,7 +147,7 @@ QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat& format) if (rc.frequency() != target.frequency()) rc.setFrequency(target.frequency()); if (rc.channels() != target.channels()) - rc.setChannels(target.channels()); + rc.setChannelCount(target.channels()); 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 33af022..3c5b129 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.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); nearest.setSampleSize(8); diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index b2bbe14..b8e0851 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -245,6 +245,15 @@ int QAudioFormat::frequency() const Sets the channels to \a channels. */ +void QAudioFormat::setChannelCount(int channels) +{ + d->channels = channels; +} + +/*! + \internal +*/ + void QAudioFormat::setChannels(int channels) { d->channels = channels; diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h index 7e92c2f..88241df 100644 --- a/src/multimedia/audio/qaudioformat.h +++ b/src/multimedia/audio/qaudioformat.h @@ -76,6 +76,7 @@ public: void setFrequency(int frequency); int frequency() const; + void setChannelCount(int channels); void setChannels(int channels); int channels() const; diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index d81df7a..0d43ce4 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -89,7 +89,7 @@ QT_BEGIN_NAMESPACE QAudioFormat format; // set up the format you want, eg. format.setFrequency(8000); - format.setChannels(1); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp index 1c7b617..2f1ad3b 100644 --- a/src/multimedia/audio/qaudiooutput.cpp +++ b/src/multimedia/audio/qaudiooutput.cpp @@ -84,7 +84,7 @@ QT_BEGIN_NAMESPACE QAudioFormat format; // Set up the format, eg. format.setFrequency(8000); - format.setChannels(1); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp index 715f219..14cf6b3 100644 --- a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp +++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp @@ -170,7 +170,7 @@ void tst_QAudioDeviceInfo::isformat() if(available) { QAudioFormat format; format.setFrequency(44100); - format.setChannels(2); + format.setChannelCount(2); format.setSampleType(QAudioFormat::SignedInt); format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleSize(16); diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp index 0778a8e..2742dd7 100644 --- a/tests/auto/qaudioformat/tst_qaudioformat.cpp +++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp @@ -78,7 +78,7 @@ void tst_QAudioFormat::checkNull() QVERIFY(!audioFormat1.isValid()); audioFormat0.setFrequency(44100); - audioFormat0.setChannels(2); + audioFormat0.setChannelCount(2); audioFormat0.setSampleSize(16); audioFormat0.setCodec("audio/pcm"); audioFormat0.setSampleType(QAudioFormat::SignedInt); @@ -95,7 +95,7 @@ void tst_QAudioFormat::checkFrequency() void tst_QAudioFormat::checkChannels() { QAudioFormat audioFormat; - audioFormat.setChannels(2); + audioFormat.setChannelCount(2); QVERIFY(audioFormat.channels() == 2); } @@ -138,14 +138,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); @@ -165,7 +165,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 744ce38..40bf01f 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -69,7 +69,7 @@ private: void tst_QAudioInput::initTestCase() { format.setFrequency(8000); - format.setChannels(1); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp index 26694cc..f3feec1 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -72,7 +72,7 @@ private: void tst_QAudioOutput::initTestCase() { format.setFrequency(8000); - format.setChannels(1); + format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); -- cgit v0.12 From 80d4a4945d3273a4b2ce91e34597533f661af320 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 6 Jan 2010 13:45:05 +1000 Subject: Frequency to SampleRate and channels to channelCount. -Added channelCount(), changed everything to use this instead of channels() in QAudioFormat class. -Added setSampleRate() and sampleRate(), changed everthing to use these instead of setFrequency() and frequency() in QAudioFormat class. -Added supportedSampleRates() and supportedChannelCounts(), changed everything to use these instead of supportedFrequencies() and supportedChannels() in QAudioDeviceInfo class. Reviewed-by:Justin McPherson --- doc/src/snippets/audio/main.cpp | 2 +- examples/multimedia/audiodevices/audiodevices.cpp | 12 +++---- examples/multimedia/audioinput/audioinput.cpp | 2 +- examples/multimedia/audiooutput/audiooutput.cpp | 2 +- src/multimedia/audio/qaudio_mac.cpp | 10 +++--- src/multimedia/audio/qaudiodeviceinfo.cpp | 26 ++++++++++++--- src/multimedia/audio/qaudiodeviceinfo.h | 2 ++ src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 20 ++++++------ src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 8 ++--- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 10 +++--- src/multimedia/audio/qaudioformat.cpp | 37 +++++++++++++++++++--- src/multimedia/audio/qaudioformat.h | 5 +++ src/multimedia/audio/qaudioinput.cpp | 2 +- src/multimedia/audio/qaudioinput_alsa_p.cpp | 8 ++--- src/multimedia/audio/qaudioinput_mac_p.cpp | 2 +- src/multimedia/audio/qaudioinput_win32_p.cpp | 14 ++++---- src/multimedia/audio/qaudiooutput.cpp | 2 +- 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 | 14 ++++---- tests/auto/qaudioformat/tst_qaudioformat.cpp | 16 +++++----- tests/auto/qaudioinput/tst_qaudioinput.cpp | 6 ++-- tests/auto/qaudiooutput/tst_qaudiooutput.cpp | 6 ++-- 24 files changed, 142 insertions(+), 90 deletions(-) diff --git a/doc/src/snippets/audio/main.cpp b/doc/src/snippets/audio/main.cpp index 1e6242d..bf4b145 100644 --- a/doc/src/snippets/audio/main.cpp +++ b/doc/src/snippets/audio/main.cpp @@ -89,7 +89,7 @@ private: { //![1] QAudioFormat format; - format.setFrequency(44100); + format.setSampleRate(44100); //![1] format.setChannelCount(2); format.setSampleSize(16); diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index 4f4a95f..beb31b4 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,14 +161,14 @@ 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()) @@ -229,7 +229,7 @@ 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) diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index e6ebe95..dbf460b 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -195,7 +195,7 @@ InputTest::InputTest() pullMode = true; - format.setFrequency(8000); + format.setSampleRate(8000); format.setChannelCount(1); format.setSampleSize(16); format.setSampleType(QAudioFormat::SignedInt); diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index e822064..7d60cd4 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -164,7 +164,7 @@ AudioTest::AudioTest() gen->start(); - settings.setFrequency(SYSTEM_FREQ); + settings.setSampleRate(SYSTEM_FREQ); settings.setChannelCount(1); settings.setSampleSize(16); settings.setCodec("audio/pcm"); diff --git a/src/multimedia/audio/qaudio_mac.cpp b/src/multimedia/audio/qaudio_mac.cpp index 635377c..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,7 +64,7 @@ QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf) { QAudioFormat audioFormat; - audioFormat.setFrequency(sf.mSampleRate); + audioFormat.setSampleRate(sf.mSampleRate); audioFormat.setChannelCount(sf.mChannelsPerFrame); audioFormat.setSampleSize(sf.mBitsPerChannel); audioFormat.setCodec(QString::fromLatin1("audio/pcm")); @@ -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 5e3adcb..226d723 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 + 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,7 +259,16 @@ QStringList QAudioDeviceInfo::supportedCodecs() const } /*! - Returns a list of supported frequencies. + Returns a list of supported sample rates. +*/ + +QList QAudioDeviceInfo::supportedSampleRates() const +{ + return supportedFrequencies(); +} + +/*! + \internal */ QList QAudioDeviceInfo::supportedFrequencies() const @@ -268,7 +277,16 @@ QList QAudioDeviceInfo::supportedFrequencies() const } /*! - Returns a list of supported channels. + Returns a list of supported channel counts. +*/ + +QList QAudioDeviceInfo::supportedChannelCounts() const +{ + return supportedChannels(); +} + +/*! + \internal */ QList QAudioDeviceInfo::supportedChannels() const diff --git a/src/multimedia/audio/qaudiodeviceinfo.h b/src/multimedia/audio/qaudiodeviceinfo.h index 5c7cb98..78b1e69 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 3bcf05b..9187264 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp @@ -78,14 +78,14 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const { QAudioFormat nearest; if(mode == QAudio::AudioOutput) { - nearest.setFrequency(44100); + 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.setSampleRate(8000); nearest.setChannelCount(1); nearest.setSampleType(QAudioFormat::UnSignedInt); nearest.setSampleSize(8); @@ -253,8 +253,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) @@ -295,18 +295,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 c8b0196..8e19b12 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.setChannelCount(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 3c5b129..739b0d0 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -94,14 +94,14 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const { QAudioFormat nearest; if(mode == QAudio::AudioOutput) { - nearest.setFrequency(44100); + 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(11025); + nearest.setSampleRate(11025); nearest.setChannelCount(1); nearest.setByteOrder(QAudioFormat::LittleEndian); nearest.setSampleType(QAudioFormat::SignedInt); @@ -181,12 +181,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 b8e0851..f7867f4 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -144,7 +144,7 @@ public: Values are initialized as follows: \list \o frequency() = -1 - \o channels() = -1 + \o channelCount() = -1 \o sampleSize() = -1 \o byteOrder() = QAudioFormat::Endian(QSysInfo::ByteOrder) \o sampleType() = QAudioFormat::Unknown @@ -224,7 +224,16 @@ bool QAudioFormat::isValid() const } /*! - Sets the frequency to \a frequency. + Sets the sample rate to \a samplerate Hertz. +*/ + +void QAudioFormat::setSampleRate(int samplerate) +{ + d->frequency = samplerate; +} + +/*! + \internal */ void QAudioFormat::setFrequency(int frequency) @@ -233,7 +242,16 @@ void QAudioFormat::setFrequency(int frequency) } /*! - Returns the current frequency value. + Returns the current sample rate in Hertz. +*/ + +int QAudioFormat::sampleRate() const +{ + return d->frequency; +} + +/*! + \internal */ int QAudioFormat::frequency() const @@ -242,7 +260,7 @@ int QAudioFormat::frequency() const } /*! - Sets the channels to \a channels. + Sets the channel count to \a channels. */ void QAudioFormat::setChannelCount(int channels) @@ -260,7 +278,16 @@ void QAudioFormat::setChannels(int channels) } /*! - Returns the current channel value. + Returns the current channel count value. +*/ + +int QAudioFormat::channelCount() const +{ + return d->channels; +} + +/*! + \internal */ int QAudioFormat::channels() const diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h index 88241df..efc247f 100644 --- a/src/multimedia/audio/qaudioformat.h +++ b/src/multimedia/audio/qaudioformat.h @@ -76,7 +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 0d43ce4..733ff4e 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -88,7 +88,7 @@ QT_BEGIN_NAMESPACE QAudioFormat format; // set up the format you want, eg. - format.setFrequency(8000); + format.setSampleRate(8000); format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 3dbe66c..096b7ca 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())); QList devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioInput); @@ -332,7 +332,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); @@ -505,7 +505,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; @@ -702,7 +702,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 d63045f..7c856f4 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::processedUSecs() const { - return totalFrames * 1000000 / audioFormat.frequency(); + return totalFrames * 1000000 / audioFormat.sampleRate(); } qint64 QAudioInputPrivate::elapsedUSecs() const diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index f50a547..f98ecc6 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -225,16 +225,16 @@ 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; } 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; @@ -374,8 +374,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; @@ -388,8 +388,8 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) qDebug()<<"IN: "< devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); @@ -354,7 +354,7 @@ bool QAudioOutputPrivate::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("QAudioOutput: snd_pcm_hw_params_set_channels: err = %1").arg(err); @@ -494,7 +494,7 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) err = snd_pcm_writei( handle, data, frames ); } if(err > 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 e0651bf..2dec43d 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::processedUSecs() const { - return totalFrames * 1000000 / audioFormat.frequency(); + return totalFrames * 1000000 / audioFormat.sampleRate(); } qint64 QAudioOutputPrivate::elapsedUSecs() const diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 02c8cfe..389aef9 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -213,7 +213,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; @@ -232,9 +232,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; @@ -289,8 +289,8 @@ void QAudioOutputPrivate::close() return; deviceState = QAudio::StoppedState; - 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); @@ -386,8 +386,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 14cf6b3..2270eb2 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,7 +169,7 @@ void tst_QAudioDeviceInfo::isformat() { if(available) { QAudioFormat format; - format.setFrequency(44100); + format.setSampleRate(44100); format.setChannelCount(2); format.setSampleType(QAudioFormat::SignedInt); format.setByteOrder(QAudioFormat::LittleEndian); @@ -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 2742dd7..5237dca 100644 --- a/tests/auto/qaudioformat/tst_qaudioformat.cpp +++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp @@ -77,7 +77,7 @@ void tst_QAudioFormat::checkNull() QAudioFormat audioFormat1(audioFormat0); QVERIFY(!audioFormat1.isValid()); - audioFormat0.setFrequency(44100); + audioFormat0.setSampleRate(44100); audioFormat0.setChannelCount(2); audioFormat0.setSampleSize(16); audioFormat0.setCodec("audio/pcm"); @@ -88,15 +88,15 @@ void tst_QAudioFormat::checkNull() void tst_QAudioFormat::checkFrequency() { QAudioFormat audioFormat; - audioFormat.setFrequency(44100); - QVERIFY(audioFormat.frequency() == 44100); + audioFormat.setSampleRate(44100); + QVERIFY(audioFormat.sampleRate() == 44100); } void tst_QAudioFormat::checkChannels() { QAudioFormat audioFormat; audioFormat.setChannelCount(2); - QVERIFY(audioFormat.channels() == 2); + QVERIFY(audioFormat.channelCount() == 2); } void tst_QAudioFormat::checkSampleSize() @@ -137,14 +137,14 @@ void tst_QAudioFormat::checkEquality() QVERIFY(!(audioFormat0 != audioFormat1)); // on filled formats - audioFormat0.setFrequency(8000); + audioFormat0.setSampleRate(8000); audioFormat0.setChannelCount(1); audioFormat0.setSampleSize(8); audioFormat0.setCodec("audio/pcm"); audioFormat0.setByteOrder(QAudioFormat::LittleEndian); audioFormat0.setSampleType(QAudioFormat::UnSignedInt); - audioFormat1.setFrequency(8000); + audioFormat1.setSampleRate(8000); audioFormat1.setChannelCount(1); audioFormat1.setSampleSize(8); audioFormat1.setCodec("audio/pcm"); @@ -154,7 +154,7 @@ void tst_QAudioFormat::checkEquality() QVERIFY(audioFormat0 == audioFormat1); QVERIFY(!(audioFormat0 != audioFormat1)); - audioFormat0.setFrequency(44100); + audioFormat0.setSampleRate(44100); QVERIFY(audioFormat0 != audioFormat1); QVERIFY(!(audioFormat0 == audioFormat1)); } @@ -164,7 +164,7 @@ void tst_QAudioFormat::checkAssignment() QAudioFormat audioFormat0; QAudioFormat audioFormat1; - audioFormat0.setFrequency(8000); + audioFormat0.setSampleRate(8000); audioFormat0.setChannelCount(1); audioFormat0.setSampleSize(8); audioFormat0.setCodec("audio/pcm"); diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp index 40bf01f..994e9ef 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -68,7 +68,7 @@ private: void tst_QAudioInput::initTestCase() { - format.setFrequency(8000); + format.setSampleRate(8000); format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); @@ -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 f3feec1..60d0124 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -71,7 +71,7 @@ private: void tst_QAudioOutput::initTestCase() { - format.setFrequency(8000); + format.setSampleRate(8000); format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); @@ -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 fac8aa652775424ae890cb428267c155f8e48b9b Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 6 Jan 2010 11:21:41 +0100 Subject: Doc: Improved the advice about deployment of plugins. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Recommended deploying all plugins, excluding only those that are not required. Included accessibility plugins in the list of example plugins that users may need. Reviewed-by: Jan-Arve Sæther --- doc/src/deployment/deployment.qdoc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/src/deployment/deployment.qdoc b/doc/src/deployment/deployment.qdoc index 6a1760e..1459e6a 100644 --- a/doc/src/deployment/deployment.qdoc +++ b/doc/src/deployment/deployment.qdoc @@ -110,6 +110,7 @@ \o \l {QtXmlPatterns} \o \l {Phonon Module}{Phonon} \o \l {Qt3Support} + \o \endtable Since Qt is not a system library, it has to be redistributed along @@ -117,10 +118,15 @@ of the libraries used by the application. Using static linking, however, the Qt run-time is compiled into the executable. - In particular, you will need to deploy Qt plugins, such as - JPEG support or SQL drivers. For more information about plugins, - see the \l {plugins-howto.html}{How to Create Qt Plugins} - documentation. + In general, you should deploy all plugins that your build of Qt uses, + excluding only those that you have identified as being unnecessary + for your application and its users. + + For instance, you may need to deploy plugins for JPEG support and + SQL drivers, but you should also deploy plugins that your users may + require, including those for accessibility. + For more information about plugins, see the + \l{plugins-howto.html}{How to Create Qt Plugins} documentation. When deploying an application using the shared library approach you must ensure that the Qt libraries will use the correct path to -- cgit v0.12 From 982cffb529f65c7d0c401844ef9af1925e550ffb Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 6 Jan 2010 13:44:17 +0100 Subject: Doc: Made coding style changes to the Audio Input and Output examples. Reviewed-by: Trust Me --- examples/multimedia/audioinput/audioinput.cpp | 75 +++++++++++++------------ examples/multimedia/audioinput/audioinput.h | 35 ++++++------ examples/multimedia/audiooutput/audiooutput.cpp | 26 ++++----- 3 files changed, 70 insertions(+), 66 deletions(-) diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 75bddd6..4d54776 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -52,8 +52,8 @@ #define BUFFER_SIZE 4096 -AudioInfo::AudioInfo(QObject* parent, QAudioInput* device) - :QIODevice( parent ) +AudioInfo::AudioInfo(QObject *parent, QAudioInput *device) + :QIODevice(parent) { input = device; @@ -90,21 +90,24 @@ qint64 AudioInfo::writeData(const char *data, qint64 len) m_maxValue = 0; - qint16* s = (qint16*)data; + qint16 *s = (qint16*)data; // sample format is S16LE, only! - for(int i=0;i m_maxValue) m_maxValue = abs(sample); + if (abs(sample) > m_maxValue) m_maxValue = abs(sample); } // check for clipping - if(m_maxValue>=(maxAmp-1)) clipping = true; + if (m_maxValue >= (maxAmp - 1)) + clipping = true; float value = ((float)m_maxValue/(float)maxAmp); - if(clipping) m_maxValue = 100; - else m_maxValue = (int)(value*100); + if (clipping) + m_maxValue = 100; + else + m_maxValue = (int)(value*100); emit update(); @@ -132,25 +135,25 @@ void RenderArea::paintEvent(QPaintEvent * /* event */) QPainter painter(this); painter.setPen(Qt::black); - painter.drawRect(QRect(painter.viewport().left()+10, painter.viewport().top()+10, - painter.viewport().right()-20, painter.viewport().bottom()-20)); - - if(level == 0) + painter.drawRect(QRect(painter.viewport().left()+10, + painter.viewport().top()+10, + painter.viewport().right()-20, + painter.viewport().bottom()-20)); + if (level == 0) return; painter.setPen(Qt::red); int pos = ((painter.viewport().right()-20)-(painter.viewport().left()+11))*level/100; - int x1,y1,x2,y2; - for(int i=0;i<10;i++) { - x1 = painter.viewport().left()+11; - y1 = painter.viewport().top()+10+i; - x2 = painter.viewport().left()+20+pos; - y2 = painter.viewport().top()+10+i; - if(x2 < painter.viewport().left()+10) + for (int i = 0; i < 10; ++i) { + int x1 = painter.viewport().left()+11; + int y1 = painter.viewport().top()+10+i; + int x2 = painter.viewport().left()+20+pos; + int y2 = painter.viewport().top()+10+i; + if (x2 < painter.viewport().left()+10) x2 = painter.viewport().left()+10; - painter.drawLine(QPoint(x1,y1),QPoint(x2,y2)); + painter.drawLine(QPoint(x1, y1),QPoint(x2, y2)); } } @@ -171,20 +174,20 @@ InputTest::InputTest() deviceBox = new QComboBox(this); QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); - for(int i = 0; i < devices.size(); ++i) { + for(int i = 0; i < devices.size(); ++i) deviceBox->addItem(devices.at(i).deviceName(), qVariantFromValue(devices.at(i))); - } - connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); + + connect(deviceBox, SIGNAL(activated(int)), SLOT(deviceChanged(int))); layout->addWidget(deviceBox); button = new QPushButton(this); button->setText(tr("Click for Push Mode")); - connect(button,SIGNAL(clicked()),SLOT(toggleMode())); + connect(button, SIGNAL(clicked()), SLOT(toggleMode())); layout->addWidget(button); button2 = new QPushButton(this); button2->setText(tr("Click To Suspend")); - connect(button2,SIGNAL(clicked()),SLOT(toggleSuspend())); + connect(button2, SIGNAL(clicked()), SLOT(toggleSuspend())); layout->addWidget(button2); window->setLayout(layout); @@ -214,10 +217,10 @@ InputTest::InputTest() } audioInput = new QAudioInput(format,this); - connect(audioInput,SIGNAL(notify()),SLOT(status())); - connect(audioInput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); + connect(audioInput, SIGNAL(notify()), SLOT(status())); + connect(audioInput, SIGNAL(stateChanged(QAudio::State)), SLOT(state(QAudio::State))); audioinfo = new AudioInfo(this,audioInput); - connect(audioinfo,SIGNAL(update()),SLOT(refreshDisplay())); + connect(audioinfo, SIGNAL(update()), SLOT(refreshDisplay())); audioinfo->start(); audioInput->start(audioinfo); } @@ -250,7 +253,7 @@ void InputTest::toggleMode() if (pullMode) { button->setText(tr("Click for Pull Mode")); input = audioInput->start(); - connect(input,SIGNAL(readyRead()),SLOT(readMore())); + connect(input, SIGNAL(readyRead()), SLOT(readMore())); pullMode = false; } else { button->setText(tr("Click for Push Mode")); @@ -263,25 +266,25 @@ void InputTest::toggleSuspend() { // toggle suspend/resume if(audioInput->state() == QAudio::SuspendedState) { - qWarning()<<"status: Suspended, resume()"; + qWarning() << "status: Suspended, resume()"; audioInput->resume(); button2->setText("Click To Suspend"); } else if (audioInput->state() == QAudio::ActiveState) { - qWarning()<<"status: Active, suspend()"; + qWarning() << "status: Active, suspend()"; audioInput->suspend(); button2->setText("Click To Resume"); } else if (audioInput->state() == QAudio::StoppedState) { - qWarning()<<"status: Stopped, resume()"; + qWarning() << "status: Stopped, resume()"; audioInput->resume(); button2->setText("Click To Suspend"); } else if (audioInput->state() == QAudio::IdleState) { - qWarning()<<"status: IdleState"; + qWarning() << "status: IdleState"; } } void InputTest::state(QAudio::State state) { - qWarning()<<" state="<state() == QAudio::SuspendedState) { + qWarning() << "status: Suspended, resume()"; audioOutput->resume(); button2->setText("Click To Suspend"); } else if (audioOutput->state() == QAudio::ActiveState) { - qWarning()<<"status: Active, suspend()"; + qWarning() << "status: Active, suspend()"; audioOutput->suspend(); button2->setText("Click To Resume"); } else if (audioOutput->state() == QAudio::StoppedState) { - qWarning()<<"status: Stopped, resume()"; + qWarning() << "status: Stopped, resume()"; audioOutput->resume(); button2->setText("Click To Suspend"); } else if (audioOutput->state() == QAudio::IdleState) { - qWarning()<<"status: IdleState"; + qWarning() << "status: IdleState"; } } void AudioTest::state(QAudio::State state) { - qWarning()<<" state="<display, VisualIDMask, &visualInfo, &numVisuals); - if (!vi || numVisuals < 1) { - qWarning("QGLTempContext: Unable to get X11 visual info id."); - return; - } + XVisualInfo visualInfo; + XVisualInfo *vi; + int numVisuals; + EGLint id = 0; + + eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &id); + if (id == 0) { + // EGL_NATIVE_VISUAL_ID is optional and might not be supported + // on some implementations - we'll have to do it the hard way + QX11Info xinfo; + qt_egl_setup_x11_visual(visualInfo, display, config, xinfo, false); + } else { + visualInfo.visualid = id; + } + vi = XGetVisualInfo(X11->display, VisualIDMask, &visualInfo, &numVisuals); + if (!vi || numVisuals < 1) { + qWarning("QGLTempContext: Unable to get X11 visual info id."); + return; + } - window = XCreateWindow(X11->display, RootWindow(X11->display, screen), - 0, 0, 1, 1, 0, - vi->depth, InputOutput, vi->visual, - 0, 0); + window = XCreateWindow(X11->display, RootWindow(X11->display, screen), + 0, 0, 1, 1, 0, + vi->depth, InputOutput, vi->visual, + 0, 0); - surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType) window, NULL); + surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType) window, NULL); - if (surface == EGL_NO_SURFACE) { - qWarning("QGLTempContext: Error creating EGL surface."); - XFree(vi); - XDestroyWindow(X11->display, window); - return; - } + if (surface == EGL_NO_SURFACE) { + qWarning("QGLTempContext: Error creating EGL surface."); + XFree(vi); + XDestroyWindow(X11->display, window); + return; + } - EGLint contextAttribs[] = { + EGLint contextAttribs[] = { #ifdef QT_OPENGL_ES_2 - EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_CONTEXT_CLIENT_VERSION, 2, #endif - EGL_NONE - }; - context = eglCreateContext(display, config, 0, contextAttribs); - if (context != EGL_NO_CONTEXT - && eglMakeCurrent(display, surface, surface, context)) - { - initialized = true; - } else { - qWarning("QGLTempContext: Error creating EGL context."); - eglDestroySurface(display, surface); - XDestroyWindow(X11->display, window); - } - XFree(vi); + EGL_NONE + }; + context = eglCreateContext(display, config, 0, contextAttribs); + if (context != EGL_NO_CONTEXT + && eglMakeCurrent(display, surface, surface, context)) + { + initialized = true; + } else { + qWarning("QGLTempContext: Error creating EGL context."); + eglDestroySurface(display, surface); + XDestroyWindow(X11->display, window); } + XFree(vi); + } ~QGLTempContext() { if (initialized) { @@ -349,7 +349,7 @@ bool qt_egl_setup_x11_visual(XVisualInfo &vi, EGLDisplay display, EGLConfig conf // If EGL does not know the visual ID, so try to select an appropriate one ourselves, first // using XRender if we're supposed to have an alpha, then falling back to XGetVisualInfo - + #if !defined(QT_NO_XRENDER) if (vi.visualid == 0 && useArgbVisual) { // Try to use XRender to find an ARGB visual we can use -- cgit v0.12 From 6026436f0de6020252410c021e0745a22599b159 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 7 Jan 2010 16:13:14 +0100 Subject: Fix performance regression in _q_polishItems. QSet is a hash internally, using Iterator::begin while erasing elements inside the set might create holes and then the complexity increase. We now use the return value of erase (the next element) so the complexity is linear. For those who create/delete item in the polish event (BAD), _q_polishItem might be slower than the normal call. Task-number:QTBUG-6958 Reviewed-by:olivier --- src/gui/graphicsview/qgraphicsscene.cpp | 17 +++++++++++------ src/gui/graphicsview/qgraphicsscene_p.h | 1 + tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 774a6d3..ceb810b 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -292,6 +292,7 @@ QGraphicsScenePrivate::QGraphicsScenePrivate() processDirtyItemsEmitted(false), selectionChanging(0), needSortTopLevelItems(true), + unpolishedItemsModified(true), holesInTopLevelSiblingIndex(false), topLevelSequentialOrdering(true), scenePosDescendantsUpdatePending(false), @@ -428,12 +429,12 @@ void QGraphicsScenePrivate::unregisterTopLevelItem(QGraphicsItem *item) */ void QGraphicsScenePrivate::_q_polishItems() { - QSet::Iterator it; + QSet::Iterator it = unpolishedItems.begin(); const QVariant booleanTrueVariant(true); while (!unpolishedItems.isEmpty()) { - it = unpolishedItems.begin(); QGraphicsItem *item = *it; - unpolishedItems.erase(it); + it = unpolishedItems.erase(it); + unpolishedItemsModified = false; if (!item->d_ptr->explicitlyHidden) { item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant); item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant); @@ -442,6 +443,8 @@ void QGraphicsScenePrivate::_q_polishItems() QEvent event(QEvent::Polish); QApplication::sendEvent((QGraphicsWidget *)item, &event); } + if (unpolishedItemsModified) + it = unpolishedItems.begin(); } } @@ -636,6 +639,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) hoverItems.removeAll(item); cachedItemsUnderMouse.removeAll(item); unpolishedItems.remove(item); + unpolishedItemsModified = true; resetDirtyItem(item); //We remove all references of item from the sceneEventFilter arrays @@ -2577,9 +2581,10 @@ void QGraphicsScene::addItem(QGraphicsItem *item) item->d_ptr->resolveFont(d->font.resolve()); item->d_ptr->resolvePalette(d->palette.resolve()); - if (d->unpolishedItems.isEmpty()) - QMetaObject::invokeMethod(this, "_q_polishItems", Qt::QueuedConnection); - d->unpolishedItems.insert(item); + if (d->unpolishedItems.isEmpty()) + QMetaObject::invokeMethod(this, "_q_polishItems", Qt::QueuedConnection); + d->unpolishedItems.insert(item); + d->unpolishedItemsModified = true; // Reenable selectionChanged() for individual items --d->selectionChanging; diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index 69e4d5b..f6ec0aa 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -111,6 +111,7 @@ public: QSet unpolishedItems; QList topLevelItems; bool needSortTopLevelItems; + bool unpolishedItemsModified; bool holesInTopLevelSiblingIndex; bool topLevelSequentialOrdering; diff --git a/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp index 1944219..53fd9b6 100644 --- a/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp @@ -64,6 +64,7 @@ private slots: void addItem(); void itemAt_data(); void itemAt(); + void initialShow(); }; tst_QGraphicsScene::tst_QGraphicsScene() @@ -227,5 +228,21 @@ void tst_QGraphicsScene::itemAt() qApp->processEvents(); } +void tst_QGraphicsScene::initialShow() +{ + QGraphicsScene scene; + + QBENCHMARK { + for (int y = 0; y < 30000; ++y) { + QGraphicsRectItem *item = new QGraphicsRectItem(0, 0, 50, 50); + item->setPos((y/2) * item->rect().width(), (y/2) * item->rect().height()); + scene.addItem(item); + } + scene.itemAt(0, 0); // triggers indexing + //This call polish the items so we bench their processing too. + qApp->processEvents(); + } +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" -- cgit v0.12 From f8e08419c78e94d32273c8b039dd48dc9d5e3433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 7 Jan 2010 16:14:07 +0100 Subject: Reset the GL stencil mask, op and function in resetGLState(). Task-number: QTBUG-7203 Reviewed-by: Samuel --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 5901601..ff096c2 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -559,6 +559,9 @@ void QGL2PaintEngineExPrivate::resetGLState() glDepthMask(true); glDepthFunc(GL_LESS); glClearDepth(1); + glStencilMask(0xff); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + glStencilFunc(GL_ALWAYS, 0, 0xff); } void QGL2PaintEngineEx::endNativePainting() -- cgit v0.12 From 3b57425aa11e5e1536016ccccdde7657493a0dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 7 Jan 2010 13:31:08 +0100 Subject: Avoid double-buffering in QFile Since Qt 4.3 QIODevice has been providing read buffering for buffered devices; QFile provides a write buffer. Thus, requesting a buffered file from the engine results in unnecessary double-buffering where this is supported natively. By preferring QFile/QIODevice's buffering over the file engine we reduce the number of system calls. On the other hand, buffering inside QIODevice can't easily be disabled without changing the return value of QIODevice::openMode() (function is non-virtual). Reviewed-by: Thiago Macieira --- src/corelib/io/qfile.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 72d1d16..eb6f5be 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -968,9 +968,6 @@ bool QFile::isSequential() const mode, if the relevant file does not already exist, this function will try to create a new file before opening it. - \note Because of limitations in the native API, QFile ignores the - Unbuffered flag on Windows. - \sa QIODevice::OpenMode, setFileName() */ bool QFile::open(OpenMode mode) @@ -988,7 +985,9 @@ bool QFile::open(OpenMode mode) qWarning("QIODevice::open: File access not specified"); return false; } - if (fileEngine()->open(mode)) { + + // QIODevice provides the buffering, so there's no need to request it from the file engine. + if (fileEngine()->open(mode | QIODevice::Unbuffered)) { QIODevice::open(mode); if (mode & Append) seek(size()); -- cgit v0.12 From 6bf1674f1e51fd8b08783035cda7493ecd63b443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 7 Jan 2010 14:50:14 +0100 Subject: Don't drop errors from flush on QFile::close Now that we don't defer to the file engine for the write buffer it is doubly more important to retain errors from flush. The logic employed reproduces what we already had in QFSFileEngine::close, earliest error stays. Reviewed-by: Thiago Macieira --- src/corelib/io/qfile.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index eb6f5be..b6fa5f3 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -1386,11 +1386,14 @@ QFile::close() Q_D(QFile); if(!isOpen()) return; - flush(); + bool flushed = flush(); QIODevice::close(); - unsetError(); - if(!fileEngine()->close()) + + // keep earlier error from flush + if (fileEngine()->close() && flushed) + unsetError(); + else if (flushed) d->setError(fileEngine()->error(), fileEngine()->errorString()); } -- cgit v0.12 From 183be5348e53ef1df9a6e1eb82f10f24ce612f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 7 Jan 2010 15:54:06 +0100 Subject: Fix bugs evidenced by change to keep flush errors on QFile::close When closing a file, the contents of the write buffer should be emptied even in the case where flush fails, so it doesn't leak to subsequent files opened through the same instance. This is inline with what would happen with native close on a buffered device. Also changed the resource file engine to succeed on flush. Since all writes fail there, logically it's write buffer is empty and flush should succeed. This keeps auto-tests happy :-) tst_QFile::fullDisk auto-test extended to ensure re-opening QFile does not keep the write buffer alive. Reviewed-by: Thiago Macieira --- src/corelib/io/qfile.cpp | 3 +++ src/corelib/io/qresource.cpp | 2 +- tests/auto/qfile/tst_qfile.cpp | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index b6fa5f3..6395cc7 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -1389,6 +1389,9 @@ QFile::close() bool flushed = flush(); QIODevice::close(); + // reset write buffer + d->lastWasWrite = false; + d->writeBuffer.clear(); // keep earlier error from flush if (fileEngine()->close() && flushed) diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 3d54969..adfbb15 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -1285,7 +1285,7 @@ bool QResourceFileEngine::close() bool QResourceFileEngine::flush() { - return false; + return true; } qint64 QResourceFileEngine::read(char *data, qint64 len) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 453434d..f407b12 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -2119,15 +2119,17 @@ void tst_QFile::fullDisk() file.write(&c, 0); QVERIFY(!file.flush()); QCOMPARE(file.error(), QFile::ResourceError); - file.write(&c, 1); + QCOMPARE(file.write(&c, 1), qint64(1)); QVERIFY(!file.flush()); QCOMPARE(file.error(), QFile::ResourceError); file.close(); QVERIFY(!file.isOpen()); QCOMPARE(file.error(), QFile::ResourceError); + file.open(QIODevice::WriteOnly); QCOMPARE(file.error(), QFile::NoError); + QVERIFY(file.flush()); // Shouldn't inherit write buffer file.close(); QCOMPARE(file.error(), QFile::NoError); -- cgit v0.12 From 3e0d30cbb7f5b8faeb7c7389b935c37da47f6944 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 7 Jan 2010 11:09:47 +0100 Subject: Autotest: rename test with typo in the name --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 8f393fe..20cf922 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -223,7 +223,7 @@ private Q_SLOTS: void ioPostToHttpFromMiddleOfQBufferFiveBytes(); void ioPostToHttpNoBufferFlag(); void ioPostToHttpUploadProgress(); - void ioPostToHttpEmtpyUploadProgress(); + void ioPostToHttpEmptyUploadProgress(); void lastModifiedHeaderForFile(); void lastModifiedHeaderForHttp(); @@ -2921,7 +2921,7 @@ void tst_QNetworkReply::ioPostToHttpUploadProgress() server.close(); } -void tst_QNetworkReply::ioPostToHttpEmtpyUploadProgress() +void tst_QNetworkReply::ioPostToHttpEmptyUploadProgress() { QByteArray ba; ba.resize(0); -- cgit v0.12 From 0d97775f7a1077862281e3858da6b2c899ea8790 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 7 Jan 2010 18:12:17 +0100 Subject: Doc: Added license information for the Symbian version of qtmain. Reviewed-by: Trust Me Discussed-with: Legal and axis --- doc/src/modules.qdoc | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/doc/src/modules.qdoc b/doc/src/modules.qdoc index 1a16609..298e0be 100644 --- a/doc/src/modules.qdoc +++ b/doc/src/modules.qdoc @@ -996,9 +996,9 @@ \brief Describes the use and license of the qtmain helper library. qtmain is a helper library that enables the developer to write a - cross-platform main() function on Windows. If you do not use \l qmake - or other build tools such as CMake, then you need to link against - the \c qtmain library. + cross-platform main() function on Windows and on the Symbian platform. + If you do not use \l qmake or other build tools such as CMake, then you + need to link against the \c qtmain library. \section1 License Information @@ -1011,9 +1011,9 @@ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).\br All rights reserved. - Contact: Nokia Corporation (qt-info@nokia.com)\br + Contact: Nokia Corporation (qt-info@nokia.com) - You may use this file under the terms of the BSD license as follows:\br + You may use this file under the terms of the BSD license as follows: "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -1037,6 +1037,48 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." \endlegalese + + The contents of the \c{qts60main.cpp} and \c{qts60main_mcrt0.cpp} files, + located in the \c{src/s60main} directory are not covered by the + \l{GNU General Public License (GPL)}, the + \l{GNU Lesser General Public License (LGPL)}, or the + \l{Qt Commercial Editions}{Qt Commercial License}. Instead, they are + distributed under the following license. + + \legalese + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\br + All rights reserved.\br + Contact: Nokia Corporation (qt-info@nokia.com) + + This file is part of the Symbian application wrapper of the Qt Toolkit. + + You may use this file under the terms of the BSD license as follows: + + "Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met:\br + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer.\br + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution.\br + * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + the names of its contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + \endlegalese */ /*! -- cgit v0.12 From 5d03f940fd1e2cf80211318053f8cbe139e46b6a Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 7 Jan 2010 18:15:02 +0100 Subject: Doc: Added the QAudio namespace to the multimedia module documentation. Also added it to the multimedia group. Reviewed-by: Trust Me --- src/multimedia/audio/qaudio.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/multimedia/audio/qaudio.cpp b/src/multimedia/audio/qaudio.cpp index 9d69640..e0f24ce 100644 --- a/src/multimedia/audio/qaudio.cpp +++ b/src/multimedia/audio/qaudio.cpp @@ -65,6 +65,8 @@ public: /*! \namespace QAudio \brief The QAudio namespace contains enums used by the audio classes. + \inmodule QtMultimedia + \ingroup multimedia \since 4.6 */ -- cgit v0.12 From a010d26629e8aa5aaa14a7e57ace06708fc903d6 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 7 Jan 2010 18:32:45 +0100 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( 99ccc1c3e4db5354246720f9b9aa3d282e64497d ) Changes in WebKit/qt since the last update: ++ b/WebKit/qt/ChangeLog 2010-01-07 Yael Aharon Reviewed by Kenneth Rohde Christiansen. [Qt] Allow the application to override online/offline network status https://bugs.webkit.org/show_bug.cgi?id=32684 Add a setting so that applications can overide the network status. Applications that use this setting still need to block network access through QNAM. * Api/qwebsettings.cpp: (qt_networkAccessAllowed): --- .../webkit/JavaScriptCore/API/JSClassRef.cpp | 17 ++++++------ src/3rdparty/webkit/JavaScriptCore/ChangeLog | 23 +++++++++++++++++ .../webkit/JavaScriptCore/runtime/Structure.h | 6 +++++ src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 30 ++++++++++++++++++++++ src/3rdparty/webkit/WebCore/WebCore.pro | 4 +-- .../platform/network/NetworkStateNotifier.h | 6 ++++- .../network/qt/NetworkStateNotifierPrivate.h | 2 ++ .../platform/network/qt/NetworkStateNotifierQt.cpp | 25 +++++++++++++++--- src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp | 11 ++++++++ src/3rdparty/webkit/WebKit/qt/ChangeLog | 14 ++++++++++ 11 files changed, 124 insertions(+), 16 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/API/JSClassRef.cpp b/src/3rdparty/webkit/JavaScriptCore/API/JSClassRef.cpp index afde7ce..3785bab 100644 --- a/src/3rdparty/webkit/JavaScriptCore/API/JSClassRef.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/API/JSClassRef.cpp @@ -61,8 +61,8 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* if (const JSStaticValue* staticValue = definition->staticValues) { m_staticValues = new OpaqueJSClassStaticValuesTable(); while (staticValue->name) { - m_staticValues->add(UString::Rep::createFromUTF8(staticValue->name), - new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes)); + StaticValueEntry* e = new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes); + m_staticValues->add(UString::Rep::createFromUTF8(staticValue->name), e); ++staticValue; } } @@ -70,8 +70,8 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* if (const JSStaticFunction* staticFunction = definition->staticFunctions) { m_staticFunctions = new OpaqueJSClassStaticFunctionsTable(); while (staticFunction->name) { - m_staticFunctions->add(UString::Rep::createFromUTF8(staticFunction->name), - new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes)); + StaticFunctionEntry* e = new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes); + m_staticFunctions->add(UString::Rep::createFromUTF8(staticFunction->name), e); ++staticFunction; } } @@ -149,8 +149,9 @@ OpaqueJSClassContextData::OpaqueJSClassContextData(OpaqueJSClass* jsClass) OpaqueJSClassStaticValuesTable::const_iterator end = jsClass->m_staticValues->end(); for (OpaqueJSClassStaticValuesTable::const_iterator it = jsClass->m_staticValues->begin(); it != end; ++it) { ASSERT(!it->first->identifierTable()); - staticValues->add(UString::Rep::createCopying(it->first->data(), it->first->size()), - new StaticValueEntry(it->second->getProperty, it->second->setProperty, it->second->attributes)); + StaticValueEntry* e = new StaticValueEntry(it->second->getProperty, it->second->setProperty, it->second->attributes); + staticValues->add(UString::Rep::createCopying(it->first->data(), it->first->size()), e); + } } else @@ -162,8 +163,8 @@ OpaqueJSClassContextData::OpaqueJSClassContextData(OpaqueJSClass* jsClass) OpaqueJSClassStaticFunctionsTable::const_iterator end = jsClass->m_staticFunctions->end(); for (OpaqueJSClassStaticFunctionsTable::const_iterator it = jsClass->m_staticFunctions->begin(); it != end; ++it) { ASSERT(!it->first->identifierTable()); - staticFunctions->add(UString::Rep::createCopying(it->first->data(), it->first->size()), - new StaticFunctionEntry(it->second->callAsFunction, it->second->attributes)); + StaticFunctionEntry* e = new StaticFunctionEntry(it->second->callAsFunction, it->second->attributes); + staticFunctions->add(UString::Rep::createCopying(it->first->data(), it->first->size()), e); } } else diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index 1694966..e292418 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,3 +1,26 @@ +2010-01-07 Norbert Leser + + Reviewed by NOBODY (OOPS!). + + RVCT compiler with "-Otime -O3" optimization tries to optimize out + inline new'ed pointers that are passed as arguments. + Proposed patch assigns new'ed pointer explicitly outside function call. + + * API/JSClassRef.cpp: + (OpaqueJSClass::OpaqueJSClass): + (OpaqueJSClassContextData::OpaqueJSClassContextData): + +2010-01-07 Norbert Leser + + Reviewed by NOBODY (OOPS!). + + Added time-based optimization and increased optimization level to O3, + conditionally for COMPILER(RVCT), + for increasing performance of JavaScript execution. + (Default settings are Ospace and O2) + + * runtime/Structure.h: + 2009-11-19 Thiago Macieira Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h index f355c53..ecdd997 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h @@ -45,6 +45,12 @@ #define DUMP_PROPERTYMAP_STATS 0 #endif +#if COMPILER(RVCT) +#pragma arm +#pragma Otime +#pragma O3 +#endif + namespace JSC { class MarkStack; diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 6b107cd..0b88429 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - b217cdfedc7b5e7581325bda718192247f03dd5d + 99ccc1c3e4db5354246720f9b9aa3d282e64497d diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index acc8a6a..516fadd 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,33 @@ +2010-01-07 Yael Aharon + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Allow the application to override online/offline network status + https://bugs.webkit.org/show_bug.cgi?id=32684 + + Added API to NetworkStateNotifier for forcing network status. + + * platform/network/NetworkStateNotifier.h: + * platform/network/qt/NetworkStateNotifierPrivate.h: + * platform/network/qt/NetworkStateNotifierQt.cpp: + (WebCore::NetworkStateNotifierPrivate::NetworkStateNotifierPrivate): + (WebCore::NetworkStateNotifierPrivate::onlineStateChanged): + (WebCore::NetworkStateNotifierPrivate::networkAccessPermissionChanged): + (WebCore::NetworkStateNotifier::updateState): + (WebCore::NetworkStateNotifier::NetworkStateNotifier): + (WebCore::NetworkStateNotifier::setNetworkAccessAllowed): + +2010-01-07 Simon Hausmann + + Reviewed by Tor Arne Vestbø. + + [Qt] Fix linkage against Qt mobility API bearer management module + + Use the documented .pro file syntax to link against the correct + library and (more importantly) get the include paths correct. + + * WebCore.pro: + 2010-01-07 Laszlo Gombos Reviewed by NOBODY (OOPS!). diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index be64e3b..3eba696 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -2876,8 +2876,8 @@ contains(DEFINES, ENABLE_QT_BEARER=1) { SOURCES += \ platform/network/qt/NetworkStateNotifierQt.cpp - LIBS += -lQtBearer - + CONFIG += mobility + MOBILITY += bearer } contains(DEFINES, ENABLE_SVG=1) { diff --git a/src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h b/src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h index f8c5654..700a062 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h +++ b/src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h @@ -56,7 +56,11 @@ public: void setNetworkStateChangedFunction(void (*)()); bool onLine() const { return m_isOnLine; } - + +#if (PLATFORM(QT) && ENABLE(QT_BEARER)) + void setNetworkAccessAllowed(bool); +#endif + private: bool m_isOnLine; void (*m_networkStateChangedFunction)(); diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h b/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h index 7af6392..536b06a 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h @@ -37,10 +37,12 @@ public: ~NetworkStateNotifierPrivate(); public slots: void onlineStateChanged(bool); + void networkAccessPermissionChanged(bool); public: QtMobility::QNetworkConfigurationManager* m_configurationManager; bool m_online; + bool m_networkAccessAllowed; NetworkStateNotifier* m_notifier; }; diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp index f74398b..e694264 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp @@ -30,6 +30,7 @@ namespace WebCore { NetworkStateNotifierPrivate::NetworkStateNotifierPrivate(NetworkStateNotifier* notifier) : m_configurationManager(new QNetworkConfigurationManager()) , m_online(m_configurationManager->isOnline()) + , m_networkAccessAllowed(true) , m_notifier(notifier) { Q_ASSERT(notifier); @@ -42,7 +43,18 @@ void NetworkStateNotifierPrivate::onlineStateChanged(bool isOnline) return; m_online = isOnline; - m_notifier->updateState(); + if (m_networkAccessAllowed) + m_notifier->updateState(); +} + +void NetworkStateNotifierPrivate::networkAccessPermissionChanged(bool isAllowed) +{ + if (isAllowed == m_networkAccessAllowed) + return; + + m_networkAccessAllowed = isAllowed; + if (m_online) + m_notifier->updateState(); } NetworkStateNotifierPrivate::~NetworkStateNotifierPrivate() @@ -52,10 +64,10 @@ NetworkStateNotifierPrivate::~NetworkStateNotifierPrivate() void NetworkStateNotifier::updateState() { - if (m_isOnLine == p->m_online) + if (m_isOnLine == (p->m_online && p->m_networkAccessAllowed)) return; - m_isOnLine = p->m_online; + m_isOnLine = p->m_online && p->m_networkAccessAllowed; if (m_networkStateChangedFunction) m_networkStateChangedFunction(); } @@ -65,7 +77,12 @@ NetworkStateNotifier::NetworkStateNotifier() , m_networkStateChangedFunction(0) { p = new NetworkStateNotifierPrivate(this); - m_isOnLine = p->m_online; + m_isOnLine = p->m_online && p->m_networkAccessAllowed; +} + +void NetworkStateNotifier::setNetworkAccessAllowed(bool isAllowed) +{ + p->networkAccessPermissionChanged(isAllowed); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp index b637d04..79ef16f 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp @@ -47,6 +47,17 @@ #include #include +#if ENABLE(QT_BEARER) +#include "NetworkStateNotifier.h" +#endif + +void QWEBKIT_EXPORT qt_networkAccessAllowed(bool isAllowed) +{ +#if ENABLE(QT_BEARER) + WebCore::networkStateNotifier().setNetworkAccessAllowed(isAllowed); +#endif +} + class QWebSettingsPrivate { public: QWebSettingsPrivate(WebCore::Settings* wcSettings = 0) diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index d7c3c52..31fad69 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,17 @@ +2010-01-07 Yael Aharon + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Allow the application to override online/offline network status + https://bugs.webkit.org/show_bug.cgi?id=32684 + + Add a setting so that applications can overide the network status. + Applications that use this setting still need to block network access + through QNAM. + + * Api/qwebsettings.cpp: + (qt_networkAccessAllowed): + 2010-01-07 Yongjun Zhang , Laszlo Gombos Reviewed by Simon Hausmann. -- cgit v0.12 From 23f9444055edcaeb79fa680523800ad11671cece Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 7 Jan 2010 19:28:51 +0100 Subject: make it possible to retrieve name of the user who owns the file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QFSFileEngine::owner(OwnerUser) now works as expected Merge-request: 815 Reviewed-by: João Abecasis --- src/corelib/io/qfsfileengine_win.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index d8b6b00..1c0d5cf 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1731,7 +1731,8 @@ QString QFSFileEngine::owner(FileOwner own) const if(ptrGetNamedSecurityInfoW && ptrLookupAccountSidW) { if(ptrGetNamedSecurityInfoW((wchar_t*)d->filePath.utf16(), SE_FILE_OBJECT, own == OwnerGroup ? GROUP_SECURITY_INFORMATION : OWNER_SECURITY_INFORMATION, - NULL, &pOwner, NULL, NULL, &pSD) == ERROR_SUCCESS) { + own == OwnerUser ? &pOwner : 0, own == OwnerGroup ? &pOwner : 0, + 0, 0, &pSD) == ERROR_SUCCESS) { DWORD lowner = 0, ldomain = 0; SID_NAME_USE use; // First call, to determine size of the strings (with '\0'). -- cgit v0.12 From c24d7011e3e0cd84ce5bce4755ee9a6473bd60c0 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 7 Jan 2010 19:28:52 +0100 Subject: fix styling; improve readability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * tabs -> spaces; * if( -> if ( * some strings rearranged. no code changes! Merge-request: 815 Reviewed-by: João Abecasis --- src/corelib/io/qfsfileengine_win.cpp | 69 +++++++++++++++++------------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 1c0d5cf..1c3c801 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1419,22 +1419,20 @@ QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions() const #if !defined(QT_NO_LIBRARY) if((qt_ntfs_permission_lookup > 0) && ((QSysInfo::WindowsVersion&QSysInfo::WV_NT_based) > QSysInfo::WV_NT)) { - PSID pOwner = 0; - PSID pGroup = 0; - PACL pDacl; - PSECURITY_DESCRIPTOR pSD; - ACCESS_MASK access_mask; - - enum { ReadMask = 0x00000001, WriteMask = 0x00000002, ExecMask = 0x00000020 }; resolveLibs(); if(ptrGetNamedSecurityInfoW && ptrBuildTrusteeWithSidW && ptrGetEffectiveRightsFromAclW) { + enum { ReadMask = 0x00000001, WriteMask = 0x00000002, ExecMask = 0x00000020 }; QString fname = filePath.endsWith(QLatin1String(".lnk")) ? readLink(filePath) : filePath; + PSID pOwner = 0; + PSID pGroup = 0; + PACL pDacl; + PSECURITY_DESCRIPTOR pSD; DWORD res = ptrGetNamedSecurityInfoW((wchar_t*)fname.utf16(), SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, &pOwner, &pGroup, &pDacl, 0, &pSD); - if(res == ERROR_SUCCESS) { + ACCESS_MASK access_mask; TRUSTEE_W trustee; { //user if(ptrGetEffectiveRightsFromAclW(pDacl, ¤tUserTrusteeW, &access_mask) != ERROR_SUCCESS) @@ -1722,34 +1720,33 @@ QString QFSFileEngine::owner(FileOwner own) const { #if !defined(QT_NO_LIBRARY) Q_D(const QFSFileEngine); - if((qt_ntfs_permission_lookup > 0) && ((QSysInfo::WindowsVersion&QSysInfo::WV_NT_based) > QSysInfo::WV_NT)) { - PSID pOwner = 0; - PSECURITY_DESCRIPTOR pSD; - QString name; - QFSFileEnginePrivate::resolveLibs(); - - if(ptrGetNamedSecurityInfoW && ptrLookupAccountSidW) { - if(ptrGetNamedSecurityInfoW((wchar_t*)d->filePath.utf16(), SE_FILE_OBJECT, - own == OwnerGroup ? GROUP_SECURITY_INFORMATION : OWNER_SECURITY_INFORMATION, - own == OwnerUser ? &pOwner : 0, own == OwnerGroup ? &pOwner : 0, - 0, 0, &pSD) == ERROR_SUCCESS) { - DWORD lowner = 0, ldomain = 0; - SID_NAME_USE use; - // First call, to determine size of the strings (with '\0'). - ptrLookupAccountSidW(NULL, pOwner, NULL, &lowner, NULL, &ldomain, (SID_NAME_USE*)&use); - wchar_t *owner = new wchar_t[lowner]; - wchar_t *domain = new wchar_t[ldomain]; - // Second call, size is without '\0' - if(ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner, &lowner, - (LPWSTR)domain, &ldomain, (SID_NAME_USE*)&use)) { - name = QString::fromUtf16((ushort*)owner); - } - LocalFree(pSD); - delete [] owner; - delete [] domain; - } - } - return name; + if ((qt_ntfs_permission_lookup > 0) && ((QSysInfo::WindowsVersion&QSysInfo::WV_NT_based) > QSysInfo::WV_NT)) { + QString name; + QFSFileEnginePrivate::resolveLibs(); + if (ptrGetNamedSecurityInfoW && ptrLookupAccountSidW) { + PSID pOwner = 0; + PSECURITY_DESCRIPTOR pSD; + if (ptrGetNamedSecurityInfoW((wchar_t*)d->filePath.utf16(), SE_FILE_OBJECT, + own == OwnerGroup ? GROUP_SECURITY_INFORMATION : OWNER_SECURITY_INFORMATION, + own == OwnerUser ? &pOwner : 0, own == OwnerGroup ? &pOwner : 0, + 0, 0, &pSD) == ERROR_SUCCESS) { + DWORD lowner = 0, ldomain = 0; + SID_NAME_USE use; + // First call, to determine size of the strings (with '\0'). + ptrLookupAccountSidW(NULL, pOwner, NULL, &lowner, NULL, &ldomain, (SID_NAME_USE*)&use); + wchar_t *owner = new wchar_t[lowner]; + wchar_t *domain = new wchar_t[ldomain]; + // Second call, size is without '\0' + if (ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner, &lowner, + (LPWSTR)domain, &ldomain, (SID_NAME_USE*)&use)) { + name = QString::fromUtf16((ushort*)owner); + } + LocalFree(pSD); + delete [] owner; + delete [] domain; + } + } + return name; } #else Q_UNUSED(own); -- cgit v0.12 From 428a624f73ed03a311f572386de1a518ad3d5d5a Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 7 Jan 2010 19:28:52 +0100 Subject: improve readability a bit more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 815 Reviewed-by: João Abecasis --- src/corelib/io/qfsfileengine_win.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 1c3c801..c3ea08a 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1718,27 +1718,28 @@ uint QFSFileEngine::ownerId(FileOwner /*own*/) const QString QFSFileEngine::owner(FileOwner own) const { + QString name; #if !defined(QT_NO_LIBRARY) Q_D(const QFSFileEngine); + if ((qt_ntfs_permission_lookup > 0) && ((QSysInfo::WindowsVersion&QSysInfo::WV_NT_based) > QSysInfo::WV_NT)) { - QString name; QFSFileEnginePrivate::resolveLibs(); if (ptrGetNamedSecurityInfoW && ptrLookupAccountSidW) { PSID pOwner = 0; PSECURITY_DESCRIPTOR pSD; if (ptrGetNamedSecurityInfoW((wchar_t*)d->filePath.utf16(), SE_FILE_OBJECT, - own == OwnerGroup ? GROUP_SECURITY_INFORMATION : OWNER_SECURITY_INFORMATION, - own == OwnerUser ? &pOwner : 0, own == OwnerGroup ? &pOwner : 0, - 0, 0, &pSD) == ERROR_SUCCESS) { + own == OwnerGroup ? GROUP_SECURITY_INFORMATION : OWNER_SECURITY_INFORMATION, + own == OwnerUser ? &pOwner : 0, own == OwnerGroup ? &pOwner : 0, + 0, 0, &pSD) == ERROR_SUCCESS) { DWORD lowner = 0, ldomain = 0; - SID_NAME_USE use; + SID_NAME_USE use = SidTypeUnknown; // First call, to determine size of the strings (with '\0'). ptrLookupAccountSidW(NULL, pOwner, NULL, &lowner, NULL, &ldomain, (SID_NAME_USE*)&use); wchar_t *owner = new wchar_t[lowner]; wchar_t *domain = new wchar_t[ldomain]; // Second call, size is without '\0' if (ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner, &lowner, - (LPWSTR)domain, &ldomain, (SID_NAME_USE*)&use)) { + (LPWSTR)domain, &ldomain, (SID_NAME_USE*)&use)) { name = QString::fromUtf16((ushort*)owner); } LocalFree(pSD); @@ -1746,12 +1747,11 @@ QString QFSFileEngine::owner(FileOwner own) const delete [] domain; } } - return name; } #else Q_UNUSED(own); #endif - return QString(); + return name; } bool QFSFileEngine::setPermissions(uint perms) -- cgit v0.12 From 751de8211033b40c66d88140137eef76e6b20cfa Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 7 Jan 2010 19:28:53 +0100 Subject: Avoid repeatedly calling LookupAccountSid in QFSFileEngine::owner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Try to retrieve user/group name in a single call to LookupAccountSid, by using pre-allocated buffers. Only call a second time if the buffer size is insufficient. 64 bytes should be enough in common case. Previously, we would always call LookupAccountSid twice, even if ERROR_NONE_MAPPED occured first time. Merge-request: 815 Reviewed-by: João Abecasis --- src/corelib/io/qfsfileengine_win.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index c3ea08a..bec0075 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1731,20 +1731,31 @@ QString QFSFileEngine::owner(FileOwner own) const own == OwnerGroup ? GROUP_SECURITY_INFORMATION : OWNER_SECURITY_INFORMATION, own == OwnerUser ? &pOwner : 0, own == OwnerGroup ? &pOwner : 0, 0, 0, &pSD) == ERROR_SUCCESS) { - DWORD lowner = 0, ldomain = 0; + DWORD lowner = 64; + DWORD ldomain = 64; + QVarLengthArray owner(lowner); + QVarLengthArray domain(ldomain); SID_NAME_USE use = SidTypeUnknown; // First call, to determine size of the strings (with '\0'). - ptrLookupAccountSidW(NULL, pOwner, NULL, &lowner, NULL, &ldomain, (SID_NAME_USE*)&use); - wchar_t *owner = new wchar_t[lowner]; - wchar_t *domain = new wchar_t[ldomain]; - // Second call, size is without '\0' - if (ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner, &lowner, - (LPWSTR)domain, &ldomain, (SID_NAME_USE*)&use)) { - name = QString::fromUtf16((ushort*)owner); + if (!ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner.data(), &lowner, + (LPWSTR)domain.data(), &ldomain, (SID_NAME_USE*)&use)) { + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { + if (lowner > (DWORD)owner.size()) + owner.resize(lowner); + if (ldomain > (DWORD)domain.size()) + domain.resize(ldomain); + // Second call, try on resized buf-s + if (!ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner.data(), &lowner, + (LPWSTR)domain.data(), &ldomain, (SID_NAME_USE*)&use)) { + lowner = 0; + } + } else { + lowner = 0; + } } + if (lowner != 0) + name = QString::fromWCharArray(owner.data()); LocalFree(pSD); - delete [] owner; - delete [] domain; } } } -- cgit v0.12 From dbbf451755d34be44f6b7ac2e7c03ffe5528fb1b Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Fri, 8 Jan 2010 09:27:09 +1000 Subject: QAudioInput loses data on Maemo5/other linux platforms. The alsa backend was calculating sample timer on resume using buffer_time instead of period_time. Task-number:QTBUG-7044 Reviewed-by:Justin McPherson --- src/multimedia/audio/qaudioinput_alsa_p.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 096b7ca..fc612fe 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -534,7 +534,7 @@ void QAudioInputPrivate::resume() resuming = true; deviceState = QAudio::ActiveState; int chunks = buffer_size/period_size; - timer->start(buffer_time*chunks/2000); + timer->start(period_time*chunks/2000); emit stateChanged(deviceState); } } -- cgit v0.12 From 73f7772da8271428ec80efed00c8881638149e46 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 7 Jan 2010 13:50:41 +0100 Subject: QNAM HTTP: fix the caching algorithm from RFC 2616 Reviewed-by: Peter Hartmann --- src/network/access/qnetworkaccesshttpbackend.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index dda799d..efd0a93 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -419,17 +419,21 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, int age_value = 0; it = cacheHeaders.findRawHeader("age"); if (it != cacheHeaders.rawHeaders.constEnd()) - age_value = QNetworkHeadersPrivate::fromHttpDate(it->second).toTime_t(); + age_value = it->second.toInt(); + QDateTime dateHeader; int date_value = 0; it = cacheHeaders.findRawHeader("date"); - if (it != cacheHeaders.rawHeaders.constEnd()) - date_value = QNetworkHeadersPrivate::fromHttpDate(it->second).toTime_t(); + if (it != cacheHeaders.rawHeaders.constEnd()) { + dateHeader = QNetworkHeadersPrivate::fromHttpDate(it->second); + date_value = dateHeader.toTime_t(); + } int now = currentDateTime.toUTC().toTime_t(); int request_time = now; int response_time = now; + // Algorithm from RFC 2616 section 13.2.3 int apparent_age = qMax(0, response_time - date_value); int corrected_received_age = qMax(apparent_age, age_value); int response_delay = response_time - request_time; @@ -453,7 +457,9 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, } } - int freshness_lifetime = currentDateTime.secsTo(expirationDate); + // the cache-saving code below sets the expirationDate with date+max_age + // if "max-age" is present, or to Expires otherwise + int freshness_lifetime = dateHeader.secsTo(expirationDate); bool response_is_fresh = (freshness_lifetime > current_age); if (!response_is_fresh && CacheLoadControlAttribute == QNetworkRequest::PreferNetwork) -- cgit v0.12 From e49aee9f7f82a004f41dc83ac1139e1897fa90ee Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 7 Jan 2010 13:51:48 +0100 Subject: QNAM HTTP: change the caching semantics to match documentation PreferCache should not use the network even if must-revalidate is set. But if it is not fresh enough, then it should use the network. Reviewed-by: Peter Hartmann --- src/network/access/qnetworkaccesshttpbackend.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index efd0a93..c2a4079 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -385,6 +385,15 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, QNetworkHeadersPrivate::RawHeadersList::ConstIterator it; cacheHeaders.setAllRawHeaders(metaData.rawHeaders()); + if (CacheLoadControlAttribute == QNetworkRequest::PreferNetwork) { + it = cacheHeaders.findRawHeader("Cache-Control"); + if (it != cacheHeaders.rawHeaders.constEnd()) { + QHash cacheControl = parseHttpOptionHeader(it->second); + if (cacheControl.contains("must-revalidate")) + return; + } + } + it = cacheHeaders.findRawHeader("etag"); if (it != cacheHeaders.rawHeaders.constEnd()) httpRequest.setHeaderField("If-None-Match", it->second); @@ -393,12 +402,6 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, if (lastModified.isValid()) httpRequest.setHeaderField("If-Modified-Since", QNetworkHeadersPrivate::toHttpDate(lastModified)); - it = cacheHeaders.findRawHeader("Cache-Control"); - if (it != cacheHeaders.rawHeaders.constEnd()) { - QHash cacheControl = parseHttpOptionHeader(it->second); - if (cacheControl.contains("must-revalidate")) - return; - } /* * age_value @@ -462,7 +465,7 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, int freshness_lifetime = dateHeader.secsTo(expirationDate); bool response_is_fresh = (freshness_lifetime > current_age); - if (!response_is_fresh && CacheLoadControlAttribute == QNetworkRequest::PreferNetwork) + if (!response_is_fresh) return; loadedFromCache = true; -- cgit v0.12 From 2f10f91596b12b5b0c7d57b4575ea4e3b232ee0a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 7 Jan 2010 13:54:28 +0100 Subject: QNAM HTTP: just use the expirationDate in the code that validates the cache The max-age handling is already done in the cache-saving code. Reviewed-by: Peter Hartmann --- src/network/access/qnetworkaccesshttpbackend.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index c2a4079..12b10f9 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -402,7 +402,10 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, if (lastModified.isValid()) httpRequest.setHeaderField("If-Modified-Since", QNetworkHeadersPrivate::toHttpDate(lastModified)); + QDateTime currentDateTime = QDateTime::currentDateTime(); + QDateTime expirationDate = metaData.expirationDate(); +#if 0 /* * age_value * is the value of Age: header received by the cache with @@ -418,7 +421,6 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, * now * is the current (local) time */ - QDateTime currentDateTime = QDateTime::currentDateTime(); int age_value = 0; it = cacheHeaders.findRawHeader("age"); if (it != cacheHeaders.rawHeaders.constEnd()) @@ -445,7 +447,6 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, int current_age = corrected_initial_age + resident_time; // RFC 2616 13.2.4 Expiration Calculations - QDateTime expirationDate = metaData.expirationDate(); if (!expirationDate.isValid()) { if (lastModified.isValid()) { int diff = currentDateTime.secsTo(lastModified); @@ -464,6 +465,9 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest, // if "max-age" is present, or to Expires otherwise int freshness_lifetime = dateHeader.secsTo(expirationDate); bool response_is_fresh = (freshness_lifetime > current_age); +#else + bool response_is_fresh = currentDateTime.secsTo(expirationDate) >= 0; +#endif if (!response_is_fresh) return; -- cgit v0.12 From 7e5861de8019b7d383e2b2ad8cc3c46f1c3ef0bd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 7 Jan 2010 13:55:19 +0100 Subject: Autotest: add a test for QNAM's HTTP cache handling code --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 203 ++++++++++++++++++++++++- 1 file changed, 202 insertions(+), 1 deletion(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 20cf922..33753f1 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -198,6 +199,8 @@ private Q_SLOTS: #endif void ioGetFromHttpBrokenServer_data(); void ioGetFromHttpBrokenServer(); + void ioGetFromHttpWithCache_data(); + void ioGetFromHttpWithCache(); void ioGetWithManyProxies_data(); void ioGetWithManyProxies(); @@ -318,8 +321,9 @@ public: QByteArray dataToTransmit; QByteArray receivedData; bool doClose; + int totalConnections; - MiniHttpServer(const QByteArray &data) : client(0), dataToTransmit(data), doClose(true) + MiniHttpServer(const QByteArray &data) : client(0), dataToTransmit(data), doClose(true), totalConnections(0) { listen(); connect(this, SIGNAL(newConnection()), this, SLOT(doAccept())); @@ -329,6 +333,7 @@ public slots: void doAccept() { client = nextPendingConnection(); + ++totalConnections; connect(client, SIGNAL(readyRead()), this, SLOT(sendData())); } @@ -379,6 +384,61 @@ public: } }; +class MyMemoryCache: public QAbstractNetworkCache +{ +public: + typedef QPair CachedContent; + typedef QHash CacheData; + CacheData cache; + + MyMemoryCache(QObject *parent) : QAbstractNetworkCache(parent) {} + + QNetworkCacheMetaData metaData(const QUrl &url) + { + return cache.value(url.toEncoded()).first; + } + + void updateMetaData(const QNetworkCacheMetaData &metaData) + { + cache[metaData.url().toEncoded()].first = metaData; + } + + QIODevice *data(const QUrl &url) + { + CacheData::ConstIterator it = cache.find(url.toEncoded()); + if (it == cache.constEnd()) + return 0; + QBuffer *io = new QBuffer(this); + io->setData(it->second); + io->open(QIODevice::ReadOnly); + io->seek(0); + return io; + } + + bool remove(const QUrl &url) + { + cache.remove(url.toEncoded()); + return true; + } + + qint64 cacheSize() const + { + qint64 total = 0; + foreach (const CachedContent &entry, cache) + total += entry.second.size(); + return total; + } + + QIODevice *prepare(const QNetworkCacheMetaData &) + { Q_ASSERT(0 && "Should not have tried to add to the cache"); return 0; } + void insert(QIODevice *) + { Q_ASSERT(0 && "Should not have tried to add to the cache"); } + + void clear() { cache.clear(); } +}; +Q_DECLARE_METATYPE(MyMemoryCache::CachedContent) +Q_DECLARE_METATYPE(MyMemoryCache::CacheData) + class DataReader: public QObject { Q_OBJECT @@ -762,6 +822,7 @@ void tst_QNetworkReply::cleanup() // clear the internal cache QNetworkAccessManagerPrivate::clearCache(&manager); manager.setProxy(QNetworkProxy()); + manager.setCache(0); // clear cookies cookieJar->setAllCookies(QList()); @@ -1984,6 +2045,146 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer() QVERIFY(reply->error() != QNetworkReply::NoError); } +void tst_QNetworkReply::ioGetFromHttpWithCache_data() +{ + qRegisterMetaType(); + QTest::addColumn("dataToSend"); + QTest::addColumn("body"); + QTest::addColumn("cachedReply"); + QTest::addColumn("cacheMode"); + QTest::addColumn("loadedFromCache"); + QTest::addColumn("networkUsed"); + + QByteArray reply200 = + "HTTP/1.0 200\r\n" + "Connection: keep-alive\r\n" + "Content-Type: text/plain\r\n" + "Cache-control: no-cache\r\n" + "Content-length: 8\r\n" + "\r\n" + "Reloaded"; + QByteArray reply304 = + "HTTP/1.0 304 Use Cache\r\n" + "Connection: keep-alive\r\n" + "\r\n"; + + QTest::newRow("not-cached,always-network") + << reply200 << "Reloaded" << MyMemoryCache::CachedContent() << int(QNetworkRequest::AlwaysNetwork) << false << true; + QTest::newRow("not-cached,prefer-network") + << reply200 << "Reloaded" << MyMemoryCache::CachedContent() << int(QNetworkRequest::PreferNetwork) << false << true; + QTest::newRow("not-cached,prefer-cache") + << reply200 << "Reloaded" << MyMemoryCache::CachedContent() << int(QNetworkRequest::PreferCache) << false << true; + + QDateTime present = QDateTime::currentDateTime().toUTC(); + QDateTime past = present.addSecs(-3600); + QDateTime future = present.addSecs(3600); + static const char dateFormat[] = "ddd, dd MMM yyyy hh:mm:ss 'GMT'"; + + QNetworkCacheMetaData::RawHeaderList rawHeaders; + MyMemoryCache::CachedContent content; + content.second = "Not-reloaded"; + content.first.setLastModified(past); + + // + // Set to expired + // + rawHeaders.clear(); + rawHeaders << QNetworkCacheMetaData::RawHeader("Date", QLocale::c().toString(past, dateFormat).toLatin1()) + << QNetworkCacheMetaData::RawHeader("Cache-control", "max-age=0"); // isn't used in cache loading + content.first.setRawHeaders(rawHeaders); + content.first.setLastModified(past); + + QTest::newRow("expired,200,prefer-network") + << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << false << true; + QTest::newRow("expired,200,prefer-cache") + << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferCache) << false << true; + + QTest::newRow("expired,304,prefer-network") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << true << true; + QTest::newRow("expired,304,prefer-cache") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << true; + + // + // Set to not-expired + // + rawHeaders.clear(); + rawHeaders << QNetworkCacheMetaData::RawHeader("Date", QLocale::c().toString(past, dateFormat).toLatin1()) + << QNetworkCacheMetaData::RawHeader("Cache-control", "max-age=7200"); // isn't used in cache loading + content.first.setRawHeaders(rawHeaders); + content.first.setExpirationDate(future); + + QTest::newRow("not-expired,200,always-network") + << reply200 << "Reloaded" << content << int(QNetworkRequest::AlwaysNetwork) << false << true; + QTest::newRow("not-expired,200,prefer-network") + << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << true << false; + QTest::newRow("not-expired,200,prefer-cache") + << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << false; + QTest::newRow("not-expired,200,always-cache") + << reply200 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << true << false; + + QTest::newRow("not-expired,304,prefer-network") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << true << false; + QTest::newRow("not-expired,304,prefer-cache") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << false; + QTest::newRow("not-expired,304,always-cache") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << true << false; + + // + // Set must-revalidate now + // + rawHeaders.clear(); + rawHeaders << QNetworkCacheMetaData::RawHeader("Date", QLocale::c().toString(past, dateFormat).toLatin1()) + << QNetworkCacheMetaData::RawHeader("Cache-control", "max-age=7200, must-revalidate"); // must-revalidate is used + content.first.setRawHeaders(rawHeaders); + + QTest::newRow("must-revalidate,200,always-network") + << reply200 << "Reloaded" << content << int(QNetworkRequest::AlwaysNetwork) << false << true; + QTest::newRow("must-revalidate,200,prefer-network") + << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << false << true; + QTest::newRow("must-revalidate,200,prefer-cache") + << reply200 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << false; + QTest::newRow("must-revalidate,200,always-cache") + << reply200 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << true << false; + + QTest::newRow("must-revalidate,304,prefer-network") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << true << true; + QTest::newRow("must-revalidate,304,prefer-cache") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << true << false; + QTest::newRow("must-revalidate,304,always-cache") + << reply304 << "Not-reloaded" << content << int(QNetworkRequest::AlwaysCache) << true << false; +} + +void tst_QNetworkReply::ioGetFromHttpWithCache() +{ + QFETCH(QByteArray, dataToSend); + MiniHttpServer server(dataToSend); + server.doClose = false; + + MyMemoryCache *memoryCache = new MyMemoryCache(&manager); + manager.setCache(memoryCache); + + QFETCH(MyMemoryCache::CachedContent, cachedReply); + QUrl url = "http://localhost:" + QString::number(server.serverPort()); + cachedReply.first.setUrl(url); + if (!cachedReply.second.isNull()) + memoryCache->cache.insert(url.toEncoded(), cachedReply); + + QFETCH(int, cacheMode); + QNetworkRequest request(url); + request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, cacheMode); + request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false); + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QTEST(reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool(), "loadedFromCache"); + QTEST(server.totalConnections > 0, "networkUsed"); + QFETCH(QString, body); + QCOMPARE(reply->readAll().constData(), qPrintable(body)); +} + void tst_QNetworkReply::ioGetWithManyProxies_data() { QTest::addColumn >("proxyList"); -- cgit v0.12 From 73629458a18ce577e0a46e61335ef92d18dac7be Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Fri, 8 Jan 2010 11:44:59 +0100 Subject: Fixes: MenuItem size fixes and missing separator with Gtk+ Task: QTBUG-6522 RevBy: thorbjorn Details: This fixes missing separator line in the Dust theme. The patch also significantly improves the accuracy of menu item size metrics by making use of gtk_widget_size_request to query things like default heights. - More accurate offset and size of separators - Fixed item height of menu items using size_request - Fixed vertical offset of label and check boxes - Fixed clipping issue on last menu item --- src/gui/styles/qgtkstyle.cpp | 51 ++++++++++++++++++++---------------------- src/gui/styles/qgtkstyle_p.cpp | 7 +++++- src/gui/styles/qgtkstyle_p.h | 3 +++ 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 41efaa3..920a0f7 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -2495,7 +2495,6 @@ void QGtkStyle::drawControl(ControlElement element, const int windowsItemHMargin = 3; // menu item hor text margin const int windowsItemVMargin = 26; // menu item ver text margin const int windowsRightBorder = 15; // right border on windows - GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu")); GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")) : d->gtkWidget(QLS("GtkMenu.GtkMenuItem")); @@ -2509,6 +2508,7 @@ void QGtkStyle::drawControl(ControlElement element, gboolean wide_separators = 0; gint separator_height = 0; guint horizontal_padding = 3; + QRect separatorRect = option->rect; if (!d->gtk_check_version(2, 10, 0)) { d->gtk_widget_style_get(gtkMenuSeparator, "wide-separators", &wide_separators, @@ -2516,13 +2516,16 @@ void QGtkStyle::drawControl(ControlElement element, "horizontal-padding", &horizontal_padding, NULL); } + separatorRect.setHeight(option->rect.height() - 2 * gtkMenuSeparator->style->ythickness); + separatorRect.setWidth(option->rect.width() - 2 * (horizontal_padding + gtkMenuSeparator->style->xthickness)); + separatorRect.moveCenter(option->rect.center()); if (wide_separators) - gtkPainter.paintBox( gtkMenuSeparator, "hseparator", - option->rect.adjusted(0, 0, 0, -1), GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenu->style); + gtkPainter.paintBox( gtkMenuSeparator, "hseparator", + separatorRect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenuSeparator->style); else gtkPainter.paintHline( gtkMenuSeparator, "hseparator", - menuItem->rect, GTK_STATE_NORMAL, gtkMenu->style, - option->rect.left() + horizontal_padding, option->rect.width() - 2*horizontal_padding, 2); + separatorRect, GTK_STATE_NORMAL, gtkMenuSeparator->style, + 0, option->rect.right() - 1, 1); painter->restore(); break; } @@ -2530,7 +2533,7 @@ void QGtkStyle::drawControl(ControlElement element, bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled; if (selected) { - QRect rect = option->rect.adjusted(0, 0, 0, -1); + QRect rect = option->rect; #ifndef QT_NO_COMBOBOX if (qobject_cast(widget)) rect = option->rect; @@ -2556,7 +2559,7 @@ void QGtkStyle::drawControl(ControlElement element, #endif if (!ignoreCheckMark) { // Check - QRect checkRect(option->rect.left() + 7, option->rect.center().y() - checkSize/2, checkSize, checkSize); + QRect checkRect(option->rect.left() + 7, option->rect.center().y() - checkSize/2 + 1, checkSize, checkSize); checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect); if (checkable && menuItem->icon.isNull()) { @@ -2680,7 +2683,7 @@ void QGtkStyle::drawControl(ControlElement element, int tab = menuitem->tabWidth; int xm = windowsItemFrame + checkcol + windowsItemHMargin; int xpos = menuitem->rect.x() + xm + 1; - QRect textRect(xpos, y + windowsItemVMargin - 1, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); + QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin); QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect); QString s = menuitem->text; @@ -3150,44 +3153,38 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, newSize += QSize(6, 0); } break; - case CT_MenuItem: if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { int textMargin = 8; if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); - gboolean wide_separators; - gint separator_height; - d->gtk_widget_style_get(gtkMenuSeparator, - "wide-separators", &wide_separators, - "separator-height", &separator_height, - NULL); - newSize = QSize(size.width(), wide_separators ? separator_height - 1 : 7 ); - + GtkRequisition sizeReq = {0, 0}; + d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq); + newSize = QSize(size.width(), sizeReq.height); break; } - GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkMenuItem")); + GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")); GtkStyle* style = gtkMenuItem->style; - newSize += QSize(textMargin + style->xthickness - 1, style->ythickness - 3); + + // Note we get the perfect height for the default font since we + // set a fake text label on the gtkMenuItem + // But if custom fonts are used on the widget we need a minimum size + GtkRequisition sizeReq = {0, 0}; + d->gtk_widget_size_request(gtkMenuItem, &sizeReq); + newSize.setHeight(qMax(newSize.height() - 4, sizeReq.height)); + newSize += QSize(textMargin + style->xthickness - 1, 0); // Cleanlooks assumes a check column of 20 pixels so we need to // expand it a bit gint checkSize; - d->gtk_widget_style_get(d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL); - newSize.setHeight(qMax(newSize.height(), checkSize + 2)); + d->gtk_widget_style_get(gtkMenuItem, "indicator-size", &checkSize, NULL); newSize.setWidth(newSize.width() + qMax(0, checkSize - 20)); } break; - case CT_Menu: - // This is evil, but QMenu adds 1 pixel too much - newSize -= QSize(0, 1); - - break; - case CT_SpinBox: // QSpinBox does some nasty things that depends on CT_LineEdit newSize = size + QSize(0, -d->gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2); diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp index 5060be2..a033407 100644 --- a/src/gui/styles/qgtkstyle_p.cpp +++ b/src/gui/styles/qgtkstyle_p.cpp @@ -151,6 +151,7 @@ Ptr_gtk_menu_item_set_submenu QGtkStylePrivate::gtk_menu_item_set_submenu = 0; Ptr_gtk_settings_get_default QGtkStylePrivate::gtk_settings_get_default = 0; Ptr_gtk_separator_menu_item_new QGtkStylePrivate::gtk_separator_menu_item_new = 0; Ptr_gtk_widget_size_allocate QGtkStylePrivate::gtk_widget_size_allocate = 0; +Ptr_gtk_widget_size_request QGtkStylePrivate::gtk_widget_size_request = 0; Ptr_gtk_widget_set_direction QGtkStylePrivate::gtk_widget_set_direction = 0; Ptr_gtk_widget_path QGtkStylePrivate::gtk_widget_path = 0; Ptr_gtk_container_get_type QGtkStylePrivate::gtk_container_get_type = 0; @@ -159,7 +160,6 @@ Ptr_gtk_widget_get_type QGtkStylePrivate::gtk_widget_get_type = 0; Ptr_gtk_rc_get_style_by_paths QGtkStylePrivate::gtk_rc_get_style_by_paths = 0; Ptr_gtk_check_version QGtkStylePrivate::gtk_check_version = 0; Ptr_gtk_border_free QGtkStylePrivate::gtk_border_free = 0; - Ptr_pango_font_description_get_size QGtkStylePrivate::pango_font_description_get_size = 0; Ptr_pango_font_description_get_weight QGtkStylePrivate::pango_font_description_get_weight = 0; Ptr_pango_font_description_get_family QGtkStylePrivate::pango_font_description_get_family = 0; @@ -410,11 +410,13 @@ void QGtkStylePrivate::resolveGtk() const gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_new"); gtk_container_forall = (Ptr_gtk_container_forall)libgtk.resolve("gtk_container_forall"); gtk_widget_size_allocate =(Ptr_gtk_widget_size_allocate)libgtk.resolve("gtk_widget_size_allocate"); + gtk_widget_size_request =(Ptr_gtk_widget_size_request)libgtk.resolve("gtk_widget_size_request"); gtk_widget_set_direction =(Ptr_gtk_widget_set_direction)libgtk.resolve("gtk_widget_set_direction"); gtk_widget_path =(Ptr_gtk_widget_path)libgtk.resolve("gtk_widget_path"); gtk_container_get_type =(Ptr_gtk_container_get_type)libgtk.resolve("gtk_container_get_type"); gtk_window_get_type =(Ptr_gtk_window_get_type)libgtk.resolve("gtk_window_get_type"); gtk_widget_get_type =(Ptr_gtk_widget_get_type)libgtk.resolve("gtk_widget_get_type"); + gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths"); gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version"); gtk_border_free =(Ptr_gtk_border_free)libgtk.resolve("gtk_border_free"); @@ -447,10 +449,13 @@ void QGtkStylePrivate::initGtkMenu() const gtk_widget_realize(gtkMenu); GtkWidget *gtkMenuItem = QGtkStylePrivate::gtk_menu_item_new(); + g_object_set(gtkMenuItem, "label", "X", NULL); + gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuItem); gtk_widget_realize(gtkMenuItem); GtkWidget *gtkCheckMenuItem = QGtkStylePrivate::gtk_check_menu_item_new(); + g_object_set(gtkCheckMenuItem, "label", "X", NULL); gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkCheckMenuItem); gtk_widget_realize(gtkCheckMenuItem); diff --git a/src/gui/styles/qgtkstyle_p.h b/src/gui/styles/qgtkstyle_p.h index ad672db..db5b9b9 100644 --- a/src/gui/styles/qgtkstyle_p.h +++ b/src/gui/styles/qgtkstyle_p.h @@ -147,8 +147,10 @@ typedef void (*Ptr_gtk_paint_vline) (GtkStyle *, GdkWindow *, GtkStateType, co typedef void (*Ptr_gtk_menu_item_set_submenu) (GtkMenuItem *, GtkWidget *); typedef void (*Ptr_gtk_container_forall) (GtkContainer *, GtkCallback, gpointer); typedef void (*Ptr_gtk_widget_size_allocate) (GtkWidget *, GtkAllocation*); +typedef void (*Ptr_gtk_widget_size_request) (GtkWidget *widget, GtkRequisition *requisition); typedef void (*Ptr_gtk_widget_set_direction) (GtkWidget *, GtkTextDirection); typedef void (*Ptr_gtk_widget_path) (GtkWidget *, guint *, gchar **, gchar**); + typedef void (*Ptr_gtk_toolbar_insert) (GtkToolbar *toolbar, GtkToolItem *item, int pos); typedef void (*Ptr_gtk_menu_shell_append)(GtkMenuShell *, GtkWidget *); typedef GtkType (*Ptr_gtk_container_get_type) (void); @@ -365,6 +367,7 @@ public: static Ptr_gtk_settings_get_default gtk_settings_get_default; static Ptr_gtk_separator_menu_item_new gtk_separator_menu_item_new; static Ptr_gtk_widget_size_allocate gtk_widget_size_allocate; + static Ptr_gtk_widget_size_request gtk_widget_size_request; static Ptr_gtk_widget_set_direction gtk_widget_set_direction; static Ptr_gtk_widget_path gtk_widget_path; static Ptr_gtk_container_get_type gtk_container_get_type; -- cgit v0.12 From f90472009c928b3f599c182dfbab91390fdafdd9 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Fri, 8 Jan 2010 12:03:48 +0100 Subject: Fixes: Setting any style sheet breaks checkbox positioning Task: QTBUG-7198 RevBy: ogoffart Details: It was impossible to override the checkbox positioning in a custom style if any style sheet was set on the application of widget. This was because the style sheet never passed control to the base style. We now fix it by checking if the style sheet has the appropriate style rules. --- src/gui/styles/qstylesheetstyle.cpp | 12 +++++++----- tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index cf27eac..498313b 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -5611,9 +5611,6 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c case SE_ItemViewItemFocusRect: if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast(opt)) { QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem); - QStyleOptionViewItemV4 optCopy(*vopt); - optCopy.rect = subRule.contentsRect(vopt->rect); - QRect rect = ParentStyle::subElementRect(se, &optCopy, w); PseudoElement pe = PseudoElement_None; if (se == SE_ItemViewItemText || se == SE_ItemViewItemFocusRect) pe = PseudoElement_ViewItemText; @@ -5623,8 +5620,13 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c pe = PseudoElement_ViewItemIndicator; else break; - QRenderRule subRule2 = renderRule(w, opt, pe); - return positionRect(w, subRule2, pe, rect, opt->direction); + if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || hasStyleRule(w, pe)) { + QRenderRule subRule2 = renderRule(w, opt, pe); + QStyleOptionViewItemV4 optCopy(*vopt); + optCopy.rect = subRule.contentsRect(vopt->rect); + QRect rect = ParentStyle::subElementRect(se, &optCopy, w); + return positionRect(w, subRule2, pe, rect, opt->direction); + } } break; #endif // QT_NO_ITEMVIEWS diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index 1b2f268..e0512a9 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -1114,7 +1114,10 @@ class ProxyStyle : public QStyle const QStyleOption* opt, const QWidget* w) const { - return style->subElementRect(se, opt, w); + Q_UNUSED(se); + Q_UNUSED(opt); + Q_UNUSED(w); + return QRect(0, 0, 3, 3); } void drawComplexControl(QStyle::ComplexControl cc, @@ -1232,7 +1235,7 @@ void tst_QStyleSheetStyle::proxyStyle() pb4->setStyleSheet(styleSheet); // We are creating our Proxy based on current style... - // In this case it would be the QStyleSheetStyle that is delete + // In this case it would be the QStyleSheetStyle that is deleted // later on. We need to get access to the "real" QStyle to be able to // draw correctly. ProxyStyle* newProxy = new ProxyStyle(qApp->style()); @@ -1248,6 +1251,13 @@ void tst_QStyleSheetStyle::proxyStyle() w->show(); QTest::qWait(100); + + // Test for QTBUG-7198 - style sheet overrides custom element size + QStyleOptionViewItemV4 opt; + opt.initFrom(w); + opt.features |= QStyleOptionViewItemV2::HasCheckIndicator; + QVERIFY(pb5->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, + &opt, pb5).width() == 3); delete w; delete proxy; delete newProxy; -- cgit v0.12 From a54b606aef73f49dac451a35b29456bc1584a47e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 8 Jan 2010 12:31:03 +0100 Subject: Fix broken QGLWidget::renderPixmap on Mac/Carbon Task: ed2a03b3bc85be056eca87928d18a746faa07bca Reviewed-by: Trond Commit ed2a03b3bc85be056eca87928d18a746faa07bca removed all QuickDraw code and made QPixmap::macQDHandle() return 0 in all cases. Unfortunately QGLWidget::renderPixmap() depended on macQDHandle returning a valid handle, causing it to break. Fix this by inserting the macQDHandle implementation were we would call macQDHandle before. This is the only place in Qt where macQDHandle is used. --- src/opengl/qgl_mac.mm | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm index ef2fa6c..6ed07e5 100644 --- a/src/opengl/qgl_mac.mm +++ b/src/opengl/qgl_mac.mm @@ -606,10 +606,22 @@ void QGLContext::updatePaintDevice() } } } else if (d->paintDevice->devType() == QInternal::Pixmap) { - QPixmap *pm = (QPixmap *)d->paintDevice; - PixMapHandle mac_pm = GetGWorldPixMap((GWorldPtr)pm->macQDHandle()); - aglSetOffScreen((AGLContext)d->cx, pm->width(), pm->height(), - GetPixRowBytes(mac_pm), GetPixBaseAddr(mac_pm)); + QPixmap *pm = reinterpret_cast(d->paintDevice); + + unsigned long qdformat = k32ARGBPixelFormat; + if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) + qdformat = k32BGRAPixelFormat; + Rect rect; + SetRect(&rect, 0, 0, pm->width(), pm->height()); + + GWorldPtr gworld; + NewGWorldFromPtr(&gworld, qdformat, &rect, 0, 0, 0, + reinterpret_cast(qt_mac_pixmap_get_base(pm)), + qt_mac_pixmap_get_bytes_per_line(pm)); + + PixMapHandle pixmapHandle = GetGWorldPixMap(gworld); + aglSetOffScreen(reinterpret_cast(d->cx), pm->width(), pm->height(), + GetPixRowBytes(pixmapHandle), GetPixBaseAddr(pixmapHandle)); } else { qWarning("QGLContext::updatePaintDevice(): Not sure how to render OpenGL on this device!"); } -- cgit v0.12 From 4ba439f78aec1caef268dba0f229b8a0242e4c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 8 Jan 2010 12:33:52 +0100 Subject: Cocoa: Fix painting errors on QGLWidget resizing. Revby: Trond We need to update the GL context syncronously during the resize to prevent flicker. Use the existing MacGLWindowChange machinery to do that. --- src/gui/kernel/qcocoaview_mac.mm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 9950697..c14798a 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -508,6 +508,13 @@ extern "C" { } else { [self setNeedsDisplay:YES]; } + + // Make sure the opengl context is updated on resize. + if (0 && qwidgetprivate->isGLWidget) { + qwidgetprivate->needWindowChange = true; + QEvent event(QEvent::MacGLWindowChange); + qApp->sendEvent(qwidget, &event); + } } - (void)drawRect:(NSRect)aRect -- cgit v0.12