diff options
Diffstat (limited to 'src')
44 files changed, 734 insertions, 196 deletions
diff --git a/src/declarative/extra/qmlbehavior.h b/src/declarative/extra/qmlbehavior.h index 994d85c..6508455 100644 --- a/src/declarative/extra/qmlbehavior.h +++ b/src/declarative/extra/qmlbehavior.h @@ -60,6 +60,7 @@ class Q_DECLARATIVE_EXPORT QmlBehavior : public QObject, public QmlPropertyValue Q_OBJECT Q_DECLARE_PRIVATE(QmlBehavior) + Q_INTERFACES(QmlPropertyValueInterceptor) Q_CLASSINFO("DefaultProperty", "animation") Q_PROPERTY(QmlAbstractAnimation *animation READ animation WRITE setAnimation) diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index 737aa63..8d4a8b8 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -181,7 +181,6 @@ void QFxAnchorsPrivate::centerInChanged() void QFxAnchorsPrivate::clearItem(QFxItem *item) { - Q_Q(QFxAnchors); if (!item) return; if (fill == item) diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 36c06a4..0b2a935 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -736,14 +736,13 @@ QFxGridView::~QFxGridView() \endcode */ -//XXX change to \qmlattachedsignal when it exists. /*! - \qmlattachedproperty void GridView::onAdd + \qmlattachedsignal GridView::onAdd() This attached handler is called immediately after an item is added to the view. */ /*! - \qmlattachedproperty void GridView::onRemove + \qmlattachedsignal GridView::onRemove() This attached handler is called immediately before an item is removed from the view. */ diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index b82a38d..9c668ac 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1198,6 +1198,19 @@ QFxKeysAttached *QFxKeysAttached::qmlAttachedProperties(QObject *obj) } /*! + \class QFxItem + \brief QFxItem is the most basic of all visual items in QML. + + All visual items in Qt Declarative inherit from QFxItem. Although QFxItem + has no visual appearance, it defines all the properties that are + common across visual items - such as the x and y position, the + width and height, \l {anchor-layout}{anchoring} and key handling. + + You can subclass QFxItem to provide your own custom visual item that inherits + these features. +*/ + +/*! \qmlclass Item QFxItem \brief The Item is the most basic of all visual items in QML. @@ -1364,7 +1377,7 @@ QFxItem::~QFxItem() \qml Image { source: "myimage.png" - transformOrigin: "Center" + transformOrigin: Item.Center scale: 4 } \endqml diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 23bf573..1a4a60c 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -926,14 +926,13 @@ QFxListView::~QFxListView() \endcode */ -//XXX change to \qmlattachedsignal when it exists. /*! - \qmlattachedproperty void ListView::onAdd + \qmlattachedsignal ListView::onAdd() This attached handler is called immediately after an item is added to the view. */ /*! - \qmlattachedproperty void ListView::onRemove + \qmlattachedsignal ListView::onRemove() This attached handler is called immediately before an item is removed from the view. */ diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 05fcc93..e0ef99f 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE /*! \class QFxPaintedItem \brief The QFxPaintedItem class is an abstract base class for QmlView items that want cached painting. - \ingroup group_coreitems + \internal This is a convenience class for implementing items that paint their contents using a QPainter. The contents of the item are cached behind the scenes. diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index a078da6..e1ac246 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -102,7 +102,7 @@ QHash<QObject*, QFxVisualItemModelAttached*> QFxVisualItemModelAttached::attache class QFxVisualItemModelPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QFxVisualItemModel); + Q_DECLARE_PUBLIC(QFxVisualItemModel) public: QFxVisualItemModelPrivate() : QObjectPrivate(), children(this) {} @@ -143,7 +143,7 @@ public: \code Item { VisualItemModel { - id: ItemModel + id: itemModel Rectangle { height: 30; width: 80; color: "red" } Rectangle { height: 30; width: 80; color: "green" } Rectangle { height: 30; width: 80; color: "blue" } @@ -151,7 +151,7 @@ public: ListView { anchors.fill: parent - model: ItemModel + model: itemModel } } \endcode @@ -416,8 +416,13 @@ int QFxVisualDataModelDataMetaObject::createProperty(const char *name, const cha if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) { model->ensureRoles(); - if (model->m_roleNames.contains(QString::fromUtf8(name))) + if (model->m_roleNames.contains(QString::fromUtf8(name))) { return QmlOpenMetaObject::createProperty(name, type); + } else if (model->m_listAccessor->type() == QmlListAccessor::QmlList) { + QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>(); + if (object && object->property(name).isValid()) + return QmlOpenMetaObject::createProperty(name, type); + } } else { model->ensureRoles(); QString sname = QString::fromUtf8(name); @@ -448,7 +453,7 @@ QFxVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &pro return model->m_listAccessor->at(data->m_index); } else { // return any property of a single object instance. - QObject *object = model->m_listAccessor->at(0).value<QObject*>(); + QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>(); return object->property(prop.name()); } } else if (model->m_listModelInterface) { diff --git a/src/declarative/qml/qbitfield_p.h b/src/declarative/qml/qbitfield_p.h index 70d5041..a8cc9dc 100644 --- a/src/declarative/qml/qbitfield_p.h +++ b/src/declarative/qml/qbitfield_p.h @@ -139,11 +139,11 @@ QBitField QBitField::united(const QBitField &o) rv.data = rv.ownData + 1; if (bits > o.bits) { ::memcpy((quint32 *)rv.data, data, length * sizeof(quint32)); - for (quint32 ii = 0; ii < (o.bits + 31) / 32; ++ii) + for (quint32 ii = 0; ii < (o.bits + quint32(31)) / 32; ++ii) ((quint32 *)rv.data)[ii] |= o.data[ii]; } else { ::memcpy((quint32 *)rv.data, o.data, length * sizeof(quint32)); - for (quint32 ii = 0; ii < (bits + 31) / 32; ++ii) + for (quint32 ii = 0; ii < (bits + quint32(31)) / 32; ++ii) ((quint32 *)rv.data)[ii] |= data[ii]; } return rv; diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index 12fb120..0894758 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -390,8 +390,6 @@ valid for components created directly from QML. */ QmlContext *QmlComponent::creationContext() const { - Q_D(const QmlComponent); - QmlDeclarativeData *ddata = QmlDeclarativeData::get(this); if (ddata) return ddata->context; diff --git a/src/declarative/qml/qmlcomponent_p.h b/src/declarative/qml/qmlcomponent_p.h index 7eedfbd..f90502f 100644 --- a/src/declarative/qml/qmlcomponent_p.h +++ b/src/declarative/qml/qmlcomponent_p.h @@ -76,7 +76,7 @@ class QmlComponentPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QmlComponent) public: - QmlComponentPrivate() : typeData(0), progress(0.), start(-1), count(-1), cc(0), completePending(false), componentAttacheds(0), engine(0) {} + QmlComponentPrivate() : typeData(0), progress(0.), start(-1), count(-1), cc(0), componentAttacheds(0), completePending(false), engine(0) {} QObject *create(QmlContext *context, const QBitField &); diff --git a/src/declarative/qml/qmlcompositetypedata_p.h b/src/declarative/qml/qmlcompositetypedata_p.h index fa11137..ffcef4c 100644 --- a/src/declarative/qml/qmlcompositetypedata_p.h +++ b/src/declarative/qml/qmlcompositetypedata_p.h @@ -69,7 +69,8 @@ public: Invalid, Complete, Error, - Waiting + Waiting, + WaitingResources }; Status status; enum ErrorType { diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index 3c76344..b335d31 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -352,18 +352,6 @@ void QmlCompositeTypeManager::setData(QmlCompositeTypeData *unit, if (!unit->data.parse(data, url)) { ok = false; unit->errors << unit->data.errors(); - } else { - foreach (QmlScriptParser::Import imp, unit->data.imports()) { - int dot = imp.version.indexOf(QLatin1Char('.')); - if (dot < 0) dot = imp.version.length(); - if (!QmlEnginePrivate::get(engine)->addToImport(&unit->imports, imp.uri, imp.qualifier, imp.version.left(dot).toInt(), imp.version.mid(dot+1).toInt(), imp.type)) { - QmlError error; - error.setUrl(url); - error.setDescription(tr("Import %1 unavailable").arg(imp.uri)); - unit->errors << error; - ok = false; - } - } } if (ok) { @@ -400,25 +388,11 @@ void QmlCompositeTypeManager::doComplete(QmlCompositeTypeResource *resource) void QmlCompositeTypeManager::checkComplete(QmlCompositeTypeData *unit) { - if (unit->status != QmlCompositeTypeData::Waiting) + if (unit->status != QmlCompositeTypeData::Waiting + && unit->status != QmlCompositeTypeData::WaitingResources) return; int waiting = 0; - for (int ii = 0; ii < unit->types.count(); ++ii) { - QmlCompositeTypeData *u = unit->types.at(ii).unit; - - if (!u) - continue; - - if (u->status == QmlCompositeTypeData::Error) { - unit->status = QmlCompositeTypeData::Error; - unit->errors = u->errors; - doComplete(unit); - return; - } else if (u->status == QmlCompositeTypeData::Waiting) { - waiting++; - } - } for (int ii = 0; ii < unit->resources.count(); ++ii) { QmlCompositeTypeResource *r = unit->resources.at(ii); @@ -429,28 +403,84 @@ void QmlCompositeTypeManager::checkComplete(QmlCompositeTypeData *unit) unit->status = QmlCompositeTypeData::Error; QmlError error; error.setUrl(unit->imports.baseUrl()); - error.setDescription(QLatin1String("Resource ") + r->url + - QLatin1String(" unavailable")); + error.setDescription(tr("Resource %1 unavailable").arg(r->url)); unit->errors << error; doComplete(unit); return; - } else if (r->status == QmlCompositeTypeData::Waiting) { + } else if (r->status == QmlCompositeTypeResource::Waiting) { waiting++; } } + if (waiting == 0) { + if (unit->status == QmlCompositeTypeData::WaitingResources) { + waiting += resolveTypes(unit); + if (unit->status != QmlCompositeTypeData::Error) { + if (waiting) + unit->status = QmlCompositeTypeData::Waiting; + } else { + return; + } + } else { + for (int ii = 0; ii < unit->types.count(); ++ii) { + QmlCompositeTypeData *u = unit->types.at(ii).unit; + + if (!u) + continue; + + if (u->status == QmlCompositeTypeData::Error) { + unit->status = QmlCompositeTypeData::Error; + unit->errors = u->errors; + doComplete(unit); + return; + } else if (u->status == QmlCompositeTypeData::Waiting) { + waiting++; + } + } + } + } + if (!waiting) { unit->status = QmlCompositeTypeData::Complete; doComplete(unit); } } -// ### Check ref counting in here -void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) +int QmlCompositeTypeManager::resolveTypes(QmlCompositeTypeData *unit) { - QList<QmlScriptParser::TypeReference*> types = unit->data.referencedTypes(); + // not called until all resources are loaded (they include import URLs) int waiting = 0; + + foreach (QmlScriptParser::Import imp, unit->data.imports()) { + int dot = imp.version.indexOf(QLatin1Char('.')); + if (dot < 0) dot = imp.version.length(); + QString qmldir; + if (imp.type == QmlScriptParser::Import::File && imp.qualifier.isEmpty()) { + QUrl importUrl = unit->imports.baseUrl().resolved(QUrl(imp.uri + QLatin1String("/qmldir"))); + for (int ii = 0; ii < unit->resources.count(); ++ii) { + if (unit->resources.at(ii)->url == importUrl) { + qmldir = QString::fromUtf8(unit->resources.at(ii)->data); + break; + } + } + } + if (!QmlEnginePrivate::get(engine)->addToImport( + &unit->imports, qmldir, imp.uri, imp.qualifier, imp.version.left(dot).toInt(), imp.version.mid(dot+1).toInt(), imp.type)) + { + QmlError error; + error.setUrl(unit->imports.baseUrl()); + error.setDescription(tr("Import %1 unavailable").arg(imp.uri)); + unit->status = QmlCompositeTypeData::Error; + unit->errorType = QmlCompositeTypeData::GeneralError; + unit->errors << error; + doComplete(unit); + return 0; + } + } + + QList<QmlScriptParser::TypeReference*> types = unit->data.referencedTypes(); + for (int ii = 0; ii < types.count(); ++ii) { QmlScriptParser::TypeReference *parserRef = types.at(ii); QByteArray typeName = parserRef->name.toUtf8(); @@ -478,7 +508,7 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) unit->errorType = QmlCompositeTypeData::GeneralError; unit->errors << error; doComplete(unit); - return; + return 0; } if (ref.type) { @@ -521,12 +551,13 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) if (urlUnit->errorType != QmlCompositeTypeData::AccessError) unit->errors << urlUnit->errors; doComplete(unit); - return; + return 0; case QmlCompositeTypeData::Complete: break; case QmlCompositeTypeData::Waiting: + case QmlCompositeTypeData::WaitingResources: unit->addref(); ref.unit->dependants << unit; waiting++; @@ -535,8 +566,26 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) unit->types << ref; } + return waiting; +} + +// ### Check ref counting in here +void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) +{ + int waiting = 0; QList<QUrl> resourceList = unit->data.referencedResources(); + + foreach (QmlScriptParser::Import imp, unit->data.imports()) { + if (imp.type == QmlScriptParser::Import::File && imp.qualifier.isEmpty()) { + QUrl importUrl = unit->imports.baseUrl().resolved(QUrl(imp.uri + QLatin1String("/qmldir"))); + if (toLocalFileOrQrc(importUrl).isEmpty()) { + // Import requires remote qmldir + resourceList.prepend(importUrl); + } + } + } + for (int ii = 0; ii < resourceList.count(); ++ii) { QUrl url = unit->imports.baseUrl().resolved(resourceList.at(ii)); @@ -558,8 +607,7 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) { QmlError error; error.setUrl(unit->imports.baseUrl()); - error.setDescription(QLatin1String("Resource ") + resource->url + - QLatin1String(" unavailable")); + error.setDescription(tr("Resource %1 unavailable").arg(resource->url)); unit->errors << error; } doComplete(unit); @@ -579,11 +627,18 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) unit->resources << resource; } - if (waiting) { - unit->status = QmlCompositeTypeData::Waiting; + if (waiting == 0) { + waiting += resolveTypes(unit); + if (unit->status != QmlCompositeTypeData::Error) { + if (!waiting) { + unit->status = QmlCompositeTypeData::Complete; + doComplete(unit); + } else { + unit->status = QmlCompositeTypeData::Waiting; + } + } } else { - unit->status = QmlCompositeTypeData::Complete; - doComplete(unit); + unit->status = QmlCompositeTypeData::WaitingResources; } } diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h index 843a9cf..b6f84db 100644 --- a/src/declarative/qml/qmlcompositetypemanager_p.h +++ b/src/declarative/qml/qmlcompositetypemanager_p.h @@ -101,6 +101,7 @@ private: void doComplete(QmlCompositeTypeData *); void doComplete(QmlCompositeTypeResource *); void checkComplete(QmlCompositeTypeData *); + int resolveTypes(QmlCompositeTypeData *); QmlEngine *engine; typedef QHash<QString, QmlCompositeTypeData *> Components; diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 31d4e1f..7ba3544 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -396,8 +396,7 @@ void QmlContext::setContextProperty(const QString &name, const QVariant &value) } } -void QmlContextPrivate::setIdProperty(const QString &name, int idx, - QObject *obj) +void QmlContextPrivate::setIdProperty(int idx, QObject *obj) { if (notifyIndex == -1) { Q_Q(QmlContext); @@ -487,7 +486,6 @@ void QmlContext::setBaseUrl(const QUrl &baseUrl) */ QUrl QmlContext::baseUrl() const { - Q_D(const QmlContext); const QmlContext* p = this; while (p && p->d_func()->url.isEmpty()) { p = p->parentContext(); diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h index 9a77e94..be7bf1d 100644 --- a/src/declarative/qml/qmlcontext_p.h +++ b/src/declarative/qml/qmlcontext_p.h @@ -129,7 +129,7 @@ public: }; ContextGuard *idValues; int idValueCount; - void setIdProperty(const QString &, int, QObject *); + void setIdProperty(int, QObject *); void setIdPropertyData(QmlIntegerCache *); void destroyed(ContextGuard *); diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index a0601d7..21eeb7c 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -1181,6 +1181,75 @@ QmlDomObject QmlDomValueValueSource::object() const return rv; } +/*! + \class QmlDomValueValueInterceptor + \internal + \brief The QmlDomValueValueInterceptor class represents a value interceptor assignment value. + + In QML, value interceptor are special write-intercepting types that may be + assigned to properties. Value interceptor inherit the QmlPropertyValueInterceptor + class. In the example below, the "x" property is being assigned the + Behavior value interceptor. + + \qml +Rectangle { + x: Behavior { NumberAnimation { duration: 500 } } +} + \endqml +*/ + +/*! + Construct an empty QmlDomValueValueInterceptor. +*/ +QmlDomValueValueInterceptor::QmlDomValueValueInterceptor(): + d(new QmlDomBasicValuePrivate) +{ +} + +/*! + Create a copy of \a other QmlDomValueValueInterceptor. +*/ +QmlDomValueValueInterceptor::QmlDomValueValueInterceptor(const QmlDomValueValueInterceptor &other) +: d(other.d) +{ +} + +/*! + Destroy the QmlDomValueValueInterceptor. +*/ +QmlDomValueValueInterceptor::~QmlDomValueValueInterceptor() +{ +} + +/*! + Assign \a other to this QmlDomValueValueInterceptor. +*/ +QmlDomValueValueInterceptor &QmlDomValueValueInterceptor::operator=(const QmlDomValueValueInterceptor &other) +{ + d = other.d; + return *this; +} + +/*! + Return the value interceptor object. + + In the example below, an object representing the Behavior will be + returned. + \qml +Rectangle { + x: Behavior { NumberAnimation { duration: 500 } } +} + \endqml +*/ +QmlDomObject QmlDomValueValueInterceptor::object() const +{ + QmlDomObject rv; + if (d->value) { + rv.d->object = d->value->object; + rv.d->object->addref(); + } + return rv; +} QmlDomValuePrivate::QmlDomValuePrivate() : property(0), value(0) @@ -1286,6 +1355,7 @@ QmlDomValue &QmlDomValue::operator=(const QmlDomValue &other) \value Literal The QmlDomValue is a literal value assignment. Use QmlDomValue::toLiteral() to access the type instance. \value PropertyBinding The QmlDomValue is a property binding. Use QmlDomValue::toBinding() to access the type instance. \value ValueSource The QmlDomValue is a property value source. Use QmlDomValue::toValueSource() to access the type instance. + \value ValueInterceptor The QmlDomValue is a property value interceptor. Use QmlDomValue::toValueInterceptor() to access the type instance. \value Object The QmlDomValue is an object assignment. Use QmlDomValue::toObject() to access the type instnace. \value List The QmlDomValue is a list of other values. Use QmlDomValue::toList() to access the type instance. */ @@ -1314,6 +1384,8 @@ QmlDomValue::Type QmlDomValue::type() const return PropertyBinding; case QmlParser::Value::ValueSource: return ValueSource; + case QmlParser::Value::ValueInterceptor: + return ValueInterceptor; case QmlParser::Value::CreatedObject: return Object; case QmlParser::Value::SignalObject: @@ -1359,6 +1431,14 @@ bool QmlDomValue::isValueSource() const } /*! + Returns true if this is a value interceptor value, otherwise false. +*/ +bool QmlDomValue::isValueInterceptor() const +{ + return type() == ValueInterceptor; +} + +/*! Returns true if this is an object value, otherwise false. */ bool QmlDomValue::isObject() const @@ -1423,6 +1503,22 @@ QmlDomValueValueSource QmlDomValue::toValueSource() const } /*! + Returns a QmlDomValueValueInterceptor if this value is a property value interceptor + type, otherwise returns an invalid QmlDomValueValueInterceptor. + + \sa QmlDomValue::type() +*/ +QmlDomValueValueInterceptor QmlDomValue::toValueInterceptor() const +{ + QmlDomValueValueInterceptor rv; + if (type() == ValueInterceptor) { + rv.d->value = d->value; + rv.d->value->addref(); + } + return rv; +} + +/*! Returns a QmlDomObject if this value is an object assignment type, otherwise returns an invalid QmlDomObject. diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h index f344bb2..5816780 100644 --- a/src/declarative/qml/qmldom.h +++ b/src/declarative/qml/qmldom.h @@ -175,6 +175,7 @@ private: friend class QmlDomComponent; friend class QmlDomValue; friend class QmlDomValueValueSource; + friend class QmlDomValueValueInterceptor; QSharedDataPointer<QmlDomObjectPrivate> d; }; @@ -225,6 +226,22 @@ private: QSharedDataPointer<QmlDomBasicValuePrivate> d; }; +class Q_DECLARATIVE_EXPORT QmlDomValueValueInterceptor +{ +public: + QmlDomValueValueInterceptor(); + QmlDomValueValueInterceptor(const QmlDomValueValueInterceptor &); + ~QmlDomValueValueInterceptor(); + QmlDomValueValueInterceptor &operator=(const QmlDomValueValueInterceptor &); + + QmlDomObject object() const; + +private: + friend class QmlDomValue; + QSharedDataPointer<QmlDomBasicValuePrivate> d; +}; + + class Q_DECLARATIVE_EXPORT QmlDomComponent : public QmlDomObject { public: @@ -244,6 +261,7 @@ public: Literal, PropertyBinding, ValueSource, + ValueInterceptor, Object, List }; @@ -259,12 +277,14 @@ public: bool isLiteral() const; bool isBinding() const; bool isValueSource() const; + bool isValueInterceptor() const; bool isObject() const; bool isList() const; QmlDomValueLiteral toLiteral() const; QmlDomValueBinding toBinding() const; QmlDomValueValueSource toValueSource() const; + QmlDomValueValueInterceptor toValueInterceptor() const; QmlDomObject toObject() const; QmlDomList toList() const; diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 4f3b2ba..df865f1 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -1036,6 +1036,7 @@ struct QmlEnginePrivate::ImportedNamespace { QList<int> minversions; QList<bool> isLibrary; QList<bool> isBuiltin; + QList<QString> qmlDirContent; bool find(const QByteArray& type, int *vmajor, int *vminor, QmlType** type_return, QUrl* url_return) const { @@ -1057,36 +1058,39 @@ struct QmlEnginePrivate::ImportedNamespace { } } else { QUrl url = QUrl(urls.at(i) + QLatin1String("/") + QString::fromUtf8(type) + QLatin1String(".qml")); - if (vmaj || vmin) { + QString qmldircontent = qmlDirContent.at(i); + if (vmaj || vmin || !qmldircontent.isEmpty()) { // Check version file - XXX cache these in QmlEngine! - QFile qmldir(toLocalFileOrQrc(QUrl(urls.at(i)+QLatin1String("/qmldir")))); - if (qmldir.open(QIODevice::ReadOnly)) { - do { - QByteArray lineba = qmldir.readLine(); - if (lineba.at(0) == '#') - continue; - int space1 = lineba.indexOf(' '); - if (qstrncmp(lineba,type,space1)==0) { - // eg. 1.2-5 - QString line = QString::fromUtf8(lineba); - space1 = line.indexOf(QLatin1Char(' ')); // refind in Unicode - int space2 = space1 >=0 ? line.indexOf(QLatin1Char(' '),space1+1) : -1; - QString mapversions = line.mid(space1+1,space2<0?line.length()-space1-2:space2-space1-1); - int dot = mapversions.indexOf(QLatin1Char('.')); - int dash = mapversions.indexOf(QLatin1Char('-')); - int mapvmaj = mapversions.left(dot).toInt(); - if (mapvmaj==vmaj) { - int mapvmin_from = (dash <= 0 ? mapversions.mid(dot+1) : mapversions.mid(dot+1,dash-dot-1)).toInt(); - int mapvmin_to = dash <= 0 ? mapvmin_from : mapversions.mid(dash+1).toInt(); - if (vmin >= mapvmin_from && vmin <= mapvmin_to) { - QStringRef mapfile = space2<0 ? QStringRef() : line.midRef(space2+1,line.length()-space2-2); - if (url_return) - *url_return = url.resolved(mapfile.toString()); - return true; - } + if (qmldircontent.isEmpty()) { + QFile qmldir(toLocalFileOrQrc(QUrl(urls.at(i)+QLatin1String("/qmldir")))); + if (qmldir.open(QIODevice::ReadOnly)) { + qmldircontent = QString::fromUtf8(qmldir.readAll()); + } + } + QString typespace = QString::fromUtf8(type)+QLatin1Char(' '); + QStringList lines = qmldircontent.split(QLatin1Char('\n')); + foreach (QString line, lines) { + if (line.isEmpty() || line.at(0) == QLatin1Char('#')) + continue; + if (line.startsWith(typespace)) { + // eg. 1.2-5 + int space1 = line.indexOf(QLatin1Char(' ')); + int space2 = space1 >=0 ? line.indexOf(QLatin1Char(' '),space1+1) : -1; + QString mapversions = line.mid(space1+1,space2<0?line.length()-space1-1:space2-space1-1); + int dot = mapversions.indexOf(QLatin1Char('.')); + int dash = mapversions.indexOf(QLatin1Char('-')); + int mapvmaj = mapversions.left(dot).toInt(); + if (mapvmaj==vmaj) { + int mapvmin_from = (dash <= 0 ? mapversions.mid(dot+1) : mapversions.mid(dot+1,dash-dot-1)).toInt(); + int mapvmin_to = dash <= 0 ? mapvmin_from : mapversions.mid(dash+1).toInt(); + if (vmin >= mapvmin_from && vmin <= mapvmin_to) { + QStringRef mapfile = space2<0 ? QStringRef() : line.midRef(space2+1,line.length()-space2-1); + if (url_return) + *url_return = url.resolved(mapfile.toString()); + return true; } } - } while (!qmldir.atEnd()); + } } } else { // XXX search non-files too! (eg. zip files, see QT-524) @@ -1115,7 +1119,7 @@ public: delete s; } - bool add(const QUrl& base, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType, const QStringList& importPath) + bool add(const QUrl& base, const QString& qmldircontent, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType, const QStringList& importPath) { QmlEnginePrivate::ImportedNamespace *s; if (prefix.isEmpty()) { @@ -1151,6 +1155,7 @@ public: s->minversions.prepend(vmin); s->isLibrary.prepend(importType == QmlScriptParser::Import::Library); s->isBuiltin.prepend(isbuiltin); + s->qmlDirContent.prepend(qmldircontent); return true; } @@ -1375,9 +1380,9 @@ QString QmlEngine::offlineStoragePath() const The base URL must already have been set with Import::setBaseUrl(). */ -bool QmlEnginePrivate::addToImport(Imports* imports, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType) const +bool QmlEnginePrivate::addToImport(Imports* imports, const QString& qmldircontent, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType) const { - bool ok = imports->d->add(imports->d->base,uri,prefix,vmaj,vmin,importType,fileImportPath); + bool ok = imports->d->add(imports->d->base,qmldircontent,uri,prefix,vmaj,vmin,importType,fileImportPath); if (qmlImportTrace()) qDebug() << "QmlEngine::addToImport(" << imports << uri << prefix << vmaj << "." << vmin << (importType==QmlScriptParser::Import::Library? "Library" : "File") << ": " << ok; return ok; diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 29621c0..69b121e 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -227,7 +227,7 @@ public: QmlImportsPrivate *d; }; - bool addToImport(Imports*, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType) const; + bool addToImport(Imports*, const QString& qmlDirContent,const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType) const; bool resolveType(const Imports&, const QByteArray& type, QmlType** type_return, QUrl* url_return, int *version_major, int *version_minor, diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp index 7178e6c..664ca3f 100644 --- a/src/declarative/qml/qmlenginedebug.cpp +++ b/src/declarative/qml/qmlenginedebug.cpp @@ -104,7 +104,7 @@ QmlEngineDebugServer::propertyData(QObject *obj, int propIdx) rv.type = QmlObjectProperty::Unknown; rv.valueTypeName = QString::fromUtf8(prop.typeName()); - rv.name = prop.name(); + rv.name = QString::fromUtf8(prop.name()); rv.hasNotifySignal = prop.hasNotifySignal(); QmlAbstractBinding *binding = QmlMetaProperty(obj, rv.name).binding(); if (binding) @@ -229,7 +229,7 @@ QmlEngineDebugServer::objectData(QObject *object) } rv.objectName = object->objectName(); - rv.objectType = object->metaObject()->className(); + rv.objectType = QString::fromUtf8(object->metaObject()->className()); rv.objectId = QmlDebugService::idForObject(object); rv.contextId = QmlDebugService::idForObject(qmlContext(object)); diff --git a/src/declarative/qml/qmlglobalscriptclass.cpp b/src/declarative/qml/qmlglobalscriptclass.cpp index 0ade5ee..91187c7 100644 --- a/src/declarative/qml/qmlglobalscriptclass.cpp +++ b/src/declarative/qml/qmlglobalscriptclass.cpp @@ -70,6 +70,10 @@ QmlGlobalScriptClass::queryProperty(const QScriptValue &object, const QScriptString &name, QueryFlags flags, uint *id) { + Q_UNUSED(object) + Q_UNUSED(name) + Q_UNUSED(flags) + Q_UNUSED(id) return HandlesReadAccess | HandlesWriteAccess; } @@ -78,6 +82,9 @@ QmlGlobalScriptClass::property(const QScriptValue &object, const QScriptString &name, uint id) { + Q_UNUSED(object) + Q_UNUSED(name) + Q_UNUSED(id) return engine()->undefinedValue(); } @@ -85,6 +92,8 @@ void QmlGlobalScriptClass::setProperty(QScriptValue &object, const QScriptString &name, uint id, const QScriptValue &value) { + Q_UNUSED(object) + Q_UNUSED(value) QString error = QLatin1String("Invalid write to global property \"") + name.toString() + QLatin1String("\""); engine()->currentContext()->throwError(error); diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index baef71f..edec988 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE /*! \class QmlMetaProperty \brief The QmlMetaProperty class abstracts accessing QML properties. + \internal */ /*! diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index a6edd3b..eac354d 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -134,7 +134,6 @@ QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name, return 0; QmlEnginePrivate *enginePrivate = QmlEnginePrivate::get(engine); - QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); QmlPropertyCache *cache = 0; QmlDeclarativeData *ddata = QmlDeclarativeData::get(obj); diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp index 3ede341..4c24cdd 100644 --- a/src/declarative/qml/qmlpropertycache.cpp +++ b/src/declarative/qml/qmlpropertycache.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE void QmlPropertyCache::Data::load(const QMetaProperty &p) { propType = p.userType(); - if (propType == QVariant::LastType) + if (QVariant::Type(propType) == QVariant::LastType) propType = qMetaTypeId<QVariant>(); coreIndex = p.propertyIndex(); notifyIndex = p.notifySignalIndex(); diff --git a/src/declarative/qml/qmlpropertyvalueinterceptor.cpp b/src/declarative/qml/qmlpropertyvalueinterceptor.cpp index 86905e6..9a9aba8 100644 --- a/src/declarative/qml/qmlpropertyvalueinterceptor.cpp +++ b/src/declarative/qml/qmlpropertyvalueinterceptor.cpp @@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE /*! \class QmlPropertyValueInterceptor \brief The QmlPropertyValueInterceptor class is inherited by property interceptors such as Behavior. + \internal This class intercepts property writes, allowing for custom handling. For example, Behavior uses this interception to provide a default animation for all changes to a property's value. diff --git a/src/declarative/qml/qmlpropertyvaluesource.cpp b/src/declarative/qml/qmlpropertyvaluesource.cpp index 529ce37..3317289 100644 --- a/src/declarative/qml/qmlpropertyvaluesource.cpp +++ b/src/declarative/qml/qmlpropertyvaluesource.cpp @@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE /*! \class QmlPropertyValueSource \brief The QmlPropertyValueSource class is inherited by property value sources such as animations and bindings. + \internal */ /*! diff --git a/src/declarative/qml/qmlrewrite.cpp b/src/declarative/qml/qmlrewrite.cpp index 43b2529..7cf8888 100644 --- a/src/declarative/qml/qmlrewrite.cpp +++ b/src/declarative/qml/qmlrewrite.cpp @@ -120,7 +120,7 @@ bool RewriteBinding::visit(AST::ExpressionStatement *ast) return false; } -bool RewriteBinding::visit(AST::DoWhileStatement *ast) +bool RewriteBinding::visit(AST::DoWhileStatement *) { ++_inLoop; return true; @@ -131,7 +131,7 @@ void RewriteBinding::endVisit(AST::DoWhileStatement *) --_inLoop; } -bool RewriteBinding::visit(AST::WhileStatement *ast) +bool RewriteBinding::visit(AST::WhileStatement *) { ++_inLoop; return true; @@ -142,7 +142,7 @@ void RewriteBinding::endVisit(AST::WhileStatement *) --_inLoop; } -bool RewriteBinding::visit(AST::ForStatement *ast) +bool RewriteBinding::visit(AST::ForStatement *) { ++_inLoop; return true; @@ -153,7 +153,7 @@ void RewriteBinding::endVisit(AST::ForStatement *) --_inLoop; } -bool RewriteBinding::visit(AST::LocalForStatement *ast) +bool RewriteBinding::visit(AST::LocalForStatement *) { ++_inLoop; return true; @@ -164,7 +164,7 @@ void RewriteBinding::endVisit(AST::LocalForStatement *) --_inLoop; } -bool RewriteBinding::visit(AST::ForEachStatement *ast) +bool RewriteBinding::visit(AST::ForEachStatement *) { ++_inLoop; return true; @@ -175,7 +175,7 @@ void RewriteBinding::endVisit(AST::ForEachStatement *) --_inLoop; } -bool RewriteBinding::visit(AST::LocalForEachStatement *ast) +bool RewriteBinding::visit(AST::LocalForEachStatement *) { ++_inLoop; return true; diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 802a78f..b986b60 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -225,7 +225,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, { QObject *target = stack.top(); // ctxt->setContextProperty(primitives.at(instr.setId.value), target); - cp->setIdProperty(primitives.at(instr.setId.value), instr.setId.index, target); + cp->setIdProperty(instr.setId.index, target); } break; diff --git a/src/declarative/qml/qmlvmemetaobject.cpp b/src/declarative/qml/qmlvmemetaobject.cpp index a627bf9..3e1d931 100644 --- a/src/declarative/qml/qmlvmemetaobject.cpp +++ b/src/declarative/qml/qmlvmemetaobject.cpp @@ -278,7 +278,7 @@ int QmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a) QMetaMethod m = method(_id); QList<QByteArray> names = m.parameterNames(); for (int ii = 0; ii < names.count(); ++ii) - newCtxt.setContextProperty(names.at(ii), *(QVariant *)a[ii + 1]); + newCtxt.setContextProperty(QString::fromLatin1(names.at(ii)), *(QVariant *)a[ii + 1]); QmlExpression expr(&newCtxt, code, object); expr.setTrackChange(false); expr.value(); diff --git a/src/declarative/qml/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp index 5117a00..eb7235b 100644 --- a/src/declarative/qml/qmlxmlhttprequest.cpp +++ b/src/declarative/qml/qmlxmlhttprequest.cpp @@ -1102,6 +1102,7 @@ void QmlXMLHttpRequest::abort() void QmlXMLHttpRequest::downloadProgress(qint64 bytes) { + Q_UNUSED(bytes) m_status = m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); m_statusText = @@ -1124,6 +1125,7 @@ void QmlXMLHttpRequest::downloadProgress(qint64 bytes) void QmlXMLHttpRequest::error(QNetworkReply::NetworkError error) { + Q_UNUSED(error) m_status = m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); m_statusText = @@ -1315,6 +1317,7 @@ static QScriptValue qmlxmlhttprequest_abort(QScriptContext *context, QScriptEngi static QScriptValue qmlxmlhttprequest_getResponseHeader(QScriptContext *context, QScriptEngine *engine) { + Q_UNUSED(engine) QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(context->thisObject().data().toQObject()); if (!request) return context->throwError(QScriptContext::ReferenceError, QLatin1String("Not an XMLHttpRequest object")); @@ -1333,6 +1336,7 @@ static QScriptValue qmlxmlhttprequest_getResponseHeader(QScriptContext *context, static QScriptValue qmlxmlhttprequest_getAllResponseHeaders(QScriptContext *context, QScriptEngine *engine) { + Q_UNUSED(engine) QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(context->thisObject().data().toQObject()); if (!request) return context->throwError(QScriptContext::ReferenceError, QLatin1String("Not an XMLHttpRequest object")); @@ -1350,6 +1354,7 @@ static QScriptValue qmlxmlhttprequest_getAllResponseHeaders(QScriptContext *cont // XMLHttpRequest properties static QScriptValue qmlxmlhttprequest_readyState(QScriptContext *context, QScriptEngine *engine) { + Q_UNUSED(engine) QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(context->thisObject().data().toQObject()); if (!request) return context->throwError(QScriptContext::ReferenceError, QLatin1String("Not an XMLHttpRequest object")); @@ -1358,6 +1363,7 @@ static QScriptValue qmlxmlhttprequest_readyState(QScriptContext *context, QScrip static QScriptValue qmlxmlhttprequest_status(QScriptContext *context, QScriptEngine *engine) { + Q_UNUSED(engine) QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(context->thisObject().data().toQObject()); if (!request) return context->throwError(QScriptContext::ReferenceError, QLatin1String("Not an XMLHttpRequest object")); @@ -1373,6 +1379,7 @@ static QScriptValue qmlxmlhttprequest_status(QScriptContext *context, QScriptEng static QScriptValue qmlxmlhttprequest_statusText(QScriptContext *context, QScriptEngine *engine) { + Q_UNUSED(engine) QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(context->thisObject().data().toQObject()); if (!request) return context->throwError(QScriptContext::ReferenceError, QLatin1String("Not an XMLHttpRequest object")); @@ -1388,6 +1395,7 @@ static QScriptValue qmlxmlhttprequest_statusText(QScriptContext *context, QScrip static QScriptValue qmlxmlhttprequest_responseText(QScriptContext *context, QScriptEngine *engine) { + Q_UNUSED(engine) QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(context->thisObject().data().toQObject()); if (!request) return context->throwError(QScriptContext::ReferenceError, QLatin1String("Not an XMLHttpRequest object")); @@ -1412,6 +1420,7 @@ static QScriptValue qmlxmlhttprequest_responseXML(QScriptContext *context, QScri static QScriptValue qmlxmlhttprequest_onreadystatechange(QScriptContext *context, QScriptEngine *engine) { + Q_UNUSED(engine) QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(context->thisObject().data().toQObject()); if (!request) return context->throwError(QScriptContext::ReferenceError, QLatin1String("Not an XMLHttpRequest object")); diff --git a/src/declarative/util/qmlanimation.h b/src/declarative/util/qmlanimation.h index 7898980..f4f9f38 100644 --- a/src/declarative/util/qmlanimation.h +++ b/src/declarative/util/qmlanimation.h @@ -65,6 +65,7 @@ class Q_AUTOTEST_EXPORT QmlAbstractAnimation : public QObject, public QmlPropert Q_DECLARE_PRIVATE(QmlAbstractAnimation) Q_INTERFACES(QmlParserStatus) + Q_INTERFACES(QmlPropertyValueSource) Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged()) diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp index 578646b..3e4cb64 100644 --- a/src/declarative/util/qmllistaccessor.cpp +++ b/src/declarative/util/qmllistaccessor.cpp @@ -73,7 +73,7 @@ void QmlListAccessor::setList(const QVariant &v, QmlEngine *engine) m_type = Invalid; } else if (d.type() == QVariant::StringList) { m_type = StringList; - } else if (d.type() == QMetaType::QVariantList) { + } else if (d.type() == (QVariant::Type)QMetaType::QVariantList) { m_type = VariantList; } else if (d.canConvert(QVariant::Int)) { m_type = Integer; @@ -136,7 +136,7 @@ QVariant QmlListAccessor::at(int idx) const QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); void *ptr[1]; li->at(idx, ptr); - return QmlMetaType::fromObject((QObject*)ptr[0], li->type()); //XXX only handles QObject-derived types + return QVariant::fromValue((QObject*)ptr[0]); } case QList: return QmlMetaType::listAt(d, idx); diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp index a112245..7e1f15c 100644 --- a/src/declarative/util/qmlpropertychanges.cpp +++ b/src/declarative/util/qmlpropertychanges.cpp @@ -93,7 +93,7 @@ public: QmlMetaProperty property; QmlExpression *expression; QmlExpression *reverseExpression; - QmlExpression *ownedExpression; + QGuard<QmlExpression> ownedExpression; virtual void execute() { ownedExpression = property.setSignalExpression(expression); @@ -272,7 +272,6 @@ QmlPropertyChanges::~QmlPropertyChanges() delete d->expressions.at(ii).second; for(int ii = 0; ii < d->signalReplacements.count(); ++ii) delete d->signalReplacements.at(ii); - } QObject *QmlPropertyChanges::object() const diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp index 14f8279..f91d0db 100644 --- a/src/declarative/util/qmlview.cpp +++ b/src/declarative/util/qmlview.cpp @@ -360,6 +360,8 @@ void QmlView::continueExecute() emit sceneResized(sz); resize(sz); } + updateGeometry(); + emit initialSize(d->initialSize); } else if (QWidget *wid = qobject_cast<QWidget *>(obj)) { window()->setAttribute(Qt::WA_OpaquePaintEvent, false); window()->setAttribute(Qt::WA_NoSystemBackground, false); @@ -374,6 +376,7 @@ void QmlView::continueExecute() } layout()->addWidget(wid); emit sceneResized(wid->size()); + emit initialSize(wid->size()); } } } @@ -382,6 +385,10 @@ void QmlView::continueExecute() This signal is emitted when the view is resized to \a size. */ +/*! \fn void QmlView::initialSize(QSize size) + This signal is emitted when the initial size of the root item is known. + */ + /*! \fn void QmlView::errors(const QList<QmlError> &errors) This signal is emitted when the qml loaded contains \a errors. */ @@ -425,7 +432,10 @@ void QmlView::timerEvent(QTimerEvent* e) automatically resize the root item. Regardless of this property, the sizeHint of the view - is the initial size of the root item. + is the initial size of the root item. Note though that + since QML may load dynamically, that size may change. + + \sa initialSize() */ void QmlView::setContentResizable(bool on) diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qmlview.h index faf2564..822827a 100644 --- a/src/declarative/util/qmlview.h +++ b/src/declarative/util/qmlview.h @@ -88,6 +88,7 @@ public: QSize sizeHint() const; Q_SIGNALS: + void initialSize(QSize size); void sceneResized(QSize size); void errors(const QList<QmlError> &error); diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index a0b5493..93dc196 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -547,9 +547,7 @@ void QGraphicsRotation::applyTo(QMatrix4x4 *matrix) const return; matrix->translate(d->origin); - QMatrix4x4 m; - m.rotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z()); - *matrix *= m.toTransform(1024.0f); // Project back to 2D. + matrix->projectedRotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z()); matrix->translate(-d->origin); } diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 00e8f15..5d624d8 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -58,6 +58,8 @@ QT_BEGIN_NAMESPACE \sa QVector3D, QGenericMatrix */ +static const qreal inv_dist_to_plane = 1. / 1024.; + /*! \fn QMatrix4x4::QMatrix4x4() @@ -1103,7 +1105,111 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z) return *this; } -#ifndef QT_NO_VECTOR4D +/*! + \internal +*/ +QMatrix4x4& QMatrix4x4::projectedRotate(qreal angle, qreal x, qreal y, qreal z) +{ + // Used by QGraphicsRotation::applyTo() to perform a rotation + // and projection back to 2D in a single step. + if (angle == 0.0f) + return *this; + QMatrix4x4 m(1); // The "1" says to not load the identity. + qreal c, s, ic; + if (angle == 90.0f || angle == -270.0f) { + s = 1.0f; + c = 0.0f; + } else if (angle == -90.0f || angle == 270.0f) { + s = -1.0f; + c = 0.0f; + } else if (angle == 180.0f || angle == -180.0f) { + s = 0.0f; + c = -1.0f; + } else { + qreal a = angle * M_PI / 180.0f; + c = qCos(a); + s = qSin(a); + } + bool quick = false; + if (x == 0.0f) { + if (y == 0.0f) { + if (z != 0.0f) { + // Rotate around the Z axis. + m.setIdentity(); + m.m[0][0] = c; + m.m[1][1] = c; + if (z < 0.0f) { + m.m[1][0] = s; + m.m[0][1] = -s; + } else { + m.m[1][0] = -s; + m.m[0][1] = s; + } + m.flagBits = General; + quick = true; + } + } else if (z == 0.0f) { + // Rotate around the Y axis. + m.setIdentity(); + m.m[0][0] = c; + m.m[2][2] = 1.0f; + if (y < 0.0f) { + m.m[0][3] = -s * inv_dist_to_plane; + } else { + m.m[0][3] = s * inv_dist_to_plane; + } + m.flagBits = General; + quick = true; + } + } else if (y == 0.0f && z == 0.0f) { + // Rotate around the X axis. + m.setIdentity(); + m.m[1][1] = c; + m.m[2][2] = 1.0f; + if (x < 0.0f) { + m.m[1][3] = s * inv_dist_to_plane; + } else { + m.m[1][3] = -s * inv_dist_to_plane; + } + m.flagBits = General; + quick = true; + } + if (!quick) { + qreal len = x * x + y * y + z * z; + if (!qFuzzyIsNull(len - 1.0f) && !qFuzzyIsNull(len)) { + len = qSqrt(len); + x /= len; + y /= len; + z /= len; + } + ic = 1.0f - c; + m.m[0][0] = x * x * ic + c; + m.m[1][0] = x * y * ic - z * s; + m.m[2][0] = 0.0f; + m.m[3][0] = 0.0f; + m.m[0][1] = y * x * ic + z * s; + m.m[1][1] = y * y * ic + c; + m.m[2][1] = 0.0f; + m.m[3][1] = 0.0f; + m.m[0][2] = 0.0f; + m.m[1][2] = 0.0f; + m.m[2][2] = 1.0f; + m.m[3][2] = 0.0f; + m.m[0][3] = (x * z * ic - y * s) * -inv_dist_to_plane; + m.m[1][3] = (y * z * ic + x * s) * -inv_dist_to_plane; + m.m[2][3] = 0.0f; + m.m[3][3] = 1.0f; + } + int flags = flagBits; + *this *= m; + if (flags != Identity) + flagBits = flags | Rotation; + else + flagBits = Rotation; + return *this; +} + +#ifndef QT_NO_QUATERNION /*! Multiples this matrix by another that rotates coordinates according @@ -1448,8 +1554,6 @@ QTransform QMatrix4x4::toTransform() const m[3][0], m[3][1], m[3][3]); } -static const qreal inv_dist_to_plane = 1. / 1024.; - /*! Returns the conventional Qt 2D transformation matrix that corresponds to this matrix. diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 42d992e..ba74b89 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -207,6 +207,10 @@ private: QMatrix4x4(int) { flagBits = General; } QMatrix4x4 orthonormalInverse() const; + + QMatrix4x4& projectedRotate(qreal angle, qreal x, qreal y, qreal z); + + friend class QGraphicsRotation; }; inline QMatrix4x4::QMatrix4x4 diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index b582e4a..f184811 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -1456,7 +1456,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD slant_value = FC_SLANT_OBLIQUE; FcPatternAddInteger(pattern, FC_SLANT, slant_value); - double size_value = qMax(1., request.pixelSize); + double size_value = qMax(qreal(1.), request.pixelSize); FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value); int stretch = request.stretch; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index bcc6bdb..a0810bc 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1263,6 +1263,7 @@ void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) QGLContext *ctx = d->ctx; + Q_UNUSED(ctx); if (opaque) { d->prepareForDraw(opaque); diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 34114e4..d028522 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -42,6 +42,7 @@ #include "qglshaderprogram.h" #include "qglextensions_p.h" #include "qgl_p.h" +#include <QtCore/private/qobject_p.h> #include <QtCore/qdebug.h> #include <QtCore/qfile.h> #include <QtCore/qvarlengtharray.h> @@ -200,8 +201,9 @@ QT_BEGIN_NAMESPACE #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 #endif -class QGLShaderPrivate +class QGLShaderPrivate : public QObjectPrivate { + Q_DECLARE_PUBLIC(QGLShader) public: QGLShaderPrivate(const QGLContext *context, QGLShader::ShaderType type) : shaderGuard(context) @@ -211,6 +213,7 @@ public: , hasPartialSource(false) { } + ~QGLShaderPrivate(); QGLSharedResourceGuard shaderGuard; QGLShader::ShaderType shaderType; @@ -227,6 +230,14 @@ public: #define ctx shaderGuard.context() +QGLShaderPrivate::~QGLShaderPrivate() +{ + if (shaderGuard.id()) { + QGLShareContextScope scope(shaderGuard.context()); + glDeleteShader(shaderGuard.id()); + } +} + bool QGLShaderPrivate::create() { const QGLContext *context = shaderGuard.context(); @@ -306,9 +317,9 @@ void QGLShaderPrivate::deleteShader() \sa compile(), compileFile() */ QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderPrivate(QGLContext::currentContext(), type), parent) { - d = new QGLShaderPrivate(QGLContext::currentContext(), type); + Q_D(QGLShader); d->create(); } @@ -323,13 +334,21 @@ QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent) */ QGLShader::QGLShader (const QString& fileName, QGLShader::ShaderType type, QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderPrivate(QGLContext::currentContext(), type), parent) { - d = new QGLShaderPrivate(QGLContext::currentContext(), type); + Q_D(QGLShader); if (d->create() && !compileFile(fileName)) d->deleteShader(); } +static inline const QGLContext *contextOrCurrent(const QGLContext *context) +{ + if (context) + return context; + else + return QGLContext::currentContext(); +} + /*! Constructs a new QGLShader object of the specified \a type and attaches it to \a parent. If shader programs are not supported, @@ -343,14 +362,12 @@ QGLShader::QGLShader \sa compile(), compileFile() */ QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderPrivate(contextOrCurrent(context), type), parent) { - if (!context) - context = QGLContext::currentContext(); - d = new QGLShaderPrivate(context, type); + Q_D(QGLShader); #ifndef QT_NO_DEBUG if (context && !QGLContext::areSharing(context, QGLContext::currentContext())) { - qWarning("QGLShader::QGLShader: \'context\' must be the currect context or sharing with it."); + qWarning("QGLShader::QGLShader: \'context\' must be the current context or sharing with it."); return; } #endif @@ -368,14 +385,12 @@ QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObj */ QGLShader::QGLShader (const QString& fileName, QGLShader::ShaderType type, const QGLContext *context, QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderPrivate(contextOrCurrent(context), type), parent) { - if (!context) - context = QGLContext::currentContext(); - d = new QGLShaderPrivate(context, type); + Q_D(QGLShader); #ifndef QT_NO_DEBUG if (context && !QGLContext::areSharing(context, QGLContext::currentContext())) { - qWarning("QGLShader::QGLShader: \'context\' must be currect context or sharing with it."); + qWarning("QGLShader::QGLShader: \'context\' must be current context or sharing with it."); return; } #endif @@ -390,11 +405,6 @@ QGLShader::QGLShader */ QGLShader::~QGLShader() { - if (d->shaderGuard.id()) { - QGLShareContextScope scope(d->shaderGuard.context()); - glDeleteShader(d->shaderGuard.id()); - } - delete d; } /*! @@ -402,6 +412,7 @@ QGLShader::~QGLShader() */ QGLShader::ShaderType QGLShader::shaderType() const { + Q_D(const QGLShader); return d->shaderType; } @@ -439,12 +450,14 @@ static const char redefineHighp[] = */ bool QGLShader::compile(const char *source) { + Q_D(QGLShader); if (d->isPartial) { d->partialSource = QByteArray(source); d->hasPartialSource = true; return d->compile(this); } else if (d->shaderGuard.id()) { - QVarLengthArray<const char *> src; + QVarLengthArray<const char *, 4> src; + QVarLengthArray<GLint, 4> srclen; int headerLen = 0; while (source && source[headerLen] == '#') { // Skip #version and #extension directives at the start of @@ -459,21 +472,24 @@ bool QGLShader::compile(const char *source) if (source[headerLen] == '\n') ++headerLen; } - QByteArray header; if (headerLen > 0) { - header = QByteArray(source, headerLen); - src.append(header.constData()); + src.append(source); + srclen.append(GLint(headerLen)); } #ifdef QGL_DEFINE_QUALIFIERS src.append(qualifierDefines); + srclen.append(GLint(sizeof(qualifierDefines) - 1)); #endif #ifdef QGL_REDEFINE_HIGHP if (d->shaderType == FragmentShader || - d->shaderType == PartialFragmentShader) + d->shaderType == PartialFragmentShader) { src.append(redefineHighp); + srclen.append(GLint(sizeof(redefineHighp) - 1)); + } #endif src.append(source + headerLen); - glShaderSource(d->shaderGuard.id(), src.size(), src.data(), 0); + srclen.append(GLint(qstrlen(source + headerLen))); + glShaderSource(d->shaderGuard.id(), src.size(), src.data(), srclen.data()); return d->compile(this); } else { return false; @@ -481,6 +497,61 @@ bool QGLShader::compile(const char *source) } /*! + \internal +*/ +bool QGLShader::compile + (const QList<QGLShader *>& shaders, QGLShader::ShaderType type) +{ + Q_D(QGLShader); + QVarLengthArray<const char *, 16> src; + QVarLengthArray<GLint, 16> srclen; + if (!d->shaderGuard.id()) + return false; + foreach (QGLShader *shader, shaders) { + if (shader->shaderType() != type) + continue; + const char *source = shader->d_func()->partialSource.constData(); + int headerLen = 0; + if (src.isEmpty()) { + // First shader: handle the #version and #extension tags + // plus the precision qualifiers. + while (source && source[headerLen] == '#') { + // Skip #version and #extension directives at the start of + // the shader code. We need to insert the qualifierDefines + // and redefineHighp just after them. + if (qstrncmp(source + headerLen, "#version", 8) != 0 && + qstrncmp(source + headerLen, "#extension", 10) != 0) { + break; + } + while (source[headerLen] != '\0' && source[headerLen] != '\n') + ++headerLen; + if (source[headerLen] == '\n') + ++headerLen; + } + if (headerLen > 0) { + src.append(source); + srclen.append(GLint(headerLen)); + } +#ifdef QGL_DEFINE_QUALIFIERS + src.append(qualifierDefines); + srclen.append(GLint(sizeof(qualifierDefines) - 1)); +#endif +#ifdef QGL_REDEFINE_HIGHP + if (d->shaderType == FragmentShader || + d->shaderType == PartialFragmentShader) { + src.append(redefineHighp); + srclen.append(GLint(sizeof(redefineHighp) - 1)); + } +#endif + } + src.append(source + headerLen); + srclen.append(GLint(qstrlen(source + headerLen))); + } + glShaderSource(d->shaderGuard.id(), src.size(), src.data(), srclen.data()); + return d->compile(this); +} + +/*! \overload Sets the \a source code for this shader and compiles it. @@ -555,6 +626,7 @@ bool QGLShader::compileFile(const QString& fileName) */ bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length) { + Q_D(QGLShader); #if !defined(QT_OPENGL_ES_2) if (!glShaderBinary) return false; @@ -588,21 +660,22 @@ bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length) bool QGLShader::setShaderBinary (QGLShader& otherShader, GLenum format, const void *binary, int length) { + Q_D(QGLShader); #if !defined(QT_OPENGL_ES_2) if (!glShaderBinary) return false; #endif if (d->isPartial || !d->shaderGuard.id()) return false; - if (otherShader.d->isPartial || !otherShader.d->shaderGuard.id()) + if (otherShader.d_func()->isPartial || !otherShader.d_func()->shaderGuard.id()) return false; glGetError(); // Clear error state. GLuint shaders[2]; shaders[0] = d->shaderGuard.id(); - shaders[1] = otherShader.d->shaderGuard.id(); + shaders[1] = otherShader.d_func()->shaderGuard.id(); glShaderBinary(2, shaders, format, binary, length); d->compiled = (glGetError() == GL_NO_ERROR); - otherShader.d->compiled = d->compiled; + otherShader.d_func()->compiled = d->compiled; return d->compiled; } @@ -634,6 +707,7 @@ QList<GLenum> QGLShader::shaderBinaryFormats() */ QByteArray QGLShader::sourceCode() const { + Q_D(const QGLShader); if (d->isPartial) return d->partialSource; GLuint shader = d->shaderGuard.id(); @@ -658,6 +732,7 @@ QByteArray QGLShader::sourceCode() const */ bool QGLShader::isCompiled() const { + Q_D(const QGLShader); return d->compiled; } @@ -668,6 +743,7 @@ bool QGLShader::isCompiled() const */ QString QGLShader::log() const { + Q_D(const QGLShader); return d->log; } @@ -682,14 +758,16 @@ QString QGLShader::log() const */ GLuint QGLShader::shaderId() const { + Q_D(const QGLShader); return d->shaderGuard.id(); } #undef ctx #define ctx programGuard.context() -class QGLShaderProgramPrivate +class QGLShaderProgramPrivate : public QObjectPrivate { + Q_DECLARE_PUBLIC(QGLShaderProgram) public: QGLShaderProgramPrivate(const QGLContext *context) : programGuard(context) @@ -713,6 +791,8 @@ public: QList<QGLShader *> anonShaders; QGLShader *vertexShader; QGLShader *fragmentShader; + + bool hasShader(QGLShader::ShaderType type) const; }; QGLShaderProgramPrivate::~QGLShaderProgramPrivate() @@ -723,6 +803,15 @@ QGLShaderProgramPrivate::~QGLShaderProgramPrivate() } } +bool QGLShaderProgramPrivate::hasShader(QGLShader::ShaderType type) const +{ + foreach (QGLShader *shader, shaders) { + if (shader->shaderType() == type) + return true; + } + return false; +} + #undef ctx #define ctx d->programGuard.context() @@ -735,9 +824,8 @@ QGLShaderProgramPrivate::~QGLShaderProgramPrivate() \sa addShader() */ QGLShaderProgram::QGLShaderProgram(QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderProgramPrivate(QGLContext::currentContext()), parent) { - d = new QGLShaderProgramPrivate(QGLContext::currentContext()); } /*! @@ -749,9 +837,8 @@ QGLShaderProgram::QGLShaderProgram(QObject *parent) \sa addShader() */ QGLShaderProgram::QGLShaderProgram(const QGLContext *context, QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderProgramPrivate(context), parent) { - d = new QGLShaderProgramPrivate(context); } /*! @@ -759,11 +846,11 @@ QGLShaderProgram::QGLShaderProgram(const QGLContext *context, QObject *parent) */ QGLShaderProgram::~QGLShaderProgram() { - delete d; } bool QGLShaderProgram::init() { + Q_D(QGLShaderProgram); if (d->programGuard.id() || d->inited) return true; d->inited = true; @@ -801,22 +888,23 @@ bool QGLShaderProgram::init() */ bool QGLShaderProgram::addShader(QGLShader *shader) { + Q_D(QGLShaderProgram); if (!init()) return false; if (d->shaders.contains(shader)) return true; // Already added to this shader program. if (d->programGuard.id() && shader) { - if (!QGLContext::areSharing(shader->d->shaderGuard.context(), + if (!QGLContext::areSharing(shader->d_func()->shaderGuard.context(), d->programGuard.context())) { qWarning("QGLShaderProgram::addShader: Program and shader are not associated with same context."); return false; } - if (!shader->d->compiled) + if (!shader->d_func()->compiled) return false; - if (!shader->d->isPartial) { - if (!shader->d->shaderGuard.id()) + if (!shader->d_func()->isPartial) { + if (!shader->d_func()->shaderGuard.id()) return false; - glAttachShader(d->programGuard.id(), shader->d->shaderGuard.id()); + glAttachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); } else { d->hasPartialShaders = true; } @@ -843,6 +931,7 @@ bool QGLShaderProgram::addShader(QGLShader *shader) */ bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const char *source) { + Q_D(QGLShaderProgram); if (!init()) return false; QGLShader *shader = new QGLShader(type, this); @@ -908,6 +997,7 @@ bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const QString& sour bool QGLShaderProgram::addShaderFromFile (QGLShader::ShaderType type, const QString& fileName) { + Q_D(QGLShaderProgram); if (!init()) return false; QGLShader *shader = new QGLShader(type, this); @@ -927,9 +1017,10 @@ bool QGLShaderProgram::addShaderFromFile */ void QGLShaderProgram::removeShader(QGLShader *shader) { - if (d->programGuard.id() && shader && shader->d->shaderGuard.id()) { + Q_D(QGLShaderProgram); + if (d->programGuard.id() && shader && shader->d_func()->shaderGuard.id()) { QGLShareContextScope scope(d->programGuard.context()); - glDetachShader(d->programGuard.id(), shader->d->shaderGuard.id()); + glDetachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); } d->linked = false; // Program needs to be relinked. if (shader) { @@ -947,6 +1038,7 @@ void QGLShaderProgram::removeShader(QGLShader *shader) */ QList<QGLShader *> QGLShaderProgram::shaders() const { + Q_D(const QGLShaderProgram); return d->shaders; } @@ -960,10 +1052,11 @@ QList<QGLShader *> QGLShaderProgram::shaders() const */ void QGLShaderProgram::removeAllShaders() { + Q_D(QGLShaderProgram); d->removingShaders = true; foreach (QGLShader *shader, d->shaders) { - if (d->programGuard.id() && shader && shader->d->shaderGuard.id()) - glDetachShader(d->programGuard.id(), shader->d->shaderGuard.id()); + if (d->programGuard.id() && shader && shader->d_func()->shaderGuard.id()) + glDetachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); } foreach (QGLShader *shader, d->anonShaders) { // Delete shader objects that were created anonymously. @@ -1009,6 +1102,7 @@ void QGLShaderProgram::removeAllShaders() QByteArray QGLShaderProgram::programBinary(int *format) const { #if defined(QT_OPENGL_ES_2) + Q_D(const QGLShaderProgram); if (!isLinked()) return QByteArray(); @@ -1044,6 +1138,7 @@ bool QGLShaderProgram::setProgramBinary(int format, const QByteArray& binary) { #if defined(QT_OPENGL_ES_2) // Load the binary and check that it was linked correctly. + Q_D(QGLShaderProgram); GLuint program = d->programGuard.id(); if (!program) return false; @@ -1113,52 +1208,47 @@ QList<int> QGLShaderProgram::programBinaryFormats() */ bool QGLShaderProgram::link() { + Q_D(QGLShaderProgram); GLuint program = d->programGuard.id(); if (!program) return false; if (d->hasPartialShaders) { // Compile the partial vertex and fragment shaders. - QByteArray vertexSource; - QByteArray fragmentSource; - foreach (QGLShader *shader, d->shaders) { - if (shader->shaderType() == QGLShader::PartialVertexShader) - vertexSource += shader->sourceCode(); - else if (shader->shaderType() == QGLShader::PartialFragmentShader) - fragmentSource += shader->sourceCode(); - } - if (vertexSource.isEmpty()) { - if (d->vertexShader) { - glDetachShader(program, d->vertexShader->d->shaderGuard.id()); - delete d->vertexShader; - d->vertexShader = 0; - } - } else { + if (d->hasShader(QGLShader::PartialVertexShader)) { if (!d->vertexShader) { d->vertexShader = new QGLShader(QGLShader::VertexShader, this); } - if (!d->vertexShader->compile(vertexSource)) { + if (!d->vertexShader->compile + (d->shaders, QGLShader::PartialVertexShader)) { d->log = d->vertexShader->log(); return false; } - glAttachShader(program, d->vertexShader->d->shaderGuard.id()); - } - if (fragmentSource.isEmpty()) { - if (d->fragmentShader) { - glDetachShader(program, d->fragmentShader->d->shaderGuard.id()); - delete d->fragmentShader; - d->fragmentShader = 0; - } + glAttachShader(program, d->vertexShader->d_func()->shaderGuard.id()); } else { + if (d->vertexShader) { + glDetachShader(program, d->vertexShader->d_func()->shaderGuard.id()); + delete d->vertexShader; + d->vertexShader = 0; + } + } + if (d->hasShader(QGLShader::PartialFragmentShader)) { if (!d->fragmentShader) { d->fragmentShader = new QGLShader(QGLShader::FragmentShader, this); } - if (!d->fragmentShader->compile(fragmentSource)) { + if (!d->fragmentShader->compile + (d->shaders, QGLShader::PartialFragmentShader)) { d->log = d->fragmentShader->log(); return false; } - glAttachShader(program, d->fragmentShader->d->shaderGuard.id()); + glAttachShader(program, d->fragmentShader->d_func()->shaderGuard.id()); + } else { + if (d->fragmentShader) { + glDetachShader(program, d->fragmentShader->d_func()->shaderGuard.id()); + delete d->fragmentShader; + d->fragmentShader = 0; + } } } glLinkProgram(program); @@ -1190,6 +1280,7 @@ bool QGLShaderProgram::link() */ bool QGLShaderProgram::isLinked() const { + Q_D(const QGLShaderProgram); return d->linked; } @@ -1201,6 +1292,7 @@ bool QGLShaderProgram::isLinked() const */ QString QGLShaderProgram::log() const { + Q_D(const QGLShaderProgram); return d->log; } @@ -1214,6 +1306,7 @@ QString QGLShaderProgram::log() const */ bool QGLShaderProgram::enable() { + Q_D(QGLShaderProgram); GLuint program = d->programGuard.id(); if (!program) return false; @@ -1252,6 +1345,7 @@ void QGLShaderProgram::disable() */ GLuint QGLShaderProgram::programId() const { + Q_D(const QGLShaderProgram); return d->programGuard.id(); } @@ -1265,6 +1359,7 @@ GLuint QGLShaderProgram::programId() const */ void QGLShaderProgram::bindAttributeLocation(const char *name, int location) { + Q_D(QGLShaderProgram); if (!d->linked) { glBindAttribLocation(d->programGuard.id(), location, name); } else { @@ -1312,6 +1407,7 @@ void QGLShaderProgram::bindAttributeLocation(const QString& name, int location) */ int QGLShaderProgram::attributeLocation(const char *name) const { + Q_D(const QGLShaderProgram); if (d->linked) { return glGetAttribLocation(d->programGuard.id(), name); } else { @@ -1356,6 +1452,8 @@ int QGLShaderProgram::attributeLocation(const QString& name) const */ void QGLShaderProgram::setAttributeValue(int location, GLfloat value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glVertexAttrib1fv(location, &value); } @@ -1380,6 +1478,8 @@ void QGLShaderProgram::setAttributeValue(const char *name, GLfloat value) */ void QGLShaderProgram::setAttributeValue(int location, GLfloat x, GLfloat y) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[2] = {x, y}; glVertexAttrib2fv(location, values); @@ -1408,6 +1508,8 @@ void QGLShaderProgram::setAttributeValue(const char *name, GLfloat x, GLfloat y) void QGLShaderProgram::setAttributeValue (int location, GLfloat x, GLfloat y, GLfloat z) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[3] = {x, y, z}; glVertexAttrib3fv(location, values); @@ -1437,6 +1539,8 @@ void QGLShaderProgram::setAttributeValue void QGLShaderProgram::setAttributeValue (int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {x, y, z, w}; glVertexAttrib4fv(location, values); @@ -1464,6 +1568,8 @@ void QGLShaderProgram::setAttributeValue */ void QGLShaderProgram::setAttributeValue(int location, const QVector2D& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glVertexAttrib2fv(location, reinterpret_cast<const GLfloat *>(&value)); } @@ -1487,6 +1593,8 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector2D& valu */ void QGLShaderProgram::setAttributeValue(int location, const QVector3D& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glVertexAttrib3fv(location, reinterpret_cast<const GLfloat *>(&value)); } @@ -1510,6 +1618,8 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector3D& valu */ void QGLShaderProgram::setAttributeValue(int location, const QVector4D& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glVertexAttrib4fv(location, reinterpret_cast<const GLfloat *>(&value)); } @@ -1533,6 +1643,8 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector4D& valu */ void QGLShaderProgram::setAttributeValue(int location, const QColor& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {value.redF(), value.greenF(), value.blueF(), value.alphaF()}; glVertexAttrib4fv(location, values); @@ -1563,6 +1675,8 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QColor& value) void QGLShaderProgram::setAttributeValue (int location, const GLfloat *values, int columns, int rows) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (rows < 1 || rows > 4) { qWarning() << "QGLShaderProgram::setAttributeValue: rows" << rows << "not supported"; return; @@ -1612,6 +1726,8 @@ void QGLShaderProgram::setAttributeValue void QGLShaderProgram::setAttributeArray (int location, const GLfloat *values, int size, int stride) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { glVertexAttribPointer(location, size, GL_FLOAT, GL_FALSE, stride, values); @@ -1630,6 +1746,8 @@ void QGLShaderProgram::setAttributeArray void QGLShaderProgram::setAttributeArray (int location, const QVector2D *values, int stride) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { glVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, stride, values); @@ -1648,6 +1766,8 @@ void QGLShaderProgram::setAttributeArray void QGLShaderProgram::setAttributeArray (int location, const QVector3D *values, int stride) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { glVertexAttribPointer(location, 3, GL_FLOAT, GL_FALSE, stride, values); @@ -1666,6 +1786,8 @@ void QGLShaderProgram::setAttributeArray void QGLShaderProgram::setAttributeArray (int location, const QVector4D *values, int stride) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, stride, values); @@ -1746,6 +1868,8 @@ void QGLShaderProgram::setAttributeArray */ void QGLShaderProgram::disableAttributeArray(int location) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glDisableVertexAttribArray(location); } @@ -1772,6 +1896,8 @@ void QGLShaderProgram::disableAttributeArray(const char *name) */ int QGLShaderProgram::uniformLocation(const char *name) const { + Q_D(const QGLShaderProgram); + Q_UNUSED(d); if (d->linked) { return glGetUniformLocation(d->programGuard.id(), name); } else { @@ -1816,6 +1942,8 @@ int QGLShaderProgram::uniformLocation(const QString& name) const */ void QGLShaderProgram::setUniformValue(int location, GLfloat value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform1fv(location, 1, &value); } @@ -1840,6 +1968,8 @@ void QGLShaderProgram::setUniformValue(const char *name, GLfloat value) */ void QGLShaderProgram::setUniformValue(int location, GLint value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform1i(location, value); } @@ -1865,6 +1995,8 @@ void QGLShaderProgram::setUniformValue(const char *name, GLint value) */ void QGLShaderProgram::setUniformValue(int location, GLuint value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform1i(location, value); } @@ -1890,6 +2022,8 @@ void QGLShaderProgram::setUniformValue(const char *name, GLuint value) */ void QGLShaderProgram::setUniformValue(int location, GLfloat x, GLfloat y) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[2] = {x, y}; glUniform2fv(location, 1, values); @@ -1918,6 +2052,8 @@ void QGLShaderProgram::setUniformValue(const char *name, GLfloat x, GLfloat y) void QGLShaderProgram::setUniformValue (int location, GLfloat x, GLfloat y, GLfloat z) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[3] = {x, y, z}; glUniform3fv(location, 1, values); @@ -1947,6 +2083,8 @@ void QGLShaderProgram::setUniformValue void QGLShaderProgram::setUniformValue (int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {x, y, z, w}; glUniform4fv(location, 1, values); @@ -1974,6 +2112,8 @@ void QGLShaderProgram::setUniformValue */ void QGLShaderProgram::setUniformValue(int location, const QVector2D& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform2fv(location, 1, reinterpret_cast<const GLfloat *>(&value)); } @@ -1998,6 +2138,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector2D& value) */ void QGLShaderProgram::setUniformValue(int location, const QVector3D& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform3fv(location, 1, reinterpret_cast<const GLfloat *>(&value)); } @@ -2022,6 +2164,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector3D& value) */ void QGLShaderProgram::setUniformValue(int location, const QVector4D& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform4fv(location, 1, reinterpret_cast<const GLfloat *>(&value)); } @@ -2047,6 +2191,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector4D& value) */ void QGLShaderProgram::setUniformValue(int location, const QColor& color) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {color.redF(), color.greenF(), color.blueF(), color.alphaF()}; glUniform4fv(location, 1, values); @@ -2074,6 +2220,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QColor& color) */ void QGLShaderProgram::setUniformValue(int location, const QPoint& point) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {point.x(), point.y()}; glUniform2fv(location, 1, values); @@ -2101,6 +2249,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QPoint& point) */ void QGLShaderProgram::setUniformValue(int location, const QPointF& point) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {point.x(), point.y()}; glUniform2fv(location, 1, values); @@ -2128,6 +2278,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QPointF& point) */ void QGLShaderProgram::setUniformValue(int location, const QSize& size) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {size.width(), size.width()}; glUniform2fv(location, 1, values); @@ -2155,6 +2307,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QSize& size) */ void QGLShaderProgram::setUniformValue(int location, const QSizeF& size) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {size.width(), size.height()}; glUniform2fv(location, 1, values); @@ -2234,6 +2388,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QSizeF& size) */ void QGLShaderProgram::setUniformValue(int location, const QMatrix2x2& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformMatrix(glUniformMatrix2fv, location, value, 2, 2); } @@ -2258,6 +2414,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x2& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix2x3& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrix (glUniformMatrix2x3fv, glUniform3fv, location, value, 2, 3); } @@ -2283,6 +2441,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x3& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix2x4& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrix (glUniformMatrix2x4fv, glUniform4fv, location, value, 2, 4); } @@ -2308,6 +2468,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x4& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix3x2& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrix (glUniformMatrix3x2fv, glUniform2fv, location, value, 3, 2); } @@ -2333,6 +2495,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x2& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix3x3& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformMatrix(glUniformMatrix3fv, location, value, 3, 3); } @@ -2357,6 +2521,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x3& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix3x4& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrix (glUniformMatrix3x4fv, glUniform4fv, location, value, 3, 4); } @@ -2382,6 +2548,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x4& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix4x2& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrix (glUniformMatrix4x2fv, glUniform2fv, location, value, 4, 2); } @@ -2407,6 +2575,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x2& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix4x3& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrix (glUniformMatrix4x3fv, glUniform3fv, location, value, 4, 3); } @@ -2432,6 +2602,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x3& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix4x4& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformMatrix(glUniformMatrix4fv, location, value, 4, 4); } @@ -2459,6 +2631,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x4& value */ void QGLShaderProgram::setUniformValue(int location, const GLfloat value[4][4]) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniformMatrix4fv(location, 1, GL_FALSE, value[0]); } @@ -2486,6 +2660,8 @@ void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[4][ */ void QGLShaderProgram::setUniformValue(int location, const QTransform& value) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat mat[3][3] = { {value.m11(), value.m12(), value.m13()}, @@ -2519,6 +2695,8 @@ void QGLShaderProgram::setUniformValue */ void QGLShaderProgram::setUniformValueArray(int location, const GLint *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform1iv(location, count, values); } @@ -2546,6 +2724,8 @@ void QGLShaderProgram::setUniformValueArray */ void QGLShaderProgram::setUniformValueArray(int location, const GLuint *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform1iv(location, count, reinterpret_cast<const GLint *>(values)); } @@ -2574,6 +2754,8 @@ void QGLShaderProgram::setUniformValueArray */ void QGLShaderProgram::setUniformValueArray(int location, const GLfloat *values, int count, int size) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { if (size == 1) glUniform1fv(location, count, values); @@ -2611,6 +2793,8 @@ void QGLShaderProgram::setUniformValueArray */ void QGLShaderProgram::setUniformValueArray(int location, const QVector2D *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform2fv(location, count, reinterpret_cast<const GLfloat *>(values)); } @@ -2636,6 +2820,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector2D *v */ void QGLShaderProgram::setUniformValueArray(int location, const QVector3D *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform3fv(location, count, reinterpret_cast<const GLfloat *>(values)); } @@ -2661,6 +2847,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector3D *v */ void QGLShaderProgram::setUniformValueArray(int location, const QVector4D *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform4fv(location, count, reinterpret_cast<const GLfloat *>(values)); } @@ -2747,6 +2935,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector4D *v */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x2 *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformMatrixArray (glUniformMatrix2fv, location, values, count, QMatrix2x2, 2, 2); } @@ -2772,6 +2962,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x2 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x3 *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrixArray (glUniformMatrix2x3fv, glUniform3fv, location, values, count, QMatrix2x3, 2, 3); @@ -2798,6 +2990,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x3 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x4 *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrixArray (glUniformMatrix2x4fv, glUniform4fv, location, values, count, QMatrix2x4, 2, 4); @@ -2824,6 +3018,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x4 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x2 *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrixArray (glUniformMatrix3x2fv, glUniform2fv, location, values, count, QMatrix3x2, 3, 2); @@ -2850,6 +3046,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x2 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x3 *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformMatrixArray (glUniformMatrix3fv, location, values, count, QMatrix3x3, 3, 3); } @@ -2875,6 +3073,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x3 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x4 *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrixArray (glUniformMatrix3x4fv, glUniform4fv, location, values, count, QMatrix3x4, 3, 4); @@ -2901,6 +3101,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x4 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x2 *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrixArray (glUniformMatrix4x2fv, glUniform2fv, location, values, count, QMatrix4x2, 4, 2); @@ -2927,6 +3129,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x2 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x3 *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrixArray (glUniformMatrix4x3fv, glUniform3fv, location, values, count, QMatrix4x3, 4, 3); @@ -2953,6 +3157,8 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x3 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x4 *values, int count) { + Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformMatrixArray (glUniformMatrix4fv, location, values, count, QMatrix4x4, 4, 4); } @@ -2998,6 +3204,7 @@ bool QGLShaderProgram::hasShaderPrograms(const QGLContext *context) */ void QGLShaderProgram::shaderDestroyed() { + Q_D(QGLShaderProgram); QGLShader *shader = qobject_cast<QGLShader *>(sender()); if (shader && !d->removingShaders) removeShader(shader); diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h index f2d70fa..d8b9a0c 100644 --- a/src/opengl/qglshaderprogram.h +++ b/src/opengl/qglshaderprogram.h @@ -101,11 +101,12 @@ public: GLuint shaderId() const; private: - QGLShaderPrivate *d; - friend class QGLShaderProgram; Q_DISABLE_COPY(QGLShader) + Q_DECLARE_PRIVATE(QGLShader) + + bool compile(const QList<QGLShader *>& shaders, QGLShader::ShaderType type); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGLShader::ShaderType) @@ -286,9 +287,8 @@ private Q_SLOTS: void shaderDestroyed(); private: - QGLShaderProgramPrivate *d; - Q_DISABLE_COPY(QGLShaderProgram) + Q_DECLARE_PRIVATE(QGLShaderProgram) bool init(); }; diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 4547416..42e1c1e 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -364,7 +364,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) if (ctxpriv->eglSurface == EGL_NO_SURFACE) { qWarning() << "hijackWindow() could not create EGL surface"; } - qDebug("QGLWindowSurface - using EGLConfig %d", ctxpriv->eglContext->config()); + qDebug("QGLWindowSurface - using EGLConfig %d", reinterpret_cast<int>(ctxpriv->eglContext->config())); #endif widgetPrivate->extraData()->glContext = ctx; diff --git a/src/opengl/qwindowsurface_x11gl.cpp b/src/opengl/qwindowsurface_x11gl.cpp index 8ef239d..db81be2 100644 --- a/src/opengl/qwindowsurface_x11gl.cpp +++ b/src/opengl/qwindowsurface_x11gl.cpp @@ -124,6 +124,9 @@ void QX11GLWindowSurface::setGeometry(const QRect &rect) bool QX11GLWindowSurface::scroll(const QRegion &area, int dx, int dy) { + Q_UNUSED(area); + Q_UNUSED(dx); + Q_UNUSED(dy); return false; } |