summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qobject.cpp8
-rw-r--r--src/corelib/kernel/qobject_p.h8
-rw-r--r--src/corelib/thread/qthread.cpp15
-rw-r--r--src/corelib/thread/qthread_p.h3
-rw-r--r--src/corelib/thread/qthread_unix.cpp2
-rw-r--r--src/corelib/thread/qthread_win.cpp2
-rw-r--r--src/corelib/tools/qeasingcurve.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage.cpp26
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp5
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp138
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners_p.h17
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp109
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp18
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp6
-rw-r--r--src/declarative/qml/qdeclarativebinding_p.h2
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp37
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h6
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp71
-rw-r--r--src/declarative/qml/qdeclarativecomponent_p.h19
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp61
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h11
-rw-r--r--src/declarative/qml/qdeclarativedata_p.h (renamed from src/declarative/qml/qdeclarativedeclarativedata_p.h)36
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp57
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeguard_p.h4
-rw-r--r--src/declarative/qml/qdeclarativeinfo.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp14
-rw-r--r--src/declarative/qml/qdeclarativeprivate.h11
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp40
-rw-r--r--src/declarative/qml/qdeclarativeproperty_p.h3
-rw-r--r--src/declarative/qml/qdeclarativepropertycache.cpp10
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp6
-rw-r--r--src/declarative/qml/qdeclarativevaluetype_p.h5
-rw-r--r--src/declarative/qml/qdeclarativevaluetypescriptclass.cpp123
-rw-r--r--src/declarative/qml/qdeclarativevaluetypescriptclass_p.h1
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp26
-rw-r--r--src/declarative/qml/qdeclarativevmemetaobject.cpp2
-rw-r--r--src/declarative/qml/qml.pri2
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp7
-rw-r--r--src/declarative/util/qdeclarativelistmodelworkeragent.cpp2
-rw-r--r--src/declarative/util/qdeclarativeopenmetaobject.cpp4
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp34
-rw-r--r--src/declarative/util/qdeclarativepixmapcache_p.h5
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp6
-rw-r--r--src/gui/dialogs/qpagesetupdialog_mac.mm5
-rw-r--r--src/gui/egl/qegl.cpp52
-rw-r--r--src/gui/egl/qegl_p.h18
-rw-r--r--src/gui/egl/qegl_x11.cpp10
-rw-r--r--src/gui/egl/qeglproperties.cpp27
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp2
-rw-r--r--src/gui/itemviews/qlistview.cpp14
-rw-r--r--src/gui/kernel/qapplication.cpp6
-rw-r--r--src/gui/kernel/qapplication_p.h2
-rw-r--r--src/gui/kernel/qwidget.cpp2
-rw-r--r--src/gui/painting/qpaintbuffer.cpp2
-rw-r--r--src/gui/painting/qpaintbuffer_p.h2
-rw-r--r--src/gui/painting/qprintengine_mac.mm5
-rw-r--r--src/gui/text/qfontengine_ft.cpp2
-rw-r--r--src/gui/text/qstatictext.cpp4
-rw-r--r--src/imports/particles/qdeclarativeparticles.cpp10
-rw-r--r--src/multimedia/base/qgraphicsvideoitem.cpp5
-rw-r--r--src/multimedia/base/qgraphicsvideoitem.h3
-rw-r--r--src/multimedia/playback/qmediaplayer.cpp16
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp8
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h4
-rw-r--r--src/opengl/opengl.pro2
-rw-r--r--src/opengl/qgl.cpp33
-rw-r--r--src/opengl/qgl.h2
-rw-r--r--src/opengl/qgl_p.h10
-rw-r--r--src/opengl/qgl_x11egl.cpp8
-rw-r--r--src/opengl/qglpixelbuffer.cpp6
-rw-r--r--src/opengl/qglpixelbuffer_p.h12
-rw-r--r--src/openvg/qpixmapdata_vg.cpp14
-rw-r--r--src/script/api/qscriptengine.cpp14
-rw-r--r--src/script/api/qscriptengine_p.h7
79 files changed, 902 insertions, 399 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 411f22e..c13d829 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -125,8 +125,8 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *)
}
}
-void (*QDeclarativeData::destroyed)(QDeclarativeData *, QObject *) = 0;
-void (*QDeclarativeData::parentChanged)(QDeclarativeData *, QObject *, QObject *) = 0;
+void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = 0;
+void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0;
QObjectData::~QObjectData() {}
@@ -878,7 +878,7 @@ QObject::~QObject()
}
if (d->declarativeData)
- QDeclarativeData::destroyed(d->declarativeData, this);
+ QAbstractDeclarativeData::destroyed(d->declarativeData, this);
{
QMutex *signalSlotMutex = 0;
@@ -2027,7 +2027,7 @@ void QObjectPrivate::setParent_helper(QObject *o)
}
}
if (!wasDeleted && declarativeData)
- QDeclarativeData::parentChanged(declarativeData, q, o);
+ QAbstractDeclarativeData::parentChanged(declarativeData, q, o);
}
/*!
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index e5d904c..341b3e9 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -84,11 +84,11 @@ extern QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set;
enum { QObjectPrivateVersion = QT_VERSION };
-class Q_CORE_EXPORT QDeclarativeData
+class Q_CORE_EXPORT QAbstractDeclarativeData
{
public:
- static void (*destroyed)(QDeclarativeData *, QObject *);
- static void (*parentChanged)(QDeclarativeData *, QObject *, QObject *);
+ static void (*destroyed)(QAbstractDeclarativeData *, QObject *);
+ static void (*parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *);
};
class Q_CORE_EXPORT QObjectPrivate : public QObjectData
@@ -194,7 +194,7 @@ public:
QList<QPointer<QObject> > eventFilters;
union {
QObject *currentChildBeingDeleted;
- QDeclarativeData *declarativeData; //extra data used by the DeclarativeUI project.
+ QAbstractDeclarativeData *declarativeData; //extra data used by the declarative module
};
// these objects are all used to indicate that a QObject was deleted
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index cdcb65c..2c63dfc 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -173,7 +173,7 @@ void QAdoptedThread::run()
*/
QThreadPrivate::QThreadPrivate(QThreadData *d)
- : QObjectPrivate(), running(false), finished(false), terminated(false),
+ : QObjectPrivate(), running(false), finished(false), terminated(false), exited(false), returnCode(-1),
stackSize(0), priority(QThread::InheritPriority), data(d)
{
#if defined (Q_OS_UNIX)
@@ -480,11 +480,18 @@ uint QThread::stackSize() const
int QThread::exec()
{
Q_D(QThread);
+ QMutexLocker locker(&d->mutex);
+ d->data->quitNow = false;
+ if (d->exited)
+ return d->returnCode;
+ locker.unlock();
+
QEventLoop eventLoop;
int returnCode = eventLoop.exec();
- QMutexLocker locker(&d->mutex);
- d->data->quitNow = false;
+ locker.relock();
+ d->exited = false;
+ d->returnCode = -1;
return returnCode;
}
@@ -511,6 +518,8 @@ void QThread::exit(int returnCode)
{
Q_D(QThread);
QMutexLocker locker(&d->mutex);
+ d->exited = true;
+ d->returnCode = returnCode;
d->data->quitNow = true;
for (int i = 0; i < d->data->eventLoops.size(); ++i) {
QEventLoop *eventLoop = d->data->eventLoops.at(i);
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index 44eb8f8..d816aef 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -127,6 +127,9 @@ public:
bool finished;
bool terminated;
+ bool exited;
+ int returnCode;
+
uint stackSize;
QThread::Priority priority;
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index bd31d9c..6b34b5f 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -253,6 +253,7 @@ void *QThreadPrivate::start(void *arg)
pthread_setspecific(current_thread_data_key, data);
data->ref();
+ data->quitNow = false;
// ### TODO: allow the user to create a custom event dispatcher
createEventDispatcher(data);
@@ -494,7 +495,6 @@ void QThread::start(Priority priority)
d->running = true;
d->finished = false;
d->terminated = false;
- d->data->quitNow = false;
pthread_attr_t attr;
pthread_attr_init(&attr);
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 9826dcb..37d5b87 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -298,6 +298,7 @@ unsigned int __stdcall QThreadPrivate::start(void *arg)
QThread::setTerminationEnabled(false);
+ data->quitNow = false;
// ### TODO: allow the user to create a custom event dispatcher
createEventDispatcher(data);
@@ -404,7 +405,6 @@ void QThread::start(Priority priority)
d->running = true;
d->finished = false;
d->terminated = false;
- d->data->quitNow = false;
/*
NOTE: we create the thread in the suspended state, set the
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 9c65d5d..8fab963 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -304,6 +304,10 @@
#include <QtCore/qstring.h>
#endif
+#ifndef QT_NO_DATASTREAM
+#include <QtCore/qdatastream.h>
+#endif
+
QT_BEGIN_NAMESPACE
static bool isConfigFunction(QEasingCurve::Type type)
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
index 420ed90..be9d8bd 100644
--- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
@@ -43,6 +43,7 @@
#include "private/qdeclarativeborderimage_p_p.h"
#include <qdeclarativeengine.h>
+#include <qdeclarativeinfo.h>
#include <QNetworkRequest>
#include <QNetworkReply>
@@ -218,7 +219,8 @@ void QDeclarativeBorderImage::load()
}
} else {
QSize impsize;
- QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async);
+ QString errorString;
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async);
if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) {
QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url);
d->pendingPixmapCache = true;
@@ -230,8 +232,10 @@ void QDeclarativeBorderImage::load()
setImplicitWidth(impsize.width());
setImplicitHeight(impsize.height());
- if (d->pix.isNull())
+ if (d->pix.isNull()) {
d->status = Error;
+ qmlInfo(this) << errorString;
+ }
if (d->status == Loading)
d->status = Ready;
d->progress = 1.0;
@@ -338,7 +342,8 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma
d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl()));
QSize impsize;
- QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->sciurl, &d->pix, &impsize, d->async);
+ QString errorString;
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->sciurl, &d->pix, &errorString, &impsize, d->async);
if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) {
QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->sciurl);
d->sciPendingPixmapCache = true;
@@ -367,8 +372,10 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma
setImplicitWidth(impsize.width());
setImplicitHeight(impsize.height());
- if (d->pix.isNull())
+ if (d->pix.isNull()) {
d->status = Error;
+ qmlInfo(this) << errorString;
+ }
if (d->status == Loading)
d->status = Ready;
d->progress = 1.0;
@@ -386,11 +393,18 @@ void QDeclarativeBorderImage::requestFinished()
QSize impsize;
if (d->url.path().endsWith(QLatin1String(".sci"))) {
d->sciPendingPixmapCache = false;
- QDeclarativePixmapCache::get(d->sciurl, &d->pix, &impsize, d->async);
+ QString errorString;
+ if (QDeclarativePixmapCache::get(d->sciurl, &d->pix, &errorString, &impsize, d->async) != QDeclarativePixmapReply::Ready) {
+ d->status = Error;
+ qmlInfo(this) << errorString;
+ }
} else {
d->pendingPixmapCache = false;
- if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async) != QDeclarativePixmapReply::Ready)
+ QString errorString;
+ if (QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async) != QDeclarativePixmapReply::Ready) {
d->status = Error;
+ qmlInfo(this) << errorString;
+ }
}
setImplicitWidth(impsize.width());
setImplicitHeight(impsize.height());
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
index 3acafe8..c3f8195 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
@@ -43,6 +43,7 @@
#include "private/qdeclarativeimagebase_p_p.h"
#include <qdeclarativeengine.h>
+#include <qdeclarativeinfo.h>
#include <qdeclarativepixmapcache_p.h>
#include <QFile>
@@ -154,7 +155,8 @@ void QDeclarativeImageBase::load()
int reqwidth = d->sourcesize.width();
int reqheight = d->sourcesize.height();
QSize impsize;
- QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, reqwidth, reqheight);
+ QString errorString;
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async, reqwidth, reqheight);
if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) {
QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url, reqwidth, reqheight);
d->pendingPixmapCache = true;
@@ -191,6 +193,7 @@ void QDeclarativeImageBase::load()
emit sourceSizeChanged();
} else {
d->status = Error;
+ qmlInfo(this) << errorString;
}
d->progress = 1.0;
emit statusChanged(d->status);
@@ -210,8 +213,11 @@ void QDeclarativeImageBase::requestFinished()
d->pendingPixmapCache = false;
QSize impsize;
- if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, d->sourcesize.width(), d->sourcesize.height()) != QDeclarativePixmapReply::Ready)
+ QString errorString;
+ if (QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async, d->sourcesize.width(), d->sourcesize.height()) != QDeclarativePixmapReply::Ready) {
d->status = Error;
+ qmlInfo(this) << errorString;
+ }
setImplicitWidth(impsize.width());
setImplicitHeight(impsize.height());
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index cf7b96f..307c0a7 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -521,7 +521,6 @@ void QDeclarativeListViewPrivate::clear()
trackedItem = 0;
minExtentDirty = true;
maxExtentDirty = true;
- setPosition(0);
itemCount = 0;
}
@@ -708,6 +707,7 @@ void QDeclarativeListViewPrivate::layout()
layoutScheduled = false;
if (!isValid()) {
clear();
+ setPosition(0);
return;
}
updateSections();
@@ -1416,6 +1416,7 @@ void QDeclarativeListView::setModel(const QVariant &model)
disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
}
d->clear();
+ d->setPosition(0);
d->modelVariant = model;
QObject *object = qvariant_cast<QObject*>(model);
QDeclarativeVisualModel *vim = 0;
@@ -1770,6 +1771,7 @@ void QDeclarativeListView::setOrientation(QDeclarativeListView::Orientation orie
setFlickDirection(HorizontalFlick);
}
d->clear();
+ d->setPosition(0);
refill();
emit orientationChanged();
d->updateCurrent(d->currentIndex);
@@ -2791,6 +2793,7 @@ void QDeclarativeListView::modelReset()
{
Q_D(QDeclarativeListView);
d->clear();
+ d->setPosition(0);
refill();
d->moveReason = QDeclarativeListViewPrivate::SetIndex;
d->updateCurrent(d->currentIndex);
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index f436471..21c33e2 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -656,10 +656,8 @@ Grid {
*/
QDeclarativeGrid::QDeclarativeGrid(QDeclarativeItem *parent) :
- QDeclarativeBasePositioner(Both, parent)
+ QDeclarativeBasePositioner(Both, parent), m_rows(-1), m_columns(-1), m_flow(LeftToRight)
{
- _columns=-1;
- _rows=-1;
}
/*!
@@ -682,55 +680,101 @@ QDeclarativeGrid::QDeclarativeGrid(QDeclarativeItem *parent) :
void QDeclarativeGrid::setColumns(const int columns)
{
- if (columns == _columns)
+ if (columns == m_columns)
return;
- _columns = columns;
+ m_columns = columns;
prePositioning();
emit columnsChanged();
}
void QDeclarativeGrid::setRows(const int rows)
{
- if (rows == _rows)
+ if (rows == m_rows)
return;
- _rows = rows;
+ m_rows = rows;
prePositioning();
emit rowsChanged();
}
+/*!
+ \qmlproperty enumeration Flow::flow
+ This property holds the flow of the layout.
+
+ Possible values are \c LeftToRight (default) and \c TopToBottom.
+
+ If \a flow is \c LeftToRight, the items are positioned next to
+ to each other from left to right, then wrapped to the next line.
+ If \a flow is \c TopToBottom, the items are positioned next to each
+ other from top to bottom, then wrapped to the next column.
+*/
+QDeclarativeGrid::Flow QDeclarativeGrid::flow() const
+{
+ return m_flow;
+}
+
+void QDeclarativeGrid::setFlow(Flow flow)
+{
+ if (m_flow != flow) {
+ m_flow = flow;
+ prePositioning();
+ emit flowChanged();
+ }
+}
+
void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
{
- int c = _columns;
- int r = _rows;
+ int c = m_columns;
+ int r = m_rows;
int numVisible = positionedItems.count();
- if (_columns <= 0 && _rows <= 0){
+ if (m_columns <= 0 && m_rows <= 0){
c = 4;
r = (numVisible+3)/4;
- } else if (_rows <= 0){
- r = (numVisible+(_columns-1))/_columns;
- } else if (_columns <= 0){
- c = (numVisible+(_rows-1))/_rows;
+ } else if (m_rows <= 0){
+ r = (numVisible+(m_columns-1))/m_columns;
+ } else if (m_columns <= 0){
+ c = (numVisible+(m_rows-1))/m_rows;
}
QList<int> maxColWidth;
QList<int> maxRowHeight;
int childIndex =0;
- for (int i=0; i<r; i++){
- for (int j=0; j<c; j++){
- if (j==0)
- maxRowHeight << 0;
- if (i==0)
- maxColWidth << 0;
-
- if (childIndex == positionedItems.count())
- continue;
- const PositionedItem &child = positionedItems.at(childIndex++);
- if (!child.item || isInvisible(child.item))
- continue;
- if (child.item->width() > maxColWidth[j])
- maxColWidth[j] = child.item->width();
- if (child.item->height() > maxRowHeight[i])
- maxRowHeight[i] = child.item->height();
+ if (m_flow == LeftToRight) {
+ for (int i=0; i < r; i++){
+ for (int j=0; j < c; j++){
+ if (j==0)
+ maxRowHeight << 0;
+ if (i==0)
+ maxColWidth << 0;
+
+ if (childIndex == positionedItems.count())
+ continue;
+ const PositionedItem &child = positionedItems.at(childIndex++);
+ if (!child.item || isInvisible(child.item))
+ continue;
+ if (child.item->width() > maxColWidth[j])
+ maxColWidth[j] = child.item->width();
+ if (child.item->height() > maxRowHeight[i])
+ maxRowHeight[i] = child.item->height();
+ }
+ }
+ } else {
+ for (int j=0; j < c; j++){
+ for (int i=0; i < r; i++){
+ if (j==0)
+ maxRowHeight << 0;
+ if (i==0)
+ maxColWidth << 0;
+
+ if (childIndex == positionedItems.count())
+ continue;
+ const PositionedItem &child = positionedItems.at(childIndex++);
+ if (!child.item || isInvisible(child.item))
+ continue;
+ if (child.item->width() > maxColWidth[j])
+ maxColWidth[j] = child.item->width();
+ if (child.item->height() > maxRowHeight[i])
+ maxRowHeight[i] = child.item->height();
+ }
}
}
@@ -747,18 +791,34 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
positionY(yoffset, child);
}
- contentSize->setWidth(qMax(contentSize->width(), xoffset + child.item->width()));
- contentSize->setHeight(yoffset + maxRowHeight[curRow]);
+ if (m_flow == LeftToRight) {
+ contentSize->setWidth(qMax(contentSize->width(), xoffset + child.item->width()));
+ contentSize->setHeight(yoffset + maxRowHeight[curRow]);
+
+ xoffset+=maxColWidth[curCol]+spacing();
+ curCol++;
+ curCol%=c;
+ if (!curCol){
+ yoffset+=maxRowHeight[curRow]+spacing();
+ xoffset=0;
+ curRow++;
+ if (curRow>=r)
+ break;
+ }
+ } else {
+ contentSize->setHeight(qMax(contentSize->height(), yoffset + child.item->height()));
+ contentSize->setWidth(xoffset + maxColWidth[curCol]);
- xoffset+=maxColWidth[curCol]+spacing();
- curCol++;
- curCol%=c;
- if (!curCol){
yoffset+=maxRowHeight[curRow]+spacing();
- xoffset=0;
curRow++;
- if (curRow>=r)
- break;
+ curRow%=r;
+ if (!curRow){
+ xoffset+=maxColWidth[curCol]+spacing();
+ yoffset=0;
+ curCol++;
+ if (curCol>=c)
+ break;
+ }
}
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
index c4414d1..24b65fa 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
@@ -138,25 +138,34 @@ class Q_DECLARATIVE_EXPORT QDeclarativeGrid : public QDeclarativeBasePositioner
Q_OBJECT
Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowChanged)
Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
+ Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
+
public:
QDeclarativeGrid(QDeclarativeItem *parent=0);
- int rows() const {return _rows;}
+ int rows() const {return m_rows;}
void setRows(const int rows);
- int columns() const {return _columns;}
+ int columns() const {return m_columns;}
void setColumns(const int columns);
+ Q_ENUMS(Flow)
+ enum Flow { LeftToRight, TopToBottom };
+ Flow flow() const;
+ void setFlow(Flow);
+
Q_SIGNALS:
void rowsChanged();
void columnsChanged();
+ void flowChanged();
protected:
virtual void doPositioning(QSizeF *contentSize);
private:
- int _rows;
- int _columns;
+ int m_rows;
+ int m_columns;
+ Flow m_flow;
Q_DISABLE_COPY(QDeclarativeGrid)
};
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index b65212b..a95c930 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -43,7 +43,9 @@
#include "private/qdeclarativetext_p_p.h"
#include <qdeclarativestyledtext_p.h>
#include <qdeclarativeinfo.h>
+#include <qdeclarativepixmapcache_p.h>
+#include <QSet>
#include <QTextLayout>
#include <QTextLine>
#include <QTextDocument>
@@ -55,6 +57,59 @@
QT_BEGIN_NAMESPACE
+class QTextDocumentWithImageResources : public QTextDocument {
+ Q_OBJECT
+
+public:
+ QTextDocumentWithImageResources(QDeclarativeText *parent) :
+ QTextDocument(parent),
+ outstanding(0)
+ {
+ }
+
+ int resourcesLoading() const { return outstanding; }
+
+protected:
+ QVariant loadResource(int type, const QUrl &name)
+ {
+ QUrl url = qmlContext(parent())->resolvedUrl(name);
+
+ if (type == QTextDocument::ImageResource) {
+ QPixmap pm;
+ QString errorString;
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(url, &pm, &errorString, 0, false, 0, 0);
+ if (status == QDeclarativePixmapReply::Ready)
+ return pm;
+ if (status == QDeclarativePixmapReply::Error) {
+ if (!errors.contains(url)) {
+ errors.insert(url);
+ qmlInfo(parent()) << errorString;
+ }
+ } else {
+ QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(parent()), url);
+ connect(reply, SIGNAL(finished()), this, SLOT(requestFinished()));
+ outstanding++;
+ }
+ }
+
+ return QTextDocument::loadResource(type,url); // The *resolved* URL
+ }
+
+private slots:
+ void requestFinished()
+ {
+ outstanding--;
+ if (outstanding == 0)
+ static_cast<QDeclarativeText*>(parent())->reloadWithResources();
+ }
+
+private:
+ int outstanding;
+ static QSet<QUrl> errors;
+};
+
+QSet<QUrl> QTextDocumentWithImageResources::errors;
+
/*!
\qmlclass Text QDeclarativeText
\since 4.7
@@ -77,6 +132,9 @@ QT_BEGIN_NAMESPACE
The \c elide property can alternatively be used to fit a single line of
plain text to a set width.
+ Note that the \l{Supported HTML Subset} is limited, and that if IMG tags
+ load remote images, the text reloads (see resourcesLoading).
+
Text provides read-only text. For editable text, see \l TextEdit.
*/
@@ -259,11 +317,10 @@ void QDeclarativeText::setText(const QString &n)
d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(n));
if (d->richText) {
- if (!d->doc) {
- d->doc = new QTextDocument(this);
- d->doc->setDocumentMargin(0);
+ if (isComponentComplete()) {
+ d->ensureDoc();
+ d->doc->setHtml(n);
}
- d->doc->setHtml(n);
}
d->text = n;
@@ -550,11 +607,10 @@ void QDeclarativeText::setTextFormat(TextFormat format)
d->updateLayout();
d->markImgDirty();
} else if (!wasRich && d->richText) {
- if (!d->doc) {
- d->doc = new QTextDocument(this);
- d->doc->setDocumentMargin(0);
+ if (isComponentComplete()) {
+ d->ensureDoc();
+ d->doc->setHtml(d->text);
}
- d->doc->setHtml(d->text);
d->updateLayout();
d->markImgDirty();
}
@@ -677,7 +733,7 @@ void QDeclarativeTextPrivate::updateSize()
QTextOption option((Qt::Alignment)int(hAlign | vAlign));
option.setWrapMode(QTextOption::WrapMode(wrapMode));
doc->setDefaultTextOption(option);
- if (wrapMode != QDeclarativeText::NoWrap && !q->heightValid() && q->widthValid())
+ if (wrapMode != QDeclarativeText::NoWrap && q->widthValid())
doc->setTextWidth(q->width());
else
doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug)
@@ -898,6 +954,34 @@ void QDeclarativeTextPrivate::checkImgCache()
imgDirty = false;
}
+void QDeclarativeTextPrivate::ensureDoc()
+{
+ if (!doc) {
+ Q_Q(QDeclarativeText);
+ doc = new QTextDocumentWithImageResources(q);
+ doc->setDocumentMargin(0);
+ }
+}
+
+void QDeclarativeText::reloadWithResources()
+{
+ Q_D(QDeclarativeText);
+ if (!d->richText)
+ return;
+ d->doc->setHtml(d->text);
+ d->updateLayout();
+ d->markImgDirty();
+}
+
+/*!
+ Returns the number of resources (images) that are being loaded asynchronously.
+*/
+int QDeclarativeText::resourcesLoading() const
+{
+ Q_D(const QDeclarativeText);
+ return d->doc ? d->doc->resourcesLoading() : 0;
+}
+
void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QDeclarativeText);
@@ -1011,6 +1095,10 @@ void QDeclarativeText::componentComplete()
Q_D(QDeclarativeText);
QDeclarativeItem::componentComplete();
if (d->dirty) {
+ if (d->richText) {
+ d->ensureDoc();
+ d->doc->setHtml(d->text);
+ }
d->updateLayout();
d->dirty = false;
}
@@ -1061,4 +1149,7 @@ void QDeclarativeText::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (!event->isAccepted())
QDeclarativeItem::mouseReleaseEvent(event);
}
+
QT_END_NAMESPACE
+
+#include "qdeclarativetext.moc"
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h
index 871c833..4fd5e3a 100644
--- a/src/declarative/graphicsitems/qdeclarativetext_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetext_p.h
@@ -138,6 +138,8 @@ public:
virtual void componentComplete();
+ int resourcesLoading() const; // mainly for testing
+
Q_SIGNALS:
void textChanged(const QString &text);
void linkActivated(const QString &link);
@@ -160,6 +162,9 @@ protected:
private:
Q_DISABLE_COPY(QDeclarativeText)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeText)
+
+ friend class QTextDocumentWithImageResources;
+ void reloadWithResources();
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p_p.h b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
index cc5a9f2..332f99e 100644
--- a/src/declarative/graphicsitems/qdeclarativetext_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
@@ -63,7 +63,7 @@
QT_BEGIN_NAMESPACE
class QTextLayout;
-class QTextDocument;
+class QTextDocumentWithImageResources;
class QDeclarativeTextPrivate : public QDeclarativeItemPrivate
{
@@ -84,6 +84,7 @@ public:
~QDeclarativeTextPrivate();
+ void ensureDoc();
void updateSize();
void updateLayout();
void markImgDirty() {
@@ -118,7 +119,7 @@ public:
bool richText:1;
bool singleline:1;
bool cache:1;
- QTextDocument *doc;
+ QTextDocumentWithImageResources *doc;
QTextLayout layout;
QSize cachedLayoutSize;
QDeclarativeText::TextFormat format;
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 03e4703..751284d 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -50,7 +50,7 @@
#include <qdeclarativeopenmetaobject_p.h>
#include <qdeclarativelistaccessor_p.h>
#include <qdeclarativeinfo.h>
-#include <qdeclarativedeclarativedata_p.h>
+#include <qdeclarativedata_p.h>
#include <qdeclarativepropertycache_p.h>
#include <qdeclarativeguard_p.h>
#include <qdeclarativeglobal_p.h>
@@ -353,6 +353,7 @@ public:
friend class QDeclarativeVisualDataModelData;
bool m_metaDataCreated;
bool m_metaDataCacheable;
+ bool m_delegateValidated;
QDeclarativeVisualDataModelData *data(QObject *item);
@@ -560,7 +561,7 @@ QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeV
QDeclarativeVisualDataModelPrivate::QDeclarativeVisualDataModelPrivate(QDeclarativeContext *ctxt)
: m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0)
, m_context(ctxt), m_parts(0), m_delegateDataType(0), m_metaDataCreated(false)
-, m_metaDataCacheable(false), m_listAccessor(0)
+, m_metaDataCacheable(false), m_delegateValidated(false), m_listAccessor(0)
{
}
@@ -768,6 +769,7 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate)
Q_D(QDeclarativeVisualDataModel);
bool wasValid = d->m_delegate != 0;
d->m_delegate = delegate;
+ d->m_delegateValidated = false;
if (!wasValid && d->modelCount() && d->m_delegate) {
emit itemsInserted(0, d->modelCount());
emit countChanged();
@@ -987,6 +989,7 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
if (d->modelCount() <= 0 || !d->m_delegate)
return 0;
QObject *nobj = d->m_cache.getItem(index);
+ bool needComplete = false;
if (!nobj) {
QDeclarativeContext *ccontext = d->m_context;
if (!ccontext) ccontext = qmlContext(this);
@@ -997,6 +1000,8 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
nobj = d->m_delegate->beginCreate(ctxt);
if (complete)
d->m_delegate->completeCreate();
+ else
+ needComplete = true;
if (nobj) {
QDeclarative_setParent_noEvent(ctxt, nobj);
QDeclarative_setParent_noEvent(data, nobj);
@@ -1020,8 +1025,13 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
}
}
if (!item) {
+ if (needComplete)
+ d->m_delegate->completeCreate();
d->m_cache.releaseItem(nobj);
- qmlInfo(d->m_delegate) << QDeclarativeVisualDataModel::tr("Delegate component must be Item type.");
+ if (!d->m_delegateValidated) {
+ qmlInfo(d->m_delegate) << QDeclarativeVisualDataModel::tr("Delegate component must be Item type.");
+ d->m_delegateValidated = true;
+ }
}
return item;
@@ -1058,7 +1068,7 @@ QString QDeclarativeVisualDataModel::stringValue(int index, const QString &name)
tempData = true;
}
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(data);
+ QDeclarativeData *ddata = QDeclarativeData::get(data);
if (ddata && ddata->propertyCache) {
QDeclarativePropertyCache::Data *prop = ddata->propertyCache->property(name);
if (prop) {
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
index 664118d..25492ac 100644
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -46,7 +46,7 @@
#include "qdeclarativecontext.h"
#include "qdeclarativeinfo.h"
#include "private/qdeclarativecontext_p.h"
-#include "private/qdeclarativedeclarativedata_p.h"
+#include "private/qdeclarativedata_p.h"
#include "private/qdeclarativestringconverters_p.h"
#include <QVariant>
@@ -296,7 +296,7 @@ void QDeclarativeAbstractBinding::addToObject(QObject *object)
Q_ASSERT(!m_prevBinding);
m_object = object;
- QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object, true);
+ QDeclarativeData *data = QDeclarativeData::get(object, true);
if (index & 0xFF000000) {
// Value type
@@ -348,7 +348,7 @@ void QDeclarativeAbstractBinding::removeFromObject()
// Value type - we don't remove the proxy from the object. It will sit their happily
// doing nothing for ever more.
} else {
- QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(m_object, false);
+ QDeclarativeData *data = QDeclarativeData::get(m_object, false);
if (data) data->clearBindingBit(index);
}
diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h
index 2789738..2d3acf5 100644
--- a/src/declarative/qml/qdeclarativebinding_p.h
+++ b/src/declarative/qml/qdeclarativebinding_p.h
@@ -92,7 +92,7 @@ protected:
private:
- friend class QDeclarativeDeclarativeData;
+ friend class QDeclarativeData;
friend class QDeclarativeValueTypeProxyBinding;
friend class QDeclarativePropertyPrivate;
friend class QDeclarativeVME;
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index fad7779..065009a 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -67,7 +67,6 @@
#include "private/qdeclarativecompiledbindings_p.h"
#include "private/qdeclarativeglobalscriptclass_p.h"
-#include <QCoreApplication>
#include <QColor>
#include <QDebug>
#include <QPointF>
@@ -1364,35 +1363,6 @@ int QDeclarativeCompiler::componentTypeRef()
return output->types.count() - 1;
}
-QMetaMethod QDeclarativeCompiler::findSignalByName(const QMetaObject *mo, const QByteArray &name)
-{
- Q_ASSERT(mo);
- int methods = mo->methodCount();
- for (int ii = methods - 1; ii >= 0; --ii) {
- QMetaMethod method = mo->method(ii);
- QByteArray methodName = method.signature();
- int idx = methodName.indexOf('(');
- methodName = methodName.left(idx);
-
- if (methodName == name)
- return method;
- }
-
- // If no signal is found, but the signal is of the form "onBlahChanged",
- // return the notify signal for the property "Blah"
- if (name.endsWith("Changed")) {
- QByteArray propName = name.mid(0, name.length() - 7);
- int propIdx = mo->indexOfProperty(propName.constData());
- if (propIdx >= 0) {
- QMetaProperty prop = mo->property(propIdx);
- if (prop.hasNotifySignal())
- return prop.notifySignal();
- }
- }
-
- return QMetaMethod();
-}
-
bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj,
const BindingContext &ctxt)
{
@@ -1404,7 +1374,7 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
if(name[0] >= 'A' && name[0] <= 'Z')
name[0] = name[0] - 'A' + 'a';
- int sigIdx = findSignalByName(obj->metaObject(), name).methodIndex();
+ int sigIdx = QDeclarativePropertyPrivate::findSignalByName(obj->metaObject(), name).methodIndex();
if (sigIdx == -1) {
@@ -2976,9 +2946,4 @@ QStringList QDeclarativeCompiler::deferredProperties(QDeclarativeParser::Object
return rv;
}
-QString QDeclarativeCompiler::tr(const char *str)
-{
- return QCoreApplication::translate("QDeclarativeCompiler", str);
-}
-
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index 0e47774..867db2c 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -66,6 +66,7 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qset.h>
+#include <QtCore/QCoreApplication>
QT_BEGIN_NAMESPACE
@@ -148,6 +149,7 @@ private:
class QMetaObjectBuilder;
class Q_DECLARATIVE_EXPORT QDeclarativeCompiler
{
+ Q_DECLARE_TR_FUNCTIONS(QDeclarativeCompiler)
public:
QDeclarativeCompiler();
@@ -159,8 +161,6 @@ public:
static bool isAttachedPropertyName(const QByteArray &);
static bool isSignalPropertyName(const QByteArray &);
- static QMetaMethod findSignalByName(const QMetaObject *, const QByteArray &name);
-
int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum
private:
@@ -281,8 +281,6 @@ private:
void addId(const QString &, QDeclarativeParser::Object *);
- QString tr(const char *);
-
void dumpStats();
struct BindingReference {
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 5f26ad5..3e4651c 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -120,6 +120,26 @@ Item {
}
}
\endqml
+
+ \e onDestruction
+
+ Emitted as the component begins destruction. This can be used to undo
+ work done in the onCompleted signal, or other imperative code in your
+ application.
+
+ The \c {Component::onDestruction} attached property can be applied to
+ any element. However, it applies to the destruction of the component as
+ a whole, and not the destruction of the specific object. The order of
+ running the \c onDestruction scripts is undefined.
+
+ \qml
+ Rectangle {
+ Component.onDestruction: console.log("Destruction Beginning!")
+ Rectangle {
+ Component.onDestruction: console.log("Nested Destruction Beginning!")
+ }
+ }
+ \endqml
*/
/*!
@@ -518,7 +538,7 @@ QScriptValue QDeclarativeComponent::createObject()
if (!ret)
return QScriptValue();
QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(d->engine);
- QDeclarativeDeclarativeData::get(ret, true)->setImplicitDestructible();
+ QDeclarativeData::get(ret, true)->setImplicitDestructible();
return priv->objectClass->newQObject(ret, QMetaType::QObjectStar);
}
@@ -581,7 +601,7 @@ QObject *QDeclarativeComponent::beginCreate(QDeclarativeContext *context)
Q_D(QDeclarativeComponent);
QObject *rv = d->beginCreate(context?QDeclarativeContextData::get(context):0, QBitField());
if (rv) {
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(rv);
+ QDeclarativeData *ddata = QDeclarativeData::get(rv);
Q_ASSERT(ddata);
ddata->indestructible = true;
}
@@ -657,11 +677,11 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *ctxt, QDe
state->bindValues = enginePriv->bindValues;
state->parserStatus = enginePriv->parserStatus;
- state->componentAttacheds = enginePriv->componentAttacheds;
- if (state->componentAttacheds)
- state->componentAttacheds->prev = &state->componentAttacheds;
+ state->componentAttached = enginePriv->componentAttached;
+ if (state->componentAttached)
+ state->componentAttached->prev = &state->componentAttached;
- enginePriv->componentAttacheds = 0;
+ enginePriv->componentAttached = 0;
enginePriv->bindValues.clear();
enginePriv->parserStatus.clear();
state->completePending = true;
@@ -671,7 +691,7 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *ctxt, QDe
return rv;
}
-void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeContextData *, QDeclarativeEnginePrivate *enginePriv,
+void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeEnginePrivate *enginePriv,
QObject *object, ConstructionState *state)
{
bool isRoot = !enginePriv->inBeginCreate;
@@ -688,11 +708,11 @@ void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeContextData *, QDec
state->bindValues = enginePriv->bindValues;
state->parserStatus = enginePriv->parserStatus;
- state->componentAttacheds = enginePriv->componentAttacheds;
- if (state->componentAttacheds)
- state->componentAttacheds->prev = &state->componentAttacheds;
+ state->componentAttached = enginePriv->componentAttached;
+ if (state->componentAttached)
+ state->componentAttached->prev = &state->componentAttached;
- enginePriv->componentAttacheds = 0;
+ enginePriv->componentAttached = 0;
enginePriv->bindValues.clear();
enginePriv->parserStatus.clear();
state->completePending = true;
@@ -729,11 +749,13 @@ void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePri
QDeclarativeEnginePrivate::clear(ps);
}
- while (state->componentAttacheds) {
- QDeclarativeComponentAttached *a = state->componentAttacheds;
- if (a->next) a->next->prev = &state->componentAttacheds;
- state->componentAttacheds = a->next;
- a->prev = 0; a->next = 0;
+ while (state->componentAttached) {
+ QDeclarativeComponentAttached *a = state->componentAttached;
+ a->rem();
+ QDeclarativeData *d = QDeclarativeData::get(a->parent());
+ Q_ASSERT(d);
+ Q_ASSERT(d->context);
+ a->add(&d->context->componentAttached);
emit a->completed();
}
@@ -793,15 +815,18 @@ QDeclarativeComponentAttached *QDeclarativeComponent::qmlAttachedProperties(QObj
QDeclarativeComponentAttached *a = new QDeclarativeComponentAttached(obj);
QDeclarativeEngine *engine = qmlEngine(obj);
- if (!engine || !QDeclarativeEnginePrivate::get(engine)->inBeginCreate)
+ if (!engine)
return a;
- QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
-
- a->next = p->componentAttacheds;
- a->prev = &p->componentAttacheds;
- if (a->next) a->next->prev = &a->next;
- p->componentAttacheds = a;
+ if (QDeclarativeEnginePrivate::get(engine)->inBeginCreate) {
+ QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
+ a->add(&p->componentAttached);
+ } else {
+ QDeclarativeData *d = QDeclarativeData::get(obj);
+ Q_ASSERT(d);
+ Q_ASSERT(d->context);
+ a->add(&d->context->componentAttached);
+ }
return a;
}
diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h
index dfe327b..24e5386 100644
--- a/src/declarative/qml/qdeclarativecomponent_p.h
+++ b/src/declarative/qml/qdeclarativecomponent_p.h
@@ -99,10 +99,10 @@ public:
QDeclarativeCompiledData *cc;
struct ConstructionState {
- ConstructionState() : componentAttacheds(0), completePending(false) {}
+ ConstructionState() : componentAttached(0), completePending(false) {}
QList<QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding> > bindValues;
QList<QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus> > parserStatus;
- QDeclarativeComponentAttached *componentAttacheds;
+ QDeclarativeComponentAttached *componentAttached;
QList<QDeclarativeError> errors;
bool completePending;
};
@@ -111,8 +111,8 @@ public:
static QObject *begin(QDeclarativeContextData *ctxt, QDeclarativeEnginePrivate *enginePriv,
QDeclarativeCompiledData *component, int start, int count,
ConstructionState *state, const QBitField &bindings = QBitField());
- static void beginDeferred(QDeclarativeContextData *ctxt, QDeclarativeEnginePrivate *enginePriv,
- QObject *object, ConstructionState *state);
+ static void beginDeferred(QDeclarativeEnginePrivate *enginePriv, QObject *object,
+ ConstructionState *state);
static void complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state);
QDeclarativeEngine *engine;
@@ -132,13 +132,24 @@ public:
QDeclarativeComponentAttached(QObject *parent = 0);
~QDeclarativeComponentAttached();
+ void add(QDeclarativeComponentAttached **a) {
+ prev = a; next = *a; *a = this;
+ if (next) next->prev = &next;
+ }
+ void rem() {
+ if (next) next->prev = prev;
+ *prev = next;
+ next = 0; prev = 0;
+ }
QDeclarativeComponentAttached **prev;
QDeclarativeComponentAttached *next;
Q_SIGNALS:
void completed();
+ void destruction();
private:
+ friend class QDeclarativeContextData;;
friend class QDeclarativeComponentPrivate;
};
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index ba4da95..6657fea 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -42,6 +42,7 @@
#include "qdeclarativecontext.h"
#include "private/qdeclarativecontext_p.h"
+#include "private/qdeclarativecomponent_p.h"
#include "private/qdeclarativeexpression_p.h"
#include "private/qdeclarativeengine_p.h"
#include "qdeclarativeengine.h"
@@ -476,21 +477,34 @@ QObject *QDeclarativeContextPrivate::context_at(QDeclarativeListProperty<QObject
QDeclarativeContextData::QDeclarativeContextData()
: parent(0), engine(0), isInternal(false), publicContext(0), propertyNames(0), contextObject(0),
imports(0), childContexts(0), nextChild(0), prevChild(0), expressions(0), contextObjects(0),
- contextGuards(0), idValues(0), idValueCount(0), optimizedBindings(0), linkedContext(0)
+ contextGuards(0), idValues(0), idValueCount(0), optimizedBindings(0), linkedContext(0),
+ componentAttached(0)
{
}
QDeclarativeContextData::QDeclarativeContextData(QDeclarativeContext *ctxt)
: parent(0), engine(0), isInternal(false), publicContext(ctxt), propertyNames(0), contextObject(0),
imports(0), childContexts(0), nextChild(0), prevChild(0), expressions(0), contextObjects(0),
- contextGuards(0), idValues(0), idValueCount(0), optimizedBindings(0), linkedContext(0)
+ contextGuards(0), idValues(0), idValueCount(0), optimizedBindings(0), linkedContext(0),
+ componentAttached(0)
{
}
-void QDeclarativeContextData::destroy()
+void QDeclarativeContextData::invalidate()
{
- if (linkedContext)
- linkedContext->destroy();
+ while (childContexts)
+ childContexts->invalidate();
+
+ while (componentAttached) {
+ QDeclarativeComponentAttached *a = componentAttached;
+ componentAttached = a->next;
+ if (componentAttached) componentAttached->prev = &componentAttached;
+
+ a->next = 0;
+ a->prev = 0;
+
+ emit a->destruction();
+ }
if (prevChild) {
*prevChild = nextChild;
@@ -498,19 +512,17 @@ void QDeclarativeContextData::destroy()
nextChild = 0;
prevChild = 0;
}
-
- QDeclarativeContextData *child = childContexts;
- while (child) {
- QDeclarativeContextData *next = child->nextChild;
- child->invalidateEngines();
- child->parent = 0;
- child->nextChild = 0;
- child->prevChild = 0;
+ engine = 0;
+ parent = 0;
+}
- child = next;
- }
- childContexts = 0;
+void QDeclarativeContextData::destroy()
+{
+ if (linkedContext)
+ linkedContext->destroy();
+
+ if (engine) invalidate();
QDeclarativeAbstractExpression *expression = expressions;
while (expression) {
@@ -525,7 +537,7 @@ void QDeclarativeContextData::destroy()
expressions = 0;
while (contextObjects) {
- QDeclarativeDeclarativeData *co = contextObjects;
+ QDeclarativeData *co = contextObjects;
contextObjects = contextObjects->nextContextObject;
co->context = 0;
@@ -573,19 +585,6 @@ void QDeclarativeContextData::setParent(QDeclarativeContextData *p)
}
}
-void QDeclarativeContextData::invalidateEngines()
-{
- if (!engine)
- return;
- engine = 0;
-
- QDeclarativeContextData *child = childContexts;
- while (child) {
- child->invalidateEngines();
- child = child->nextChild;
- }
-}
-
/*
Refreshes all expressions that could possibly depend on this context. Refreshing flushes all
context-tree dependent caches in the expressions, and should occur every time the context tree
@@ -608,7 +607,7 @@ void QDeclarativeContextData::refreshExpressions()
void QDeclarativeContextData::addObject(QObject *o)
{
- QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(o, true);
+ QDeclarativeData *data = QDeclarativeData::get(o, true);
Q_ASSERT(data->context == 0);
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
index 7a16179..77a6d94 100644
--- a/src/declarative/qml/qdeclarativecontext_p.h
+++ b/src/declarative/qml/qdeclarativecontext_p.h
@@ -55,7 +55,7 @@
#include "qdeclarativecontext.h"
-#include "private/qdeclarativedeclarativedata_p.h"
+#include "private/qdeclarativedata_p.h"
#include "private/qdeclarativeintegercache_p.h"
#include "private/qdeclarativetypenamecache_p.h"
#include "private/qdeclarativenotifier_p.h"
@@ -106,6 +106,7 @@ public:
static QObject *context_at(QDeclarativeListProperty<QObject> *, int);
};
+class QDeclarativeComponentAttached;
class QDeclarativeGuardedContextData;
class QDeclarativeContextData
{
@@ -113,6 +114,7 @@ public:
QDeclarativeContextData();
QDeclarativeContextData(QDeclarativeContext *);
void destroy();
+ void invalidate();
inline bool isValid() const {
return engine && (!isInternal || !contextObject || !QObjectPrivate::get(contextObject)->wasDeleted);
@@ -123,7 +125,6 @@ public:
QDeclarativeEngine *engine;
void setParent(QDeclarativeContextData *);
- void invalidateEngines();
void refreshExpressions();
void addObject(QObject *);
@@ -166,7 +167,7 @@ public:
QDeclarativeAbstractExpression *expressions;
// Doubly-linked list of objects that are owned by this context
- QDeclarativeDeclarativeData *contextObjects;
+ QDeclarativeData *contextObjects;
// Doubly-linked list of context guards (XXX merge with contextObjects)
QDeclarativeGuardedContextData *contextGuards;
@@ -194,6 +195,10 @@ public:
// Linked contexts. this owns linkedContext.
QDeclarativeContextData *linkedContext;
+ // Linked list of uses of the Component attached property in this
+ // context
+ QDeclarativeComponentAttached *componentAttached;
+
QString findObjectId(const QObject *obj) const;
static QDeclarativeContextData *get(QDeclarativeContext *context) {
diff --git a/src/declarative/qml/qdeclarativedeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h
index 5b12629..2ddd7e5 100644
--- a/src/declarative/qml/qdeclarativedeclarativedata_p.h
+++ b/src/declarative/qml/qdeclarativedata_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QDECLARATIVEDECLARATIVEDATA_P_H
-#define QDECLARATIVEDECLARATIVEDATA_P_H
+#ifndef QDECLARATIVEDATA_P_H
+#define QDECLARATIVEDATA_P_H
//
// W A R N I N G
@@ -68,10 +68,10 @@ class QDeclarativeContextData;
// default state for elemental object allocations. This is crucial in the
// workings of the QDeclarativeInstruction::CreateSimpleObject instruction.
// Don't change anything here without first considering that case!
-class Q_AUTOTEST_EXPORT QDeclarativeDeclarativeData : public QDeclarativeData
+class Q_AUTOTEST_EXPORT QDeclarativeData : public QAbstractDeclarativeData
{
public:
- QDeclarativeDeclarativeData()
+ QDeclarativeData()
: ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false),
context(0), outerContext(0), bindings(0), nextContextObject(0), prevContextObject(0), bindingBitsSize(0),
bindingBits(0), lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0),
@@ -80,12 +80,12 @@ public:
}
static inline void init() {
- QDeclarativeData::destroyed = destroyed;
- QDeclarativeData::parentChanged = parentChanged;
+ QAbstractDeclarativeData::destroyed = destroyed;
+ QAbstractDeclarativeData::parentChanged = parentChanged;
}
- static void destroyed(QDeclarativeData *, QObject *);
- static void parentChanged(QDeclarativeData *, QObject *, QObject *);
+ static void destroyed(QAbstractDeclarativeData *, QObject *);
+ static void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *);
void destroyed(QObject *);
void parentChanged(QObject *, QObject *);
@@ -100,14 +100,16 @@ public:
quint32 explicitIndestructibleSet:1;
quint32 dummy:28;
- QDeclarativeContextData *context;
+ // The context that created the C++ object
+ QDeclarativeContextData *context;
+ // The outermost context in which this object lives
QDeclarativeContextData *outerContext;
QDeclarativeAbstractBinding *bindings;
// Linked list for QDeclarativeContext::contextObjects
- QDeclarativeDeclarativeData *nextContextObject;
- QDeclarativeDeclarativeData**prevContextObject;
+ QDeclarativeData *nextContextObject;
+ QDeclarativeData**prevContextObject;
int bindingBitsSize;
quint32 *bindingBits;
@@ -130,16 +132,16 @@ public:
QDeclarativeGuard<QObject> *guards;
- static QDeclarativeDeclarativeData *get(const QObject *object, bool create = false) {
+ static QDeclarativeData *get(const QObject *object, bool create = false) {
QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
if (priv->wasDeleted) {
Q_ASSERT(!create);
return 0;
} else if (priv->declarativeData) {
- return static_cast<QDeclarativeDeclarativeData *>(priv->declarativeData);
+ return static_cast<QDeclarativeData *>(priv->declarativeData);
} else if (create) {
- priv->declarativeData = new QDeclarativeDeclarativeData;
- return static_cast<QDeclarativeDeclarativeData *>(priv->declarativeData);
+ priv->declarativeData = new QDeclarativeData;
+ return static_cast<QDeclarativeData *>(priv->declarativeData);
} else {
return 0;
}
@@ -154,7 +156,7 @@ void QDeclarativeGuard<T>::addGuard()
return;
}
- QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(o, true);
+ QDeclarativeData *data = QDeclarativeData::get(o, true);
next = data->guards;
if (next) reinterpret_cast<QDeclarativeGuard<T> *>(next)->prev = &next;
data->guards = reinterpret_cast<QDeclarativeGuard<QObject> *>(this);
@@ -172,4 +174,4 @@ void QDeclarativeGuard<T>::remGuard()
QT_END_NAMESPACE
-#endif // QDECLARATIVEDECLARATIVEDATA_P_H
+#endif // QDECLARATIVEDATA_P_H
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index c5afe92..96145fb 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -155,7 +155,7 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
: captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false),
contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0),
globalClass(0), cleanup(0), erroredBindings(0), inProgressCreations(0),
- scriptEngine(this), workerScriptEngine(0), componentAttacheds(0), inBeginCreate(false),
+ scriptEngine(this), workerScriptEngine(0), componentAttached(0), inBeginCreate(false),
networkAccessManager(0), networkAccessManagerFactory(0),
typeManager(e), uniqueId(1)
{
@@ -350,14 +350,23 @@ typedef QMap<QString, QString> StringStringMap;
Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri
-void QDeclarativeDeclarativeData::destroyed(QDeclarativeData *d, QObject *o)
+void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *o)
{
- static_cast<QDeclarativeDeclarativeData *>(d)->destroyed(o);
+ QObjectPrivate *p = QObjectPrivate::get(o);
+ Q_ASSERT(p->declarativeData);
+ QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData);
+ if (d->ownContext)
+ d->context->destroy();
}
-void QDeclarativeDeclarativeData::parentChanged(QDeclarativeData *d, QObject *o, QObject *p)
+void QDeclarativeData::destroyed(QAbstractDeclarativeData *d, QObject *o)
{
- static_cast<QDeclarativeDeclarativeData *>(d)->parentChanged(o, p);
+ static_cast<QDeclarativeData *>(d)->destroyed(o);
+}
+
+void QDeclarativeData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p)
+{
+ static_cast<QDeclarativeData *>(d)->parentChanged(o, p);
}
void QDeclarativeEnginePrivate::init()
@@ -367,7 +376,7 @@ void QDeclarativeEnginePrivate::init()
qRegisterMetaType<QDeclarativeScriptString>("QDeclarativeScriptString");
qRegisterMetaType<QScriptValue>("QScriptValue");
- QDeclarativeDeclarativeData::init();
+ QDeclarativeData::init();
contextClass = new QDeclarativeContextScriptClass(q);
objectClass = new QDeclarativeObjectScriptClass(q);
@@ -659,8 +668,8 @@ QDeclarativeContext *QDeclarativeEngine::contextForObject(const QObject *object)
QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
- QDeclarativeDeclarativeData *data =
- static_cast<QDeclarativeDeclarativeData *>(priv->declarativeData);
+ QDeclarativeData *data =
+ static_cast<QDeclarativeData *>(priv->declarativeData);
if (!data)
return 0;
@@ -683,7 +692,7 @@ void QDeclarativeEngine::setContextForObject(QObject *object, QDeclarativeContex
if (!object || !context)
return;
- QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object, true);
+ QDeclarativeData *data = QDeclarativeData::get(object, true);
if (data->context) {
qWarning("QDeclarativeEngine::setContextForObject(): Object already has a QDeclarativeContext");
return;
@@ -734,7 +743,7 @@ void QDeclarativeEngine::setContextForObject(QObject *object, QDeclarativeContex
*/
void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership ownership)
{
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, true);
+ QDeclarativeData *ddata = QDeclarativeData::get(object, true);
if (!ddata)
return;
@@ -747,7 +756,7 @@ void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership own
*/
QDeclarativeEngine::ObjectOwnership QDeclarativeEngine::objectOwnership(QObject *object)
{
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, false);
+ QDeclarativeData *ddata = QDeclarativeData::get(object, false);
if (!ddata)
return CppOwnership;
else
@@ -756,14 +765,14 @@ QDeclarativeEngine::ObjectOwnership QDeclarativeEngine::objectOwnership(QObject
void qmlExecuteDeferred(QObject *object)
{
- QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object);
+ QDeclarativeData *data = QDeclarativeData::get(object);
if (data && data->deferredComponent) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(data->context->engine);
QDeclarativeComponentPrivate::ConstructionState state;
- QDeclarativeComponentPrivate::beginDeferred(data->context, ep, object, &state);
+ QDeclarativeComponentPrivate::beginDeferred(ep, object, &state);
data->deferredComponent->release();
data->deferredComponent = 0;
@@ -789,7 +798,7 @@ QDeclarativeEngine *qmlEngine(const QObject *obj)
QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create)
{
- QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object);
+ QDeclarativeData *data = QDeclarativeData::get(object);
if (!data)
return 0; // Attached properties are only on objects created by QML
@@ -824,7 +833,7 @@ QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object,
return qmlAttachedPropertiesObjectById(*idCache, object, create);
}
-void QDeclarativeDeclarativeData::destroyed(QObject *object)
+void QDeclarativeData::destroyed(QObject *object)
{
if (deferredComponent)
deferredComponent->release();
@@ -851,7 +860,7 @@ void QDeclarativeDeclarativeData::destroyed(QObject *object)
if (propertyCache)
propertyCache->release();
- if (ownContext)
+ if (ownContext && context)
context->destroy();
QDeclarativeGuard<QObject> *guard = guards;
@@ -871,12 +880,12 @@ void QDeclarativeDeclarativeData::destroyed(QObject *object)
delete this;
}
-void QDeclarativeDeclarativeData::parentChanged(QObject *, QObject *parent)
+void QDeclarativeData::parentChanged(QObject *, QObject *parent)
{
if (!parent && scriptValue) { delete scriptValue; scriptValue = 0; }
}
-bool QDeclarativeDeclarativeData::hasBindingBit(int bit) const
+bool QDeclarativeData::hasBindingBit(int bit) const
{
if (bindingBitsSize > bit)
return bindingBits[bit / 32] & (1 << (bit % 32));
@@ -884,13 +893,13 @@ bool QDeclarativeDeclarativeData::hasBindingBit(int bit) const
return false;
}
-void QDeclarativeDeclarativeData::clearBindingBit(int bit)
+void QDeclarativeData::clearBindingBit(int bit)
{
if (bindingBitsSize > bit)
bindingBits[bit / 32] &= ~(1 << (bit % 32));
}
-void QDeclarativeDeclarativeData::setBindingBit(QObject *obj, int bit)
+void QDeclarativeData::setBindingBit(QObject *obj, int bit)
{
if (bindingBitsSize <= bit) {
int props = obj->metaObject()->propertyCount();
@@ -956,7 +965,7 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS
QUrl url = QUrl(context->resolvedUrl(QUrl(arg)));
QDeclarativeComponent *c = new QDeclarativeComponent(activeEngine, url, activeEngine);
QDeclarativeComponentPrivate::get(c)->creationContext = context;
- QDeclarativeDeclarativeData::get(c, true)->setImplicitDestructible();
+ QDeclarativeData::get(c, true)->setImplicitDestructible();
return activeEnginePriv->objectClass->newQObject(c, qMetaTypeId<QDeclarativeComponent*>());
}
}
@@ -1027,7 +1036,7 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS
if(gobj && gparent)
gobj->setParentItem(gparent);
- QDeclarativeDeclarativeData::get(obj, true)->setImplicitDestructible();
+ QDeclarativeData::get(obj, true)->setImplicitDestructible();
return activeEnginePriv->objectClass->newQObject(obj, QMetaType::QObjectStar);
}
@@ -1356,7 +1365,9 @@ QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant(const QVariant &v
rv.setProperty(ii, objectClass->newQObject(object));
}
return rv;
- }
+ } else if (QDeclarativeValueType *vt = valueTypes[val.userType()]) {
+ return valueTypeClass->newObject(val, vt);
+ }
bool objOk;
QObject *obj = QDeclarativeMetaType::toQObject(val, &objOk);
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index 7766ad6..b3bba43 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -215,7 +215,7 @@ public:
QList<SimpleList<QDeclarativeAbstractBinding> > bindValues;
QList<SimpleList<QDeclarativeParserStatus> > parserStatus;
- QDeclarativeComponentAttached *componentAttacheds;
+ QDeclarativeComponentAttached *componentAttached;
bool inBeginCreate;
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index 3455883..578733c 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -264,7 +264,7 @@ void QDeclarativeEngineDebugServer::buildObjectList(QDataStream &message, QDecla
QDeclarativeEngineDebugServer::QDeclarativeObjectData
QDeclarativeEngineDebugServer::objectData(QObject *object)
{
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object);
+ QDeclarativeData *ddata = QDeclarativeData::get(object);
QDeclarativeObjectData rv;
if (ddata && ddata->outerContext) {
rv.url = ddata->outerContext->url;
diff --git a/src/declarative/qml/qdeclarativeguard_p.h b/src/declarative/qml/qdeclarativeguard_p.h
index 747d58f..be60ce4 100644
--- a/src/declarative/qml/qdeclarativeguard_p.h
+++ b/src/declarative/qml/qdeclarativeguard_p.h
@@ -65,7 +65,7 @@ class QDeclarativeGuard
QObject *o;
QDeclarativeGuard<QObject> *next;
QDeclarativeGuard<QObject> **prev;
- friend class QDeclarativeDeclarativeData;
+ friend class QDeclarativeData;
public:
inline QDeclarativeGuard();
inline QDeclarativeGuard(T *);
@@ -99,7 +99,7 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QDeclarativeGuard<QObject>);
-#include "private/qdeclarativedeclarativedata_p.h"
+#include "private/qdeclarativedata_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeinfo.cpp b/src/declarative/qml/qdeclarativeinfo.cpp
index 6199aa9..0a4352f 100644
--- a/src/declarative/qml/qdeclarativeinfo.cpp
+++ b/src/declarative/qml/qdeclarativeinfo.cpp
@@ -41,7 +41,7 @@
#include "qdeclarativeinfo.h"
-#include "private/qdeclarativedeclarativedata_p.h"
+#include "private/qdeclarativedata_p.h"
#include "qdeclarativecontext.h"
#include "private/qdeclarativecontext_p.h"
#include "private/qdeclarativemetatype_p.h"
@@ -100,7 +100,7 @@ QDeclarativeInfo::QDeclarativeInfo(const QObject *object)
pos += typeName;
}
- QDeclarativeDeclarativeData *ddata = object?QDeclarativeDeclarativeData::get(object):0;
+ QDeclarativeData *ddata = object?QDeclarativeData::get(object):0;
pos += QLatin1String(" (");
if (ddata) {
if (ddata->outerContext && !ddata->outerContext->url.isEmpty()) {
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index e1e33ab..5773fe6 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -43,7 +43,7 @@
#include "private/qdeclarativeengine_p.h"
#include "private/qdeclarativecontext_p.h"
-#include "private/qdeclarativedeclarativedata_p.h"
+#include "private/qdeclarativedata_p.h"
#include "private/qdeclarativetypenamescriptclass_p.h"
#include "private/qdeclarativelistscriptclass_p.h"
#include "private/qdeclarativebinding_p.h"
@@ -63,7 +63,7 @@ struct ObjectData : public QScriptDeclarativeClass::Object {
virtual ~ObjectData() {
if (object && !object->parent()) {
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, false);
+ QDeclarativeData *ddata = QDeclarativeData::get(object, false);
if (ddata && !ddata->indestructible)
object->deleteLater();
}
@@ -104,7 +104,7 @@ QScriptValue QDeclarativeObjectScriptClass::newQObject(QObject *object, int type
if (QObjectPrivate::get(object)->wasDeleted)
return scriptEngine->undefinedValue();
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, true);
+ QDeclarativeData *ddata = QDeclarativeData::get(object, true);
if (!ddata) {
return scriptEngine->undefinedValue();
@@ -428,7 +428,7 @@ QScriptValue QDeclarativeObjectScriptClass::destroy(QScriptContext *context, QSc
if (!data->object)
return engine->undefinedValue();
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(data->object, false);
+ QDeclarativeData *ddata = QDeclarativeData::get(data->object, false);
if (!ddata || ddata->indestructible)
return engine->currentContext()->throwError(QLatin1String("Invalid attempt to destroy() an indestructible object"));
@@ -453,7 +453,7 @@ QStringList QDeclarativeObjectScriptClass::propertyNames(Object *object)
QDeclarativeEnginePrivate *enginePrivate = QDeclarativeEnginePrivate::get(engine);
QDeclarativePropertyCache *cache = 0;
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(obj);
+ QDeclarativeData *ddata = QDeclarativeData::get(obj);
if (ddata)
cache = ddata->propertyCache;
if (!cache) {
@@ -752,7 +752,7 @@ QScriptDeclarativeClass::Value MetaCallArgument::toValue(QDeclarativeEngine *e)
return QScriptDeclarativeClass::Value(engine, *((QString *)&data));
} else if (type == QMetaType::QObjectStar) {
QObject *object = *((QObject **)&data);
- QDeclarativeDeclarativeData::get(object, true)->setImplicitDestructible();
+ QDeclarativeData::get(object, true)->setImplicitDestructible();
QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(e);
return QScriptDeclarativeClass::Value(engine, priv->objectClass->newQObject(object));
} else if (type == qMetaTypeId<QList<QObject *> >()) {
@@ -761,7 +761,7 @@ QScriptDeclarativeClass::Value MetaCallArgument::toValue(QDeclarativeEngine *e)
QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(e);
for (int ii = 0; ii < list.count(); ++ii) {
QObject *object = list.at(ii);
- QDeclarativeDeclarativeData::get(object, true)->setImplicitDestructible();
+ QDeclarativeData::get(object, true)->setImplicitDestructible();
rv.setProperty(ii, priv->objectClass->newQObject(object));
}
return QScriptDeclarativeClass::Value(engine, rv);
diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h
index bebe82c..6e240d8 100644
--- a/src/declarative/qml/qdeclarativeprivate.h
+++ b/src/declarative/qml/qdeclarativeprivate.h
@@ -69,11 +69,18 @@ public:
class QDeclarativeCustomParser;
namespace QDeclarativePrivate
{
+ void Q_DECLARATIVE_EXPORT qdeclarativeelement_destructor(QObject *);
template<typename T>
- QObject *create() { return new T; }
+ class QDeclarativeElement : public T
+ {
+ public:
+ virtual ~QDeclarativeElement() {
+ QDeclarativePrivate::qdeclarativeelement_destructor(this);
+ }
+ };
template<typename T>
- void createInto(void *memory) { new (memory) T; }
+ void createInto(void *memory) { new (memory) QDeclarativeElement<T>; }
template<typename T>
QObject *createParent(QObject *p) { return new T(p); }
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
index affb6b9..afd0d84 100644
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -50,7 +50,7 @@
#include "private/qdeclarativeboundsignal_p.h"
#include "qdeclarativeengine.h"
#include "private/qdeclarativeengine_p.h"
-#include "private/qdeclarativedeclarativedata_p.h"
+#include "private/qdeclarativedata_p.h"
#include "private/qdeclarativestringconverters_p.h"
#include "private/qdeclarativelist_p.h"
#include "private/qdeclarativecompiler_p.h"
@@ -286,7 +286,7 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name
QString signalName = terminal.mid(2);
signalName[0] = signalName.at(0).toLower();
- QMetaMethod method = QDeclarativeCompiler::findSignalByName(currentObject->metaObject(), signalName.toLatin1().constData());
+ QMetaMethod method = findSignalByName(currentObject->metaObject(), signalName.toLatin1().constData());
if (method.signature()) {
object = currentObject;
core.load(method);
@@ -606,7 +606,7 @@ QDeclarativePropertyPrivate::binding(const QDeclarativeProperty &that)
if (!that.isProperty() || !that.d->object)
return 0;
- QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(that.d->object);
+ QDeclarativeData *data = QDeclarativeData::get(that.d->object);
if (!data)
return 0;
@@ -660,7 +660,7 @@ QDeclarativeAbstractBinding *
QDeclarativePropertyPrivate::setBinding(QObject *object, int coreIndex, int valueTypeIndex,
QDeclarativeAbstractBinding *newBinding, WriteFlags flags)
{
- QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object, 0 != newBinding);
+ QDeclarativeData *data = QDeclarativeData::get(object, 0 != newBinding);
QDeclarativeAbstractBinding *binding = 0;
if (data && data->hasBindingBit(coreIndex)) {
@@ -1353,4 +1353,36 @@ bool QDeclarativePropertyPrivate::canConvert(const QMetaObject *from, const QMet
return false;
}
+/*!
+ Return the signal corresponding to \a name
+*/
+QMetaMethod QDeclarativePropertyPrivate::findSignalByName(const QMetaObject *mo, const QByteArray &name)
+{
+ Q_ASSERT(mo);
+ int methods = mo->methodCount();
+ for (int ii = methods - 1; ii >= 2; --ii) { // >= 2 to block the destroyed signal
+ QMetaMethod method = mo->method(ii);
+ QByteArray methodName = method.signature();
+ int idx = methodName.indexOf('(');
+ methodName = methodName.left(idx);
+
+ if (methodName == name)
+ return method;
+ }
+
+ // If no signal is found, but the signal is of the form "onBlahChanged",
+ // return the notify signal for the property "Blah"
+ if (name.endsWith("Changed")) {
+ QByteArray propName = name.mid(0, name.length() - 7);
+ int propIdx = mo->indexOfProperty(propName.constData());
+ if (propIdx >= 0) {
+ QMetaProperty prop = mo->property(propIdx);
+ if (prop.hasNotifySignal())
+ return prop.notifySignal();
+ }
+ }
+
+ return QMetaMethod();
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h
index 420a1ba..8522561 100644
--- a/src/declarative/qml/qdeclarativeproperty_p.h
+++ b/src/declarative/qml/qdeclarativeproperty_p.h
@@ -96,8 +96,6 @@ public:
void initProperty(QObject *obj, const QString &name);
void initDefault(QObject *obj);
- QMetaMethod findSignal(QObject *, const QString &);
-
bool isValueType() const;
int propertyType() const;
QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory() const;
@@ -134,6 +132,7 @@ public:
static bool write(const QDeclarativeProperty &that, const QVariant &, WriteFlags);
static int valueTypeCoreIndex(const QDeclarativeProperty &that);
static int bindingIndex(const QDeclarativeProperty &that);
+ static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyPrivate::WriteFlags)
diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp
index 111259d..888945b 100644
--- a/src/declarative/qml/qdeclarativepropertycache.cpp
+++ b/src/declarative/qml/qdeclarativepropertycache.cpp
@@ -147,7 +147,7 @@ QDeclarativePropertyCache::Data QDeclarativePropertyCache::create(const QMetaObj
}
int methodCount = metaObject->methodCount();
- for (int ii = methodCount - 1; ii >= 0; --ii) {
+ for (int ii = methodCount - 1; ii >= 2; --ii) { // >=2 to block the destroyed signal
QMetaMethod m = metaObject->method(ii);
if (m.access() == QMetaMethod::Private)
continue;
@@ -216,7 +216,7 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb
}
int methodCount = metaObject->methodCount();
- int methodOffset = metaObject->methodOffset();
+ int methodOffset = qMax(2, metaObject->methodOffset()); // 2 to block the destroyed signal
for (int ii = methodOffset; ii < methodCount; ++ii) {
QMetaMethod m = metaObject->method(ii);
if (m.access() == QMetaMethod::Private)
@@ -289,7 +289,7 @@ void QDeclarativePropertyCache::update(QDeclarativeEngine *engine, const QMetaOb
}
int methodCount = metaObject->methodCount();
- for (int ii = methodCount - 1; ii >= 0; --ii) {
+ for (int ii = methodCount - 1; ii >= 2; --ii) { // >=2 to block the destroyed signal
QMetaMethod m = metaObject->method(ii);
if (m.access() == QMetaMethod::Private)
continue;
@@ -368,7 +368,7 @@ QDeclarativePropertyCache::Data *QDeclarativePropertyCache::property(QDeclarativ
QDeclarativeEnginePrivate *enginePrivate = QDeclarativeEnginePrivate::get(engine);
QDeclarativePropertyCache *cache = 0;
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(obj);
+ QDeclarativeData *ddata = QDeclarativeData::get(obj);
if (ddata && ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine)
cache = ddata->propertyCache;
if (!cache) {
@@ -400,7 +400,7 @@ QDeclarativePropertyCache::Data *QDeclarativePropertyCache::property(QDeclarativ
QDeclarativeEnginePrivate *enginePrivate = QDeclarativeEnginePrivate::get(engine);
QDeclarativePropertyCache *cache = 0;
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(obj);
+ QDeclarativeData *ddata = QDeclarativeData::get(obj);
if (ddata && ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine)
cache = ddata->propertyCache;
if (!cache) {
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index 261c84a..352a6c0 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -99,12 +99,6 @@ void QDeclarativeValueTypeFactory::registerValueTypes()
qmlRegisterValueTypeEnums<QDeclarativeFontValueType>("Font");
}
-QDeclarativeValueType *QDeclarativeValueTypeFactory::operator[](int idx) const
-{
- return valueTypes[idx];
-}
-
-
QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t)
{
switch (t) {
diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h
index 5bfc27d..d1833bb 100644
--- a/src/declarative/qml/qdeclarativevaluetype_p.h
+++ b/src/declarative/qml/qdeclarativevaluetype_p.h
@@ -86,7 +86,10 @@ public:
static void registerValueTypes();
- QDeclarativeValueType *operator[](int idx) const;
+ QDeclarativeValueType *operator[](int idx) const {
+ if (idx >= (int)QVariant::UserType) return 0;
+ else return valueTypes[idx];
+ }
private:
QDeclarativeValueType *valueTypes[QVariant::UserType - 1];
diff --git a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp
index fdb71c6..cb1f27d 100644
--- a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp
+++ b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp
@@ -48,12 +48,24 @@
QT_BEGIN_NAMESPACE
-struct QDeclarativeValueTypeReference : public QScriptDeclarativeClass::Object {
+struct QDeclarativeValueTypeObject : public QScriptDeclarativeClass::Object {
+ enum Type { Reference, Copy };
+ QDeclarativeValueTypeObject(Type t) : objectType(t) {}
+ Type objectType;
QDeclarativeValueType *type;
+};
+
+struct QDeclarativeValueTypeReference : public QDeclarativeValueTypeObject {
+ QDeclarativeValueTypeReference() : QDeclarativeValueTypeObject(Reference) {}
QDeclarativeGuard<QObject> object;
int property;
};
+struct QDeclarativeValueTypeCopy : public QDeclarativeValueTypeObject {
+ QDeclarativeValueTypeCopy() : QDeclarativeValueTypeObject(Copy) {}
+ QVariant value;
+};
+
QDeclarativeValueTypeScriptClass::QDeclarativeValueTypeScriptClass(QDeclarativeEngine *bindEngine)
: QScriptDeclarativeClass(QDeclarativeEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine)
{
@@ -73,40 +85,67 @@ QScriptValue QDeclarativeValueTypeScriptClass::newObject(QObject *object, int co
return QScriptDeclarativeClass::newObject(scriptEngine, this, ref);
}
+QScriptValue QDeclarativeValueTypeScriptClass::newObject(const QVariant &v, QDeclarativeValueType *type)
+{
+ QDeclarativeValueTypeCopy *copy = new QDeclarativeValueTypeCopy;
+ copy->type = type;
+ copy->value = v;
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+ return QScriptDeclarativeClass::newObject(scriptEngine, this, copy);
+}
+
QScriptClass::QueryFlags
QDeclarativeValueTypeScriptClass::queryProperty(Object *obj, const Identifier &name,
- QScriptClass::QueryFlags)
+ QScriptClass::QueryFlags)
{
- QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(obj);
+ QDeclarativeValueTypeObject *o = static_cast<QDeclarativeValueTypeObject *>(obj);
m_lastIndex = -1;
- if (!ref->object)
- return 0;
-
QByteArray propName = toString(name).toUtf8();
- m_lastIndex = ref->type->metaObject()->indexOfProperty(propName.constData());
+ m_lastIndex = o->type->metaObject()->indexOfProperty(propName.constData());
if (m_lastIndex == -1)
return 0;
- QMetaProperty prop = ref->object->metaObject()->property(m_lastIndex);
+ QScriptClass::QueryFlags rv = 0;
+
+ if (o->objectType == QDeclarativeValueTypeObject::Reference) {
+ QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(o);
+
+ if (!ref->object)
+ return 0;
- QScriptClass::QueryFlags rv =
- QScriptClass::HandlesReadAccess;
- if (prop.isWritable())
- rv |= QScriptClass::HandlesWriteAccess;
+ QMetaProperty prop = ref->object->metaObject()->property(m_lastIndex);
+
+ rv = QScriptClass::HandlesReadAccess;
+ if (prop.isWritable())
+ rv |= QScriptClass::HandlesWriteAccess;
+ } else {
+ rv = QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess;
+ }
return rv;
}
QDeclarativeValueTypeScriptClass::Value QDeclarativeValueTypeScriptClass::property(Object *obj, const Identifier &)
{
- QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(obj);
+ QDeclarativeValueTypeObject *o = static_cast<QDeclarativeValueTypeObject *>(obj);
- QMetaProperty p = ref->type->metaObject()->property(m_lastIndex);
- ref->type->read(ref->object, ref->property);
- QVariant rv = p.read(ref->type);
+ QVariant rv;
+ if (o->objectType == QDeclarativeValueTypeObject::Reference) {
+ QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(obj);
+
+ QMetaProperty p = ref->type->metaObject()->property(m_lastIndex);
+ ref->type->read(ref->object, ref->property);
+ rv = p.read(ref->type);
+ } else {
+ QDeclarativeValueTypeCopy *copy = static_cast<QDeclarativeValueTypeCopy *>(obj);
+
+ QMetaProperty p = copy->type->metaObject()->property(m_lastIndex);
+ copy->type->setValue(copy->value);
+ rv = p.read(copy->type);
+ }
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
return Value(scriptEngine, static_cast<QDeclarativeEnginePrivate *>(QObjectPrivate::get(engine))->scriptValueFromVariant(rv));
@@ -115,33 +154,53 @@ QDeclarativeValueTypeScriptClass::Value QDeclarativeValueTypeScriptClass::proper
void QDeclarativeValueTypeScriptClass::setProperty(Object *obj, const Identifier &,
const QScriptValue &value)
{
- QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(obj);
-
- QDeclarativeAbstractBinding *delBinding =
- QDeclarativePropertyPrivate::setBinding(ref->object, ref->property, m_lastIndex, 0);
- if (delBinding)
- delBinding->destroy();
+ QDeclarativeValueTypeObject *o = static_cast<QDeclarativeValueTypeObject *>(obj);
QVariant v = QDeclarativeEnginePrivate::get(engine)->scriptValueToVariant(value);
- ref->type->read(ref->object, ref->property);
- QMetaProperty p = ref->type->metaObject()->property(m_lastIndex);
- p.write(ref->type, v);
- ref->type->write(ref->object, ref->property, 0);
+ if (o->objectType == QDeclarativeValueTypeObject::Reference) {
+ QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(obj);
+
+ QDeclarativeAbstractBinding *delBinding =
+ QDeclarativePropertyPrivate::setBinding(ref->object, ref->property, m_lastIndex, 0);
+ if (delBinding)
+ delBinding->destroy();
+
+ ref->type->read(ref->object, ref->property);
+ QMetaProperty p = ref->type->metaObject()->property(m_lastIndex);
+ p.write(ref->type, v);
+ ref->type->write(ref->object, ref->property, 0);
+ } else {
+ QDeclarativeValueTypeCopy *copy = static_cast<QDeclarativeValueTypeCopy *>(obj);
+ copy->type->setValue(copy->value);
+ QMetaProperty p = copy->type->metaObject()->property(m_lastIndex);
+ p.write(copy->type, v);
+ copy->value = copy->type->value();
+ }
}
QVariant QDeclarativeValueTypeScriptClass::toVariant(Object *obj, bool *ok)
{
- QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(obj);
+ QDeclarativeValueTypeObject *o = static_cast<QDeclarativeValueTypeObject *>(obj);
- if (ok) *ok = true;
+ if (o->objectType == QDeclarativeValueTypeObject::Reference) {
+ QDeclarativeValueTypeReference *ref = static_cast<QDeclarativeValueTypeReference *>(obj);
- if (ref->object) {
- ref->type->read(ref->object, ref->property);
- return ref->type->value();
+ if (ok) *ok = true;
+
+ if (ref->object) {
+ ref->type->read(ref->object, ref->property);
+ return ref->type->value();
+ }
} else {
- return QVariant();
+ QDeclarativeValueTypeCopy *copy = static_cast<QDeclarativeValueTypeCopy *>(obj);
+
+ if (ok) *ok = true;
+
+ return copy->value;
}
+
+ return QVariant();
}
QVariant QDeclarativeValueTypeScriptClass::toVariant(const QScriptValue &value)
diff --git a/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h b/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h
index 2bbb61f..9dafa99 100644
--- a/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h
+++ b/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h
@@ -67,6 +67,7 @@ public:
~QDeclarativeValueTypeScriptClass();
QScriptValue newObject(QObject *object, int coreIndex, QDeclarativeValueType *);
+ QScriptValue newObject(const QVariant &, QDeclarativeValueType *);
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
QScriptClass::QueryFlags flags);
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 3575c17..fdcbeee 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -45,7 +45,7 @@
#include "private/qdeclarativeboundsignal_p.h"
#include "private/qdeclarativestringconverters_p.h"
#include "private/qmetaobjectbuilder_p.h"
-#include "private/qdeclarativedeclarativedata_p.h"
+#include "private/qdeclarativedata_p.h"
#include "qdeclarative.h"
#include "private/qdeclarativecustomparser_p.h"
#include "qdeclarativeengine.h"
@@ -112,7 +112,7 @@ QObject *QDeclarativeVME::run(QDeclarativeContextData *ctxt, QDeclarativeCompile
void QDeclarativeVME::runDeferred(QObject *object)
{
- QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object);
+ QDeclarativeData *data = QDeclarativeData::get(object);
if (!data || !data->context || !data->deferredComponent)
return;
@@ -194,7 +194,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Unable to create object of type %1").arg(QString::fromLatin1(types.at(instr.create.type).className)));
}
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(o);
+ QDeclarativeData *ddata = QDeclarativeData::get(o);
Q_ASSERT(ddata);
if (stack.isEmpty()) {
@@ -245,12 +245,12 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::CreateSimpleObject:
{
QObject *o = (QObject *)operator new(instr.createSimple.typeSize +
- sizeof(QDeclarativeDeclarativeData));
- ::memset(o, 0, instr.createSimple.typeSize + sizeof(QDeclarativeDeclarativeData));
+ sizeof(QDeclarativeData));
+ ::memset(o, 0, instr.createSimple.typeSize + sizeof(QDeclarativeData));
instr.createSimple.create(o);
- QDeclarativeDeclarativeData *ddata =
- (QDeclarativeDeclarativeData *)(((const char *)o) + instr.createSimple.typeSize);
+ QDeclarativeData *ddata =
+ (QDeclarativeData *)(((const char *)o) + instr.createSimple.typeSize);
ddata->lineNumber = instr.line;
ddata->columnNumber = instr.createSimple.column;
@@ -289,7 +289,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
new QDeclarativeComponent(ctxt->engine, comp, ii + 1, instr.createComponent.count,
stack.isEmpty() ? 0 : stack.top());
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(qcomp, true);
+ QDeclarativeData *ddata = QDeclarativeData::get(qcomp, true);
Q_ASSERT(ddata);
ctxt->addObject(qcomp);
@@ -322,7 +322,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
(void)new QDeclarativeVMEMetaObject(target, &mo, data, comp);
- QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(target, true);
+ QDeclarativeData *ddata = QDeclarativeData::get(target, true);
if (ddata->propertyCache) ddata->propertyCache->release();
ddata->propertyCache = propertyCaches.at(instr.storeMeta.propertyCache);
ddata->propertyCache->addref();
@@ -854,8 +854,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
{
if (instr.defer.deferCount) {
QObject *target = stack.top();
- QDeclarativeDeclarativeData *data =
- QDeclarativeDeclarativeData::get(target, true);
+ QDeclarativeData *data =
+ QDeclarativeData::get(target, true);
comp->addref();
data->deferredComponent = comp;
data->deferredIdx = ii;
@@ -935,8 +935,8 @@ QDeclarativeCompiledData::TypeReference::createInstance(QDeclarativeContextData
QObject *rv = 0;
void *memory = 0;
- type->create(&rv, &memory, sizeof(QDeclarativeDeclarativeData));
- QDeclarativeDeclarativeData *ddata = new (memory) QDeclarativeDeclarativeData;
+ type->create(&rv, &memory, sizeof(QDeclarativeData));
+ QDeclarativeData *ddata = new (memory) QDeclarativeData;
ddata->ownMemory = false;
QObjectPrivate::get(rv)->declarativeData = ddata;
diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp
index 2e2a8e8..c4d47b3 100644
--- a/src/declarative/qml/qdeclarativevmemetaobject.cpp
+++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp
@@ -379,7 +379,7 @@ QDeclarativeVMEMetaObject::QDeclarativeVMEMetaObject(QObject *obj,
const QMetaObject *other,
const QDeclarativeVMEMetaData *meta,
QDeclarativeCompiledData *cdata)
-: object(obj), compiledData(cdata), ctxt(QDeclarativeDeclarativeData::get(obj)->outerContext),
+: object(obj), compiledData(cdata), ctxt(QDeclarativeData::get(obj)->outerContext),
metaData(meta), data(0), methods(0), parent(0)
{
compiledData->addref();
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index 1087f44..c48662c 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -94,7 +94,7 @@ HEADERS += \
$$PWD/qdeclarativecompositetypemanager_p.h \
$$PWD/qdeclarativelist.h \
$$PWD/qdeclarativelist_p.h \
- $$PWD/qdeclarativedeclarativedata_p.h \
+ $$PWD/qdeclarativedata_p.h \
$$PWD/qdeclarativeerror.h \
$$PWD/qdeclarativescriptparser_p.h \
$$PWD/qdeclarativeenginedebug_p.h \
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 33ddb46..7e20428 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -44,6 +44,7 @@
#include "private/qdeclarativebehavior_p.h"
#include "private/qdeclarativestateoperations_p.h"
+#include "private/qdeclarativecontext_p.h"
#include <qdeclarativepropertyvaluesource.h>
#include <qdeclarative.h>
@@ -767,6 +768,7 @@ void QDeclarativeScriptAction::setStateChangeScriptName(const QString &name)
void QDeclarativeScriptActionPrivate::execute()
{
+ Q_Q(QDeclarativeScriptAction);
if (hasRunScriptScript && reversing)
return;
@@ -775,7 +777,12 @@ void QDeclarativeScriptActionPrivate::execute()
const QString &str = scriptStr.script();
if (!str.isEmpty()) {
QDeclarativeExpression expr(scriptStr.context(), str, scriptStr.scopeObject());
+ QDeclarativeData *ddata = QDeclarativeData::get(q);
+ if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
+ expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber);
expr.value();
+ if (expr.hasError())
+ qWarning() << expr.error();
}
}
diff --git a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp
index 3c0a086..d91b107 100644
--- a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp
+++ b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp
@@ -41,7 +41,7 @@
#include "private/qdeclarativelistmodelworkeragent_p.h"
#include "private/qdeclarativelistmodel_p_p.h"
-#include "private/qdeclarativedeclarativedata_p.h"
+#include "private/qdeclarativedata_p.h"
#include "private/qdeclarativeengine_p.h"
#include "qdeclarativeinfo.h"
diff --git a/src/declarative/util/qdeclarativeopenmetaobject.cpp b/src/declarative/util/qdeclarativeopenmetaobject.cpp
index 3d95125..0e5aaa6 100644
--- a/src/declarative/util/qdeclarativeopenmetaobject.cpp
+++ b/src/declarative/util/qdeclarativeopenmetaobject.cpp
@@ -41,7 +41,7 @@
#include "private/qdeclarativeopenmetaobject_p.h"
#include "private/qdeclarativepropertycache_p.h"
-#include "private/qdeclarativedeclarativedata_p.h"
+#include "private/qdeclarativedata_p.h"
#include <qmetaobjectbuilder_p.h>
#include <qdebug.h>
@@ -302,7 +302,7 @@ void QDeclarativeOpenMetaObject::setCached(bool c)
d->cacheProperties = c;
- QDeclarativeDeclarativeData *qmldata = QDeclarativeDeclarativeData::get(d->object, true);
+ QDeclarativeData *qmldata = QDeclarativeData::get(d->object, true);
if (d->cacheProperties) {
if (!d->type->d->cache)
d->type->d->cache = QDeclarativePropertyCache::create(d->type->d->engine, this);
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp
index 5e60819..dbca326 100644
--- a/src/declarative/util/qdeclarativepixmapcache.cpp
+++ b/src/declarative/util/qdeclarativepixmapcache.cpp
@@ -194,8 +194,8 @@ static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *e
return true;
} else {
if (errorString)
- *errorString = QLatin1String("Error decoding: ") + url.toString()
- + QLatin1String(" \"") + imgio.errorString() + QLatin1String("\"");
+ *errorString = QDeclarativePixmapCache::tr("Error decoding: %1: %2").arg(url.toString())
+ .arg(imgio.errorString());
return false;
}
}
@@ -264,7 +264,7 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event)
QString errorStr;
if (image.isNull()) {
errorCode = QDeclarativeImageReaderEvent::Loading;
- errorStr = QLatin1String("Failed to get image from provider: ") + url.toString();
+ errorStr = QDeclarativePixmapCache::tr("Failed to get image from provider: %1").arg(url.toString());
}
QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image));
} else {
@@ -283,7 +283,7 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event)
errorCode = QDeclarativeImageReaderEvent::Loading;
}
} else {
- errorStr = QLatin1String("Cannot open: ") + url.toString();
+ errorStr = QDeclarativePixmapCache::tr("Cannot open: %1").arg(url.toString());
errorCode = QDeclarativeImageReaderEvent::Loading;
}
QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image));
@@ -460,6 +460,7 @@ public:
bool loading;
QDeclarativeImageReader *reader;
int forced_width, forced_height;
+ QString errorString;
};
@@ -511,7 +512,7 @@ bool QDeclarativePixmapReply::event(QEvent *event)
if (d->status == Ready)
d->pixmap = QPixmap::fromImage(de->image);
else
- qWarning() << de->errorString;
+ d->errorString = de->errorString;
QByteArray key = d->url.toEncoded(QUrl::FormattingOption(0x100));
QString strKey = QString::fromLatin1(key.constData(), key.count());
QPixmapCache::insert(strKey, d->pixmap); // note: may fail (returns false)
@@ -523,6 +524,12 @@ bool QDeclarativePixmapReply::event(QEvent *event)
return QObject::event(event);
}
+QString QDeclarativePixmapReply::errorString() const
+{
+ Q_D(const QDeclarativePixmapReply);
+ return d->errorString;
+}
+
QDeclarativePixmapReply::Status QDeclarativePixmapReply::status() const
{
Q_D(const QDeclarativePixmapReply);
@@ -586,7 +593,7 @@ bool QDeclarativePixmapReply::release(bool defer)
Note that images sourced from the network will always be loaded and
decoded asynchonously.
*/
-QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QPixmap *pixmap, QSize *impsize, bool async, int req_width, int req_height)
+QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QPixmap *pixmap, QString *errorString, QSize *impsize, bool async, int req_width, int req_height)
{
QDeclarativePixmapReply::Status status = QDeclarativePixmapReply::Unrequested;
QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100));
@@ -609,17 +616,16 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP
QFile f(lf);
QSize read_impsize;
if (f.open(QIODevice::ReadOnly)) {
- QString errorString;
QImage image;
- if (readImage(url, &f, &image, &errorString, &read_impsize, req_width, req_height)) {
+ if (readImage(url, &f, &image, errorString, &read_impsize, req_width, req_height)) {
*pixmap = QPixmap::fromImage(image);
} else {
- qWarning() << errorString;
*pixmap = QPixmap();
status = QDeclarativePixmapReply::Error;
}
} else {
- qWarning() << "Cannot open" << url;
+ if (errorString)
+ *errorString = tr("Cannot open: %1").arg(url.toString());
*pixmap = QPixmap();
status = QDeclarativePixmapReply::Error;
}
@@ -650,9 +656,15 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP
} else if (QPixmapCache::find(strKey, pixmap)) {
if (iter != qmlActivePixmapReplies()->end()) {
status = (*iter)->status();
+ if (errorString)
+ *errorString = (*iter)->errorString();
(*iter)->release();
+ } else if (pixmap->isNull()) {
+ status = QDeclarativePixmapReply::Error;
+ if (errorString)
+ *errorString = tr("Unknown Error loading %1").arg(url.toString());
} else {
- status = pixmap->isNull() ? QDeclarativePixmapReply::Error : QDeclarativePixmapReply::Ready;
+ status = QDeclarativePixmapReply::Ready;
}
} else if (iter != qmlActivePixmapReplies()->end()) {
status = QDeclarativePixmapReply::Loading;
diff --git a/src/declarative/util/qdeclarativepixmapcache_p.h b/src/declarative/util/qdeclarativepixmapcache_p.h
index df71d65..33d9de1 100644
--- a/src/declarative/util/qdeclarativepixmapcache_p.h
+++ b/src/declarative/util/qdeclarativepixmapcache_p.h
@@ -45,6 +45,7 @@
#include <QtCore/QString>
#include <QtGui/QPixmap>
#include <QtCore/qurl.h>
+#include <QtCore/QCoreApplication>
QT_BEGIN_HEADER
@@ -64,6 +65,7 @@ public:
enum Status { Ready, Error, Unrequested, Loading };
Status status() const;
+ QString errorString() const;
const QUrl &url() const;
int forcedWidth() const;
@@ -94,8 +96,9 @@ private:
class Q_DECLARATIVE_EXPORT QDeclarativePixmapCache
{
+ Q_DECLARE_TR_FUNCTIONS(QDeclarativePixmapCache)
public:
- static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, QSize *impsize=0, bool async=false, int req_width=0, int req_height=0);
+ static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, QString *errorString, QSize *impsize=0, bool async=false, int req_width=0, int req_height=0);
static QDeclarativePixmapReply *request(QDeclarativeEngine *, const QUrl& url, int req_width=0, int req_height=0);
static void cancel(const QUrl& url, QObject *obj);
static int pendingRequests();
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 410a269..3854b10 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -49,6 +49,7 @@
#include <qdeclarativeitem_p.h>
#include <qdeclarativeguard_p.h>
#include <qdeclarativenullablevalue_p_p.h>
+#include "private/qdeclarativecontext_p.h"
#include <QtCore/qdebug.h>
#include <QtGui/qgraphicsitem.h>
@@ -571,7 +572,12 @@ void QDeclarativeStateChangeScript::execute()
const QString &script = d->script.script();
if (!script.isEmpty()) {
QDeclarativeExpression expr(d->script.context(), script, d->script.scopeObject());
+ QDeclarativeData *ddata = QDeclarativeData::get(this);
+ if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
+ expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber);
expr.value();
+ if (expr.hasError())
+ qWarning() << expr.error();
}
}
diff --git a/src/gui/dialogs/qpagesetupdialog_mac.mm b/src/gui/dialogs/qpagesetupdialog_mac.mm
index 13ffa05..cfcde0f 100644
--- a/src/gui/dialogs/qpagesetupdialog_mac.mm
+++ b/src/gui/dialogs/qpagesetupdialog_mac.mm
@@ -232,6 +232,11 @@ void QPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality)
void QPageSetupDialogPrivate::closeCocoaPageLayout()
{
+ // NSPageLayout can change the session behind our back and then our
+ // d->ep->session object will become a dangling pointer. Update it
+ // based on the "current" session
+ ep->session = static_cast<PMPrintSession>([ep->printInfo PMPrintSession]);
+
[pageLayout release];
pageLayout = 0;
}
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp
index 6f215cc..0fe5cbe 100644
--- a/src/gui/egl/qegl.cpp
+++ b/src/gui/egl/qegl.cpp
@@ -326,10 +326,17 @@ EGLSurface QEglContext::createSurface(QPaintDevice* device, const QEglProperties
bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties *properties)
{
// We need to select the correct API before calling eglCreateContext().
+#ifdef QT_OPENGL_ES
#ifdef EGL_OPENGL_ES_API
if (apiType == QEgl::OpenGL)
eglBindAPI(EGL_OPENGL_ES_API);
#endif
+#else
+#ifdef EGL_OPENGL_API
+ if (apiType == QEgl::OpenGL)
+ eglBindAPI(EGL_OPENGL_API);
+#endif
+#endif //defined(QT_OPENGL_ES)
#ifdef EGL_OPENVG_API
if (apiType == QEgl::OpenVG)
eglBindAPI(EGL_OPENVG_API);
@@ -339,7 +346,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties
QEglProperties contextProps;
if (properties)
contextProps = *properties;
-#if defined(QT_OPENGL_ES_2)
+#ifdef QT_OPENGL_ES_2
if (apiType == QEgl::OpenGL)
contextProps.setValue(EGL_CONTEXT_CLIENT_VERSION, 2);
#endif
@@ -528,10 +535,14 @@ QEglProperties QEglContext::configProperties() const
return QEglProperties(config());
}
-#if (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES)
-_eglCreateImageKHR eglCreateImageKHR = 0;
-_eglDestroyImageKHR eglDestroyImageKHR = 0;
-#endif
+
+typedef EGLImageKHR (EGLAPIENTRY *_eglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*);
+typedef EGLBoolean (EGLAPIENTRY *_eglDestroyImageKHR)(EGLDisplay, EGLImageKHR);
+
+// Defined in qegl.cpp:
+static _eglCreateImageKHR qt_eglCreateImageKHR = 0;
+static _eglDestroyImageKHR qt_eglDestroyImageKHR = 0;
+
EGLDisplay QEgl::display()
{
@@ -558,8 +569,8 @@ EGLDisplay QEgl::display()
// Resolve the egl extension function pointers:
#if (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES)
if (QEgl::hasExtension("EGL_KHR_image") || QEgl::hasExtension("EGL_KHR_image_base")) {
- eglCreateImageKHR = (_eglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR");
- eglDestroyImageKHR = (_eglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR");
+ qt_eglCreateImageKHR = (_eglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR");
+ qt_eglDestroyImageKHR = (_eglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR");
}
#endif
}
@@ -567,6 +578,33 @@ EGLDisplay QEgl::display()
return dpy;
}
+EGLImageKHR QEgl::eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
+{
+ if (qt_eglCreateImageKHR)
+ return qt_eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list);
+
+ QEgl::display(); // Initialises function pointers
+ if (qt_eglCreateImageKHR)
+ return qt_eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list);
+
+ qWarning("QEgl::eglCreateImageKHR() called but EGL_KHR_image(_base) extension not present");
+ return 0;
+}
+
+EGLBoolean QEgl::eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
+{
+ if (qt_eglDestroyImageKHR)
+ return qt_eglDestroyImageKHR(dpy, img);
+
+ QEgl::display(); // Initialises function pointers
+ if (qt_eglDestroyImageKHR)
+ return qt_eglDestroyImageKHR(dpy, img);
+
+ qWarning("QEgl::eglDestroyImageKHR() called but EGL_KHR_image(_base) extension not present");
+ return 0;
+}
+
+
#ifndef Q_WS_X11
EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *properties)
{
diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h
index f81add6..6345d5d 100644
--- a/src/gui/egl/qegl_p.h
+++ b/src/gui/egl/qegl_p.h
@@ -147,20 +147,6 @@ typedef void *EGLImageKHR;
#define EGL_KHR_image_pixmap
#endif
-// It is possible that something has included eglext.h (like Symbian 10.1's broken egl.h), in
-// which case, EGL_KHR_image/EGL_KHR_image_base will be defined. They may have also defined
-// the actual function prototypes, but generally EGL_EGLEXT_PROTOTYPES will be defined in that
-// case and we shouldn't re-define them here.
-#if (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES)
-typedef EGLImageKHR (EGLAPIENTRY *_eglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, EGLint*);
-typedef EGLBoolean (EGLAPIENTRY *_eglDestroyImageKHR)(EGLDisplay, EGLImageKHR);
-
-// Defined in qegl.cpp:
-extern Q_GUI_EXPORT _eglCreateImageKHR eglCreateImageKHR;
-extern Q_GUI_EXPORT _eglDestroyImageKHR eglDestroyImageKHR;
-#endif // (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES)
-
-
class QEglProperties;
@@ -210,6 +196,10 @@ namespace QEgl {
Q_GUI_EXPORT EGLNativeWindowType nativeWindow(QWidget*);
Q_GUI_EXPORT EGLNativePixmapType nativePixmap(QPixmap*);
+ // Extension functions
+ Q_GUI_EXPORT EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+ Q_GUI_EXPORT EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img);
+
#ifdef Q_WS_X11
Q_GUI_EXPORT VisualID getCompatibleVisualId(EGLConfig config);
#endif
diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp
index 5341ea1..cb8dcda 100644
--- a/src/gui/egl/qegl_x11.cpp
+++ b/src/gui/egl/qegl_x11.cpp
@@ -210,6 +210,11 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config)
}
XFree(chosenVisualInfo);
}
+#ifdef QT_DEBUG_X11_VISUAL_SELECTION
+ else
+ qDebug("EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId);
+#endif
+
if (visualId) {
#ifdef QT_DEBUG_X11_VISUAL_SELECTION
if (configAlphaSize > 0)
@@ -263,6 +268,11 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config)
# endif // QT_DEBUG_X11_VISUAL_SELECTION
return visualId;
}
+# ifdef QT_DEBUG_X11_VISUAL_SELECTION
+ else
+ qDebug("Failed to find an XVisual which matches EGL config %d using XRender", configId);
+# endif // QT_DEBUG_X11_VISUAL_SELECTION
+
#endif //!defined(QT_NO_XRENDER)
diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp
index b5d3103..b34d2c3 100644
--- a/src/gui/egl/qeglproperties.cpp
+++ b/src/gui/egl/qeglproperties.cpp
@@ -80,19 +80,19 @@ int QEglProperties::value(int name) const
case EGL_GREEN_SIZE: return 0;
case EGL_BLUE_SIZE: return 0;
case EGL_ALPHA_SIZE: return 0;
-#if defined(EGL_LUMINANCE_SIZE)
+#ifdef EGL_LUMINANCE_SIZE
case EGL_LUMINANCE_SIZE: return 0;
#endif
-#if defined(EGL_ALPHA_MASK_SIZE)
+#ifdef EGL_ALPHA_MASK_SIZE
case EGL_ALPHA_MASK_SIZE: return 0;
#endif
-#if defined(EGL_BIND_TO_TEXTURE_RGB)
+#ifdef EGL_BIND_TO_TEXTURE_RGB
case EGL_BIND_TO_TEXTURE_RGB: return EGL_DONT_CARE;
#endif
-#if defined(EGL_BIND_TO_TEXTURE_RGBA)
+#ifdef EGL_BIND_TO_TEXTURE_RGBA
case EGL_BIND_TO_TEXTURE_RGBA: return EGL_DONT_CARE;
#endif
-#if defined(EGL_COLOR_BUFFER_TYPE)
+#ifdef EGL_COLOR_BUFFER_TYPE
case EGL_COLOR_BUFFER_TYPE: return EGL_RGB_BUFFER;
#endif
case EGL_CONFIG_CAVEAT: return EGL_DONT_CARE;
@@ -103,7 +103,7 @@ int QEglProperties::value(int name) const
case EGL_NATIVE_VISUAL_TYPE: return EGL_DONT_CARE;
case EGL_MAX_SWAP_INTERVAL: return EGL_DONT_CARE;
case EGL_MIN_SWAP_INTERVAL: return EGL_DONT_CARE;
-#if defined(EGL_RENDERABLE_TYPE)
+#ifdef EGL_RENDERABLE_TYPE
case EGL_RENDERABLE_TYPE: return EGL_OPENGL_ES_BIT;
#endif
case EGL_SAMPLE_BUFFERS: return 0;
@@ -115,7 +115,7 @@ int QEglProperties::value(int name) const
case EGL_TRANSPARENT_GREEN_VALUE: return EGL_DONT_CARE;
case EGL_TRANSPARENT_BLUE_VALUE: return EGL_DONT_CARE;
-#if defined(EGL_VERSION_1_3)
+#ifdef EGL_VERSION_1_3
case EGL_CONFORMANT: return 0;
case EGL_MATCH_NATIVE_PIXMAP: return EGL_NONE;
#endif
@@ -215,15 +215,18 @@ void QEglProperties::setPixelFormat(QImage::Format pixelFormat)
void QEglProperties::setRenderableType(QEgl::API api)
{
-#if defined(EGL_RENDERABLE_TYPE)
+#ifdef EGL_RENDERABLE_TYPE
#if defined(QT_OPENGL_ES_2)
if (api == QEgl::OpenGL)
setValue(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT);
#elif defined(QT_OPENGL_ES)
if (api == QEgl::OpenGL)
setValue(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT);
+#elif defined(EGL_OPENGL_BIT)
+ if (api == QEgl::OpenGL)
+ setValue(EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT);
#endif
-#if defined(EGL_OPENVG_BIT)
+#ifdef EGL_OPENVG_BIT
if (api == QEgl::OpenVG)
setValue(EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT);
#endif
@@ -272,7 +275,7 @@ bool QEglProperties::reduceConfiguration()
return true;
if (removeValue(EGL_DEPTH_SIZE))
return true;
-#if defined(EGL_BIND_TO_TEXTURE_RGB)
+#ifdef EGL_BIND_TO_TEXTURE_RGB
if (removeValue(EGL_BIND_TO_TEXTURE_RGB))
return true;
#endif
@@ -327,6 +330,10 @@ QString QEglProperties::toString() const
if ((val & EGL_OPENGL_ES2_BIT) != 0)
types += QLatin1String("es2");
#endif
+#ifdef EGL_OPENGL_BIT
+ if ((val & EGL_OPENGL_BIT) != 0)
+ types += QLatin1String("gl");
+#endif
if ((val & EGL_OPENVG_BIT) != 0)
types += QLatin1String("vg");
if ((val & ~7) != 0)
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 9e0ec2e..9759b39 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1413,7 +1413,7 @@ QGraphicsItem::~QGraphicsItem()
QObjectPrivate *p = QObjectPrivate::get(o);
p->wasDeleted = true;
if (p->declarativeData) {
- QDeclarativeData::destroyed(p->declarativeData, o);
+ QAbstractDeclarativeData::destroyed(p->declarativeData, o);
p->declarativeData = 0;
}
}
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index 39ca75a..1869093 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -1853,14 +1853,14 @@ void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step)
{
horizontalScrollBar()->setSingleStep(step.width() + spacing());
horizontalScrollBar()->setPageStep(viewport()->width());
- horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width() - 2 * spacing());
+ horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width());
}
void QCommonListViewBase::updateVerticalScrollBar(const QSize &step)
{
verticalScrollBar()->setSingleStep(step.height() + spacing());
verticalScrollBar()->setPageStep(viewport()->height());
- verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height() - 2 * spacing());
+ verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height());
}
void QCommonListViewBase::scrollContentsBy(int dx, int dy, bool /*scrollElasticBand*/)
@@ -2276,6 +2276,7 @@ void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info)
const QPoint topLeft = initStaticLayout(info);
QStyleOptionViewItemV4 option = viewOptions();
option.rect = info.bounds;
+ option.rect.adjust(info.spacing, info.spacing, -info.spacing, -info.spacing);
// The static layout data structures are as follows:
// One vector contains the coordinate in the direction of layout flow.
@@ -2905,8 +2906,13 @@ void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info)
batchStartRow = info.last + 1;
bool done = (info.last >= rowCount() - 1);
// resize the content area
- if (done || !info.bounds.contains(item->rect()))
- contentsSize = QSize(rect.width(), rect.height());
+ if (done || !info.bounds.contains(item->rect())) {
+ contentsSize = rect.size();
+ if (info.flow == QListView::LeftToRight)
+ contentsSize.rheight() += info.spacing;
+ else
+ contentsSize.rwidth() += info.spacing;
+ }
// resize tree
int insertFrom = info.first;
if (done || info.first == 0) {
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 5f5e29f..62e99e9 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -186,9 +186,11 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T
gestureManager = 0;
gestureWidget = 0;
+#if defined(Q_WS_X11) || defined(Q_WS_WIN)
move_cursor = 0;
copy_cursor = 0;
link_cursor = 0;
+#endif
#if defined(Q_WS_WIN)
ignore_cursor = 0;
#endif
@@ -1043,9 +1045,11 @@ QApplication::~QApplication()
qt_clipboard = 0;
#endif
+#if defined(Q_WS_X11) || defined(Q_WS_WIN)
delete d->move_cursor; d->move_cursor = 0;
delete d->copy_cursor; d->copy_cursor = 0;
delete d->link_cursor; d->link_cursor = 0;
+#endif
#if defined(Q_WS_WIN)
delete d->ignore_cursor; d->ignore_cursor = 0;
#endif
@@ -5932,6 +5936,7 @@ static const char * const link_xpm[] = {
QPixmap QApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
{
+#if defined(Q_WS_X11) || defined(Q_WS_WIN)
if (!move_cursor) {
move_cursor = new QPixmap((const char **)move_xpm);
copy_cursor = new QPixmap((const char **)copy_xpm);
@@ -5955,6 +5960,7 @@ QPixmap QApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
default:
break;
}
+#endif
return QPixmap();
}
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 6d71cfe..01abe54 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -520,9 +520,11 @@ public:
QGestureManager *gestureManager;
QWidget *gestureWidget;
+#if defined(Q_WS_X11) || defined(Q_WS_WIN)
QPixmap *move_cursor;
QPixmap *copy_cursor;
QPixmap *link_cursor;
+#endif
#if defined(Q_WS_WIN)
QPixmap *ignore_cursor;
#endif
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 4fba8cf..10fa4b9 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -1478,7 +1478,7 @@ QWidget::~QWidget()
QObjectPrivate::clearGuards(this);
if (d->declarativeData) {
- QDeclarativeData::destroyed(d->declarativeData, this);
+ QAbstractDeclarativeData::destroyed(d->declarativeData, this);
d->declarativeData = 0; // don't activate again in ~QObject
}
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp
index e1156dc..9077eba 100644
--- a/src/gui/painting/qpaintbuffer.cpp
+++ b/src/gui/painting/qpaintbuffer.cpp
@@ -312,6 +312,7 @@ int QPaintBuffer::processCommands(QPainter *painter, int begin, int end) const
return depth;
}
+#ifndef QT_NO_DEBUG_STREAM
QString QPaintBuffer::commandDescription(int command) const
{
QString desc;
@@ -563,6 +564,7 @@ QString QPaintBuffer::commandDescription(int command) const
return desc;
}
+#endif
QRectF QPaintBuffer::boundingRect() const
{
diff --git a/src/gui/painting/qpaintbuffer_p.h b/src/gui/painting/qpaintbuffer_p.h
index 4576947..e4fe4bf 100644
--- a/src/gui/painting/qpaintbuffer_p.h
+++ b/src/gui/painting/qpaintbuffer_p.h
@@ -82,7 +82,9 @@ public:
int frameStartIndex(int frame) const;
int frameEndIndex(int frame) const;
int processCommands(QPainter *painter, int begin, int end) const;
+#ifndef QT_NO_DEBUG_STREAM
QString commandDescription(int command) const;
+#endif
void setBoundingRect(const QRectF &rect);
QRectF boundingRect() const;
diff --git a/src/gui/painting/qprintengine_mac.mm b/src/gui/painting/qprintengine_mac.mm
index 3d5d1d5..a548225 100644
--- a/src/gui/painting/qprintengine_mac.mm
+++ b/src/gui/painting/qprintengine_mac.mm
@@ -114,8 +114,11 @@ bool QMacPrintEngine::end()
Q_D(QMacPrintEngine);
if (d->state == QPrinter::Aborted)
return true; // I was just here a function call ago :)
- if(d->paintEngine->type() == QPaintEngine::CoreGraphics)
+ if(d->paintEngine->type() == QPaintEngine::CoreGraphics) {
+ // We dont need the paint engine to call restoreGraphicsState()
+ static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->stackCount = 0;
static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->hd = 0;
+ }
d->paintEngine->end();
if (d->state != QPrinter::Idle)
d->releaseSession();
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index a9def8e..449dffd 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1368,7 +1368,7 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransfor
if (!gs) {
// don't try to load huge fonts
- bool draw_as_outline = fontDef.pixelSize * qSqrt(matrix.det()) >= 64;
+ bool draw_as_outline = fontDef.pixelSize * qSqrt(qAbs(matrix.det())) >= 64;
if (draw_as_outline)
return 0;
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index 6c504a7..8027389 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -363,7 +363,7 @@ QSizeF QStaticText::size() const
}
QStaticTextPrivate::QStaticTextPrivate()
- : items(0), itemCount(0), glyphPool(0), positionPool(0), textWidth(-1.0),
+ : textWidth(-1.0), items(0), itemCount(0), glyphPool(0), positionPool(0),
needsRelayout(true), useBackendOptimizations(false), textFormat(Qt::AutoText)
{
}
@@ -584,11 +584,13 @@ void QStaticTextPrivate::paintText(const QPointF &topLeftPosition, QPainter *p)
textLayout.draw(p, topLeftPosition);
} else {
QTextDocument document;
+#ifndef QT_NO_CSSPARSER
QColor color = p->pen().color();
document.setDefaultStyleSheet(QString::fromLatin1("body { color: #%1%2%3 }")
.arg(QString::number(color.red(), 16), 2, QLatin1Char('0'))
.arg(QString::number(color.green(), 16), 2, QLatin1Char('0'))
.arg(QString::number(color.blue(), 16), 2, QLatin1Char('0')));
+#endif
document.setDefaultFont(font);
document.setDocumentMargin(0.0);
if (textWidth >= 0.0)
diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp
index d17a8a1..264cba2 100644
--- a/src/imports/particles/qdeclarativeparticles.cpp
+++ b/src/imports/particles/qdeclarativeparticles.cpp
@@ -41,6 +41,7 @@
#include "qdeclarativeparticles_p.h"
+#include <qdeclarativeinfo.h>
#include <private/qdeclarativeitem_p.h>
#include <private/qdeclarativepixmapcache_p.h>
@@ -730,7 +731,9 @@ void QDeclarativeParticles::imageLoaded()
{
Q_D(QDeclarativeParticles);
d->pendingPixmapCache = false;
- QDeclarativePixmapCache::get(d->url, &d->image);
+ QString errorString;
+ if (QDeclarativePixmapCache::get(d->url, &d->image, &errorString)==QDeclarativePixmapReply::Error)
+ qmlInfo(this) << errorString;
d->paintItem->updateSize();
d->paintItem->update();
}
@@ -754,12 +757,15 @@ void QDeclarativeParticles::setSource(const QUrl &name)
} else {
d->url = name;
Q_ASSERT(!name.isRelative());
- QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->image);
+ QString errorString;
+ QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->image, &errorString);
if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) {
QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url);
connect(reply, SIGNAL(finished()), this, SLOT(imageLoaded()));
d->pendingPixmapCache = true;
} else {
+ if (status == QDeclarativePixmapReply::Error)
+ qmlInfo(this) << errorString;
//### unify with imageLoaded
d->paintItem->updateSize();
d->paintItem->update();
diff --git a/src/multimedia/base/qgraphicsvideoitem.cpp b/src/multimedia/base/qgraphicsvideoitem.cpp
index f903eb7..c50d3ff 100644
--- a/src/multimedia/base/qgraphicsvideoitem.cpp
+++ b/src/multimedia/base/qgraphicsvideoitem.cpp
@@ -52,6 +52,8 @@
#include <QtOpenGL/qgl.h>
#endif
+#ifndef QT_NO_GRAPHICSVIEW
+
QT_BEGIN_NAMESPACE
@@ -434,4 +436,7 @@ bool QGraphicsVideoItem::sceneEvent(QEvent *event)
}
QT_END_NAMESPACE
+
+#endif // QT_NO_GRAPHICSVIEW
+
#include "moc_qgraphicsvideoitem.cpp"
diff --git a/src/multimedia/base/qgraphicsvideoitem.h b/src/multimedia/base/qgraphicsvideoitem.h
index e6f0d81..a20caf3 100644
--- a/src/multimedia/base/qgraphicsvideoitem.h
+++ b/src/multimedia/base/qgraphicsvideoitem.h
@@ -46,6 +46,7 @@
#include <QtMultimedia/qvideowidget.h>
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
QT_BEGIN_HEADER
@@ -109,4 +110,6 @@ QT_END_NAMESPACE
QT_END_HEADER
+#endif // QT_NO_GRAPHICSVIEW
+
#endif
diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp
index 9466cad..6b2e0f9 100644
--- a/src/multimedia/playback/qmediaplayer.cpp
+++ b/src/multimedia/playback/qmediaplayer.cpp
@@ -145,7 +145,9 @@ public:
QMediaPlaylist *playlist;
QPointer<QVideoWidget> videoWidget;
+#ifndef QT_NO_GRAPHICSVIEW
QPointer<QGraphicsVideoItem> videoItem;
+#endif
void _q_stateChanged(QMediaPlayer::State state);
void _q_mediaStatusChanged(QMediaPlayer::MediaStatus status);
@@ -618,26 +620,36 @@ void QMediaPlayer::bind(QObject *obj)
}
QVideoWidget *videoWidget = qobject_cast<QVideoWidget*>(obj);
+#ifndef QT_NO_GRAPHICSVIEW
QGraphicsVideoItem *videoItem = qobject_cast<QGraphicsVideoItem*>(obj);
+#endif
- if (videoWidget || videoItem) {
+ if (videoWidget
+#ifndef QT_NO_GRAPHICSVIEW
+ || videoItem
+#endif
+ ) {
//detach the current video output
if (d->videoWidget) {
d->videoWidget->setMediaObject(0);
d->videoWidget = 0;
}
+#ifndef QT_NO_GRAPHICSVIEW
if (d->videoItem) {
d->videoItem->setMediaObject(0);
d->videoItem = 0;
}
+#endif
}
if (videoWidget)
d->videoWidget = videoWidget;
+#ifndef QT_NO_GRAPHICSVIEW
if (videoItem)
d->videoItem = videoItem;
+#endif
}
}
@@ -651,8 +663,10 @@ void QMediaPlayer::unbind(QObject *obj)
if (obj == d->videoWidget) {
d->videoWidget = 0;
+#ifndef QT_NO_GRAPHICSVIEW
} else if (obj == d->videoItem) {
d->videoItem = 0;
+#endif
} else if (obj == d->playlist) {
disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)),
this, SLOT(_q_updateMedia(QMediaContent)));
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 0cc7430..c89d34f 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -516,6 +516,8 @@ void QGL2PaintEngineEx::beginNativePainting()
ensureActive();
d->transferMode(BrushDrawingMode);
+ d->nativePaintingActive = true;
+
QGLContext *ctx = d->ctx;
glUseProgram(0);
@@ -583,6 +585,12 @@ void QGL2PaintEngineEx::endNativePainting()
{
Q_D(QGL2PaintEngineEx);
d->needsSync = true;
+ d->nativePaintingActive = false;
+}
+
+bool QGL2PaintEngineEx::isNativePaintingActive() const {
+ Q_D(const QGL2PaintEngineEx);
+ return d->nativePaintingActive;
}
void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode)
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index 34d72d1..2ac2ca4 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -154,11 +154,11 @@ public:
void setRenderTextActive(bool);
+ bool isNativePaintingActive() const;
private:
Q_DISABLE_COPY(QGL2PaintEngineEx)
};
-
class QGL2PaintEngineExPrivate : public QPaintEngineExPrivate
{
Q_DECLARE_PUBLIC(QGL2PaintEngineEx)
@@ -178,6 +178,7 @@ public:
elementIndicesVBOId(0),
snapToPixelGrid(false),
addOffset(false),
+ nativePaintingActive(false),
inverseScale(1),
lastMaskTextureUsed(0)
{ }
@@ -280,6 +281,7 @@ public:
bool snapToPixelGrid;
bool addOffset; // When enabled, adds a 0.49,0.49 offset to matrix in updateMatrix
+ bool nativePaintingActive;
GLfloat pmvMatrix[3][3];
GLfloat inverseScale;
diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro
index 9473343..15795d2 100644
--- a/src/opengl/opengl.pro
+++ b/src/opengl/opengl.pro
@@ -77,7 +77,7 @@ SOURCES += qgl.cpp \
}
x11 {
- contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2) {
+ contains(QT_CONFIG, egl) {
SOURCES += qgl_x11egl.cpp \
qglpixelbuffer_egl.cpp \
qgl_egl.cpp \
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 5595e02..394bcbc 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -49,7 +49,7 @@
#include "private/qpixmap_x11_p.h"
#define INT32 dummy_INT32
#define INT8 dummy_INT8
-#if !defined(QT_OPENGL_ES)
+#ifdef QT_NO_EGL
# include <GL/glx.h>
#endif
#undef INT32
@@ -1582,7 +1582,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
# endif
vi = 0;
#endif
-#if defined(QT_OPENGL_ES)
+#ifndef QT_NO_EGL
ownsEglContext = false;
eglContext = 0;
eglSurface = EGL_NO_SURFACE;
@@ -2767,6 +2767,18 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text
return;
}
#else
+
+ if (d_ptr->active_engine &&
+ d_ptr->active_engine->type() == QPaintEngine::OpenGL2) {
+ QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine);
+ if (!eng->isNativePaintingActive()) {
+ QRectF src(0, 0, target.width(), target.height());
+ QSize size(target.width(), target.height());
+ eng->drawTexture(target, textureId, size, src);
+ return;
+ }
+ }
+
const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D);
GLint oldTexture;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture);
@@ -2817,6 +2829,7 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text
Q_UNUSED(textureTarget);
qWarning("drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) not supported with OpenGL ES, use rect version instead");
#else
+
const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D);
GLint oldTexture;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture);
@@ -2830,6 +2843,18 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text
glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth);
glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight);
+ if (d_ptr->active_engine &&
+ d_ptr->active_engine->type() == QPaintEngine::OpenGL2) {
+ QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine);
+ if (!eng->isNativePaintingActive()) {
+ QRectF dest(point, QSizeF(textureWidth, textureHeight));
+ QRectF src(0, 0, textureWidth, textureHeight);
+ QSize size(textureWidth, textureHeight);
+ eng->drawTexture(dest, textureId, size, src);
+ return;
+ }
+ }
+
qDrawTextureRect(QRectF(point, QSizeF(textureWidth, textureHeight)), textureWidth, textureHeight, textureTarget);
if (!wasEnabled)
@@ -3950,7 +3975,7 @@ bool QGLWidget::event(QEvent *e)
}
}
-#if defined(QT_OPENGL_ES)
+#ifndef QT_NO_EGL
// A re-parent is likely to destroy the X11 window and re-create it. It is important
// that we free the EGL surface _before_ the winID changes - otherwise we can leak.
if (e->type() == QEvent::ParentAboutToChange)
@@ -4909,7 +4934,7 @@ void QGLWidget::drawTexture(const QPointF &point, QMacCompatGLuint textureId, QM
}
#endif
-#if !defined(QT_OPENGL_ES_1)
+#ifndef QT_OPENGL_ES_1
Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_2_engine)
#endif
diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h
index 64f54a3..b1e2ede 100644
--- a/src/opengl/qgl.h
+++ b/src/opengl/qgl.h
@@ -376,7 +376,7 @@ protected:
#if defined(Q_WS_WIN)
virtual int choosePixelFormat(void* pfd, HDC pdc);
#endif
-#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
+#if defined(Q_WS_X11) && defined(QT_NO_EGL)
virtual void* tryVisual(const QGLFormat& f, int bufDepth = 1);
virtual void* chooseVisual();
#endif
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 1f28b08..ee580a6 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -64,7 +64,7 @@
#include "qcache.h"
#include "qglpaintdevice_p.h"
-#if defined(QT_OPENGL_ES) || defined(QT_OPENGL_ES_2)
+#ifndef QT_NO_EGL
#include <QtGui/private/qegl_p.h>
#endif
@@ -96,7 +96,7 @@ class QMacWindowChangeEvent;
class QWSGLWindowSurface;
#endif
-#if defined(QT_OPENGL_ES)
+#ifndef QT_NO_EGL
class QEglContext;
#endif
@@ -164,7 +164,7 @@ public:
#ifdef Q_WS_QWS
, wsurf(0)
#endif
-#if defined(Q_WS_X11) && defined(QT_OPENGL_ES)
+#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
, eglSurfaceWindowId(0)
#endif
{
@@ -194,7 +194,7 @@ public:
QGLContext *olcx;
#elif defined(Q_WS_X11)
QGLOverlayWidget *olw;
-#if defined(QT_OPENGL_ES)
+#ifndef QT_NO_EGL
void recreateEglSurface(bool force);
WId eglSurfaceWindowId;
#endif
@@ -344,7 +344,7 @@ public:
HBITMAP hbitmap;
HDC hbitmap_hdc;
#endif
-#if defined(QT_OPENGL_ES)
+#ifndef QT_NO_EGL
bool ownsEglContext;
QEglContext *eglContext;
EGLSurface eglSurface;
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index af0100b..6f210ce 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -378,8 +378,6 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
// eglCreateImageKHR & eglDestroyImageKHR without support for pixmaps, so we must
// check we have the EGLImage from pixmap functionality.
if (QEgl::hasExtension("EGL_KHR_image") || QEgl::hasExtension("EGL_KHR_image_pixmap")) {
- Q_ASSERT(eglCreateImageKHR);
- Q_ASSERT(eglDestroyImageKHR);
// Being able to create an EGLImage from a native pixmap is also pretty useless
// without the ability to bind that EGLImage as a texture, which is provided by
@@ -436,15 +434,13 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
// If the pixmap doesn't already have a valid surface, try binding it via EGLImage
// first, as going through EGLImage should be faster and better supported:
if (!textureIsBound && haveEglImageTFP) {
- Q_ASSERT(eglCreateImageKHR);
-
EGLImageKHR eglImage;
EGLint attribs[] = {
EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
EGL_NONE
};
- eglImage = eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
+ eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
(EGLClientBuffer)QEgl::nativePixmap(pixmap), attribs);
QGLContext* ctx = q;
@@ -457,7 +453,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons
// Once the egl image is bound, the texture becomes a new sibling image and we can safely
// destroy the EGLImage we created for the pixmap:
if (eglImage != EGL_NO_IMAGE_KHR)
- eglDestroyImageKHR(QEgl::display(), eglImage);
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
}
if (!textureIsBound && haveTFP) {
diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp
index eca9550..9a8b243 100644
--- a/src/opengl/qglpixelbuffer.cpp
+++ b/src/opengl/qglpixelbuffer.cpp
@@ -137,14 +137,14 @@ void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &form
#if defined(Q_WS_WIN) && !defined(QT_OPENGL_ES)
qctx->d_func()->dc = dc;
qctx->d_func()->rc = ctx;
-#elif (defined(Q_WS_X11) && !defined(QT_OPENGL_ES))
+#elif (defined(Q_WS_X11) && defined(QT_NO_EGL))
qctx->d_func()->cx = ctx;
qctx->d_func()->pbuf = (void *) pbuf;
qctx->d_func()->vi = 0;
#elif defined(Q_WS_MAC)
qctx->d_func()->cx = ctx;
qctx->d_func()->vi = 0;
-#elif defined(QT_OPENGL_ES)
+#elif !defined(QT_NO_EGL)
qctx->d_func()->eglContext = ctx;
qctx->d_func()->eglSurface = pbuf;
#endif
@@ -254,7 +254,7 @@ bool QGLPixelBuffer::doneCurrent()
\sa size()
*/
-#if (defined(Q_WS_X11) || defined(Q_WS_WIN)) && !defined(QT_OPENGL_ES)
+#if (defined(Q_WS_X11) || defined(Q_WS_WIN)) && defined(QT_NO_EGL)
GLuint QGLPixelBuffer::generateDynamicTexture() const
{
Q_D(const QGLPixelBuffer);
diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h
index c85dc5a..2a1f671 100644
--- a/src/opengl/qglpixelbuffer_p.h
+++ b/src/opengl/qglpixelbuffer_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_INCLUDE_NAMESPACE
#include <private/qgl_p.h>
#include <private/qglpaintdevice_p.h>
-#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
+#if defined(Q_WS_X11) && defined(QT_NO_EGL)
#include <GL/glx.h>
// The below is needed to for compilation on HPUX, due to broken GLX
@@ -127,10 +127,8 @@ struct GLXFBConfig {
#elif defined(Q_WS_WIN)
DECLARE_HANDLE(HPBUFFERARB);
-#elif defined(QT_OPENGL_ES_2)
-#include <EGL/egl.h>
-#elif defined(QT_OPENGL_ES)
-#include <GLES/egl.h>
+#elif !defined(QT_NO_EGL)
+#include <QtGui/private/qegl_p.h>
#endif
QT_END_INCLUDE_NAMESPACE
@@ -174,7 +172,7 @@ public:
QPointer<QGLWidget> req_shareWidget;
QSize req_size;
-#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
+#if defined(Q_WS_X11) && defined(QT_NO_EGL)
GLXPbuffer pbuf;
GLXContext ctx;
#elif defined(Q_WS_WIN)
@@ -195,7 +193,7 @@ public:
AGLContext share_ctx;
# endif
#endif
-#if defined(QT_OPENGL_ES)
+#ifndef QT_NO_EGL
EGLSurface pbuf;
QEglContext *ctx;
int textureFormat;
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index 5c4f41b..6258e0c 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -42,7 +42,9 @@
#include "qpixmapdata_vg_p.h"
#include "qpaintengine_vg_p.h"
#include <QtGui/private/qdrawhelper_p.h>
+#if !defined(QT_NO_EGL)
#include <QtGui/private/qegl_p.h>
+#endif
#include "qvg_p.h"
#include "qvgimagepool_p.h"
@@ -496,7 +498,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
}
const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
- EGLImageKHR eglImage = eglCreateImageKHR(QEgl::display(),
+ EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(),
EGL_NO_CONTEXT,
EGL_NATIVE_PIXMAP_KHR,
(EGLClientBuffer)sgImage,
@@ -511,7 +513,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
vgImage = vgCreateEGLImageTargetKHR(eglImage);
if (vgGetError() != VG_NO_ERROR) {
cleanup();
- eglDestroyImageKHR(QEgl::display(), eglImage);
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
driver.Close();
return;
}
@@ -525,7 +527,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
prevSize = QSize(w, h);
setSerialNumber(++qt_vg_pixmap_serial);
// release stuff
- eglDestroyImageKHR(QEgl::display(), eglImage);
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
driver.Close();
#endif
} else if (type == QPixmapData::FbsBitmap) {
@@ -611,7 +613,7 @@ void* QVGPixmapData::toNativeType(NativeType type)
}
const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
- EGLImageKHR eglImage = eglCreateImageKHR(QEgl::display(),
+ EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(),
EGL_NO_CONTEXT,
EGL_NATIVE_PIXMAP_KHR,
(EGLClientBuffer)sgImage,
@@ -624,7 +626,7 @@ void* QVGPixmapData::toNativeType(NativeType type)
VGImage dstVgImage = vgCreateEGLImageTargetKHR(eglImage);
if (vgGetError() != VG_NO_ERROR) {
- eglDestroyImageKHR(QEgl::display(), eglImage);
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
sgImage->Close();
driver.Close();
return 0;
@@ -640,7 +642,7 @@ void* QVGPixmapData::toNativeType(NativeType type)
}
// release stuff
vgDestroyImage(dstVgImage);
- eglDestroyImageKHR(QEgl::display(), eglImage);
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
driver.Close();
return reinterpret_cast<void*>(sgImage);
#endif
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 58c8d83..f732907 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -792,6 +792,7 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS
if ((args.size() > 2) && !args.at(2).isNumber())
return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): third argument (n) must be a number");
#ifndef QT_NO_QOBJECT
+ QScriptEnginePrivate *engine = scriptEngineFromExec(exec);
JSC::UString context;
// The first non-empty source URL in the call stack determines the translation context.
{
@@ -799,7 +800,7 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS
while (frame) {
if (frame->codeBlock() && frame->codeBlock()->source()
&& !frame->codeBlock()->source()->url().isEmpty()) {
- context = QFileInfo(frame->codeBlock()->source()->url()).baseName();
+ context = engine->translationContextFromUrl(frame->codeBlock()->source()->url());
break;
}
frame = frame->callerFrame()->removeHostCallFrameFlag();
@@ -921,6 +922,8 @@ QScriptEnginePrivate::QScriptEnginePrivate()
activeAgent = 0;
agentLineNumber = -1;
processEventsInterval = -1;
+ cachedTranslationUrl = JSC::UString();
+ cachedTranslationContext = JSC::UString();
JSC::setCurrentIdentifierTable(oldTable);
}
@@ -3307,6 +3310,15 @@ bool QScriptEnginePrivate::hasDemarshalFunction(int type) const
return info && (info->demarshal != 0);
}
+JSC::UString QScriptEnginePrivate::translationContextFromUrl(const JSC::UString &url)
+{
+ if (url != cachedTranslationUrl) {
+ cachedTranslationContext = QFileInfo(url).baseName();
+ cachedTranslationUrl = url;
+ }
+ return cachedTranslationContext;
+}
+
/*!
\internal
*/
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index 5c2007f..fd47208 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -63,6 +63,7 @@
#include "RegExpObject.h"
#include "SourceProvider.h"
#include "Structure.h"
+#include "UString.h"
#include "JSGlobalObject.h"
#include "JSValue.h"
@@ -73,7 +74,6 @@ namespace JSC
typedef ExecState CallFrame;
class JSCell;
class JSGlobalObject;
- class UString;
}
@@ -298,6 +298,8 @@ public:
static inline QScriptDeclarativeClass *declarativeClass(JSC::JSValue);
static inline QScriptDeclarativeClass::Object *declarativeObject(JSC::JSValue);
+ JSC::UString translationContextFromUrl(const JSC::UString &);
+
#ifndef QT_NO_QOBJECT
JSC::JSValue newQObject(QObject *object,
QScriptEngine::ValueOwnership ownership = QScriptEngine::QtOwnership,
@@ -367,6 +369,9 @@ public:
QScriptValue abortResult;
bool inEval;
+ JSC::UString cachedTranslationUrl;
+ JSC::UString cachedTranslationContext;
+
QSet<QString> importedExtensions;
QSet<QString> extensionsBeingImported;