From 1acc9bcf4c43851af2096539eda88da9ef58bce3 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 30 Mar 2010 10:05:10 +0200 Subject: Avoid taking sqrt of negative number in FT font engine When using a reflecting matrix, the determinant will be -1, thus the call to sqrt() will return NaN. Same fix as in 0fa878c4d2. Task-number: QTBUG-9442 Reviewed-by: Trond --- src/gui/text/qfontengine_ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index a9def8e..449dffd 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1368,7 +1368,7 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransfor if (!gs) { // don't try to load huge fonts - bool draw_as_outline = fontDef.pixelSize * qSqrt(matrix.det()) >= 64; + bool draw_as_outline = fontDef.pixelSize * qSqrt(qAbs(matrix.det())) >= 64; if (draw_as_outline) return 0; -- cgit v0.12 From f9fdac19aff44f5c6d868a8e8dfa59c0ab6e3c20 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 13 Apr 2010 10:52:35 +0300 Subject: QS60Style: Single Click UI support for SD 9.2 time-box Final commit for this task. For widgets that use the highlighted list/table graphic, style now supports pressed state for the highlight. Style filters mouse press and release events and sets the highlight graphics to be correct based on mouse events (i.e. touch) it gets. Task-number: QT-2298 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 175 +++++++++++++++++++++++++++------------ src/gui/styles/qs60style_p.h | 27 +++++- src/gui/styles/qs60style_s60.cpp | 21 +++++ 3 files changed, 170 insertions(+), 53 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index f49acc4..28cbc45 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -122,6 +122,8 @@ QPalette *QS60StylePrivate::m_themePalette = 0; qint64 QS60StylePrivate::m_webPaletteKey = 0; +QPointer QS60StylePrivate::m_pressedWidget = 0; + const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { {SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, {SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, @@ -138,6 +140,8 @@ const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameEleme {SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, {SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive}, {SE_Editor, QS60StyleEnums::SP_QsnFrInputCenter}, + {SE_TableItemPressed, QS60StyleEnums::SP_QsnFrGridCenterPressed}, + {SE_ListItemPressed, QS60StyleEnums::SP_QsnFrListPressed}, }; static const int frameElementsCount = @@ -294,6 +298,12 @@ void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, case SE_DropArea: drawPart(QS60StyleEnums::SP_QgnGrafOrgBgGrid, painter, rect, flags | SF_PointNorth); break; + case SE_TableItemPressed: + drawFrame(SF_TableItemPressed, painter, rect, flags | SF_PointNorth); + break; + case SE_ListItemPressed: + drawFrame(SF_ListItemPressed, painter, rect, flags | SF_PointNorth); + break; default: break; } @@ -939,6 +949,11 @@ bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush, con backgroundBrush.style() == Qt::NoBrush) ? true : false; } +bool QS60StylePrivate::isWidgetPressed(const QWidget *widget) +{ + return (widget && widget == m_pressedWidget); +} + /*! \class QS60Style \brief The QS60Style class provides a look and feel suitable for applications on S60. @@ -1424,73 +1439,37 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, // draw themed background for table unless background brush has been defined. if (vopt->backgroundBrush == Qt::NoBrush) { if (itemView) { - const QModelIndex index = vopt->index; - //todo: Draw cell background only once - for the first cell. - QStyleOptionViewItemV4 voptAdj2 = voptAdj; - const QModelIndex indexFirst = itemView->model()->index(0, 0); - const QModelIndex indexLast = itemView->model()->index( - itemView->model()->rowCount() - 1, itemView->model()->columnCount() -1); - if (itemView->viewport()) - voptAdj2.rect = QRect( itemView->visualRect(indexFirst).topLeft(), - itemView->visualRect(indexLast).bottomRight()).intersect(itemView->viewport()->rect()); drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget); } } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);} - // draw the focus rect - if (isSelected || hasFocus ) { - QRect highlightRect = option->rect.adjusted(1,1,-1,-1); - QAbstractItemView::SelectionBehavior selectionBehavior = - itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems; - if (selectionBehavior != QAbstractItemView::SelectItems) { - // set highlight rect so that it is continuous from cell to cell, yet sligthly - // smaller than cell rect - int xBeginning = 0, yBeginning = 0, xEnd = 0, yEnd = 0; - if (selectionBehavior == QAbstractItemView::SelectRows) { - yBeginning = 1; yEnd = -1; - if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) - xBeginning = 1; - else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) - xEnd = -1; - } else if (selectionBehavior == QAbstractItemView::SelectColumns) { - xBeginning = 1; xEnd = -1; - if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) - yBeginning = 1; - else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) - yEnd = -1; - } - highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, yEnd); - } - if (vopt->showDecorationSelected && - (vopt->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color())) - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags); - else - painter->fillRect(highlightRect, vopt->palette.highlight()); - } - // draw the icon const QIcon::Mode mode = (voptAdj.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled; - const QIcon::State state = voptAdj.state & State_Open ? QIcon::On : QIcon::Off; + const QIcon::State state = (voptAdj.state & State_Open) ? QIcon::On : QIcon::Off; voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state); // Draw selection check mark. Show check mark only in multi selection modes. if (itemView) { const bool singleSelection = (itemView->selectionMode() == QAbstractItemView::SingleSelection || - itemView->selectionMode() == QAbstractItemView::NoSelection); + itemView->selectionMode() == QAbstractItemView::NoSelection)|| + (itemView->selectionModel()->selectedIndexes().count() < 2 ); + + const bool selectItemsOnly = (itemView->selectionBehavior() == QAbstractItemView::SelectItems); + const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget); QStyleOptionViewItemV4 checkMarkOption(voptAdj); - // Draw selection mark. - if (voptAdj.state & State_Selected && !singleSelection) { + if (selectionRect.isValid()) checkMarkOption.rect = selectionRect; - drawPrimitive(PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); - if ( textRect.right() > selectionRect.left() ) + // Draw selection mark. + if (isSelected && !singleSelection && selectItemsOnly) { + proxy()->drawPrimitive(PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); + // @todo: this should happen in the rect retrievel i.e. subElementRect() + if (textRect.right() > selectionRect.left()) textRect.setRight(selectionRect.left()); } else if (singleSelection && - voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator && - selectionRect.isValid()) { - checkMarkOption.rect = selectionRect; + voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator) { checkMarkOption.state = checkMarkOption.state & ~State_HasFocus; switch (vopt->checkState) { @@ -2037,7 +2016,10 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) if ((qstyleoption_cast(option) && (qobject_cast(widget) || qobject_cast(widget)))) - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); + QS60StylePrivate::drawSkinElement( + QS60StylePrivate::isWidgetPressed(widget) ? + QS60StylePrivate::SE_ListItemPressed : + QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); else commonStyleDraws = true; } @@ -2257,6 +2239,57 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti break; #ifndef QT_NO_ITEMVIEWS case PE_PanelItemViewItem: + if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast(option)) { + const bool isSelected = (vopt->state & State_Selected); + const bool hasFocus = (vopt->state & State_HasFocus); + const bool isPressed = QS60StylePrivate::isWidgetPressed(widget); + + if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) { + QRect highlightRect = vopt->rect.adjusted(1,1,-1,-1); + const QAbstractItemView *itemView = qobject_cast(widget); + QAbstractItemView::SelectionBehavior selectionBehavior = + itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems; + // Set the draw area for highlights (focus, select rect or pressed rect) + if (hasFocus || isSelected || isPressed) { + if (selectionBehavior != QAbstractItemView::SelectItems) { + // set highlight rect so that it is continuous from cell to cell, yet sligthly + // smaller than cell rect + int xBeginning = 0, yBeginning = 0, xEnd = 0, yEnd = 0; + if (selectionBehavior == QAbstractItemView::SelectRows) { + yBeginning = 1; yEnd = -1; + if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) + xBeginning = 1; + else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) + xEnd = -1; + } else if (selectionBehavior == QAbstractItemView::SelectColumns) { + xBeginning = 1; xEnd = -1; + if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning) + yBeginning = 1; + else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End) + yEnd = -1; + } + highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, yEnd); + } + } + bool tableView = false; + if (itemView && qobject_cast(widget)) + tableView = true; + + QS60StylePrivate::SkinElements element; + QRect elementRect = option->rect; + + //draw item is drawn as pressed, if it already has focus. + if (isPressed && (hasFocus || isSelected)) { + element = tableView ? QS60StylePrivate::SE_TableItemPressed : QS60StylePrivate::SE_ListItemPressed; + } else if (hasFocus || (isSelected && selectionBehavior != QAbstractItemView::SelectItems)) { + element = QS60StylePrivate::SE_ListHighlight; + elementRect = highlightRect; + } + QS60StylePrivate::drawSkinElement(element, painter, elementRect, flags); + } else { + QCommonStyle::drawPrimitive(element, option, painter, widget); + } + } break; #endif //QT_NO_ITEMVIEWS @@ -3067,8 +3100,11 @@ void QS60Style::unpolish(QWidget *widget) void QS60Style::polish(QApplication *application) { Q_D(QS60Style); + QCommonStyle::polish(qApp); d->m_originalPalette = application->palette(); d->setThemePalette(application); + if (QS60StylePrivate::isTouchSupported()) + qApp->installEventFilter(this); } /*! @@ -3077,10 +3113,14 @@ void QS60Style::polish(QApplication *application) void QS60Style::unpolish(QApplication *application) { Q_UNUSED(application) + Q_D(QS60Style); + QCommonStyle::unpolish(qApp); const QPalette newPalette = QApplication::style()->standardPalette(); QApplication::setPalette(newPalette); QApplicationPrivate::setSystemPalette(d->m_originalPalette); + if (QS60StylePrivate::isTouchSupported()) + qApp->removeEventFilter(this); } /*! @@ -3227,9 +3267,40 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, */ bool QS60Style::eventFilter(QObject *object, QEvent *event) { + Q_D(QS60Style); + switch(event->type()) { + case QEvent::MouseButtonPress: { + QWidget *w = QApplication::widgetAt(QCursor::pos()); + if (w) { + QWidget *focusW = w->focusProxy(); + if (qobject_cast(focusW) || + qobject_cast(focusW) || + qobject_cast(focusW)) + d->m_pressedWidget = focusW; + else if (qobject_cast(w)|| + qobject_cast(w) || + qobject_cast(w)) + d->m_pressedWidget = w; + + if ( d->m_pressedWidget) + d->m_pressedWidget->update(); + } + break; + } + case QEvent::MouseButtonRelease: { + const QWidget *w = QApplication::widgetAt(QCursor::pos()); + if (w && d->m_pressedWidget) { + d->m_pressedWidget->update(); + d->m_pressedWidget = 0; + } + break; + } + default: + break; + } + #ifdef Q_WS_S60 #ifndef QT_NO_PROGRESSBAR - Q_D(QS60Style); switch(event->type()) { case QEvent::StyleChange: case QEvent::Show: @@ -3250,7 +3321,7 @@ bool QS60Style::eventFilter(QObject *object, QEvent *event) } #endif // QT_NO_PROGRESSBAR #endif // Q_WS_S60 - return QStyle::eventFilter(object, event); + return QCommonStyle::eventFilter(object, event); } /*! diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 6ce4960..9dd3810 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -293,6 +293,24 @@ public: SP_QsnFrButtonSideLInactive, SP_QsnFrButtonSideRInactive, SP_QsnFrButtonCenterInactive, + SP_QsnFrGridCornerTlPressed, // Pressed table item + SP_QsnFrGridCornerTrPressed, + SP_QsnFrGridCornerBlPressed, + SP_QsnFrGridCornerBrPressed, + SP_QsnFrGridSideTPressed, + SP_QsnFrGridSideBPressed, + SP_QsnFrGridSideLPressed, + SP_QsnFrGridSideRPressed, + SP_QsnFrGridCenterPressed, + SP_QsnFrListCornerTlPressed, // Pressed list item + SP_QsnFrListCornerTrPressed, + SP_QsnFrListCornerBlPressed, + SP_QsnFrListCornerBrPressed, + SP_QsnFrListSideTPressed, + SP_QsnFrListSideBPressed, + SP_QsnFrListSideLPressed, + SP_QsnFrListSideRPressed, + SP_QsnFrListPressed, }; enum ColorLists { @@ -424,7 +442,9 @@ public: SE_ScrollBarHandlePressedVertical, SE_ButtonInactive, SE_Editor, - SE_DropArea + SE_DropArea, + SE_TableItemPressed, + SE_ListItemPressed, }; enum SkinFrameElements { @@ -442,6 +462,8 @@ public: SF_ToolBarButtonPressed, SF_PanelBackground, SF_ButtonInactive, + SF_TableItemPressed, + SF_ListItemPressed, }; enum SkinElementFlag { @@ -496,6 +518,7 @@ public: static bool isToolBarBackground(); static bool hasSliderGrooveGraphic(); static bool isSingleClickUi(); + static bool isWidgetPressed(const QWidget *widget); // calculates average color based on button skin graphics (minus borders). QColor colorFromFrameGraphics(SkinFrameElements frame) const; @@ -593,6 +616,8 @@ private: QPointer m_focusFrame; static qint64 m_webPaletteKey; + static QPointer m_pressedWidget; + #ifdef Q_WS_S60 //list of progress bars having animation running QList m_bars; diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 97cf919..74da51e 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -377,6 +377,27 @@ const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { /* SP_QsnFrButtonSideRInactive */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x21b8}, /* SP_QsnFrButtonCenterInactive */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon, ES60_3_X, EAknsMajorSkin, 0x21b9}, + // No pressed down grid in 3.1/3.2 + /* SP_QsnFrGridCornerTlPressed */ {KAknsIIDQsnFrGridCornerTl, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2681}, /*KAknsIIDQsnFrGridCornerTlPressed*/ + /* SP_QsnFrGridCornerTrPressed */ {KAknsIIDQsnFrGridCornerTr, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2682}, + /* SP_QsnFrGridCornerBlPressed */ {KAknsIIDQsnFrGridCornerBl, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2683}, + /* SP_QsnFrGridCornerBrPressed */ {KAknsIIDQsnFrGridCornerBr, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2684}, + /* SP_QsnFrGridSideTPressed */ {KAknsIIDQsnFrGridSideT, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2685}, + /* SP_QsnFrGridSideBPressed */ {KAknsIIDQsnFrGridSideB, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2686}, + /* SP_QsnFrGridSideLPressed */ {KAknsIIDQsnFrGridSideL, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2687}, + /* SP_QsnFrGridSideRPressed */ {KAknsIIDQsnFrGridSideR, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2688}, + /* SP_QsnFrGridCenterPressed */ {KAknsIIDQsnFrGridCenter, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2689}, + + // No pressed down list in 3.1/3.2 + /* SP_QsnFrListCornerTlPressed */ {KAknsIIDQsnFrListCornerTl, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x268b}, /*KAknsIIDQsnFrListCornerTlPressed*/ + /* SP_QsnFrListCornerTrPressed */ {KAknsIIDQsnFrListCornerTr, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x268c}, + /* SP_QsnFrListCornerBlPressed */ {KAknsIIDQsnFrListCornerBl, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x268d}, + /* SP_QsnFrListCornerBrPressed */ {KAknsIIDQsnFrListCornerBr, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x268e}, + /* SP_QsnFrListSideTPressed */ {KAknsIIDQsnFrListSideT, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x268f}, + /* SP_QsnFrListSideBPressed */ {KAknsIIDQsnFrListSideB, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2690}, + /* SP_QsnFrListSideLPressed */ {KAknsIIDQsnFrListSideL, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2691}, + /* SP_QsnFrListSideRPressed */ {KAknsIIDQsnFrListSideR, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2692}, + /* SP_QsnFrListPressed */ {KAknsIIDQsnFrList, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2693}, }; QPixmap QS60StyleModeSpecifics::skinnedGraphics( -- cgit v0.12 From 920b5381941ca0bed603158cbab958d172623612 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 13 Apr 2010 11:56:51 +0300 Subject: Make qmake possible to build with mingw using qmake.pro Added missing libraries Reviewed-by: Marius Storm-Olsen --- qmake/qmake.pri | 1 + 1 file changed, 1 insertion(+) diff --git a/qmake/qmake.pri b/qmake/qmake.pri index 05debe6..b82ab4d 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -130,6 +130,7 @@ bootstrap { #Qt code } else:win32 { SOURCES += qfsfileengine_win.cpp qfsfileengine_iterator_win.cpp qsettings_win.cpp win32-msvc*:LIBS += ole32.lib advapi32.lib + win32-g++:LIBS += -lole32 -luuid } qnx { -- cgit v0.12 From cbabeb657132b71b6ab5cfee18a7abace56982f3 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 13 Apr 2010 14:17:26 +0300 Subject: Export .flm files always if they are different There are valid cases where Qt .flm files found under /epoc32/tools/makefile_templates/qt/ have newer timestamp than those in Qt repo one is developing against but still need to be overwritten, so always export .flm files when the timestamp is different instead of just when the files to be exported are newer. Task-number: QT-3253 Reviewed-by: TrustMe --- qmake/generators/symbian/symmake_sbsv2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp index 1014ba2..9f3f5c3 100644 --- a/qmake/generators/symbian/symmake_sbsv2.cpp +++ b/qmake/generators/symbian/symmake_sbsv2.cpp @@ -75,7 +75,7 @@ void SymbianSbsv2MakefileGenerator::exportFlm() foreach(QFileInfo item, sourceInfos) { QFileInfo destInfo = QFileInfo(destDir.absolutePath() + "/" + item.fileName()); - if (!destInfo.exists() || destInfo.lastModified() < item.lastModified()) { + if (!destInfo.exists() || destInfo.lastModified() != item.lastModified()) { if (destInfo.exists()) QFile::remove(destInfo.absoluteFilePath()); if (QFile::copy(item.absoluteFilePath(), destInfo.absoluteFilePath())) -- cgit v0.12 From 914bc1cb6d29b9fda93be10e73bbcb15465cca8f Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 13 Apr 2010 14:25:21 +0200 Subject: Fix typos, there is no QT_NO_SSL Reviewed-by: thiago Reviewed-by: andreas --- src/network/ssl/qsslsocket_openssl_symbols.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 94cc9d2..8620e00 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -742,7 +742,7 @@ bool q_resolveOpenSslSymbols() bool q_resolveOpenSslSymbols() { -#ifdef QT_NO_SSL +#ifdef QT_NO_OPENSSL return false; #endif return true; -- cgit v0.12 From e090c7ff6c36557e3b0f739308147234978e9d2a Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 13 Apr 2010 15:28:05 +0300 Subject: Not possible to show selected text in virtual keyboard In Sym^3 when virtual keyboard is opened, text selection is not carried over from editor-like widget to the VKB. This is due that new implementation of AVKON FEP manager requires that clients indicate with editor flags that they can handle text selection. Task-number: QT-3277 Reviewed-by: Janne Anttila --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index cc60246..94036d0 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -58,6 +58,11 @@ // MAknEdStateObserver::EAknActivatePenInputRequest #define QT_EAknActivatePenInputRequest MAknEdStateObserver::EAknEdwinStateEvent(7) +// EAknEditorFlagSelectionVisible is only valid from 3.2 onwards. +// Sym^3 AVKON FEP manager expects that this flag is used for FEP-aware editors +// that support text selection. +#define QT_EAknEditorFlagSelectionVisible 0x100000 + QT_BEGIN_NAMESPACE QCoeFepInputContext::QCoeFepInputContext(QObject *parent) @@ -75,7 +80,10 @@ QCoeFepInputContext::QCoeFepInputContext(QObject *parent) m_hasTempPreeditString(false) { m_fepState->SetObjectProvider(this); - m_fepState->SetFlags(EAknEditorFlagDefault); + if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) + m_fepState->SetFlags(EAknEditorFlagDefault | QT_EAknEditorFlagSelectionVisible); + else + m_fepState->SetFlags(EAknEditorFlagDefault); m_fepState->SetDefaultInputMode( EAknEditorTextInputMode ); m_fepState->SetPermittedInputModes( EAknEditorAllInputModes ); m_fepState->SetDefaultCase( EAknEditorLowerCase ); @@ -432,7 +440,10 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) m_fepState->SetPermittedCases(flags); ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateCaseModeUpdate); - flags = 0; + if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) + flags = QT_EAknEditorFlagSelectionVisible; + else + flags = 0; if (hints & ImhUppercaseOnly && !(hints & ImhLowercaseOnly) || hints & ImhLowercaseOnly && !(hints & ImhUppercaseOnly)) { flags |= EAknEditorFlagFixedCase; -- cgit v0.12 From 058ba4d19b296464f87504bdc2a2076ee1368e57 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 12 Apr 2010 16:55:37 +0200 Subject: Make qsTr work in global scope Search up the call stack to find the first non-empty source URL. Also and add an autotest for the QtScript translator functions since there was none (their presence was checked, but not their behavior...). Task-number: QTBUG-9775 Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine.cpp | 16 +++++++-- tests/auto/qscriptengine/qscriptengine.pro | 1 + tests/auto/qscriptengine/qscriptengine.qrc | 5 +++ tests/auto/qscriptengine/translatable.js | 7 ++++ .../qscriptengine/translations/translatable_la.qm | Bin 0 -> 241 bytes .../qscriptengine/translations/translatable_la.ts | 34 ++++++++++++++++++ tests/auto/qscriptengine/tst_qscriptengine.cpp | 40 +++++++++++++++++++++ 7 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 tests/auto/qscriptengine/qscriptengine.qrc create mode 100644 tests/auto/qscriptengine/translatable.js create mode 100644 tests/auto/qscriptengine/translations/translatable_la.qm create mode 100644 tests/auto/qscriptengine/translations/translatable_la.ts diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 2422108..ccd3e56 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -41,6 +41,7 @@ #include #include +#include "CodeBlock.h" #include "Error.h" #include "JSArray.h" #include "JSLock.h" @@ -699,9 +700,18 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): third argument (n) must be a number"); #ifndef QT_NO_QOBJECT QString context; - QScriptContext *ctx = QScriptEnginePrivate::contextForFrame(exec); - if (ctx && ctx->parentContext()) - context = QFileInfo(QScriptContextInfo(ctx->parentContext()).fileName()).baseName(); + // The first non-empty source URL in the call stack determines the translation context. + { + JSC::ExecState *frame = exec->removeHostCallFrameFlag(); + while (frame) { + if (frame->codeBlock() && frame->codeBlock()->source() + && !frame->codeBlock()->source()->url().isEmpty()) { + context = QFileInfo(frame->codeBlock()->source()->url()).baseName(); + break; + } + frame = frame->callerFrame()->removeHostCallFrameFlag(); + } + } #endif QString text(args.at(0).toString(exec)); #ifndef QT_NO_QOBJECT diff --git a/tests/auto/qscriptengine/qscriptengine.pro b/tests/auto/qscriptengine/qscriptengine.pro index dd058a4..7d0f5d0 100644 --- a/tests/auto/qscriptengine/qscriptengine.pro +++ b/tests/auto/qscriptengine/qscriptengine.pro @@ -1,6 +1,7 @@ load(qttest_p4) QT = core gui script SOURCES += tst_qscriptengine.cpp +RESOURCES += qscriptengine.qrc wince* { DEFINES += SRCDIR=\\\"./\\\" diff --git a/tests/auto/qscriptengine/qscriptengine.qrc b/tests/auto/qscriptengine/qscriptengine.qrc new file mode 100644 index 0000000..b87f985 --- /dev/null +++ b/tests/auto/qscriptengine/qscriptengine.qrc @@ -0,0 +1,5 @@ + + + translations/translatable_la.qm + + diff --git a/tests/auto/qscriptengine/translatable.js b/tests/auto/qscriptengine/translatable.js new file mode 100644 index 0000000..0c948e7 --- /dev/null +++ b/tests/auto/qscriptengine/translatable.js @@ -0,0 +1,7 @@ +qsTr("One"); +qsTranslate("FooContext", "Two"); + +var greeting_strings = [ + QT_TR_NOOP("Hello"), + QT_TRANSLATE_NOOP("FooContext", "Goodbye") +]; diff --git a/tests/auto/qscriptengine/translations/translatable_la.qm b/tests/auto/qscriptengine/translations/translatable_la.qm new file mode 100644 index 0000000..03fcc52 Binary files /dev/null and b/tests/auto/qscriptengine/translations/translatable_la.qm differ diff --git a/tests/auto/qscriptengine/translations/translatable_la.ts b/tests/auto/qscriptengine/translations/translatable_la.ts new file mode 100644 index 0000000..3f631de --- /dev/null +++ b/tests/auto/qscriptengine/translations/translatable_la.ts @@ -0,0 +1,34 @@ + + + + + FooContext + + + Two + To + + + + Goodbye + Farvel + + + + translatable + + + One + En + + + + Hello + Hallo + + + Goodbye + Farvel + + + diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index f556fa1..aa5c85d 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -154,6 +154,7 @@ private slots: void incDecNonObjectProperty(); void installTranslatorFunctions_data(); void installTranslatorFunctions(); + void translateScript(); void functionScopes(); void nativeFunctionScopes(); void evaluateProgram(); @@ -4314,6 +4315,45 @@ void tst_QScriptEngine::installTranslatorFunctions() } } +void tst_QScriptEngine::translateScript() +{ + QScriptEngine engine; + + QTranslator translator; + translator.load(":/translations/translatable_la"); + QCoreApplication::instance()->installTranslator(&translator); + engine.installTranslatorFunctions(); + + QString fileName = QString::fromLatin1("translatable.js"); + // Top-level + QCOMPARE(engine.evaluate("qsTr('One')", fileName).toString(), QString::fromLatin1("En")); + QCOMPARE(engine.evaluate("qsTr('Hello')", fileName).toString(), QString::fromLatin1("Hallo")); + // From function + QCOMPARE(engine.evaluate("(function() { return qsTr('One'); })()", fileName).toString(), QString::fromLatin1("En")); + QCOMPARE(engine.evaluate("(function() { return qsTr('Hello'); })()", fileName).toString(), QString::fromLatin1("Hallo")); + // From eval + QCOMPARE(engine.evaluate("eval('qsTr(\\'One\\')')", fileName).toString(), QString::fromLatin1("En")); + QCOMPARE(engine.evaluate("eval('qsTr(\\'Hello\\')')", fileName).toString(), QString::fromLatin1("Hallo")); + + QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Two')", fileName).toString(), QString::fromLatin1("To")); + QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Goodbye')", fileName).toString(), QString::fromLatin1("Farvel")); + // From eval + QCOMPARE(engine.evaluate("eval('qsTranslate(\\'FooContext\\', \\'Two\\')')", fileName).toString(), QString::fromLatin1("To")); + QCOMPARE(engine.evaluate("eval('qsTranslate(\\'FooContext\\', \\'Goodbye\\')')", fileName).toString(), QString::fromLatin1("Farvel")); + + // Don't exist in translation + QCOMPARE(engine.evaluate("qsTr('Three')", fileName).toString(), QString::fromLatin1("Three")); + QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'So long')", fileName).toString(), QString::fromLatin1("So long")); + QCOMPARE(engine.evaluate("qsTranslate('BarContext', 'Goodbye')", fileName).toString(), QString::fromLatin1("Goodbye")); + + // From C++ + // There is no context, but it shouldn't crash + QCOMPARE(engine.globalObject().property("qsTr").call( + QScriptValue(), QScriptValueList() << "One").toString(), QString::fromLatin1("One")); + + QCoreApplication::instance()->removeTranslator(&translator); +} + void tst_QScriptEngine::functionScopes() { QScriptEngine eng; -- cgit v0.12 From 5a339d4de6bc12408149c51e8de96025fc80e5eb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 13 Apr 2010 15:41:09 +0200 Subject: Autotest: update location of fluke.gif on test server --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 890983e..038610d 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -4013,7 +4013,7 @@ public slots: } } void startOne() { - QUrl url = "http://" + QtNetworkSettings::serverName() + "/gif/fluke.gif"; + QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/fluke.gif"; QNetworkRequest request(url); QNetworkReply *reply = manager.get(request); reply->setParent(this); -- cgit v0.12 From 0678a400ad59b80f1a3e23d38e59685ed90d3210 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 13 Apr 2010 15:51:52 +0200 Subject: Autotest: update path location on the test server --- tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp | 2 +- tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp | 2 +- tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp index 3a3ea79..f86ba63 100644 --- a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -641,7 +641,7 @@ void tst_QHttpSocketEngine::downloadBigFile() QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState); - QVERIFY(tmpSocket->write("GET /mediumfile HTTP/1.0\r\n") > 0); + QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("Host: ") > 0); QVERIFY(tmpSocket->write(hostName.data()) > 0); QVERIFY(tmpSocket->write("\r\n") > 0); diff --git a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp index a679765..8f0cbc3 100644 --- a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -780,7 +780,7 @@ void tst_QSocks5SocketEngine::downloadBigFile() QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState); - QVERIFY(tmpSocket->write("GET /mediumfile HTTP/1.0\r\n") > 0); + QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("HOST: ") > 0); QVERIFY(tmpSocket->write(hostName.data()) > 0); QVERIFY(tmpSocket->write("\r\n") > 0); diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index ef7ff83..c6e4758 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -1116,7 +1116,7 @@ void tst_QTcpSocket::downloadBigFile() QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState); - QVERIFY(tmpSocket->write("GET /mediumfile HTTP/1.0\r\n") > 0); + QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("HOST: ") > 0); QVERIFY(tmpSocket->write(hostName.data()) > 0); QVERIFY(tmpSocket->write("\r\n") > 0); -- cgit v0.12 From 34cb9b282b14ba01df7266bdb3649a3e43ddd9f4 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 13 Apr 2010 16:07:45 +0200 Subject: QNAM HTTP: Do not pipeline with WebLogic servers --- src/network/access/qhttpnetworkconnectionchannel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index bc7684a..83b7d4c 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -690,6 +690,8 @@ void QHttpNetworkConnectionChannel::detectPipeliningSupport() && (serverHeaderField = reply->headerField("Server"), !serverHeaderField.contains("Microsoft-IIS/4.")) && (!serverHeaderField.contains("Microsoft-IIS/5.")) && (!serverHeaderField.contains("Netscape-Enterprise/3.")) + // this is adpoted from the knowledge of the Nokia 7.x browser team (DEF143319) + && (!serverHeaderField.contains("WebLogic")) ) { pipeliningSupported = QHttpNetworkConnectionChannel::PipeliningProbablySupported; } else { -- cgit v0.12 From a8094876e3c1194262b13313eee92cff3c0a0021 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 13 Apr 2010 16:46:58 +0200 Subject: tst_qftp: Attempting to reproduce a crash Task-number: QTBUG-7359 --- tests/auto/qftp/tst_qftp.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp index 638c810..2a42d6d 100644 --- a/tests/auto/qftp/tst_qftp.cpp +++ b/tests/auto/qftp/tst_qftp.cpp @@ -123,6 +123,8 @@ private slots: void doneSignal(); void queueMoreCommandsInDoneSlot(); + void qtbug7359Crash(); + protected slots: void stateChanged( int ); void listInfo( const QUrlInfo & ); @@ -2052,6 +2054,30 @@ void tst_QFtp::cdUpSlot(bool error) } } +void tst_QFtp::qtbug7359Crash() +{ + QFtp ftp; + ftp.connectToHost("127.0.0.1"); + + QTime t; + int elapsed; + + t.start(); + while ((elapsed = t.elapsed()) < 200) + QCoreApplication::processEvents(QEventLoop::AllEvents, 200 - elapsed); + + ftp.close(); + t.restart(); + while ((elapsed = t.elapsed()) < 1000) + QCoreApplication::processEvents(QEventLoop::AllEvents, 1000 - elapsed); + + ftp.connectToHost("127.0.0.1"); + + t.restart(); + while ((elapsed = t.elapsed()) < 2000) + QCoreApplication::processEvents(QEventLoop::AllEvents, 2000 - elapsed); +} + QTEST_MAIN(tst_QFtp) #include "tst_qftp.moc" -- cgit v0.12 From acbab8c493760467ce35ae2ef8d4a56f2bf327ae Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Tue, 13 Apr 2010 18:15:12 +0200 Subject: Fix QNX screen initialization Reviewed-by: Harald Fernengel --- src/gui/embedded/qscreenqnx_qws.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/embedded/qscreenqnx_qws.cpp b/src/gui/embedded/qscreenqnx_qws.cpp index 705db7e..a0a697f 100644 --- a/src/gui/embedded/qscreenqnx_qws.cpp +++ b/src/gui/embedded/qscreenqnx_qws.cpp @@ -205,7 +205,7 @@ static bool createMemSurface(QQnxScreenContext * const d, int w, int h) int ret = gf_surface_create(&d->memSurface, d->device, w, h, GF_FORMAT_ARGB8888, 0, GF_SURFACE_CREATE_CPU_FAST_ACCESS | GF_SURFACE_CREATE_CPU_LINEAR_ACCESSIBLE - | GF_SURFACE_PHYS_CONTIG); + | GF_SURFACE_PHYS_CONTIG | GF_SURFACE_CREATE_SHAREABLE); if (ret != GF_ERR_OK) { qWarning("QQnxScreen: gf_surface_create(%dx%d) failed with error code %d", w, h, ret); -- cgit v0.12 From 67f6618f887b3c524f9da58de8136d474881d29f Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 13 Apr 2010 18:16:02 +0200 Subject: Provide overview for Symbian capabilities. Each individual class which requires special capabilities is documented, but for finding out what to sign with, it's convenient to have it summarized in a single place. 0dcfe6f813d75da55c6183acac9a2cdfe2381594 is a related commit. Task-number: QTBUG-9342 Reviewed-by: Iain --- doc/src/platforms/platform-notes.qdoc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/src/platforms/platform-notes.qdoc b/doc/src/platforms/platform-notes.qdoc index f513181..131d035 100644 --- a/doc/src/platforms/platform-notes.qdoc +++ b/doc/src/platforms/platform-notes.qdoc @@ -502,6 +502,31 @@ For information about mixing exceptions with Symbian leaves, see \l{Exception Safety with Symbian}. + \section1 Required Capabilities + + Distributions of Qt are typically signed with \c{All -TCB}. What your + application needs to be signed with in order to function with Qt depends + on what functionality it uses: + + \table + \header \o Technology + \o Required Symbian Capability + \row \o QtCore + \o \c PowerMgmt if applications are terminated using QProcess. + \row \o QtNetwork + \o NetworkServices + \row \o QtMultiMedia + \o \c UserEnvironment if QAudioInput is used. + \endtable + + Depending on what file paths that are accessed and how AllFiles may be + required. Similarly, if the network is accessed indirectly through + components such as QtXmlPatterns, QtWebkit or QtScript, the capabilities + needs to match accordingly. + + See individual classes' documentation for specifics. If a class does not + mention Symbian capabilities, it requires none. + \section1 Multimedia and Phonon Support Qt provides a backend for Qt's Phonon module, which supports -- cgit v0.12 From 68037d915cb5f8070c89c70fe741982340def79e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 14 Apr 2010 14:04:48 +0200 Subject: Fix gcc compile warning in qstatictext.cpp Synchronize order of initialization with order of declaration. Reviewed-by: TrustMe --- src/gui/text/qstatictext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 6c504a7..06b0d3b 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -363,7 +363,7 @@ QSizeF QStaticText::size() const } QStaticTextPrivate::QStaticTextPrivate() - : items(0), itemCount(0), glyphPool(0), positionPool(0), textWidth(-1.0), + : textWidth(-1.0), items(0), itemCount(0), glyphPool(0), positionPool(0), needsRelayout(true), useBackendOptimizations(false), textFormat(Qt::AutoText) { } -- cgit v0.12 From 9ad274406a0f893f9a595aac7031deac2b25afbd Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 13 Apr 2010 12:40:35 +0200 Subject: Print more information when debugging X11 Visual selection Reviewed-By: TrustMe --- src/gui/egl/qegl_x11.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index 5341ea1..cb8dcda 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -210,6 +210,11 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config) } XFree(chosenVisualInfo); } +#ifdef QT_DEBUG_X11_VISUAL_SELECTION + else + qDebug("EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId); +#endif + if (visualId) { #ifdef QT_DEBUG_X11_VISUAL_SELECTION if (configAlphaSize > 0) @@ -263,6 +268,11 @@ VisualID QEgl::getCompatibleVisualId(EGLConfig config) # endif // QT_DEBUG_X11_VISUAL_SELECTION return visualId; } +# ifdef QT_DEBUG_X11_VISUAL_SELECTION + else + qDebug("Failed to find an XVisual which matches EGL config %d using XRender", configId); +# endif // QT_DEBUG_X11_VISUAL_SELECTION + #endif //!defined(QT_NO_XRENDER) -- cgit v0.12 From b331a74b8fd71ba803e2cf2a9e0c49e1d3538f40 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 13 Apr 2010 14:51:51 +0200 Subject: Support building with desktop OpenGL managed via EGL This mostly replaces lots of QT_OPENGL_ES defines with QT_NO_EGL instead. It also switches off EGL auto-detection by default. This is to make sure we default to using GLX on systems with both EGL and desktop OpenGL. If -opengl es1|es2 or -openvg is specified, then EGL auto-detection is switched back on (as a requirement. If configure auto-detects OpenGL ES it also switches on EGL auto-detection, but failue then just disables both EGL & OpenGL. As a side effect, this patch also fixes building Qt when both EGL and glx are avaliable, as they are in Mesa >= 7.8.0. Reviewed-by: Trond Task-number: QTBUG-9691 --- configure | 138 +++++++++++++++++++++++++---------------- src/gui/egl/qegl.cpp | 9 ++- src/gui/egl/qeglproperties.cpp | 27 +++++--- src/opengl/opengl.pro | 2 +- src/opengl/qgl.cpp | 8 +-- src/opengl/qgl.h | 2 +- src/opengl/qgl_p.h | 10 +-- src/opengl/qglpixelbuffer.cpp | 6 +- src/opengl/qglpixelbuffer_p.h | 12 ++-- 9 files changed, 130 insertions(+), 84 deletions(-) diff --git a/configure b/configure index 5478d06..a78e9ac 100755 --- a/configure +++ b/configure @@ -937,7 +937,7 @@ while [ "$#" -gt 0 ]; do VAL=no ;; #Qt style yes options - -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-carbon|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-mediaservice|-audio-backend|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config|-s60|-usedeffiles) + -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xsync|-xinput|-egl|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-carbon|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-multimedia|-mediaservice|-audio-backend|-svg|-declarative|-webkit|-javascript-jit|-script|-scripttools|-rpath|-force-pkg-config|-s60|-usedeffiles) VAR=`echo $1 | sed "s,^-\(.*\),\1,"` VAL=yes ;; @@ -1246,6 +1246,9 @@ while [ "$#" -gt 0 ]; do [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "es1" ] || [ "$VAL" = "es2" ]; then CFG_OPENGL="$VAL" + if [ "$VAL" = "es1" ] || [ "$VAL" = "es2" ]; then + CFG_EGL="yes" + fi else UNKNOWN_OPT=yes fi @@ -1253,6 +1256,7 @@ while [ "$#" -gt 0 ]; do openvg) if [ "$VAL" = "auto" ] || [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then CFG_OPENVG="$VAL" + CFG_EGL="auto" else UNKNOWN_OPT=yes fi @@ -1569,6 +1573,13 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; + egl) + if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then + CFG_EGL="$VAL" + else + UNKNOWN_OPT=yes + fi + ;; stl) if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then CFG_STL="$VAL" @@ -3810,6 +3821,12 @@ Qt/X11 only: -system-nas-sound .. Use NAS libaudio from the operating system. See http://radscan.com/nas.html + -egl ............... Use EGL instead of GLX to manage contexts. + When building for desktop OpenGL, this option will + make Qt use EGL to manage contexts rather than the + GLX, which is the default. Note: For OpenGL ES, EGL + is always used. + -no-opengl ......... Do not support OpenGL. + -opengl ...... Enable OpenGL support. With no parameter, this will auto-detect the "best" @@ -3817,8 +3834,6 @@ Qt/X11 only: will be used. Use desktop, es1, or es2 for to force the use of the Desktop (OpenGL 1.x or 2.x), OpenGL ES 1.x Common profile, or 2.x APIs instead. - On X11, the EGL API will be used to manage GL - contexts in the case of OpenGL ES -no-openvg ........ Do not support OpenVG. + -openvg ........... Enable OpenVG support. @@ -5121,26 +5136,6 @@ fi if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" ]; then - # detect EGL support - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/egl" "EGL (EGL/egl.h)" $L_FLAGS $I_FLAGS $l_FLAGS; then - # EGL specified by QMAKE_*_EGL, included with - CFG_EGL=yes - CFG_EGL_GLES_INCLUDES=no - elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/egl4gles1" "EGL (GLES/egl.h)" $L_FLAGS $I_FLAGS $l_FLAGS; then - # EGL specified by QMAKE_*_EGL, included with - CFG_EGL=yes - CFG_EGL_GLES_INCLUDES=yes - fi - if ( [ "$CFG_OPENGL" = "es1" ] || [ "$CFG_OPENGL" = "es2" ] ) && [ "$CFG_EGL" != "yes" ]; then - echo "The EGL functionality test failed!" - echo " EGL is required for OpenGL ES to manage contexts & surfaces." - echo " You might need to modify the include and library search paths by editing" - echo " QMAKE_INCDIR_EGL, QMAKE_LIBDIR_EGL and QMAKE_LIBS_EGL in" - echo " ${XQMAKESPEC}." - exit 1 - fi - - # auto-detect Glib support if [ "$CFG_GLIB" != "no" ]; then if [ -n "$PKG_CONFIG" ]; then @@ -5332,8 +5327,14 @@ if [ "$PLATFORM_X11" = "yes" ]; then CFG_OPENGL=desktop elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS; then CFG_OPENGL=es2 - elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS; then + if [ "$CFG_EGL" = "no" ]; then + CFG_EGL=auto + fi + elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS; then CFG_OPENGL=es1 + if [ "$CFG_EGL" = "no" ]; then + CFG_EGL=auto + fi else if [ "$CFG_OPENGL" = "yes" ]; then echo "All the OpenGL functionality tests failed!" @@ -5344,24 +5345,24 @@ if [ "$PLATFORM_X11" = "yes" ]; then fi CFG_OPENGL=no fi - case "$PLATFORM" in - hpux*) - # HP-UX have buggy glx headers; check if we really need to define the GLXFBConfig struct. - if [ "$CFG_OPENGL" = "desktop" ]; then - "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/glxfbconfig "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS - if [ $? != "0" ]; then - QMakeVar add DEFINES QT_DEFINE_GLXFBCONFIG_STRUCT - fi - fi - ;; - *) - ;; - esac + case "$PLATFORM" in + hpux*) + # HP-UX have buggy glx headers; check if we really need to define the GLXFBConfig struct. + if [ "$CFG_OPENGL" = "desktop" ]; then + "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/glxfbconfig "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS + if [ $? != "0" ]; then + QMakeVar add DEFINES QT_DEFINE_GLXFBCONFIG_STRUCT + fi + fi + ;; + *) + ;; + esac elif [ "$CFG_OPENGL" = "es1" ]; then # OpenGL ES 1.x - "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS + "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS if [ $? != "0" ]; then - echo "The OpenGL ES 1.x functionality test failed!" + echo "The OpenGL ES 1.x functionality test failed!" echo " You might need to modify the include and library search paths by editing" echo " QMAKE_INCDIR_OPENGL_ES1, QMAKE_LIBDIR_OPENGL_ES1 and QMAKE_LIBS_OPENGL_ES1 in" echo " ${XQMAKESPEC}." @@ -5369,9 +5370,9 @@ if [ "$PLATFORM_X11" = "yes" ]; then fi elif [ "$CFG_OPENGL" = "es2" ]; then #OpenGL ES 2.x - "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS + "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS if [ $? != "0" ]; then - echo "The OpenGL ES 2.0 functionality test failed!" + echo "The OpenGL ES 2.0 functionality test failed!" echo " You might need to modify the include and library search paths by editing" echo " QMAKE_INCDIR_OPENGL_ES2, QMAKE_LIBDIR_OPENGL_ES2 and QMAKE_LIBS_OPENGL_ES2 in" echo " ${XQMAKESPEC}." @@ -5381,7 +5382,7 @@ if [ "$PLATFORM_X11" = "yes" ]; then # Desktop OpenGL support "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/x11/opengl "OpenGL" $L_FLAGS $I_FLAGS $l_FLAGS $X11TESTS_FLAGS if [ $? != "0" ]; then - echo "The OpenGL functionality test failed!" + echo "The OpenGL functionality test failed!" echo " You might need to modify the include and library search paths by editing" echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" echo " ${XQMAKESPEC}." @@ -5394,7 +5395,7 @@ if [ "$PLATFORM_X11" = "yes" ]; then if [ $? != "0" ]; then QMakeVar add DEFINES QT_DEFINE_GLXFBCONFIG_STRUCT fi - ;; + ;; *) ;; esac @@ -5703,9 +5704,10 @@ if [ "$PLATFORM_QWS" = "yes" ]; then fi fi if [ "$CFG_OPENGL" = "yes" ]; then + CFG_EGL=auto if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS; then CFG_OPENGL=es2 - elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS; then + elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS; then CFG_OPENGL=es1 else echo "All the OpenGL ES functionality tests failed!" @@ -5716,24 +5718,26 @@ if [ "$PLATFORM_QWS" = "yes" ]; then fi elif [ "$CFG_OPENGL" = "es1" ]; then # OpenGL ES 1.x - "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS + "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles1 "OpenGL ES 1.x" $L_FLAGS $I_FLAGS $l_FLAGS if [ $? != "0" ]; then - echo "The OpenGL ES 1.x functionality test failed!" + echo "The OpenGL ES 1.x functionality test failed!" echo " You might need to modify the include and library search paths by editing" - echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" - echo " ${XQMAKESPEC}." + echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" + echo " ${XQMAKESPEC}." exit 1 fi + CFG_EGL=yes elif [ "$CFG_OPENGL" = "es2" ]; then #OpenGL ES 2.x - "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS + "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS if [ $? != "0" ]; then - echo "The OpenGL ES 2.0 functionality test failed!" + echo "The OpenGL ES 2.0 functionality test failed!" echo " You might need to modify the include and library search paths by editing" - echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" - echo " ${XQMAKESPEC}." + echo " QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in" + echo " ${XQMAKESPEC}." exit 1 fi + CFG_EGL=yes elif [ "$CFG_OPENGL" = "desktop" ]; then # Desktop OpenGL support echo "Desktop OpenGL support is not avaliable on Qt for Embedded Linux" @@ -5820,6 +5824,36 @@ if [ "$PLATFORM_QWS" = "yes" ]; then fi # QWS +# EGL Support +if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" ]; then + if [ "$CFG_EGL" != "no" ]; then + # detect EGL support + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/egl" "EGL (EGL/egl.h)" $L_FLAGS $I_FLAGS $l_FLAGS; then + # EGL specified by QMAKE_*_EGL, included with + CFG_EGL=yes + CFG_EGL_GLES_INCLUDES=no + elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/egl4gles1" "EGL (GLES/egl.h)" $L_FLAGS $I_FLAGS $l_FLAGS; then + # EGL specified by QMAKE_*_EGL, included with + CFG_EGL=yes + CFG_EGL_GLES_INCLUDES=yes + else + if [ "$CFG_EGL" = "yes" ]; then + echo "The EGL functionality test failed!" + echo " EGL is required for OpenGL ES to manage contexts & surfaces." + echo " You might need to modify the include and library search paths by editing" + echo " QMAKE_INCDIR_EGL, QMAKE_LIBDIR_EGL and QMAKE_LIBS_EGL in" + echo " ${XQMAKESPEC}." + exit 1 + fi + CFG_EGL=no + # If QtOpenGL would be built against OpenGL ES, disable it as we can't to that if EGL is missing + if [ "$CFG_OPENGL" = "es1" || "$CFG_OPENGL" = "es2" ]; then + CFG_OPENGL=no + fi + fi + fi +fi + # freetype support [ "x$CFG_EMBEDDED" != "xno" ] && CFG_LIBFREETYPE="$CFG_QWS_FREETYPE" [ "x$PLATFORM_MAC" = "xyes" ] && CFG_LIBFREETYPE=no diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 6f215cc..3b007d7 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -326,10 +326,17 @@ EGLSurface QEglContext::createSurface(QPaintDevice* device, const QEglProperties bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties *properties) { // We need to select the correct API before calling eglCreateContext(). +#ifdef QT_OPENGL_ES #ifdef EGL_OPENGL_ES_API if (apiType == QEgl::OpenGL) eglBindAPI(EGL_OPENGL_ES_API); #endif +#else +#ifdef EGL_OPENGL_API + if (apiType == QEgl::OpenGL) + eglBindAPI(EGL_OPENGL_API); +#endif +#endif //defined(QT_OPENGL_ES) #ifdef EGL_OPENVG_API if (apiType == QEgl::OpenVG) eglBindAPI(EGL_OPENVG_API); @@ -339,7 +346,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties QEglProperties contextProps; if (properties) contextProps = *properties; -#if defined(QT_OPENGL_ES_2) +#ifdef QT_OPENGL_ES_2 if (apiType == QEgl::OpenGL) contextProps.setValue(EGL_CONTEXT_CLIENT_VERSION, 2); #endif diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp index b5d3103..b34d2c3 100644 --- a/src/gui/egl/qeglproperties.cpp +++ b/src/gui/egl/qeglproperties.cpp @@ -80,19 +80,19 @@ int QEglProperties::value(int name) const case EGL_GREEN_SIZE: return 0; case EGL_BLUE_SIZE: return 0; case EGL_ALPHA_SIZE: return 0; -#if defined(EGL_LUMINANCE_SIZE) +#ifdef EGL_LUMINANCE_SIZE case EGL_LUMINANCE_SIZE: return 0; #endif -#if defined(EGL_ALPHA_MASK_SIZE) +#ifdef EGL_ALPHA_MASK_SIZE case EGL_ALPHA_MASK_SIZE: return 0; #endif -#if defined(EGL_BIND_TO_TEXTURE_RGB) +#ifdef EGL_BIND_TO_TEXTURE_RGB case EGL_BIND_TO_TEXTURE_RGB: return EGL_DONT_CARE; #endif -#if defined(EGL_BIND_TO_TEXTURE_RGBA) +#ifdef EGL_BIND_TO_TEXTURE_RGBA case EGL_BIND_TO_TEXTURE_RGBA: return EGL_DONT_CARE; #endif -#if defined(EGL_COLOR_BUFFER_TYPE) +#ifdef EGL_COLOR_BUFFER_TYPE case EGL_COLOR_BUFFER_TYPE: return EGL_RGB_BUFFER; #endif case EGL_CONFIG_CAVEAT: return EGL_DONT_CARE; @@ -103,7 +103,7 @@ int QEglProperties::value(int name) const case EGL_NATIVE_VISUAL_TYPE: return EGL_DONT_CARE; case EGL_MAX_SWAP_INTERVAL: return EGL_DONT_CARE; case EGL_MIN_SWAP_INTERVAL: return EGL_DONT_CARE; -#if defined(EGL_RENDERABLE_TYPE) +#ifdef EGL_RENDERABLE_TYPE case EGL_RENDERABLE_TYPE: return EGL_OPENGL_ES_BIT; #endif case EGL_SAMPLE_BUFFERS: return 0; @@ -115,7 +115,7 @@ int QEglProperties::value(int name) const case EGL_TRANSPARENT_GREEN_VALUE: return EGL_DONT_CARE; case EGL_TRANSPARENT_BLUE_VALUE: return EGL_DONT_CARE; -#if defined(EGL_VERSION_1_3) +#ifdef EGL_VERSION_1_3 case EGL_CONFORMANT: return 0; case EGL_MATCH_NATIVE_PIXMAP: return EGL_NONE; #endif @@ -215,15 +215,18 @@ void QEglProperties::setPixelFormat(QImage::Format pixelFormat) void QEglProperties::setRenderableType(QEgl::API api) { -#if defined(EGL_RENDERABLE_TYPE) +#ifdef EGL_RENDERABLE_TYPE #if defined(QT_OPENGL_ES_2) if (api == QEgl::OpenGL) setValue(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT); #elif defined(QT_OPENGL_ES) if (api == QEgl::OpenGL) setValue(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT); +#elif defined(EGL_OPENGL_BIT) + if (api == QEgl::OpenGL) + setValue(EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT); #endif -#if defined(EGL_OPENVG_BIT) +#ifdef EGL_OPENVG_BIT if (api == QEgl::OpenVG) setValue(EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT); #endif @@ -272,7 +275,7 @@ bool QEglProperties::reduceConfiguration() return true; if (removeValue(EGL_DEPTH_SIZE)) return true; -#if defined(EGL_BIND_TO_TEXTURE_RGB) +#ifdef EGL_BIND_TO_TEXTURE_RGB if (removeValue(EGL_BIND_TO_TEXTURE_RGB)) return true; #endif @@ -327,6 +330,10 @@ QString QEglProperties::toString() const if ((val & EGL_OPENGL_ES2_BIT) != 0) types += QLatin1String("es2"); #endif +#ifdef EGL_OPENGL_BIT + if ((val & EGL_OPENGL_BIT) != 0) + types += QLatin1String("gl"); +#endif if ((val & EGL_OPENVG_BIT) != 0) types += QLatin1String("vg"); if ((val & ~7) != 0) diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 9473343..15795d2 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -77,7 +77,7 @@ SOURCES += qgl.cpp \ } x11 { - contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2) { + contains(QT_CONFIG, egl) { SOURCES += qgl_x11egl.cpp \ qglpixelbuffer_egl.cpp \ qgl_egl.cpp \ diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 5595e02..4e1a63c 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -49,7 +49,7 @@ #include "private/qpixmap_x11_p.h" #define INT32 dummy_INT32 #define INT8 dummy_INT8 -#if !defined(QT_OPENGL_ES) +#ifdef QT_NO_EGL # include #endif #undef INT32 @@ -1582,7 +1582,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) # endif vi = 0; #endif -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL ownsEglContext = false; eglContext = 0; eglSurface = EGL_NO_SURFACE; @@ -3950,7 +3950,7 @@ bool QGLWidget::event(QEvent *e) } } -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL // A re-parent is likely to destroy the X11 window and re-create it. It is important // that we free the EGL surface _before_ the winID changes - otherwise we can leak. if (e->type() == QEvent::ParentAboutToChange) @@ -4909,7 +4909,7 @@ void QGLWidget::drawTexture(const QPointF &point, QMacCompatGLuint textureId, QM } #endif -#if !defined(QT_OPENGL_ES_1) +#ifndef QT_OPENGL_ES_1 Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_2_engine) #endif diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 64f54a3..b1e2ede 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -376,7 +376,7 @@ protected: #if defined(Q_WS_WIN) virtual int choosePixelFormat(void* pfd, HDC pdc); #endif -#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES) +#if defined(Q_WS_X11) && defined(QT_NO_EGL) virtual void* tryVisual(const QGLFormat& f, int bufDepth = 1); virtual void* chooseVisual(); #endif diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 1f28b08..ee580a6 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -64,7 +64,7 @@ #include "qcache.h" #include "qglpaintdevice_p.h" -#if defined(QT_OPENGL_ES) || defined(QT_OPENGL_ES_2) +#ifndef QT_NO_EGL #include #endif @@ -96,7 +96,7 @@ class QMacWindowChangeEvent; class QWSGLWindowSurface; #endif -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL class QEglContext; #endif @@ -164,7 +164,7 @@ public: #ifdef Q_WS_QWS , wsurf(0) #endif -#if defined(Q_WS_X11) && defined(QT_OPENGL_ES) +#if defined(Q_WS_X11) && !defined(QT_NO_EGL) , eglSurfaceWindowId(0) #endif { @@ -194,7 +194,7 @@ public: QGLContext *olcx; #elif defined(Q_WS_X11) QGLOverlayWidget *olw; -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL void recreateEglSurface(bool force); WId eglSurfaceWindowId; #endif @@ -344,7 +344,7 @@ public: HBITMAP hbitmap; HDC hbitmap_hdc; #endif -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL bool ownsEglContext; QEglContext *eglContext; EGLSurface eglSurface; diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index eca9550..9a8b243 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -137,14 +137,14 @@ void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &form #if defined(Q_WS_WIN) && !defined(QT_OPENGL_ES) qctx->d_func()->dc = dc; qctx->d_func()->rc = ctx; -#elif (defined(Q_WS_X11) && !defined(QT_OPENGL_ES)) +#elif (defined(Q_WS_X11) && defined(QT_NO_EGL)) qctx->d_func()->cx = ctx; qctx->d_func()->pbuf = (void *) pbuf; qctx->d_func()->vi = 0; #elif defined(Q_WS_MAC) qctx->d_func()->cx = ctx; qctx->d_func()->vi = 0; -#elif defined(QT_OPENGL_ES) +#elif !defined(QT_NO_EGL) qctx->d_func()->eglContext = ctx; qctx->d_func()->eglSurface = pbuf; #endif @@ -254,7 +254,7 @@ bool QGLPixelBuffer::doneCurrent() \sa size() */ -#if (defined(Q_WS_X11) || defined(Q_WS_WIN)) && !defined(QT_OPENGL_ES) +#if (defined(Q_WS_X11) || defined(Q_WS_WIN)) && defined(QT_NO_EGL) GLuint QGLPixelBuffer::generateDynamicTexture() const { Q_D(const QGLPixelBuffer); diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h index c85dc5a..2a1f671 100644 --- a/src/opengl/qglpixelbuffer_p.h +++ b/src/opengl/qglpixelbuffer_p.h @@ -60,7 +60,7 @@ QT_BEGIN_INCLUDE_NAMESPACE #include #include -#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES) +#if defined(Q_WS_X11) && defined(QT_NO_EGL) #include // The below is needed to for compilation on HPUX, due to broken GLX @@ -127,10 +127,8 @@ struct GLXFBConfig { #elif defined(Q_WS_WIN) DECLARE_HANDLE(HPBUFFERARB); -#elif defined(QT_OPENGL_ES_2) -#include -#elif defined(QT_OPENGL_ES) -#include +#elif !defined(QT_NO_EGL) +#include #endif QT_END_INCLUDE_NAMESPACE @@ -174,7 +172,7 @@ public: QPointer req_shareWidget; QSize req_size; -#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES) +#if defined(Q_WS_X11) && defined(QT_NO_EGL) GLXPbuffer pbuf; GLXContext ctx; #elif defined(Q_WS_WIN) @@ -195,7 +193,7 @@ public: AGLContext share_ctx; # endif #endif -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL EGLSurface pbuf; QEglContext *ctx; int textureFormat; -- cgit v0.12 From 91976b6bde42dd8c939591c01017208aaa670418 Mon Sep 17 00:00:00 2001 From: Carolina Gomes Date: Fri, 26 Mar 2010 12:10:36 -0300 Subject: QTBUG-6800 patch included, but only for OpenGL 2.0 Merge-request: 2344 Reviewed-by: Tom Cooksey --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 11 ++++++++- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 2 ++ src/opengl/qgl.cpp | 27 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 0cc7430..0ef9204 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -510,12 +510,19 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } +bool QGL2PaintEngineEx::isNativePaintingActive() +{ + return nativePaintingActive; +} + void QGL2PaintEngineEx::beginNativePainting() { Q_D(QGL2PaintEngineEx); ensureActive(); d->transferMode(BrushDrawingMode); + nativePaintingActive = true; + QGLContext *ctx = d->ctx; glUseProgram(0); @@ -583,6 +590,7 @@ void QGL2PaintEngineEx::endNativePainting() { Q_D(QGL2PaintEngineEx); d->needsSync = true; + nativePaintingActive = false; } void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) @@ -1101,7 +1109,8 @@ void QGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stops, i /////////////////////////////////// Public Methods ////////////////////////////////////////// QGL2PaintEngineEx::QGL2PaintEngineEx() - : QPaintEngineEx(*(new QGL2PaintEngineExPrivate(this))) + : QPaintEngineEx(*(new QGL2PaintEngineExPrivate(this))), + nativePaintingActive(false) { } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 34d72d1..e91d7ac 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -154,8 +154,10 @@ public: void setRenderTextActive(bool); + bool isNativePaintingActive(); private: Q_DISABLE_COPY(QGL2PaintEngineEx) + bool nativePaintingActive; }; diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 4e1a63c..848982d 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2767,6 +2767,19 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text return; } #else + + if (d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { + QGL2PaintEngineEx *eng = static_cast(d_ptr->active_engine); + //qDebug() << "Paint Engine is OpenGL2"; + if (eng->isNativePaintingActive() == false) { + //qDebug() << "No usage of begin/endNativePainting()"; + QRectF src = QRectF(0, 0, target.width(), target.height()); + QSize size = QSize(target.width(), target.height()); + eng->drawTexture(target, textureId, size, src); + return; + } + } + const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D); GLint oldTexture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture); @@ -2817,6 +2830,7 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text Q_UNUSED(textureTarget); qWarning("drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) not supported with OpenGL ES, use rect version instead"); #else + const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D); GLint oldTexture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture); @@ -2830,6 +2844,19 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth); glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight); + if (d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { + QGL2PaintEngineEx *eng = static_cast(d_ptr->active_engine); + //qDebug() << "Paint Engine is OpenGL2"; + if (eng->isNativePaintingActive() == false) { + //qDebug() << "No usage of begin/endNativePainting()"; + QRectF dest = QRectF(point, QSizeF(textureWidth, textureHeight)); + QRectF src = QRectF(0, 0, textureWidth, textureHeight); + QSize size = QSize(textureWidth, textureHeight); + eng->drawTexture(dest, textureId, size, src); + return; + } + } + qDrawTextureRect(QRectF(point, QSizeF(textureWidth, textureHeight)), textureWidth, textureHeight, textureTarget); if (!wasEnabled) -- cgit v0.12 From 65536764c06200762ea6308703eae7ee3df17b15 Mon Sep 17 00:00:00 2001 From: Carolina Gomes Date: Sat, 27 Mar 2010 01:06:41 -0300 Subject: Adjustments to QTBUG-6800 patch. Merge-request: 2344 Reviewed-by: Tom Cooksey --- src/opengl/qgl.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 848982d..c20c058 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2768,11 +2768,10 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text } #else - if (d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { - QGL2PaintEngineEx *eng = static_cast(d_ptr->active_engine); - //qDebug() << "Paint Engine is OpenGL2"; - if (eng->isNativePaintingActive() == false) { - //qDebug() << "No usage of begin/endNativePainting()"; + if (d_ptr->active_engine && + d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { + QGL2PaintEngineEx *eng = static_cast(d_ptr->active_engine); + if (eng->isNativePaintingActive() == false) { QRectF src = QRectF(0, 0, target.width(), target.height()); QSize size = QSize(target.width(), target.height()); eng->drawTexture(target, textureId, size, src); @@ -2844,11 +2843,10 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth); glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight); - if (d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { + if (d_ptr->active_engine && + d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { QGL2PaintEngineEx *eng = static_cast(d_ptr->active_engine); - //qDebug() << "Paint Engine is OpenGL2"; if (eng->isNativePaintingActive() == false) { - //qDebug() << "No usage of begin/endNativePainting()"; QRectF dest = QRectF(point, QSizeF(textureWidth, textureHeight)); QRectF src = QRectF(0, 0, textureWidth, textureHeight); QSize size = QSize(textureWidth, textureHeight); -- cgit v0.12 From 131f634a2595ca7910c34bd07c311aea9de2bb62 Mon Sep 17 00:00:00 2001 From: Carolina Gomes Date: Mon, 29 Mar 2010 00:34:12 -0300 Subject: More adjustments to QTBUG-6800 Merge-request: 2344 Reviewed-by: Tom Cooksey --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 5 ----- src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 5 ++++- src/opengl/qgl.cpp | 14 +++++++------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 0ef9204..0534233 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -510,11 +510,6 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } -bool QGL2PaintEngineEx::isNativePaintingActive() -{ - return nativePaintingActive; -} - void QGL2PaintEngineEx::beginNativePainting() { Q_D(QGL2PaintEngineEx); diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index e91d7ac..0538107 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -154,12 +154,15 @@ public: void setRenderTextActive(bool); - bool isNativePaintingActive(); + bool isNativePaintingActive() const; private: Q_DISABLE_COPY(QGL2PaintEngineEx) bool nativePaintingActive; }; +inline bool QGL2PaintEngineEx::isNativePaintingActive() const { + return nativePaintingActive; +} class QGL2PaintEngineExPrivate : public QPaintEngineExPrivate { diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index c20c058..394bcbc 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2771,9 +2771,9 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text if (d_ptr->active_engine && d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { QGL2PaintEngineEx *eng = static_cast(d_ptr->active_engine); - if (eng->isNativePaintingActive() == false) { - QRectF src = QRectF(0, 0, target.width(), target.height()); - QSize size = QSize(target.width(), target.height()); + if (!eng->isNativePaintingActive()) { + QRectF src(0, 0, target.width(), target.height()); + QSize size(target.width(), target.height()); eng->drawTexture(target, textureId, size, src); return; } @@ -2846,10 +2846,10 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text if (d_ptr->active_engine && d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { QGL2PaintEngineEx *eng = static_cast(d_ptr->active_engine); - if (eng->isNativePaintingActive() == false) { - QRectF dest = QRectF(point, QSizeF(textureWidth, textureHeight)); - QRectF src = QRectF(0, 0, textureWidth, textureHeight); - QSize size = QSize(textureWidth, textureHeight); + if (!eng->isNativePaintingActive()) { + QRectF dest(point, QSizeF(textureWidth, textureHeight)); + QRectF src(0, 0, textureWidth, textureHeight); + QSize size(textureWidth, textureHeight); eng->drawTexture(dest, textureId, size, src); return; } -- cgit v0.12 From 78dd32bce0cab27474faafd149bac99b4197f124 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 14 Apr 2010 15:29:03 +0200 Subject: Move nativePaintingActive flag to GL2 engine's private Reviewed-By: Samuel --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 12 ++++++++---- src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 7 ++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 0534233..c89d34f 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -516,7 +516,7 @@ void QGL2PaintEngineEx::beginNativePainting() ensureActive(); d->transferMode(BrushDrawingMode); - nativePaintingActive = true; + d->nativePaintingActive = true; QGLContext *ctx = d->ctx; glUseProgram(0); @@ -585,7 +585,12 @@ void QGL2PaintEngineEx::endNativePainting() { Q_D(QGL2PaintEngineEx); d->needsSync = true; - nativePaintingActive = false; + d->nativePaintingActive = false; +} + +bool QGL2PaintEngineEx::isNativePaintingActive() const { + Q_D(const QGL2PaintEngineEx); + return d->nativePaintingActive; } void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) @@ -1104,8 +1109,7 @@ void QGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stops, i /////////////////////////////////// Public Methods ////////////////////////////////////////// QGL2PaintEngineEx::QGL2PaintEngineEx() - : QPaintEngineEx(*(new QGL2PaintEngineExPrivate(this))), - nativePaintingActive(false) + : QPaintEngineEx(*(new QGL2PaintEngineExPrivate(this))) { } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 0538107..2ac2ca4 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -157,13 +157,8 @@ public: bool isNativePaintingActive() const; private: Q_DISABLE_COPY(QGL2PaintEngineEx) - bool nativePaintingActive; }; -inline bool QGL2PaintEngineEx::isNativePaintingActive() const { - return nativePaintingActive; -} - class QGL2PaintEngineExPrivate : public QPaintEngineExPrivate { Q_DECLARE_PUBLIC(QGL2PaintEngineEx) @@ -183,6 +178,7 @@ public: elementIndicesVBOId(0), snapToPixelGrid(false), addOffset(false), + nativePaintingActive(false), inverseScale(1), lastMaskTextureUsed(0) { } @@ -285,6 +281,7 @@ public: bool snapToPixelGrid; bool addOffset; // When enabled, adds a 0.49,0.49 offset to matrix in updateMatrix + bool nativePaintingActive; GLfloat pmvMatrix[3][3]; GLfloat inverseScale; -- cgit v0.12 From d20bf43e3f7b3d39fddd28eee5a5594de6930873 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 15 Apr 2010 13:40:12 +1000 Subject: Fix compilation of ShivaVG, which does not have EGL. Task-number: QTBUG-9809 Reviewed-by: Sarah Smith --- src/openvg/qpixmapdata_vg.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index 5c4f41b..168f06a 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -42,7 +42,9 @@ #include "qpixmapdata_vg_p.h" #include "qpaintengine_vg_p.h" #include +#if !defined(QT_NO_EGL) #include +#endif #include "qvg_p.h" #include "qvgimagepool_p.h" -- cgit v0.12 From f6f030cfff44f4625fd7655f3401651c0ecc760b Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 14:48:58 +1000 Subject: Remove unused parameter --- src/declarative/qml/qdeclarativecomponent.cpp | 2 +- src/declarative/qml/qdeclarativecomponent_p.h | 4 ++-- src/declarative/qml/qdeclarativeengine.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 1903006..7744b75 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -671,7 +671,7 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *ctxt, QDe return rv; } -void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeContextData *, QDeclarativeEnginePrivate *enginePriv, +void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeEnginePrivate *enginePriv, QObject *object, ConstructionState *state) { bool isRoot = !enginePriv->inBeginCreate; diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h index dfe327b..dfd0fc3 100644 --- a/src/declarative/qml/qdeclarativecomponent_p.h +++ b/src/declarative/qml/qdeclarativecomponent_p.h @@ -111,8 +111,8 @@ public: static QObject *begin(QDeclarativeContextData *ctxt, QDeclarativeEnginePrivate *enginePriv, QDeclarativeCompiledData *component, int start, int count, ConstructionState *state, const QBitField &bindings = QBitField()); - static void beginDeferred(QDeclarativeContextData *ctxt, QDeclarativeEnginePrivate *enginePriv, - QObject *object, ConstructionState *state); + static void beginDeferred(QDeclarativeEnginePrivate *enginePriv, QObject *object, + ConstructionState *state); static void complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state); QDeclarativeEngine *engine; diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index ae0929b..a478bf5 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -767,7 +767,7 @@ void qmlExecuteDeferred(QObject *object) QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(data->context->engine); QDeclarativeComponentPrivate::ConstructionState state; - QDeclarativeComponentPrivate::beginDeferred(data->context, ep, object, &state); + QDeclarativeComponentPrivate::beginDeferred(ep, object, &state); data->deferredComponent->release(); data->deferredComponent = 0; -- cgit v0.12 From 6362d17d5551749618f5975e050c54fca31c408f Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 14:54:01 +1000 Subject: Comments --- src/declarative/qml/qdeclarativedata_p.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h index 3676d8d..2ddd7e5 100644 --- a/src/declarative/qml/qdeclarativedata_p.h +++ b/src/declarative/qml/qdeclarativedata_p.h @@ -100,7 +100,9 @@ public: quint32 explicitIndestructibleSet:1; quint32 dummy:28; - QDeclarativeContextData *context; + // The context that created the C++ object + QDeclarativeContextData *context; + // The outermost context in which this object lives QDeclarativeContextData *outerContext; QDeclarativeAbstractBinding *bindings; -- cgit v0.12 From c24d3ce5d268e6e91bcecb155e4e2f5bd9c7dadd Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 15 Apr 2010 16:17:39 +1000 Subject: Use qmlInfo for image loading errors, not qWarning(). Task-number: QTBUG-9908 --- .../graphicsitems/qdeclarativeborderimage.cpp | 26 +++++++++++++---- .../graphicsitems/qdeclarativeimagebase.cpp | 10 +++++-- src/declarative/graphicsitems/qdeclarativetext.cpp | 14 +++++++-- src/declarative/util/qdeclarativepixmapcache.cpp | 34 +++++++++++++++------- src/declarative/util/qdeclarativepixmapcache_p.h | 3 +- src/imports/particles/qdeclarativeparticles.cpp | 10 +++++-- .../tst_qdeclarativeborderimage.cpp | 4 +-- .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 9 +++--- .../tst_qdeclarativeimageprovider.cpp | 8 +++-- .../tst_qdeclarativepixmapcache.cpp | 23 +++++++++------ .../qdeclarativetext/tst_qdeclarativetext.cpp | 4 +-- 11 files changed, 101 insertions(+), 44 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 420ed90..be9d8bd 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -43,6 +43,7 @@ #include "private/qdeclarativeborderimage_p_p.h" #include +#include #include #include @@ -218,7 +219,8 @@ void QDeclarativeBorderImage::load() } } else { QSize impsize; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url); d->pendingPixmapCache = true; @@ -230,8 +232,10 @@ void QDeclarativeBorderImage::load() setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); - if (d->pix.isNull()) + if (d->pix.isNull()) { d->status = Error; + qmlInfo(this) << errorString; + } if (d->status == Loading) d->status = Ready; d->progress = 1.0; @@ -338,7 +342,8 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); QSize impsize; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->sciurl, &d->pix, &impsize, d->async); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->sciurl, &d->pix, &errorString, &impsize, d->async); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->sciurl); d->sciPendingPixmapCache = true; @@ -367,8 +372,10 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); - if (d->pix.isNull()) + if (d->pix.isNull()) { d->status = Error; + qmlInfo(this) << errorString; + } if (d->status == Loading) d->status = Ready; d->progress = 1.0; @@ -386,11 +393,18 @@ void QDeclarativeBorderImage::requestFinished() QSize impsize; if (d->url.path().endsWith(QLatin1String(".sci"))) { d->sciPendingPixmapCache = false; - QDeclarativePixmapCache::get(d->sciurl, &d->pix, &impsize, d->async); + QString errorString; + if (QDeclarativePixmapCache::get(d->sciurl, &d->pix, &errorString, &impsize, d->async) != QDeclarativePixmapReply::Ready) { + d->status = Error; + qmlInfo(this) << errorString; + } } else { d->pendingPixmapCache = false; - if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async) != QDeclarativePixmapReply::Ready) + QString errorString; + if (QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async) != QDeclarativePixmapReply::Ready) { d->status = Error; + qmlInfo(this) << errorString; + } } setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp index 3acafe8..c3f8195 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp @@ -43,6 +43,7 @@ #include "private/qdeclarativeimagebase_p_p.h" #include +#include #include #include @@ -154,7 +155,8 @@ void QDeclarativeImageBase::load() int reqwidth = d->sourcesize.width(); int reqheight = d->sourcesize.height(); QSize impsize; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, reqwidth, reqheight); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async, reqwidth, reqheight); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url, reqwidth, reqheight); d->pendingPixmapCache = true; @@ -191,6 +193,7 @@ void QDeclarativeImageBase::load() emit sourceSizeChanged(); } else { d->status = Error; + qmlInfo(this) << errorString; } d->progress = 1.0; emit statusChanged(d->status); @@ -210,8 +213,11 @@ void QDeclarativeImageBase::requestFinished() d->pendingPixmapCache = false; QSize impsize; - if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, d->sourcesize.width(), d->sourcesize.height()) != QDeclarativePixmapReply::Ready) + QString errorString; + if (QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async, d->sourcesize.width(), d->sourcesize.height()) != QDeclarativePixmapReply::Ready) { d->status = Error; + qmlInfo(this) << errorString; + } setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 3b39fa4..9fcfd92 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -75,10 +76,16 @@ protected: if (type == QTextDocument::ImageResource) { QPixmap pm; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(url, &pm, 0, true, 0, 0); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(url, &pm, &errorString, 0, true, 0, 0); if (status == QDeclarativePixmapReply::Ready) return pm; - if (status != QDeclarativePixmapReply::Error) { + if (status == QDeclarativePixmapReply::Error) { + if (!errors.contains(url)) { + errors.insert(url); + qmlInfo(parent()) << errorString; + } + } else { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(parent()), url); connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); outstanding++; @@ -98,8 +105,11 @@ private slots: private: int outstanding; + static QSet errors; }; +QSet QTextDocumentWithImageResources::errors; + /*! \qmlclass Text QDeclarativeText \since 4.7 diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index 5e60819..4a96a2a 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -194,8 +194,8 @@ static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *e return true; } else { if (errorString) - *errorString = QLatin1String("Error decoding: ") + url.toString() - + QLatin1String(" \"") + imgio.errorString() + QLatin1String("\""); + *errorString = QDeclarativeImageRequestHandler::tr("Error decoding: %1: %2").arg(url.toString()) + .arg(imgio.errorString()); return false; } } @@ -264,7 +264,7 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event) QString errorStr; if (image.isNull()) { errorCode = QDeclarativeImageReaderEvent::Loading; - errorStr = QLatin1String("Failed to get image from provider: ") + url.toString(); + errorStr = QDeclarativeImageRequestHandler::tr("Failed to get image from provider: %1").arg(url.toString()); } QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image)); } else { @@ -283,7 +283,7 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event) errorCode = QDeclarativeImageReaderEvent::Loading; } } else { - errorStr = QLatin1String("Cannot open: ") + url.toString(); + errorStr = QDeclarativeImageRequestHandler::tr("Cannot open: %1").arg(url.toString()); errorCode = QDeclarativeImageReaderEvent::Loading; } QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image)); @@ -460,6 +460,7 @@ public: bool loading; QDeclarativeImageReader *reader; int forced_width, forced_height; + QString errorString; }; @@ -511,7 +512,7 @@ bool QDeclarativePixmapReply::event(QEvent *event) if (d->status == Ready) d->pixmap = QPixmap::fromImage(de->image); else - qWarning() << de->errorString; + d->errorString = de->errorString; QByteArray key = d->url.toEncoded(QUrl::FormattingOption(0x100)); QString strKey = QString::fromLatin1(key.constData(), key.count()); QPixmapCache::insert(strKey, d->pixmap); // note: may fail (returns false) @@ -523,6 +524,12 @@ bool QDeclarativePixmapReply::event(QEvent *event) return QObject::event(event); } +QString QDeclarativePixmapReply::errorString() const +{ + Q_D(const QDeclarativePixmapReply); + return d->errorString; +} + QDeclarativePixmapReply::Status QDeclarativePixmapReply::status() const { Q_D(const QDeclarativePixmapReply); @@ -586,7 +593,7 @@ bool QDeclarativePixmapReply::release(bool defer) Note that images sourced from the network will always be loaded and decoded asynchonously. */ -QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QPixmap *pixmap, QSize *impsize, bool async, int req_width, int req_height) +QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QPixmap *pixmap, QString *errorString, QSize *impsize, bool async, int req_width, int req_height) { QDeclarativePixmapReply::Status status = QDeclarativePixmapReply::Unrequested; QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100)); @@ -609,17 +616,16 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP QFile f(lf); QSize read_impsize; if (f.open(QIODevice::ReadOnly)) { - QString errorString; QImage image; - if (readImage(url, &f, &image, &errorString, &read_impsize, req_width, req_height)) { + if (readImage(url, &f, &image, errorString, &read_impsize, req_width, req_height)) { *pixmap = QPixmap::fromImage(image); } else { - qWarning() << errorString; *pixmap = QPixmap(); status = QDeclarativePixmapReply::Error; } } else { - qWarning() << "Cannot open" << url; + if (errorString) + *errorString = QDeclarativeImageRequestHandler::tr("Cannot open: %1").arg(url.toString()); *pixmap = QPixmap(); status = QDeclarativePixmapReply::Error; } @@ -650,9 +656,15 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP } else if (QPixmapCache::find(strKey, pixmap)) { if (iter != qmlActivePixmapReplies()->end()) { status = (*iter)->status(); + if (errorString) + *errorString = (*iter)->errorString(); (*iter)->release(); + } else if (pixmap->isNull()) { + status = QDeclarativePixmapReply::Error; + if (errorString) + *errorString = QDeclarativeImageRequestHandler::tr("Unknown Error loading %1").arg(url); } else { - status = pixmap->isNull() ? QDeclarativePixmapReply::Error : QDeclarativePixmapReply::Ready; + status = QDeclarativePixmapReply::Ready; } } else if (iter != qmlActivePixmapReplies()->end()) { status = QDeclarativePixmapReply::Loading; diff --git a/src/declarative/util/qdeclarativepixmapcache_p.h b/src/declarative/util/qdeclarativepixmapcache_p.h index df71d65..7b94728 100644 --- a/src/declarative/util/qdeclarativepixmapcache_p.h +++ b/src/declarative/util/qdeclarativepixmapcache_p.h @@ -64,6 +64,7 @@ public: enum Status { Ready, Error, Unrequested, Loading }; Status status() const; + QString errorString() const; const QUrl &url() const; int forcedWidth() const; @@ -95,7 +96,7 @@ private: class Q_DECLARATIVE_EXPORT QDeclarativePixmapCache { public: - static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, QSize *impsize=0, bool async=false, int req_width=0, int req_height=0); + static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, QString *errorString, QSize *impsize=0, bool async=false, int req_width=0, int req_height=0); static QDeclarativePixmapReply *request(QDeclarativeEngine *, const QUrl& url, int req_width=0, int req_height=0); static void cancel(const QUrl& url, QObject *obj); static int pendingRequests(); diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp index d17a8a1..264cba2 100644 --- a/src/imports/particles/qdeclarativeparticles.cpp +++ b/src/imports/particles/qdeclarativeparticles.cpp @@ -41,6 +41,7 @@ #include "qdeclarativeparticles_p.h" +#include #include #include @@ -730,7 +731,9 @@ void QDeclarativeParticles::imageLoaded() { Q_D(QDeclarativeParticles); d->pendingPixmapCache = false; - QDeclarativePixmapCache::get(d->url, &d->image); + QString errorString; + if (QDeclarativePixmapCache::get(d->url, &d->image, &errorString)==QDeclarativePixmapReply::Error) + qmlInfo(this) << errorString; d->paintItem->updateSize(); d->paintItem->update(); } @@ -754,12 +757,15 @@ void QDeclarativeParticles::setSource(const QUrl &name) } else { d->url = name; Q_ASSERT(!name.isRelative()); - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->image); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->image, &errorString); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url); connect(reply, SIGNAL(finished()), this, SLOT(imageLoaded())); d->pendingPixmapCache = true; } else { + if (status == QDeclarativePixmapReply::Error) + qmlInfo(this) << errorString; //### unify with imageLoaded d->paintItem->updateSize(); d->paintItem->update(); diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp index 0f03527..8621239 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp +++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp @@ -121,10 +121,10 @@ void tst_qdeclarativeborderimage::imageSource_data() QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << ""; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false - << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) "; + << "QML BorderImage (file::2:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString(); QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true - << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; + << "QML BorderImage (file::2:1) Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; } void tst_qdeclarativeborderimage::imageSource() diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 53c208e..854bcdd 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -124,13 +124,14 @@ void tst_qdeclarativeimage::imageSource_data() QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << 120.0 << 120.0 << false << false << ""; QTest::newRow("local async") << QUrl::fromLocalFile(SRCDIR "/data/colors1.png").toString() << 120.0 << 120.0 << false << true << ""; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << 0.0 << 0.0 << false - << false << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) "; + << false << "QML Image (file::2:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString(); QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << 0.0 << 0.0 << false - << true << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() + "\" "; + << true << "QML Image (file::2:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString(); QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << ""; QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << ""; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true << false - << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; + QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true + << false << "QML Image (file::2:1) Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; + } void tst_qdeclarativeimage::imageSource() diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index 162c266..aca951b 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -96,9 +96,10 @@ void tst_qdeclarativeimageprovider::imageSource_data() QTest::newRow("exists") << "image://test/exists.png" << "" << QSize(100,100) << ""; QTest::newRow("scaled") << "image://test/exists.png" << "sourceSize: \"80x30\"" << QSize(80,30) << ""; QTest::newRow("missing") << "image://test/no-such-file.png" << "" << QSize() - << "\"Failed to get image from provider: image://test/no-such-file.png\" "; + << "QML Image (file::2:1) Failed to get image from provider: image://test/no-such-file.png"; QTest::newRow("unknown provider") << "image://bogus/exists.png" << "" << QSize() - << "\"Failed to get image from provider: image://bogus/exists.png\" "; + << "QML Image (file::2:1) Failed to get image from provider: image://bogus/exists.png"; + } void tst_qdeclarativeimageprovider::imageSource() @@ -157,7 +158,8 @@ void tst_qdeclarativeimageprovider::removeProvider() QCOMPARE(obj->width(), 100.0); // remove the provider and confirm - QString error("\"Failed to get image from provider: image://test2/exists2.png\" "); + QString error("QML Image (file::2:1) Failed to get image from provider: image://test2/exists2.png"); + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); engine.removeImageProvider("test2"); diff --git a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp index f2ccf80..0cc13ad 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp +++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp @@ -126,19 +126,20 @@ void tst_qdeclarativepixmapcache::single() QFETCH(bool, exists); QFETCH(bool, neterror); + QString expectedError; if (neterror) { - QString expected = "\"Error downloading " + target.toString() + " - server replied: Not found\" "; - QTest::ignoreMessage(QtWarningMsg, expected.toLatin1()); + expectedError = "Error downloading " + target.toString() + " - server replied: Not found"; } else if (!exists) { - QString expected = "Cannot open QUrl( \"" + target.toString() + "\" ) "; - QTest::ignoreMessage(QtWarningMsg, expected.toLatin1()); + expectedError = "Cannot open: " + target.toString(); } QPixmap pixmap; QVERIFY(pixmap.width() <= 0); // Check Qt assumption - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap, &errorString); if (incache) { + QCOMPARE(errorString, expectedError); if (exists) { QVERIFY(status == QDeclarativePixmapReply::Ready); QVERIFY(pixmap.width() > 0); @@ -156,13 +157,15 @@ void tst_qdeclarativepixmapcache::single() QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(getter.gotslot); + QString errorString; if (exists) { - QVERIFY(QDeclarativePixmapCache::get(target, &pixmap) == QDeclarativePixmapReply::Ready); + QVERIFY(QDeclarativePixmapCache::get(target, &pixmap, &errorString) == QDeclarativePixmapReply::Ready); QVERIFY(pixmap.width() > 0); } else { - QVERIFY(QDeclarativePixmapCache::get(target, &pixmap) == QDeclarativePixmapReply::Error); + QVERIFY(QDeclarativePixmapCache::get(target, &pixmap, &errorString) == QDeclarativePixmapReply::Error); QVERIFY(pixmap.width() <= 0); } + QCOMPARE(errorString, expectedError); } QCOMPARE(QDeclarativePixmapCache::pendingRequests(), 0); @@ -236,7 +239,8 @@ void tst_qdeclarativepixmapcache::parallel() for (int i=0; igotslot); QPixmap pixmap; - QVERIFY(QDeclarativePixmapCache::get(targets[i], &pixmap) == QDeclarativePixmapReply::Ready); + QString errorString; + QVERIFY(QDeclarativePixmapCache::get(targets[i], &pixmap, &errorString) == QDeclarativePixmapReply::Ready); QVERIFY(pixmap.width() > 0); } delete getters[i]; diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 53640d0..ca7dfe7 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -871,10 +871,10 @@ void tst_qdeclarativetext::embeddedImages_data() QTest::addColumn("error"); QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocal.qml") << ""; QTest::newRow("local-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml") - << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/http/notexists.png").toString() + "\" "; + << "QML Text ("+QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml").toString()+":3:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/http/notexists.png").toString(); QTest::newRow("remote") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemote.qml") << ""; QTest::newRow("remote-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml") - << "\"Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found\" "; + << "QML Text ("+QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml").toString()+":3:1) Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found"; } void tst_qdeclarativetext::embeddedImages() -- cgit v0.12 From 30a3e78a12b72ab6f67992ec2f06cd4f21a01a6c Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 16:35:51 +1000 Subject: Add Component.onDestruction attached property This property complements Component.onCompleted. It is emitted before the destruction actually begins (for the most part) so the objects are still alive and accessible. The QtObject.onDestroyed signal is now blocked as it never really worked properly anyway. --- src/declarative/qml/qdeclarativecompiler.cpp | 31 +----------- src/declarative/qml/qdeclarativecompiler_p.h | 2 - src/declarative/qml/qdeclarativecomponent.cpp | 45 +++++++++-------- src/declarative/qml/qdeclarativecomponent_p.h | 15 +++++- src/declarative/qml/qdeclarativecontext.cpp | 57 +++++++++++----------- src/declarative/qml/qdeclarativecontext_p.h | 7 ++- src/declarative/qml/qdeclarativeengine.cpp | 11 +++-- src/declarative/qml/qdeclarativeengine_p.h | 2 +- src/declarative/qml/qdeclarativeproperty.cpp | 34 ++++++++++++- src/declarative/qml/qdeclarativeproperty_p.h | 3 +- src/declarative/qml/qdeclarativepropertycache.cpp | 6 +-- .../tst_qdeclarativecontext.cpp | 10 ++-- .../data/OnDestructionType.qml | 8 +++ .../data/destroyedSignal.errors.txt | 1 + .../qdeclarativelanguage/data/destroyedSignal.qml | 5 ++ .../qdeclarativelanguage/data/onDestruction.qml | 17 +++++++ .../tst_qdeclarativelanguage.cpp | 16 ++++++ 17 files changed, 171 insertions(+), 99 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index fad7779..5c5ad37 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -1364,35 +1364,6 @@ int QDeclarativeCompiler::componentTypeRef() return output->types.count() - 1; } -QMetaMethod QDeclarativeCompiler::findSignalByName(const QMetaObject *mo, const QByteArray &name) -{ - Q_ASSERT(mo); - int methods = mo->methodCount(); - for (int ii = methods - 1; ii >= 0; --ii) { - QMetaMethod method = mo->method(ii); - QByteArray methodName = method.signature(); - int idx = methodName.indexOf('('); - methodName = methodName.left(idx); - - if (methodName == name) - return method; - } - - // If no signal is found, but the signal is of the form "onBlahChanged", - // return the notify signal for the property "Blah" - if (name.endsWith("Changed")) { - QByteArray propName = name.mid(0, name.length() - 7); - int propIdx = mo->indexOfProperty(propName.constData()); - if (propIdx >= 0) { - QMetaProperty prop = mo->property(propIdx); - if (prop.hasNotifySignal()) - return prop.notifySignal(); - } - } - - return QMetaMethod(); -} - bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj, const BindingContext &ctxt) { @@ -1404,7 +1375,7 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl if(name[0] >= 'A' && name[0] <= 'Z') name[0] = name[0] - 'A' + 'a'; - int sigIdx = findSignalByName(obj->metaObject(), name).methodIndex(); + int sigIdx = QDeclarativePropertyPrivate::findSignalByName(obj->metaObject(), name).methodIndex(); if (sigIdx == -1) { diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h index 0e47774..002c6c9 100644 --- a/src/declarative/qml/qdeclarativecompiler_p.h +++ b/src/declarative/qml/qdeclarativecompiler_p.h @@ -159,8 +159,6 @@ public: static bool isAttachedPropertyName(const QByteArray &); static bool isSignalPropertyName(const QByteArray &); - static QMetaMethod findSignalByName(const QMetaObject *, const QByteArray &name); - int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum private: diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 7744b75..5cc6639 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -657,11 +657,11 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *ctxt, QDe state->bindValues = enginePriv->bindValues; state->parserStatus = enginePriv->parserStatus; - state->componentAttacheds = enginePriv->componentAttacheds; - if (state->componentAttacheds) - state->componentAttacheds->prev = &state->componentAttacheds; + state->componentAttached = enginePriv->componentAttached; + if (state->componentAttached) + state->componentAttached->prev = &state->componentAttached; - enginePriv->componentAttacheds = 0; + enginePriv->componentAttached = 0; enginePriv->bindValues.clear(); enginePriv->parserStatus.clear(); state->completePending = true; @@ -688,11 +688,11 @@ void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeEnginePrivate *engi state->bindValues = enginePriv->bindValues; state->parserStatus = enginePriv->parserStatus; - state->componentAttacheds = enginePriv->componentAttacheds; - if (state->componentAttacheds) - state->componentAttacheds->prev = &state->componentAttacheds; + state->componentAttached = enginePriv->componentAttached; + if (state->componentAttached) + state->componentAttached->prev = &state->componentAttached; - enginePriv->componentAttacheds = 0; + enginePriv->componentAttached = 0; enginePriv->bindValues.clear(); enginePriv->parserStatus.clear(); state->completePending = true; @@ -729,11 +729,13 @@ void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePri QDeclarativeEnginePrivate::clear(ps); } - while (state->componentAttacheds) { - QDeclarativeComponentAttached *a = state->componentAttacheds; - if (a->next) a->next->prev = &state->componentAttacheds; - state->componentAttacheds = a->next; - a->prev = 0; a->next = 0; + while (state->componentAttached) { + QDeclarativeComponentAttached *a = state->componentAttached; + a->rem(); + QDeclarativeData *d = QDeclarativeData::get(a->parent()); + Q_ASSERT(d); + Q_ASSERT(d->context); + a->add(&d->context->componentAttached); emit a->completed(); } @@ -793,15 +795,18 @@ QDeclarativeComponentAttached *QDeclarativeComponent::qmlAttachedProperties(QObj QDeclarativeComponentAttached *a = new QDeclarativeComponentAttached(obj); QDeclarativeEngine *engine = qmlEngine(obj); - if (!engine || !QDeclarativeEnginePrivate::get(engine)->inBeginCreate) + if (!engine) return a; - QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine); - - a->next = p->componentAttacheds; - a->prev = &p->componentAttacheds; - if (a->next) a->next->prev = &a->next; - p->componentAttacheds = a; + if (QDeclarativeEnginePrivate::get(engine)->inBeginCreate) { + QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine); + a->add(&p->componentAttached); + } else { + QDeclarativeData *d = QDeclarativeData::get(obj); + Q_ASSERT(d); + Q_ASSERT(d->context); + a->add(&d->context->componentAttached); + } return a; } diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h index dfd0fc3..24e5386 100644 --- a/src/declarative/qml/qdeclarativecomponent_p.h +++ b/src/declarative/qml/qdeclarativecomponent_p.h @@ -99,10 +99,10 @@ public: QDeclarativeCompiledData *cc; struct ConstructionState { - ConstructionState() : componentAttacheds(0), completePending(false) {} + ConstructionState() : componentAttached(0), completePending(false) {} QList > bindValues; QList > parserStatus; - QDeclarativeComponentAttached *componentAttacheds; + QDeclarativeComponentAttached *componentAttached; QList errors; bool completePending; }; @@ -132,13 +132,24 @@ public: QDeclarativeComponentAttached(QObject *parent = 0); ~QDeclarativeComponentAttached(); + void add(QDeclarativeComponentAttached **a) { + prev = a; next = *a; *a = this; + if (next) next->prev = &next; + } + void rem() { + if (next) next->prev = prev; + *prev = next; + next = 0; prev = 0; + } QDeclarativeComponentAttached **prev; QDeclarativeComponentAttached *next; Q_SIGNALS: void completed(); + void destruction(); private: + friend class QDeclarativeContextData;; friend class QDeclarativeComponentPrivate; }; diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index 42e7386..6657fea 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -42,6 +42,7 @@ #include "qdeclarativecontext.h" #include "private/qdeclarativecontext_p.h" +#include "private/qdeclarativecomponent_p.h" #include "private/qdeclarativeexpression_p.h" #include "private/qdeclarativeengine_p.h" #include "qdeclarativeengine.h" @@ -476,21 +477,34 @@ QObject *QDeclarativeContextPrivate::context_at(QDeclarativeListPropertydestroy(); + while (childContexts) + childContexts->invalidate(); + + while (componentAttached) { + QDeclarativeComponentAttached *a = componentAttached; + componentAttached = a->next; + if (componentAttached) componentAttached->prev = &componentAttached; + + a->next = 0; + a->prev = 0; + + emit a->destruction(); + } if (prevChild) { *prevChild = nextChild; @@ -498,19 +512,17 @@ void QDeclarativeContextData::destroy() nextChild = 0; prevChild = 0; } - - QDeclarativeContextData *child = childContexts; - while (child) { - QDeclarativeContextData *next = child->nextChild; - child->invalidateEngines(); - child->parent = 0; - child->nextChild = 0; - child->prevChild = 0; + engine = 0; + parent = 0; +} - child = next; - } - childContexts = 0; +void QDeclarativeContextData::destroy() +{ + if (linkedContext) + linkedContext->destroy(); + + if (engine) invalidate(); QDeclarativeAbstractExpression *expression = expressions; while (expression) { @@ -573,19 +585,6 @@ void QDeclarativeContextData::setParent(QDeclarativeContextData *p) } } -void QDeclarativeContextData::invalidateEngines() -{ - if (!engine) - return; - engine = 0; - - QDeclarativeContextData *child = childContexts; - while (child) { - child->invalidateEngines(); - child = child->nextChild; - } -} - /* Refreshes all expressions that could possibly depend on this context. Refreshing flushes all context-tree dependent caches in the expressions, and should occur every time the context tree diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h index 5d26e7e..77a6d94 100644 --- a/src/declarative/qml/qdeclarativecontext_p.h +++ b/src/declarative/qml/qdeclarativecontext_p.h @@ -106,6 +106,7 @@ public: static QObject *context_at(QDeclarativeListProperty *, int); }; +class QDeclarativeComponentAttached; class QDeclarativeGuardedContextData; class QDeclarativeContextData { @@ -113,6 +114,7 @@ public: QDeclarativeContextData(); QDeclarativeContextData(QDeclarativeContext *); void destroy(); + void invalidate(); inline bool isValid() const { return engine && (!isInternal || !contextObject || !QObjectPrivate::get(contextObject)->wasDeleted); @@ -123,7 +125,6 @@ public: QDeclarativeEngine *engine; void setParent(QDeclarativeContextData *); - void invalidateEngines(); void refreshExpressions(); void addObject(QObject *); @@ -194,6 +195,10 @@ public: // Linked contexts. this owns linkedContext. QDeclarativeContextData *linkedContext; + // Linked list of uses of the Component attached property in this + // context + QDeclarativeComponentAttached *componentAttached; + QString findObjectId(const QObject *obj) const; static QDeclarativeContextData *get(QDeclarativeContext *context) { diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index a478bf5..1deadb2 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -155,7 +155,7 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e) : captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false), contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0), globalClass(0), cleanup(0), erroredBindings(0), inProgressCreations(0), - scriptEngine(this), workerScriptEngine(0), componentAttacheds(0), inBeginCreate(false), + scriptEngine(this), workerScriptEngine(0), componentAttached(0), inBeginCreate(false), networkAccessManager(0), networkAccessManagerFactory(0), typeManager(e), uniqueId(1) { @@ -350,8 +350,13 @@ typedef QMap StringStringMap; Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri -void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *) +void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *o) { + QObjectPrivate *p = QObjectPrivate::get(o); + Q_ASSERT(p->declarativeData); + QDeclarativeData *d = static_cast(p->declarativeData); + if (d->ownContext) + d->context->destroy(); } void QDeclarativeData::destroyed(QAbstractDeclarativeData *d, QObject *o) @@ -855,7 +860,7 @@ void QDeclarativeData::destroyed(QObject *object) if (propertyCache) propertyCache->release(); - if (ownContext) + if (ownContext && context) context->destroy(); QDeclarativeGuard *guard = guards; diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 7766ad6..b3bba43 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -215,7 +215,7 @@ public: QList > bindValues; QList > parserStatus; - QDeclarativeComponentAttached *componentAttacheds; + QDeclarativeComponentAttached *componentAttached; bool inBeginCreate; diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 9cb2416..afd0d84 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -286,7 +286,7 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name QString signalName = terminal.mid(2); signalName[0] = signalName.at(0).toLower(); - QMetaMethod method = QDeclarativeCompiler::findSignalByName(currentObject->metaObject(), signalName.toLatin1().constData()); + QMetaMethod method = findSignalByName(currentObject->metaObject(), signalName.toLatin1().constData()); if (method.signature()) { object = currentObject; core.load(method); @@ -1353,4 +1353,36 @@ bool QDeclarativePropertyPrivate::canConvert(const QMetaObject *from, const QMet return false; } +/*! + Return the signal corresponding to \a name +*/ +QMetaMethod QDeclarativePropertyPrivate::findSignalByName(const QMetaObject *mo, const QByteArray &name) +{ + Q_ASSERT(mo); + int methods = mo->methodCount(); + for (int ii = methods - 1; ii >= 2; --ii) { // >= 2 to block the destroyed signal + QMetaMethod method = mo->method(ii); + QByteArray methodName = method.signature(); + int idx = methodName.indexOf('('); + methodName = methodName.left(idx); + + if (methodName == name) + return method; + } + + // If no signal is found, but the signal is of the form "onBlahChanged", + // return the notify signal for the property "Blah" + if (name.endsWith("Changed")) { + QByteArray propName = name.mid(0, name.length() - 7); + int propIdx = mo->indexOfProperty(propName.constData()); + if (propIdx >= 0) { + QMetaProperty prop = mo->property(propIdx); + if (prop.hasNotifySignal()) + return prop.notifySignal(); + } + } + + return QMetaMethod(); +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h index 420a1ba..8522561 100644 --- a/src/declarative/qml/qdeclarativeproperty_p.h +++ b/src/declarative/qml/qdeclarativeproperty_p.h @@ -96,8 +96,6 @@ public: void initProperty(QObject *obj, const QString &name); void initDefault(QObject *obj); - QMetaMethod findSignal(QObject *, const QString &); - bool isValueType() const; int propertyType() const; QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory() const; @@ -134,6 +132,7 @@ public: static bool write(const QDeclarativeProperty &that, const QVariant &, WriteFlags); static int valueTypeCoreIndex(const QDeclarativeProperty &that); static int bindingIndex(const QDeclarativeProperty &that); + static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyPrivate::WriteFlags) diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp index 4b4b142..888945b 100644 --- a/src/declarative/qml/qdeclarativepropertycache.cpp +++ b/src/declarative/qml/qdeclarativepropertycache.cpp @@ -147,7 +147,7 @@ QDeclarativePropertyCache::Data QDeclarativePropertyCache::create(const QMetaObj } int methodCount = metaObject->methodCount(); - for (int ii = methodCount - 1; ii >= 0; --ii) { + for (int ii = methodCount - 1; ii >= 2; --ii) { // >=2 to block the destroyed signal QMetaMethod m = metaObject->method(ii); if (m.access() == QMetaMethod::Private) continue; @@ -216,7 +216,7 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb } int methodCount = metaObject->methodCount(); - int methodOffset = metaObject->methodOffset(); + int methodOffset = qMax(2, metaObject->methodOffset()); // 2 to block the destroyed signal for (int ii = methodOffset; ii < methodCount; ++ii) { QMetaMethod m = metaObject->method(ii); if (m.access() == QMetaMethod::Private) @@ -289,7 +289,7 @@ void QDeclarativePropertyCache::update(QDeclarativeEngine *engine, const QMetaOb } int methodCount = metaObject->methodCount(); - for (int ii = methodCount - 1; ii >= 0; --ii) { + for (int ii = methodCount - 1; ii >= 2; --ii) { // >=2 to block the destroyed signal QMetaMethod m = metaObject->method(ii); if (m.access() == QMetaMethod::Private) continue; diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp index 35cffdc..851460f 100644 --- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp +++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp @@ -172,8 +172,8 @@ void tst_qdeclarativecontext::parentContext() delete ctxt2; ctxt2 = 0; QCOMPARE(ctxt->parentContext(), engine->rootContext()); - QCOMPARE(ctxt3->parentContext(), ctxt2); - QCOMPARE(ctxt4->parentContext(), ctxt2); + QCOMPARE(ctxt3->parentContext(), (QDeclarativeContext *)0); + QCOMPARE(ctxt4->parentContext(), (QDeclarativeContext *)0); QCOMPARE(ctxt5->parentContext(), ctxt); QCOMPARE(ctxt6->parentContext(), engine->rootContext()); QCOMPARE(ctxt7->parentContext(), engine->rootContext()); @@ -181,9 +181,9 @@ void tst_qdeclarativecontext::parentContext() delete engine; engine = 0; QCOMPARE(ctxt->parentContext(), (QDeclarativeContext *)0); - QCOMPARE(ctxt3->parentContext(), ctxt2); - QCOMPARE(ctxt4->parentContext(), ctxt2); - QCOMPARE(ctxt5->parentContext(), ctxt); + QCOMPARE(ctxt3->parentContext(), (QDeclarativeContext *)0); + QCOMPARE(ctxt4->parentContext(), (QDeclarativeContext *)0); + QCOMPARE(ctxt5->parentContext(), (QDeclarativeContext *)0); QCOMPARE(ctxt6->parentContext(), (QDeclarativeContext *)0); QCOMPARE(ctxt7->parentContext(), (QDeclarativeContext *)0); diff --git a/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml b/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml new file mode 100644 index 0000000..e5a7cf8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml @@ -0,0 +1,8 @@ +import Test 1.0 +import Qt 4.6 + +MyQmlObject { + property int a: Math.max(10, 9) + property int b: 11 + Component.onDestruction: console.log("Destruction " + a + " " + b); +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt new file mode 100644 index 0000000..3348494 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt @@ -0,0 +1 @@ +4:5:Cannot assign to non-existent property "onDestroyed" diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml new file mode 100644 index 0000000..4eab50a --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +QtObject { + onDestroyed: print("Hello World!") +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml b/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml new file mode 100644 index 0000000..7ebae7b --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml @@ -0,0 +1,17 @@ +import Test 1.0 +import Qt 4.6 + +MyTypeObject { + // We set a and b to ensure that onCompleted is executed after bindings and + // constants have been assigned + property int a: Math.min(6, 7) + Component.onDestruction: console.log("Destruction " + a + " " + nestedObject.b) + + objectProperty: OnDestructionType { + qmlobjectProperty: MyQmlObject { + id: nestedObject + property int b: 10 + Component.onDestruction: console.log("Destruction " + a + " " + nestedObject.b) + } + } +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 7c327c2..8feab32 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -113,6 +113,7 @@ private slots: void i18n(); void i18n_data(); void onCompleted(); + void onDestruction(); void scriptString(); void defaultPropertyListOrder(); void declaredPropertyValues(); @@ -329,6 +330,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false; QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false; QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false; + QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false; } @@ -1049,6 +1051,20 @@ void tst_qdeclarativelanguage::onCompleted() QVERIFY(object != 0); } +// Check that the Component::onDestruction attached property works +void tst_qdeclarativelanguage::onDestruction() +{ + QDeclarativeComponent component(&engine, TEST_FILE("onDestruction.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10"); + QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10"); + QTest::ignoreMessage(QtDebugMsg, "Destruction 10 11"); + delete object; +} + // Check that assignments to QDeclarativeScriptString properties work void tst_qdeclarativelanguage::scriptString() { -- cgit v0.12 From 5783d51bcaed2a769c222ae7f6123f7638d6388a Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 15 Apr 2010 16:49:35 +1000 Subject: Simplify dynamic resource loading to avoid cluttering Text API. Task-number: QTBUG-9900 QT-3287 --- src/declarative/graphicsitems/qdeclarativetext.cpp | 13 ++++--------- src/declarative/graphicsitems/qdeclarativetext_p.h | 4 +--- .../declarative/qdeclarativetext/tst_qdeclarativetext.cpp | 6 +++++- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 9fcfd92..a95c930 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -77,7 +77,7 @@ protected: if (type == QTextDocument::ImageResource) { QPixmap pm; QString errorString; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(url, &pm, &errorString, 0, true, 0, 0); + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(url, &pm, &errorString, 0, false, 0, 0); if (status == QDeclarativePixmapReply::Ready) return pm; if (status == QDeclarativePixmapReply::Error) { @@ -89,7 +89,6 @@ protected: QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(parent()), url); connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); outstanding++; - static_cast(parent())->reloadWithResources(); } } @@ -100,7 +99,8 @@ private slots: void requestFinished() { outstanding--; - static_cast(parent())->reloadWithResources(); + if (outstanding == 0) + static_cast(parent())->reloadWithResources(); } private: @@ -968,17 +968,13 @@ void QDeclarativeText::reloadWithResources() Q_D(QDeclarativeText); if (!d->richText) return; - if (resourcesLoading()!=0) - return; - emit resourcesLoadingChanged(); d->doc->setHtml(d->text); d->updateLayout(); d->markImgDirty(); } /*! - \qmlproperty int Text::resourcesLoading - This property is the number of resources (images) that are being loaded asynchronously. + Returns the number of resources (images) that are being loaded asynchronously. */ int QDeclarativeText::resourcesLoading() const { @@ -986,7 +982,6 @@ int QDeclarativeText::resourcesLoading() const return d->doc ? d->doc->resourcesLoading() : 0; } - void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QDeclarativeText); diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h index fcad898..4fd5e3a 100644 --- a/src/declarative/graphicsitems/qdeclarativetext_p.h +++ b/src/declarative/graphicsitems/qdeclarativetext_p.h @@ -72,7 +72,6 @@ class Q_DECLARATIVE_EXPORT QDeclarativeText : public QDeclarativeItem Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapModeChanged) Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged) Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode? - Q_PROPERTY(int resourcesLoading READ resourcesLoading NOTIFY resourcesLoadingChanged) public: QDeclarativeText(QDeclarativeItem *parent=0); @@ -139,7 +138,7 @@ public: virtual void componentComplete(); - int resourcesLoading() const; + int resourcesLoading() const; // mainly for testing Q_SIGNALS: void textChanged(const QString &text); @@ -153,7 +152,6 @@ Q_SIGNALS: void wrapModeChanged(); void textFormatChanged(TextFormat textFormat); void elideModeChanged(TextElideMode mode); - void resourcesLoadingChanged(); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index ca7dfe7..edb4a32 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -897,10 +897,14 @@ void tst_qdeclarativetext::embeddedImages() QTRY_COMPARE(textObject->resourcesLoading(), 0); + QPixmap pm(SRCDIR "/data/http/exists.png"); if (error.isEmpty()) { - QPixmap pm(SRCDIR "/data/http/exists.png"); QCOMPARE(textObject->width(), double(pm.width())); QCOMPARE(textObject->height(), double(pm.height())); + } else { + QVERIFY(16 != pm.width()); // check test is effective + QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon + QCOMPARE(textObject->height(), 16.0); } } -- cgit v0.12 From 55a33571a2cbf8187f5533125f961316f866fca2 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 16:53:12 +1000 Subject: Doc --- src/declarative/qml/qdeclarativecomponent.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 5cc6639..3e4651c 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -120,6 +120,26 @@ Item { } } \endqml + + \e onDestruction + + Emitted as the component begins destruction. This can be used to undo + work done in the onCompleted signal, or other imperative code in your + application. + + The \c {Component::onDestruction} attached property can be applied to + any element. However, it applies to the destruction of the component as + a whole, and not the destruction of the specific object. The order of + running the \c onDestruction scripts is undefined. + + \qml + Rectangle { + Component.onDestruction: console.log("Destruction Beginning!") + Rectangle { + Component.onDestruction: console.log("Nested Destruction Beginning!") + } + } + \endqml */ /*! -- cgit v0.12 From 0b3ade40922ecb06e3f67be96973322f8440bef9 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 15 Apr 2010 17:25:14 +1000 Subject: Compile without Qt3 support. --- src/declarative/util/qdeclarativepixmapcache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index 4a96a2a..893fbf3 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -662,7 +662,7 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP } else if (pixmap->isNull()) { status = QDeclarativePixmapReply::Error; if (errorString) - *errorString = QDeclarativeImageRequestHandler::tr("Unknown Error loading %1").arg(url); + *errorString = QDeclarativeImageRequestHandler::tr("Unknown Error loading %1").arg(url.toString()); } else { status = QDeclarativePixmapReply::Ready; } -- cgit v0.12 From 2c9ff8dc79b69b310a568f7457838753abbf2178 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 17:48:56 +1000 Subject: Support valuetypes as method return values QTBUG-9818 --- src/declarative/qml/qdeclarativeengine.cpp | 4 +- src/declarative/qml/qdeclarativevaluetype.cpp | 6 - src/declarative/qml/qdeclarativevaluetype_p.h | 5 +- .../qml/qdeclarativevaluetypescriptclass.cpp | 123 +++++++++++++++------ .../qml/qdeclarativevaluetypescriptclass_p.h | 1 + .../tst_qdeclarativeecmascript.cpp | 1 - .../qdeclarativevaluetypes/data/returnValues.qml | 17 +++ .../declarative/qdeclarativevaluetypes/testtypes.h | 3 + .../tst_qdeclarativevaluetypes.cpp | 14 +++ 9 files changed, 133 insertions(+), 41 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 1deadb2..96145fb 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1365,7 +1365,9 @@ QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant(const QVariant &v rv.setProperty(ii, objectClass->newQObject(object)); } return rv; - } + } else if (QDeclarativeValueType *vt = valueTypes[val.userType()]) { + return valueTypeClass->newObject(val, vt); + } bool objOk; QObject *obj = QDeclarativeMetaType::toQObject(val, &objOk); diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp index 261c84a..352a6c0 100644 --- a/src/declarative/qml/qdeclarativevaluetype.cpp +++ b/src/declarative/qml/qdeclarativevaluetype.cpp @@ -99,12 +99,6 @@ void QDeclarativeValueTypeFactory::registerValueTypes() qmlRegisterValueTypeEnums("Font"); } -QDeclarativeValueType *QDeclarativeValueTypeFactory::operator[](int idx) const -{ - return valueTypes[idx]; -} - - QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t) { switch (t) { diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h index 5bfc27d..d1833bb 100644 --- a/src/declarative/qml/qdeclarativevaluetype_p.h +++ b/src/declarative/qml/qdeclarativevaluetype_p.h @@ -86,7 +86,10 @@ public: static void registerValueTypes(); - QDeclarativeValueType *operator[](int idx) const; + QDeclarativeValueType *operator[](int idx) const { + if (idx >= (int)QVariant::UserType) return 0; + else return valueTypes[idx]; + } private: QDeclarativeValueType *valueTypes[QVariant::UserType - 1]; diff --git a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp index fdb71c6..cb1f27d 100644 --- a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp +++ b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp @@ -48,12 +48,24 @@ QT_BEGIN_NAMESPACE -struct QDeclarativeValueTypeReference : public QScriptDeclarativeClass::Object { +struct QDeclarativeValueTypeObject : public QScriptDeclarativeClass::Object { + enum Type { Reference, Copy }; + QDeclarativeValueTypeObject(Type t) : objectType(t) {} + Type objectType; QDeclarativeValueType *type; +}; + +struct QDeclarativeValueTypeReference : public QDeclarativeValueTypeObject { + QDeclarativeValueTypeReference() : QDeclarativeValueTypeObject(Reference) {} QDeclarativeGuard object; int property; }; +struct QDeclarativeValueTypeCopy : public QDeclarativeValueTypeObject { + QDeclarativeValueTypeCopy() : QDeclarativeValueTypeObject(Copy) {} + QVariant value; +}; + QDeclarativeValueTypeScriptClass::QDeclarativeValueTypeScriptClass(QDeclarativeEngine *bindEngine) : QScriptDeclarativeClass(QDeclarativeEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine) { @@ -73,40 +85,67 @@ QScriptValue QDeclarativeValueTypeScriptClass::newObject(QObject *object, int co return QScriptDeclarativeClass::newObject(scriptEngine, this, ref); } +QScriptValue QDeclarativeValueTypeScriptClass::newObject(const QVariant &v, QDeclarativeValueType *type) +{ + QDeclarativeValueTypeCopy *copy = new QDeclarativeValueTypeCopy; + copy->type = type; + copy->value = v; + QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); + return QScriptDeclarativeClass::newObject(scriptEngine, this, copy); +} + QScriptClass::QueryFlags QDeclarativeValueTypeScriptClass::queryProperty(Object *obj, const Identifier &name, - QScriptClass::QueryFlags) + QScriptClass::QueryFlags) { - QDeclarativeValueTypeReference *ref = static_cast(obj); + QDeclarativeValueTypeObject *o = static_cast(obj); m_lastIndex = -1; - if (!ref->object) - return 0; - QByteArray propName = toString(name).toUtf8(); - m_lastIndex = ref->type->metaObject()->indexOfProperty(propName.constData()); + m_lastIndex = o->type->metaObject()->indexOfProperty(propName.constData()); if (m_lastIndex == -1) return 0; - QMetaProperty prop = ref->object->metaObject()->property(m_lastIndex); + QScriptClass::QueryFlags rv = 0; + + if (o->objectType == QDeclarativeValueTypeObject::Reference) { + QDeclarativeValueTypeReference *ref = static_cast(o); + + if (!ref->object) + return 0; - QScriptClass::QueryFlags rv = - QScriptClass::HandlesReadAccess; - if (prop.isWritable()) - rv |= QScriptClass::HandlesWriteAccess; + QMetaProperty prop = ref->object->metaObject()->property(m_lastIndex); + + rv = QScriptClass::HandlesReadAccess; + if (prop.isWritable()) + rv |= QScriptClass::HandlesWriteAccess; + } else { + rv = QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess; + } return rv; } QDeclarativeValueTypeScriptClass::Value QDeclarativeValueTypeScriptClass::property(Object *obj, const Identifier &) { - QDeclarativeValueTypeReference *ref = static_cast(obj); + QDeclarativeValueTypeObject *o = static_cast(obj); - QMetaProperty p = ref->type->metaObject()->property(m_lastIndex); - ref->type->read(ref->object, ref->property); - QVariant rv = p.read(ref->type); + QVariant rv; + if (o->objectType == QDeclarativeValueTypeObject::Reference) { + QDeclarativeValueTypeReference *ref = static_cast(obj); + + QMetaProperty p = ref->type->metaObject()->property(m_lastIndex); + ref->type->read(ref->object, ref->property); + rv = p.read(ref->type); + } else { + QDeclarativeValueTypeCopy *copy = static_cast(obj); + + QMetaProperty p = copy->type->metaObject()->property(m_lastIndex); + copy->type->setValue(copy->value); + rv = p.read(copy->type); + } QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); return Value(scriptEngine, static_cast(QObjectPrivate::get(engine))->scriptValueFromVariant(rv)); @@ -115,33 +154,53 @@ QDeclarativeValueTypeScriptClass::Value QDeclarativeValueTypeScriptClass::proper void QDeclarativeValueTypeScriptClass::setProperty(Object *obj, const Identifier &, const QScriptValue &value) { - QDeclarativeValueTypeReference *ref = static_cast(obj); - - QDeclarativeAbstractBinding *delBinding = - QDeclarativePropertyPrivate::setBinding(ref->object, ref->property, m_lastIndex, 0); - if (delBinding) - delBinding->destroy(); + QDeclarativeValueTypeObject *o = static_cast(obj); QVariant v = QDeclarativeEnginePrivate::get(engine)->scriptValueToVariant(value); - ref->type->read(ref->object, ref->property); - QMetaProperty p = ref->type->metaObject()->property(m_lastIndex); - p.write(ref->type, v); - ref->type->write(ref->object, ref->property, 0); + if (o->objectType == QDeclarativeValueTypeObject::Reference) { + QDeclarativeValueTypeReference *ref = static_cast(obj); + + QDeclarativeAbstractBinding *delBinding = + QDeclarativePropertyPrivate::setBinding(ref->object, ref->property, m_lastIndex, 0); + if (delBinding) + delBinding->destroy(); + + ref->type->read(ref->object, ref->property); + QMetaProperty p = ref->type->metaObject()->property(m_lastIndex); + p.write(ref->type, v); + ref->type->write(ref->object, ref->property, 0); + } else { + QDeclarativeValueTypeCopy *copy = static_cast(obj); + copy->type->setValue(copy->value); + QMetaProperty p = copy->type->metaObject()->property(m_lastIndex); + p.write(copy->type, v); + copy->value = copy->type->value(); + } } QVariant QDeclarativeValueTypeScriptClass::toVariant(Object *obj, bool *ok) { - QDeclarativeValueTypeReference *ref = static_cast(obj); + QDeclarativeValueTypeObject *o = static_cast(obj); - if (ok) *ok = true; + if (o->objectType == QDeclarativeValueTypeObject::Reference) { + QDeclarativeValueTypeReference *ref = static_cast(obj); - if (ref->object) { - ref->type->read(ref->object, ref->property); - return ref->type->value(); + if (ok) *ok = true; + + if (ref->object) { + ref->type->read(ref->object, ref->property); + return ref->type->value(); + } } else { - return QVariant(); + QDeclarativeValueTypeCopy *copy = static_cast(obj); + + if (ok) *ok = true; + + return copy->value; } + + return QVariant(); } QVariant QDeclarativeValueTypeScriptClass::toVariant(const QScriptValue &value) diff --git a/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h b/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h index 2bbb61f..9dafa99 100644 --- a/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h +++ b/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h @@ -67,6 +67,7 @@ public: ~QDeclarativeValueTypeScriptClass(); QScriptValue newObject(QObject *object, int coreIndex, QDeclarativeValueType *); + QScriptValue newObject(const QVariant &, QDeclarativeValueType *); virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 35b4d99..098ac36 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -1382,7 +1382,6 @@ void tst_qdeclarativeecmascript::callQtInvokables() o.reset(); { QScriptValue ret = engine->evaluate("object.method_NoArgs_QPointF()"); - QVERIFY(ret.isVariant()); QCOMPARE(ret.toVariant(), QVariant(QPointF(123, 4.5))); QCOMPARE(o.error(), false); QCOMPARE(o.invoked(), 3); diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml new file mode 100644 index 0000000..185e7ba --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml @@ -0,0 +1,17 @@ +import Test 1.0 +import Qt 4.6 + +MyTypeObject { + property bool test1: false; + property bool test2: false; + + Component.onCompleted: { + var a = method(); + + test1 = (a.width == 13) + test2 = (a.height == 14) + + size = a; + } +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h index 9057b4f..dd13429 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h @@ -129,6 +129,9 @@ public: signals: void changed(); void runScript(); + +public slots: + QSize method() { return QSize(13, 14); } }; QML_DECLARE_TYPE(MyTypeObject); diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index e653abf..b733b10 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -79,6 +79,7 @@ private slots: void cppClasses(); void enums(); void conflictingBindings(); + void returnValues(); private: QDeclarativeEngine engine; @@ -763,6 +764,19 @@ void tst_qdeclarativevaluetypes::conflictingBindings() } } +void tst_qdeclarativevaluetypes::returnValues() +{ + QDeclarativeComponent component(&engine, TEST_FILE("returnValues.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + QCOMPARE(object->property("size").toSize(), QSize(13, 14)); + + delete object; +} + QTEST_MAIN(tst_qdeclarativevaluetypes) #include "tst_qdeclarativevaluetypes.moc" -- cgit v0.12 From 9e66838d0e766da45524d38c7235441500877c41 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 15 Apr 2010 10:47:02 +0300 Subject: Shouldn't call epocRoot() in non-epoc builds in generatePkgFile Reviewed-by: Janne Koskinen --- qmake/generators/symbian/symbiancommon.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qmake/generators/symbian/symbiancommon.cpp b/qmake/generators/symbian/symbiancommon.cpp index 0df2d15..0802c01 100644 --- a/qmake/generators/symbian/symbiancommon.cpp +++ b/qmake/generators/symbian/symbiancommon.cpp @@ -362,8 +362,10 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, bool epocB // deploy any additional DEPLOYMENT files QString remoteTestPath; + QString zDir; remoteTestPath = QString("!:\\private\\%1").arg(privateDirUid); - QString zDir = epocRoot() + QLatin1String("epoc32/data/z"); + if (epocBuild) + zDir = epocRoot() + QLatin1String("epoc32/data/z"); DeploymentList depList; initProjectDeploySymbian(project, depList, remoteTestPath, true, epocBuild, "$(PLATFORM)", "$(TARGET)", generatedDirs, generatedFiles); -- cgit v0.12 From b9f71669979f7e892e3af3197915bb732ab0f243 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 18:23:33 +1000 Subject: Update examples autotest to use the runtime directly This improves the test execution time --- tests/auto/declarative/examples/examples.pro | 2 + tests/auto/declarative/examples/tst_examples.cpp | 103 ++++++----------------- tools/qml/qmlruntime.cpp | 28 +++--- tools/qml/qmlruntime.h | 5 +- 4 files changed, 42 insertions(+), 96 deletions(-) diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index b316cb9..4c32524 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -4,6 +4,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_examples.cpp +include(../../../../tools/qml/qml.pri) + DEFINES += SRCDIR=\\\"$$PWD\\\" CONFIG += parallel_test diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index e62aad2..c650346 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -43,8 +43,9 @@ #include #include #include -#include -#include +#include "qmlruntime.h" +#include +#include class tst_examples : public QObject { @@ -53,6 +54,7 @@ public: tst_examples(); private slots: + void examples_data(); void examples(); void namingConvention(); @@ -173,8 +175,6 @@ QStringList tst_examples::findQmlFiles(const QDir &d) return rv; } - - /* This test runs all the examples in the declarative UI source tree and ensures that they start and exit cleanly. @@ -182,57 +182,9 @@ that they start and exit cleanly. Examples are any .qml files under the examples/ or demos/ directory that start with a lower case letter. */ -#define THREADS 5 - -struct Example { -public: - Example() : result(Unknown) {} - - enum Result { Pass, Unknown, Fail }; - Result result; - QString file; - QString qmlruntime; - - void run(); -}; - -void Example::run() +void tst_examples::examples_data() { - QFileInfo fi(file); - QFileInfo dir(fi.path()); - QString script = SRCDIR "/data/"+dir.baseName()+"/"+fi.baseName(); - QFileInfo testdata(script+".qml"); - QStringList arguments; - arguments << "-script" << (testdata.exists() ? script : QLatin1String(SRCDIR "/data/dummytest")) - << "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure" - << file; -#ifdef Q_WS_QWS - arguments << "-qws"; -#endif - - QProcess p; - p.start(qmlruntime, arguments); - if (!p.waitForFinished()) { - result = Fail; - return; - } - - if (p.exitStatus() != QProcess::NormalExit || p.exitCode() != 0) - qWarning() << p.readAllStandardOutput() << p.readAllStandardError(); - - if (p.exitStatus() != QProcess::NormalExit || - p.exitCode() != 0) { - result = Fail; - return; - } else { - result = Pass; - return; - } -} - -void tst_examples::examples() -{ - QThreadPool::globalInstance()->setMaxThreadCount(5); + QTest::addColumn("file"); QString examples = QLatin1String(SRCDIR) + "/../../../../demos/declarative/"; QString demos = QLatin1String(SRCDIR) + "/../../../../examples/declarative/"; @@ -243,38 +195,31 @@ void tst_examples::examples() files << findQmlFiles(QDir(demos)); files << findQmlFiles(QDir(snippets)); - QList tests; - - for (int ii = 0; ii < files.count(); ++ii) { - Example e; - e.file = files.at(ii); - e.qmlruntime = qmlruntime; - tests << e; - } + foreach (const QString &file, files) + QTest::newRow(qPrintable(file)) << file; +} - QFutureSynchronizer sync; +static void silentErrorsMsgHandler(QtMsgType, const char *) +{ +} - for (int ii = 0; ii < tests.count(); ++ii) { - Example *e = &tests[ii]; - QFuture r = QtConcurrent::run(e, &Example::run); - sync.addFuture(r); - } +void tst_examples::examples() +{ + QFETCH(QString, file); - sync.waitForFinished(); + QDeclarativeViewer viewer; - QStringList failures; - for (int ii = 0; ii < tests.count(); ++ii) { - if (tests.at(ii).result != Example::Pass) - failures << QDir::cleanPath(tests.at(ii).file); - } + QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler); + QVERIFY(viewer.open(file)); + qInstallMsgHandler(old); - if (failures.count()) { - QString error("Failed examples: "); - error += failures.join(", "); + if (viewer.view()->status() == QDeclarativeView::Error) + qWarning() << viewer.view()->errors(); - QFAIL(qPrintable(error)); - } + QCOMPARE(viewer.view()->status(), QDeclarativeView::Ready); + viewer.show(); + QTest::qWaitForWindowShown(&viewer); } QTEST_MAIN(tst_examples) diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 0a0ad9b..53409c1 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -550,6 +550,11 @@ QMenuBar *QDeclarativeViewer::menuBar() const return mb; } +QDeclarativeView *QDeclarativeViewer::view() const +{ + return canvas; +} + void QDeclarativeViewer::createMenu(QMenuBar *menu, QMenu *flatmenu) { QObject *parent = flatmenu ? (QObject*)flatmenu : (QObject*)menu; @@ -888,24 +893,19 @@ void QDeclarativeViewer::addPluginPath(const QString& plugin) void QDeclarativeViewer::reload() { - openQml(currentFileOrUrl); -} - -void QDeclarativeViewer::open(const QString& doc) -{ - openQml(doc); + open(currentFileOrUrl); } void QDeclarativeViewer::openFile() { QString cur = canvas->source().toLocalFile(); if (useQmlFileBrowser) { - openQml("qrc:/content/Browser.qml"); + open("qrc:/content/Browser.qml"); } else { QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)")); if (!fileName.isEmpty()) { QFileInfo fi(fileName); - openQml(fi.absoluteFilePath()); + open(fi.absoluteFilePath()); } } } @@ -935,10 +935,10 @@ void QDeclarativeViewer::statusChanged() void QDeclarativeViewer::launch(const QString& file_or_url) { - QMetaObject::invokeMethod(this, "openQml", Qt::QueuedConnection, Q_ARG(QString, file_or_url)); + QMetaObject::invokeMethod(this, "open", Qt::QueuedConnection, Q_ARG(QString, file_or_url)); } -void QDeclarativeViewer::openQml(const QString& file_or_url) +bool QDeclarativeViewer::open(const QString& file_or_url) { currentFileOrUrl = file_or_url; @@ -971,7 +971,7 @@ void QDeclarativeViewer::openQml(const QString& file_or_url) if (fi.exists()) { if (fi.suffix().toLower() != QLatin1String("qml")) { qWarning() << "qml cannot open non-QML file" << fileName; - return; + return false; } QDir dir(fi.path()+"/dummydata", "*.qml"); @@ -1002,7 +1002,7 @@ void QDeclarativeViewer::openQml(const QString& file_or_url) } } else { qWarning() << "qml cannot find file:" << fileName; - return; + return false; } } @@ -1013,9 +1013,7 @@ void QDeclarativeViewer::openQml(const QString& file_or_url) qWarning() << "Wall startup time:" << t.elapsed(); -#ifdef QTOPIA - show(); -#endif + return true; } void QDeclarativeViewer::startNetwork() diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 8792d0c..2089dda 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -105,10 +105,11 @@ public: QMenuBar *menuBar() const; + QDeclarativeView *view() const; + public slots: void sceneResized(QSize size); - void open(const QString&); - void openQml(const QString&); + bool open(const QString&); void openFile(); void reload(); void takeSnapShot(); -- cgit v0.12 From 0e0009e0bae445938e73e3ea7b031c882b8930d2 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 15 Apr 2010 18:54:57 +1000 Subject: Improve declarative calculator example. --- demos/declarative/calculator/CalcButton.qml | 41 ----- demos/declarative/calculator/Core/Button.qml | 39 +++++ demos/declarative/calculator/Core/Display.qml | 27 ++++ demos/declarative/calculator/Core/calculator.js | 91 +++++++++++ .../declarative/calculator/Core/images/button-.png | Bin 0 -> 1288 bytes .../calculator/Core/images/button-blue.png | Bin 0 -> 1565 bytes .../calculator/Core/images/button-green.png | Bin 0 -> 1543 bytes .../calculator/Core/images/button-purple.png | Bin 0 -> 1566 bytes .../calculator/Core/images/button-red.png | Bin 0 -> 1586 bytes .../declarative/calculator/Core/images/display.png | Bin 0 -> 998 bytes demos/declarative/calculator/Core/qmldir | 2 + demos/declarative/calculator/calculator.js | 87 ---------- demos/declarative/calculator/calculator.qml | 178 +++++++++------------ 13 files changed, 238 insertions(+), 227 deletions(-) delete mode 100644 demos/declarative/calculator/CalcButton.qml create mode 100644 demos/declarative/calculator/Core/Button.qml create mode 100644 demos/declarative/calculator/Core/Display.qml create mode 100644 demos/declarative/calculator/Core/calculator.js create mode 100644 demos/declarative/calculator/Core/images/button-.png create mode 100644 demos/declarative/calculator/Core/images/button-blue.png create mode 100644 demos/declarative/calculator/Core/images/button-green.png create mode 100644 demos/declarative/calculator/Core/images/button-purple.png create mode 100644 demos/declarative/calculator/Core/images/button-red.png create mode 100644 demos/declarative/calculator/Core/images/display.png create mode 100644 demos/declarative/calculator/Core/qmldir delete mode 100644 demos/declarative/calculator/calculator.js diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml deleted file mode 100644 index a125346..0000000 --- a/demos/declarative/calculator/CalcButton.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.7 - -Rectangle { - property alias operation: label.text - property bool toggable: false - property bool toggled: false - signal clicked - - id: button; width: 50; height: 30 - border.color: palette.mid; radius: 6 - gradient: Gradient { - GradientStop { id: gradientStop1; position: 0.0; color: Qt.lighter(palette.button) } - GradientStop { id: gradientStop2; position: 1.0; color: palette.button } - } - - Text { id: label; anchors.centerIn: parent; color: palette.buttonText } - - MouseArea { - id: clickRegion - anchors.fill: parent - onClicked: { - doOp(operation); - button.clicked(); - if (!button.toggable) return; - button.toggled ? button.toggled = false : button.toggled = true - } - } - - states: [ - State { - name: "Pressed"; when: clickRegion.pressed == true - PropertyChanges { target: gradientStop1; color: palette.dark } - PropertyChanges { target: gradientStop2; color: palette.button } - }, - State { - name: "Toggled"; when: button.toggled == true - PropertyChanges { target: gradientStop1; color: palette.dark } - PropertyChanges { target: gradientStop2; color: palette.button } - } - ] -} diff --git a/demos/declarative/calculator/Core/Button.qml b/demos/declarative/calculator/Core/Button.qml new file mode 100644 index 0000000..8948adc --- /dev/null +++ b/demos/declarative/calculator/Core/Button.qml @@ -0,0 +1,39 @@ +import Qt 4.7 + +BorderImage { + id: button + + property alias operation: buttonText.text + property string color: "" + + signal clicked + + source: "images/button-" + color + ".png"; clip: true + border { left: 10; top: 10; right: 10; bottom: 10 } + + Rectangle { + id: shade + anchors.fill: button; radius: 10; color: "black"; opacity: 0 + } + + Text { + id: buttonText + anchors.centerIn: parent; anchors.verticalCenterOffset: -1 + font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5 + style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + doOp(operation) + button.clicked() + } + } + + states: State { + name: "pressed"; when: mouseArea.pressed == true + PropertyChanges { target: shade; opacity: .4 } + } +} diff --git a/demos/declarative/calculator/Core/Display.qml b/demos/declarative/calculator/Core/Display.qml new file mode 100644 index 0000000..b98c44b --- /dev/null +++ b/demos/declarative/calculator/Core/Display.qml @@ -0,0 +1,27 @@ +import Qt 4.7 + +BorderImage { + id: image + + property alias text : displayText.text + property alias currentOperation : operationText + + source: "images/display.png" + border { left: 10; top: 10; right: 10; bottom: 10 } + + Text { + id: displayText + anchors { + right: parent.right; verticalCenter: parent.verticalCenter; verticalCenterOffset: -1 + rightMargin: 6; left: operationText.right + } + font.pixelSize: parent.height * .6; text: "0"; horizontalAlignment: Text.AlignRight; elide: Text.ElideRight + color: "#343434"; smooth: true; font.bold: true + } + Text { + id: operationText + font.bold: true; font.pixelSize: parent.height * .7 + color: "#343434"; smooth: true + anchors { left: parent.left; leftMargin: 6; verticalCenterOffset: -3; verticalCenter: parent.verticalCenter } + } +} diff --git a/demos/declarative/calculator/Core/calculator.js b/demos/declarative/calculator/Core/calculator.js new file mode 100644 index 0000000..2b19de8 --- /dev/null +++ b/demos/declarative/calculator/Core/calculator.js @@ -0,0 +1,91 @@ + +var curVal = 0 +var memory = 0 +var lastOp = "" +var timer = 0 + +function disabled(op) { + if (op == "." && display.text.toString().search(/\./) != -1) { + return true + } else if (op == squareRoot && display.text.toString().search(/-/) != -1) { + return true + } else { + return false + } +} + +function doOperation(op) { + if (disabled(op)) { + return + } + + if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) { + if (display.text.toString().length >= 14) + return; // No arbitrary length numbers + if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) { + display.text = display.text + op.toString() + } else { + display.text = op + } + lastOp = op + return + } + lastOp = op + + if (display.currentOperation.text == "+") { + display.text = Number(display.text.valueOf()) + Number(curVal.valueOf()) + } else if (display.currentOperation.text == "-") { + display.text = Number(curVal) - Number(display.text.valueOf()) + } else if (display.currentOperation.text == multiplication) { + display.text = Number(curVal) * Number(display.text.valueOf()) + } else if (display.currentOperation.text == division) { + display.text = Number(Number(curVal) / Number(display.text.valueOf())).toString() + } else if (display.currentOperation.text == "=") { + } + + if (op == "+" || op == "-" || op == multiplication || op == division) { + display.currentOperation.text = op + curVal = display.text.valueOf() + return + } + + curVal = 0 + display.currentOperation.text = "" + + if (op == "1/x") { + display.text = (1 / display.text.valueOf()).toString() + } else if (op == "^2") { + display.text = (display.text.valueOf() * display.text.valueOf()).toString() + } else if (op == "Abs") { + display.text = (Math.abs(display.text.valueOf())).toString() + } else if (op == "Int") { + display.text = (Math.floor(display.text.valueOf())).toString() + } else if (op == plusminus) { + display.text = (display.text.valueOf() * -1).toString() + } else if (op == squareRoot) { + display.text = (Math.sqrt(display.text.valueOf())).toString() + } else if (op == "mc") { + memory = 0; + } else if (op == "m+") { + memory += display.text.valueOf() + } else if (op == "mr") { + display.text = memory.toString() + } else if (op == "m-") { + memory = display.text.valueOf() + } else if (op == leftArrow) { + display.text = display.text.toString().slice(0, -1) + } else if (op == "C") { + display.text = "0" + } else if (op == "AC") { + curVal = 0 + memory = 0 + lastOp = "" + display.text ="0" + } + + if (op == rotateLeft) + main.state = 'rotated' + if (op == rotateRight) + main.state = '' +} + diff --git a/demos/declarative/calculator/Core/images/button-.png b/demos/declarative/calculator/Core/images/button-.png new file mode 100644 index 0000000..544e514 Binary files /dev/null and b/demos/declarative/calculator/Core/images/button-.png differ diff --git a/demos/declarative/calculator/Core/images/button-blue.png b/demos/declarative/calculator/Core/images/button-blue.png new file mode 100644 index 0000000..5f92de3 Binary files /dev/null and b/demos/declarative/calculator/Core/images/button-blue.png differ diff --git a/demos/declarative/calculator/Core/images/button-green.png b/demos/declarative/calculator/Core/images/button-green.png new file mode 100644 index 0000000..36c9391 Binary files /dev/null and b/demos/declarative/calculator/Core/images/button-green.png differ diff --git a/demos/declarative/calculator/Core/images/button-purple.png b/demos/declarative/calculator/Core/images/button-purple.png new file mode 100644 index 0000000..347cbbe Binary files /dev/null and b/demos/declarative/calculator/Core/images/button-purple.png differ diff --git a/demos/declarative/calculator/Core/images/button-red.png b/demos/declarative/calculator/Core/images/button-red.png new file mode 100644 index 0000000..3b33589 Binary files /dev/null and b/demos/declarative/calculator/Core/images/button-red.png differ diff --git a/demos/declarative/calculator/Core/images/display.png b/demos/declarative/calculator/Core/images/display.png new file mode 100644 index 0000000..9507f43 Binary files /dev/null and b/demos/declarative/calculator/Core/images/display.png differ diff --git a/demos/declarative/calculator/Core/qmldir b/demos/declarative/calculator/Core/qmldir new file mode 100644 index 0000000..a926b93 --- /dev/null +++ b/demos/declarative/calculator/Core/qmldir @@ -0,0 +1,2 @@ +Button Button.qml +Display Display.qml diff --git a/demos/declarative/calculator/calculator.js b/demos/declarative/calculator/calculator.js deleted file mode 100644 index f172daf..0000000 --- a/demos/declarative/calculator/calculator.js +++ /dev/null @@ -1,87 +0,0 @@ - -var curVal = 0; -var memory = 0; -var lastOp = ""; -var timer = 0; - -function disabled(op) { - if (op == "." && curNum.text.toString().search(/\./) != -1) { - return true; - } else if (op == "Sqrt" && curNum.text.toString().search(/-/) != -1) { - return true; - } else { - return false; - } -} - -function doOperation(op) { - if (disabled(op)) { - return; - } - - if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) { - if (curNum.text.toString().length >= 14) - return; // No arbitrary length numbers - if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp==".") ) { - curNum.text = curNum.text + op.toString(); - } else { - curNum.text = op; - } - lastOp = op; - return; - } - lastOp = op; - - // Pending operations - if (currentOperation.text == "+") { - curNum.text = Number(curNum.text.valueOf()) + Number(curVal.valueOf()); - } else if (currentOperation.text == "-") { - curNum.text = Number(curVal) - Number(curNum.text.valueOf()); - } else if (currentOperation.text == "x") { - curNum.text = Number(curVal) * Number(curNum.text.valueOf()); - } else if (currentOperation.text == "/") { - curNum.text = Number(Number(curVal) / Number(curNum.text.valueOf())).toString(); - } else if (currentOperation.text == "=") { - } - - if (op == "+" || op == "-" || op == "x" || op == "/") { - currentOperation.text = op; - curVal = curNum.text.valueOf(); - return; - } - curVal = 0; - currentOperation.text = ""; - - // Immediate operations - if (op == "1/x") { // reciprocal - curNum.text = (1 / curNum.text.valueOf()).toString(); - } else if (op == "^2") { // squared - curNum.text = (curNum.text.valueOf() * curNum.text.valueOf()).toString(); - } else if (op == "Abs") { - curNum.text = (Math.abs(curNum.text.valueOf())).toString(); - } else if (op == "Int") { - curNum.text = (Math.floor(curNum.text.valueOf())).toString(); - } else if (op == "+/-") { // plus/minus - curNum.text = (curNum.text.valueOf() * -1).toString(); - } else if (op == "Sqrt") { // square root - curNum.text = (Math.sqrt(curNum.text.valueOf())).toString(); - } else if (op == "MC") { // memory clear - memory = 0; - } else if (op == "M+") { // memory increment - memory += curNum.text.valueOf(); - } else if (op == "MR") { // memory recall - curNum.text = memory.toString(); - } else if (op == "MS") { // memory set - memory = curNum.text.valueOf(); - } else if (op == "Bksp") { - curNum.text = curNum.text.toString().slice(0, -1); - } else if (op == "C") { - curNum.text = "0"; - } else if (op == "AC") { - curVal = 0; - memory = 0; - lastOp = ""; - curNum.text ="0"; - } -} - diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index b8e506e..fc2b95a 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -1,126 +1,106 @@ import Qt 4.7 -import "calculator.js" as CalcEngine +import "Core" +import "Core/calculator.js" as CalcEngine Rectangle { - width: 320; height: 270; color: palette.window + id: window - function doOp(operation) { CalcEngine.doOperation(operation); } + width: 480; height: 360 + color: "#282828" - SystemPalette { id: palette } + property string rotateLeft: "\u2939" + property string rotateRight: "\u2935" + property string leftArrow: "\u2190" + property string division : "\u00f7" + property string multiplication : "\u00d7" + property string squareRoot : "\u221a" + property string plusminus : "\u00b1" - Column { - x: 2; spacing: 10; + function doOp(operation) { CalcEngine.doOperation(operation) } - Rectangle { - id: container - width: 316; height: 50 - border.color: palette.dark; color: palette.base + Item { + id: main + state: (runtime.orientation == Orientation.Portrait) ? '' : 'rotated' + width: parent.width; height: parent.height; anchors.centerIn: parent - Text { - id: curNum - font.bold: true; font.pointSize: 16 - color: palette.text - anchors.right: container.right - anchors.rightMargin: 5 - anchors.verticalCenter: container.verticalCenter - } + Column { + id: box; spacing: 8 - Text { - id: currentOperation - color: palette.text - font.bold: true; font.pointSize: 16 - anchors.left: container.left - anchors.leftMargin: 5 - anchors.verticalCenter: container.verticalCenter - } - } + anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 } - Item { - width: 320; height: 30 - - CalcButton { - id: advancedCheckBox - x: 55; width: 206 - operation: "Advanced Mode" - toggable: true + Row { + Display { id: display; width: box.width; height: 64 } } - } - Item { - width: 320; height: 160 + Column { + id: column; spacing: 6 - Item { - id: basicButtons - x: 55; width: 160; height: 160 + property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6) - CalcButton { operation: "Bksp"; id: bksp; width: 67; opacity: 0 } - CalcButton { operation: "C"; id: c; width: 76 } - CalcButton { operation: "AC"; id: ac; x: 78; width: 76 } - - Grid { - id: numKeypad; y: 32; spacing: 2; columns: 3 - - CalcButton { operation: "7" } - CalcButton { operation: "8" } - CalcButton { operation: "9" } - CalcButton { operation: "4" } - CalcButton { operation: "5" } - CalcButton { operation: "6" } - CalcButton { operation: "1" } - CalcButton { operation: "2" } - CalcButton { operation: "3" } + Row { + spacing: 6 + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) + + Button { + id: rotateButton + width: parent.w; height: column.h; color: 'purple'; operation: rotateLeft + } + Button { width: parent.w; height: column.h; color: 'purple'; operation: leftArrow } + Button { width: parent.w; height: column.h; color: 'purple'; operation: "C" } + Button { width: parent.w; height: column.h; color: 'purple'; operation: "AC" } } Row { - y: 128; spacing: 2 + spacing: 6 + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) - CalcButton { operation: "0"; width: 50 } - CalcButton { operation: "."; x: 77; width: 50 } - CalcButton { operation: "="; id: equals; x: 77; width: 102 } + Button { width: parent.w; height: column.h; color: 'green'; operation: "mc" } + Button { width: parent.w; height: column.h; color: 'green'; operation: "m+" } + Button { width: parent.w; height: column.h; color: 'green'; operation: "m-" } + Button { width: parent.w; height: column.h; color: 'green'; operation: "mr" } } - Column { - id: simpleOperations - x: 156; y: 0; spacing: 2 - - CalcButton { operation: "x" } - CalcButton { operation: "/" } - CalcButton { operation: "-" } - CalcButton { operation: "+" } + Grid { + id: grid; rows: 4; columns: 5; spacing: 6 + + property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns) + + Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: division } + Button { width: grid.w; height: column.h; operation: squareRoot } + Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: multiplication } + Button { width: grid.w; height: column.h; operation: "x^2" } + Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "-" } + Button { width: grid.w; height: column.h; operation: "1/x" } + Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "." } + Button { width: grid.w; height: column.h; operation: plusminus } + Button { width: grid.w; height: column.h; operation: "+" } + Button { width: grid.w; height: column.h; operation: "="; color: 'red' } } } - - Grid { - id: advancedButtons - x: 350; spacing: 2; columns: 2; opacity: 0 - - CalcButton { operation: "Abs" } - CalcButton { operation: "Int" } - CalcButton { operation: "MC" } - CalcButton { operation: "Sqrt" } - CalcButton { operation: "MR" } - CalcButton { operation: "^2" } - CalcButton { operation: "MS" } - CalcButton { operation: "1/x" } - CalcButton { operation: "M+" } - CalcButton { operation: "+/-" } - } } - } - states: State { - name: "Advanced"; when: advancedCheckBox.toggled == true - PropertyChanges { target: basicButtons; x: 0 } - PropertyChanges { target: simpleOperations; y: 32 } - PropertyChanges { target: bksp; opacity: 1 } - PropertyChanges { target: c; x: 69; width: 67 } - PropertyChanges { target: ac; x: 138; width: 67 } - PropertyChanges { target: equals; width: 50 } - PropertyChanges { target: advancedButtons; x: 210; opacity: 1 } - } + states: State { + name: 'rotated' + PropertyChanges { target: main; rotation: -90; width: window.height; height: window.width } + PropertyChanges { target: rotateButton; operation: rotateRight } + } - transitions: Transition { - NumberAnimation { properties: "x,y,width"; easing.type: "OutBounce"; duration: 500 } - NumberAnimation { properties: "opacity"; easing.type: "InOutQuad"; duration: 500 } + transitions: Transition { + SequentialAnimation { + PropertyAction { target: rotateButton; property: "operation" } + NumberAnimation { properties: "rotation"; duration: 300; easing.type: "InOutQuint" } + NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: "InOutQuint" } + } + } } } -- cgit v0.12 From 8dca45fa2ad0f260143282ee01d52e72f8f88a68 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 15 Apr 2010 19:03:12 +1000 Subject: Small calculator fix. --- demos/declarative/calculator/Core/calculator.js | 2 +- demos/declarative/calculator/calculator.qml | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/demos/declarative/calculator/Core/calculator.js b/demos/declarative/calculator/Core/calculator.js index 2b19de8..51b3dd3 100644 --- a/demos/declarative/calculator/Core/calculator.js +++ b/demos/declarative/calculator/Core/calculator.js @@ -54,7 +54,7 @@ function doOperation(op) { if (op == "1/x") { display.text = (1 / display.text.valueOf()).toString() - } else if (op == "^2") { + } else if (op == "x^2") { display.text = (display.text.valueOf() * display.text.valueOf()).toString() } else if (op == "Abs") { display.text = (Math.abs(display.text.valueOf())).toString() diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index fc2b95a..286a4d1 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -36,28 +36,28 @@ Rectangle { id: column; spacing: 6 property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6) + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) Row { spacing: 6 - property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) Button { id: rotateButton - width: parent.w; height: column.h; color: 'purple'; operation: rotateLeft + width: column.w; height: column.h; color: 'purple'; operation: rotateLeft } - Button { width: parent.w; height: column.h; color: 'purple'; operation: leftArrow } - Button { width: parent.w; height: column.h; color: 'purple'; operation: "C" } - Button { width: parent.w; height: column.h; color: 'purple'; operation: "AC" } + Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow } + Button { width: column.w; height: column.h; color: 'purple'; operation: "C" } + Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" } } Row { spacing: 6 property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) - Button { width: parent.w; height: column.h; color: 'green'; operation: "mc" } - Button { width: parent.w; height: column.h; color: 'green'; operation: "m+" } - Button { width: parent.w; height: column.h; color: 'green'; operation: "m-" } - Button { width: parent.w; height: column.h; color: 'green'; operation: "mr" } + Button { width: column.w; height: column.h; color: 'green'; operation: "mc" } + Button { width: column.w; height: column.h; color: 'green'; operation: "m+" } + Button { width: column.w; height: column.h; color: 'green'; operation: "m-" } + Button { width: column.w; height: column.h; color: 'green'; operation: "mr" } } Grid { -- cgit v0.12 From 794cbd5800a4428babc100528fd4fdba49557b6f Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 15 Apr 2010 12:48:56 +0200 Subject: Wrap EGL image function pointers and move into QEgl namespace QtGui exporting a symbol called eglCreateImageKHR seems a pretty silly idea. Much better to have them in the QEgl namespace. Reviewed-By: Iain --- src/gui/egl/qegl.cpp | 43 +++++++++++++++++++++++++++++++++++++------ src/gui/egl/qegl_p.h | 18 ++++-------------- src/opengl/qgl_x11egl.cpp | 8 ++------ src/openvg/qpixmapdata_vg.cpp | 12 ++++++------ 4 files changed, 49 insertions(+), 32 deletions(-) diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 3b007d7..0fe5cbe 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -535,10 +535,14 @@ QEglProperties QEglContext::configProperties() const return QEglProperties(config()); } -#if (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES) -_eglCreateImageKHR eglCreateImageKHR = 0; -_eglDestroyImageKHR eglDestroyImageKHR = 0; -#endif + +typedef EGLImageKHR (EGLAPIENTRY *_eglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*); +typedef EGLBoolean (EGLAPIENTRY *_eglDestroyImageKHR)(EGLDisplay, EGLImageKHR); + +// Defined in qegl.cpp: +static _eglCreateImageKHR qt_eglCreateImageKHR = 0; +static _eglDestroyImageKHR qt_eglDestroyImageKHR = 0; + EGLDisplay QEgl::display() { @@ -565,8 +569,8 @@ EGLDisplay QEgl::display() // Resolve the egl extension function pointers: #if (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES) if (QEgl::hasExtension("EGL_KHR_image") || QEgl::hasExtension("EGL_KHR_image_base")) { - eglCreateImageKHR = (_eglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR"); - eglDestroyImageKHR = (_eglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR"); + qt_eglCreateImageKHR = (_eglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR"); + qt_eglDestroyImageKHR = (_eglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR"); } #endif } @@ -574,6 +578,33 @@ EGLDisplay QEgl::display() return dpy; } +EGLImageKHR QEgl::eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) +{ + if (qt_eglCreateImageKHR) + return qt_eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list); + + QEgl::display(); // Initialises function pointers + if (qt_eglCreateImageKHR) + return qt_eglCreateImageKHR(dpy, ctx, target, buffer, attrib_list); + + qWarning("QEgl::eglCreateImageKHR() called but EGL_KHR_image(_base) extension not present"); + return 0; +} + +EGLBoolean QEgl::eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img) +{ + if (qt_eglDestroyImageKHR) + return qt_eglDestroyImageKHR(dpy, img); + + QEgl::display(); // Initialises function pointers + if (qt_eglDestroyImageKHR) + return qt_eglDestroyImageKHR(dpy, img); + + qWarning("QEgl::eglDestroyImageKHR() called but EGL_KHR_image(_base) extension not present"); + return 0; +} + + #ifndef Q_WS_X11 EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *properties) { diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h index f81add6..6345d5d 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -147,20 +147,6 @@ typedef void *EGLImageKHR; #define EGL_KHR_image_pixmap #endif -// It is possible that something has included eglext.h (like Symbian 10.1's broken egl.h), in -// which case, EGL_KHR_image/EGL_KHR_image_base will be defined. They may have also defined -// the actual function prototypes, but generally EGL_EGLEXT_PROTOTYPES will be defined in that -// case and we shouldn't re-define them here. -#if (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES) -typedef EGLImageKHR (EGLAPIENTRY *_eglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, EGLint*); -typedef EGLBoolean (EGLAPIENTRY *_eglDestroyImageKHR)(EGLDisplay, EGLImageKHR); - -// Defined in qegl.cpp: -extern Q_GUI_EXPORT _eglCreateImageKHR eglCreateImageKHR; -extern Q_GUI_EXPORT _eglDestroyImageKHR eglDestroyImageKHR; -#endif // (defined(EGL_KHR_image) || defined(EGL_KHR_image_base)) && !defined(EGL_EGLEXT_PROTOTYPES) - - class QEglProperties; @@ -210,6 +196,10 @@ namespace QEgl { Q_GUI_EXPORT EGLNativeWindowType nativeWindow(QWidget*); Q_GUI_EXPORT EGLNativePixmapType nativePixmap(QPixmap*); + // Extension functions + Q_GUI_EXPORT EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); + Q_GUI_EXPORT EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img); + #ifdef Q_WS_X11 Q_GUI_EXPORT VisualID getCompatibleVisualId(EGLConfig config); #endif diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index af0100b..6f210ce 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -378,8 +378,6 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons // eglCreateImageKHR & eglDestroyImageKHR without support for pixmaps, so we must // check we have the EGLImage from pixmap functionality. if (QEgl::hasExtension("EGL_KHR_image") || QEgl::hasExtension("EGL_KHR_image_pixmap")) { - Q_ASSERT(eglCreateImageKHR); - Q_ASSERT(eglDestroyImageKHR); // Being able to create an EGLImage from a native pixmap is also pretty useless // without the ability to bind that EGLImage as a texture, which is provided by @@ -436,15 +434,13 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons // If the pixmap doesn't already have a valid surface, try binding it via EGLImage // first, as going through EGLImage should be faster and better supported: if (!textureIsBound && haveEglImageTFP) { - Q_ASSERT(eglCreateImageKHR); - EGLImageKHR eglImage; EGLint attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; - eglImage = eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, + eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)QEgl::nativePixmap(pixmap), attribs); QGLContext* ctx = q; @@ -457,7 +453,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons // Once the egl image is bound, the texture becomes a new sibling image and we can safely // destroy the EGLImage we created for the pixmap: if (eglImage != EGL_NO_IMAGE_KHR) - eglDestroyImageKHR(QEgl::display(), eglImage); + QEgl::eglDestroyImageKHR(QEgl::display(), eglImage); } if (!textureIsBound && haveTFP) { diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index 168f06a..6258e0c 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -498,7 +498,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) } const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE}; - EGLImageKHR eglImage = eglCreateImageKHR(QEgl::display(), + EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)sgImage, @@ -513,7 +513,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) vgImage = vgCreateEGLImageTargetKHR(eglImage); if (vgGetError() != VG_NO_ERROR) { cleanup(); - eglDestroyImageKHR(QEgl::display(), eglImage); + QEgl::eglDestroyImageKHR(QEgl::display(), eglImage); driver.Close(); return; } @@ -527,7 +527,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) prevSize = QSize(w, h); setSerialNumber(++qt_vg_pixmap_serial); // release stuff - eglDestroyImageKHR(QEgl::display(), eglImage); + QEgl::eglDestroyImageKHR(QEgl::display(), eglImage); driver.Close(); #endif } else if (type == QPixmapData::FbsBitmap) { @@ -613,7 +613,7 @@ void* QVGPixmapData::toNativeType(NativeType type) } const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE}; - EGLImageKHR eglImage = eglCreateImageKHR(QEgl::display(), + EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)sgImage, @@ -626,7 +626,7 @@ void* QVGPixmapData::toNativeType(NativeType type) VGImage dstVgImage = vgCreateEGLImageTargetKHR(eglImage); if (vgGetError() != VG_NO_ERROR) { - eglDestroyImageKHR(QEgl::display(), eglImage); + QEgl::eglDestroyImageKHR(QEgl::display(), eglImage); sgImage->Close(); driver.Close(); return 0; @@ -642,7 +642,7 @@ void* QVGPixmapData::toNativeType(NativeType type) } // release stuff vgDestroyImage(dstVgImage); - eglDestroyImageKHR(QEgl::display(), eglImage); + QEgl::eglDestroyImageKHR(QEgl::display(), eglImage); driver.Close(); return reinterpret_cast(sgImage); #endif -- cgit v0.12 From 63224660526b199eabd08e1dfbd8956e764d768e Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Tue, 13 Apr 2010 13:21:15 +0200 Subject: Fix compile error with QT_NO_IMAGEFORMAT_XPM in QtGui Merge-request: 2327 Reviewed-by: Thierry Bastian --- src/gui/kernel/qapplication.cpp | 2 ++ src/gui/kernel/qapplication_p.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index b0a23d4..62e99e9 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -5936,6 +5936,7 @@ static const char * const link_xpm[] = { QPixmap QApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) { +#if defined(Q_WS_X11) || defined(Q_WS_WIN) if (!move_cursor) { move_cursor = new QPixmap((const char **)move_xpm); copy_cursor = new QPixmap((const char **)copy_xpm); @@ -5959,6 +5960,7 @@ QPixmap QApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) default: break; } +#endif return QPixmap(); } diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 6d71cfe..01abe54 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -520,9 +520,11 @@ public: QGestureManager *gestureManager; QWidget *gestureWidget; +#if defined(Q_WS_X11) || defined(Q_WS_WIN) QPixmap *move_cursor; QPixmap *copy_cursor; QPixmap *link_cursor; +#endif #if defined(Q_WS_WIN) QPixmap *ignore_cursor; #endif -- cgit v0.12 From 97caf6916a830b70f6a40a99a55fd4500b163c37 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Tue, 13 Apr 2010 13:22:01 +0200 Subject: Fix compile error with QT_NO_GRAPHICSVIEW in QtMultimedia Merge-request: 2333 Reviewed-by: Thierry Bastian --- src/multimedia/base/qgraphicsvideoitem.cpp | 5 +++++ src/multimedia/base/qgraphicsvideoitem.h | 3 +++ src/multimedia/playback/qmediaplayer.cpp | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/multimedia/base/qgraphicsvideoitem.cpp b/src/multimedia/base/qgraphicsvideoitem.cpp index f903eb7..c50d3ff 100644 --- a/src/multimedia/base/qgraphicsvideoitem.cpp +++ b/src/multimedia/base/qgraphicsvideoitem.cpp @@ -52,6 +52,8 @@ #include #endif +#ifndef QT_NO_GRAPHICSVIEW + QT_BEGIN_NAMESPACE @@ -434,4 +436,7 @@ bool QGraphicsVideoItem::sceneEvent(QEvent *event) } QT_END_NAMESPACE + +#endif // QT_NO_GRAPHICSVIEW + #include "moc_qgraphicsvideoitem.cpp" diff --git a/src/multimedia/base/qgraphicsvideoitem.h b/src/multimedia/base/qgraphicsvideoitem.h index e6f0d81..a20caf3 100644 --- a/src/multimedia/base/qgraphicsvideoitem.h +++ b/src/multimedia/base/qgraphicsvideoitem.h @@ -46,6 +46,7 @@ #include +#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW QT_BEGIN_HEADER @@ -109,4 +110,6 @@ QT_END_NAMESPACE QT_END_HEADER +#endif // QT_NO_GRAPHICSVIEW + #endif diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp index 9466cad..6b2e0f9 100644 --- a/src/multimedia/playback/qmediaplayer.cpp +++ b/src/multimedia/playback/qmediaplayer.cpp @@ -145,7 +145,9 @@ public: QMediaPlaylist *playlist; QPointer videoWidget; +#ifndef QT_NO_GRAPHICSVIEW QPointer videoItem; +#endif void _q_stateChanged(QMediaPlayer::State state); void _q_mediaStatusChanged(QMediaPlayer::MediaStatus status); @@ -618,26 +620,36 @@ void QMediaPlayer::bind(QObject *obj) } QVideoWidget *videoWidget = qobject_cast(obj); +#ifndef QT_NO_GRAPHICSVIEW QGraphicsVideoItem *videoItem = qobject_cast(obj); +#endif - if (videoWidget || videoItem) { + if (videoWidget +#ifndef QT_NO_GRAPHICSVIEW + || videoItem +#endif + ) { //detach the current video output if (d->videoWidget) { d->videoWidget->setMediaObject(0); d->videoWidget = 0; } +#ifndef QT_NO_GRAPHICSVIEW if (d->videoItem) { d->videoItem->setMediaObject(0); d->videoItem = 0; } +#endif } if (videoWidget) d->videoWidget = videoWidget; +#ifndef QT_NO_GRAPHICSVIEW if (videoItem) d->videoItem = videoItem; +#endif } } @@ -651,8 +663,10 @@ void QMediaPlayer::unbind(QObject *obj) if (obj == d->videoWidget) { d->videoWidget = 0; +#ifndef QT_NO_GRAPHICSVIEW } else if (obj == d->videoItem) { d->videoItem = 0; +#endif } else if (obj == d->playlist) { disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)), this, SLOT(_q_updateMedia(QMediaContent))); -- cgit v0.12 From b53f7d4ce3d5d9af47daf78c9f831acc532e688b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 15 Apr 2010 11:05:05 +0200 Subject: QListView: Re-fix scrollbar ranges Commit 11dea4a8b227801c110f791f350632bf6f0c958d fixing QTBUG-2678 was the wrong solution and introduced some regressions. Auto-test included. Reviewed-by: Thierry Task-number: QTBUG-2678 Task-number: QTBUG-9455 --- src/gui/itemviews/qlistview.cpp | 14 ++++++++++---- tests/auto/qlistview/tst_qlistview.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 39ca75a..1869093 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1853,14 +1853,14 @@ void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step) { horizontalScrollBar()->setSingleStep(step.width() + spacing()); horizontalScrollBar()->setPageStep(viewport()->width()); - horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width() - 2 * spacing()); + horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width()); } void QCommonListViewBase::updateVerticalScrollBar(const QSize &step) { verticalScrollBar()->setSingleStep(step.height() + spacing()); verticalScrollBar()->setPageStep(viewport()->height()); - verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height() - 2 * spacing()); + verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height()); } void QCommonListViewBase::scrollContentsBy(int dx, int dy, bool /*scrollElasticBand*/) @@ -2276,6 +2276,7 @@ void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info) const QPoint topLeft = initStaticLayout(info); QStyleOptionViewItemV4 option = viewOptions(); option.rect = info.bounds; + option.rect.adjust(info.spacing, info.spacing, -info.spacing, -info.spacing); // The static layout data structures are as follows: // One vector contains the coordinate in the direction of layout flow. @@ -2905,8 +2906,13 @@ void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info) batchStartRow = info.last + 1; bool done = (info.last >= rowCount() - 1); // resize the content area - if (done || !info.bounds.contains(item->rect())) - contentsSize = QSize(rect.width(), rect.height()); + if (done || !info.bounds.contains(item->rect())) { + contentsSize = rect.size(); + if (info.flow == QListView::LeftToRight) + contentsSize.rheight() += info.spacing; + else + contentsSize.rwidth() += info.spacing; + } // resize tree int insertFrom = info.first; if (done || info.first == 0) { diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index d2181f8..f5c32cd 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -123,6 +123,7 @@ private slots: void taskQTBUG_435_deselectOnViewportClick(); void taskQTBUG_2678_spacingAndWrappedText(); void taskQTBUG_5877_skippingItemInPageDownUp(); + void taskQTBUG_9455_wrongScrollbarRanges(); }; // Testing get/set functions @@ -1941,5 +1942,34 @@ void tst_QListView::taskQTBUG_5877_skippingItemInPageDownUp() } } +class ListView_9455 : public QListView +{ +public: + QSize contentsSize() const + { + return QListView::contentsSize(); + } +}; + +void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges() +{ + QStringList list; + const int nrItems = 8; + for (int i = 0; i < nrItems; i++) + list << QString().sprintf("item %d", i); + + QStringListModel model(list); + ListView_9455 w; + w.setModel(&model); + w.setViewMode(QListView::IconMode); + w.resize(116, 132); + w.setMovement(QListView::Static); + const int spacing = 40; + w.setSpacing(spacing); + w.show(); + QTest::qWaitForWindowShown(&w); + QCOMPARE(w.verticalScrollBar()->maximum(), w.contentsSize().height() - w.viewport()->geometry().height()); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" -- cgit v0.12 From 16ae00c689faac5d7af312ae31d7f715dc6e0745 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 16 Apr 2010 09:54:24 +1000 Subject: Correctly support translation in QDeclarativeCompiler Reviewed-by: Friedemann Kleint --- src/declarative/qml/qdeclarativecompiler.cpp | 6 ------ src/declarative/qml/qdeclarativecompiler_p.h | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 5c5ad37..065009a 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -67,7 +67,6 @@ #include "private/qdeclarativecompiledbindings_p.h" #include "private/qdeclarativeglobalscriptclass_p.h" -#include #include #include #include @@ -2947,9 +2946,4 @@ QStringList QDeclarativeCompiler::deferredProperties(QDeclarativeParser::Object return rv; } -QString QDeclarativeCompiler::tr(const char *str) -{ - return QCoreApplication::translate("QDeclarativeCompiler", str); -} - QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h index 002c6c9..867db2c 100644 --- a/src/declarative/qml/qdeclarativecompiler_p.h +++ b/src/declarative/qml/qdeclarativecompiler_p.h @@ -66,6 +66,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -148,6 +149,7 @@ private: class QMetaObjectBuilder; class Q_DECLARATIVE_EXPORT QDeclarativeCompiler { + Q_DECLARE_TR_FUNCTIONS(QDeclarativeCompiler) public: QDeclarativeCompiler(); @@ -279,8 +281,6 @@ private: void addId(const QString &, QDeclarativeParser::Object *); - QString tr(const char *); - void dumpStats(); struct BindingReference { -- cgit v0.12