summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-08-04 09:00:23 +1000
committerWarwick Allison <warwick.allison@nokia.com>2009-08-04 09:00:23 +1000
commit897014a47b41dcf2b9d91549be9b96890d5291c7 (patch)
tree91da900adb42122eebdef573c012051ea511e42d
parent37cdd053623bfadded77ba6ad34e0d4c45158cc7 (diff)
parent2076f150995e541308b1d8da936b3e12ab68b886 (diff)
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
-rw-r--r--demos/sub-attaq/custompropertyanimation.cpp2
-rw-r--r--demos/sub-attaq/states.cpp6
-rw-r--r--doc/src/classes/qnamespace.qdoc5
-rw-r--r--doc/src/examples/googlechat.qdoc1
-rw-r--r--doc/src/examples/googlesuggest.qdoc1
-rw-r--r--doc/src/images/cursor-hsplit.pngbin161 -> 155 bytes
-rw-r--r--doc/src/images/cursor-vsplit.pngbin155 -> 161 bytes
-rw-r--r--examples/animation/stickman/lifecycle.cpp6
-rw-r--r--examples/phonon/musicplayer/mainwindow.cpp5
-rw-r--r--src/3rdparty/phonon/ds9/abstractvideorenderer.cpp4
-rw-r--r--src/3rdparty/phonon/ds9/fakesource.cpp2
-rw-r--r--src/3rdparty/phonon/ds9/iodevicereader.cpp2
-rw-r--r--src/3rdparty/phonon/ds9/mediagraph.cpp8
-rw-r--r--src/3rdparty/phonon/ds9/mediaobject.cpp7
-rw-r--r--src/3rdparty/phonon/ds9/qbasefilter.cpp7
-rw-r--r--src/3rdparty/phonon/ds9/qmeminputpin.cpp7
-rw-r--r--src/3rdparty/phonon/ds9/qpin.cpp8
-rw-r--r--src/3rdparty/phonon/ds9/videorenderer_soft.cpp6
-rw-r--r--src/activeqt/container/qaxwidget.cpp4
-rw-r--r--src/activeqt/control/qaxserverbase.cpp13
-rw-r--r--src/corelib/global/qglobal.cpp4
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents.cpp7
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents_p.h1
-rw-r--r--src/corelib/kernel/qobject.cpp29
-rw-r--r--src/corelib/kernel/qobject_p.h5
-rw-r--r--src/corelib/statemachine/qabstracttransition.cpp22
-rw-r--r--src/corelib/statemachine/qabstracttransition.h3
-rw-r--r--src/corelib/statemachine/qeventtransition.cpp30
-rw-r--r--src/corelib/statemachine/qeventtransition.h5
-rw-r--r--src/corelib/statemachine/qsignaltransition.cpp15
-rw-r--r--src/corelib/statemachine/qsignaltransition.h3
-rw-r--r--src/corelib/statemachine/qstate.cpp6
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp6
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h8
-rw-r--r--src/corelib/tools/qsharedpointer.cpp23
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h97
-rw-r--r--src/gui/dialogs/qcolordialog.cpp22
-rw-r--r--src/gui/dialogs/qcolordialog_mac.mm221
-rw-r--r--src/gui/dialogs/qcolordialog_p.h13
-rw-r--r--src/gui/dialogs/qfilesystemmodel.cpp1
-rw-r--r--src/gui/egl/qegl_x11.cpp12
-rw-r--r--src/gui/egl/qeglproperties.cpp25
-rw-r--r--src/gui/egl/qeglproperties_p.h1
-rw-r--r--src/gui/image/qpixmap_mac.cpp1
-rw-r--r--src/gui/kernel/qapplication_mac.mm49
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm4
-rw-r--r--src/gui/kernel/qcursor.cpp4
-rw-r--r--src/gui/kernel/qwidget.cpp4
-rw-r--r--src/gui/kernel/qwidget_mac.mm52
-rw-r--r--src/gui/kernel/qwidget_win.cpp5
-rw-r--r--src/gui/painting/qblendfunctions.cpp8
-rw-r--r--src/gui/painting/qdatabuffer_p.h17
-rw-r--r--src/gui/painting/qoutlinemapper.cpp67
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp6
-rw-r--r--src/gui/painting/qpaintengineex.cpp106
-rw-r--r--src/gui/painting/qtransform.cpp47
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp4
-rw-r--r--src/gui/statemachine/qkeyeventtransition.cpp13
-rw-r--r--src/gui/statemachine/qkeyeventtransition.h3
-rw-r--r--src/gui/statemachine/qmouseeventtransition.cpp15
-rw-r--r--src/gui/statemachine/qmouseeventtransition.h4
-rw-r--r--src/gui/text/qfontengine_mac.mm9
-rw-r--r--src/gui/widgets/qmenu.cpp2
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp7
-rw-r--r--src/network/access/qnetworkreply.cpp9
-rw-r--r--src/opengl/opengl.pro1
-rw-r--r--src/opengl/qgl_x11egl.cpp6
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp29
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp13
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h21
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp288
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp13
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h3
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp21
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.h3
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp20
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h7
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp6
-rw-r--r--src/svg/qsvgstyle.cpp4
-rw-r--r--tests/arthur/data/qps/pixmap_scaling.qps346
-rw-r--r--tests/auto/moc/os9-newlines.h2
-rw-r--r--tests/auto/q3socket/tst_qsocket.cpp14
-rw-r--r--tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp6
-rw-r--r--tests/auto/q3urloperator/tst_q3urloperator.cpp12
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp16
-rw-r--r--tests/auto/qmake/testdata/simple_app_build/README1
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp36
-rw-r--r--tests/auto/qsharedpointer/qsharedpointer.pro11
-rw-r--r--tests/auto/qsharedpointer/tst_qsharedpointer.cpp297
-rw-r--r--tests/auto/qsharedpointer/wrapper.cpp60
-rw-r--r--tests/auto/qsharedpointer/wrapper.h55
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp4
-rw-r--r--tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp8
-rw-r--r--tests/auto/qstate/tst_qstate.cpp5
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp30
-rw-r--r--tests/auto/selftests/tst_selftests.cpp7
-rw-r--r--tests/auto/uic3/uic3.pro3
-rw-r--r--tools/assistant/tools/assistant/centralwidget.cpp28
-rw-r--r--tools/assistant/tools/assistant/centralwidget.h3
-rw-r--r--tools/assistant/tools/assistant/mainwindow.cpp2
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.cpp41
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.h12
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.ui118
103 files changed, 1758 insertions, 883 deletions
diff --git a/demos/sub-attaq/custompropertyanimation.cpp b/demos/sub-attaq/custompropertyanimation.cpp
index 9282f4202..27a4eba6b 100644
--- a/demos/sub-attaq/custompropertyanimation.cpp
+++ b/demos/sub-attaq/custompropertyanimation.cpp
@@ -96,7 +96,7 @@ void CustomPropertyAnimation::updateState(QAbstractAnimation::State oldState, QA
setKeyValues(values);
}
- if (animProp && !startValue().isValid() && currentTime() == 0
+ if ((animProp && !startValue().isValid() && currentTime() == 0)
|| (currentTime() == duration() && currentLoop() == (loopCount() - 1))) {
setStartValue(def);
}
diff --git a/demos/sub-attaq/states.cpp b/demos/sub-attaq/states.cpp
index d63737f52..d6c0b5a1d 100644
--- a/demos/sub-attaq/states.cpp
+++ b/demos/sub-attaq/states.cpp
@@ -269,9 +269,10 @@ void UpdateScoreState::onEntry(QEvent *e)
/** Win transition */
UpdateScoreTransition::UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target)
- : QSignalTransition(scene,SIGNAL(subMarineDestroyed(int)), QList<QAbstractState*>() << target),
+ : QSignalTransition(scene,SIGNAL(subMarineDestroyed(int))),
game(game), scene(scene)
{
+ setTargetState(target);
}
bool UpdateScoreTransition::eventTest(QEvent *event)
@@ -288,9 +289,10 @@ bool UpdateScoreTransition::eventTest(QEvent *event)
/** Win transition */
WinTransition::WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target)
- : QSignalTransition(scene,SIGNAL(allSubMarineDestroyed(int)), QList<QAbstractState*>() << target),
+ : QSignalTransition(scene,SIGNAL(allSubMarineDestroyed(int))),
game(game), scene(scene)
{
+ setTargetState(target);
}
bool WinTransition::eventTest(QEvent *event)
diff --git a/doc/src/classes/qnamespace.qdoc b/doc/src/classes/qnamespace.qdoc
index 2d40fdd50..59e0a95ad 100644
--- a/doc/src/classes/qnamespace.qdoc
+++ b/doc/src/classes/qnamespace.qdoc
@@ -1884,7 +1884,10 @@
We refer to a top-level window that has a parent
as a \e secondary window.
- \value Sheet Indicates that the widget is a Macintosh sheet.
+ \value Sheet Indicates that the window is a Macintosh sheet. Since
+ using a sheet implies window modality, the recommended
+ way is to use QWidget::setWindowModality(), or
+ QDialog::open(), instead.
\value Drawer Indicates that the widget is a Macintosh drawer.
diff --git a/doc/src/examples/googlechat.qdoc b/doc/src/examples/googlechat.qdoc
index 42a0198c7..7c9d7db61 100644
--- a/doc/src/examples/googlechat.qdoc
+++ b/doc/src/examples/googlechat.qdoc
@@ -48,4 +48,5 @@
\image googlechat-example.png
+ \note The Google Talk instant messaging service is a registered trademark of Google Inc.
*/
diff --git a/doc/src/examples/googlesuggest.qdoc b/doc/src/examples/googlesuggest.qdoc
index 1752420f3..e3d2b1f72 100644
--- a/doc/src/examples/googlesuggest.qdoc
+++ b/doc/src/examples/googlesuggest.qdoc
@@ -48,4 +48,5 @@
\image googlesuggest-example.png
+ \note The Google Suggest suggestion service is a registered trademark of Google Inc.
*/
diff --git a/doc/src/images/cursor-hsplit.png b/doc/src/images/cursor-hsplit.png
index 1beda2570..a5667e3ff 100644
--- a/doc/src/images/cursor-hsplit.png
+++ b/doc/src/images/cursor-hsplit.png
Binary files differ
diff --git a/doc/src/images/cursor-vsplit.png b/doc/src/images/cursor-vsplit.png
index a5667e3ff..1beda2570 100644
--- a/doc/src/images/cursor-vsplit.png
+++ b/doc/src/images/cursor-vsplit.png
Binary files differ
diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp
index c761d87a3..700916d22 100644
--- a/examples/animation/stickman/lifecycle.cpp
+++ b/examples/animation/stickman/lifecycle.cpp
@@ -56,8 +56,9 @@ public:
{
}
KeyPressTransition(GraphicsView *receiver, Qt::Key key, QAbstractState *target)
- : QSignalTransition(receiver, SIGNAL(keyPressed(int)), QList<QAbstractState*>() << target), m_key(key)
+ : QSignalTransition(receiver, SIGNAL(keyPressed(int))), m_key(key)
{
+ setTargetState(target);
}
virtual bool eventTest(QEvent *e)
@@ -78,8 +79,9 @@ class LightningStrikesTransition: public QEventTransition
{
public:
LightningStrikesTransition(QAbstractState *target)
- : QEventTransition(this, QEvent::Timer, QList<QAbstractState*>() << target)
+ : QEventTransition(this, QEvent::Timer)
{
+ setTargetState(target);
qsrand((uint)QDateTime::currentDateTime().toTime_t());
startTimer(1000);
}
diff --git a/examples/phonon/musicplayer/mainwindow.cpp b/examples/phonon/musicplayer/mainwindow.cpp
index 7ec86ecf8..c3cc5d594 100644
--- a/examples/phonon/musicplayer/mainwindow.cpp
+++ b/examples/phonon/musicplayer/mainwindow.cpp
@@ -157,9 +157,12 @@ void MainWindow::tableClicked(int row, int /* column */)
mediaObject->stop();
mediaObject->clearQueue();
+ if (row >= sources.size())
+ return;
+
mediaObject->setCurrentSource(sources[row]);
- if (wasPlaying)
+ if (wasPlaying)
mediaObject->play();
else
mediaObject->stop();
diff --git a/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp b/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp
index e932e7096..a9d069455 100644
--- a/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp
+++ b/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp
@@ -99,8 +99,8 @@ namespace Phonon
m_dstX = m_dstY = 0;
if (ratio > 0) {
- if (realWidth / realHeight > ratio && scaleMode == Phonon::VideoWidget::FitInView
- || realWidth / realHeight < ratio && scaleMode == Phonon::VideoWidget::ScaleAndCrop) {
+ if ((realWidth / realHeight > ratio && scaleMode == Phonon::VideoWidget::FitInView)
+ || (realWidth / realHeight < ratio && scaleMode == Phonon::VideoWidget::ScaleAndCrop)) {
//the height is correct, let's change the width
m_dstWidth = qRound(realHeight * ratio);
m_dstX = qRound((realWidth - realHeight * ratio) / 2.);
diff --git a/src/3rdparty/phonon/ds9/fakesource.cpp b/src/3rdparty/phonon/ds9/fakesource.cpp
index a4d464057..4dce138b6 100644
--- a/src/3rdparty/phonon/ds9/fakesource.cpp
+++ b/src/3rdparty/phonon/ds9/fakesource.cpp
@@ -29,7 +29,7 @@ namespace Phonon
namespace DS9
{
static WAVEFORMATEX g_defaultWaveFormat = {WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0};
- static VIDEOINFOHEADER2 g_defaultVideoInfo = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, {sizeof(BITMAPINFOHEADER), 1, 1, 1, 0, 0, 0, 0, 0, 0, 0} };
+ static VIDEOINFOHEADER2 g_defaultVideoInfo = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, {0}, 0, {sizeof(BITMAPINFOHEADER), 1, 1, 1, 0, 0, 0, 0, 0, 0, 0} };
static const AM_MEDIA_TYPE g_fakeAudioType = {MEDIATYPE_Audio, MEDIASUBTYPE_PCM, 0, 0, 2, FORMAT_WaveFormatEx, 0, sizeof(WAVEFORMATEX), reinterpret_cast<BYTE*>(&g_defaultWaveFormat)};
static const AM_MEDIA_TYPE g_fakeVideoType = {MEDIATYPE_Video, MEDIASUBTYPE_RGB32, TRUE, FALSE, 0, FORMAT_VideoInfo2, 0, sizeof(VIDEOINFOHEADER2), reinterpret_cast<BYTE*>(&g_defaultVideoInfo)};
diff --git a/src/3rdparty/phonon/ds9/iodevicereader.cpp b/src/3rdparty/phonon/ds9/iodevicereader.cpp
index 38c983b38..a885a6979 100644
--- a/src/3rdparty/phonon/ds9/iodevicereader.cpp
+++ b/src/3rdparty/phonon/ds9/iodevicereader.cpp
@@ -167,7 +167,7 @@ namespace Phonon
oldSize = currentBufferSize();
}
- DWORD bytesRead = qMin(currentBufferSize(), int(length));
+ int bytesRead = qMin(currentBufferSize(), int(length));
{
QWriteLocker locker(&m_lock);
qMemCopy(buffer, m_buffer.data(), bytesRead);
diff --git a/src/3rdparty/phonon/ds9/mediagraph.cpp b/src/3rdparty/phonon/ds9/mediagraph.cpp
index 31a0622ff..7b101769a 100644
--- a/src/3rdparty/phonon/ds9/mediagraph.cpp
+++ b/src/3rdparty/phonon/ds9/mediagraph.cpp
@@ -68,6 +68,8 @@ namespace Phonon
return ret;
}
+
+/*
static HRESULT saveToFile(Graph graph, const QString &filepath)
{
const WCHAR wszStreamName[] = L"ActiveMovieGraph";
@@ -103,7 +105,7 @@ namespace Phonon
return hr;
}
-
+*/
MediaGraph::MediaGraph(MediaObject *mo, short index) :
m_graph(CLSID_FilterGraph, IID_IGraphBuilder),
@@ -537,7 +539,7 @@ namespace Phonon
const QList<OutputPin> outputs = BackendNode::pins(filter, PINDIR_OUTPUT);
for(int i = 0; i < outputs.count(); ++i) {
const OutputPin &pin = outputs.at(i);
- if (VFW_E_NOT_CONNECTED == pin->ConnectedTo(inPin.pparam())) {
+ if (HRESULT(VFW_E_NOT_CONNECTED) == pin->ConnectedTo(inPin.pparam())) {
return SUCCEEDED(pin->Connect(newIn, 0));
}
}
@@ -809,7 +811,7 @@ namespace Phonon
for (int i = 0; i < outputs.count(); ++i) {
const OutputPin &out = outputs.at(i);
InputPin pin;
- if (out->ConnectedTo(pin.pparam()) == VFW_E_NOT_CONNECTED) {
+ if (out->ConnectedTo(pin.pparam()) == HRESULT(VFW_E_NOT_CONNECTED)) {
m_decoderPins += out; //unconnected outputs can be decoded outputs
}
}
diff --git a/src/3rdparty/phonon/ds9/mediaobject.cpp b/src/3rdparty/phonon/ds9/mediaobject.cpp
index df4201136..10782c251 100644
--- a/src/3rdparty/phonon/ds9/mediaobject.cpp
+++ b/src/3rdparty/phonon/ds9/mediaobject.cpp
@@ -786,15 +786,16 @@ namespace Phonon
case Phonon::PausedState:
pause();
break;
- case Phonon::StoppedState:
- stop();
- break;
case Phonon::PlayingState:
play();
break;
case Phonon::ErrorState:
setState(Phonon::ErrorState);
break;
+ case Phonon::StoppedState:
+ default:
+ stop();
+ break;
}
}
}
diff --git a/src/3rdparty/phonon/ds9/qbasefilter.cpp b/src/3rdparty/phonon/ds9/qbasefilter.cpp
index 95cab92f8..c950c4197 100644
--- a/src/3rdparty/phonon/ds9/qbasefilter.cpp
+++ b/src/3rdparty/phonon/ds9/qbasefilter.cpp
@@ -92,8 +92,8 @@ namespace Phonon
return E_POINTER;
}
- int nbfetched = 0;
- while (nbfetched < int(count) && m_index < m_pins.count()) {
+ uint nbfetched = 0;
+ while (nbfetched < count && m_index < m_pins.count()) {
IPin *current = m_pins[m_index];
current->AddRef();
ret[nbfetched] = current;
@@ -211,7 +211,8 @@ namespace Phonon
}
else if (iid == IID_IMediaPosition || iid == IID_IMediaSeeking) {
if (inputPins().isEmpty()) {
- if (*out = getUpStreamInterface(iid)) {
+ *out = getUpStreamInterface(iid);
+ if (*out) {
return S_OK; //we return here to avoid adding a reference
} else {
hr = E_NOINTERFACE;
diff --git a/src/3rdparty/phonon/ds9/qmeminputpin.cpp b/src/3rdparty/phonon/ds9/qmeminputpin.cpp
index dca99dbc5..865b8af48 100644
--- a/src/3rdparty/phonon/ds9/qmeminputpin.cpp
+++ b/src/3rdparty/phonon/ds9/qmeminputpin.cpp
@@ -137,7 +137,8 @@ namespace Phonon
return E_POINTER;
}
- if (*alloc = memoryAllocator(true)) {
+ *alloc = memoryAllocator(true);
+ if (*alloc) {
return S_OK;
}
@@ -294,7 +295,7 @@ namespace Phonon
LONG length = sample->GetActualDataLength();
HRESULT hr = alloc->Commit();
- if (hr == VFW_E_SIZENOTSET) {
+ if (hr == HRESULT(VFW_E_SIZENOTSET)) {
ALLOCATOR_PROPERTIES prop = getDefaultAllocatorProperties();
prop.cbBuffer = qMax(prop.cbBuffer, length);
ALLOCATOR_PROPERTIES actual;
@@ -324,7 +325,7 @@ namespace Phonon
{
LONGLONG start, end;
hr = sample->GetMediaTime(&start, &end);
- if (hr != VFW_E_MEDIA_TIME_NOT_SET) {
+ if (hr != HRESULT(VFW_E_MEDIA_TIME_NOT_SET)) {
hr = out->SetMediaTime(&start, &end);
Q_ASSERT(SUCCEEDED(hr));
}
diff --git a/src/3rdparty/phonon/ds9/qpin.cpp b/src/3rdparty/phonon/ds9/qpin.cpp
index 68a4ec0c9..d14876b1e 100644
--- a/src/3rdparty/phonon/ds9/qpin.cpp
+++ b/src/3rdparty/phonon/ds9/qpin.cpp
@@ -91,8 +91,8 @@ namespace Phonon
return E_INVALIDARG;
}
- int nbFetched = 0;
- while (nbFetched < int(count) && m_index < m_pin->mediaTypes().count()) {
+ uint nbFetched = 0;
+ while (nbFetched < count && m_index < m_pin->mediaTypes().count()) {
//the caller will deallocate the memory
*out = static_cast<AM_MEDIA_TYPE *>(::CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)));
const AM_MEDIA_TYPE original = m_pin->mediaTypes().at(m_index);
@@ -145,9 +145,9 @@ namespace Phonon
QPin::QPin(QBaseFilter *parent, PIN_DIRECTION dir, const QVector<AM_MEDIA_TYPE> &mt) :
- m_memAlloc(0), m_parent(parent), m_refCount(1), m_connected(0),
+ m_parent(parent), m_flushing(false), m_refCount(1), m_connected(0),
m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType),
- m_flushing(false)
+ m_memAlloc(0)
{
Q_ASSERT(m_parent);
m_parent->addPin(this);
diff --git a/src/3rdparty/phonon/ds9/videorenderer_soft.cpp b/src/3rdparty/phonon/ds9/videorenderer_soft.cpp
index 211226755..cf5ce9611 100644
--- a/src/3rdparty/phonon/ds9/videorenderer_soft.cpp
+++ b/src/3rdparty/phonon/ds9/videorenderer_soft.cpp
@@ -194,8 +194,8 @@ namespace Phonon
m_sampleBuffer = ComPointer<IMediaSample>();
#ifndef QT_NO_OPENGL
freeGLResources();
-#endif // QT_NO_OPENGL
m_textureUploaded = false;
+#endif // QT_NO_OPENGL
}
void endOfStream()
@@ -314,7 +314,6 @@ namespace Phonon
REFERENCE_TIME m_start;
HANDLE m_renderEvent, m_receiveCanWait; // Signals sample to render
QSize m_size;
- bool m_textureUploaded;
//mixer settings
qreal m_brightness,
@@ -356,6 +355,7 @@ namespace Phonon
bool m_checkedPrograms;
bool m_usingOpenGL;
+ bool m_textureUploaded;
GLuint m_program[2];
GLuint m_texture[3];
#endif
@@ -436,7 +436,7 @@ namespace Phonon
QBaseFilter(CLSID_NULL), m_inputPin(new VideoRendererSoftPin(this)),
m_renderer(renderer), m_start(0)
#ifndef QT_NO_OPENGL
- ,m_usingOpenGL(false), m_checkedPrograms(false), m_textureUploaded(false)
+ , m_checkedPrograms(false), m_usingOpenGL(false), m_textureUploaded(false)
#endif
{
m_renderEvent = ::CreateEvent(0, 0, 0, 0);
diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp
index 19f00db25..ff6bcb86a 100644
--- a/src/activeqt/container/qaxwidget.cpp
+++ b/src/activeqt/container/qaxwidget.cpp
@@ -985,7 +985,11 @@ HRESULT WINAPI QAxClientSite::TranslateAccelerator(LPMSG lpMsg, DWORD /*grfModif
bool ActiveQtDetected = false;
bool fromInProcServer = false;
+#ifdef GWLP_USERDATA
LONG_PTR serverType = GetWindowLongPtr(lpMsg->hwnd, GWLP_USERDATA);
+#else
+ LONG serverType = GetWindowLong(lpMsg->hwnd, GWL_USERDATA);
+#endif
if (serverType == QAX_INPROC_SERVER) {
ActiveQtDetected = true;
fromInProcServer = true;
diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp
index e482c6029..e7ddb4785 100644
--- a/src/activeqt/control/qaxserverbase.cpp
+++ b/src/activeqt/control/qaxserverbase.cpp
@@ -3605,15 +3605,26 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg)
return S_FALSE;
bool resetUserData = false;
// set server type in the user-data of the window.
+#ifdef GWLP_USERDATA
LONG_PTR serverType = QAX_INPROC_SERVER;
+#else
+ LONG serverType = QAX_INPROC_SERVER;
+#endif
if (qAxOutProcServer)
serverType = QAX_OUTPROC_SERVER;
+#ifdef GWLP_USERDATA
LONG_PTR oldData = SetWindowLongPtr(pMsg->hwnd, GWLP_USERDATA, serverType);
+#else
+ LONG oldData = SetWindowLong(pMsg->hwnd, GWL_USERDATA, serverType);
+#endif
HRESULT hres = controlSite->TranslateAcceleratorW(pMsg, dwKeyMod);
controlSite->Release();
// reset the user-data for the window.
+#ifdef GWLP_USERDATA
SetWindowLongPtr(pMsg->hwnd, GWLP_USERDATA, oldData);
-
+#else
+ SetWindowLong(pMsg->hwnd, GWL_USERDATA, oldData);
+#endif
return hres;
}
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 776a7409d..63941ef9b 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1083,7 +1083,7 @@ bool qSharedBuild()
\value WV_XP Windows XP (operating system version 5.1)
\value WV_2003 Windows Server 2003, Windows Server 2003 R2, Windows Home Server, Windows XP Professional x64 Edition (operating system version 5.2)
\value WV_VISTA Windows Vista, Windows Server 2008 (operating system version 6.0)
- \value WV_WINDOWS7 Windows 7 (operating system version 6.1)
+ \value WV_WINDOWS7 Windows 7, Windows Server 2008 R2 (operating system version 6.1)
Alternatively, you may use the following macros which correspond directly to the Windows operating system version number:
@@ -1092,7 +1092,7 @@ bool qSharedBuild()
\value WV_5_1 Operating system version 5.1, corresponds to Windows XP
\value WV_5_2 Operating system version 5.2, corresponds to Windows Server 2003, Windows Server 2003 R2, Windows Home Server, and Windows XP Professional x64 Edition
\value WV_6_0 Operating system version 6.0, corresponds to Windows Vista and Windows Server 2008
- \value WV_6_1 Operating system version 6.1, corresponds to Windows 7
+ \value WV_6_1 Operating system version 6.1, corresponds to Windows 7 and Windows Server 2008 R2
CE-based versions:
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.cpp b/src/corelib/io/qfilesystemwatcher_fsevents.cpp
index 3e0aee89c..cb276b795 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents.cpp
+++ b/src/corelib/io/qfilesystemwatcher_fsevents.cpp
@@ -422,9 +422,12 @@ void QFSEventsFileSystemWatcherEngine::fseventsCallback(ConstFSEventStreamRef ,
void QFSEventsFileSystemWatcherEngine::stop()
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+ QMutexLocker locker(&mutex);
stopFSStream(fsStream);
- if (threadsRunLoop)
+ if (threadsRunLoop) {
CFRunLoopStop(threadsRunLoop);
+ waitForStop.wait(&mutex);
+ }
#endif
}
@@ -461,6 +464,8 @@ void QFSEventsFileSystemWatcherEngine::run()
// immediately.
CFRunLoopRun();
threadsRunLoop = 0;
+ QMutexLocker locker(&mutex);
+ waitForStop.wakeAll();
#endif
}
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents_p.h b/src/corelib/io/qfilesystemwatcher_fsevents_p.h
index 477086725..ffc0c687f 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents_p.h
+++ b/src/corelib/io/qfilesystemwatcher_fsevents_p.h
@@ -114,6 +114,7 @@ private:
CFRunLoopRef threadsRunLoop;
QMutex mutex;
QWaitCondition waitCondition;
+ QWaitCondition waitForStop;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
PathHash filePathInfoHash;
PathHash dirPathInfoHash;
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index ab91799d1..7bf209a3b 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -123,7 +123,7 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *)
}
QObjectPrivate::QObjectPrivate(int version)
- : threadData(0), currentSender(0), currentChildBeingDeleted(0), connectionLists(0), senders(0)
+ : threadData(0), currentSender(0), declarativeData(0), connectionLists(0), senders(0)
{
if (version != QObjectPrivateVersion)
qFatal("Cannot mix incompatible Qt libraries");
@@ -1859,12 +1859,13 @@ void QObjectPrivate::deleteChildren()
// don't use qDeleteAll as the destructor of the child might
// delete siblings
for (int i = 0; i < children.count(); ++i) {
- currentChildBeingDeleted = children.at(i);
+ QObject *child = children.at(i);
children[i] = 0;
- delete currentChildBeingDeleted;
+ if (child)
+ child->d_func()->parent = 0;
+ delete child;
}
children.clear();
- currentChildBeingDeleted = 0;
wasDeleted = reallyWasDeleted;
}
@@ -1875,20 +1876,14 @@ void QObjectPrivate::setParent_helper(QObject *o)
return;
if (parent) {
QObjectPrivate *parentD = parent->d_func();
- if (parentD->wasDeleted && wasDeleted
- && parentD->currentChildBeingDeleted == q) {
- // don't do anything since QObjectPrivate::deleteChildren() already
- // cleared our entry in parentD->children.
+ const int index = parentD->children.indexOf(q);
+ if (parentD->wasDeleted) {
+ parentD->children[index] = 0;
} else {
- const int index = parentD->children.indexOf(q);
- if (parentD->wasDeleted) {
- parentD->children[index] = 0;
- } else {
- parentD->children.removeAt(index);
- if (sendChildEvents && parentD->receiveChildEvents) {
- QChildEvent e(QEvent::ChildRemoved, q);
- QCoreApplication::sendEvent(parent, &e);
- }
+ parentD->children.removeAt(index);
+ if (sendChildEvents && parentD->receiveChildEvents) {
+ QChildEvent e(QEvent::ChildRemoved, q);
+ QCoreApplication::sendEvent(parent, &e);
}
}
}
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index e908753b6..0b41c9afa 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -125,10 +125,7 @@ public:
// object currently activating the object
Sender *currentSender;
- union {
- QObject *currentChildBeingDeleted;
- QDeclarativeData *declarativeData;
- };
+ QDeclarativeData *declarativeData;
bool isSender(const QObject *receiver, const char *signal) const;
QObjectList receiverList(const char *signal) const;
diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp
index 0004d3e12..3248dcf94 100644
--- a/src/corelib/statemachine/qabstracttransition.cpp
+++ b/src/corelib/statemachine/qabstracttransition.cpp
@@ -153,34 +153,12 @@ QAbstractTransition::QAbstractTransition(QState *sourceState)
}
/*!
- Constructs a new QAbstractTransition object with the given \a targets and \a
- sourceState.
-*/
-QAbstractTransition::QAbstractTransition(const QList<QAbstractState*> &targets,
- QState *sourceState)
- : QObject(*new QAbstractTransitionPrivate, sourceState)
-{
- setTargetStates(targets);
-}
-
-/*!
- \internal
-*/
-QAbstractTransition::QAbstractTransition(QAbstractTransitionPrivate &dd,
- QState *parent)
- : QObject(dd, parent)
-{
-}
-
-/*!
\internal
*/
QAbstractTransition::QAbstractTransition(QAbstractTransitionPrivate &dd,
- const QList<QAbstractState*> &targets,
QState *parent)
: QObject(dd, parent)
{
- setTargetStates(targets);
}
/*!
diff --git a/src/corelib/statemachine/qabstracttransition.h b/src/corelib/statemachine/qabstracttransition.h
index 9ba1f11b6..8ff3a6edb 100644
--- a/src/corelib/statemachine/qabstracttransition.h
+++ b/src/corelib/statemachine/qabstracttransition.h
@@ -72,7 +72,6 @@ class Q_CORE_EXPORT QAbstractTransition : public QObject
Q_PROPERTY(QList<QAbstractState*> targetStates READ targetStates WRITE setTargetStates)
public:
QAbstractTransition(QState *sourceState = 0);
- QAbstractTransition(const QList<QAbstractState*> &targets, QState *sourceState = 0);
virtual ~QAbstractTransition();
QState *sourceState() const;
@@ -104,8 +103,6 @@ protected:
protected:
QAbstractTransition(QAbstractTransitionPrivate &dd, QState *parent);
- QAbstractTransition(QAbstractTransitionPrivate &dd,
- const QList<QAbstractState*> &targets, QState *parent);
private:
Q_DISABLE_COPY(QAbstractTransition)
diff --git a/src/corelib/statemachine/qeventtransition.cpp b/src/corelib/statemachine/qeventtransition.cpp
index 393398127..813c96026 100644
--- a/src/corelib/statemachine/qeventtransition.cpp
+++ b/src/corelib/statemachine/qeventtransition.cpp
@@ -153,22 +153,6 @@ QEventTransition::QEventTransition(QObject *object, QEvent::Type type,
}
/*!
- Constructs a new QEventTransition object associated with events of the given
- \a type for the given \a object. The transition has the given \a targets and
- \a sourceState.
-*/
-QEventTransition::QEventTransition(QObject *object, QEvent::Type type,
- const QList<QAbstractState*> &targets,
- QState *sourceState)
- : QAbstractTransition(*new QEventTransitionPrivate, targets, sourceState)
-{
- Q_D(QEventTransition);
- d->registered = false;
- d->object = object;
- d->eventType = type;
-}
-
-/*!
\internal
*/
QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QState *parent)
@@ -190,20 +174,6 @@ QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QObject *object,
}
/*!
- \internal
-*/
-QEventTransition::QEventTransition(QEventTransitionPrivate &dd, QObject *object,
- QEvent::Type type, const QList<QAbstractState*> &targets,
- QState *parent)
- : QAbstractTransition(dd, targets, parent)
-{
- Q_D(QEventTransition);
- d->registered = false;
- d->object = object;
- d->eventType = type;
-}
-
-/*!
Destroys this QObject event transition.
*/
QEventTransition::~QEventTransition()
diff --git a/src/corelib/statemachine/qeventtransition.h b/src/corelib/statemachine/qeventtransition.h
index b05ffefd2..0ebca1948 100644
--- a/src/corelib/statemachine/qeventtransition.h
+++ b/src/corelib/statemachine/qeventtransition.h
@@ -62,8 +62,6 @@ class Q_CORE_EXPORT QEventTransition : public QAbstractTransition
public:
QEventTransition(QState *sourceState = 0);
QEventTransition(QObject *object, QEvent::Type type, QState *sourceState = 0);
- QEventTransition(QObject *object, QEvent::Type type,
- const QList<QAbstractState*> &targets, QState *sourceState = 0);
~QEventTransition();
QObject *eventObject() const;
@@ -82,9 +80,6 @@ protected:
QEventTransition(QEventTransitionPrivate &dd, QState *parent);
QEventTransition(QEventTransitionPrivate &dd, QObject *object,
QEvent::Type type, QState *parent);
- QEventTransition(QEventTransitionPrivate &dd, QObject *object,
- QEvent::Type type, const QList<QAbstractState*> &targets,
- QState *parent);
private:
Q_DISABLE_COPY(QEventTransition)
diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp
index 389e51302..781469935 100644
--- a/src/corelib/statemachine/qsignaltransition.cpp
+++ b/src/corelib/statemachine/qsignaltransition.cpp
@@ -159,21 +159,6 @@ QSignalTransition::QSignalTransition(QObject *sender, const char *signal,
}
/*!
- Constructs a new signal transition associated with the given \a signal of
- the given \a sender. The transition has the given \a targets and \a
- sourceState.
-*/
-QSignalTransition::QSignalTransition(QObject *sender, const char *signal,
- const QList<QAbstractState*> &targets,
- QState *sourceState)
- : QAbstractTransition(*new QSignalTransitionPrivate, targets, sourceState)
-{
- Q_D(QSignalTransition);
- d->sender = sender;
- d->signal = signal;
-}
-
-/*!
Destroys this signal transition.
*/
QSignalTransition::~QSignalTransition()
diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h
index 69060ae66..415751eb9 100644
--- a/src/corelib/statemachine/qsignaltransition.h
+++ b/src/corelib/statemachine/qsignaltransition.h
@@ -62,9 +62,6 @@ public:
QSignalTransition(QState *sourceState = 0);
QSignalTransition(QObject *sender, const char *signal,
QState *sourceState = 0);
- QSignalTransition(QObject *sender, const char *signal,
- const QList<QAbstractState*> &targets,
- QState *sourceState = 0);
~QSignalTransition();
QObject *senderObject() const;
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index 2042288ce..09d0be083 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -339,7 +339,8 @@ QSignalTransition *QState::addTransition(QObject *sender, const char *signal,
return 0;
}
}
- QSignalTransition *trans = new QSignalTransition(sender, signal, QList<QAbstractState*>() << target);
+ QSignalTransition *trans = new QSignalTransition(sender, signal);
+ trans->setTargetState(target);
addTransition(trans);
return trans;
}
@@ -351,7 +352,8 @@ class UnconditionalTransition : public QAbstractTransition
{
public:
UnconditionalTransition(QAbstractState *target)
- : QAbstractTransition(QList<QAbstractState*>() << target) {}
+ : QAbstractTransition()
+ { setTargetState(target); }
protected:
void onTransition(QEvent *) {}
bool eventTest(QEvent *) { return true; }
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 5aa5917c5..9cb1d4dba 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -1139,7 +1139,8 @@ class InitialTransition : public QAbstractTransition
{
public:
InitialTransition(QAbstractState *target)
- : QAbstractTransition(QList<QAbstractState*>() << target) {}
+ : QAbstractTransition()
+ { setTargetState(target); }
protected:
virtual bool eventTest(QEvent *) { return true; }
virtual void onTransition(QEvent *) {}
@@ -1306,7 +1307,8 @@ class GoToStateTransition : public QAbstractTransition
{
public:
GoToStateTransition(QAbstractState *target)
- : QAbstractTransition(QList<QAbstractState*>() << target) {}
+ : QAbstractTransition()
+ { setTargetState(target); }
protected:
void onTransition(QEvent *) { deleteLater(); }
bool eventTest(QEvent *) { return true; }
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index 387e42e1d..f0f74d659 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -79,7 +79,7 @@ class QAbstractAnimation;
#endif
class QStateMachine;
-class Q_AUTOTEST_EXPORT QStateMachinePrivate : public QStatePrivate
+class Q_CORE_EXPORT QStateMachinePrivate : public QStatePrivate
{
Q_DECLARE_PUBLIC(QStateMachine)
public:
@@ -214,11 +214,7 @@ public:
f_cloneEvent cloneEvent;
};
- static
-#ifndef QT_BUILD_INTERNAL // otherwise Q_AUTOTEST_EXPORT exports it all
- Q_CORE_EXPORT
-#endif
- const Handler *handler;
+ static const Handler *handler;
};
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index 59dfffe14..2ca612ed1 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -897,6 +897,7 @@ QT_BEGIN_NAMESPACE
namespace QtSharedPointer {
Q_CORE_EXPORT void internalSafetyCheckAdd(const volatile void *);
Q_CORE_EXPORT void internalSafetyCheckRemove(const volatile void *);
+ Q_AUTOTEST_EXPORT void internalSafetyCheckCleanCheck();
}
/*!
@@ -961,6 +962,7 @@ void QtSharedPointer::internalSafetyCheckAdd2(const void *d_ptr, const volatile
kp->dPointers.insert(d_ptr, data);
kp->dataPointers.insert(ptr, d_ptr);
+ Q_ASSERT(kp->dPointers.size() == kp->dataPointers.size());
}
/*!
@@ -985,10 +987,29 @@ void QtSharedPointer::internalSafetyCheckRemove2(const void *d_ptr)
Q_ASSERT(it2 != kp->dataPointers.end());
//qDebug("Removing d=%p value=%p", d_ptr, it->pointer);
-
+
// remove entries
kp->dataPointers.erase(it2);
kp->dPointers.erase(it);
+ Q_ASSERT(kp->dPointers.size() == kp->dataPointers.size());
+}
+
+/*!
+ \internal
+ Called by the QSharedPointer autotest
+*/
+void QtSharedPointer::internalSafetyCheckCleanCheck()
+{
+# ifdef QT_BUILD_INTERNAL
+ KnownPointers *const kp = knownPointers();
+ Q_ASSERT_X(kp, "internalSafetyCheckSelfCheck()", "Called after global statics deletion!");
+
+ if (kp->dPointers.size() != kp->dataPointers.size())
+ qFatal("Internal consistency error: the number of pointers is not equal!");
+
+ if (!kp->dPointers.isEmpty())
+ qFatal("Pointer cleaning failed: %d entries remaining", kp->dPointers.size());
+# endif
}
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index b8f41391b..9fa8df4c7 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -100,20 +100,22 @@ namespace QtSharedPointer {
// used in debug mode to verify the reuse of pointers
Q_CORE_EXPORT void internalSafetyCheckAdd2(const void *, const volatile void *);
Q_CORE_EXPORT void internalSafetyCheckRemove2(const void *);
-
+
template <class T, typename Klass, typename RetVal>
inline void executeDeleter(T *t, RetVal (Klass:: *memberDeleter)())
{ (t->*memberDeleter)(); }
template <class T, typename Deleter>
inline void executeDeleter(T *t, Deleter d)
{ d(t); }
+ template <class T> inline void normalDeleter(T *t) { delete t; }
+
+ // this uses partial template specialization
+ // the only compilers that didn't support this were MSVC 6.0 and 2002
+ template <class T> struct RemovePointer;
+ template <class T> struct RemovePointer<T *> { typedef T Type; };
+ template <class T> struct RemovePointer<QSharedPointer<T> > { typedef T Type; };
+ template <class T> struct RemovePointer<QWeakPointer<T> > { typedef T Type; };
- //
- // Depending on its template parameter, QSharedPointer derives from either
- // QtSharedPointer::InternalRefCount or from QtSharedPointer::ExternalRefCount.
- // Both of these classes derive from QtSharedPointer::Basic, which provides common
- // operations,
- //
template <class T>
class Basic
{
@@ -168,6 +170,7 @@ namespace QtSharedPointer {
virtual inline bool destroy() { return false; }
};
+ // sizeof(ExternalRefCount) = 12 (32-bit) / 16 (64-bit)
template <class T, typename Deleter>
struct CustomDeleter
@@ -177,6 +180,9 @@ namespace QtSharedPointer {
inline CustomDeleter(T *p, Deleter d) : deleter(d), ptr(p) {}
};
+ // sizeof(CustomDeleter) = sizeof(Deleter) + sizeof(void*)
+ // for Deleter = function pointer: 8 (32-bit) / 16 (64-bit)
+ // for Deleter = PMF: 12 (32-bit) / 24 (64-bit) (GCC)
struct ExternalRefCountWithDestroyFn: public ExternalRefCountData
{
@@ -190,6 +196,7 @@ namespace QtSharedPointer {
inline bool destroy() { destroyer(this); return true; }
inline void operator delete(void *ptr) { ::operator delete(ptr); }
};
+ // sizeof(ExternalRefCountWithDestroyFn) = 16 (32-bit) / 24 (64-bit)
template <class T, typename Deleter>
struct ExternalRefCountWithCustomDeleter: public ExternalRefCountWithDestroyFn
@@ -203,11 +210,23 @@ namespace QtSharedPointer {
{
Self *realself = static_cast<Self *>(self);
executeDeleter(realself->extra.ptr, realself->extra.deleter);
+
+ // delete the deleter too
+ realself->extra.~Next();
+ }
+ static void safetyCheckDeleter(ExternalRefCountData *self)
+ {
+ internalSafetyCheckRemove2(self);
+ deleter(self);
}
static inline Self *create(T *ptr, Deleter userDeleter)
{
+# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
+ DestroyerFn destroy = &safetyCheckDeleter;
+# else
DestroyerFn destroy = &deleter;
+# endif
Self *d = static_cast<Self *>(::operator new(sizeof(Self)));
// initialize the two sub-objects
@@ -234,10 +253,19 @@ namespace QtSharedPointer {
static_cast<ExternalRefCountWithContiguousData *>(self);
that->data.~T();
}
+ static void safetyCheckDeleter(ExternalRefCountData *self)
+ {
+ internalSafetyCheckRemove2(self);
+ deleter(self);
+ }
static inline ExternalRefCountData *create(T **ptr)
{
+# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
+ DestroyerFn destroy = &safetyCheckDeleter;
+# else
DestroyerFn destroy = &deleter;
+# endif
ExternalRefCountWithContiguousData *d =
static_cast<ExternalRefCountWithContiguousData *>(::operator new(sizeof(ExternalRefCountWithContiguousData)));
@@ -258,9 +286,9 @@ namespace QtSharedPointer {
template <class T>
class ExternalRefCount: public Basic<T>
{
- typedef ExternalRefCountData Data;
- typedef void (*DeleterFunction)(T *);
protected:
+ typedef ExternalRefCountData Data;
+
inline void ref() const { d->weakref.ref(); d->strongref.ref(); }
inline bool deref()
{
@@ -272,32 +300,34 @@ namespace QtSharedPointer {
inline void internalConstruct(T *ptr)
{
- Basic<T>::internalConstruct(ptr);
+#ifdef QT_SHAREDPOINTER_TRACK_POINTERS
+ internalConstruct<void (*)(T *)>(ptr, normalDeleter);
+#else
Q_ASSERT(!d);
if (ptr)
d = new Data;
-#ifdef QT_SHAREDPOINTER_TRACK_POINTERS
- if (ptr) internalSafetyCheckAdd2(d, ptr);
+ internalFinishConstruction(ptr);
#endif
}
template <typename Deleter>
inline void internalConstruct(T *ptr, Deleter deleter)
{
- Basic<T>::internalConstruct(ptr);
Q_ASSERT(!d);
if (ptr)
d = ExternalRefCountWithCustomDeleter<T, Deleter>::create(ptr, deleter);
-#ifdef QT_SHAREDPOINTER_TRACK_POINTERS
- if (ptr) internalSafetyCheckAdd2(d, ptr);
-#endif
+ internalFinishConstruction(ptr);
}
inline void internalCreate()
{
T *ptr;
d = ExternalRefCountWithContiguousData<T>::create(&ptr);
+ Basic<T>::internalConstruct(ptr);
+ }
+ inline void internalFinishConstruction(T *ptr)
+ {
Basic<T>::internalConstruct(ptr);
#ifdef QT_SHAREDPOINTER_TRACK_POINTERS
if (ptr) internalSafetyCheckAdd2(d, ptr);
@@ -317,9 +347,6 @@ namespace QtSharedPointer {
inline void internalDestroy()
{
-#ifdef QT_SHAREDPOINTER_TRACK_POINTERS
- internalSafetyCheckRemove2(d);
-#endif
if (!d->destroy())
delete this->value;
}
@@ -337,12 +364,22 @@ namespace QtSharedPointer {
inline void internalSet(Data *o, T *actual)
{
if (d == o) return;
- if (o && !o->strongref)
- o = 0;
if (o) {
verifyReconstruction(actual);
- o->weakref.ref();
- o->strongref.ref();
+
+ // increase the strongref, but never up from zero
+ register int tmp = o->strongref;
+ while (tmp > 0) {
+ // try to increment from "tmp" to "tmp + 1"
+ if (o->strongref.testAndSetRelaxed(tmp, tmp + 1))
+ break; // succeeded
+ tmp = o->strongref; // failed, try again
+ }
+
+ if (tmp)
+ o->weakref.ref();
+ else
+ o = 0;
}
if (d && !deref())
delete d;
@@ -350,9 +387,7 @@ namespace QtSharedPointer {
this->value = d && d->strongref ? actual : 0;
}
-#if defined(QT_BUILD_INTERNAL)
- public:
-#endif
+ protected:
Data *d;
private:
@@ -442,6 +477,7 @@ public:
// now initialize the data
new (result.data()) T();
+ result.internalFinishConstruction(result.data());
return result;
}
};
@@ -669,14 +705,6 @@ Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerObjectCast(const QWeakPointer<
return qSharedPointerObjectCast<X>(src.toStrongRef());
}
-# ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
-namespace QtSharedPointer {
- template <class T> struct RemovePointer;
- template <class T> struct RemovePointer<T *> { typedef T Type; };
- template <class T> struct RemovePointer<QSharedPointer<T> > { typedef T Type; };
- template <class T> struct RemovePointer<QWeakPointer<T> > { typedef T Type; };
-}
-
template <class X, class T>
inline QSharedPointer<typename QtSharedPointer::RemovePointer<X>::Type>
qobject_cast(const QSharedPointer<T> &src)
@@ -689,7 +717,6 @@ qobject_cast(const QWeakPointer<T> &src)
{
return qSharedPointerObjectCast<typename QtSharedPointer::RemovePointer<X>::Type, T>(src);
}
-# endif
#endif
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index 42d3a9a3e..aee592c21 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -1583,8 +1583,7 @@ void QColorDialog::setCurrentColor(const QColor &color)
#ifdef Q_WS_MAC
d->setCurrentQColor(color);
- if (d->delegate)
- QColorDialogPrivate::setColor(d->delegate, color);
+ d->setCocoaPanelColor(color);
#endif
}
@@ -1725,19 +1724,16 @@ void QColorDialog::setVisible(bool visible)
#if defined(Q_WS_MAC)
if (visible) {
- if (!d->delegate && QColorDialogPrivate::sharedColorPanelAvailable &&
- !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog))){
- d->delegate = QColorDialogPrivate::openCocoaColorPanel(
- currentColor(), parentWidget(), windowTitle(), options(), d);
+ if (d->delegate || (QColorDialogPrivate::sharedColorPanelAvailable &&
+ !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog)))){
+ d->openCocoaColorPanel(currentColor(), parentWidget(), windowTitle(), options());
QColorDialogPrivate::sharedColorPanelAvailable = false;
setAttribute(Qt::WA_DontShowOnScreen);
}
setWindowFlags(windowModality() == Qt::WindowModal ? Qt::Sheet : DefaultWindowFlags);
} else {
if (d->delegate) {
- QColorDialogPrivate::closeCocoaColorPanel(d->delegate);
- d->delegate = 0;
- QColorDialogPrivate::sharedColorPanelAvailable = true;
+ d->closeCocoaColorPanel();
setAttribute(Qt::WA_DontShowOnScreen, false);
}
}
@@ -1840,6 +1836,14 @@ QRgb QColorDialog::getRgba(QRgb initial, bool *ok, QWidget *parent)
QColorDialog::~QColorDialog()
{
+ Q_D(QColorDialog);
+#if defined(Q_WS_MAC)
+ if (d->delegate) {
+ d->releaseCocoaColorPanelDelegate();
+ QColorDialogPrivate::sharedColorPanelAvailable = true;
+ }
+#endif
+
#ifndef QT_NO_SETTINGS
if (!customSet) {
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
diff --git a/src/gui/dialogs/qcolordialog_mac.mm b/src/gui/dialogs/qcolordialog_mac.mm
index 1936de531..6cdb7eeaf 100644
--- a/src/gui/dialogs/qcolordialog_mac.mm
+++ b/src/gui/dialogs/qcolordialog_mac.mm
@@ -76,6 +76,8 @@ QT_USE_NAMESPACE
CGFloat mMinWidth; // currently unused
CGFloat mExtraHeight; // currently unused
BOOL mHackedPanel;
+ NSInteger mResultCode;
+ BOOL mDialogIsExecuting;
}
- (id)initWithColorPanel:(NSColorPanel *)panel
stolenContentView:(NSView *)stolenContentView
@@ -90,7 +92,8 @@ QT_USE_NAMESPACE
- (NSColorPanel *)colorPanel;
- (QColor)qtColor;
- (void)finishOffWithCode:(NSInteger)result;
-- (void)cleanUpAfterMyself;
+- (void)showColorPanel;
+- (void)exec;
@end
@implementation QCocoaColorPanelDelegate
@@ -110,6 +113,8 @@ QT_USE_NAMESPACE
mMinWidth = 0.0;
mExtraHeight = 0.0;
mHackedPanel = (okButton != 0);
+ mResultCode = NSCancelButton;
+ mDialogIsExecuting = false;
if (mHackedPanel) {
[self relayout];
@@ -121,19 +126,31 @@ QT_USE_NAMESPACE
[cancelButton setTarget:self];
}
- if (mPriv)
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(colorChanged:)
- name:NSColorPanelColorDidChangeNotification
- object:mColorPanel];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(colorChanged:)
+ name:NSColorPanelColorDidChangeNotification
+ object:mColorPanel];
+
mQtColor = new QColor();
return self;
}
- (void)dealloc
{
- if (mPriv)
- [[NSNotificationCenter defaultCenter] removeObserver:self];
+ QMacCocoaAutoReleasePool pool;
+ if (mHackedPanel) {
+ NSView *ourContentView = [mColorPanel contentView];
+
+ // return stolen stuff to its rightful owner
+ [mStolenContentView removeFromSuperview];
+ [mColorPanel setContentView:mStolenContentView];
+
+ [mOkButton release];
+ [mCancelButton release];
+ [ourContentView release];
+ }
+ [mColorPanel setDelegate:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
delete mQtColor;
[super dealloc];
}
@@ -160,8 +177,7 @@ QT_USE_NAMESPACE
- (void)colorChanged:(NSNotification *)notification;
{
Q_UNUSED(notification);
- if (mPriv)
- [self updateQtColor];
+ [self updateQtColor];
}
- (void)relayout
@@ -258,8 +274,7 @@ QT_USE_NAMESPACE
}
}
- if (mPriv)
- mPriv->setCurrentQColor(*mQtColor);
+ mPriv->setCurrentQColor(*mQtColor);
}
- (NSColorPanel *)colorPanel
@@ -274,36 +289,42 @@ QT_USE_NAMESPACE
- (void)finishOffWithCode:(NSInteger)code
{
- if (mPriv) {
- // Finish the QColorDialog as well. But since a call to accept or reject will
- // close down the QEventLoop found in QDialog, we need to make sure that the
- // current thread has exited the native dialogs modal session/run loop first.
- // We ensure this by posting the call:
+ mResultCode = code;
+ if (mDialogIsExecuting) {
+ // We stop the current modal event loop. The control
+ // will then return inside -(void)exec below.
+ // It's important that the modal event loop is stopped before
+ // we accept/reject QColorDialog, since QColorDialog has its
+ // own event loop that needs to be stopped last.
[NSApp stopModalWithCode:code];
- if (code == NSOKButton)
- QMetaObject::invokeMethod(mPriv->colorDialog(), "accept", Qt::QueuedConnection);
- else
- QMetaObject::invokeMethod(mPriv->colorDialog(), "reject", Qt::QueuedConnection);
} else {
- [NSApp stopModalWithCode:code];
+ // Since we are not in a modal event loop, we can safely close
+ // down QColorDialog
+ if (mResultCode == NSCancelButton)
+ mPriv->colorDialog()->reject();
+ else
+ mPriv->colorDialog()->accept();
}
}
-- (void)cleanUpAfterMyself
+- (void)showColorPanel
{
- if (mHackedPanel) {
- NSView *ourContentView = [mColorPanel contentView];
-
- // return stolen stuff to its rightful owner
- [mStolenContentView removeFromSuperview];
- [mColorPanel setContentView:mStolenContentView];
+ mDialogIsExecuting = false;
+ [mColorPanel makeKeyAndOrderFront:mColorPanel];
+}
- [mOkButton release];
- [mCancelButton release];
- [ourContentView release];
- }
- [mColorPanel setDelegate:nil];
+- (void)exec
+{
+ QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
+ QMacCocoaAutoReleasePool pool;
+ mDialogIsExecuting = true;
+ [NSApp runModalForWindow:mColorPanel];
+ if (mResultCode == NSCancelButton)
+ mPriv->colorDialog()->reject();
+ else
+ mPriv->colorDialog()->accept();
}
+
@end
QT_BEGIN_NAMESPACE
@@ -312,91 +333,90 @@ extern void macStartInterceptNSPanelCtor();
extern void macStopInterceptNSPanelCtor();
extern NSButton *macCreateButton(const char *text, NSView *superview);
-void *QColorDialogPrivate::openCocoaColorPanel(const QColor &initial,
- QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options,
- QColorDialogPrivate *priv)
+void QColorDialogPrivate::openCocoaColorPanel(const QColor &initial,
+ QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options)
{
Q_UNUSED(parent); // we would use the parent if only NSColorPanel could be a sheet
QMacCocoaAutoReleasePool pool;
- /*
- The standard Cocoa color panel has no OK or Cancel button and
- is created as a utility window, whereas we want something like
- the Carbon color panel. We need to take the following steps:
+ if (!delegate) {
+ /*
+ The standard Cocoa color panel has no OK or Cancel button and
+ is created as a utility window, whereas we want something like
+ the Carbon color panel. We need to take the following steps:
+
+ 1. Intercept the color panel constructor to turn off the
+ NSUtilityWindowMask flag. This is done by temporarily
+ replacing initWithContentRect:styleMask:backing:defer:
+ in NSPanel by our own method.
- 1. Intercept the color panel constructor to turn off the
- NSUtilityWindowMask flag. This is done by temporarily
- replacing initWithContentRect:styleMask:backing:defer:
- in NSPanel by our own method.
+ 2. Modify the color panel so that its content view is part
+ of a new content view that contains it as well as two
+ buttons (OK and Cancel).
- 2. Modify the color panel so that its content view is part
- of a new content view that contains it as well as two
- buttons (OK and Cancel).
+ 3. Lay out the original content view and the buttons when
+ the color panel is shown and whenever it is resized.
- 3. Lay out the original content view and the buttons when
- the color panel is shown and whenever it is resized.
+ 4. Clean up after ourselves.
+ */
- 4. Clean up after ourselves.
- */
+ bool hackColorPanel = !(options & QColorDialog::NoButtons);
- bool hackColorPanel = !(options & QColorDialog::NoButtons);
+ if (hackColorPanel)
+ macStartInterceptNSPanelCtor();
+ NSColorPanel *colorPanel = [NSColorPanel sharedColorPanel];
+ if (hackColorPanel)
+ macStopInterceptNSPanelCtor();
- if (hackColorPanel)
- macStartInterceptNSPanelCtor();
- NSColorPanel *colorPanel = [NSColorPanel sharedColorPanel];
- if (hackColorPanel)
- macStopInterceptNSPanelCtor();
+ [colorPanel setHidesOnDeactivate:false];
- [colorPanel setHidesOnDeactivate:false];
+ // set up the Cocoa color panel
+ [colorPanel setShowsAlpha:options & QColorDialog::ShowAlphaChannel];
+ [colorPanel setTitle:(NSString*)(CFStringRef)QCFString(title)];
- // set up the Cocoa color panel
- [colorPanel setShowsAlpha:options & QColorDialog::ShowAlphaChannel];
- [colorPanel setTitle:(NSString*)(CFStringRef)QCFString(title)];
+ NSView *stolenContentView = 0;
+ NSButton *okButton = 0;
+ NSButton *cancelButton = 0;
- NSView *stolenContentView = 0;
- NSButton *okButton = 0;
- NSButton *cancelButton = 0;
+ if (hackColorPanel) {
+ // steal the color panel's contents view
+ stolenContentView = [colorPanel contentView];
+ [stolenContentView retain];
+ [colorPanel setContentView:0];
- if (hackColorPanel) {
- // steal the color panel's contents view
- stolenContentView = [colorPanel contentView];
- [stolenContentView retain];
- [colorPanel setContentView:0];
+ // create a new content view and add the stolen one as a subview
+ NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
+ NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect];
+ [ourContentView addSubview:stolenContentView];
- // create a new content view and add the stolen one as a subview
- NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
- NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect];
- [ourContentView addSubview:stolenContentView];
+ // create OK and Cancel buttons and add these as subviews
+ okButton = macCreateButton("&OK", ourContentView);
+ cancelButton = macCreateButton("Cancel", ourContentView);
- // create OK and Cancel buttons and add these as subviews
- okButton = macCreateButton("&OK", ourContentView);
- cancelButton = macCreateButton("Cancel", ourContentView);
+ [colorPanel setContentView:ourContentView];
+ [colorPanel setDefaultButtonCell:[okButton cell]];
+ }
- [colorPanel setContentView:ourContentView];
- [colorPanel setDefaultButtonCell:[okButton cell]];
+ delegate = [[QCocoaColorPanelDelegate alloc] initWithColorPanel:colorPanel
+ stolenContentView:stolenContentView
+ okButton:okButton
+ cancelButton:cancelButton
+ priv:this];
+ [colorPanel setDelegate:static_cast<QCocoaColorPanelDelegate *>(delegate)];
}
- // create a delegate and set it
- QCocoaColorPanelDelegate *delegate =
- [[QCocoaColorPanelDelegate alloc] initWithColorPanel:colorPanel
- stolenContentView:stolenContentView
- okButton:okButton
- cancelButton:cancelButton
- priv:priv];
- [colorPanel setDelegate:delegate];
- setColor(delegate, initial);
- [colorPanel makeKeyAndOrderFront:colorPanel];
-
- return delegate;
+ setCocoaPanelColor(initial);
+ [static_cast<QCocoaColorPanelDelegate *>(delegate) showColorPanel];
}
-void QColorDialogPrivate::closeCocoaColorPanel(void *delegate)
+void QColorDialogPrivate::closeCocoaColorPanel()
{
- QMacCocoaAutoReleasePool pool;
- QCocoaColorPanelDelegate *theDelegate = static_cast<QCocoaColorPanelDelegate *>(delegate);
- [[theDelegate colorPanel] close];
- [theDelegate cleanUpAfterMyself];
- [theDelegate autorelease];
+ [[static_cast<QCocoaColorPanelDelegate *>(delegate) colorPanel] close];
+}
+
+void QColorDialogPrivate::releaseCocoaColorPanelDelegate()
+{
+ [static_cast<QCocoaColorPanelDelegate *>(delegate) release];
}
void QColorDialogPrivate::mac_nativeDialogModalHelp()
@@ -416,13 +436,10 @@ void QColorDialogPrivate::mac_nativeDialogModalHelp()
void QColorDialogPrivate::_q_macRunNativeAppModalPanel()
{
- QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
- QMacCocoaAutoReleasePool pool;
- QCocoaColorPanelDelegate *delegateCasted = static_cast<QCocoaColorPanelDelegate *>(delegate);
- [NSApp runModalForWindow:[delegateCasted colorPanel]];
+ [static_cast<QCocoaColorPanelDelegate *>(delegate) exec];
}
-void QColorDialogPrivate::setColor(void *delegate, const QColor &color)
+void QColorDialogPrivate::setCocoaPanelColor(const QColor &color)
{
QMacCocoaAutoReleasePool pool;
QCocoaColorPanelDelegate *theDelegate = static_cast<QCocoaColorPanelDelegate *>(delegate);
diff --git a/src/gui/dialogs/qcolordialog_p.h b/src/gui/dialogs/qcolordialog_p.h
index ea66d4aae..00d40b6fa 100644
--- a/src/gui/dialogs/qcolordialog_p.h
+++ b/src/gui/dialogs/qcolordialog_p.h
@@ -116,14 +116,11 @@ public:
QByteArray memberToDisconnectOnClose;
#ifdef Q_WS_MAC
- static void *openCocoaColorPanel(const QColor &initial,
- QWidget *parent, const QString &title,
- QColorDialog::ColorDialogOptions options,
- QColorDialogPrivate *priv = 0);
- static void closeCocoaColorPanel(void *delegate);
- static QColor execCocoaColorPanel(const QColor &initial, QWidget *parent,
- const QString &title, QColorDialog::ColorDialogOptions options);
- static void setColor(void *delegate, const QColor &color);
+ void openCocoaColorPanel(const QColor &initial,
+ QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options);
+ void closeCocoaColorPanel();
+ void releaseCocoaColorPanelDelegate();
+ void setCocoaPanelColor(const QColor &color);
inline void done(int result) { q_func()->done(result); }
inline QColorDialog *colorDialog() { return q_func(); }
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp
index 5a5d845a1..b8e12b493 100644
--- a/src/gui/dialogs/qfilesystemmodel.cpp
+++ b/src/gui/dialogs/qfilesystemmodel.cpp
@@ -872,6 +872,7 @@ QVariant QFileSystemModel::headerData(int section, Qt::Orientation orientation,
pixmap.setAlphaChannel(pixmap.createAlphaMask());
return pixmap;
}
+ break;
case Qt::TextAlignmentRole:
return Qt::AlignLeft;
}
diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp
index be89efe78..daaa4ba12 100644
--- a/src/gui/egl/qegl_x11.cpp
+++ b/src/gui/egl/qegl_x11.cpp
@@ -125,7 +125,17 @@ void QEglProperties::setVisualFormat(const QX11Info *xinfo)
setValue(EGL_RED_SIZE, countBits(visual->red_mask));
setValue(EGL_GREEN_SIZE, countBits(visual->green_mask));
setValue(EGL_BLUE_SIZE, countBits(visual->blue_mask));
- setValue(EGL_ALPHA_SIZE, 0); // XXX
+
+ EGLint alphaBits = 0;
+#if !defined(QT_NO_XRENDER)
+ XRenderPictFormat *format;
+ format = XRenderFindVisualFormat(xinfo->display(), visual);
+ if (format && (format->type == PictTypeDirect) && format->direct.alphaMask) {
+ alphaBits = countBits(format->direct.alphaMask);
+ qDebug("QEglProperties::setVisualFormat() - visual's alphaMask is %d", alphaBits);
+ }
+#endif
+ setValue(EGL_ALPHA_SIZE, alphaBits);
}
extern const QX11Info *qt_x11Info(const QPaintDevice *pd);
diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp
index e0ae8a65d..358ebccb3 100644
--- a/src/gui/egl/qeglproperties.cpp
+++ b/src/gui/egl/qeglproperties.cpp
@@ -46,12 +46,26 @@ QT_BEGIN_NAMESPACE
#include <QtCore/qdebug.h>
#include <QtCore/qstringlist.h>
+#include "qegl_p.h"
+
+
// Initialize a property block.
QEglProperties::QEglProperties()
{
props.append(EGL_NONE);
}
+QEglProperties::QEglProperties(EGLConfig cfg)
+{
+ props.append(EGL_NONE);
+ for (int name = 0x3020; name <= 0x304F; ++name) {
+ EGLint value;
+ if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::defaultDisplay(0), cfg, name, &value))
+ setValue(name, value);
+ }
+ eglGetError(); // Clear the error state.
+}
+
// Fetch the current value associated with a property.
int QEglProperties::value(int name) const
{
@@ -215,12 +229,21 @@ bool QEglProperties::reduceConfiguration()
removeValue(EGL_SAMPLES);
return true;
}
- if (removeValue(EGL_ALPHA_SIZE))
+ if (removeValue(EGL_ALPHA_SIZE)) {
+#if defined(EGL_BIND_TO_TEXTURE_RGBA) && defined(EGL_BIND_TO_TEXTURE_RGB)
+ if (removeValue(EGL_BIND_TO_TEXTURE_RGBA))
+ setValue(EGL_BIND_TO_TEXTURE_RGB, TRUE);
+#endif
return true;
+ }
if (removeValue(EGL_STENCIL_SIZE))
return true;
if (removeValue(EGL_DEPTH_SIZE))
return true;
+#if defined(EGL_BIND_TO_TEXTURE_RGB)
+ if (removeValue(EGL_BIND_TO_TEXTURE_RGB))
+ return true;
+#endif
return false;
}
diff --git a/src/gui/egl/qeglproperties_p.h b/src/gui/egl/qeglproperties_p.h
index 81af4cd41..bcdc65737 100644
--- a/src/gui/egl/qeglproperties_p.h
+++ b/src/gui/egl/qeglproperties_p.h
@@ -107,6 +107,7 @@ class Q_GUI_EXPORT QEglProperties
{
public:
QEglProperties();
+ QEglProperties(EGLConfig);
QEglProperties(const QEglProperties& other) : props(other.props) {}
~QEglProperties() {}
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp
index 45392f160..556889832 100644
--- a/src/gui/image/qpixmap_mac.cpp
+++ b/src/gui/image/qpixmap_mac.cpp
@@ -1178,6 +1178,7 @@ QPixmap QPixmap::fromMacCGImageRef(CGImageRef image)
const size_t w = CGImageGetWidth(image),
h = CGImageGetHeight(image);
QPixmap ret(w, h);
+ ret.fill(Qt::transparent);
CGRect rect = CGRectMake(0, 0, w, h);
CGContextRef ctx = qt_mac_cg_context(&ret);
qt_mac_drawCGImage(ctx, &rect, image);
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index beccfb0d3..ac132aa32 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -1480,6 +1480,7 @@ QWidget *QApplicationPrivate::tryModalHelper_sys(QWidget *top)
return top;
}
+#ifndef QT_MAC_USE_COCOA
static bool qt_try_modal(QWidget *widget, EventRef event)
{
QWidget * top = 0;
@@ -1513,6 +1514,7 @@ static bool qt_try_modal(QWidget *widget, EventRef event)
#endif
return !block_event;
}
+#endif
OSStatus QApplicationPrivate::tabletProximityCallback(EventHandlerCallRef, EventRef carbonEvent,
void *)
@@ -2890,52 +2892,25 @@ bool QApplicationPrivate::canQuit()
#endif
}
-void onApplicationWindowChangedActivation( QWidget*widget, bool activated )
+void onApplicationWindowChangedActivation(QWidget *widget, bool activated)
{
#if QT_MAC_USE_COCOA
- QApplication *app = qApp;
+ if (!widget)
+ return;
- if ( activated )
- {
- if (QApplicationPrivate::app_style)
- {
+ if (activated) {
+ if (QApplicationPrivate::app_style) {
QEvent ev(QEvent::Style);
qt_sendSpontaneousEvent(QApplicationPrivate::app_style, &ev);
}
-
- if (widget && app_do_modal && !qt_try_modal(widget, NULL))
- return;
-
- if (widget && widget->window()->isVisible())
- {
- QWidget *tlw = widget->window();
-
- if (tlw->isWindow() && !(tlw->windowType() == Qt::Popup)
- && !qt_mac_is_macdrawer(tlw)
- && (!tlw->parentWidget() || tlw->isModal() || !(tlw->windowType() == Qt::Tool))) {
- bool just_send_event = false;
-#if 0
- WindowActivationScope scope;
- if ( GetWindowActivationScope((OSWindowRef)wid, &scope) == noErr &&
- scope == kWindowActivationScopeIndependent)
- {
- if ( GetFrontWindowOfClass(kAllWindowClasses, true) != wid )
- just_send_event = true;
- }
-#endif
- if (just_send_event) {
- QEvent e(QEvent::WindowActivate);
- qt_sendSpontaneousEvent(widget, &e);
- } else {
- app->setActiveWindow(tlw);
- }
- }
- }
+ qApp->setActiveWindow(widget);
} else { // deactivated
- if (widget && QApplicationPrivate::active_window == widget)
- app->setActiveWindow(0);
+ if (QApplicationPrivate::active_window == widget)
+ qApp->setActiveWindow(0);
}
+
QMenuBar::macUpdateMenuBar();
+
#else
Q_UNUSED(widget);
Q_UNUSED(activated);
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 57c911783..1d352cb3a 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -327,7 +327,7 @@ extern "C" {
return NSDragOperationNone;
} else {
// save the mouse position, used by draggingExited handler.
- DnDParams *dndParams = [QCocoaView currentMouseEvent];
+ DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent];
dndParams->activeDragEnterPos = windowPoint;
// send a drag move event immediately after a drag enter event (as per documentation).
QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
@@ -406,7 +406,7 @@ extern "C" {
dragEnterSequence = -1;
if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) {
// try sending the leave event to the last view which accepted drag enter.
- DnDParams *dndParams = [QCocoaView currentMouseEvent];
+ DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent];
NSView *candidateView = [[[self window] contentView] hitTest:dndParams->activeDragEnterPos];
if (candidateView && candidateView != self)
return [candidateView draggingExited:sender];
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp
index 9cca0d661..0b47b6f56 100644
--- a/src/gui/kernel/qcursor.cpp
+++ b/src/gui/kernel/qcursor.cpp
@@ -127,11 +127,11 @@ QT_BEGIN_NAMESPACE
\o Qt::SizeAllCursor \o \c size_all
\row \o \inlineimage cursor-busy.png
\o Qt::BusyCursor \o \c left_ptr_watch
- \o \inlineimage cursor-hsplit.png
+ \o \inlineimage cursor-vsplit.png
\o Qt::SplitVCursor \o \c split_v
\row \o \inlineimage cursor-forbidden.png
\o Qt::ForbiddenCursor \o \c forbidden
- \o \inlineimage cursor-vsplit.png
+ \o \inlineimage cursor-hsplit.png
\o Qt::SplitHCursor \o \c split_h
\row \o \inlineimage cursor-hand.png
\o Qt::PointingHandCursor \o \c pointing_hand
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 6ee229a64..43ac37d17 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -9865,6 +9865,10 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
data->window_modality = (w && w->testAttribute(Qt::WA_GroupLeader))
? Qt::WindowModal
: Qt::ApplicationModal;
+ // Some window managers does not allow us to enter modal after the
+ // window is showing. Therefore, to be consistent, we cannot call
+ // QApplicationPrivate::enterModal(this) here. The window must be
+ // hidden before changing modality.
}
if (testAttribute(Qt::WA_WState_Created)) {
// don't call setModal_sys() before create_sys()
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 3bbf5d4df..78df09da0 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -4589,6 +4589,7 @@ void QWidgetPrivate::setModal_sys()
OSWindowRef windowRef = qt_mac_window_for(q);
#ifdef QT_MAC_USE_COCOA
+ QMacCocoaAutoReleasePool pool;
bool alreadySheet = [windowRef styleMask] & NSDocModalWindowMask;
if (windowParent && q->windowModality() == Qt::WindowModal){
@@ -4665,31 +4666,40 @@ void QWidgetPrivate::setModal_sys()
|| (primaryWindow && primaryWindow->windowModality() == Qt::WindowModal)){
// Window should be window-modal (which implies a sheet).
if (old_wclass != kSheetWindowClass){
- // We cannot convert a created window to a sheet. So we recreate the window:
+ // We cannot convert a created window to a sheet.
+ // So we recreate the window:
recreateMacWindow();
return;
}
- } else if (!(q->data->window_flags & Qt::CustomizeWindowHint)) {
- if (old_wclass == kDocumentWindowClass || old_wclass == kFloatingWindowClass || old_wclass == kUtilityWindowClass){
- // Only change the class to kMovableModalWindowClass if the no explicit jewels
- // are set (kMovableModalWindowClass can't contain them), and the current window class
- // can be converted to modal (according to carbon doc). Mind the order of
- // HIWindowChangeClass and ChangeWindowAttributes.
- WindowGroupRef group = GetWindowGroup(windowRef);
- HIWindowChangeClass(windowRef, kMovableModalWindowClass);
- quint32 tmpWattr = kWindowCloseBoxAttribute | kWindowHorizontalZoomAttribute;
- ChangeWindowAttributes(windowRef, tmpWattr, kWindowNoAttributes);
- ChangeWindowAttributes(windowRef, kWindowNoAttributes, tmpWattr);
- // If the window belongs to a qt-created group, set that group once more:
- if (data.window_flags & Qt::WindowStaysOnTopHint
- || q->windowType() == Qt::Popup
- || q->windowType() == Qt::ToolTip)
- SetWindowGroup(windowRef, group);
+ } else {
+ // Window should be application-modal (which implies NOT using a sheet).
+ if (old_wclass == kSheetWindowClass){
+ // We cannot convert a sheet to a window.
+ // So we recreate the window:
+ recreateMacWindow();
+ return;
+ } else if (!(q->data->window_flags & Qt::CustomizeWindowHint)) {
+ if (old_wclass == kDocumentWindowClass || old_wclass == kFloatingWindowClass || old_wclass == kUtilityWindowClass){
+ // Only change the class to kMovableModalWindowClass if the no explicit jewels
+ // are set (kMovableModalWindowClass can't contain them), and the current window class
+ // can be converted to modal (according to carbon doc). Mind the order of
+ // HIWindowChangeClass and ChangeWindowAttributes.
+ WindowGroupRef group = GetWindowGroup(windowRef);
+ HIWindowChangeClass(windowRef, kMovableModalWindowClass);
+ quint32 tmpWattr = kWindowCloseBoxAttribute | kWindowHorizontalZoomAttribute;
+ ChangeWindowAttributes(windowRef, tmpWattr, kWindowNoAttributes);
+ ChangeWindowAttributes(windowRef, kWindowNoAttributes, tmpWattr);
+ // If the window belongs to a qt-created group, set that group once more:
+ if (data.window_flags & Qt::WindowStaysOnTopHint
+ || q->windowType() == Qt::Popup
+ || q->windowType() == Qt::ToolTip)
+ SetWindowGroup(windowRef, group);
+ }
+ // Popups are usually handled "special" and are never modal.
+ Qt::WindowType winType = q->windowType();
+ if (winType != Qt::Popup && winType != Qt::ToolTip)
+ SetWindowModality(windowRef, kWindowModalityAppModal, 0);
}
- // Popups are usually handled "special" and are never modal.
- Qt::WindowType winType = q->windowType();
- if (winType != Qt::Popup && winType != Qt::ToolTip)
- SetWindowModality(windowRef, kWindowModalityAppModal, 0);
}
} else if (windowRef) {
if (old_wclass == kSheetWindowClass){
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 2f230d744..b11b661d8 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -1432,10 +1432,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
qt_wince_maximize(q);
} else {
#endif
- if (!isTranslucentWindow)
- MoveWindow(q->internalWinId(), fs.x(), fs.y(), fs.width(), fs.height(), true);
- else if (isMove && !isResize)
- SetWindowPos(q->internalWinId(), 0, fs.x(), fs.y(), 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
+ MoveWindow(q->internalWinId(), fs.x(), fs.y(), fs.width(), fs.height(), true);
}
if (!q->isVisible())
InvalidateRect(q->internalWinId(), 0, FALSE);
diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp
index 831d38917..fc2eb60dc 100644
--- a/src/gui/painting/qblendfunctions.cpp
+++ b/src/gui/painting/qblendfunctions.cpp
@@ -223,8 +223,8 @@ void qt_scale_image_16bit(uchar *destPixels, int dbpl,
int h = ty2 - ty1;
int w = tx2 - tx1;
- const int dstx = int((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix);
- const int dsty = int((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy);
+ const int dstx = qCeil((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix) - 1;
+ const int dsty = qCeil((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy) - 1;
quint32 basex = quint32((sx < 0 ? srcRect.right() : srcRect.left()) * 65536) + dstx;
quint32 srcy = quint32((sy < 0 ? srcRect.bottom() : srcRect.top()) * 65536) + dsty;
@@ -723,8 +723,8 @@ template <typename T> void qt_scale_image_32bit(uchar *destPixels, int dbpl,
int h = ty2 - ty1;
int w = tx2 - tx1;
- const int dstx = int((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix);
- const int dsty = int((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy);
+ const int dstx = qCeil((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix) - 1;
+ const int dsty = qCeil((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy) - 1;
quint32 basex = quint32((sx < 0 ? srcRect.right() : srcRect.left()) * 65536) + dstx;
quint32 srcy = quint32((sy < 0 ? srcRect.bottom() : srcRect.top()) * 65536) + dsty;
diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h
index b568f43ce..275ec13d7 100644
--- a/src/gui/painting/qdatabuffer_p.h
+++ b/src/gui/painting/qdatabuffer_p.h
@@ -114,23 +114,6 @@ public:
qSwap(buffer, other.buffer);
}
- inline void insertBlank(int pos, int count) {
- Q_ASSERT(pos >= 0);
- Q_ASSERT(pos < siz);
- reserve(siz + count);
- for (int i = siz - pos - 1; i >= 0; --i)
- buffer[pos + count + i] = buffer[pos + i];
- siz += count;
- }
-
- inline void removeAndShift(int pos, int count) {
- Q_ASSERT(pos >= 0);
- Q_ASSERT(pos < siz);
- for (int i=pos; i<siz-count; ++i)
- buffer[i] = buffer[i+count];
- siz -= count;
- }
-
inline QDataBuffer &operator<<(const Type &t) { add(t); return *this; }
private:
diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp
index 9c073f29b..70125b9ea 100644
--- a/src/gui/painting/qoutlinemapper.cpp
+++ b/src/gui/painting/qoutlinemapper.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include "qoutlinemapper_p.h"
-#include "qbezier_p.h"
#include "qmath.h"
@@ -199,70 +198,28 @@ void QOutlineMapper::endOutline()
m_m22 * e.y() + m_m12 * e.x() + m_dy);
}
} else {
- // ## TODO: this case needs to be plain code polygonal paths
- QTransform matrix(m_m11, m_m12, m_m13, m_m21, m_m22, m_m23, m_dx, m_dy, m_m33);
-
- if (m_element_types.isEmpty()) {
- if (!m_elements.isEmpty())
- m_elements_dev << m_elements.at(0) * matrix;
- for (int i=1; i<m_elements.size(); ++i)
- m_elements_dev << m_elements.at(i) * matrix;
-
- } else {
- for (int i=0, t=0; i<m_elements.size(); ++i) {
- switch (m_element_types.at(t)) {
- case QPainterPath::MoveToElement:
- m_elements_dev << m_elements.at(i) * matrix;
- ++t;
- break;
- case QPainterPath::LineToElement:
- m_elements_dev << m_elements.at(i) * matrix;
- ++t;
- break;
- case QPainterPath::CurveToElement: {
- QPolygonF segment = QBezier::fromPoints(m_elements.at(i-1),
- m_elements.at(i),
- m_elements.at(i+1),
- m_elements.at(i+2)).toPolygon();
- if (segment.size() > 3)
- m_element_types.insertBlank(t, segment.size() - 3);
- else if (segment.size() < 3)
- m_element_types.removeAndShift(t, 3 - segment.size());
-
- for (QPolygonF::const_iterator it = segment.constBegin();
- it < segment.constEnd(); ++it, ++t) {
- m_elements_dev << *it * matrix;
- m_element_types.at(t) = QPainterPath::LineToElement;
- }
- i += 2;
- } break;
- default:
- Q_ASSERT(false);
- break;
- }
- }
- element_count = m_elements_dev.size();
- }
+ const QVectorPath vp((qreal *)m_elements.data(), m_elements.size(), m_element_types.data());
+ QPainterPath path = vp.convertToPainterPath();
+ path = QTransform(m_m11, m_m12, m_m13, m_m21, m_m22, m_m23, m_dx, m_dy, m_m33).map(path);
+ uint old_txop = m_txop;
+ m_txop = QTransform::TxNone;
+ if (path.isEmpty())
+ m_valid = false;
+ else
+ convertPath(path);
+ m_txop = old_txop;
+ return;
}
elements = m_elements_dev.data();
}
if (m_round_coords) {
// round coordinates to match outlines drawn with drawLine_midpoint_i
- for (int i = 0; i < element_count; ++i)
+ for (int i = 0; i < m_elements.size(); ++i)
elements[i] = QPointF(qFloor(elements[i].x() + aliasedCoordinateDelta),
qFloor(elements[i].y() + aliasedCoordinateDelta));
}
-#ifdef QT_DEBUG_CONVERT
- for (int i=0; i<element_count; ++i) {
- printf("%d: (%.2f, %.2f)\n",
- !m_element_types.isEmpty() ? m_element_types.at(i) : -1,
- elements[i].x(),
- elements[i].y());
- }
-#endif
-
controlPointRect = boundingRect(elements, element_count);
#ifdef QT_DEBUG_CONVERT
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 69e490a5a..74456dde4 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -1736,6 +1736,8 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
const QLineF *lines = reinterpret_cast<const QLineF *>(path.points());
for (int i = 0; i < lineCount; ++i) {
+ if (path.shape() == QVectorPath::LinesHint)
+ dashOffset = s->lastPen.dashOffset();
if (lines[i].p1() == lines[i].p2()) {
if (s->lastPen.capStyle() != Qt::FlatCap) {
QPointF p = lines[i].p1();
@@ -3454,8 +3456,8 @@ void QRasterPaintEngine::drawLines(const QLine *lines, int lineCount)
int m22 = int(s->matrix.m22());
int dx = qFloor(s->matrix.dx() + aliasedCoordinateDelta);
int dy = qFloor(s->matrix.dy() + aliasedCoordinateDelta);
- int dashOffset = int(s->lastPen.dashOffset());
for (int i=0; i<lineCount; ++i) {
+ int dashOffset = int(s->lastPen.dashOffset());
if (s->flags.int_xform) {
const QLine &l = lines[i];
int x1 = l.x1() * m11 + dx;
@@ -3554,8 +3556,8 @@ void QRasterPaintEngine::drawLines(const QLineF *lines, int lineCount)
? LineDrawNormal
: LineDrawIncludeLastPixel;
- int dashOffset = int(s->lastPen.dashOffset());
for (int i=0; i<lineCount; ++i) {
+ int dashOffset = int(s->lastPen.dashOffset());
QLineF line = (lines[i] * s->matrix).translated(aliasedCoordinateDelta, aliasedCoordinateDelta);
const QRectF brect(QPointF(line.x1(), line.y1()),
QPointF(line.x2(), line.y2()));
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 8ec881ef7..ed9b8586d 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -421,7 +421,6 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
const qreal *lastPoint = points + (pointCount<<1);
- d->activeStroker->begin(d->strokeHandler);
d->strokeHandler->types.reset();
d->strokeHandler->pts.reset();
@@ -430,13 +429,13 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin)
flags |= QVectorPath::CurvedShapeHint;
- // ### Perspective Xforms are currently not supported...
qreal txscale = 1;
if (!(pen.isCosmetic() || (qt_scaleForTransform(state()->matrix, &txscale) && txscale != 1))) {
// We include cosmetic pens in this case to avoid having to
// change the current transform. Normal transformed,
// non-cosmetic pens will be transformed as part of fill
// later, so they are also covered here..
+ d->activeStroker->begin(d->strokeHandler);
if (types) {
while (points < lastPoint) {
switch (*types) {
@@ -491,79 +490,64 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
const qreal strokeWidth = d->stroker.strokeWidth();
d->stroker.setStrokeWidth(strokeWidth * txscale);
// For cosmetic pens we need a bit of trickery... We to process xform the input points
- if (types) {
- bool isProject = state()->matrix.type() >= QTransform::TxProject;
- while (points < lastPoint) {
- switch (*types) {
- case QPainterPath::MoveToElement: {
- QPointF pt = (*(QPointF *) points) * state()->matrix;
- d->activeStroker->moveTo(pt.x(), pt.y());
- points += 2;
- ++types;
- break;
- }
- case QPainterPath::LineToElement: {
- QPointF pt = (*(QPointF *) points) * state()->matrix;
- d->activeStroker->lineTo(pt.x(), pt.y());
- points += 2;
- ++types;
- break;
- }
- case QPainterPath::CurveToElement: {
- // Convert projective xformed curves to line
- // segments so they can be transformed more
- // accurately
- if (isProject) {
- // -1 access here is safe because there is
- // always an element prior to the cubicTo, we
- // just need the value..
- QPolygonF segment =
- QBezier::fromPoints(*(((QPointF *) points) - 1),
- *((QPointF *) points),
- *(((QPointF *) points) + 1),
- *(((QPointF *) points) + 2)).toPolygon();
-
- for (QPolygonF::const_iterator it = segment.constBegin();
- it < segment.constEnd(); ++it) {
- const QPointF pt = *it * state()->matrix;
- d->activeStroker->lineTo(pt.x(), pt.y());
- }
- } else {
+ if (state()->matrix.type() >= QTransform::TxProject) {
+ QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath());
+ d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform());
+ } else {
+ d->activeStroker->begin(d->strokeHandler);
+ if (types) {
+ while (points < lastPoint) {
+ switch (*types) {
+ case QPainterPath::MoveToElement: {
+ QPointF pt = (*(QPointF *) points) * state()->matrix;
+ d->activeStroker->moveTo(pt.x(), pt.y());
+ points += 2;
+ ++types;
+ break;
+ }
+ case QPainterPath::LineToElement: {
+ QPointF pt = (*(QPointF *) points) * state()->matrix;
+ d->activeStroker->lineTo(pt.x(), pt.y());
+ points += 2;
+ ++types;
+ break;
+ }
+ case QPainterPath::CurveToElement: {
QPointF c1 = ((QPointF *) points)[0] * state()->matrix;
QPointF c2 = ((QPointF *) points)[1] * state()->matrix;
QPointF e = ((QPointF *) points)[2] * state()->matrix;
d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y());
+ points += 6;
+ types += 3;
+ flags |= QVectorPath::CurvedShapeHint;
+ break;
+ }
+ default:
+ break;
}
- points += 6;
- types += 3;
- flags |= QVectorPath::CurvedShapeHint;
- break;
}
- default:
- break;
+ if (path.hasImplicitClose()) {
+ QPointF pt = * ((QPointF *) path.points()) * state()->matrix;
+ d->activeStroker->lineTo(pt.x(), pt.y());
}
- }
- if (path.hasImplicitClose()) {
- QPointF pt = * ((QPointF *) path.points()) * state()->matrix;
- d->activeStroker->lineTo(pt.x(), pt.y());
- }
- } else {
- QPointF p = ((QPointF *)points)[0] * state()->matrix;
- d->activeStroker->moveTo(p.x(), p.y());
- points += 2;
- ++types;
- while (points < lastPoint) {
+ } else {
QPointF p = ((QPointF *)points)[0] * state()->matrix;
- d->activeStroker->lineTo(p.x(), p.y());
+ d->activeStroker->moveTo(p.x(), p.y());
points += 2;
++types;
+ while (points < lastPoint) {
+ QPointF p = ((QPointF *)points)[0] * state()->matrix;
+ d->activeStroker->lineTo(p.x(), p.y());
+ points += 2;
+ ++types;
+ }
+ if (path.hasImplicitClose())
+ d->activeStroker->lineTo(p.x(), p.y());
}
- if (path.hasImplicitClose())
- d->activeStroker->lineTo(p.x(), p.y());
+ d->activeStroker->end();
}
- d->activeStroker->end();
d->stroker.setStrokeWidth(strokeWidth);
QVectorPath strokePath(d->strokeHandler->pts.data(),
d->strokeHandler->types.size(),
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index a322fe4de..0a64e4ede 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -48,6 +48,8 @@
#include "qvariant.h"
#include <qmath.h>
+#include <private/qbezier_p.h>
+
QT_BEGIN_NAMESPACE
#define Q_NEAR_CLIP 0.000001
@@ -1492,27 +1494,12 @@ static inline bool lineTo_clipped(QPainterPath &path, const QTransform &transfor
static inline bool cubicTo_clipped(QPainterPath &path, const QTransform &transform, const QPointF &a, const QPointF &b, const QPointF &c, const QPointF &d, bool needsMoveTo)
{
- const QHomogeneousCoordinate ha = mapHomogeneous(transform, a);
- const QHomogeneousCoordinate hb = mapHomogeneous(transform, b);
- const QHomogeneousCoordinate hc = mapHomogeneous(transform, c);
- const QHomogeneousCoordinate hd = mapHomogeneous(transform, d);
-
- if (ha.w < Q_NEAR_CLIP && hb.w < Q_NEAR_CLIP && hc.w < Q_NEAR_CLIP && hd.w < Q_NEAR_CLIP)
- return false;
+ // Convert projective xformed curves to line
+ // segments so they can be transformed more accurately
+ QPolygonF segment = QBezier::fromPoints(a, b, c, d).toPolygon();
- if (ha.w >= Q_NEAR_CLIP && hb.w >= Q_NEAR_CLIP && hc.w >= Q_NEAR_CLIP && hd.w >= Q_NEAR_CLIP) {
- if (needsMoveTo)
- path.moveTo(ha.toPoint());
-
- path.cubicTo(hb.toPoint(), hc.toPoint(), hd.toPoint());
- return true;
- }
-
- if (lineTo_clipped(path, transform, a, b, needsMoveTo))
- needsMoveTo = false;
- if (lineTo_clipped(path, transform, b, c, needsMoveTo))
- needsMoveTo = false;
- if (lineTo_clipped(path, transform, c, d, needsMoveTo))
+ for (int i = 0; i < segment.size() - 1; ++i)
+ if (lineTo_clipped(path, transform, segment.at(i), segment.at(i+1), needsMoveTo))
needsMoveTo = false;
return !needsMoveTo;
@@ -1793,6 +1780,14 @@ void QTransform::setMatrix(qreal m11, qreal m12, qreal m13,
m_dirty = TxProject;
}
+static inline bool needsPerspectiveClipping(const QRectF &rect, const QTransform &transform)
+{
+ const qreal wx = qMin(transform.m13() * rect.left(), transform.m13() * rect.right());
+ const qreal wy = qMin(transform.m23() * rect.top(), transform.m23() * rect.bottom());
+
+ return wx + wy + transform.m33() < Q_NEAR_CLIP;
+}
+
QRect QTransform::mapRect(const QRect &rect) const
{
TransformationType t = inline_type();
@@ -1813,7 +1808,7 @@ QRect QTransform::mapRect(const QRect &rect) const
y -= h;
}
return QRect(x, y, w, h);
- } else {
+ } else if (t < TxProject || !needsPerspectiveClipping(rect, *this)) {
// see mapToPolygon for explanations of the algorithm.
qreal x = 0, y = 0;
MAP(rect.left(), rect.top(), x, y);
@@ -1837,6 +1832,10 @@ QRect QTransform::mapRect(const QRect &rect) const
xmax = qMax(xmax, x);
ymax = qMax(ymax, y);
return QRect(qRound(xmin), qRound(ymin), qRound(xmax)-qRound(xmin), qRound(ymax)-qRound(ymin));
+ } else {
+ QPainterPath path;
+ path.addRect(rect);
+ return map(path).boundingRect().toRect();
}
}
@@ -1879,7 +1878,7 @@ QRectF QTransform::mapRect(const QRectF &rect) const
y -= h;
}
return QRectF(x, y, w, h);
- } else {
+ } else if (t < TxProject || !needsPerspectiveClipping(rect, *this)) {
qreal x = 0, y = 0;
MAP(rect.x(), rect.y(), x, y);
qreal xmin = x;
@@ -1902,6 +1901,10 @@ QRectF QTransform::mapRect(const QRectF &rect) const
xmax = qMax(xmax, x);
ymax = qMax(ymax, y);
return QRectF(xmin, ymin, xmax-xmin, ymax - ymin);
+ } else {
+ QPainterPath path;
+ path.addRect(rect);
+ return map(path).boundingRect();
}
}
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp
index 22433dd37..eddbfd2da 100644
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ b/src/gui/painting/qwindowsurface_raster.cpp
@@ -118,7 +118,7 @@ QPaintDevice *QRasterWindowSurface::paintDevice()
void QRasterWindowSurface::beginPaint(const QRegion &rgn)
{
#if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_WS_WINCE))
- if (!qt_widget_private(window())->isOpaque) {
+ if (!qt_widget_private(window())->isOpaque && window()->testAttribute(Qt::WA_TranslucentBackground)) {
#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
if (d_ptr->image->image.format() != QImage::Format_ARGB32_Premultiplied)
prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
@@ -149,7 +149,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
QRect br = rgn.boundingRect();
#ifndef Q_WS_WINCE
- if (!qt_widget_private(window())->isOpaque) {
+ if (!qt_widget_private(window())->isOpaque && window()->testAttribute(Qt::WA_TranslucentBackground)) {
QRect r = window()->frameGeometry();
QPoint frameOffset = qt_widget_private(window())->frameStrut().topLeft();
QRect dirtyRect = br.translated(offset + frameOffset);
diff --git a/src/gui/statemachine/qkeyeventtransition.cpp b/src/gui/statemachine/qkeyeventtransition.cpp
index 51b3ccc1e..21a073608 100644
--- a/src/gui/statemachine/qkeyeventtransition.cpp
+++ b/src/gui/statemachine/qkeyeventtransition.cpp
@@ -106,19 +106,6 @@ QKeyEventTransition::QKeyEventTransition(QObject *object, QEvent::Type type,
}
/*!
- Constructs a new key event transition for events of the given \a type for
- the given \a object, with the given \a key, \a targets and \a sourceState.
-*/
-QKeyEventTransition::QKeyEventTransition(QObject *object, QEvent::Type type,
- int key, const QList<QAbstractState*> &targets,
- QState *sourceState)
- : QEventTransition(*new QKeyEventTransitionPrivate, object, type, targets, sourceState)
-{
- Q_D(QKeyEventTransition);
- d->transition = new QBasicKeyEventTransition(type, key);
-}
-
-/*!
Destroys this key event transition.
*/
QKeyEventTransition::~QKeyEventTransition()
diff --git a/src/gui/statemachine/qkeyeventtransition.h b/src/gui/statemachine/qkeyeventtransition.h
index f5e8de360..45ae684d6 100644
--- a/src/gui/statemachine/qkeyeventtransition.h
+++ b/src/gui/statemachine/qkeyeventtransition.h
@@ -62,9 +62,6 @@ public:
QKeyEventTransition(QState *sourceState = 0);
QKeyEventTransition(QObject *object, QEvent::Type type, int key,
QState *sourceState = 0);
- QKeyEventTransition(QObject *object, QEvent::Type type, int key,
- const QList<QAbstractState*> &targets,
- QState *sourceState = 0);
~QKeyEventTransition();
int key() const;
diff --git a/src/gui/statemachine/qmouseeventtransition.cpp b/src/gui/statemachine/qmouseeventtransition.cpp
index 0cd096af3..dbe50b367 100644
--- a/src/gui/statemachine/qmouseeventtransition.cpp
+++ b/src/gui/statemachine/qmouseeventtransition.cpp
@@ -112,21 +112,6 @@ QMouseEventTransition::QMouseEventTransition(QObject *object, QEvent::Type type,
}
/*!
- Constructs a new mouse event transition for events of the given \a type for
- the given \a object, with the given \a button, \a targets and \a
- sourceState.
-*/
-QMouseEventTransition::QMouseEventTransition(QObject *object, QEvent::Type type,
- Qt::MouseButton button,
- const QList<QAbstractState*> &targets,
- QState *sourceState)
- : QEventTransition(*new QMouseEventTransitionPrivate, object, type, targets, sourceState)
-{
- Q_D(QMouseEventTransition);
- d->transition = new QBasicMouseEventTransition(type, button);
-}
-
-/*!
Destroys this mouse event transition.
*/
QMouseEventTransition::~QMouseEventTransition()
diff --git a/src/gui/statemachine/qmouseeventtransition.h b/src/gui/statemachine/qmouseeventtransition.h
index 73ae6c9aa..a56a55434 100644
--- a/src/gui/statemachine/qmouseeventtransition.h
+++ b/src/gui/statemachine/qmouseeventtransition.h
@@ -63,10 +63,6 @@ public:
QMouseEventTransition(QState *sourceState = 0);
QMouseEventTransition(QObject *object, QEvent::Type type,
Qt::MouseButton button, QState *sourceState = 0);
- QMouseEventTransition(QObject *object, QEvent::Type type,
- Qt::MouseButton button,
- const QList<QAbstractState*> &targets,
- QState *sourceState = 0);
~QMouseEventTransition();
Qt::MouseButton button() const;
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 76132dfd1..dbf301551 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -156,7 +156,7 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, con
if (!kerning) {
float zero = 0.0;
QCFType<CFNumberRef> noKern = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero);
- CFDictionaryAddValue(attributeDict, kCTKernAttributeName, &noKern);
+ CFDictionaryAddValue(attributeDict, kCTKernAttributeName, noKern);
}
QCoreTextFontEngine *fe = new QCoreTextFontEngine(ctfont, fontDef, this);
@@ -1588,6 +1588,7 @@ QFontEngine::FaceId QFontEngineMac::faceId() const
{
FaceId ret;
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
+if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
// CTFontGetPlatformFont
FSRef ref;
if (ATSFontGetFileReference(FMGetATSFontRefFromFont(fontID), &ref) != noErr)
@@ -1595,7 +1596,9 @@ QFontEngine::FaceId QFontEngineMac::faceId() const
ret.filename = QByteArray(128, 0);
ret.index = fontID;
FSRefMakePath(&ref, (UInt8 *)ret.filename.data(), ret.filename.size());
-#else
+}else
+#endif
+{
FSSpec spec;
if (ATSFontGetFileSpecification(FMGetATSFontRefFromFont(fontID), &spec) != noErr)
return ret;
@@ -1605,7 +1608,7 @@ QFontEngine::FaceId QFontEngineMac::faceId() const
ret.filename = QByteArray(128, 0);
ret.index = fontID;
FSRefMakePath(&ref, (UInt8 *)ret.filename.data(), ret.filename.size());
-#endif
+}
return ret;
}
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 8eec0fc84..0b85eec67 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -2721,7 +2721,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e)
QAction *action = d->actionAt(e->pos());
if (!action) {
- if (d->hasHadMouse && !rect().contains(e->pos()))
+ if (d->hasHadMouse)
d->setCurrentAction(0);
return;
} else if(e->buttons()) {
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 61e560118..e1d663432 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -121,7 +121,9 @@ static void ensureInitialized()
as well as meta-data (headers, etc.).
\note After the request has finished, it is the responsibility of the user
- to delete the QNetworkReply object at an appropriate time.
+ to delete the QNetworkReply object at an appropriate time. Do not directly
+ delete it inside the slot connected to finished(). You can use the
+ deleteLater() function.
A more involved example, assuming the manager is already existent,
can be:
@@ -202,6 +204,9 @@ static void ensureInitialized()
See QNetworkReply::finished() for information on the status that
the object will be in.
+ \note Do not delete the \a reply object in the slot connected to this
+ signal. Use deleteLater().
+
\sa QNetworkReply::finished(), QNetworkReply::error()
*/
diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp
index 3abf92789..f6649b6c5 100644
--- a/src/network/access/qnetworkreply.cpp
+++ b/src/network/access/qnetworkreply.cpp
@@ -87,6 +87,9 @@ QNetworkReplyPrivate::QNetworkReplyPrivate()
indicates the progress of the upload for operations that have such
content.
+ \note Do not delete the object in the slot connected to the
+ error() or finished() signal. Use deleteLater().
+
\sa QNetworkRequest, QNetworkAccessManager
*/
@@ -232,6 +235,9 @@ QNetworkReplyPrivate::QNetworkReplyPrivate()
QNetworkAccessManager::finished() where that signal's reply
parameter is this object.
+ \note Do not delete the object in the slot connected to this
+ signal. Use deleteLater().
+
\sa QNetworkAccessManager::finished()
*/
@@ -246,6 +252,9 @@ QNetworkReplyPrivate::QNetworkReplyPrivate()
detected. Call errorString() to obtain a textual representation of
the error condition.
+ \note Do not delete the object in the slot connected to this
+ signal. Use deleteLater().
+
\sa error(), errorString()
*/
diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro
index c92b8cf57..868484ee1 100644
--- a/src/opengl/opengl.pro
+++ b/src/opengl/opengl.pro
@@ -20,6 +20,7 @@ HEADERS += qgl.h \
qgl_p.h \
qglcolormap.h \
qglpixelbuffer.h \
+ qglpixelbuffer_p.h \
qglframebufferobject.h \
qglextensions_p.h
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index 5ab3647b9..ed9930f8a 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -299,6 +299,7 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext,
int matchingCount = 0;
chosenVisualInfo = XGetVisualInfo(x11Info().display(), VisualIDMask, &vi, &matchingCount);
if (chosenVisualInfo) {
+#if !defined(QT_NO_XRENDER)
if (useArgbVisual) {
// Check to make sure the visual provided by EGL is ARGB
XRenderPictFormat *format;
@@ -312,8 +313,9 @@ void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext,
nativeVisualId, (int)qeglCtx->config());
vi.visualid = 0;
}
- }
- else {
+ } else
+#endif
+ {
qDebug("Using opaque X Visual ID (%d) provided by EGL", (int)vi.visualid);
vi = *chosenVisualInfo;
}
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
index b5376b142..13c4053c8 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
@@ -77,13 +77,15 @@ private:
QSocketNotifier *keyboardNotifier;
DFBEvent event;
int bytesRead;
-
+ int lastUnicode, lastKeycode;
+ Qt::KeyboardModifiers lastModifiers;
private Q_SLOTS:
void readKeyboardData();
};
QDirectFBKeyboardHandlerPrivate::QDirectFBKeyboardHandlerPrivate(QDirectFBKeyboardHandler *h)
- : handler(h), eventBuffer(0)
+ : handler(h), eventBuffer(0), keyboardNotifier(0), bytesRead(0),
+ lastUnicode(0), lastKeycode(0), lastModifiers(0)
{
Q_ASSERT(qt_screen);
@@ -114,8 +116,6 @@ QDirectFBKeyboardHandlerPrivate::QDirectFBKeyboardHandlerPrivate(QDirectFBKeyboa
::fcntl(fd, F_SETFL, flags | O_NONBLOCK);
memset(&event, 0, sizeof(event));
- bytesRead = 0;
-
keyboardNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
connect(keyboardNotifier, SIGNAL(activated(int)),
@@ -213,8 +213,27 @@ void QDirectFBKeyboardHandlerPrivate::readKeyboardData()
unicode = symbol;
if (unicode != -1 || keycode != 0) {
+ bool autoRepeat = false;
+ if (press) {
+ if (unicode == lastUnicode && keycode == lastKeycode && modifiers == lastModifiers) {
+ autoRepeat = true;
+ } else {
+ lastUnicode = unicode;
+ lastKeycode = keycode;
+ lastModifiers = modifiers;
+ }
+ } else {
+ lastUnicode = lastKeycode = -1;
+ lastModifiers = 0;
+ }
+ if (autoRepeat) {
+ handler->processKeyEvent(unicode, keycode,
+ modifiers, false, autoRepeat);
+
+ }
+
handler->processKeyEvent(unicode, keycode,
- modifiers, press, false);
+ modifiers, press, autoRepeat);
}
}
}
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
index 86e92f7b9..207579904 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
@@ -43,10 +43,17 @@
#include "qdirectfbscreen.h"
#include "qdirectfbpaintdevice.h"
+#include "qdirectfbpaintengine.h"
+
+QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr)
+ : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr),
+ lock(DFBSurfaceLockFlags(0)), mem(0), engine(0)
+{}
QDirectFBPaintDevice::~QDirectFBPaintDevice()
{
delete lockedImage;
+ delete engine;
}
@@ -164,4 +171,10 @@ int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
}
}
+QPaintEngine *QDirectFBPaintDevice::paintEngine() const
+{
+ return engine;
+}
+
#endif
+
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
index 248a15b34..c4aeb702a 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
@@ -51,7 +51,8 @@ QT_BEGIN_HEADER
QT_MODULE(Gui)
// Inherited by both window surface and pixmap
- class QDirectFBPaintDevice : public QCustomRasterPaintDevice
+class QDirectFBPaintEngine;
+class QDirectFBPaintDevice : public QCustomRasterPaintDevice
{
public:
~QDirectFBPaintDevice();
@@ -62,19 +63,16 @@ public:
void unlockDirectFB();
// Reimplemented from QCustomRasterPaintDevice:
- void* memory() const;
+ void *memory() const;
QImage::Format format() const;
int bytesPerLine() const;
QSize size() const;
int metric(QPaintDevice::PaintDeviceMetric metric) const;
DFBSurfaceLockFlags lockFlags() const { return lock; }
-protected:
- // Shouldn't create QDirectFBPaintDevice by itself but only sub-class it:
- QDirectFBPaintDevice(QDirectFBScreen *scr = QDirectFBScreen::instance())
- : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr),
- lock(DFBSurfaceLockFlags(0)), mem(0)
- {}
+ QPaintEngine *paintEngine() const;
+protected:
+ QDirectFBPaintDevice(QDirectFBScreen *scr);
inline int dotsPerMeterX() const
{
return (screen->deviceWidth() * 1000) / screen->physicalWidth();
@@ -83,16 +81,17 @@ protected:
{
return (screen->deviceHeight() * 1000) / screen->physicalHeight();
}
-
+protected:
IDirectFBSurface *dfbSurface;
QImage *lockedImage;
QDirectFBScreen *screen;
int bpl;
DFBSurfaceLockFlags lock;
uchar *mem;
+ QDirectFBPaintEngine *engine;
private:
- Q_DISABLE_COPY(QDirectFBPaintDevice)
- };
+ Q_DISABLE_COPY(QDirectFBPaintDevice);
+};
QT_END_HEADER
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
index 2ed890b4d..58c8a581c 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
@@ -60,10 +60,25 @@ class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate
{
public:
enum TransformationTypeFlags {
- NegativeScale = 0x100,
- RectsUnsupported = (QTransform::TxRotate|QTransform::TxShear|QTransform::TxProject),
- BlitUnsupported = (NegativeScale|RectsUnsupported)
+ Matrix_NegativeScale = 0x100,
+ Matrix_RectsUnsupported = (QTransform::TxRotate|QTransform::TxShear|QTransform::TxProject),
+ Matrix_BlitsUnsupported = (Matrix_NegativeScale|Matrix_RectsUnsupported)
};
+
+ enum CompositionModeStatus {
+ PorterDuff_None = 0x0,
+ PorterDuff_SupportedBlits = 0x1,
+ PorterDuff_SupportedPrimitives = 0x2
+ };
+
+ enum ClipType {
+ ClipUnset,
+ NoClip,
+ RectClip,
+ RegionClip,
+ ComplexClip
+ };
+
QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p);
~QDirectFBPaintEnginePrivate();
@@ -77,9 +92,6 @@ public:
inline void lock();
inline void unlock();
- inline bool dfbCanHandleClip(const QRect &rect) const;
- inline bool dfbCanHandleClip(const QRectF &rect) const;
- inline bool dfbCanHandleClip() const;
inline bool isSimpleBrush(const QBrush &brush) const;
void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &pos);
@@ -101,19 +113,16 @@ private:
bool antialiased;
bool simplePen;
- uint transformationType; // this is QTransform::type() + NegativeScale if qMin(transform.m11(), transform.m22()) < 0
+ uint transformationType; // this is QTransform::type() + Matrix_NegativeScale if qMin(transform.m11(), transform.m22()) < 0
SurfaceCache *surfaceCache;
-
IDirectFB *fb;
-
quint8 opacity;
bool dirtyClip;
- bool dfbHandledClip;
- bool ignoreSystemClip;
+ ClipType clipType;
QDirectFBPaintDevice *dfbDevice;
- bool unsupportedCompositionMode;
+ uint compositionModeStatus;
QDirectFBPaintEngine *q;
QRect currentClip;
@@ -162,8 +171,12 @@ enum PaintOperation {
#ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS
template <typename device, typename T1, typename T2, typename T3>
-static void rasterFallbackWarn(const char *msg, const char *, const device *, uint, bool, bool, bool,
- const char *, const T1 &, const char *, const T2 &, const char *, const T3 &);
+static void rasterFallbackWarn(const char *msg, const char *func, const device *dev,
+ uint transformationType, bool simplePen,
+ uint clipType, uint compositionModeStatus,
+ const char *nameOne, const T1 &one,
+ const char *nameTwo, const T2 &two,
+ const char *nameThree, const T3 &three);
#endif
#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS
@@ -173,8 +186,8 @@ static void rasterFallbackWarn(const char *msg, const char *, const device *, ui
__FUNCTION__, state()->painter->device(), \
d_func()->transformationType, \
d_func()->simplePen, \
- d_func()->dfbCanHandleClip(), \
- d_func()->unsupportedCompositionMode, \
+ d_func()->clipType, \
+ d_func()->compositionModeStatus, \
#one, one, #two, two, #three, three); \
if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \
return;
@@ -189,14 +202,13 @@ static void rasterFallbackWarn(const char *msg, const char *, const device *, ui
__FUNCTION__, state()->painter->device(), \
d_func()->transformationType, \
d_func()->simplePen, \
- d_func()->dfbCanHandleClip(), \
- d_func()->unsupportedCompositionMode, \
+ d_func()->clipType, \
+ d_func()->compositionModeStatus, \
#one, one, #two, two, #three, three);
#else
#define RASTERFALLBACK(op, one, two, three)
#endif
-
template <class T>
static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface);
template <class T>
@@ -204,6 +216,36 @@ static inline void fillRects(const T *rects, int n, const QTransform &transform,
template <class T>
static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface);
+#define CLIPPED_PAINT(operation) { \
+ DFBRegion clipRegion; \
+ switch (d->clipType) { \
+ case QDirectFBPaintEnginePrivate::NoClip: \
+ case QDirectFBPaintEnginePrivate::RectClip: \
+ operation; \
+ break; \
+ case QDirectFBPaintEnginePrivate::RegionClip: { \
+ Q_ASSERT(d->clip()); \
+ const QVector<QRect> cr = d->clip()->clipRegion.rects(); \
+ const int size = cr.size(); \
+ for (int i=0; i<size; ++i) { \
+ d->currentClip = cr.at(i); \
+ clipRegion.x1 = d->currentClip.x(); \
+ clipRegion.y1 = d->currentClip.y(); \
+ clipRegion.x2 = d->currentClip.right(); \
+ clipRegion.y2 = d->currentClip.bottom(); \
+ d->surface->SetClip(d->surface, &clipRegion); \
+ operation; \
+ } \
+ d->dirtyClip = true; \
+ break; } \
+ case QDirectFBPaintEnginePrivate::ComplexClip: \
+ case QDirectFBPaintEnginePrivate::ClipUnset: \
+ qFatal("CLIPPED_PAINT internal error %d", d->clipType); \
+ break; \
+ } \
+ }
+
+
QDirectFBPaintEngine::QDirectFBPaintEngine(QPaintDevice *device)
: QRasterPaintEngine(*(new QDirectFBPaintEnginePrivate(this)), device)
{
@@ -234,7 +276,7 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device)
}
d->prepare(d->dfbDevice);
-
+ d->setCompositionMode(state()->composition_mode);
return QRasterPaintEngine::begin(device);
}
@@ -324,58 +366,60 @@ void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount)
{
Q_D(QDirectFBPaintEngine);
- d->updateClip();
+ const QPen &pen = state()->pen;
const QBrush &brush = state()->brush;
- if (d->unsupportedCompositionMode
- || (d->transformationType & QDirectFBPaintEnginePrivate::RectsUnsupported)
+ if (brush == Qt::NoBrush && pen == Qt::NoPen)
+ return;
+
+ d->updateClip();
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)
|| !d->simplePen
- || !d->dfbCanHandleClip()
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
|| !d->isSimpleBrush(brush)) {
RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG());
d->lock();
QRasterPaintEngine::drawRects(rects, rectCount);
return;
}
-
d->unlock();
-
if (brush != Qt::NoBrush) {
d->setDFBColor(brush.color());
- ::fillRects<QRect>(rects, rectCount, state()->matrix, d->surface);
+ CLIPPED_PAINT(::fillRects<QRect>(rects, rectCount, state()->matrix, d->surface));
}
- const QPen &pen = state()->pen;
if (pen != Qt::NoPen) {
d->setDFBColor(pen.color());
- ::drawRects<QRect>(rects, rectCount, state()->matrix, d->surface);
+ CLIPPED_PAINT(::drawRects<QRect>(rects, rectCount, state()->matrix, d->surface));
}
}
void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount)
{
Q_D(QDirectFBPaintEngine);
- d->updateClip();
+ const QPen &pen = state()->pen;
const QBrush &brush = state()->brush;
- if (d->unsupportedCompositionMode
- || (d->transformationType & QDirectFBPaintEnginePrivate::RectsUnsupported)
+ if (brush == Qt::NoBrush && pen == Qt::NoPen)
+ return;
+
+ d->updateClip();
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)
|| !d->simplePen
- || !d->dfbCanHandleClip()
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
|| !d->isSimpleBrush(brush)) {
RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG());
d->lock();
QRasterPaintEngine::drawRects(rects, rectCount);
return;
}
-
d->unlock();
-
if (brush != Qt::NoBrush) {
d->setDFBColor(brush.color());
- ::fillRects<QRectF>(rects, rectCount, state()->matrix, d->surface);
+ CLIPPED_PAINT(::fillRects<QRectF>(rects, rectCount, state()->matrix, d->surface));
}
- const QPen &pen = state()->pen;
if (pen != Qt::NoPen) {
d->setDFBColor(pen.color());
- ::drawRects<QRectF>(rects, rectCount, state()->matrix, d->surface);
+ CLIPPED_PAINT(::drawRects<QRectF>(rects, rectCount, state()->matrix, d->surface));
}
}
@@ -383,7 +427,10 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (d->unsupportedCompositionMode || !d->simplePen || !d->dfbCanHandleClip()) {
+
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)
+ || !d->simplePen
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) {
RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG());
d->lock();
QRasterPaintEngine::drawLines(lines, lineCount);
@@ -394,7 +441,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount)
if (pen != Qt::NoPen) {
d->unlock();
d->setDFBColor(pen.color());
- ::drawLines<QLine>(lines, lineCount, state()->matrix, d->surface);
+ CLIPPED_PAINT(::drawLines<QLine>(lines, lineCount, state()->matrix, d->surface));
}
}
@@ -402,7 +449,10 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (d->unsupportedCompositionMode || !d->simplePen || !d->dfbCanHandleClip()) {
+
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)
+ || !d->simplePen
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) {
RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG());
d->lock();
QRasterPaintEngine::drawLines(lines, lineCount);
@@ -413,7 +463,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount)
if (pen != Qt::NoPen) {
d->unlock();
d->setDFBColor(pen.color());
- ::drawLines<QLineF>(lines, lineCount, state()->matrix, d->surface);
+ CLIPPED_PAINT(::drawLines<QLineF>(lines, lineCount, state()->matrix, d->surface));
}
}
@@ -443,9 +493,9 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image,
d->updateClip();
#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE
- if (d->unsupportedCompositionMode
- || (d->transformationType & QDirectFBPaintEnginePrivate::BlitUnsupported)
- || !d->dfbCanHandleClip(r)
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
#ifndef QT_DIRECTFB_IMAGECACHE
|| QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN
#elif defined QT_NO_DIRECTFB_PREALLOCATED
@@ -464,7 +514,7 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image,
bool release;
IDirectFBSurface *imgSurface = d->getSurface(image, &release);
d->prepareForBlit(QDirectFBScreen::hasAlpha(imgSurface));
- d->blit(r, imgSurface, sr);
+ CLIPPED_PAINT(d->blit(r, imgSurface, sr));
if (release) {
#if (Q_DIRECTFB_VERSION >= 0x010000)
d->surface->ReleaseSource(d->surface);
@@ -483,15 +533,15 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap,
const QRectF &sr)
{
Q_D(QDirectFBPaintEngine);
- d->updateClip();
+ d->updateClip();
if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) {
RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr);
d->lock();
QRasterPaintEngine::drawPixmap(r, pixmap, sr);
- } else if (d->unsupportedCompositionMode
- || (d->transformationType & QDirectFBPaintEnginePrivate::BlitUnsupported)
- || !d->dfbCanHandleClip(r)) {
+ } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) {
RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr);
const QImage *img = static_cast<QDirectFBPixmapData*>(pixmap.pixmapData())->buffer(DSLF_READ);
d->lock();
@@ -504,7 +554,8 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap,
QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data);
dfbData->unlockDirectFB();
IDirectFBSurface *s = dfbData->directFBSurface();
- d->blit(r, s, sr);
+
+ CLIPPED_PAINT(d->blit(r, s, sr));
}
}
@@ -523,9 +574,9 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r,
RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset);
d->lock();
QRasterPaintEngine::drawTiledPixmap(r, pixmap, offset);
- } else if (d->unsupportedCompositionMode
- || (d->transformationType & QDirectFBPaintEnginePrivate::BlitUnsupported)
- || !d->dfbCanHandleClip(r)) {
+ } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) {
RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset);
const QImage *img = static_cast<QDirectFBPixmapData*>(pixmap.pixmapData())->buffer(DSLF_READ);
d->lock();
@@ -624,30 +675,34 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
if (brush.style() == Qt::NoBrush)
return;
d->updateClip();
- if (!d->unsupportedCompositionMode
- && !(d->transformationType & (QDirectFBPaintEnginePrivate::RectsUnsupported))
- && d->dfbCanHandleClip(rect)) {
+ if (d->clipType != QDirectFBPaintEnginePrivate::ComplexClip) {
switch (brush.style()) {
case Qt::SolidPattern: {
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)) {
+ break;
+ }
const QColor color = brush.color();
if (!color.isValid())
return;
d->unlock();
d->setDFBColor(color);
const QRect r = state()->matrix.mapRect(rect).toRect();
- d->surface->FillRectangle(d->surface, r.x(), r.y(),
- r.width(), r.height());
+ CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height()));
return; }
+
case Qt::TexturePattern: {
- if (d->transformationType & QDirectFBPaintEnginePrivate::NegativeScale)
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)) {
break;
+ }
const QPixmap texture = brush.texture();
if (texture.pixmapData()->classId() != QPixmapData::DirectFBClass)
break;
d->unlock();
- d->drawTiledPixmap(rect, texture, rect.topLeft() - state()->brushOrigin);
+ CLIPPED_PAINT(d->drawTiledPixmap(rect, texture, rect.topLeft() - state()->brushOrigin));
return; }
default:
break;
@@ -664,9 +719,9 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color)
return;
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (d->unsupportedCompositionMode
- || (d->transformationType & QDirectFBPaintEnginePrivate::RectsUnsupported)
- || !d->dfbCanHandleClip()) {
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) {
RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG());
d->lock();
QRasterPaintEngine::fillRect(rect, color);
@@ -711,11 +766,10 @@ void QDirectFBPaintEngine::initImageCache(int size)
QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p)
: surface(0), antialiased(false), simplePen(false),
transformationType(0), opacity(255), dirtyClip(true),
- dfbHandledClip(false), dfbDevice(0),
- unsupportedCompositionMode(false), q(p)
+ clipType(ClipUnset), dfbDevice(0),
+ compositionModeStatus(0), q(p)
{
fb = QDirectFBScreen::instance()->dfb();
- ignoreSystemClip = QDirectFBScreen::instance()->directFBFlags() & QDirectFBScreen::IgnoreSystemClip;
surfaceCache = new SurfaceCache;
}
@@ -724,23 +778,6 @@ QDirectFBPaintEnginePrivate::~QDirectFBPaintEnginePrivate()
delete surfaceCache;
}
-bool QDirectFBPaintEnginePrivate::dfbCanHandleClip(const QRect &) const
-{
- // TODO: Check to see if DirectFB can handle the clip for the given rect
- return dfbHandledClip;
-}
-
-bool QDirectFBPaintEnginePrivate::dfbCanHandleClip(const QRectF &) const
-{
- // TODO: Check to see if DirectFB can handle the clip for the given rect
- return dfbHandledClip;
-}
-
-bool QDirectFBPaintEnginePrivate::dfbCanHandleClip() const
-{
- return dfbHandledClip;
-}
-
bool QDirectFBPaintEnginePrivate::isSimpleBrush(const QBrush &brush) const
{
return (brush.style() == Qt::NoBrush) || (brush.style() == Qt::SolidPattern && !antialiased);
@@ -768,7 +805,7 @@ void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform)
{
transformationType = transform.type();
if (qMin(transform.m11(), transform.m22()) < 0) {
- transformationType |= QDirectFBPaintEnginePrivate::NegativeScale;
+ transformationType |= QDirectFBPaintEnginePrivate::Matrix_NegativeScale;
}
setPen(q->state()->pen);
}
@@ -790,7 +827,53 @@ void QDirectFBPaintEnginePrivate::setPen(const QPen &pen)
void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode)
{
- unsupportedCompositionMode = (mode != QPainter::CompositionMode_SourceOver);
+ if (!surface)
+ return;
+ compositionModeStatus = PorterDuff_SupportedBlits;
+ switch (mode) {
+ case QPainter::CompositionMode_Clear:
+ surface->SetPorterDuff(surface, DSPD_CLEAR);
+ break;
+ case QPainter::CompositionMode_Source:
+ surface->SetPorterDuff(surface, DSPD_SRC);
+ break;
+ case QPainter::CompositionMode_SourceOver:
+ compositionModeStatus |= PorterDuff_SupportedPrimitives;
+ surface->SetPorterDuff(surface, DSPD_SRC_OVER);
+ break;
+ case QPainter::CompositionMode_DestinationOver:
+ surface->SetPorterDuff(surface, DSPD_DST_OVER);
+ break;
+ case QPainter::CompositionMode_SourceIn:
+ surface->SetPorterDuff(surface, DSPD_SRC_IN);
+ break;
+ case QPainter::CompositionMode_DestinationIn:
+ surface->SetPorterDuff(surface, DSPD_DST_IN);
+ break;
+ case QPainter::CompositionMode_SourceOut:
+ surface->SetPorterDuff(surface, DSPD_SRC_OUT);
+ break;
+ case QPainter::CompositionMode_DestinationOut:
+ surface->SetPorterDuff(surface, DSPD_DST_OUT);
+ break;
+#if (Q_DIRECTFB_VERSION >= 0x010000)
+ case QPainter::CompositionMode_SourceAtop:
+ surface->SetPorterDuff(surface, DSPD_SRC_ATOP);
+ break;
+ case QPainter::CompositionMode_DestinationAtop:
+ surface->SetPorterDuff(surface, DSPD_DST_ATOP);
+ break;
+ case QPainter::CompositionMode_Plus:
+ surface->SetPorterDuff(surface, DSPD_ADD);
+ break;
+#endif
+ case QPainter::CompositionMode_Xor:
+ surface->SetPorterDuff(surface, DSPD_XOR);
+ break;
+ default:
+ compositionModeStatus = 0;
+ break;
+ }
}
void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints)
@@ -896,7 +979,7 @@ static inline qreal fixCoord(qreal rect_pos, qreal pixmapSize, qreal offset)
void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &off)
{
Q_ASSERT(!dirtyClip);
- Q_ASSERT(!(transformationType & BlitUnsupported));
+ Q_ASSERT(!(transformationType & Matrix_BlitsUnsupported));
const QTransform &transform = q->state()->matrix;
const QRect destinationRect = transform.mapRect(dest).toRect().normalized();
QRect newClip = destinationRect;
@@ -909,8 +992,8 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix
const DFBRegion clip = {
newClip.x(),
newClip.y(),
- newClip.x() + newClip.width() - 1,
- newClip.y() + newClip.height() - 1
+ newClip.right(),
+ newClip.bottom()
};
surface->SetClip(surface, &clip);
@@ -979,8 +1062,8 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix
const DFBRegion clip = {
currentClip.x(),
currentClip.y(),
- currentClip.x() + currentClip.width(),
- currentClip.y() + currentClip.height()
+ currentClip.right(),
+ currentClip.bottom()
};
surface->SetClip(surface, &clip);
}
@@ -995,22 +1078,22 @@ void QDirectFBPaintEnginePrivate::updateClip()
const QClipData *clipData = clip();
if (!clipData || !clipData->enabled) {
surface->SetClip(surface, NULL);
- dfbHandledClip = true;
+ clipType = NoClip;
} else if (clipData->hasRectClip) {
const DFBRegion r = {
clipData->clipRect.x(),
clipData->clipRect.y(),
- clipData->clipRect.x() + clipData->clipRect.width(),
- clipData->clipRect.y() + clipData->clipRect.height()
+ clipData->clipRect.right(),
+ clipData->clipRect.bottom()
};
surface->SetClip(surface, &r);
currentClip = clipData->clipRect.normalized();
// ### is this guaranteed to always be normalized?
- dfbHandledClip = true;
- } else if (clipData->hasRegionClip && ignoreSystemClip && clipData->clipRegion == systemClip) {
- dfbHandledClip = true;
+ clipType = RectClip;
+ } else if (clipData->hasRegionClip) {
+ clipType = RegionClip;
} else {
- dfbHandledClip = false;
+ clipType = ComplexClip;
}
dirtyClip = false;
@@ -1107,7 +1190,7 @@ template <> inline const bool* ptr<bool>(const bool &) { return 0; }
template <typename device, typename T1, typename T2, typename T3>
static void rasterFallbackWarn(const char *msg, const char *func, const device *dev,
uint transformationType, bool simplePen,
- bool dfbHandledClip, bool unsupportedCompositionMode,
+ uint clipType, uint compositionModeStatus,
const char *nameOne, const T1 &one,
const char *nameTwo, const T2 &two,
const char *nameThree, const T3 &three)
@@ -1123,8 +1206,8 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device *
dbg << QString("transformationType 0x%1").arg(transformationType, 3, 16, QLatin1Char('0'))
<< "simplePen" << simplePen
- << "dfbHandledClip" << dfbHandledClip
- << "unsupportedCompositionMode" << unsupportedCompositionMode;
+ << "clipType" << clipType
+ << "compositionModeStatus" << compositionModeStatus;
const T1 *t1 = ptr(one);
const T2 *t2 = ptr(two);
@@ -1141,7 +1224,6 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device *
}
qWarning("%s", qPrintable(out));
}
-#endif
-
+#endif // QT_DIRECTFB_WARN_ON_RASTERFALLBACKS
#endif // QT_NO_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
index 52e85ba3a..bedd9e5a7 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
@@ -49,9 +49,9 @@
static int global_ser_no = 0;
-QDirectFBPixmapData::QDirectFBPixmapData(PixelType pixelType)
- : QPixmapData(pixelType, DirectFBClass),
- engine(0), format(QImage::Format_Invalid), alpha(false)
+QDirectFBPixmapData::QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType)
+ : QPixmapData(pixelType, DirectFBClass), QDirectFBPaintDevice(screen),
+ format(QImage::Format_Invalid), alpha(false)
{
setSerialNumber(0);
}
@@ -61,7 +61,6 @@ QDirectFBPixmapData::~QDirectFBPixmapData()
unlockDirectFB();
if (dfbSurface && QDirectFBScreen::instance())
screen->releaseDFBSurface(dfbSurface);
- delete engine;
}
void QDirectFBPixmapData::resize(int width, int height)
@@ -304,7 +303,7 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
Q_ASSERT(image);
const QImage transformed = image->transformed(transform, mode);
that->unlockDirectFB();
- QDirectFBPixmapData *data = new QDirectFBPixmapData(QPixmapData::PixmapType);
+ QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType);
data->fromImage(transformed, Qt::AutoColor);
return QPixmap(data);
}
@@ -314,7 +313,7 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
if (size.isEmpty())
return QPixmap();
- QDirectFBPixmapData *data = new QDirectFBPixmapData(QPixmapData::PixmapType);
+ QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType);
DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
data->alpha = alpha;
if (alpha) {
@@ -373,6 +372,8 @@ QImage QDirectFBPixmapData::toImage() const
return img->copy();
}
+/* This is QPixmapData::paintEngine(), not QPaintDevice::paintEngine() */
+
QPaintEngine *QDirectFBPixmapData::paintEngine() const
{
if (!engine) {
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
index 020406184..df3c679a7 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
@@ -56,7 +56,7 @@ class QDirectFBPaintEngine;
class QDirectFBPixmapData : public QPixmapData, public QDirectFBPaintDevice
{
public:
- QDirectFBPixmapData(PixelType pixelType);
+ QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType);
~QDirectFBPixmapData();
// Re-implemented from QPixmapData:
@@ -79,7 +79,6 @@ public:
inline bool hasAlphaChannel() const { return alpha; }
private:
void invalidate();
- QDirectFBPaintEngine *engine;
QImage::Format format;
bool alpha;
};
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index 030e51f7c..4f8fa2f11 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -57,7 +57,7 @@
class QDirectFBScreenPrivate : public QObject, public QWSGraphicsSystem
{
public:
- QDirectFBScreenPrivate(QDirectFBScreen*);
+ QDirectFBScreenPrivate(QDirectFBScreen *qptr);
~QDirectFBScreenPrivate();
void setFlipFlags(const QStringList &args);
@@ -82,10 +82,11 @@ public:
QDirectFBScreen::DirectFBFlags directFBFlags;
QImage::Format alphaPixmapFormat;
QColor backgroundColor;
+ QDirectFBScreen *q;
};
-QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *screen)
- : QWSGraphicsSystem(screen), dfb(0), dfbSurface(0), flipFlags(DSFLIP_NONE)
+QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr)
+ : QWSGraphicsSystem(qptr), dfb(0), dfbSurface(0), flipFlags(DSFLIP_NONE)
#ifndef QT_NO_DIRECTFB_LAYER
, dfbLayer(0)
#endif
@@ -98,6 +99,7 @@ QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *screen)
#endif
, directFBFlags(QDirectFBScreen::NoFlags)
, alphaPixmapFormat(QImage::Format_Invalid)
+ , q(qptr)
{
#ifndef QT_NO_QWS_SIGNALHANDLER
QWSSignalHandler::instance()->addObject(this);
@@ -742,7 +744,7 @@ QPixmapData *QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType typ
if (type == QPixmapData::BitmapType)
return QWSGraphicsSystem::createPixmapData(type);
- return new QDirectFBPixmapData(type);
+ return new QDirectFBPixmapData(q, type);
}
#if (Q_DIRECTFB_VERSION >= 0x000923)
@@ -914,9 +916,6 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
QDirectFBPaintEngine::initImageCache(imageCacheSize);
#endif
- if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive))
- d_ptr->directFBFlags |= IgnoreSystemClip;
-
#ifndef QT_NO_DIRECTFB_WM
if (displayArgs.contains(QLatin1String("fullscreen")))
#endif
@@ -1328,15 +1327,15 @@ void QDirectFBScreen::flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags
for (int i=0; i<rects.size(); ++i) {
const QRect &r = rects.at(i);
const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(),
- r.x() + r.width() + offset.x(),
- r.y() + r.height() + offset.y() };
+ r.right() + offset.x(),
+ r.bottom() + offset.y() };
surface->Flip(surface, &dfbReg, i + 1 < rects.size() ? nonWaitFlags : flipFlags);
}
} else {
const QRect r = region.boundingRect();
const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(),
- r.x() + r.width() + offset.x(),
- r.y() + r.height() + offset.y() };
+ r.right() + offset.x(),
+ r.bottom() + offset.y() };
surface->Flip(surface, &dfbReg, flipFlags);
}
}
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
index 63c608eec..8884a06e0 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
@@ -79,8 +79,7 @@ public:
NoFlags = 0x00,
VideoOnly = 0x01,
SystemOnly = 0x02,
- IgnoreSystemClip = 0x04,
- BoundingRectFlip = 0x08
+ BoundingRectFlip = 0x04
};
Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag);
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
index 8cddc76de..34168bc6b 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
@@ -55,7 +55,7 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect
#ifndef QT_NO_DIRECTFB_WM
, dfbWindow(0)
#endif
- , engine(0)
+ , engineHeight(-1)
, flipFlags(flip)
, boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
{
@@ -76,7 +76,7 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect
#ifndef QT_NO_DIRECTFB_WM
, dfbWindow(0)
#endif
- , engine(0)
+ , engineHeight(-1)
, flipFlags(flip)
, boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
{
@@ -295,16 +295,6 @@ bool QDirectFBWindowSurface::move(const QPoint &moveBy)
return true;
}
-QPaintEngine *QDirectFBWindowSurface::paintEngine() const
-{
- if (!engine) {
- QDirectFBWindowSurface *that = const_cast<QDirectFBWindowSurface*>(this);
- that->engine = new QDirectFBPaintEngine(that);
- return that->engine;
- }
- return engine;
-}
-
// hw: XXX: copied from QWidgetPrivate::isOpaque()
inline bool isWidgetOpaque(const QWidget *w)
{
@@ -429,6 +419,12 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion &region,
void QDirectFBWindowSurface::beginPaint(const QRegion &)
{
+ const int h = height();
+ if (h > engineHeight) {
+ engineHeight = h;
+ delete engine;
+ engine = new QDirectFBPaintEngine(this);
+ }
}
void QDirectFBWindowSurface::endPaint(const QRegion &)
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
index c46d93bf4..fefe9f35a 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
@@ -61,8 +61,8 @@ QT_MODULE(Gui)
class QDirectFBWindowSurface : public QWSWindowSurface, public QDirectFBPaintDevice
{
public:
- QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr);
- QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr, QWidget *widget);
+ QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen *scr);
+ QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen *scr, QWidget *widget);
~QDirectFBWindowSurface();
bool isValid() const;
@@ -79,7 +79,6 @@ public:
QImage image() const { return QImage(); }
QPaintDevice *paintDevice() { return this; }
- QPaintEngine *paintEngine() const;
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
@@ -92,7 +91,7 @@ private:
void createWindow();
IDirectFBWindow *dfbWindow;
#endif
- QDirectFBPaintEngine *engine;
+ int engineHeight;
enum Mode {
Primary,
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp
index bfd65fcfe..bd6f7b94b 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp
@@ -1338,8 +1338,8 @@ QSqlIndex QMYSQLDriver::primaryIndex(const QString& tablename) const
if (!isOpen())
return idx;
- prepQ = d->preparedQuerys;
- d->preparedQuerys = false;
+ prepQ = d->preparedQuerysEnabled;
+ d->preparedQuerysEnabled = false;
QSqlQuery i(createResult());
QString stmt(QLatin1String("show index from %1;"));
@@ -1353,7 +1353,7 @@ QSqlIndex QMYSQLDriver::primaryIndex(const QString& tablename) const
}
}
- d->preparedQuerys = prepQ;
+ d->preparedQuerysEnabled = prepQ;
return idx;
}
diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp
index 3682f474f..6ed3dc2db 100644
--- a/src/svg/qsvgstyle.cpp
+++ b/src/svg/qsvgstyle.cpp
@@ -206,8 +206,8 @@ QSvgFontStyle::QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc)
}
QSvgFontStyle::QSvgFontStyle()
- : m_doc(0)
- , m_svgFont(0)
+ : m_svgFont(0)
+ , m_doc(0)
, m_familySet(0)
, m_sizeSet(0)
, m_styleSet(0)
diff --git a/tests/arthur/data/qps/pixmap_scaling.qps b/tests/arthur/data/qps/pixmap_scaling.qps
index 81b8faec5..c5053adc0 100644
--- a/tests/arthur/data/qps/pixmap_scaling.qps
+++ b/tests/arthur/data/qps/pixmap_scaling.qps
@@ -3,8 +3,8 @@
translate 5 25
setFont "arial" 8
-save
- drawText 15 0 "opaque image"
+save
+ drawText 15 0 "opaque image"
translate 50 50
save
translate 1 1
@@ -16,23 +16,23 @@ save
scale -20 20
drawImage solid2x2.png 0 0
restore
- save
+ save
translate 1 -1
scale 20 -20
drawImage solid2x2.png 0 0
restore
- save
+ save
translate -1 -1
scale -20 -20
drawImage solid2x2.png 0 0
restore
-
-restore
+
+restore
save
translate 150 0
- drawText 15 0 "alpha image"
+ drawText 15 0 "alpha image"
translate 50 50
save
translate 1 1
@@ -44,12 +44,12 @@ save
scale -20 20
drawImage alpha2x2.png 0 0
restore
- save
+ save
translate 1 -1
scale 20 -20
drawImage alpha2x2.png 0 0
restore
- save
+ save
translate -1 -1
scale -20 -20
drawImage alpha2x2.png 0 0
@@ -59,7 +59,7 @@ restore
save
translate 0 150
- drawText 15 0 "solid pixmap"
+ drawText 15 0 "solid pixmap"
translate 50 50
save
translate 1 1
@@ -71,12 +71,12 @@ save
scale -20 20
drawPixmap solid2x2.png 0 0
restore
- save
+ save
translate 1 -1
scale 20 -20
drawPixmap solid2x2.png 0 0
restore
- save
+ save
translate -1 -1
scale -20 -20
drawPixmap solid2x2.png 0 0
@@ -85,9 +85,9 @@ restore
save
- translate 150 150
+ translate 150 150
drawText 15 0 "alpha pixmap"
- translate 50 50
+ translate 50 50
save
translate 1 1
scale 20 20
@@ -98,12 +98,12 @@ save
scale -20 20
drawPixmap alpha2x2.png 0 0
restore
- save
+ save
translate 1 -1
scale 20 -20
drawPixmap alpha2x2.png 0 0
restore
- save
+ save
translate -1 -1
scale -20 -20
drawPixmap alpha2x2.png 0 0
@@ -111,7 +111,7 @@ save
restore
-save
+save
translate 300 10
save
drawText 0 -10 "subrect solid image"
@@ -138,7 +138,7 @@ save
drawImage solid2x2.png 45 0 5 50 1.8 0 0.2 2
restore
- save
+ save
translate 150 0
drawText 0 -10 "subrect solid image"
drawImage alpha2x2.png 0 0 50 5 0 0.0 2 0.2
@@ -151,7 +151,7 @@ save
drawImage alpha2x2.png 0 35 50 5 0 1.4 2 0.2
drawImage alpha2x2.png 0 40 50 5 0 1.6 2 0.2
drawImage alpha2x2.png 0 45 50 5 0 1.8 2 0.2
- translate 60 0
+ translate 60 0
drawImage alpha2x2.png 0 0 5 50 0.0 0 0.2 2
drawImage alpha2x2.png 5 0 5 50 0.2 0 0.2 2
drawImage alpha2x2.png 10 0 5 50 0.4 0 0.2 2
@@ -217,3 +217,311 @@ save
restore
restore
+
+
+
+image_load alpha2x2.png alpha2x2
+image_convertToFormat alpha2x2 alpha2x2_argb32 ARGB32
+image_convertToFormat alpha2x2 alpha2x2_argb32pre ARGB32_Premultiplied
+image_convertToFormat alpha2x2 alpha2x2_rgb888 Format_RGB888
+image_convertToFormat alpha2x2 alpha2x2_rgb32 RGB32
+image_convertToFormat alpha2x2 alpha2x2_rgb16 Format_RGB16
+
+save
+ translate 0 300
+ drawText 15 0 "drawImage - argb32"
+ translate 50 50
+ save
+ translate 0.5 0.5
+ scale 20 20
+ drawImage alpha2x2_argb32 0 0
+ restore
+ save
+ translate -0.5 0.5
+ scale -20 20
+ drawImage alpha2x2_argb32 0 0
+ restore
+ save
+ translate 0.5 -0.5
+ scale 20 -20
+ drawImage alpha2x2_argb32 0 0
+ restore
+ save
+ translate -0.5 -0.5
+ scale -20 -20
+ drawImage alpha2x2_argb32 0 0
+ restore
+restore
+
+save
+ translate 150 300
+ drawText 15 0 "drawImage - argb32premul"
+ translate 50 50
+ save
+ translate 0.5 0.5
+ scale 20 20
+ drawImage alpha2x2_argb32pre 0 0
+ restore
+ save
+ translate -0.5 0.5
+ scale -20 20
+ drawImage alpha2x2_argb32pre 0 0
+ restore
+ save
+ translate 0.5 -0.5
+ scale 20 -20
+ drawImage alpha2x2_argb32pre 0 0
+ restore
+ save
+ translate -0.5 -0.5
+ scale -20 -20
+ drawImage alpha2x2_argb32pre 0 0
+ restore
+restore
+
+
+
+save
+ translate 0 450
+ drawText 15 0 "drawImage - rgb888"
+ translate 50 50
+ save
+ translate 0.5 0.5
+ scale 20 20
+ drawImage alpha2x2_rgb888 0 0
+ restore
+ save
+ translate -0.5 0.5
+ scale -20 20
+ drawImage alpha2x2_rgb888 0 0
+ restore
+ save
+ translate 0.5 -0.5
+ scale 20 -20
+ drawImage alpha2x2_rgb888 0 0
+ restore
+ save
+ translate -0.5 -0.5
+ scale -20 -20
+ drawImage alpha2x2_rgb888 0 0
+ restore
+restore
+
+save
+ translate 150 450
+ drawText 15 0 "drawImage - rgb32"
+ translate 50 50
+ save
+ translate 0.5 0.5
+ scale 20 20
+ drawImage alpha2x2_rgb32 0 0
+ restore
+ save
+ translate -0.5 0.5
+ scale -20 20
+ drawImage alpha2x2_rgb32 0 0
+ restore
+ save
+ translate 0.5 -0.5
+ scale 20 -20
+ drawImage alpha2x2_rgb32 0 0
+ restore
+ save
+ translate -0.5 -0.5
+ scale -20 -20
+ drawImage alpha2x2_rgb32 0 0
+ restore
+restore
+
+save
+ translate 300 450
+ drawText 15 0 "drawImage - rgb16"
+ translate 50 50
+ save
+ translate 0.5 0.5
+ scale 20 20
+ drawImage alpha2x2_rgb16 0 0
+ restore
+ save
+ translate -0.5 0.5
+ scale -20 20
+ drawImage alpha2x2_rgb16 0 0
+ restore
+ save
+ translate 0.5 -0.5
+ scale 20 -20
+ drawImage alpha2x2_rgb16 0 0
+ restore
+ save
+ translate -0.5 -0.5
+ scale -20 -20
+ drawImage alpha2x2_rgb16 0 0
+ restore
+restore
+
+
+
+save
+ translate 0 600
+ drawText 15 0 "clipping - argb32"
+ translate 50 50
+ setClipRect -30 -30 60 60 ReplaceClip
+ save
+ translate 0.5 0.5
+ scale 20 20
+ drawImage alpha2x2_argb32 0 0
+ restore
+ save
+ translate -0.5 0.5
+ scale -20 20
+ drawImage alpha2x2_argb32 0 0
+ restore
+ save
+ translate 0.5 -0.5
+ scale 20 -20
+ drawImage alpha2x2_argb32 0 0
+ restore
+ save
+ translate -0.5 -0.5
+ scale -20 -20
+ drawImage alpha2x2_argb32 0 0
+ restore
+restore
+
+save
+ translate 150 600
+ drawText 15 0 "clipping - argb32premul"
+ translate 50 50
+ setClipRect -30 -30 60 60 ReplaceClip
+ save
+ translate 0.5 0.5
+ scale 20 20
+ drawImage alpha2x2_argb32pre 0 0
+ restore
+ save
+ translate -0.5 0.5
+ scale -20 20
+ drawImage alpha2x2_argb32pre 0 0
+ restore
+ save
+ translate 0.5 -0.5
+ scale 20 -20
+ drawImage alpha2x2_argb32pre 0 0
+ restore
+ save
+ translate -0.5 -0.5
+ scale -20 -20
+ drawImage alpha2x2_argb32pre 0 0
+ restore
+restore
+
+save
+ translate 300 600
+ drawText 15 0 "clipping - rgb16"
+ translate 50 50
+ setClipRect -30 -30 60 60 ReplaceClip
+ save
+ translate 0.5 0.5
+ scale 20 20
+ drawImage alpha2x2_rgb16 0 0
+ restore
+ save
+ translate -0.5 0.5
+ scale -20 20
+ drawImage alpha2x2_rgb16 0 0
+ restore
+ save
+ translate 0.5 -0.5
+ scale 20 -20
+ drawImage alpha2x2_rgb16 0 0
+ restore
+ save
+ translate -0.5 -0.5
+ scale -20 -20
+ drawImage alpha2x2_rgb16 0 0
+ restore
+restore
+
+
+path_addEllipse ellipse -30 -30 60 60
+
+save
+ translate 0 750
+ drawText 15 0 "clipping - argb32"
+ translate 50 50
+ setClipPath ellipse ReplaceClip
+ save
+ translate 0.5 0.5
+ scale 20 20
+ drawImage alpha2x2_argb32 0 0
+ restore
+ save
+ translate -0.5 0.5
+ scale -20 20
+ drawImage alpha2x2_argb32 0 0
+ restore
+ save
+ translate 0.5 -0.5
+ scale 20 -20
+ drawImage alpha2x2_argb32 0 0
+ restore
+ save
+ translate -0.5 -0.5
+ scale -20 -20
+ drawImage alpha2x2_argb32 0 0
+ restore
+restore
+
+save
+ translate 150 750
+ drawText 15 0 "clipping - argb32premul"
+ translate 50 50
+ setClipPath ellipse ReplaceClip
+ save
+ translate 0.5 0.5
+ scale 20 20
+ drawImage alpha2x2_argb32pre 0 0
+ restore
+ save
+ translate -0.5 0.5
+ scale -20 20
+ drawImage alpha2x2_argb32pre 0 0
+ restore
+ save
+ translate 0.5 -0.5
+ scale 20 -20
+ drawImage alpha2x2_argb32pre 0 0
+ restore
+ save
+ translate -0.5 -0.5
+ scale -20 -20
+ drawImage alpha2x2_argb32pre 0 0
+ restore
+restore
+
+save
+ translate 300 750
+ drawText 15 0 "clipping - rgb16"
+ translate 50 50
+ setClipPath ellipse ReplaceClip
+ save
+ translate 0.5 0.5
+ scale 20 20
+ drawImage alpha2x2_rgb16 0 0
+ restore
+ save
+ translate -0.5 0.5
+ scale -20 20
+ drawImage alpha2x2_rgb16 0 0
+ restore
+ save
+ translate 0.5 -0.5
+ scale 20 -20
+ drawImage alpha2x2_rgb16 0 0
+ restore
+ save
+ translate -0.5 -0.5
+ scale -20 -20
+ drawImage alpha2x2_rgb16 0 0
+ restore
+restore
diff --git a/tests/auto/moc/os9-newlines.h b/tests/auto/moc/os9-newlines.h
index fb9bbe424..85fa6713a 100644
--- a/tests/auto/moc/os9-newlines.h
+++ b/tests/auto/moc/os9-newlines.h
@@ -1 +1 @@
-/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions ** contained in the either Technology Preview License Agreement or the ** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ #include <QObject> class Os9Newlines : public QObject { Q_OBJECT public Q_SLOTS: inline void testSlot() {} };
+/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions ** contained in the either Technology Preview License Agreement or the ** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ #include <QObject> class Os9Newlines : public QObject { Q_OBJECT public Q_SLOTS: inline void testSlot() {} }; \ No newline at end of file
diff --git a/tests/auto/q3socket/tst_qsocket.cpp b/tests/auto/q3socket/tst_qsocket.cpp
index b07fa2fa4..854cc7527 100644
--- a/tests/auto/q3socket/tst_qsocket.cpp
+++ b/tests/auto/q3socket/tst_qsocket.cpp
@@ -124,8 +124,10 @@ void tst_Q3Socket::peerAddress_data()
QTest::addColumn<bool>("peerClosesConnection");
QTest::addColumn<QString>("peerAddr");
- QTest::newRow( "echo" ) << QString("qt-test-server.troll.no") << (uint)7 << false << QString("10.3.3.69");
- QTest::newRow( "daytime" ) << QString("qt-test-server.troll.no") << (uint)13 << true << QString("10.3.3.69");
+ QTest::newRow( "echo" ) << QtNetworkSettings::serverLocalName() << (uint)7 << false
+ << QtNetworkSettings::serverIP().toString();
+ QTest::newRow( "daytime" ) << QtNetworkSettings::serverLocalName() << (uint)13 << true
+ << QtNetworkSettings::serverIP().toString();
}
void tst_Q3Socket::peerAddress()
@@ -191,7 +193,7 @@ void tst_Q3Socket::emitConnectionRefused()
{
Q3Socket sock;
connect( &sock, SIGNAL(error(int)), SLOT(emitConnectionRefused_error(int)) );
- sock.connectToHost( "ares.troll.no", 12331 );
+ sock.connectToHost( QtNetworkSettings::serverLocalName(), 12331 );
emitConnectionRefused_errorReceived = false;
QTestEventLoop::instance().enterLoop( 30 );
@@ -225,8 +227,8 @@ void tst_Q3Socket::connectionAttempts_data()
QTest::addColumn<int>("port");
QTest::addColumn<bool>("expectedResult");
- QTest::newRow("fluke port 80") << QString("qt-test-server.troll.no") << 80 << true;
- QTest::newRow("fluke port 79") << QString("qt-test-server.troll.no") << 79 << false;
+ QTest::newRow("fluke port 80") << QtNetworkSettings::serverLocalName() << 80 << true;
+ QTest::newRow("fluke port 79") << QtNetworkSettings::serverLocalName() << 79 << false;
}
void tst_Q3Socket::connectionAttempts()
@@ -266,7 +268,7 @@ void tst_Q3Socket::canReadLine()
connect(&socket, SIGNAL(connected()), &loop, SLOT(quit()));
// timeout error will fail in #238
connect(&socket, SIGNAL(error(int)), &loop, SLOT(quit()));
- socket.connectToHost("qt-test-server.troll.no", 143);
+ socket.connectToHost(QtNetworkSettings::serverLocalName(), 143);
loop.exec();
diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
index e4b1a55ec..e5a9b012c 100644
--- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
+++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
@@ -548,7 +548,7 @@ void tst_Q3SqlCursor::unicode()
else
QFAIL( QString( "Strings differ at position %1: orig: %2, db: %3" ).arg( i ).arg( utf8str[ i ].unicode(), 0, 16 ).arg( res[ i ].unicode(), 0, 16 ) );
}
- if(db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QDB2"))
+ if((db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QDB2")) && res != utf8str)
QEXPECT_FAIL("", "See above message", Continue);
QVERIFY( res == utf8str );
}
@@ -721,7 +721,9 @@ void tst_Q3SqlCursor::updateNoPK()
// Sqlite returns 2, don't ask why.
QVERIFY(cur.update() != 0);
QString expect = "update " + qTableName("qtestPK") +
- " set id = 1 , name = NULL , num = NULL where " + qTableName("qtestPK") + ".id"
+ " set "+db.driver()->escapeIdentifier("id", QSqlDriver::FieldName)+" = 1 , "
+ +db.driver()->escapeIdentifier("name", QSqlDriver::FieldName)+" = NULL , "
+ +db.driver()->escapeIdentifier("num", QSqlDriver::FieldName)+" = NULL where " + qTableName("qtestPK") + ".id"
" IS NULL and " + qTableName("qtestPK") + ".name IS NULL and " +
qTableName("qtestPK") + ".num IS NULL";
if (!db.driver()->hasFeature(QSqlDriver::PreparedQueries)) {
diff --git a/tests/auto/q3urloperator/tst_q3urloperator.cpp b/tests/auto/q3urloperator/tst_q3urloperator.cpp
index f1e1059c5..a9e509631 100644
--- a/tests/auto/q3urloperator/tst_q3urloperator.cpp
+++ b/tests/auto/q3urloperator/tst_q3urloperator.cpp
@@ -55,6 +55,8 @@
#include <q3valuelist.h>
#include <qlist.h>
+#include "../network-settings.h"
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -150,7 +152,7 @@ void tst_Q3UrlOperator::initTestCase()
// prepare: make sure that there is a unique directory for FTP upload
// testing (to avoid parallel executed tests interfere with each other)
- ftpQtestUpload = "ftp://qt-test-server.troll.no/";
+ ftpQtestUpload = QString("ftp://%1/").arg(QtNetworkSettings::serverLocalName());
QString dir = QString( "qtest/upload/%1" ).arg( (ulong)this );
Q3UrlOperator opMkdir( ftpQtestUpload );
@@ -218,8 +220,8 @@ void tst_Q3UrlOperator::cleanup()
void tst_Q3UrlOperator::copy_data()
{
- const QString ftpQtest( "ftp://qt-test-server.troll.no/qtest" );
- const QString httpQtest( "http://qt-test-server.troll.no/qtest" );
+ const QString ftpQtest( QString("ftp://%1/qtest").arg(QtNetworkSettings::serverLocalName()) );
+ const QString httpQtest( QString("http://%1/qtest").arg(QtNetworkSettings::serverLocalName()) );
// argument for the constructor
QTest::addColumn<QString>("url");
@@ -339,8 +341,8 @@ void tst_Q3UrlOperator::slotFinished_copy( Q3NetworkOperation *op )
void tst_Q3UrlOperator::put_data()
{
- const QString httpQtest( "http://qt-test-server.troll.no/qtest/cgi-bin" );
- const QString httpQtestGet( "http://qt-test-server.troll.no/qtest/cgi-bin/retrieve_testfile.cgi" );
+ const QString httpQtest( QString("http://%1/qtest/cgi-bin").arg(QtNetworkSettings::serverLocalName()) );
+ const QString httpQtestGet( QString("http://%1/qtest/cgi-bin/retrieve_testfile.cgi").arg(QtNetworkSettings::serverLocalName()) );
QByteArray putData_1( 5 );
putData_1[0] = 'a';
diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp
index 9ef7f1db3..9a5c54984 100644
--- a/tests/auto/qlocale/tst_qlocale.cpp
+++ b/tests/auto/qlocale/tst_qlocale.cpp
@@ -327,9 +327,8 @@ void tst_QLocale::emptyCtor()
{ \
/* Test constructor without arguments. Needs separate process */ \
/* because of caching of the system locale. */ \
- QString oldEnv = QString::fromLocal8Bit(qgetenv("LANG")); \
- qputenv("LANG", QString(req_lc).toLocal8Bit()); \
QProcess process; \
+ process.setEnvironment(QStringList(env) << QString("LANG=%1").arg(req_lc)); \
process.start("syslocaleapp/syslocaleapp"); \
process.waitForReadyRead(); \
QString ret = QString(process.readAll()); \
@@ -337,18 +336,23 @@ void tst_QLocale::emptyCtor()
QVERIFY2(!ret.isEmpty(), "Cannot launch external process"); \
QVERIFY2(QString(exp_str) == ret, QString("Expected: " + QString(exp_str) + ", got: " \
+ ret + ". Requested: " + QString(req_lc)).toLatin1().constData()); \
- qputenv("LANG", oldEnv.toLocal8Bit()); \
+ }
+
+ // Get an environment free of any locale-related variables
+ QStringList env;
+ foreach (QString const& entry, QProcess::systemEnvironment()) {
+ if (entry.startsWith("LANG=") || entry.startsWith("LC_"))
+ continue;
+ env << entry;
}
// Get default locale.
- QString old = QString::fromLocal8Bit(qgetenv("LANG"));
- qputenv("LANG", "");
QProcess p;
+ p.setEnvironment(env);
p.start("syslocaleapp/syslocaleapp");
p.waitForReadyRead();
QString defaultLoc = QString(p.readAll());
p.waitForFinished();
- qputenv("LANG", old.toLocal8Bit());
TEST_CTOR("C", "C")
TEST_CTOR("bla", "C")
diff --git a/tests/auto/qmake/testdata/simple_app_build/README b/tests/auto/qmake/testdata/simple_app_build/README
new file mode 100644
index 000000000..81dc596e5
--- /dev/null
+++ b/tests/auto/qmake/testdata/simple_app_build/README
@@ -0,0 +1 @@
+Placeholder file to ensure this directory exists
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index 1d19ffa14..ec9c7b47c 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -95,6 +95,7 @@ private slots:
void task250673_activeMultiColumnSubMenuPosition();
void task256918_setFont();
void menuSizeHint();
+ void task258920_mouseBorder();
protected slots:
void onActivated(QAction*);
void onHighlighted(QAction*);
@@ -763,5 +764,40 @@ void tst_QMenu::menuSizeHint()
QCOMPARE(resSize, menu.sizeHint());
}
+class Menu258920 : public QMenu
+{
+ Q_OBJECT
+public slots:
+ void paintEvent(QPaintEvent *e)
+ {
+ QMenu::paintEvent(e);
+ painted = true;
+ }
+
+public:
+ bool painted;
+};
+
+void tst_QMenu::task258920_mouseBorder()
+{
+ Menu258920 menu;
+ QAction *action = menu.addAction("test");
+
+ menu.popup(QPoint());
+ QTest::qWait(100);
+ QRect actionRect = menu.actionGeometry(action);
+ QTest::mouseMove(&menu, actionRect.center());
+ QTest::qWait(30);
+ QTest::mouseMove(&menu, actionRect.center() + QPoint(10, 0));
+ QTest::qWait(30);
+ QCOMPARE(action, menu.activeAction());
+ menu.painted = false;
+ QTest::mouseMove(&menu, QPoint(actionRect.center().x(), actionRect.bottom() + 1));
+ QTest::qWait(30);
+ QCOMPARE(static_cast<QAction*>(0), menu.activeAction());
+ QVERIFY(menu.painted);
+}
+
+
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"
diff --git a/tests/auto/qsharedpointer/qsharedpointer.pro b/tests/auto/qsharedpointer/qsharedpointer.pro
index 90fde066b..1759323fd 100644
--- a/tests/auto/qsharedpointer/qsharedpointer.pro
+++ b/tests/auto/qsharedpointer/qsharedpointer.pro
@@ -1,9 +1,14 @@
load(qttest_p4)
+
SOURCES += tst_qsharedpointer.cpp \
forwarddeclaration.cpp \
- forwarddeclared.cpp
+ forwarddeclared.cpp \
+ wrapper.cpp
+
+HEADERS += forwarddeclared.h \
+ wrapper.h
+
QT = core
DEFINES += SRCDIR=\\\"$$PWD/\\\"
-requires(contains(QT_CONFIG,private_tests))
+
include(externaltests.pri)
-HEADERS += forwarddeclared.h
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index ae5155ece..210f3fae1 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -41,8 +41,19 @@
#define QT_SHAREDPOINTER_TRACK_POINTERS
#include "qsharedpointer.h"
-#include "externaltests.h"
#include <QtTest/QtTest>
+#include <QtCore/QThread>
+#include <QtCore/QVector>
+
+#include "externaltests.h"
+#include "wrapper.h"
+
+#include <stdlib.h>
+#include <time.h>
+
+namespace QtSharedPointer {
+ Q_CORE_EXPORT void internalSafetyCheckCleanCheck();
+}
class tst_QSharedPointer: public QObject
{
@@ -68,10 +79,34 @@ private slots:
void constCorrectness();
void customDeleter();
void creating();
+ void mixTrackingPointerCode();
+ void threadStressTest_data();
+ void threadStressTest();
void validConstructs();
void invalidConstructs_data();
void invalidConstructs();
+
+public slots:
+ void cleanup() { check(); }
+
+public:
+ inline void check()
+ {
+#ifdef QT_BUILD_INTERNAL
+ QtSharedPointer::internalSafetyCheckCleanCheck();
+#endif
+ }
+};
+
+template <typename Base>
+class RefCountHack: public Base
+{
+public:
+ using Base::d;
};
+template<typename Base> static inline
+QtSharedPointer::ExternalRefCountData *refCountData(const Base &b)
+{ return static_cast<const RefCountHack<Base> *>(&b)->d; }
class Data
{
@@ -156,8 +191,8 @@ void tst_QSharedPointer::basics()
QVERIFY(! (ptr == otherData));
QVERIFY(! (otherData == ptr));
}
- QVERIFY(!ptr.d || ptr.d->weakref == 1);
- QVERIFY(!ptr.d || ptr.d->strongref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1);
{
// create another object:
@@ -169,8 +204,8 @@ void tst_QSharedPointer::basics()
// otherData is deleted here
}
- QVERIFY(!ptr.d || ptr.d->weakref == 1);
- QVERIFY(!ptr.d || ptr.d->strongref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1);
{
// create a copy:
@@ -186,8 +221,8 @@ void tst_QSharedPointer::basics()
QCOMPARE(copy.data(), aData);
QVERIFY(copy == aData);
}
- QVERIFY(!ptr.d || ptr.d->weakref == 1);
- QVERIFY(!ptr.d || ptr.d->strongref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1);
{
// create a weak reference:
@@ -218,8 +253,8 @@ void tst_QSharedPointer::basics()
QVERIFY(strong == ptr);
QCOMPARE(strong.data(), aData);
}
- QVERIFY(!ptr.d || ptr.d->weakref == 1);
- QVERIFY(!ptr.d || ptr.d->strongref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1);
// aData is deleted here
}
@@ -435,15 +470,15 @@ void tst_QSharedPointer::upCast()
QVERIFY(baseptr == derivedptr);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QWeakPointer<DerivedData> derivedptr = qWeakPointerCast<DerivedData>(baseptr);
QVERIFY(baseptr == derivedptr);
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QWeakPointer<Data> weakptr = baseptr;
@@ -451,16 +486,16 @@ void tst_QSharedPointer::upCast()
QVERIFY(baseptr == derivedptr);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QSharedPointer<DerivedData> derivedptr = baseptr.staticCast<DerivedData>();
QVERIFY(baseptr == derivedptr);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
}
class OtherObject: public QObject
@@ -496,6 +531,7 @@ void tst_QSharedPointer::objectCast()
QVERIFY(ptr == data);
#endif
}
+ check();
{
const OtherObject *data = new OtherObject;
@@ -523,6 +559,7 @@ void tst_QSharedPointer::objectCast()
QVERIFY(ptr == data);
#endif
}
+ check();
{
OtherObject *data = new OtherObject;
@@ -564,6 +601,7 @@ void tst_QSharedPointer::objectCast()
QVERIFY(otherptr.isNull());
#endif
}
+ check();
}
void tst_QSharedPointer::differentPointers()
@@ -583,6 +621,7 @@ void tst_QSharedPointer::differentPointers()
QVERIFY(baseptr == aData);
QVERIFY(baseptr == aBase);
}
+ check();
{
DiffPtrDerivedData *aData = new DiffPtrDerivedData;
@@ -597,6 +636,7 @@ void tst_QSharedPointer::differentPointers()
QVERIFY(ptr == aBase);
QVERIFY(baseptr == aData);
}
+ check();
{
DiffPtrDerivedData *aData = new DiffPtrDerivedData;
@@ -613,6 +653,7 @@ void tst_QSharedPointer::differentPointers()
QVERIFY(baseptr == aData);
QVERIFY(baseptr == aBase);
}
+ check();
}
void tst_QSharedPointer::virtualBaseDifferentPointers()
@@ -632,6 +673,7 @@ void tst_QSharedPointer::virtualBaseDifferentPointers()
QVERIFY(baseptr == aData);
QVERIFY(baseptr == aBase);
}
+ check();
{
VirtualDerived *aData = new VirtualDerived;
@@ -648,6 +690,7 @@ void tst_QSharedPointer::virtualBaseDifferentPointers()
QVERIFY(baseptr == aData);
QVERIFY(baseptr == aBase);
}
+ check();
}
#ifndef QTEST_NO_RTTI
@@ -662,8 +705,8 @@ void tst_QSharedPointer::dynamicCast()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QWeakPointer<Data> weakptr = baseptr;
@@ -672,8 +715,8 @@ void tst_QSharedPointer::dynamicCast()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QSharedPointer<DerivedData> derivedptr = baseptr.dynamicCast<DerivedData>();
@@ -681,8 +724,8 @@ void tst_QSharedPointer::dynamicCast()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
}
void tst_QSharedPointer::dynamicCastDifferentPointers()
@@ -697,8 +740,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QWeakPointer<Data> weakptr = baseptr;
@@ -707,8 +750,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QSharedPointer<DiffPtrDerivedData> derivedptr = baseptr.dynamicCast<DiffPtrDerivedData>();
@@ -716,8 +759,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
Stuffing *nakedptr = dynamic_cast<Stuffing *>(baseptr.data());
@@ -742,8 +785,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QWeakPointer<Data> weakptr = baseptr;
@@ -752,8 +795,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QSharedPointer<VirtualDerived> derivedptr = baseptr.dynamicCast<VirtualDerived>();
@@ -761,8 +804,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
}
void tst_QSharedPointer::dynamicCastFailure()
@@ -774,15 +817,15 @@ void tst_QSharedPointer::dynamicCastFailure()
QSharedPointer<DerivedData> derivedptr = qSharedPointerDynamicCast<DerivedData>(baseptr);
QVERIFY(derivedptr.isNull());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QSharedPointer<DerivedData> derivedptr = baseptr.dynamicCast<DerivedData>();
QVERIFY(derivedptr.isNull());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
}
#endif
@@ -814,6 +857,7 @@ void tst_QSharedPointer::constCorrectness()
ptr = cvptr.constCast<Data>();
#endif
}
+ check();
{
Data *aData = new Data;
@@ -827,6 +871,7 @@ void tst_QSharedPointer::constCorrectness()
QCOMPARE(cptr.data(), aData);
QCOMPARE(cptr.operator->(), aData);
}
+ check();
}
static int customDeleterFnCallCount;
@@ -836,9 +881,14 @@ void customDeleterFn(Data *ptr)
delete ptr;
}
+static int refcount;
+
template <typename T>
struct CustomDeleter
{
+ CustomDeleter() { ++refcount; }
+ CustomDeleter(const CustomDeleter &) { ++refcount; }
+ ~CustomDeleter() { --refcount; }
inline void operator()(T *ptr)
{
delete ptr;
@@ -855,11 +905,13 @@ void tst_QSharedPointer::customDeleter()
QSharedPointer<Data> ptr2(new Data, &Data::alsoDelete);
QSharedPointer<Data> ptr3(new Data, &Data::virtualDelete);
}
+ check();
{
QSharedPointer<DerivedData> ptr(new DerivedData, &Data::doDelete);
QSharedPointer<DerivedData> ptr2(new DerivedData, &Data::alsoDelete);
QSharedPointer<DerivedData> ptr3(new DerivedData, &Data::virtualDelete);
}
+ check();
customDeleterFnCallCount = 0;
{
@@ -868,6 +920,7 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 0);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
customDeleterFnCallCount = 0;
{
@@ -877,6 +930,7 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 1);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
customDeleterFnCallCount = 0;
{
@@ -886,6 +940,7 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 1);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
customDeleterFnCallCount = 0;
{
@@ -894,6 +949,7 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 0);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
customDeleterFnCallCount = 0;
{
@@ -902,6 +958,7 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 0);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
customDeleterFnCallCount = 0;
{
@@ -914,6 +971,7 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 0);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
customDeleterFnCallCount = 0;
{
@@ -926,7 +984,9 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 0);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
+ refcount = 0;
CustomDeleter<Data> dataDeleter;
dataDeleter.callCount = 0;
{
@@ -935,6 +995,8 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(dataDeleter.callCount, 0);
}
QCOMPARE(dataDeleter.callCount, 1);
+ QCOMPARE(refcount, 1);
+ check();
dataDeleter.callCount = 0;
{
@@ -944,6 +1006,8 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(dataDeleter.callCount, 0);
}
QCOMPARE(dataDeleter.callCount, 1);
+ QCOMPARE(refcount, 1);
+ check();
dataDeleter.callCount = 0;
{
@@ -956,6 +1020,8 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(dataDeleter.callCount, 0);
}
QCOMPARE(dataDeleter.callCount, 1);
+ QCOMPARE(refcount, 1);
+ check();
dataDeleter.callCount = 0;
{
@@ -964,6 +1030,8 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(dataDeleter.callCount, 0);
}
QCOMPARE(dataDeleter.callCount, 1);
+ QCOMPARE(refcount, 1);
+ check();
CustomDeleter<DerivedData> derivedDataDeleter;
derivedDataDeleter.callCount = 0;
@@ -976,6 +1044,8 @@ void tst_QSharedPointer::customDeleter()
}
QCOMPARE(dataDeleter.callCount, 0);
QCOMPARE(derivedDataDeleter.callCount, 1);
+ QCOMPARE(refcount, 2);
+ check();
derivedDataDeleter.callCount = 0;
dataDeleter.callCount = 0;
@@ -992,6 +1062,8 @@ void tst_QSharedPointer::customDeleter()
}
QCOMPARE(dataDeleter.callCount, 1);
QCOMPARE(derivedDataDeleter.callCount, 0);
+ QCOMPARE(refcount, 2);
+ check();
derivedDataDeleter.callCount = 0;
dataDeleter.callCount = 0;
@@ -1008,6 +1080,7 @@ void tst_QSharedPointer::customDeleter()
}
QCOMPARE(dataDeleter.callCount, 0);
QCOMPARE(derivedDataDeleter.callCount, 1);
+ QCOMPARE(refcount, 2);
}
void tst_QSharedPointer::creating()
@@ -1025,12 +1098,13 @@ void tst_QSharedPointer::creating()
ptr.clear();
QCOMPARE(Data::destructorCounter, 1);
}
+ check();
Data::generationCounter = Data::destructorCounter = 0;
{
QSharedPointer<Data> ptr = QSharedPointer<Data>::create();
QWeakPointer<Data> weakptr = ptr;
- QtSharedPointer::ExternalRefCountData *d = ptr.d;
+ QtSharedPointer::ExternalRefCountData *d = refCountData(ptr);
ptr.clear();
QVERIFY(ptr.isNull());
@@ -1040,6 +1114,7 @@ void tst_QSharedPointer::creating()
QVERIFY(d->weakref == 1);
QVERIFY(d->strongref == 0);
}
+ check();
Data::generationCounter = Data::destructorCounter = 0;
DerivedData::derivedDestructorCounter = 0;
@@ -1052,6 +1127,7 @@ void tst_QSharedPointer::creating()
QCOMPARE(Data::destructorCounter, 1);
QCOMPARE(DerivedData::derivedDestructorCounter, 1);
}
+ check();
{
QSharedPointer<Data> ptr = QSharedPointer<DiffPtrDerivedData>::create();
@@ -1060,6 +1136,7 @@ void tst_QSharedPointer::creating()
QCOMPARE(ptr.staticCast<DiffPtrDerivedData>()->buffer[3]+0, 16-3);
QCOMPARE(ptr.staticCast<DiffPtrDerivedData>()->buffer[0]+0, 16);
}
+ check();
{
QSharedPointer<VirtualDerived> ptr = QSharedPointer<VirtualDerived>::create();
@@ -1069,6 +1146,7 @@ void tst_QSharedPointer::creating()
QSharedPointer<Data> baseptr = ptr;
QCOMPARE(baseptr->classLevel(), 4);
}
+ check();
{
QSharedPointer<QObject> ptr = QSharedPointer<QObject>::create();
@@ -1079,11 +1157,148 @@ void tst_QSharedPointer::creating()
QVERIFY(qptr.isNull());
}
+ check();
{
QSharedPointer<QObject> ptr = QSharedPointer<OtherObject>::create();
QCOMPARE(ptr->metaObject(), &OtherObject::staticMetaObject);
}
+ check();
+}
+
+void tst_QSharedPointer::mixTrackingPointerCode()
+{
+ {
+ // pointer created with tracking
+ // deleted in code without tracking
+ QSharedPointer<int> ptr = QSharedPointer<int>(new int(42));
+ Wrapper w(ptr);
+ ptr.clear();
+ }
+ check();
+
+ {
+ // pointer created without tracking
+ // deleted in code with tracking
+ Wrapper w = Wrapper::create();
+ w.ptr.clear();
+ }
+}
+
+class ThreadData
+{
+ QAtomicInt * volatile ptr;
+public:
+ ThreadData(QAtomicInt *p) : ptr(p) { }
+ ~ThreadData() { ++ptr; }
+ void ref()
+ {
+ // if we're called after the destructor, we'll crash
+ ptr->ref();
+ }
+};
+
+class StrongThread: public QThread
+{
+protected:
+ void run()
+ {
+ usleep(rand() % 2000);
+ ptr->ref();
+ ptr.clear();
+ }
+public:
+ QSharedPointer<ThreadData> ptr;
+};
+
+class WeakThread: public QThread
+{
+protected:
+ void run()
+ {
+ usleep(rand() % 2000);
+ QSharedPointer<ThreadData> ptr = weak;
+ if (ptr)
+ ptr->ref();
+ ptr.clear();
+ }
+public:
+ QWeakPointer<ThreadData> weak;
+};
+
+void tst_QSharedPointer::threadStressTest_data()
+{
+ QTest::addColumn<int>("strongThreadCount");
+ QTest::addColumn<int>("weakThreadCount");
+
+ QTest::newRow("0+0") << 0 << 0;
+ QTest::newRow("1+0") << 1 << 0;
+ QTest::newRow("2+0") << 2 << 0;
+ QTest::newRow("10+0") << 10 << 0;
+
+ QTest::newRow("0+1") << 0 << 1;
+ QTest::newRow("1+1") << 1 << 1;
+
+ QTest::newRow("2+10") << 2 << 10;
+ QTest::newRow("5+10") << 5 << 10;
+ QTest::newRow("5+30") << 5 << 30;
+
+ QTest::newRow("100+100") << 100 << 100;
+}
+
+void tst_QSharedPointer::threadStressTest()
+{
+ QFETCH(int, strongThreadCount);
+ QFETCH(int, weakThreadCount);
+
+ int guard1[128];
+ QAtomicInt counter;
+ int guard2[128];
+
+ memset(guard1, 0, sizeof guard1);
+ memset(guard2, 0, sizeof guard2);
+
+ for (int r = 0; r < 5; ++r) {
+ QVector<QThread*> allThreads(6 * qMax(strongThreadCount, weakThreadCount) + 3, 0);
+ QSharedPointer<ThreadData> base = QSharedPointer<ThreadData>(new ThreadData(&counter));
+ counter = 0;
+
+ // set the pointers
+ for (int i = 0; i < strongThreadCount; ++i) {
+ StrongThread *t = new StrongThread;
+ t->ptr = base;
+ allThreads[2 * i] = t;
+ }
+ for (int i = 0; i < weakThreadCount; ++i) {
+ WeakThread *t = new WeakThread;
+ t->weak = base;
+ allThreads[6 * i + 3] = t;
+ }
+
+ base.clear();
+
+ srand(time(NULL));
+ // start threads
+ for (int i = 0; i < allThreads.count(); ++i)
+ if (allThreads[i]) allThreads[i]->start();
+
+ // wait for them to finish
+ for (int i = 0; i < allThreads.count(); ++i)
+ if (allThreads[i]) allThreads[i]->wait();
+ qDeleteAll(allThreads);
+
+ // ensure the guards aren't touched
+ for (uint i = 0; i < sizeof guard1 / sizeof guard1[0]; ++i)
+ QVERIFY(!guard1[i]);
+ for (uint i = 0; i < sizeof guard2 / sizeof guard2[0]; ++i)
+ QVERIFY(!guard2[i]);
+
+ // verify that the count is the right range
+ int minValue = strongThreadCount;
+ int maxValue = strongThreadCount + weakThreadCount;
+ QVERIFY(counter >= minValue);
+ QVERIFY(counter <= maxValue);
+ }
}
void tst_QSharedPointer::validConstructs()
@@ -1195,6 +1410,7 @@ void tst_QSharedPointer::invalidConstructs_data()
"QSharedPointer<Data> b;\n"
"if (a + b) return;";
+#if QT_VERSION >= 0x040600
// two objects with the same pointer
QTest::newRow("same-pointer")
<< &QTest::QExternalTest::tryRunFail
@@ -1208,6 +1424,7 @@ void tst_QSharedPointer::invalidConstructs_data()
<< "Data *aData = new Data;\n"
"QSharedPointer<Data> ptr1 = QSharedPointer<Data>(aData);"
"ptr1 = QSharedPointer<Data>(aData);";
+#endif
// any type of cast for unrelated types:
// (we have no reinterpret_cast)
diff --git a/tests/auto/qsharedpointer/wrapper.cpp b/tests/auto/qsharedpointer/wrapper.cpp
new file mode 100644
index 000000000..7640e6846
--- /dev/null
+++ b/tests/auto/qsharedpointer/wrapper.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifdef QT_SHAREDPOINTER_TRACK_POINTERS
+# undef QT_SHAREDPOINTER_TRACK_POINTERS
+#endif
+#include <QtCore/qsharedpointer.h>
+#include "wrapper.h"
+
+Wrapper::Wrapper(const QSharedPointer<int> &value)
+ : ptr(value)
+{
+}
+
+Wrapper::~Wrapper()
+{
+}
+
+Wrapper Wrapper::create()
+{
+ return Wrapper(QSharedPointer<int>(new int(-47)));
+}
diff --git a/tests/auto/qsharedpointer/wrapper.h b/tests/auto/qsharedpointer/wrapper.h
new file mode 100644
index 000000000..a888063ed
--- /dev/null
+++ b/tests/auto/qsharedpointer/wrapper.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef WRAPPER_H
+#define WRAPPER_H
+
+template <class T> class QSharedPointer;
+class Wrapper
+{
+public:
+ QSharedPointer<int> ptr;
+ Wrapper(const QSharedPointer<int> &);
+ ~Wrapper();
+
+ static Wrapper create();
+};
+
+#endif // WRAPPER_H
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index e1f1d3c1b..4cf8d562a 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -2028,8 +2028,8 @@ void tst_QSqlDatabase::mysql_multiselect()
QVERIFY_SQL(q, exec("select version()"));
QVERIFY_SQL(q, next());
QString version=tst_Databases::getMySqlVersion( db );
- int ver=version.section(QChar::fromLatin1('.'),0,1).toDouble();
- if (ver >= 4.1)
+ double ver=version.section(QChar::fromLatin1('.'),0,1).toDouble();
+ if (ver < 4.1)
QSKIP("Test requires MySQL >= 4.1", SkipSingle);
QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtest") + "; SELECT * FROM " + qTableName("qtest")));
diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
index 1e23d3d9a..d836486a1 100644
--- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
+++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
@@ -930,13 +930,15 @@ void tst_QSqlRelationalTableModel::casing()
QSqlQuery q(db);
QVERIFY_SQL( q, exec("create table " + qTableName("CASETEST1", db.driver()).toUpper() +
" (id int not null primary key, name varchar(20), title_key int, another_title_key int)"));
+
+ if( !q.exec("create table " + qTableName("casetest1", db.driver()) +
+ " (ident int not null primary key, name varchar(20), title_key int)"))
+ QSKIP("The casing test for this database is irrelevant since this database does not treat different cases as separate entities", SkipAll);
+
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(1, 'harry', 1, 2)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(2, 'trond', 2, 1)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(3, 'vohi', 1, 2)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(4, 'boris', 2, 2)"));
-
- QVERIFY_SQL( q, exec("create table " + qTableName("casetest1", db.driver()) +
- " (ident int not null primary key, name varchar(20), title_key int)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(1, 'jerry', 1)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(2, 'george', 2)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(4, 'kramer', 2)"));
diff --git a/tests/auto/qstate/tst_qstate.cpp b/tests/auto/qstate/tst_qstate.cpp
index 78b98530d..43ea7fe56 100644
--- a/tests/auto/qstate/tst_qstate.cpp
+++ b/tests/auto/qstate/tst_qstate.cpp
@@ -250,8 +250,9 @@ class EventTestTransition: public QAbstractTransition
{
public:
EventTestTransition(QEvent::Type type, QState *targetState)
- : QAbstractTransition(QList<QAbstractState*>() << targetState), m_type(type)
- {
+ : QAbstractTransition(), m_type(type)
+ {
+ setTargetState(targetState);
}
protected:
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 32812e215..97115bbad 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -226,7 +226,8 @@ class TestTransition : public QAbstractTransition
{
public:
TestTransition(QAbstractState *target)
- : QAbstractTransition(QList<QAbstractState*>() << target) {}
+ : QAbstractTransition()
+ { setTargetState(target); }
QList<int> triggers;
protected:
virtual bool eventTest(QEvent *) {
@@ -249,7 +250,8 @@ class EventTransition : public QAbstractTransition
{
public:
EventTransition(QEvent::Type type, QAbstractState *target, QState *parent = 0)
- : QAbstractTransition(QList<QAbstractState*>() << target, parent), m_type(type) {}
+ : QAbstractTransition(parent), m_type(type)
+ { setTargetState(target); }
protected:
virtual bool eventTest(QEvent *e) {
return (e->type() == m_type);
@@ -1514,7 +1516,8 @@ class StringTransition : public QAbstractTransition
{
public:
StringTransition(const QString &value, QAbstractState *target)
- : QAbstractTransition(QList<QAbstractState*>() << target), m_value(value) {}
+ : QAbstractTransition(), m_value(value)
+ { setTargetState(target); }
protected:
virtual bool eventTest(QEvent *e)
@@ -1737,7 +1740,8 @@ public:
: QSignalTransition(sourceState) {}
TestSignalTransition(QObject *sender, const char *signal,
QAbstractState *target)
- : QSignalTransition(sender, signal, QList<QAbstractState*>() << target) {}
+ : QSignalTransition(sender, signal)
+ { setTargetState(target); }
QVariantList argumentsReceived() const {
return m_args;
}
@@ -2022,20 +2026,15 @@ void tst_QStateMachine::signalTransitions()
void tst_QStateMachine::eventTransitions()
{
QPushButton button;
- for (int x = 0; x < 2; ++x) {
+ {
QStateMachine machine;
QState *s0 = new QState(&machine);
QFinalState *s1 = new QFinalState(&machine);
QMouseEventTransition *trans;
- if (x == 0) {
- trans = new QMouseEventTransition(&button, QEvent::MouseButtonPress, Qt::LeftButton);
- QCOMPARE(trans->targetState(), (QAbstractState*)0);
- trans->setTargetState(s1);
- } else {
- trans = new QMouseEventTransition(&button, QEvent::MouseButtonPress,
- Qt::LeftButton, QList<QAbstractState*>() << s1);
- }
+ trans = new QMouseEventTransition(&button, QEvent::MouseButtonPress, Qt::LeftButton);
+ QCOMPARE(trans->targetState(), (QAbstractState*)0);
+ trans->setTargetState(s1);
QCOMPARE(trans->eventType(), QEvent::MouseButtonPress);
QCOMPARE(trans->button(), Qt::LeftButton);
QCOMPARE(trans->targetState(), (QAbstractState*)s1);
@@ -2071,7 +2070,7 @@ void tst_QStateMachine::eventTransitions()
QTest::mousePress(&button2, Qt::LeftButton);
QTRY_COMPARE(finishedSpy.count(), 4);
}
- for (int x = 0; x < 3; ++x) {
+ for (int x = 0; x < 2; ++x) {
QStateMachine machine;
QState *s0 = new QState(&machine);
QFinalState *s1 = new QFinalState(&machine);
@@ -2087,9 +2086,6 @@ void tst_QStateMachine::eventTransitions()
} else if (x == 1) {
trans = new QEventTransition(&button, QEvent::MouseButtonPress);
trans->setTargetState(s1);
- } else {
- trans = new QEventTransition(&button, QEvent::MouseButtonPress,
- QList<QAbstractState*>() << s1);
}
QCOMPARE(trans->eventObject(), (QObject*)&button);
QCOMPARE(trans->eventType(), QEvent::MouseButtonPress);
diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp
index 69b84e287..76a005bd3 100644
--- a/tests/auto/selftests/tst_selftests.cpp
+++ b/tests/auto/selftests/tst_selftests.cpp
@@ -184,9 +184,10 @@ void tst_Selftests::runSubTest_data()
QTest::newRow("benchliboptions") << "benchliboptions" << QStringList("-eventcounter");
QTest::newRow("benchlibwalltime") << "benchlibwalltime" << QStringList();
- //### QWS tests are currently run on a virtual machine, where ticks are not
- //### monotonously increasing
-#if defined(HAVE_TICK_COUNTER) && !defined(Q_WS_QWS)
+ //### This test is affected by the speed of the CPU and whether the tick counter is
+ //### monotonically increasing. It won't work on some machines so leave it off by default.
+ //### Feel free to uncomment for your own testing.
+#if 0
QTest::newRow("benchlibtickcounter") << "benchlibtickcounter" << QStringList("-tickcounter");
#endif
diff --git a/tests/auto/uic3/uic3.pro b/tests/auto/uic3/uic3.pro
index 520f95a2f..72a1304f0 100644
--- a/tests/auto/uic3/uic3.pro
+++ b/tests/auto/uic3/uic3.pro
@@ -6,3 +6,6 @@ TARGET = tst_uic3
# This test is not run on wince (I think)
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+requires(contains(QT_CONFIG,qt3support))
+
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp
index a38454453..23562db63 100644
--- a/tools/assistant/tools/assistant/centralwidget.cpp
+++ b/tools/assistant/tools/assistant/centralwidget.cpp
@@ -43,6 +43,7 @@
#include "helpviewer.h"
#include "searchwidget.h"
#include "mainwindow.h"
+#include "preferencesdialog.h"
#include <QtCore/QDir>
#include <QtCore/QEvent>
@@ -423,6 +424,27 @@ void CentralWidget::setSource(const QUrl &url)
tabWidget->setTabText(lastTabPage, quoteTabTitle(viewer->documentTitle()));
}
+void CentralWidget::setupWidget()
+{
+ int option = helpEngine->customValue(QLatin1String("StartOption"),
+ ShowLastPages).toInt();
+
+ if (option != ShowLastPages) {
+ QString homePage;
+ if (option == ShowHomePage) {
+ homePage = helpEngine->customValue(QLatin1String("defaultHomepage"),
+ QLatin1String("help")).toString();
+ homePage = helpEngine->customValue(QLatin1String("homepage"),
+ homePage).toString();
+ }
+ if (option == ShowBlankPage)
+ homePage = QLatin1String("about:blank");
+ setSource(homePage);
+ } else {
+ setLastShownPages();
+ }
+}
+
void CentralWidget::setLastShownPages()
{
const QLatin1String key("LastShownPages");
@@ -739,8 +761,10 @@ void CentralWidget::setTabTitle(const QUrl &url)
QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget);
for (int tab = 0; tab < tabBar->count(); ++tab) {
HelpViewer *viewer = qobject_cast<HelpViewer*>(tabWidget->widget(tab));
- if (viewer)
- tabWidget->setTabText(tab, viewer->documentTitle().trimmed());
+ if (viewer) {
+ tabWidget->setTabText(tab,
+ quoteTabTitle(viewer->documentTitle().trimmed()));
+ }
}
#else
HelpViewer *viewer = currentHelpViewer();
diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h
index ca9caaf0d..f7ce1d53c 100644
--- a/tools/assistant/tools/assistant/centralwidget.h
+++ b/tools/assistant/tools/assistant/centralwidget.h
@@ -111,7 +111,7 @@ public:
CentralWidget(QHelpEngine *engine, MainWindow *parent);
~CentralWidget();
- void setLastShownPages();
+ void setupWidget();
bool hasSelection() const;
QUrl currentSource() const;
QString currentTitle() const;
@@ -188,6 +188,7 @@ private:
void initPrinter();
QString quoteTabTitle(const QString &title) const;
void highlightSearchTerms();
+ void setLastShownPages();
private:
int lastTabPage;
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp
index 0c1723c9f..bc73b80d6 100644
--- a/tools/assistant/tools/assistant/mainwindow.cpp
+++ b/tools/assistant/tools/assistant/mainwindow.cpp
@@ -407,7 +407,7 @@ void MainWindow::insertLastPages()
if (m_cmdLine->url().isValid())
m_centralWidget->setSource(m_cmdLine->url());
else
- m_centralWidget->setLastShownPages();
+ m_centralWidget->setupWidget();
if (m_cmdLine->search() == CmdLineParser::Activate)
showSearch();
diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp
index fa7019640..2b58c649f 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.cpp
+++ b/tools/assistant/tools/assistant/preferencesdialog.cpp
@@ -146,10 +146,13 @@ PreferencesDialog::~PreferencesDialog()
emit updateBrowserFont();
}
- if (!m_ui.homePageLineEdit->text().isEmpty()) {
- key = QLatin1String("homepage");
- m_helpEngine->setCustomValue(key, m_ui.homePageLineEdit->text());
- }
+ QString homePage = m_ui.homePageLineEdit->text();
+ if (homePage.isEmpty())
+ homePage = QLatin1String("help");
+ m_helpEngine->setCustomValue(QLatin1String("homepage"), homePage);
+
+ int option = m_ui.helpStartComboBox->currentIndex();
+ m_helpEngine->setCustomValue(QLatin1String("StartOption"), option);
}
void PreferencesDialog::showDialog()
@@ -379,6 +382,8 @@ void PreferencesDialog::applyChanges()
CentralWidget* widget = CentralWidget::instance();
for (int i = m_TabsToClose.count(); --i >= 0;)
widget->closeTabAt(m_TabsToClose.at(i));
+ if (widget->availableHelpViewer()== 0)
+ widget->setSource(QUrl(QLatin1String("about:blank")));
if (m_unregDocs.count()) {
foreach (const QString &doc, m_unregDocs)
@@ -483,22 +488,23 @@ void PreferencesDialog::updateOptionsPage()
homepage = m_helpEngine->customValue(QLatin1String("defaultHomepage"),
QLatin1String("help")).toString();
}
-
m_ui.homePageLineEdit->setText(homepage);
- connect(m_ui.currentPageButton, SIGNAL(pressed()), this,
- SLOT(currentHomepageChanged()));
- connect(m_ui.restoreDefaultHomePageButton, SIGNAL(pressed()), this,
- SLOT(restoreDefaultHomepage()));
+
+ int option = m_helpEngine->customValue(QLatin1String("StartOption"),
+ ShowLastPages).toInt();
+ m_ui.helpStartComboBox->setCurrentIndex(option);
+
+ connect(m_ui.blankPageButton, SIGNAL(clicked()), this, SLOT(setBlankPage()));
+ connect(m_ui.currentPageButton, SIGNAL(clicked()), this, SLOT(setCurrentPage()));
+ connect(m_ui.defaultPageButton, SIGNAL(clicked()), this, SLOT(setDefaultPage()));
}
-void PreferencesDialog::restoreDefaultHomepage()
+void PreferencesDialog::setBlankPage()
{
- QString homepage = m_helpEngine->customValue(QLatin1String("defaultHomepage"),
- QLatin1String("help")).toString();
- m_ui.homePageLineEdit->setText(homepage);
+ m_ui.homePageLineEdit->setText(QLatin1String("about:blank"));
}
-void PreferencesDialog::currentHomepageChanged()
+void PreferencesDialog::setCurrentPage()
{
QString homepage = CentralWidget::instance()->currentSource().toString();
if (homepage.isEmpty())
@@ -507,4 +513,11 @@ void PreferencesDialog::currentHomepageChanged()
m_ui.homePageLineEdit->setText(homepage);
}
+void PreferencesDialog::setDefaultPage()
+{
+ QString homepage = m_helpEngine->customValue(QLatin1String("defaultHomepage"),
+ QLatin1String("help")).toString();
+ m_ui.homePageLineEdit->setText(homepage);
+}
+
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/preferencesdialog.h b/tools/assistant/tools/assistant/preferencesdialog.h
index 5b8ffe8c8..4471b5f6c 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.h
+++ b/tools/assistant/tools/assistant/preferencesdialog.h
@@ -50,6 +50,12 @@ QT_BEGIN_NAMESPACE
class FontPanel;
class QHelpEngineCore;
+enum {
+ ShowHomePage = 0,
+ ShowBlankPage = 1,
+ ShowLastPages = 2
+};
+
class PreferencesDialog : public QDialog
{
Q_OBJECT
@@ -72,8 +78,10 @@ private slots:
void appFontSettingChanged(int index);
void browserFontSettingToggled(bool on);
void browserFontSettingChanged(int index);
- void restoreDefaultHomepage();
- void currentHomepageChanged();
+
+ void setBlankPage();
+ void setCurrentPage();
+ void setDefaultPage();
signals:
void updateBrowserFont();
diff --git a/tools/assistant/tools/assistant/preferencesdialog.ui b/tools/assistant/tools/assistant/preferencesdialog.ui
index d848b498d..279084d1e 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.ui
+++ b/tools/assistant/tools/assistant/preferencesdialog.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>359</width>
+ <width>375</width>
<height>266</height>
</rect>
</property>
@@ -187,19 +187,90 @@
<attribute name="title">
<string>Options</string>
</attribute>
- <layout class="QVBoxLayout" name="verticalLayout_3">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QGroupBox" name="groupBox">
+ <widget class="QGroupBox" name="groupBox_2">
<property name="title">
- <string>Homepage</string>
+ <string/>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
- <widget class="QLineEdit" name="homePageLineEdit"/>
+ <widget class="QLabel" name="label_5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>On help start:</string>
+ </property>
+ </widget>
</item>
<item>
+ <widget class="QComboBox" name="helpStartComboBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <item>
+ <property name="text">
+ <string>Show my home page</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Show a blank page</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Show my tabs from last session</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>54</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string/>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Homepage</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="homePageLineEdit"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -213,22 +284,25 @@
</spacer>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QPushButton" name="currentPageButton">
- <property name="text">
- <string>Current Page</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="restoreDefaultHomePageButton">
- <property name="text">
- <string>Restore to default</string>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QPushButton" name="currentPageButton">
+ <property name="text">
+ <string>Current Page</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="blankPageButton">
+ <property name="text">
+ <string>Blank Page</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="defaultPageButton">
+ <property name="text">
+ <string>Restore to default</string>
+ </property>
+ </widget>
</item>
</layout>
</item>