summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-03-15 01:17:34 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-03-15 01:17:34 (GMT)
commitb55f19b956958dc94e8f35e7dc215a70445759a4 (patch)
tree5b1f7e020b5d501369c944933613d467e1df8473
parentacec7123d383840d66fa63e84d0d0a0b72820496 (diff)
parent6a536a8750bf0c82d9bfd557c09827bf61e9986a (diff)
downloadQt-b55f19b956958dc94e8f35e7dc215a70445759a4.zip
Qt-b55f19b956958dc94e8f35e7dc215a70445759a4.tar.gz
Qt-b55f19b956958dc94e8f35e7dc215a70445759a4.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp8
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp12
-rw-r--r--src/gui/egl/qegl.cpp2
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.cpp16
-rw-r--r--src/gui/itemviews/qtreeview.cpp100
-rw-r--r--src/gui/itemviews/qtreeview_p.h5
-rw-r--r--src/gui/painting/qcups.cpp3
-rw-r--r--src/gui/text/qfontdatabase_qws.cpp7
-rw-r--r--src/gui/text/qfontengine_qpf.cpp14
-rw-r--r--src/imports/multimedia/multimedia.pro4
-rw-r--r--src/imports/particles/particles.pro7
-rw-r--r--src/imports/webkit/webkit.pro4
-rw-r--r--src/imports/widgets/widgets.pro7
-rw-r--r--src/multimedia/base/qpaintervideosurface.cpp14
-rw-r--r--src/opengl/qgl.cpp65
-rw-r--r--src/opengl/qgl_egl.cpp9
-rw-r--r--src/opengl/qgl_p.h4
-rw-r--r--src/opengl/qgl_qws.cpp1
-rw-r--r--src/opengl/qgl_wince.cpp1
-rw-r--r--src/opengl/qgl_x11egl.cpp1
-rw-r--r--src/opengl/qpixmapdata_x11gl_egl.cpp3
-rw-r--r--src/openvg/qpaintengine_vg.cpp9
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp52
-rw-r--r--src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h1
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro5
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp35
27 files changed, 228 insertions, 165 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index 61a32e5..6dbcd16 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -155,6 +155,8 @@ void QDeclarativeLoaderPrivate::initResize()
QDeclarativeLoader::QDeclarativeLoader(QDeclarativeItem *parent)
: QDeclarativeItem(*(new QDeclarativeLoaderPrivate), parent)
{
+ Q_D(QDeclarativeItem);
+ d->flags |= QGraphicsItem::ItemIsFocusScope;
}
/*!
@@ -348,7 +350,7 @@ QDeclarativeLoader::Status QDeclarativeLoader::status() const
/*!
\qmlproperty real Loader::progress
-This property holds the progress of loading QML data from the network, from
+This property holds the progress of loading QML data from the network, from
0.0 (nothing loaded) to 1.0 (finished). Most QML files are quite small, so
this value will rapidly change from 0 to 1.
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
index 8ca5406..c55c22f 100644
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -494,15 +494,13 @@ QDeclarativeProperty &QDeclarativeProperty::operator=(const QDeclarativeProperty
*/
bool QDeclarativeProperty::isWritable() const
{
- QDeclarativeProperty::PropertyTypeCategory category = propertyTypeCategory();
-
if (!d->object)
return false;
- if (category == List)
+ if (d->core.flags & QDeclarativePropertyCache::Data::IsQList) //list
return true;
- else if (type() & SignalProperty)
+ else if (d->core.flags & QDeclarativePropertyCache::Data::IsFunction) //signal handler
return false;
- else if (d->core.isValid() && d->object)
+ else if (d->core.isValid()) //normal property
return d->core.flags & QDeclarativePropertyCache::Data::IsWritable;
else
return false;
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index d77ef40..009e07f 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -1877,13 +1877,17 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t)
}
/*!
- \qmlproperty QEasingCurve PropertyAnimation::easing
- \brief the easing curve used for the transition.
+ \qmlproperty enum PropertyAnimation::easing.type
+ \qmlproperty real PropertyAnimation::easing.amplitude
+ \qmlproperty real PropertyAnimation::easing.overshoot
+ \qmlproperty real PropertyAnimation::easing.period
+ \brief the easing curve used for the animation.
- For the easing you can specify the following parameters: type, amplitude, period and overshoot.
+ To specify an easing curve you need to specify at least the type. For some curves you can also specify
+ amplitude, period and/or overshoot (more details provided after the table).
\qml
- PropertyAnimation { properties: "y"; easing.type: "InOutElastc"; easing.amplitude: 2.0; easing.period: 1.5 }
+ PropertyAnimation { properties: "y"; easing.type: "InOutElastic"; easing.amplitude: 2.0; easing.period: 1.5 }
\endqml
Available types are:
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp
index 6e0331f..b870523 100644
--- a/src/gui/egl/qegl.cpp
+++ b/src/gui/egl/qegl.cpp
@@ -60,7 +60,7 @@ static QEglContext * volatile currentVGContext = 0;
QEglContext::QEglContext()
: apiType(QEgl::OpenGL)
, ctx(EGL_NO_CONTEXT)
- , cfg(0)
+ , cfg(QEGL_NO_CONFIG)
, currentSurface(EGL_NO_SURFACE)
, current(false)
, ownsContext(true)
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp
index c63a07b..5c7d24b7 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/gui/itemviews/qsortfilterproxymodel.cpp
@@ -122,10 +122,10 @@ public:
QVector<int> proxy_rows;
QVector<int> proxy_columns;
QVector<QModelIndex> mapped_children;
- QMap<QModelIndex, Mapping *>::const_iterator map_iter;
+ QHash<QModelIndex, Mapping *>::const_iterator map_iter;
};
- mutable QMap<QModelIndex, Mapping*> source_index_mapping;
+ mutable QHash<QModelIndex, Mapping*> source_index_mapping;
int source_sort_column;
int proxy_sort_column;
@@ -142,7 +142,7 @@ public:
QModelIndexPairList saved_persistent_indexes;
- QMap<QModelIndex, Mapping *>::const_iterator create_mapping(
+ QHash<QModelIndex, Mapping *>::const_iterator create_mapping(
const QModelIndex &source_parent) const;
QModelIndex proxy_to_source(const QModelIndex &proxyIndex) const;
QModelIndex source_to_proxy(const QModelIndex &sourceIndex) const;
@@ -150,14 +150,14 @@ public:
void remove_from_mapping(const QModelIndex &source_parent);
- inline QMap<QModelIndex, Mapping *>::const_iterator index_to_iterator(
+ inline QHash<QModelIndex, Mapping *>::const_iterator index_to_iterator(
const QModelIndex &proxy_index) const
{
Q_ASSERT(proxy_index.isValid());
Q_ASSERT(proxy_index.model() == q_func());
const void *p = proxy_index.internalPointer();
Q_ASSERT(p);
- QMap<QModelIndex, Mapping *>::const_iterator it =
+ QHash<QModelIndex, Mapping *>::const_iterator it =
static_cast<const Mapping*>(p)->map_iter;
Q_ASSERT(it != source_index_mapping.constEnd());
Q_ASSERT(it.value());
@@ -165,7 +165,7 @@ public:
}
inline QModelIndex create_index(int row, int column,
- QMap<QModelIndex, Mapping*>::const_iterator it) const
+ QHash<QModelIndex, Mapping*>::const_iterator it) const
{
return q_func()->createIndex(row, column, *it);
}
@@ -246,7 +246,7 @@ public:
virtual void _q_sourceModelDestroyed();
};
-typedef QMap<QModelIndex, QSortFilterProxyModelPrivate::Mapping *> IndexMap;
+typedef QHash<QModelIndex, QSortFilterProxyModelPrivate::Mapping *> IndexMap;
void QSortFilterProxyModelPrivate::_q_sourceModelDestroyed()
{
@@ -292,11 +292,13 @@ IndexMap::const_iterator QSortFilterProxyModelPrivate::create_mapping(
Mapping *m = new Mapping;
int source_rows = model->rowCount(source_parent);
+ m->source_rows.reserve(source_rows);
for (int i = 0; i < source_rows; ++i) {
if (q->filterAcceptsRow(i, source_parent))
m->source_rows.append(i);
}
int source_cols = model->columnCount(source_parent);
+ m->source_columns.reserve(source_cols);
for (int i = 0; i < source_cols; ++i) {
if (q->filterAcceptsColumn(i, source_parent))
m->source_columns.append(i);
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 0a7ffb7..4135ba0 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -2407,9 +2407,9 @@ void QTreeView::reexpand()
/*!
\internal
+ This function assume that left is a (grand-)child of the parent of left.
*/
-static bool treeViewItemLessThan(const QTreeViewItem &left,
- const QTreeViewItem &right)
+static bool treeViewItemLessThanInInsert(const QTreeViewItem &left, const QTreeViewItem &right)
{
if (left.level != right.level) {
Q_ASSERT(left.level > right.level);
@@ -2496,7 +2496,7 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end)
QVector<QTreeViewItem>::iterator it;
it = qLowerBound(d->viewItems.begin() + firstChildItem,
d->viewItems.begin() + lastChildItem + 1,
- insertedItems.at(0), treeViewItemLessThan);
+ insertedItems.at(0), treeViewItemLessThanInInsert);
insertPos = it - d->viewItems.begin();
// update stale model indexes of siblings
@@ -2662,17 +2662,8 @@ void QTreeView::expandAll()
{
Q_D(QTreeView);
d->viewItems.clear();
- d->expandedIndexes.clear();
d->interruptDelayedItemsLayout();
- d->layout(-1);
- for (int i = 0; i < d->viewItems.count(); ++i) {
- if (d->viewItems[i].expanded)
- continue;
- d->viewItems[i].expanded = true;
- d->layout(i);
- QModelIndex idx = d->viewItems.at(i).index;
- d->expandedIndexes.insert(idx);
- }
+ d->layout(-1, true);
updateGeometries();
d->viewport->update();
}
@@ -3155,7 +3146,14 @@ void QTreeViewPrivate::_q_columnsRemoved(const QModelIndex &parent, int start, i
QAbstractItemViewPrivate::_q_columnsRemoved(parent, start, end);
}
-void QTreeViewPrivate::layout(int i)
+/** \internal
+ creates and initialize the viewItem structure of the children of the element \i
+
+ set \a recursiveExpanding if the function has to expand all the children (called from expandAll)
+ \a afterIsUninitialized is when we recurse from layout(-1), it means all the items after 'i' are
+ not yet initialized and need not to be moved
+ */
+void QTreeViewPrivate::layout(int i, bool recursiveExpanding, bool afterIsUninitialized)
{
Q_Q(QTreeView);
QModelIndex current;
@@ -3182,8 +3180,12 @@ void QTreeViewPrivate::layout(int i)
defaultItemHeight = q->indexRowSizeHint(index);
}
viewItems.resize(count);
+ afterIsUninitialized = true;
} else if (viewItems[i].total != (uint)count) {
+ if (!afterIsUninitialized)
insertViewItems(i + 1, count, QTreeViewItem()); // expand
+ else if (count > 0)
+ viewItems.resize(viewItems.count() + count);
} else {
expanding = false;
}
@@ -3212,9 +3214,11 @@ void QTreeViewPrivate::layout(int i)
item->expanded = false;
item->total = 0;
item->hasMoreSiblings = false;
- if (isIndexExpanded(current)) {
+ if (recursiveExpanding || isIndexExpanded(current)) {
+ if (recursiveExpanding)
+ expandedIndexes.insert(current);
item->expanded = true;
- layout(last);
+ layout(last, recursiveExpanding, afterIsUninitialized);
item = &viewItems[last];
children += item->total;
item->hasChildren = item->total > 0;
@@ -3226,8 +3230,12 @@ void QTreeViewPrivate::layout(int i)
}
// remove hidden items
- if (hidden > 0)
- removeViewItems(last + 1, hidden); // collapse
+ if (hidden > 0) {
+ if (!afterIsUninitialized)
+ removeViewItems(last + 1, hidden);
+ else
+ viewItems.resize(viewItems.size() - hidden);
+ }
if (!expanding)
return; // nothing changed
@@ -3389,46 +3397,39 @@ int QTreeViewPrivate::viewIndex(const QModelIndex &_index) const
const int totalCount = viewItems.count();
const QModelIndex index = _index.sibling(_index.row(), 0);
+ const int row = index.row();
+ const quint64 internalId = index.internalId();
-
- // A quick check near the last item to see if we are just incrementing
- const int start = lastViewedItem > 2 ? lastViewedItem - 2 : 0;
- const int end = lastViewedItem < totalCount - 2 ? lastViewedItem + 2 : totalCount;
- int row = index.row();
- for (int i = start; i < end; ++i) {
- const QModelIndex &idx = viewItems.at(i).index;
- if (idx.row() == row) {
- if (idx.internalId() == index.internalId()) {
- lastViewedItem = i;
- return i;
- }
+ // We start nearest to the lastViewedItem
+ int localCount = qMin(lastViewedItem - 1, totalCount - lastViewedItem);
+ for (int i = 0; i < localCount; ++i) {
+ const QModelIndex &idx1 = viewItems.at(lastViewedItem + i).index;
+ if (idx1.row() == row && idx1.internalId() == internalId) {
+ lastViewedItem = lastViewedItem + i;
+ return lastViewedItem;
+ }
+ const QModelIndex &idx2 = viewItems.at(lastViewedItem - i - 1).index;
+ if (idx2.row() == row && idx2.internalId() == internalId) {
+ lastViewedItem = lastViewedItem - i - 1;
+ return lastViewedItem;
}
}
- // NOTE: this function is slow if the item is outside the visible area
- // search in visible items first and below
- int t = firstVisibleItem();
- t = t > 100 ? t - 100 : 0; // start 100 items above the visible area
-
- for (int i = t; i < totalCount; ++i) {
- const QModelIndex &idx = viewItems.at(i).index;
- if (idx.row() == row) {
- if (idx.internalId() == index.internalId()) {
- lastViewedItem = i;
- return i;
- }
+ for (int j = qMax(0, lastViewedItem + localCount); j < totalCount; ++j) {
+ const QModelIndex &idx = viewItems.at(j).index;
+ if (idx.row() == row && idx.internalId() == internalId) {
+ lastViewedItem = j;
+ return j;
}
}
- // search from top to first visible
- for (int j = 0; j < t; ++j) {
+ for (int j = qMin(totalCount, lastViewedItem - localCount) - 1; j >= 0; --j) {
const QModelIndex &idx = viewItems.at(j).index;
- if (idx.row() == row) {
- if (idx.internalId() == index.internalId()) {
- lastViewedItem = j;
- return j;
- }
+ if (idx.row() == row && idx.internalId() == internalId) {
+ lastViewedItem = j;
+ return j;
}
}
+
// nothing found
return -1;
}
@@ -3753,7 +3754,6 @@ bool QTreeViewPrivate::hasVisibleChildren(const QModelIndex& parent) const
void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent,
int start, int end, bool after)
{
- Q_Q(QTreeView);
// if we are going to do a complete relayout anyway, there is no need to update
if (delayedPendingLayout) {
_q_rowsRemoved(parent, start, end);
diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h
index 7893e04..48997b7 100644
--- a/src/gui/itemviews/qtreeview_p.h
+++ b/src/gui/itemviews/qtreeview_p.h
@@ -55,6 +55,7 @@
#include "private/qabstractitemview_p.h"
#include <QtCore/qvariantanimation.h>
+#include <QtCore/qabstractitemmodel.h>
#ifndef QT_NO_TREEVIEW
@@ -75,6 +76,8 @@ struct QTreeViewItem
int height : 16; // row height
};
+Q_DECLARE_TYPEINFO(QTreeViewItem, Q_MOVABLE_TYPE);
+
class QTreeViewPrivate : public QAbstractItemViewPrivate
{
Q_DECLARE_PUBLIC(QTreeView)
@@ -124,7 +127,7 @@ public:
void _q_sortIndicatorChanged(int column, Qt::SortOrder order);
void _q_modelDestroyed();
- void layout(int item);
+ void layout(int item, bool recusiveExpanding = false, bool afterIsUninitialized = false);
int pageUp(int item) const;
int pageDown(int item) const;
diff --git a/src/gui/painting/qcups.cpp b/src/gui/painting/qcups.cpp
index ac41692..1ea1670 100644
--- a/src/gui/painting/qcups.cpp
+++ b/src/gui/painting/qcups.cpp
@@ -343,7 +343,8 @@ bool QCUPSSupport::printerHasPPD(const char *printerName)
if (!isAvailable())
return false;
const char *ppdFile = _cupsGetPPD(printerName);
- unlink(ppdFile);
+ if (ppdFile)
+ unlink(ppdFile);
return (ppdFile != 0);
}
diff --git a/src/gui/text/qfontdatabase_qws.cpp b/src/gui/text/qfontdatabase_qws.cpp
index 62d7793..a3d8d65 100644
--- a/src/gui/text/qfontdatabase_qws.cpp
+++ b/src/gui/text/qfontdatabase_qws.cpp
@@ -632,8 +632,9 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp,
#ifndef QT_NO_FREETYPE
QScopedPointer<QFontEngineFT> fte(new QFontEngineFT(def));
- if (fte->init(faceId, style->antialiased,
- style->antialiased ? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono)) {
+ bool antialias = style->antialiased && !(request.styleStrategy & QFont::NoAntialias);
+ if (fte->init(faceId, antialias,
+ antialias ? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono)) {
#ifdef QT_NO_QWS_QPF2
return fte.take();
#else
@@ -793,7 +794,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
" family: %s [%s], script: %d\n"
" weight: %d, style: %d\n"
" stretch: %d\n"
- " pixelSize: %d\n"
+ " pixelSize: %g\n"
" pitch: %c",
family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(),
foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(),
diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp
index 136737d..a0593cc 100644
--- a/src/gui/text/qfontengine_qpf.cpp
+++ b/src/gui/text/qfontengine_qpf.cpp
@@ -920,8 +920,18 @@ void QFontEngineQPF::loadGlyph(glyph_t glyph)
if (!renderingFontEngine)
return;
-
- QImage img = renderingFontEngine->alphaMapForGlyph(glyph).convertToFormat(QImage::Format_Indexed8);
+ QImage img = renderingFontEngine->alphaMapForGlyph(glyph);
+ if (img.format() != QImage::Format_Indexed8) {
+ bool mono = img.depth() == 1;
+ img = img.convertToFormat(QImage::Format_Indexed8);
+ if (mono) {
+ //### we know that 1 is opaque and 0 is transparent
+ uchar *byte = img.bits();
+ int count = img.byteCount();
+ while (count--)
+ *byte++ *= 0xff;
+ }
+ }
glyph_metrics_t metrics = renderingFontEngine->boundingBox(glyph);
renderingFontEngine->removeGlyphFromCache(glyph);
diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro
index f348fef..16b3ace 100644
--- a/src/imports/multimedia/multimedia.pro
+++ b/src/imports/multimedia/multimedia.pro
@@ -18,9 +18,9 @@ SOURCES += \
qmetadatacontrolmetaobject.cpp
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH
-target.path = $$TARGETPATH
+target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
-qmldir.files += $$QT_BUILD_TREE/imports/Qt/multimedia/qmldir
+qmldir.files += $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir
qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
INSTALLS += target qmldir
diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro
index 2a0b8f5..02d9ea6 100644
--- a/src/imports/particles/particles.pro
+++ b/src/imports/particles/particles.pro
@@ -12,10 +12,9 @@ HEADERS += \
qdeclarativeparticles_p.h
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH
-target.path = $$TARGETPATH
+target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
-# install qmldir file
-qmldir.files += qmldir
-qmldir.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
+qmldir.files += $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir
+qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
INSTALLS += target qmldir
diff --git a/src/imports/webkit/webkit.pro b/src/imports/webkit/webkit.pro
index 858d3ba..ef08efe 100644
--- a/src/imports/webkit/webkit.pro
+++ b/src/imports/webkit/webkit.pro
@@ -9,9 +9,9 @@ HEADERS += qdeclarativewebview_p.h \
qdeclarativewebview_p_p.h
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH
-target.path = $$TARGETPATH
+target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
-qmldir.files += $$QT_BUILD_TREE/imports/org/webkit/qmldir
+qmldir.files += $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir
qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
INSTALLS += target qmldir
diff --git a/src/imports/widgets/widgets.pro b/src/imports/widgets/widgets.pro
index de22403..aa09b3c 100644
--- a/src/imports/widgets/widgets.pro
+++ b/src/imports/widgets/widgets.pro
@@ -13,10 +13,9 @@ HEADERS += \
graphicslayouts_p.h
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH
-target.path = $$TARGETPATH
+target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
-# install qmldir file
-qmldir.files += qmldir
-qmldir.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
+qmldir.files += $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir
+qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
INSTALLS += target qmldir
diff --git a/src/multimedia/base/qpaintervideosurface.cpp b/src/multimedia/base/qpaintervideosurface.cpp
index fc3d493..ed93fad 100644
--- a/src/multimedia/base/qpaintervideosurface.cpp
+++ b/src/multimedia/base/qpaintervideosurface.cpp
@@ -434,6 +434,9 @@ void QVideoSurfaceGLPainter::initRgbTextureInfo(
void QVideoSurfaceGLPainter::initYuv420PTextureInfo(const QSize &size)
{
+ int w = (size.width() + 3) & ~3;
+ int w2 = (size.width()/2 + 3) & ~3;
+
m_yuv = true;
m_textureInternalFormat = GL_LUMINANCE;
m_textureFormat = GL_LUMINANCE;
@@ -444,14 +447,17 @@ void QVideoSurfaceGLPainter::initYuv420PTextureInfo(const QSize &size)
m_textureOffsets[0] = 0;
m_textureWidths[1] = size.width() / 2;
m_textureHeights[1] = size.height() / 2;
- m_textureOffsets[1] = size.width() * size.height();
+ m_textureOffsets[1] = w * size.height();
m_textureWidths[2] = size.width() / 2;
m_textureHeights[2] = size.height() / 2;
- m_textureOffsets[2] = size.width() * size.height() * 5 / 4;
+ m_textureOffsets[2] = w * size.height() + w2 * (size.height() / 2);
}
void QVideoSurfaceGLPainter::initYv12TextureInfo(const QSize &size)
{
+ int w = (size.width() + 3) & ~3;
+ int w2 = (size.width()/2 + 3) & ~3;
+
m_yuv = true;
m_textureInternalFormat = GL_LUMINANCE;
m_textureFormat = GL_LUMINANCE;
@@ -462,10 +468,10 @@ void QVideoSurfaceGLPainter::initYv12TextureInfo(const QSize &size)
m_textureOffsets[0] = 0;
m_textureWidths[1] = size.width() / 2;
m_textureHeights[1] = size.height() / 2;
- m_textureOffsets[1] = size.width() * size.height() * 5 / 4;
+ m_textureOffsets[1] = w * size.height() + w2 * (size.height() / 2);
m_textureWidths[2] = size.width() / 2;
m_textureHeights[2] = size.height() / 2;
- m_textureOffsets[2] = size.width() * size.height();
+ m_textureOffsets[2] = w * size.height();
}
#ifndef QT_OPENGL_ES
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 7839191..e0030ad 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1583,6 +1583,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
vi = 0;
#endif
#if defined(QT_OPENGL_ES)
+ ownsEglContext = false;
eglContext = 0;
eglSurface = EGL_NO_SURFACE;
#endif
@@ -1688,14 +1689,12 @@ typedef void (*_qt_image_cleanup_hook_64)(qint64);
extern Q_GUI_EXPORT _qt_pixmap_cleanup_hook_64 qt_pixmap_cleanup_hook_64;
extern Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64;
-static QGLTextureCache *qt_gl_texture_cache = 0;
+
+Q_GLOBAL_STATIC(QGLTextureCache, qt_gl_texture_cache)
QGLTextureCache::QGLTextureCache()
: m_cache(64*1024) // cache ~64 MB worth of textures - this is not accurate though
{
- Q_ASSERT(qt_gl_texture_cache == 0);
- qt_gl_texture_cache = this;
-
QImagePixmapCleanupHooks::instance()->addPixmapDataModificationHook(cleanupTexturesForPixampData);
QImagePixmapCleanupHooks::instance()->addPixmapDataDestructionHook(cleanupBeforePixmapDestruction);
QImagePixmapCleanupHooks::instance()->addImageHook(cleanupTexturesForCacheKey);
@@ -1703,8 +1702,7 @@ QGLTextureCache::QGLTextureCache()
QGLTextureCache::~QGLTextureCache()
{
- qt_gl_texture_cache = 0;
-
+ Q_ASSERT(size() == 0);
QImagePixmapCleanupHooks::instance()->removePixmapDataModificationHook(cleanupTexturesForPixampData);
QImagePixmapCleanupHooks::instance()->removePixmapDataDestructionHook(cleanupBeforePixmapDestruction);
QImagePixmapCleanupHooks::instance()->removeImageHook(cleanupTexturesForCacheKey);
@@ -1754,22 +1752,14 @@ void QGLTextureCache::removeContextTextures(QGLContext* ctx)
}
}
-QGLTextureCache* QGLTextureCache::instance()
-{
- if (!qt_gl_texture_cache)
- qt_gl_texture_cache = new QGLTextureCache;
-
- return qt_gl_texture_cache;
-}
-
/*
a hook that removes textures from the cache when a pixmap/image
is deref'ed
*/
void QGLTextureCache::cleanupTexturesForCacheKey(qint64 cacheKey)
{
- instance()->remove(cacheKey);
- Q_ASSERT(instance()->getTexture(cacheKey) == 0);
+ qt_gl_texture_cache()->remove(cacheKey);
+ Q_ASSERT(qt_gl_texture_cache()->getTexture(cacheKey) == 0);
}
@@ -1791,10 +1781,9 @@ void QGLTextureCache::cleanupBeforePixmapDestruction(QPixmapData* pmd)
#endif
}
-void QGLTextureCache::deleteIfEmpty()
+QGLTextureCache *QGLTextureCache::instance()
{
- if (instance()->size() == 0)
- delete instance();
+ return qt_gl_texture_cache();
}
// DDS format structure
@@ -1960,7 +1949,6 @@ QGLContext::~QGLContext()
{
// remove any textures cached in this context
QGLTextureCache::instance()->removeContextTextures(this);
- QGLTextureCache::deleteIfEmpty(); // ### thread safety
d_ptr->group->cleanupResources(this);
@@ -5072,6 +5060,20 @@ QGLExtensions::Extensions QGLExtensions::currentContextExtensions()
return glExtensions;
}
+
+class QGLDefaultExtensions
+{
+public:
+ QGLDefaultExtensions() {
+ QGLTemporaryContext tempContext;
+ extensions = QGLExtensions::currentContextExtensions();
+ }
+
+ QGLExtensions::Extensions extensions;
+};
+
+Q_GLOBAL_STATIC(QGLDefaultExtensions, qtDefaultExtensions)
+
/*
Returns the GL extensions for the current QGLContext. If there is no
current QGLContext, a default context will be created and the extensions
@@ -5079,34 +5081,19 @@ QGLExtensions::Extensions QGLExtensions::currentContextExtensions()
*/
QGLExtensions::Extensions QGLExtensions::glExtensions()
{
- QGLTemporaryContext *tmpContext = 0;
- static bool cachedDefault = false;
- static Extensions defaultExtensions = 0;
+ Extensions extensionFlags = 0;
QGLContext *currentCtx = const_cast<QGLContext *>(QGLContext::currentContext());
if (currentCtx && currentCtx->d_func()->extension_flags_cached)
return currentCtx->d_func()->extension_flags;
if (!currentCtx) {
- if (cachedDefault) {
- return defaultExtensions;
- } else {
- tmpContext = new QGLTemporaryContext;
- cachedDefault = true;
- }
- }
-
- Extensions extensionFlags = currentContextExtensions();
- if (currentCtx) {
+ extensionFlags = qtDefaultExtensions()->extensions;
+ } else {
+ extensionFlags = currentContextExtensions();
currentCtx->d_func()->extension_flags_cached = true;
currentCtx->d_func()->extension_flags = extensionFlags;
- } else {
- defaultExtensions = extensionFlags;
}
-
- if (tmpContext)
- delete tmpContext;
-
return extensionFlags;
}
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index c08d6fd..822c9f6 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -63,10 +63,8 @@ void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLForma
// QGLFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that
// type has been requested. So we must check QGLFormat's booleans too if size is -1:
- if (glFormat.alpha() && alphaSize <= 0) {
- qDebug("QGLFormat::alpha() returned true");
+ if (glFormat.alpha() && alphaSize <= 0)
alphaSize = 1;
- }
if (glFormat.depth() && depthSize <= 0)
depthSize = 1;
if (glFormat.stencil() && stencilSize <= 0)
@@ -164,10 +162,11 @@ void QGLContext::reset()
return;
d->cleanup();
doneCurrent();
- if (d->eglContext) {
+ if (d->eglContext && d->ownsEglContext) {
d->destroyEglSurfaceForDevice();
delete d->eglContext;
}
+ d->ownsEglContext = false;
d->eglContext = 0;
d->eglSurface = EGL_NO_SURFACE;
d->crWin = false;
@@ -215,7 +214,7 @@ void QGLContextPrivate::destroyEglSurfaceForDevice()
#ifdef Q_WS_X11
// Make sure we don't call eglDestroySurface on a surface which
// was created for a different winId:
- if (paintDevice->devType() == QInternal::Widget) {
+ if (paintDevice && paintDevice->devType() == QInternal::Widget) {
QGLWidget* w = static_cast<QGLWidget*>(paintDevice);
if (w->d_func()->eglSurfaceWindowId == w->winId())
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index ed34f79..45f8f30 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -278,8 +278,6 @@ public:
Q_DECLARE_FLAGS(Extensions, Extension)
static Extensions glExtensions();
-
-private:
static Extensions currentContextExtensions();
};
@@ -347,6 +345,7 @@ public:
HDC hbitmap_hdc;
#endif
#if defined(QT_OPENGL_ES)
+ bool ownsEglContext;
QEglContext *eglContext;
EGLSurface eglSurface;
void destroyEglSurfaceForDevice();
@@ -532,7 +531,6 @@ public:
bool remove(QGLContext *ctx, GLuint textureId);
void removeContextTextures(QGLContext *ctx);
static QGLTextureCache *instance();
- static void deleteIfEmpty();
static void cleanupTexturesForCacheKey(qint64 cacheKey);
static void cleanupTexturesForPixampData(QPixmapData* pixmap);
static void cleanupBeforePixmapDestruction(QPixmapData* pixmap);
diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp
index 96b2454..38c3774 100644
--- a/src/opengl/qgl_qws.cpp
+++ b/src/opengl/qgl_qws.cpp
@@ -182,6 +182,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Get the display and initialize it.
d->eglContext = new QEglContext();
+ d->ownsEglContext = true;
d->eglContext->setApi(QEgl::OpenGL);
// Construct the configuration we need for this surface.
diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp
index fefcca2..47a19b5 100644
--- a/src/opengl/qgl_wince.cpp
+++ b/src/opengl/qgl_wince.cpp
@@ -145,6 +145,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Get the display and initialize it.
d->eglContext = new QEglContext();
+ d->ownsEglContext = true;
d->eglContext->setApi(QEgl::OpenGL);
// Construct the configuration we need for this surface.
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index fe87c65..0954e69 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -182,6 +182,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Only create the eglContext if we don't already have one:
if (d->eglContext == 0) {
d->eglContext = new QEglContext();
+ d->ownsEglContext = true;
d->eglContext->setApi(QEgl::OpenGL);
// If the device is a widget with WA_TranslucentBackground set, make sure the glFormat
diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp
index d7fae16..a01eec4 100644
--- a/src/opengl/qpixmapdata_x11gl_egl.cpp
+++ b/src/opengl/qpixmapdata_x11gl_egl.cpp
@@ -181,6 +181,8 @@ QX11GLPixmapData::QX11GLPixmapData()
QX11GLPixmapData::~QX11GLPixmapData()
{
+ if (ctx)
+ delete ctx;
}
#if !defined(QT_OPENGL_ES_1)
@@ -245,6 +247,7 @@ void QX11GLPixmapData::beginPaint()
if ((EGLSurface)gl_surface == EGL_NO_SURFACE) {
QPixmap tmpPixmap(this);
EGLConfig cfg = ctx->d_func()->eglContext->config();
+ Q_ASSERT(cfg != QEGL_NO_CONFIG);
EGLSurface surface = QEgl::createSurface(&tmpPixmap, cfg);
if (surface == EGL_NO_SURFACE) {
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 2c850c9..4902cbd 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -3307,6 +3307,7 @@ void QVGPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
bool QVGPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFont &font,
QFontEngine *fontEngine, const QPointF &p)
{
+#if !defined(QVG_NO_DRAW_GLYPHS)
Q_D(QVGPaintEngine);
// Find the glyph cache for this font.
@@ -3361,6 +3362,14 @@ void QVGPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
NULL, NULL, VG_FILL_PATH, VG_TRUE);
return true;
+#else
+ Q_UNUSED(numGlyphs);
+ Q_UNUSED(glyphs);
+ Q_UNUSED(font);
+ Q_UNUSED(fontEngine);
+ Q_UNUSED(p);
+ return false;
+#endif
}
void QVGPaintEngine::setState(QPainterState *s)
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp
index 47fb451..8307aa5 100644
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp
+++ b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.cpp
@@ -99,9 +99,26 @@ protected:
QGstreamerVideoWidgetControl::QGstreamerVideoWidgetControl(QObject *parent)
: QVideoWidgetControl(parent)
, m_videoSink(0)
- , m_widget(new QGstreamerVideoWidget)
+ , m_widget(0)
, m_fullScreen(false)
+{
+}
+
+QGstreamerVideoWidgetControl::~QGstreamerVideoWidgetControl()
+{
+ if (m_videoSink)
+ gst_object_unref(GST_OBJECT(m_videoSink));
+
+ delete m_widget;
+}
+
+void QGstreamerVideoWidgetControl::createVideoWidget()
{
+ if (m_widget)
+ return;
+
+ m_widget = new QGstreamerVideoWidget;
+
m_widget->installEventFilter(this);
m_windowId = m_widget->winId();
@@ -125,22 +142,15 @@ QGstreamerVideoWidgetControl::QGstreamerVideoWidgetControl(QObject *parent)
gst_object_sink (GST_OBJECT (m_videoSink));
}
-QGstreamerVideoWidgetControl::~QGstreamerVideoWidgetControl()
-{
- if (m_videoSink)
- gst_object_unref(GST_OBJECT(m_videoSink));
-
- delete m_widget;
-}
-
GstElement *QGstreamerVideoWidgetControl::videoSink()
{
+ createVideoWidget();
return m_videoSink;
}
bool QGstreamerVideoWidgetControl::eventFilter(QObject *object, QEvent *e)
{
- if (object == m_widget) {
+ if (m_widget && object == m_widget) {
if (e->type() == QEvent::ParentChange || e->type() == QEvent::Show) {
WId newWId = m_widget->winId();
if (newWId != m_windowId) {
@@ -205,7 +215,8 @@ void QGstreamerVideoWidgetControl::updateNativeVideoSize()
gst_caps_unref(caps);
}
} else {
- m_widget->setNativeSize(QSize());
+ if (m_widget)
+ m_widget->setNativeSize(QSize());
}
}
@@ -218,6 +229,7 @@ void QGstreamerVideoWidgetControl::windowExposed()
QWidget *QGstreamerVideoWidgetControl::videoWidget()
{
+ createVideoWidget();
return m_widget;
}
@@ -252,7 +264,7 @@ int QGstreamerVideoWidgetControl::brightness() const
{
int brightness = 0;
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness"))
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness"))
g_object_get(G_OBJECT(m_videoSink), "brightness", &brightness, NULL);
return brightness / 10;
@@ -260,7 +272,7 @@ int QGstreamerVideoWidgetControl::brightness() const
void QGstreamerVideoWidgetControl::setBrightness(int brightness)
{
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness")) {
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "brightness")) {
g_object_set(G_OBJECT(m_videoSink), "brightness", brightness * 10, NULL);
emit brightnessChanged(brightness);
@@ -271,15 +283,15 @@ int QGstreamerVideoWidgetControl::contrast() const
{
int contrast = 0;
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast"))
- g_object_get(G_OBJECT(m_videoSink), "contrast", &contrast, NULL);
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast"))
+ g_object_get(G_OBJECT(m_videoSink), "contrast", &contrast, NULL);
return contrast / 10;
}
void QGstreamerVideoWidgetControl::setContrast(int contrast)
{
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast")) {
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "contrast")) {
g_object_set(G_OBJECT(m_videoSink), "contrast", contrast * 10, NULL);
emit contrastChanged(contrast);
@@ -290,7 +302,7 @@ int QGstreamerVideoWidgetControl::hue() const
{
int hue = 0;
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue"))
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue"))
g_object_get(G_OBJECT(m_videoSink), "hue", &hue, NULL);
return hue / 10;
@@ -298,7 +310,7 @@ int QGstreamerVideoWidgetControl::hue() const
void QGstreamerVideoWidgetControl::setHue(int hue)
{
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue")) {
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "hue")) {
g_object_set(G_OBJECT(m_videoSink), "hue", hue * 10, NULL);
emit hueChanged(hue);
@@ -309,7 +321,7 @@ int QGstreamerVideoWidgetControl::saturation() const
{
int saturation = 0;
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation"))
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation"))
g_object_get(G_OBJECT(m_videoSink), "saturation", &saturation, NULL);
return saturation / 10;
@@ -317,7 +329,7 @@ int QGstreamerVideoWidgetControl::saturation() const
void QGstreamerVideoWidgetControl::setSaturation(int saturation)
{
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation")) {
+ if (m_videoSink && g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSink), "saturation")) {
g_object_set(G_OBJECT(m_videoSink), "saturation", saturation * 10, NULL);
emit saturationChanged(saturation);
diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h
index 7b966b7..6a4c0f3 100644
--- a/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h
+++ b/src/plugins/mediaservices/gstreamer/qgstreamervideowidget.h
@@ -93,6 +93,7 @@ public slots:
void updateNativeVideoSize();
private:
+ void createVideoWidget();
void windowExposed();
GstElement *m_videoSink;
diff --git a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro
index 0c736b4..3ba50be 100644
--- a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro
+++ b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro
@@ -1,8 +1,9 @@
load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
+contains(QT_CONFIG,declarative): QT += declarative gui network
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativefontloader.cpp
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qdeclarativefontloader.cpp ../shared/testhttpserver.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
index add3c7b..375e801 100644
--- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
+++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
@@ -43,6 +43,9 @@
#include <QtDeclarative/qdeclarativecomponent.h>
#include <private/qdeclarativefontloader_p.h>
#include "../../../shared/util.h"
+#include "../shared/testhttpserver.h"
+
+#define SERVER_PORT 14445
class tst_qdeclarativefontloader : public QObject
@@ -57,16 +60,21 @@ private slots:
void localFont();
void failLocalFont();
void webFont();
+ void redirWebFont();
void failWebFont();
private slots:
private:
QDeclarativeEngine engine;
+ TestHTTPServer server;
};
-tst_qdeclarativefontloader::tst_qdeclarativefontloader()
+tst_qdeclarativefontloader::tst_qdeclarativefontloader() :
+ server(SERVER_PORT)
{
+ server.serveDirectory(SRCDIR "/data");
+ Q_ASSERT(server.isValid());
}
void tst_qdeclarativefontloader::noFont()
@@ -126,21 +134,38 @@ void tst_qdeclarativefontloader::failLocalFont()
void tst_qdeclarativefontloader::webFont()
{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://www.princexml.com/fonts/steffmann/Starburst.ttf\" }";
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://localhost:14445/tarzeau_ocr_a.ttf\" }";
+ QDeclarativeComponent component(&engine);
+
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+ QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
+}
+
+void tst_qdeclarativefontloader::redirWebFont()
+{
+ server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf");
+
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://localhost:14445/olddir/oldname.ttf\" }";
QDeclarativeComponent component(&engine);
+
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
QVERIFY(fontObject != 0);
QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("Starburst"));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
}
void tst_qdeclarativefontloader::failWebFont()
{
- QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://wrong.address.nokia.com/Starburst.ttf\" }";
- QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"http://wrong.address.nokia.com/Starburst.ttf\" ) ");
+ QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://localhost:14445/nonexist.ttf\" }";
+ QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"http://localhost:14445/nonexist.ttf\" ) ");
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());