summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2010-10-05 00:10:31 (GMT)
committerRohan McGovern <rohan.mcgovern@nokia.com>2010-10-05 00:10:31 (GMT)
commit7f94e6a6f48176a5b5cfd61c796a4fa2bcc63afb (patch)
treeb4741e78769d8af5eb97e0ce7337bb89db9e0ef1
parent68778d0d5c0eb9d85ac09e424bfabdd6ccce3b83 (diff)
parenta7bf1cfb1a75c35e837c01f4a5b0697fc8961148 (diff)
downloadQt-7f94e6a6f48176a5b5cfd61c796a4fa2bcc63afb.zip
Qt-7f94e6a6f48176a5b5cfd61c796a4fa2bcc63afb.tar.gz
Qt-7f94e6a6f48176a5b5cfd61c796a4fa2bcc63afb.tar.bz2
Merge remote branch 'origin/4.7' into master-from-4.7
-rw-r--r--src/corelib/plugin/qsystemlibrary.cpp5
-rw-r--r--src/corelib/plugin/qsystemlibrary_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp2
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp4
-rw-r--r--src/gui/painting/qpdf.cpp18
-rw-r--r--src/gui/painting/qpdf_p.h2
-rw-r--r--src/gui/text/qfontengine.cpp24
-rw-r--r--src/gui/text/qfontengine_ft.cpp6
-rw-r--r--src/gui/text/qfontengine_mac.mm3
-rw-r--r--src/gui/text/qfontengine_p.h2
-rw-r--r--src/gui/text/qfontengine_win.cpp5
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp23
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp8
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp11
-rw-r--r--src/multimedia/audio/qaudioinput_alsa_p.cpp24
-rw-r--r--src/multimedia/audio/qaudioinput_mac_p.cpp2
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp46
-rw-r--r--src/multimedia/audio/qaudiooutput_alsa_p.cpp23
-rw-r--r--src/multimedia/audio/qaudiooutput_mac_p.cpp6
-rw-r--r--src/multimedia/audio/qaudiooutput_mac_p.h2
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp36
-rw-r--r--src/svg/qsvghandler.cpp33
-rw-r--r--tests/auto/qaudioinput/tst_qaudioinput.cpp47
-rw-r--r--tests/auto/qaudiooutput/tst_qaudiooutput.cpp47
-rw-r--r--tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-ellipse.pngbin0 -> 1819 bytes
-rw-r--r--tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-rect.pngbin0 -> 1255 bytes
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp65
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp35
29 files changed, 381 insertions, 110 deletions
diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp
index eeb142b..1b8d8fe 100644
--- a/src/corelib/plugin/qsystemlibrary.cpp
+++ b/src/corelib/plugin/qsystemlibrary.cpp
@@ -77,6 +77,9 @@
in the documentation for LoadLibrary for Windows CE at MSDN.
(http://msdn.microsoft.com/en-us/library/ms886736.aspx)
*/
+
+QT_BEGIN_NAMESPACE
+
#if defined(Q_OS_WINCE)
HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirectory /* = true */)
{
@@ -134,3 +137,5 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect
}
#endif //Q_OS_WINCE
+
+QT_END_NAMESPACE
diff --git a/src/corelib/plugin/qsystemlibrary_p.h b/src/corelib/plugin/qsystemlibrary_p.h
index 3251a3c..8000a61 100644
--- a/src/corelib/plugin/qsystemlibrary_p.h
+++ b/src/corelib/plugin/qsystemlibrary_p.h
@@ -47,6 +47,8 @@
#include <qt_windows.h>
#include <QtCore/qstring.h>
+QT_BEGIN_NAMESPACE
+
class QSystemLibrary
{
public:
@@ -101,6 +103,8 @@ private:
bool m_didLoad;
};
+QT_END_NAMESPACE
+
#endif //Q_OS_WIN
#endif //QSYSTEMLIBRARY_P_H
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index ed163d7..810055f 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -6655,6 +6655,11 @@ bool QGraphicsItem::sceneEvent(QEvent *event)
return true;
}
+ if (event->type() == QEvent::FocusOut) {
+ focusOutEvent(static_cast<QFocusEvent *>(event));
+ return true;
+ }
+
if (!d_ptr->visible) {
// Eaten
return true;
@@ -6664,9 +6669,6 @@ bool QGraphicsItem::sceneEvent(QEvent *event)
case QEvent::FocusIn:
focusInEvent(static_cast<QFocusEvent *>(event));
break;
- case QEvent::FocusOut:
- focusOutEvent(static_cast<QFocusEvent *>(event));
- break;
case QEvent::GraphicsSceneContextMenu:
contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event));
break;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index cba26ef..733d282 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -1759,7 +1759,7 @@ void QGraphicsScene::render(QPainter *painter, const QRectF &target, const QRect
painter->save();
// Transform the painter.
- painter->setClipRect(targetRect);
+ painter->setClipRect(targetRect, Qt::IntersectClip);
QTransform painterTransform;
painterTransform *= QTransform()
.translate(targetRect.left(), targetRect.top())
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index cc9bfdf..dbf7b26 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -4221,6 +4221,8 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline,
break;
}
+ rendered_spans += q_gray_rendered_spans(*grayRaster.data());
+
#if defined(Q_WS_WIN64)
_aligned_free(rasterPoolBase);
#else
@@ -4239,8 +4241,6 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline,
#endif
Q_CHECK_PTR(rasterPoolBase); // note: we just freed the old rasterPoolBase. I hope it's not fatal.
- rendered_spans += q_gray_rendered_spans(*grayRaster.data());
-
qt_ft_grays_raster.raster_done(*grayRaster.data());
qt_ft_grays_raster.raster_new(grayRaster.data());
qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize);
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index 6e02435..ba5d164 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -916,24 +916,6 @@ const char *QPdf::paperSizeToString(QPrinter::PaperSize paperSize)
}
-QByteArray QPdf::stripSpecialCharacters(const QByteArray &string)
-{
- QByteArray s = string;
- s.replace(' ', "");
- s.replace('(', "");
- s.replace(')', "");
- s.replace('<', "");
- s.replace('>', "");
- s.replace('[', "");
- s.replace(']', "");
- s.replace('{', "");
- s.replace('}', "");
- s.replace('/', "");
- s.replace('%', "");
- return s;
-}
-
-
// -------------------------- base engine, shared code between PS and PDF -----------------------
QPdfBaseEngine::QPdfBaseEngine(QPdfBaseEnginePrivate &dd, PaintEngineFeatures f)
diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h
index 9c4d05d..5c5ceb4 100644
--- a/src/gui/painting/qpdf_p.h
+++ b/src/gui/painting/qpdf_p.h
@@ -156,8 +156,6 @@ namespace QPdf {
PaperSize paperSize(QPrinter::PaperSize paperSize);
const char *paperSizeToString(QPrinter::PaperSize paperSize);
-
- QByteArray stripSpecialCharacters(const QByteArray &string);
}
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 70b7d65..be346e9 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -46,7 +46,6 @@
#include "qpainter.h"
#include "qpainterpath.h"
#include "qvarlengtharray.h"
-#include <private/qpdf_p.h>
#include <qmath.h>
#include <qendian.h>
#include <private/qharfbuzz_p.h>
@@ -681,11 +680,7 @@ void QFontEngine::removeGlyphFromCache(glyph_t)
QFontEngine::Properties QFontEngine::properties() const
{
Properties p;
-#ifndef QT_NO_PRINTER
- QByteArray psname = QPdf::stripSpecialCharacters(fontDef.family.toUtf8());
-#else
- QByteArray psname = fontDef.family.toUtf8();
-#endif
+ QByteArray psname = QFontEngine::convertToPostscriptFontFamilyName(fontDef.family.toUtf8());
psname += '-';
psname += QByteArray::number(fontDef.style);
psname += '-';
@@ -1097,6 +1092,23 @@ quint32 QFontEngine::getTrueTypeGlyphIndex(const uchar *cmap, uint unicode)
return 0;
}
+QByteArray QFontEngine::convertToPostscriptFontFamilyName(const QByteArray &family)
+{
+ QByteArray f = family;
+ f.replace(' ', "");
+ f.replace('(', "");
+ f.replace(')', "");
+ f.replace('<', "");
+ f.replace('>', "");
+ f.replace('[', "");
+ f.replace(']', "");
+ f.replace('{', "");
+ f.replace('}', "");
+ f.replace('/', "");
+ f.replace('%', "");
+ return f;
+}
+
Q_GLOBAL_STATIC_WITH_INITIALIZER(QVector<QRgb>, qt_grayPalette, {
x->resize(256);
QRgb *it = x->data();
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 5e86b37..512afc8 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -51,7 +51,6 @@
#include "qabstractfileengine.h"
#include "qthreadstorage.h"
#include <qmath.h>
-#include <private/qpdf_p.h>
#include <private/qharfbuzz_p.h>
#include "qfontengine_ft_p.h"
@@ -1205,10 +1204,7 @@ QFontEngine::Properties QFontEngineFT::properties() const
{
Properties p = freetype->properties();
if (p.postscriptName.isEmpty()) {
- p.postscriptName = fontDef.family.toUtf8();
-#ifndef QT_NO_PRINTER
- p.postscriptName = QPdf::stripSpecialCharacters(p.postscriptName);
-#endif
+ p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(fontDef.family.toUtf8());
}
return freetype->properties();
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 6e524f6..ebc1f6d 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -46,7 +46,6 @@
#include <qbitmap.h>
#include <private/qpaintengine_mac_p.h>
#include <private/qprintengine_mac_p.h>
-#include <private/qpdf_p.h>
#include <qglobal.h>
#include <qpixmap.h>
#include <qpixmapcache.h>
@@ -1876,7 +1875,7 @@ QFontEngine::Properties QFontEngineMac::properties() const
QCFString psName;
if (ATSFontGetPostScriptName(FMGetATSFontRefFromFont(fontID), kATSOptionFlagsDefault, &psName) == noErr)
props.postscriptName = QString(psName).toUtf8();
- props.postscriptName = QPdf::stripSpecialCharacters(props.postscriptName);
+ props.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(props.postscriptName);
return props;
}
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index b3a6c59..d07c8c9 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -232,6 +232,8 @@ public:
static const uchar *getCMap(const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize);
static quint32 getTrueTypeGlyphIndex(const uchar *cmap, uint unicode);
+ static QByteArray convertToPostscriptFontFamilyName(const QByteArray &fontFamily);
+
QAtomicInt ref;
QFontDef fontDef;
uint cache_cost; // amount of mem used in kb by the font
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index 3006776..a941dab 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -63,7 +63,6 @@
#include <qbitmap.h>
#include <private/qpainter_p.h>
-#include <private/qpdf_p.h>
#include "qpaintengine.h"
#include "qvarlengtharray.h"
#include <private/qpaintengine_raster_p.h>
@@ -1039,9 +1038,7 @@ QFontEngine::Properties QFontEngineWin::properties() const
p.italicAngle = otm->otmItalicAngle;
p.postscriptName = QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpFamilyName)).toLatin1();
p.postscriptName += QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpStyleName)).toLatin1();
-#ifndef QT_NO_PRINTER
- p.postscriptName = QPdf::stripSpecialCharacters(p.postscriptName);
-#endif
+ p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(p.postscriptName);
p.boundingBox = QRectF(otm->otmrcFontBox.left, -otm->otmrcFontBox.top,
otm->otmrcFontBox.right - otm->otmrcFontBox.left,
otm->otmrcFontBox.top - otm->otmrcFontBox.bottom);
diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
index 633b309..25622a4 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
@@ -257,37 +257,40 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
// set the values!
snd_pcm_hw_params_set_channels(handle,params,format.channels());
snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir);
+
+ err = -1;
+
switch(format.sampleSize()) {
case 8:
if(format.sampleType() == QAudioFormat::SignedInt)
- snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8);
+ err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8);
else if(format.sampleType() == QAudioFormat::UnSignedInt)
- snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8);
+ err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8);
break;
case 16:
if(format.sampleType() == QAudioFormat::SignedInt) {
if(format.byteOrder() == QAudioFormat::LittleEndian)
- snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE);
+ err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE);
else if(format.byteOrder() == QAudioFormat::BigEndian)
- snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE);
+ err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE);
} else if(format.sampleType() == QAudioFormat::UnSignedInt) {
if(format.byteOrder() == QAudioFormat::LittleEndian)
- snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE);
+ err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE);
else if(format.byteOrder() == QAudioFormat::BigEndian)
- snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE);
+ err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE);
}
break;
case 32:
if(format.sampleType() == QAudioFormat::SignedInt) {
if(format.byteOrder() == QAudioFormat::LittleEndian)
- snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE);
+ err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE);
else if(format.byteOrder() == QAudioFormat::BigEndian)
- snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE);
+ err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE);
} else if(format.sampleType() == QAudioFormat::UnSignedInt) {
if(format.byteOrder() == QAudioFormat::LittleEndian)
- snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE);
+ err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE);
else if(format.byteOrder() == QAudioFormat::BigEndian)
- snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE);
+ err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE);
}
}
diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp
index 19f3b3c..727f6a6 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp
@@ -78,7 +78,13 @@ QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray const& handle, QAu
bool QAudioDeviceInfoInternal::isFormatSupported(const QAudioFormat& format) const
{
- return format.codec() == QString::fromLatin1("audio/pcm");
+ QAudioDeviceInfoInternal *self = const_cast<QAudioDeviceInfoInternal*>(this);
+
+ return format.isValid()
+ && format.codec() == QString::fromLatin1("audio/pcm")
+ && self->frequencyList().contains(format.frequency())
+ && self->channelsList().contains(format.channels())
+ && self->sampleSizeList().contains(format.sampleSize());
}
QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const
diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
index 9e8b1bf..4ff6a21 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
@@ -196,8 +196,9 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
break;
}
}
+ if (!match)
+ failed = true;
}
- if (!match) failed = true;
// check frequency
match = false;
@@ -208,6 +209,8 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
break;
}
}
+ if (!match)
+ failed = true;
}
// check sample size
@@ -219,6 +222,8 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
break;
}
}
+ if (!match)
+ failed = true;
}
// check byte order
@@ -230,6 +235,8 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
break;
}
}
+ if (!match)
+ failed = true;
}
// check sample type
@@ -241,6 +248,8 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
break;
}
}
+ if (!match)
+ failed = true;
}
if(!failed) {
diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp
index 58669b3..ddafa3d 100644
--- a/src/multimedia/audio/qaudioinput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp
@@ -152,7 +152,7 @@ int QAudioInputPrivate::xrun_recovery(int err)
int QAudioInputPrivate::setFormat()
{
- snd_pcm_format_t format = SND_PCM_FORMAT_S16;
+ snd_pcm_format_t format = SND_PCM_FORMAT_UNKNOWN;
if(settings.sampleSize() == 8) {
format = SND_PCM_FORMAT_U8;
@@ -204,7 +204,9 @@ int QAudioInputPrivate::setFormat()
format = SND_PCM_FORMAT_FLOAT64_BE;
}
- return snd_pcm_hw_params_set_format( handle, hwparams, format);
+ return format != SND_PCM_FORMAT_UNKNOWN
+ ? snd_pcm_hw_params_set_format( handle, hwparams, format)
+ : -1;
}
QIODevice* QAudioInputPrivate::start(QIODevice* device)
@@ -259,10 +261,26 @@ bool QAudioInputPrivate::open()
elapsedTimeOffset = 0;
int dir;
- int err=-1;
+ int err = 0;
int count=0;
unsigned int freakuency=settings.frequency();
+ if (!settings.isValid()) {
+ qWarning("QAudioOutput: open error, invalid format.");
+ } else if (settings.frequency() <= 0) {
+ qWarning("QAudioOutput: open error, invalid sample rate (%d).",
+ settings.frequency());
+ } else {
+ err = -1;
+ }
+
+ if (err == 0) {
+ errorState = QAudio::OpenError;
+ deviceState = QAudio::StoppedState;
+ return false;
+ }
+
+
QString dev = QString(QLatin1String(m_device.constData()));
QList<QByteArray> devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioInput);
if(dev.compare(QLatin1String("default")) == 0) {
diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp
index 5897e75..c3d2ae2 100644
--- a/src/multimedia/audio/qaudioinput_mac_p.cpp
+++ b/src/multimedia/audio/qaudioinput_mac_p.cpp
@@ -717,7 +717,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
{
QIODevice* op = device;
- if (!audioFormat.isValid() || !open()) {
+ if (!audioDeviceInfo->isFormatSupported(audioFormat) || !open()) {
stateCode = QAudio::StoppedState;
errorCode = QAudio::OpenError;
return audioIO;
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index ece1c26..1cde159 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -214,18 +214,44 @@ bool QAudioInputPrivate::open()
qDebug()<<now.second()<<"s "<<now.msec()<<"ms :open()";
#endif
header = 0;
- if(buffer_size == 0) {
- // Default buffer size, 200ms, default period size is 40ms
- buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2;
- period_size = buffer_size/5;
+ period_size = 0;
+
+ if (!settings.isValid()) {
+ qWarning("QAudioInput: open error, invalid format.");
+ } else if (settings.channels() <= 0) {
+ qWarning("QAudioInput: open error, invalid number of channels (%d).",
+ settings.channels());
+ } else if (settings.sampleSize() <= 0) {
+ qWarning("QAudioInput: open error, invalid sample size (%d).",
+ settings.sampleSize());
+ } else if (settings.frequency() < 8000 || settings.frequency() > 48000) {
+ qWarning("QAudioInput: open error, frequency out of range (%d).", settings.frequency());
+ } else if (buffer_size == 0) {
+
+ buffer_size
+ = (settings.frequency()
+ * settings.channels()
+ * settings.sampleSize()
+#ifndef Q_OS_WINCE // Default buffer size, 200ms, default period size is 40ms
+ + 39) / 40;
+ period_size = buffer_size / 5;
} else {
- period_size = buffer_size/5;
- }
-#ifdef Q_OS_WINCE
- // For wince reduce size to 40ms for buffer size and 20ms period
- buffer_size = settings.sampleRate()*settings.channelCount()*(settings.sampleSize()/8)*0.04;
- period_size = buffer_size/2;
+ period_size = buffer_size / 5;
+#else // For wince reduce size to 40ms for buffer size and 20ms period
+ + 199) / 200;
+ period_size = buffer_size / 2;
+ } else {
+ period_size = buffer_size / 2;
#endif
+ }
+
+ if (period_size == 0) {
+ errorState = QAudio::OpenError;
+ deviceState = QAudio::StoppedState;
+ emit stateChanged(deviceState);
+ return false;
+ }
+
timeStamp.restart();
elapsedTimeOffset = 0;
wfx.nSamplesPerSec = settings.frequency();
diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
index 49b32c0..ecf3215 100644
--- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
@@ -155,7 +155,7 @@ int QAudioOutputPrivate::xrun_recovery(int err)
int QAudioOutputPrivate::setFormat()
{
- snd_pcm_format_t pcmformat = SND_PCM_FORMAT_S16;
+ snd_pcm_format_t pcmformat = SND_PCM_FORMAT_UNKNOWN;
if(settings.sampleSize() == 8) {
pcmformat = SND_PCM_FORMAT_U8;
@@ -208,7 +208,9 @@ int QAudioOutputPrivate::setFormat()
pcmformat = SND_PCM_FORMAT_FLOAT64_BE;
}
- return snd_pcm_hw_params_set_format( handle, hwparams, pcmformat);
+ return pcmformat != SND_PCM_FORMAT_UNKNOWN
+ ? snd_pcm_hw_params_set_format( handle, hwparams, pcmformat)
+ : -1;
}
QIODevice* QAudioOutputPrivate::start(QIODevice* device)
@@ -275,10 +277,25 @@ bool QAudioOutputPrivate::open()
elapsedTimeOffset = 0;
int dir;
- int err=-1;
+ int err = 0;
int count=0;
unsigned int freakuency=settings.frequency();
+ if (!settings.isValid()) {
+ qWarning("QAudioOutput: open error, invalid format.");
+ } else if (settings.frequency() <= 0) {
+ qWarning("QAudioOutput: open error, invalid sample rate (%d).",
+ settings.frequency());
+ } else {
+ err = -1;
+ }
+
+ if (err == 0) {
+ errorState = QAudio::OpenError;
+ deviceState = QAudio::StoppedState;
+ return false;
+ }
+
QString dev = QString(QLatin1String(m_device.constData()));
QList<QByteArray> devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput);
if(dev.compare(QLatin1String("default")) == 0) {
diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp
index cc52d90..86a2e31 100644
--- a/src/multimedia/audio/qaudiooutput_mac_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp
@@ -60,11 +60,11 @@
#include <QtCore/qtimer.h>
#include <QtCore/qdebug.h>
-#include <QtMultimedia/qaudiodeviceinfo.h>
#include <QtMultimedia/qaudiooutput.h>
#include "qaudio_mac_p.h"
#include "qaudiooutput_mac_p.h"
+#include "qaudiodeviceinfo_mac_p.h"
QT_BEGIN_NAMESPACE
@@ -278,6 +278,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device, const QAudioF
if (QAudio::Mode(mode) == QAudio::AudioInput)
errorCode = QAudio::OpenError;
else {
+ audioDeviceInfo = new QAudioDeviceInfoInternal(device, QAudio::AudioOutput);
isOpen = false;
audioDeviceId = AudioDeviceID(did);
audioUnit = 0;
@@ -299,6 +300,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device, const QAudioF
QAudioOutputPrivate::~QAudioOutputPrivate()
{
+ delete audioDeviceInfo;
close();
}
@@ -424,7 +426,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device)
{
QIODevice* op = device;
- if (!audioFormat.isValid() || !open()) {
+ if (!audioDeviceInfo->isFormatSupported(audioFormat) || !open()) {
stateCode = QAudio::StoppedState;
errorCode = QAudio::OpenError;
return audioIO;
diff --git a/src/multimedia/audio/qaudiooutput_mac_p.h b/src/multimedia/audio/qaudiooutput_mac_p.h
index 752905c..7013961 100644
--- a/src/multimedia/audio/qaudiooutput_mac_p.h
+++ b/src/multimedia/audio/qaudiooutput_mac_p.h
@@ -73,6 +73,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QIODevice;
+class QAbstractAudioDeviceInfo;
namespace QtMultimediaInternal
{
@@ -101,6 +102,7 @@ public:
QWaitCondition threadFinished;
QMutex mutex;
QTimer* intervalTimer;
+ QAbstractAudioDeviceInfo *audioDeviceInfo;
QAudio::Error errorCode;
QAudio::State stateCode;
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index 99bada2..1f304e3 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -251,20 +251,38 @@ bool QAudioOutputPrivate::open()
QTime now(QTime::currentTime());
qDebug()<<now.second()<<"s "<<now.msec()<<"ms :open()";
#endif
- if (!(settings.frequency() >= 8000 && settings.frequency() <= 48000)) {
+
+ period_size = 0;
+
+ if (!settings.isValid()) {
+ qWarning("QAudioOutput: open error, invalid format.");
+ } else if (settings.channels() <= 0) {
+ qWarning("QAudioOutput: open error, invalid number of channels (%d).",
+ settings.channels());
+ } else if (settings.sampleSize() <= 0) {
+ qWarning("QAudioOutput: open error, invalid sample size (%d).",
+ settings.sampleSize());
+ } else if (settings.frequency() < 8000 || settings.frequency() > 48000) {
+ qWarning("QAudioOutput: open error, frequency out of range (%d).", settings.frequency());
+ } else if (buffer_size == 0) {
+ // Default buffer size, 200ms, default period size is 40ms
+ buffer_size
+ = (settings.frequency()
+ * settings.channels()
+ * settings.sampleSize()
+ + 39) / 40;
+ period_size = buffer_size / 5;
+ } else {
+ period_size = buffer_size / 5;
+ }
+
+ if (period_size == 0) {
errorState = QAudio::OpenError;
deviceState = QAudio::StoppedState;
emit stateChanged(deviceState);
- qWarning("QAudioOutput: open error, frequency out of range.");
return false;
}
- if(buffer_size == 0) {
- // Default buffer size, 200ms, default period size is 40ms
- buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2;
- period_size = buffer_size/5;
- } else {
- period_size = buffer_size/5;
- }
+
waveBlocks = allocateBlocks(period_size, buffer_size/period_size);
mutex.lock();
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index bf19a88..c17ca7a 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -1282,8 +1282,39 @@ static void parseFont(QSvgNode *node,
fontStyle->setFamily(attributes.fontFamily.toString().trimmed());
if (!attributes.fontSize.isEmpty() && attributes.fontSize != QT_INHERIT) {
+ // TODO: Support relative sizes 'larger' and 'smaller'.
QSvgHandler::LengthType dummy; // should always be pixel size
- fontStyle->setSize(parseLength(attributes.fontSize.toString(), dummy, handler));
+ qreal size = 0;
+ static const qreal sizeTable[] = { qreal(6.9), qreal(8.3), qreal(10.0), qreal(12.0), qreal(14.4), qreal(17.3), qreal(20.7) };
+ enum AbsFontSize { XXSmall, XSmall, Small, Medium, Large, XLarge, XXLarge };
+ switch (attributes.fontSize.at(0).unicode()) {
+ case 'x':
+ if (attributes.fontSize == QLatin1String("xx-small"))
+ size = sizeTable[XXSmall];
+ else if (attributes.fontSize == QLatin1String("x-small"))
+ size = sizeTable[XSmall];
+ else if (attributes.fontSize == QLatin1String("x-large"))
+ size = sizeTable[XLarge];
+ else if (attributes.fontSize == QLatin1String("xx-large"))
+ size = sizeTable[XXLarge];
+ break;
+ case 's':
+ if (attributes.fontSize == QLatin1String("small"))
+ size = sizeTable[Small];
+ break;
+ case 'm':
+ if (attributes.fontSize == QLatin1String("medium"))
+ size = sizeTable[Medium];
+ break;
+ case 'l':
+ if (attributes.fontSize == QLatin1String("large"))
+ size = sizeTable[Large];
+ break;
+ default:
+ size = parseLength(attributes.fontSize.toString(), dummy, handler);
+ break;
+ }
+ fontStyle->setSize(size);
}
if (!attributes.fontStyle.isEmpty() && attributes.fontStyle != QT_INHERIT) {
diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp
index 84c3874..1808b1d 100644
--- a/tests/auto/qaudioinput/tst_qaudioinput.cpp
+++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp
@@ -50,6 +50,8 @@
#define SRCDIR ""
#endif
+Q_DECLARE_METATYPE(QAudioFormat)
+
class tst_QAudioInput : public QObject
{
Q_OBJECT
@@ -58,6 +60,8 @@ public:
private slots:
void initTestCase();
+ void invalidFormat_data();
+ void invalidFormat();
void settings();
void buffers();
void notifyInterval();
@@ -71,6 +75,8 @@ private:
void tst_QAudioInput::initTestCase()
{
+ qRegisterMetaType<QAudioFormat>();
+
format.setFrequency(8000);
format.setChannels(1);
format.setSampleSize(8);
@@ -91,6 +97,47 @@ void tst_QAudioInput::initTestCase()
audio = new QAudioInput(format, this);
}
+void tst_QAudioInput::invalidFormat_data()
+{
+ QTest::addColumn<QAudioFormat>("invalidFormat");
+
+ QAudioFormat audioFormat;
+
+ QTest::newRow("Null Format")
+ << audioFormat;
+
+ audioFormat = format;
+ audioFormat.setChannels(0);
+ QTest::newRow("Channel count 0")
+ << audioFormat;
+
+ audioFormat = format;
+ audioFormat.setFrequency(0);
+ QTest::newRow("Sample rate 0")
+ << audioFormat;
+
+ audioFormat = format;
+ audioFormat.setSampleSize(0);
+ QTest::newRow("Sample size 0")
+ << audioFormat;
+}
+
+void tst_QAudioInput::invalidFormat()
+{
+ QFETCH(QAudioFormat, invalidFormat);
+
+ QAudioInput audioInput(invalidFormat, this);
+
+ // Check that we are in the default state before calling start
+ QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
+ QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()");
+
+ audioInput.start();
+
+ // Check that error is raised
+ QVERIFY2((audioInput.error() == QAudio::OpenError),"error() was not set to QAudio::OpenError after start()");
+}
+
void tst_QAudioInput::settings()
{
if(available) {
diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
index 437ef5e..e6d11a6 100644
--- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
+++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
@@ -52,6 +52,8 @@
#define SRCDIR ""
#endif
+Q_DECLARE_METATYPE(QAudioFormat)
+
class tst_QAudioOutput : public QObject
{
Q_OBJECT
@@ -60,6 +62,8 @@ public:
private slots:
void initTestCase();
+ void invalidFormat_data();
+ void invalidFormat();
void settings();
void buffers();
void notifyInterval();
@@ -74,6 +78,8 @@ private:
void tst_QAudioOutput::initTestCase()
{
+ qRegisterMetaType<QAudioFormat>();
+
format.setFrequency(8000);
format.setChannels(1);
format.setSampleSize(8);
@@ -92,6 +98,47 @@ void tst_QAudioOutput::initTestCase()
audio = new QAudioOutput(format, this);
}
+void tst_QAudioOutput::invalidFormat_data()
+{
+ QTest::addColumn<QAudioFormat>("invalidFormat");
+
+ QAudioFormat audioFormat;
+
+ QTest::newRow("Null Format")
+ << audioFormat;
+
+ audioFormat = format;
+ audioFormat.setChannels(0);
+ QTest::newRow("Channel count 0")
+ << audioFormat;
+
+ audioFormat = format;
+ audioFormat.setFrequency(0);
+ QTest::newRow("Sample rate 0")
+ << audioFormat;
+
+ audioFormat = format;
+ audioFormat.setSampleSize(0);
+ QTest::newRow("Sample size 0")
+ << audioFormat;
+}
+
+void tst_QAudioOutput::invalidFormat()
+{
+ QFETCH(QAudioFormat, invalidFormat);
+
+ QAudioOutput audioOutput(invalidFormat, this);
+
+ // Check that we are in the default state before calling start
+ QVERIFY2((audioOutput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
+ QVERIFY2((audioOutput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()");
+
+ audioOutput.start();
+
+ // Check that error is raised
+ QVERIFY2((audioOutput.error() == QAudio::OpenError),"error() was not set to QAudio::OpenError after start()");
+}
+
void tst_QAudioOutput::settings()
{
if(available) {
diff --git a/tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-ellipse.png b/tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-ellipse.png
new file mode 100644
index 0000000..9b401b4
--- /dev/null
+++ b/tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-ellipse.png
Binary files differ
diff --git a/tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-rect.png b/tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-rect.png
new file mode 100644
index 0000000..1c59698
--- /dev/null
+++ b/tests/auto/qgraphicsscene/testData/render/all-all-untransformed-clip-rect.png
Binary files differ
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index b8e729e..09cf4e2 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -2617,59 +2617,70 @@ void tst_QGraphicsScene::render_data()
QTest::addColumn<QRectF>("sourceRect");
QTest::addColumn<Qt::AspectRatioMode>("aspectRatioMode");
QTest::addColumn<QMatrix>("matrix");
+ QTest::addColumn<QPainterPath>("clip");
+
+ QPainterPath clip_rect;
+ clip_rect.addRect(50, 100, 200, 150);
+
+ QPainterPath clip_ellipse;
+ clip_ellipse.addEllipse(100,50,150,200);
QTest::newRow("all-all-untransformed") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("all-topleft-untransformed") << QRectF(0, 0, 150, 150)
- << QRectF() << Qt::IgnoreAspectRatio << QMatrix();
+ << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("all-topright-untransformed") << QRectF(150, 0, 150, 150)
- << QRectF() << Qt::IgnoreAspectRatio << QMatrix();
+ << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("all-bottomleft-untransformed") << QRectF(0, 150, 150, 150)
- << QRectF() << Qt::IgnoreAspectRatio << QMatrix();
+ << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("all-bottomright-untransformed") << QRectF(150, 150, 150, 150)
- << QRectF() << Qt::IgnoreAspectRatio << QMatrix();
+ << QRectF() << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("topleft-all-untransformed") << QRectF() << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("topright-all-untransformed") << QRectF() << QRectF(0, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("bottomleft-all-untransformed") << QRectF() << QRectF(-10, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("bottomright-all-untransformed") << QRectF() << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("topleft-topleft-untransformed") << QRectF(0, 0, 150, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("topright-topleft-untransformed") << QRectF(150, 0, 150, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("bottomleft-topleft-untransformed") << QRectF(0, 150, 150, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("bottomright-topleft-untransformed") << QRectF(150, 150, 150, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("top-topleft-untransformed") << QRectF(0, 0, 300, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("bottom-topleft-untransformed") << QRectF(0, 150, 300, 150) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("left-topleft-untransformed") << QRectF(0, 0, 150, 300) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("right-topleft-untransformed") << QRectF(150, 0, 150, 300) << QRectF(-10, -10, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("top-bottomright-untransformed") << QRectF(0, 0, 300, 150) << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("bottom-bottomright-untransformed") << QRectF(0, 150, 300, 150) << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("left-bottomright-untransformed") << QRectF(0, 0, 150, 300) << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("right-bottomright-untransformed") << QRectF(150, 0, 150, 300) << QRectF(0, 0, 10, 10)
- << Qt::IgnoreAspectRatio << QMatrix();
+ << Qt::IgnoreAspectRatio << QMatrix() << QPainterPath();
QTest::newRow("all-all-45-deg-right") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().rotate(-45);
+ << Qt::IgnoreAspectRatio << QMatrix().rotate(-45) << QPainterPath();
QTest::newRow("all-all-45-deg-left") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().rotate(45);
+ << Qt::IgnoreAspectRatio << QMatrix().rotate(45) << QPainterPath();
QTest::newRow("all-all-scale-2x") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().scale(2, 2);
+ << Qt::IgnoreAspectRatio << QMatrix().scale(2, 2) << QPainterPath();
QTest::newRow("all-all-translate-50-0") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().translate(50, 0);
+ << Qt::IgnoreAspectRatio << QMatrix().translate(50, 0) << QPainterPath();
QTest::newRow("all-all-translate-0-50") << QRectF() << QRectF()
- << Qt::IgnoreAspectRatio << QMatrix().translate(0, 50);
+ << Qt::IgnoreAspectRatio << QMatrix().translate(0, 50) << QPainterPath();
+ QTest::newRow("all-all-untransformed-clip-rect") << QRectF() << QRectF()
+ << Qt::IgnoreAspectRatio << QMatrix() << clip_rect;
+ QTest::newRow("all-all-untransformed-clip-ellipse") << QRectF() << QRectF()
+ << Qt::IgnoreAspectRatio << QMatrix() << clip_ellipse;
}
void tst_QGraphicsScene::render()
@@ -2678,6 +2689,7 @@ void tst_QGraphicsScene::render()
QFETCH(QRectF, sourceRect);
QFETCH(Qt::AspectRatioMode, aspectRatioMode);
QFETCH(QMatrix, matrix);
+ QFETCH(QPainterPath, clip);
QPixmap pix(30, 30);
pix.fill(Qt::blue);
@@ -2703,6 +2715,7 @@ void tst_QGraphicsScene::render()
painter.drawLine(0, 150, 300, 150);
painter.drawLine(150, 0, 150, 300);
painter.setMatrix(matrix);
+ if (!clip.isEmpty()) painter.setClipPath(clip);
scene.render(&painter, targetRect, sourceRect, aspectRatioMode);
painter.end();
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 7f24ddc..9d6def8 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -101,6 +101,7 @@ private slots:
void focusWidget_data();
void focusWidget();
void focusWidget2();
+ void focusWidget3();
void focusPolicy_data();
void focusPolicy();
void font_data();
@@ -558,6 +559,39 @@ void tst_QGraphicsWidget::focusWidget2()
QVERIFY(!widget->focusWidget());
}
+class FocusWatchWidget : public QGraphicsWidget
+{
+public:
+ FocusWatchWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent) { gotFocusInCount = 0; gotFocusOutCount = 0; }
+ int gotFocusInCount, gotFocusOutCount;
+protected:
+ void focusInEvent(QFocusEvent *fe) { gotFocusInCount++; QGraphicsWidget::focusInEvent(fe); }
+ void focusOutEvent(QFocusEvent *fe) { gotFocusOutCount++; QGraphicsWidget::focusOutEvent(fe); }
+};
+
+void tst_QGraphicsWidget::focusWidget3()
+{
+ QGraphicsScene scene;
+ QEvent windowActivate(QEvent::WindowActivate);
+ qApp->sendEvent(&scene, &windowActivate);
+
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ FocusWatchWidget *subWidget = new FocusWatchWidget(widget);
+ subWidget->setFocusPolicy(Qt::StrongFocus);
+
+ scene.addItem(widget);
+ widget->show();
+
+ QTRY_VERIFY(!widget->hasFocus());
+ QTRY_VERIFY(!subWidget->hasFocus());
+
+ subWidget->setFocus();
+ QCOMPARE(subWidget->gotFocusInCount, 1);
+ QCOMPARE(subWidget->gotFocusOutCount, 0);
+ widget->hide();
+ QCOMPARE(subWidget->gotFocusOutCount, 1);
+}
+
Q_DECLARE_METATYPE(Qt::FocusPolicy)
void tst_QGraphicsWidget::focusPolicy_data()
{
@@ -3350,6 +3384,7 @@ void tst_QGraphicsWidget::QT_BUG_13865_doublePaintWhenAddingASubItem()
view.show();
QTest::qWaitForWindowShown(&view);
+ QApplication::processEvents();
GreenWidget *sub = new GreenWidget;