From 7c77f60643d14864e579eeddb95ec54c8c963fd9 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 18 May 2009 19:06:10 +0200 Subject: remove unused line (the function is even in qtgui nowadays) --- src/corelib/kernel/qtranslator.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 77d6599..308ca24 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -206,8 +206,6 @@ static int numerusHelper(int n, const uchar *rules, int rulesSize) return -1; } -extern bool qt_detectRTLLanguage(); - class QTranslatorPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QTranslator) -- cgit v0.12 From 8e2d3cc2e84b6d8109c30a853ea40ff9cfa29bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 28 May 2009 15:05:21 +0200 Subject: Minor cleanup. Reviewed-by: Kim --- tests/auto/qdatastream/tst_qdatastream.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp index d7ca7bc..6a69fcc 100644 --- a/tests/auto/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/qdatastream/tst_qdatastream.cpp @@ -462,7 +462,7 @@ void tst_QDataStream::writeQString(QDataStream* s) { QString test(QStringData(dataIndex(QTest::currentDataTag()))); *s << test; - *s << QString("Faen her spyr man"); + *s << QString("Her er det noe tekst"); *s << test; *s << QString(); *s << test; @@ -480,7 +480,7 @@ void tst_QDataStream::readQString(QDataStream *s) *s >> S; QCOMPARE(S, test); *s >> S; - QCOMPARE(S, QString("Faen her spyr man")); + QCOMPARE(S, QString("Her er det noe tekst")); *s >> S; QCOMPARE(S, test); *s >> S; @@ -533,7 +533,7 @@ void tst_QDataStream::writeQRegExp(QDataStream* s) { QRegExp test(QRegExpData(dataIndex(QTest::currentDataTag()))); *s << test; - *s << QString("Faen her spyr man"); + *s << QString("Her er det noe tekst"); *s << test; *s << QString("nonempty"); *s << test; @@ -550,7 +550,7 @@ void tst_QDataStream::readQRegExp(QDataStream *s) *s >> R; QCOMPARE(R, test); *s >> S; - QCOMPARE(S, QString("Faen her spyr man")); + QCOMPARE(S, QString("Her er det noe tekst")); *s >> R; QCOMPARE(R, test); *s >> S; -- cgit v0.12 From 408ca46193f70ff66d060f7b7c506a97fee945e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 28 May 2009 15:07:01 +0200 Subject: Fixed a problem with streaming QIcons containing multiple pixmaps. If pixmaps were added through QIcon::addFile() with different sizes than the sizes of the pixmaps themselves, streaming the icon in didn't work properly. Task-number: 254374 Reviewed-by: Kim --- src/gui/image/qicon.cpp | 9 ++++++--- tests/auto/qicon/tst_qicon.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index a880a13..0799ea7 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -428,10 +428,13 @@ bool QPixmapIconEngine::read(QDataStream &in) in >> sz; in >> mode; in >> state; - if (pm.isNull()) + if (pm.isNull()) { addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state)); - else - addPixmap(pm, QIcon::Mode(mode), QIcon::State(state)); + } else { + QPixmapIconEngineEntry pe(fileName, sz, QIcon::Mode(mode), QIcon::State(state)); + pe.pixmap = pm; + pixmaps += pe; + } } return true; } diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp index 4e9a880..1dd223f 100644 --- a/tests/auto/qicon/tst_qicon.cpp +++ b/tests/auto/qicon/tst_qicon.cpp @@ -72,6 +72,8 @@ private slots: void svg(); void addFile(); void availableSizes(); + void streamAvailableSizes_data(); + void streamAvailableSizes(); void task184901_badCache(); void task223279_inconsistentAddFile(); @@ -540,6 +542,47 @@ void tst_QIcon::availableSizes() } } +void tst_QIcon::streamAvailableSizes_data() +{ + QTest::addColumn("icon"); + + QIcon icon; + icon.addFile(":/image.png", QSize(32,32)); + QTest::newRow( "32x32" ) << icon; + icon.addFile(":/image.png", QSize(64,64)); + QTest::newRow( "64x64" ) << icon; + icon.addFile(":/image.png", QSize(128,128)); + QTest::newRow( "128x128" ) << icon; + icon.addFile(":/image.png", QSize(256,256)); + QTest::newRow( "256x256" ) << icon; +} + +void tst_QIcon::streamAvailableSizes() +{ + QFETCH(QIcon, icon); + + QByteArray ba; + // write to QByteArray + { + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + QDataStream stream(&buffer); + stream << icon; + } + + // read from QByteArray + { + QBuffer buffer(&ba); + buffer.open(QIODevice::ReadOnly); + QDataStream stream(&buffer); + QIcon i; + stream >> i; + QCOMPARE(i.isNull(), icon.isNull()); + QCOMPARE(i.availableSizes(), icon.availableSizes()); + } +} + + static inline bool operator<(const QSize &lhs, const QSize &rhs) { if (lhs.width() < rhs.width()) -- cgit v0.12 From 09ae2f274b417bab4abee8900c5ad0a8f01d65b1 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Thu, 28 May 2009 16:39:48 +0200 Subject: Scroll the dirty region with WA_PaintOnScreen When QWidget::scroll() is called on a widget with WA_PaintOnScreen, scroll the dirty region. Task-number: 254742 Reviewed-by: bnilsen --- src/gui/kernel/qwidget_x11.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 6202b35..e00c37c 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -2487,6 +2487,8 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) QRect sr = valid_rect ? r : clipRect(); if (just_update) q->update(); + else if (!valid_rect) + dirty.translate(dx, dy); int x1, y1, x2, y2, w = sr.width(), h = sr.height(); if (dx > 0) { -- cgit v0.12 From 89029a54cb3adfb54736a6aafaea9ec535407592 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 28 May 2009 14:57:20 +0200 Subject: cosmetic changes to examples/dialogs/sipdialog main function has a return value now. On the HTC this example didn't work, because this stupid thing sends two resize events, if the SIP is opened (and only one if it is closed). Reviewed-by: mauricek --- examples/dialogs/sipdialog/dialog.cpp | 13 ++++++------- examples/dialogs/sipdialog/main.cpp | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/dialogs/sipdialog/dialog.cpp b/examples/dialogs/sipdialog/dialog.cpp index 9f1b9ad..653b518 100644 --- a/examples/dialogs/sipdialog/dialog.cpp +++ b/examples/dialogs/sipdialog/dialog.cpp @@ -90,7 +90,7 @@ Dialog::Dialog() //! [Dialog constructor part4] //! [Dialog constructor part5] - connect(button, SIGNAL(pressed()), + connect(button, SIGNAL(clicked()), qApp, SLOT(closeAllWindows())); connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), this, SLOT(desktopResized(int))); @@ -111,14 +111,13 @@ void Dialog::reactToSIP() { QRect availableGeometry = QApplication::desktop()->availableGeometry(0); - if (desktopGeometry.width() == availableGeometry.width()) { - if (desktopGeometry.height() > availableGeometry.height()) { + if (desktopGeometry != availableGeometry) { + if (windowState() | Qt::WindowMaximized) setWindowState(windowState() & ~Qt::WindowMaximized); - setGeometry(availableGeometry); - } else { - setWindowState(windowState() | Qt::WindowMaximized); - } + + setGeometry(availableGeometry); } + desktopGeometry = availableGeometry; } //! [reactToSIP() function] diff --git a/examples/dialogs/sipdialog/main.cpp b/examples/dialogs/sipdialog/main.cpp index 5fcbfd8..fec6de2 100644 --- a/examples/dialogs/sipdialog/main.cpp +++ b/examples/dialogs/sipdialog/main.cpp @@ -48,6 +48,6 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); Dialog dialog; - dialog.exec(); + return dialog.exec(); } //! [main() function] -- cgit v0.12 From 8e4300e2866fd28881853509df6ff054e13f841b Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 28 May 2009 14:46:39 +0200 Subject: Fix wrong sorting when using the QFileSystemModel with QTreeView An optimization was made to the sorting of QFileDialog to sort only the current root (meaning what the user see). This avoided slowness when the model was big with lots of leafs. The problem here is for the treeview, the root is always the same, we expands only nodes. In that case, a recursive sorting is needed to ensure that all expanded nodes are correctly sorted (and filtered). This will be slower that's why i use an hidden flag in the d pointer to deactivate the recursive sort for the QFileDialog. Task-number:254701 Reviewed-by:olivier BT:yes --- src/gui/dialogs/qfiledialog.cpp | 1 + src/gui/dialogs/qfilesystemmodel.cpp | 11 ++++ src/gui/dialogs/qfilesystemmodel_p.h | 7 ++- .../auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 65 +++++++++++++++++++++- 4 files changed, 80 insertions(+), 4 deletions(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index d42775a..d4d0136 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -2108,6 +2108,7 @@ void QFileDialogPrivate::createWidgets() #else model->setNameFilterDisables(false); #endif + model->d_func()->disableRecursiveSort = true; QFileDialog::connect(model, SIGNAL(fileRenamed(const QString &, const QString &, const QString &)), q, SLOT(_q_fileRenamed(const QString &, const QString &, const QString &))); QFileDialog::connect(model, SIGNAL(rootPathChanged(const QString &)), q, SLOT(_q_pathChanged(const QString &))); diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index 012d3a1..03017c3 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -1083,6 +1083,7 @@ private: */ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent) { + Q_Q(QFileSystemModel); QFileSystemModelPrivate::QFileSystemNode *indexNode = node(parent); if (indexNode->children.count() == 0) return; @@ -1106,6 +1107,16 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent indexNode->visibleChildren.append(values.at(i).first->fileName); values.at(i).first->isVisible = true; } + + if (!disableRecursiveSort) { + for (int i = 0; i < q->rowCount(parent); ++i) { + const QModelIndex childIndex = q->index(i, 0, parent); + QFileSystemModelPrivate::QFileSystemNode *indexNode = node(childIndex); + //Only do a recursive sort on visible nodes + if (indexNode->isVisible) + sortChildren(column, childIndex); + } + } } /*! diff --git a/src/gui/dialogs/qfilesystemmodel_p.h b/src/gui/dialogs/qfilesystemmodel_p.h index 61e8b4c..af4fada 100644 --- a/src/gui/dialogs/qfilesystemmodel_p.h +++ b/src/gui/dialogs/qfilesystemmodel_p.h @@ -208,7 +208,8 @@ public: readOnly(true), setRootPath(false), filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs), - nameFilterDisables(true) // false on windows, true on mac and unix + nameFilterDisables(true), // false on windows, true on mac and unix + disableRecursiveSort(false) { delayedSortTimer.setSingleShot(true); } @@ -294,6 +295,10 @@ public: QDir::Filters filters; QHash bypassFilters; bool nameFilterDisables; + //This flag is an optimization for the QFileDialog + //It enable a sort which is not recursive, it means + //we sort only what we see. + bool disableRecursiveSort; #ifndef QT_NO_REGEXP QList nameFilters; #endif diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index 59d57ce..b109d4b 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -43,6 +43,7 @@ #include #include "../../../src/gui/dialogs/qfilesystemmodel_p.h" #include +#include #include "../../shared/util.h" #include #include @@ -102,6 +103,7 @@ private slots: void setData_data(); void setData(); + void sort_data(); void sort(); void mkdir(); @@ -452,8 +454,12 @@ void tst_QFileSystemModel::rowsInserted() } else { QCOMPARE(model->index(model->rowCount(root) - 1, 0, root).data().toString(), QString("b")); } - if (spy0.count() > 0) - if (count == 0) QCOMPARE(spy0.count(), 0); else QVERIFY(spy0.count() >= 1); + if (spy0.count() > 0) { + if (count == 0) + QCOMPARE(spy0.count(), 0); + else + QVERIFY(spy0.count() >= 1); + } if (count == 0) QCOMPARE(spy1.count(), 0); else QVERIFY(spy1.count() >= 1); QVERIFY(createFiles(tmp, QStringList(".hidden_file"), 5 + count)); @@ -722,6 +728,19 @@ void tst_QFileSystemModel::setData() QTRY_COMPARE(model->rowCount(root), files.count()); } +class MyFriendFileSystemModel : public QFileSystemModel +{ + friend class tst_QFileSystemModel; + Q_DECLARE_PRIVATE(QFileSystemModel) +}; + +void tst_QFileSystemModel::sort_data() +{ + QTest::addColumn("fileDialogMode"); + QTest::newRow("standard usage") << false; + QTest::newRow("QFileDialog usage") << true; +} + void tst_QFileSystemModel::sort() { QTemporaryFile file; @@ -733,8 +752,48 @@ void tst_QFileSystemModel::sort() model->sort(0, Qt::AscendingOrder); model->sort(0, Qt::DescendingOrder); QVERIFY(idx.column() != 0); -} + QFETCH(bool, fileDialogMode); + + MyFriendFileSystemModel *myModel = new MyFriendFileSystemModel(); + QTreeView *tree = new QTreeView(); + + if (fileDialogMode) + myModel->d_func()->disableRecursiveSort = true; + + const QString dirPath = QString("%1/sortTemp").arg(QDir::tempPath()); + QDir dir(dirPath); + dir.mkpath(dirPath); + QVERIFY(dir.exists()); + dir.mkdir("a"); + dir.mkdir("b"); + dir.mkdir("c"); + dir.mkdir("d"); + dir.mkdir("e"); + dir.mkdir("f"); + dir.mkdir("g"); + QTemporaryFile tempFile(dirPath + "/rXXXXXX"); + tempFile.open(); + myModel->setRootPath(QDir::rootPath()); + tree->setModel(myModel); + tree->show(); + QTest::qWait(500); + tree->expand(myModel->index(dir.absolutePath(), 0)); + while (dir.cdUp()) + { + tree->expand(myModel->index(dir.absolutePath(), 0)); + } + QTest::qWait(250); + //File dialog Mode means sub trees are not sorted, only the current root + if (fileDialogMode) + QVERIFY(myModel->index(0, 1, myModel->index(dirPath, 0)).data(QFileSystemModel::FilePathRole).toString() != dirPath + QLatin1String("/a")); + else + QCOMPARE(myModel->index(0, 1, myModel->index(dirPath, 0)).data(QFileSystemModel::FilePathRole).toString(), dirPath + QLatin1String("/a")); + + delete tree; + delete myModel; + +} void tst_QFileSystemModel::mkdir() { -- cgit v0.12 From 4a82680736ace8abb46e6fb5e085e8622f154b2d Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 28 May 2009 17:24:53 +0200 Subject: Fix a ASSERT/Crash when adding two times the same QAction to a QGW. We were adding two times in the QActionPrivate list the entry for the current QGraphicsWidget if the action was existing before. Task-number:KDE Reviewed-by:bnilsen BT:yes --- src/gui/graphicsview/qgraphicswidget.cpp | 6 ++++-- tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 7f02fb9..7781258 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -1887,8 +1887,10 @@ void QGraphicsWidget::insertAction(QAction *before, QAction *action) } d->actions.insert(pos, action); - QActionPrivate *apriv = action->d_func(); - apriv->graphicsWidgets.append(this); + if (index == -1) { + QActionPrivate *apriv = action->d_func(); + apriv->graphicsWidgets.append(this); + } QActionEvent e(QEvent::ActionAdded, action, before); QApplication::sendEvent(this, &e); diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index b85abd3..1917357 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include "../../shared/util.h" @@ -147,6 +148,7 @@ private slots: void setSizes(); void closePopupOnOutsideClick(); void defaultSize(); + void shortcutsDeletion(); // Task fixes void task236127_bspTreeIndexFails(); @@ -1782,6 +1784,20 @@ void tst_QGraphicsWidget::defaultSize() } +void tst_QGraphicsWidget::shortcutsDeletion() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsWidget *widget2 = new QGraphicsWidget; + widget->setMinimumSize(40, 40); + QWidgetAction *del = new QWidgetAction(widget); + del->setIcon(QIcon("edit-delete")); + del->setShortcut(Qt::Key_Delete); + del->setShortcutContext(Qt::WidgetShortcut); + widget2->addAction(del); + widget2->addAction(del); + delete widget; +} + class ProxyStyle : public QCommonStyle { public: -- cgit v0.12 From 36ae58e7a6a888d3ae7bd162d59daada550bbfb1 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 28 May 2009 10:51:32 -0700 Subject: Warn when trying to use an unsupported format Due to incompatibilities between RGB32 in DirectFB and Qt we can't use RGB32. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 98e32ed..9e35a66 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -958,9 +958,6 @@ bool QDirectFBScreen::connect(const QString &displaySpec) return false; } - if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive)) - printDirectFBInfo(d_ptr->dfb, d_ptr->dfbSurface); - // Work out what format we're going to use for surfaces with an alpha channel d_ptr->alphaPixmapFormat = QDirectFBScreen::getImageFormat(d_ptr->dfbSurface); setPixelFormat(d_ptr->alphaPixmapFormat); @@ -971,12 +968,17 @@ bool QDirectFBScreen::connect(const QString &displaySpec) case QImage::Format_RGB444: d_ptr->alphaPixmapFormat = QImage::Format_ARGB4444_Premultiplied; break; + case QImage::Format_RGB32: + qWarning("QDirectFBScreen::connect(). Qt/DirectFB does not work with the RGB32 pixelformat. " + "We recommmend using ARGB instead"); + return false; + case QImage::Format_Indexed8: + qWarning("QDirectFBScreen::connect(). Qt/DirectFB does not work with the LUT8 pixelformat."); + return false; case QImage::NImageFormats: case QImage::Format_Invalid: case QImage::Format_Mono: case QImage::Format_MonoLSB: - case QImage::Format_Indexed8: - case QImage::Format_RGB32: case QImage::Format_RGB888: case QImage::Format_RGB16: case QImage::Format_RGB555: @@ -1037,6 +1039,9 @@ bool QDirectFBScreen::connect(const QString &displaySpec) setGraphicsSystem(d_ptr); + if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive)) + printDirectFBInfo(d_ptr->dfb, d_ptr->dfbSurface); + return true; } -- cgit v0.12 From 36bc35c451b6123b0e237430343a80db8a600b24 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 28 May 2009 10:57:45 -0700 Subject: Remove all force raster on RGB32 stuff Previously we allowed RGB32 but forced fallbacks for all drawing operations. It turns out blitting operations doesn't work right either so we'll rather just disallow this format altogether. See also 36ae58e7a6a888d3ae7bd162d59daada550bbfb1 Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintdevice.h | 4 -- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 77 +++++++++------------- .../gfxdrivers/directfb/qdirectfbpixmap.cpp | 23 +------ .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 3 - 4 files changed, 32 insertions(+), 75 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index 13f0a8f..180acaf 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -61,8 +61,6 @@ public: void lockDirectFB(uint flags); void unlockDirectFB(); - inline bool forceRasterPrimitives() const { return forceRaster; } - // Reimplemented from QCustomRasterPaintDevice: void* memory() const; QImage::Format format() const; @@ -77,7 +75,6 @@ protected: dfbSurface(0), lockedImage(0), screen(scr), - forceRaster(false), lock(0), mem(0) {} @@ -95,7 +92,6 @@ protected: QImage *lockedImage; QDirectFBScreen *screen; int bpl; - bool forceRaster; uint lock; uchar *mem; private: diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index a68bc8f..7535090 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -81,7 +81,7 @@ template <> inline const bool* ptr(const bool &) { return 0; } template static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, int scale, bool matrixRotShear, bool simplePen, - bool dfbHandledClip, bool forceRasterPrimitives, + bool dfbHandledClip, const char *nameOne, const T1 &one, const char *nameTwo, const T2 &two, const char *nameThree, const T3 &three) @@ -98,8 +98,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * dbg << "scale" << scale << "matrixRotShear" << matrixRotShear << "simplePen" << simplePen - << "dfbHandledClip" << dfbHandledClip - << "forceRasterPrimitives" << forceRasterPrimitives; + << "dfbHandledClip" << dfbHandledClip; const T1 *t1 = ptr(one); const T2 *t2 = ptr(two); @@ -125,7 +124,6 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * __FUNCTION__, state()->painter->device(), \ d_func()->scale, d_func()->matrixRotShear, \ d_func()->simplePen, d_func()->dfbCanHandleClip(), \ - d_func()->forceRasterPrimitives, \ #one, one, #two, two, #three, three); \ if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ return; @@ -140,7 +138,6 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * __FUNCTION__, state()->painter->device(), \ d_func()->scale, d_func()->matrixRotShear, \ d_func()->simplePen, d_func()->dfbCanHandleClip(), \ - d_func()->forceRasterPrimitives, \ #one, one, #two, two, #three, three); #else #define RASTERFALLBACK(op, one, two, three) @@ -263,7 +260,6 @@ private: QPen pen; bool antialiased; - bool forceRasterPrimitives; bool simplePen; @@ -408,8 +404,7 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) d->updateClip(); const QBrush &brush = state()->brush; if (!d->dfbCanHandleClip() || d->matrixRotShear - || !d->simplePen || d->forceRasterPrimitives - || !d->isSimpleBrush(brush)) { + || !d->simplePen || !d->isSimpleBrush(brush)) { RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); @@ -434,8 +429,7 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) d->updateClip(); const QBrush &brush = state()->brush; if (!d->dfbCanHandleClip() || d->matrixRotShear - || !d->simplePen || d->forceRasterPrimitives - || !d->isSimpleBrush(brush)) { + || !d->simplePen || !d->isSimpleBrush(brush)) { RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); @@ -458,7 +452,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) { Q_D(QDirectFBPaintEngine); d->updateClip(); - if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) { + if (!d->simplePen || !d->dfbCanHandleClip()) { RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); @@ -476,7 +470,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) { Q_D(QDirectFBPaintEngine); d->updateClip(); - if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) { + if (!d->simplePen || !d->dfbCanHandleClip()) { RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); @@ -691,8 +685,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) if (d->dfbCanHandleClip(rect) && !d->matrixRotShear) { switch (brush.style()) { case Qt::SolidPattern: { - if (d->forceRasterPrimitives) - break; d->unlock(); d->setDFBColor(brush.color()); const QRect r = d->transform.mapRect(rect).toRect(); @@ -720,7 +712,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) { Q_D(QDirectFBPaintEngine); d->updateClip(); - if (!d->dfbCanHandleClip() || d->matrixRotShear || d->forceRasterPrimitives) { + if (!d->dfbCanHandleClip() || d->matrixRotShear) { RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); d->lock(); QRasterPaintEngine::fillRect(rect, color); @@ -737,38 +729,32 @@ void QDirectFBPaintEngine::drawColorSpans(const QSpan *spans, int count, uint color) { Q_D(QDirectFBPaintEngine); - if (d->forceRasterPrimitives) { - RASTERFALLBACK(DRAW_COLORSPANS, count, color, VOID_ARG()); - d->lock(); - QRasterPaintEngine::drawColorSpans(spans, count, color); - } else { - color = INV_PREMUL(color); - - QVarLengthArray lines(count); - int j = 0; - for (int i = 0; i < count; ++i) { - if (spans[i].coverage == 255) { - lines[j].x1 = spans[i].x; - lines[j].y1 = spans[i].y; - lines[j].x2 = spans[i].x + spans[i].len - 1; - lines[j].y2 = spans[i].y; - ++j; - } else { - DFBSpan span = { spans[i].x, spans[i].len }; - uint c = BYTE_MUL(color, spans[i].coverage); - // ### how does this play with setDFBColor - d->surface->SetColor(d->surface, - qRed(c), qGreen(c), qBlue(c), qAlpha(c)); - d->surface->FillSpans(d->surface, spans[i].y, &span, 1); - } - } - if (j > 0) { + color = INV_PREMUL(color); + + QVarLengthArray lines(count); + int j = 0; + for (int i = 0; i < count; ++i) { + if (spans[i].coverage == 255) { + lines[j].x1 = spans[i].x; + lines[j].y1 = spans[i].y; + lines[j].x2 = spans[i].x + spans[i].len - 1; + lines[j].y2 = spans[i].y; + ++j; + } else { + DFBSpan span = { spans[i].x, spans[i].len }; + uint c = BYTE_MUL(color, spans[i].coverage); + // ### how does this play with setDFBColor d->surface->SetColor(d->surface, - qRed(color), qGreen(color), qBlue(color), - qAlpha(color)); - d->surface->DrawLines(d->surface, lines.data(), j); + qRed(c), qGreen(c), qBlue(c), qAlpha(c)); + d->surface->FillSpans(d->surface, spans[i].y, &span, 1); } } + if (j > 0) { + d->surface->SetColor(d->surface, + qRed(color), qGreen(color), qBlue(color), + qAlpha(color)); + d->surface->DrawLines(d->surface, lines.data(), j); + } } void QDirectFBPaintEngine::drawBufferSpan(const uint *buffer, int bufsize, @@ -803,7 +789,7 @@ void QDirectFBPaintEngine::initImageCache(int size) QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) - : surface(0), antialiased(false), forceRasterPrimitives(false), simplePen(false), + : surface(0), antialiased(false), simplePen(false), matrixRotShear(false), scale(NoScale), lastLockedHeight(-1), fbWidth(-1), fbHeight(-1), opacity(255), drawFlagsFromCompositionMode(0), blitFlagsFromCompositionMode(0), porterDuffRule(DSPD_SRC_OVER), dirtyClip(true), @@ -896,7 +882,6 @@ void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device) device->devType()); } lockedMemory = 0; - forceRasterPrimitives = dfbDevice->forceRasterPrimitives(); surface->GetSize(surface, &fbWidth, &fbHeight); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index c9b676a..dba1b51 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -76,7 +76,6 @@ void QDirectFBPixmapData::resize(int width, int height) format, QDirectFBScreen::TrackSurface); alpha = false; - forceRaster = (format == QImage::Format_RGB32); if (!dfbSurface) { invalidate(); qWarning("QDirectFBPixmapData::resize(): Unable to allocate surface"); @@ -187,7 +186,6 @@ void QDirectFBPixmapData::fromImage(const QImage &i, } dfbSurface = screen->copyToDFBSurface(img, format, QDirectFBScreen::TrackSurface); - forceRaster = (format == QImage::Format_RGB32); if (!dfbSurface) { qWarning("QDirectFBPixmapData::fromImage()"); invalidate(); @@ -216,7 +214,6 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) invalidate(); return; } - forceRaster = (format == QImage::Format_RGB32); if (hasAlpha) { dfbSurface->Clear(dfbSurface, 0, 0, 0, 0); @@ -268,7 +265,6 @@ void QDirectFBPixmapData::fill(const QColor &color) screen->releaseDFBSurface(dfbSurface); format = screen->alphaPixmapFormat(); dfbSurface = screen->createDFBSurface(size, screen->alphaPixmapFormat(), QDirectFBScreen::TrackSurface); - forceRaster = false; setSerialNumber(++global_ser_no); if (!dfbSurface) { qWarning("QDirectFBPixmapData::fill()"); @@ -277,24 +273,7 @@ void QDirectFBPixmapData::fill(const QColor &color) } } - if (forceRaster) { - // in DSPF_RGB32 all dfb drawing causes the Alpha byte to be - // set to 0. This causes issues for the raster engine. - uchar *mem = QDirectFBScreen::lockSurface(dfbSurface, DSLF_WRITE, &bpl); - if (mem) { - const int h = QPixmapData::height(); - const int w = QPixmapData::width() * 4; // 4 bytes per 32 bit pixel - const int c = color.rgba(); - for (int i = 0; i < h; ++i) { - memset(mem, c, w); - mem += bpl; - } - dfbSurface->Unlock(dfbSurface); - } - } else { - dfbSurface->Clear(dfbSurface, color.red(), color.green(), color.blue(), - color.alpha()); - } + dfbSurface->Clear(dfbSurface, color.red(), color.green(), color.blue(), color.alpha()); } QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index cd8796b..c7cae80 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -127,7 +127,6 @@ void QDirectFBWindowSurface::createWindow() dfbSurface->Release(dfbSurface); dfbWindow->GetSurface(dfbWindow, &dfbSurface); - forceRaster = (format == QImage::Format_RGB32); #endif } #endif // QT_NO_DIRECTFB_WM @@ -164,7 +163,6 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect, const QRegion &mask) rect.width(), rect.height() }; result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface); } - forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32); } else { const bool isResize = rect.size() != geometry().size(); #ifdef QT_NO_DIRECTFB_WM @@ -179,7 +177,6 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect, const QRegion &mask) } dfbSurface = screen->createDFBSurface(rect.size(), screen->pixelFormat(), QDirectFBScreen::DontTrackSurface); - forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32); } else { Q_ASSERT(dfbSurface); } -- cgit v0.12 From 2a986b86f841b798cc754fe5c5390c6fee95ce71 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 28 May 2009 13:20:48 -0700 Subject: Changes for DirectFB Reviewed-by: TrustMe --- dist/changes-4.5.2 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dist/changes-4.5.2 b/dist/changes-4.5.2 index 1e00208..dcb77d6 100644 --- a/dist/changes-4.5.2 +++ b/dist/changes-4.5.2 @@ -139,6 +139,26 @@ Qt for Windows CE * Plugins * **************************************************************************** +- directfb + * Make sure we pick an approriate format for pixmaps. E.g. use the same as + the primary surface for opaque pixmaps and pick an appropriate one for + transparent pixmaps if the primary surface format is not transparent. + * Properly fall back to the raster engine for pens that aren't solidcolor + * Properly fall back to raster engine with "mirrored" scales + * Make sure window surfaces are the approriate pixel format and created in + video memory if supported + * Fix clipping bug that would cause painting errors + * Fix various crash bugs + * Fix bugs when transforming/copying pixmaps with alpha channel + * Fix various bugs with regards to painting with alpha channel/porter duff + * Optimize a coupld of internal functions to slightly speed up drawing + * Optimize raster fall backs + * Allow more customization for Flipping options + * Fix drawing with opacity != 1.0 + * Support for better logging when trying to debug performance problems. + * Fix bug in keyboard handling that caused modifiers not to work + * Get rid of some compiler warnings + **************************************************************************** * Important Behavior Changes * -- cgit v0.12 From 8acc20e525d589e0c4450fbd60141e8b9c3f40e9 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 29 May 2009 15:23:17 +1000 Subject: Fixed compile with MinGW. MinGW 3.4.5 can't figure out the automatic QLatin1Char -> QString conversion in this code. --- src/corelib/io/qfsfileengine_win.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 790f1eb..9da9e66 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1770,10 +1770,10 @@ QString QFSFileEngine::fileName(FileName file) const if(slash == -1) { if(d->filePath.length() >= 2 && d->filePath.at(1) == QLatin1Char(':')) return d->filePath.left(2); - return QLatin1Char('.'); + return QString(QLatin1Char('.')); } else { if(!slash) - return QLatin1Char('/'); + return QString(QLatin1Char('/')); if(slash == 2 && d->filePath.length() >= 2 && d->filePath.at(1) == QLatin1Char(':')) slash++; return d->filePath.left(slash); @@ -1831,7 +1831,7 @@ QString QFSFileEngine::fileName(FileName file) const if (slash == -1) ret = QDir::currentPath(); else if (slash == 0) - ret = QLatin1Char('/'); + ret = QString(QLatin1Char('/')); ret = ret.left(slash); } return ret; -- cgit v0.12 From b946da648af0c5fa1c73fe1e57b0b1e08fb14d13 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Tue, 26 May 2009 18:31:01 +0200 Subject: Ensure a hierarchy of menus fade out together. On Mac OS X, when you have a large hierarchies of menus and you select the item at the end of the hierarchy. It will flash and then the rest will fade out at the same time. Qt would do a phased approach which was what no one expected. Introduce a QMacWindowFader class that can hold an arbitrary number of qwidgets and then on command fade them all down pased on the set duration. The API is a bit clumsy but is prefect for this internal API. Task-#: 251700 Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qt_cocoa_helpers_mac.mm | 79 ++++++++++++++++++++++++++-------- src/gui/kernel/qt_mac_p.h | 15 +++++++ src/gui/widgets/qmenu.cpp | 40 +++++++++++------ src/gui/widgets/qmenu_p.h | 2 +- 4 files changed, 103 insertions(+), 33 deletions(-) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 9165836..554e9d5 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -88,6 +88,52 @@ QT_BEGIN_NAMESPACE +Q_GLOBAL_STATIC(QMacWindowFader, macwindowFader); + +QMacWindowFader::QMacWindowFader() + : m_duration(0.250) +{ +} + +QMacWindowFader *QMacWindowFader::currentFader() +{ + return macwindowFader(); +} + +void QMacWindowFader::registerWindowToFade(QWidget *window) +{ + m_windowsToFade.append(window); +} + +void QMacWindowFader::performFade() +{ + const QWidgetList myWidgetsToFade = m_windowsToFade; + const int widgetCount = myWidgetsToFade.count(); +#if QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; + [NSAnimationContext beginGrouping]; + [[NSAnimationContext currentContext] setDuration:NSTimeInterval(m_duration)]; +#endif + + for (int i = 0; i < widgetCount; ++i) { + QWidget *widget = m_windowsToFade.at(i); + OSWindowRef window = qt_mac_window_for(widget); +#if QT_MAC_USE_COCOA + [[window animator] setAlphaValue:0.0]; + QTimer::singleShot(qRound(m_duration * 1000), widget, SLOT(hide())); +#else + TransitionWindowOptions options = {0, m_duration, 0, 0}; + TransitionWindowWithOptions(window, kWindowFadeTransitionEffect, kWindowHideTransitionAction, + 0, 1, &options); +#endif + } +#if QT_MAC_USE_COCOA + [NSAnimationContext endGrouping]; +#endif + m_duration = 0.250; + m_windowsToFade.clear(); +} + extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // qapplication.cpp; extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm extern QWidget * mac_mouse_grabber; @@ -95,29 +141,26 @@ extern QWidget * mac_mouse_grabber; void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds) { OSWindowRef wnd = static_cast(window); - if( wnd ) { + if (wnd) { + QWidget *widget; #if QT_MAC_USE_COCOA - QMacCocoaAutoReleasePool pool; - [NSAnimationContext beginGrouping]; - [[wnd animator] setAlphaValue:0.0]; - if (durationSeconds > 0) { - [[NSAnimationContext currentContext] setDuration:NSTimeInterval(durationSeconds)]; - } else { - durationSeconds = [[NSAnimationContext currentContext] duration]; - } - [NSAnimationContext endGrouping]; - QTimer::singleShot(qRound(durationSeconds * 1000), [wnd QT_MANGLE_NAMESPACE(qt_qwidget)], SLOT(hide())); + widget = [wnd QT_MANGLE_NAMESPACE(qt_qwidget)]; #else - if (durationSeconds <= 0) - durationSeconds = 0.15; - TransitionWindowOptions options = {0, durationSeconds, 0, 0}; - TransitionWindowWithOptions(wnd, kWindowFadeTransitionEffect, kWindowHideTransitionAction, 0, 1, &options); + const UInt32 kWidgetCreatorQt = kEventClassQt; + enum { + kWidgetPropertyQWidget = 'QWId' //QWidget * + }; + if (GetWindowProperty(static_cast(window), kWidgetCreatorQt, kWidgetPropertyQWidget, sizeof(widget), 0, &widget) != noErr) + widget = 0; #endif - } + if (widget) { + QMacWindowFader::currentFader()->setFadeDuration(durationSeconds); + QMacWindowFader::currentFader()->registerWindowToFade(widget); + QMacWindowFader::currentFader()->performFade(); + } + } } - - bool macWindowIsTextured( void * /*OSWindowRef*/ window ) { OSWindowRef wnd = static_cast(window); diff --git a/src/gui/kernel/qt_mac_p.h b/src/gui/kernel/qt_mac_p.h index ca995dc..3b0f546 100644 --- a/src/gui/kernel/qt_mac_p.h +++ b/src/gui/kernel/qt_mac_p.h @@ -120,6 +120,21 @@ public: } }; +// Class for chaining to gether a bunch of fades. It pretty much is only used for qmenu fading. +class QMacWindowFader +{ + QWidgetList m_windowsToFade; + float m_duration; + Q_DISABLE_COPY(QMacWindowFader) +public: + QMacWindowFader(); // PLEASE DON'T CALL THIS. + static QMacWindowFader *currentFader(); + void registerWindowToFade(QWidget *window); + void setFadeDuration(float durationInSecs) { m_duration = durationInSecs; } + float fadeDuration() const { return m_duration; } + void performFade(); +}; + class Q_GUI_EXPORT QMacCocoaAutoReleasePool { private: diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 3004841..50100af 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -398,9 +398,12 @@ QRect QMenuPrivate::actionRect(QAction *act) const return ret; } +static const float MenuFadeTimeInSec = 0.150; + void QMenuPrivate::hideUpToMenuBar() { Q_Q(QMenu); + bool fadeMenus = q->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide); if (!tornoff) { QWidget *caused = causedPopup.widget; hideMenu(q); //hide after getting causedPopup @@ -415,8 +418,9 @@ void QMenuPrivate::hideUpToMenuBar() if (QMenu *m = qobject_cast(caused)) { caused = m->d_func()->causedPopup.widget; if (!m->d_func()->tornoff) - hideMenu(m); - m->d_func()->setCurrentAction(0); + hideMenu(m, fadeMenus); + if (!fadeMenus) // Mac doesn't clear the action until after hidden. + m->d_func()->setCurrentAction(0); } else { #ifndef QT_NO_TOOLBUTTON if (qobject_cast(caused) == 0) @@ -425,26 +429,32 @@ void QMenuPrivate::hideUpToMenuBar() caused = 0; } } +#if defined(Q_WS_MAC) + if (fadeMenus) { + QEventLoop eventLoop; + QTimer::singleShot(int(MenuFadeTimeInSec * 1000), &eventLoop, SLOT(quit())); + QMacWindowFader::currentFader()->performFade(); + eventLoop.exec(); + } +#endif } setCurrentAction(0); } -void QMenuPrivate::hideMenu(QMenu *menu) +void QMenuPrivate::hideMenu(QMenu *menu, bool justRegister) { if (!menu) return; - #if !defined(QT_NO_EFFECTS) menu->blockSignals(true); aboutToHide = true; // Flash item which is about to trigger (if any). if (menu->style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem) - && currentAction && currentAction == actionAboutToTrigger) { - + && currentAction && currentAction == actionAboutToTrigger + && menu->actions().contains(currentAction)) { QEventLoop eventLoop; QAction *activeAction = currentAction; - // Deselect and wait 60 ms. menu->setActiveAction(0); QTimer::singleShot(60, &eventLoop, SLOT(quit())); eventLoop.exec(); @@ -458,22 +468,24 @@ void QMenuPrivate::hideMenu(QMenu *menu) // Fade out. if (menu->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide)) { // ### Qt 4.4: - // Should be something like: q->transitionWindow(Qt::FadeOutTransition, 150); + // Should be something like: q->transitionWindow(Qt::FadeOutTransition, MenuFadeTimeInSec); // Hopefully we'll integrate qt/research/windowtransitions into main before 4.4. // Talk to Richard, Trenton or Bjoern. #if defined(Q_WS_MAC) - macWindowFade(qt_mac_window_for(menu)); // FIXME - what is the default duration for view animations + if (justRegister) { + QMacWindowFader::currentFader()->setFadeDuration(MenuFadeTimeInSec); + QMacWindowFader::currentFader()->registerWindowToFade(menu); + } else { + macWindowFade(qt_mac_window_for(menu), MenuFadeTimeInSec); + } - // Wait for the transition to complete. - QEventLoop eventLoop; - QTimer::singleShot(150, &eventLoop, SLOT(quit())); - eventLoop.exec(); #endif // Q_WS_MAC } aboutToHide = false; menu->blockSignals(false); #endif // QT_NO_EFFECTS - menu->hide(); + if (!justRegister) + menu->hide(); } void QMenuPrivate::popupAction(QAction *action, int delay, bool activateFirst) diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index edfeee7..9654126 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -220,7 +220,7 @@ public: virtual QList > calcCausedStack() const; QMenuCaused causedPopup; void hideUpToMenuBar(); - void hideMenu(QMenu *menu); + void hideMenu(QMenu *menu, bool delay = true); //index mappings inline QAction *actionAt(int i) const { return q_func()->actions().at(i); } -- cgit v0.12 From f67bc13bc8e2d2c76d7d9f12abb1dbda85abe337 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Fri, 29 May 2009 10:22:24 +0200 Subject: Doc - marked QFileDialog::setOption() with the since 4.5 tag. Task-number: 254549 Reviewed-by: TrustMe --- src/gui/dialogs/qfiledialog.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index d4d0136..405e71e 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -565,8 +565,9 @@ bool QFileDialogPrivate::canBeNativeDialog() } /*! - Sets the given \a option to be enabled if \a on is true; - otherwise, clears the given \a option. + \since 4.5 + Sets the given \a option to be enabled if \a on is true; otherwise, + clears the given \a option. \sa options, testOption() */ -- cgit v0.12 From 7bc17b5b9ff9f2e3e04f36fec8ccbb546d9b7a31 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 29 May 2009 10:48:53 +0200 Subject: Fixed build issues with MSVC in atomic operations, we declare Interlock... functions in the namespace That can confuse the compiler because they are also declared in another header outside the namespace. Same problem in clucene where we include windows.h from within the NS. Task-number: 254214 Reviewed-by: ogoffart --- src/corelib/arch/qatomic_windows.h | 14 ++++++++++++++ tools/assistant/lib/fulltextsearch/qclucene_global_p.h | 16 ++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/corelib/arch/qatomic_windows.h b/src/corelib/arch/qatomic_windows.h index ac26b4f..5135575 100644 --- a/src/corelib/arch/qatomic_windows.h +++ b/src/corelib/arch/qatomic_windows.h @@ -220,6 +220,9 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueTo #if !defined(Q_OS_WINCE) // use compiler intrinsics for all atomic functions +//those functions need to be define in the global namespace +QT_END_NAMESPACE + extern "C" { long __cdecl _InterlockedIncrement(volatile long *); long __cdecl _InterlockedDecrement(volatile long *); @@ -252,6 +255,9 @@ extern "C" { # define _InterlockedExchangeAddPointer(a,b) \ _InterlockedExchangeAdd(reinterpret_cast(a), long(b)) # endif + +QT_BEGIN_NAMESPACE + inline bool QBasicAtomicInt::ref() { return _InterlockedIncrement(reinterpret_cast(&_q_value)) != 0; @@ -335,6 +341,8 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueTo #define Q_ARGUMENT_TYPE #endif +QT_END_NAMESPACE + extern "C" { long __cdecl InterlockedIncrement(long Q_ARGUMENT_TYPE * lpAddend); long __cdecl InterlockedDecrement(long Q_ARGUMENT_TYPE * lpAddend); @@ -351,6 +359,8 @@ long __cdecl InterlockedExchangeAdd(long Q_ARGUMENT_TYPE * Addend, long Value); # pragma intrinsic (_InterlockedExchangeAdd) #endif +QT_BEGIN_NAMESPACE + #endif @@ -409,6 +419,8 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueTo // MinGW's definition, such that we pick up variations in the headers. #ifndef __INTERLOCKED_DECLARED #define __INTERLOCKED_DECLARED +QT_END_NAMESPACE + extern "C" { __declspec(dllimport) long __stdcall InterlockedCompareExchange(long *, long, long); __declspec(dllimport) long __stdcall InterlockedIncrement(long *); @@ -416,6 +428,8 @@ extern "C" { __declspec(dllimport) long __stdcall InterlockedExchange(long *, long); __declspec(dllimport) long __stdcall InterlockedExchangeAdd(long *, long); } + +QT_BEGIN_NAMESPACE #endif inline bool QBasicAtomicInt::ref() diff --git a/tools/assistant/lib/fulltextsearch/qclucene_global_p.h b/tools/assistant/lib/fulltextsearch/qclucene_global_p.h index 2a9d146..3dba45a 100644 --- a/tools/assistant/lib/fulltextsearch/qclucene_global_p.h +++ b/tools/assistant/lib/fulltextsearch/qclucene_global_p.h @@ -29,6 +29,14 @@ #include #include +#if !defined(_MSC_VER) && defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T) +# if !defined(TCHAR) +# define TCHAR wchar_t +# endif +#else +# include +#endif + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -87,14 +95,6 @@ QT_BEGIN_NAMESPACE # define CL_NS2(sub,sub2) #endif -#if !defined(_MSC_VER) && defined(_CL_HAVE_WCHAR_H) && defined(_CL_HAVE_WCHAR_T) -# if !defined(TCHAR) -# define TCHAR wchar_t -# endif -#else -# include -#endif - namespace { TCHAR* QStringToTChar(const QString &str) { -- cgit v0.12 From e08f3e7bf3dbae6036ab89248793b98330971269 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 29 May 2009 09:21:16 +0200 Subject: Only display the choice of license if we can find the files Task-number: 254451 Reviewed-by: eskil BT: yes --- tools/configure/configureapp.cpp | 43 +++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index a6b06a6..b9d172f 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -3483,12 +3483,15 @@ void Configure::readLicense() dictionary[ "PLATFORM NAME" ] = (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/src/corelib/kernel/qfunctions_wince.h") && (dictionary.value("QMAKESPEC").startsWith("wince") || dictionary.value("XQMAKESPEC").startsWith("wince"))) ? "Qt for Windows CE" : "Qt for Windows"; + dictionary["LICENSE FILE"] = sourcePath; + bool openSource = false; + bool hasOpenSource = QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.GPL3") || QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.LGPL"); if (dictionary["BUILDNOKIA"] == "yes" || dictionary["BUILDTYPE"] == "commercial") { openSource = false; } else if (dictionary["BUILDTYPE"] == "opensource") { openSource = true; - } else { + } else if (hasOpenSource) { // No Open Source? Just display the commercial license right away forever { char accept = '?'; cout << "Which edition of Qt do you want to use ?" << endl; @@ -3506,28 +3509,23 @@ void Configure::readLicense() } } } - if (openSource) { - dictionary["LICENSE FILE"] = sourcePath; - if (QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.GPL3") || QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.LGPL")) { - cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " Open Source Edition." << endl; - licenseInfo["LICENSEE"] = "Open Source"; - dictionary["EDITION"] = "OpenSource"; - dictionary["QT_EDITION"] = "QT_EDITION_OPENSOURCE"; - cout << endl; - if (!showLicense(dictionary["LICENSE FILE"])) { - cout << "Configuration aborted since license was not accepted"; - dictionary["DONE"] = "error"; - return; - } + if (hasOpenSource && openSource) { + cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " Open Source Edition." << endl; + licenseInfo["LICENSEE"] = "Open Source"; + dictionary["EDITION"] = "OpenSource"; + dictionary["QT_EDITION"] = "QT_EDITION_OPENSOURCE"; + cout << endl; + if (!showLicense(dictionary["LICENSE FILE"])) { + cout << "Configuration aborted since license was not accepted"; + dictionary["DONE"] = "error"; return; } -#ifndef COMMERCIAL_VERSION - else { - cout << endl << "Cannot find the GPL license files!" << endl; + } else if (openSource) { + cout << endl << "Cannot find the GPL license files! Please download the Open Source version of the library." << endl; dictionary["DONE"] = "error"; } -#else - } else { +#ifdef COMMERCIAL_VERSION + else { Tools::checkLicense(dictionary, licenseInfo, firstLicensePath()); if (dictionary["DONE"] != "error" && dictionary["BUILDNOKIA"] != "yes") { // give the user some feedback, and prompt for license acceptance @@ -3539,7 +3537,12 @@ void Configure::readLicense() } } } -#endif // COMMERCIAL_VERSION +#else // !COMMERCIAL_VERSION + else { + cout << endl << "Cannot build commercial edition from the open source version of the library." << endl; + dictionary["DONE"] = "error"; + } +#endif } void Configure::reloadCmdLine() -- cgit v0.12 From 87acb1722d9db66aa01d238b6e4ac90dfe095ff0 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 29 May 2009 09:25:59 +0200 Subject: New configure.exe binary Task-number: 254451 Reviewed-by: trustme BT: yes --- configure.exe | Bin 856064 -> 856064 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/configure.exe b/configure.exe index 40843b4..9da5c60 100644 Binary files a/configure.exe and b/configure.exe differ -- cgit v0.12 From 909f96a4f92ad3c9fed1dc4c3873b638421568b0 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 29 May 2009 10:07:06 +0200 Subject: Remove the fixFilename() usage from the solution generator Only the Solution Generator was using the fixFilename() function, so under some circumstances the solution filename wouldn't find the correct vcproj file to include. This created a problem with network-chat.vcproj. Task-number: 254772 Reviewed-by: joao --- qmake/generators/win32/msvc_vcproj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 8901289..13bc05b 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -574,7 +574,7 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) } // We assume project filename is [QMAKE_ORIG_TARGET].vcproj - QString vcproj = unescapeFilePath(fixFilename(tmp_vcproj.project->first("QMAKE_ORIG_TARGET")) + project->first("VCPROJ_EXTENSION")); + QString vcproj = unescapeFilePath(tmp_vcproj.project->first("QMAKE_ORIG_TARGET") + project->first("VCPROJ_EXTENSION")); QString vcprojDir = qmake_getpwd(); // If file doesn't exsist, then maybe the users configuration -- cgit v0.12 From 7de43fbe1dda9dd823483412cd66c44a6932023b Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 29 May 2009 11:12:37 +0200 Subject: Mac: App menus reactivated when a sheet is used on a modal dialog. We need to check all window anchestors of the sheet to make sure that there it is not in effekt application modal Task-number: 254543 Reviewed-by: Trenton Schulz --- src/gui/widgets/qmenu_mac.mm | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index cce083f..87c886c 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1829,6 +1829,9 @@ OSMenuRef QMenuBar::macMenu() { return d_func()->macMenu(); } */ static bool qt_mac_is_ancestor(QWidget* possibleAncestor, QWidget *child) { + if (!possibleAncestor) + return false; + QWidget * current = child->parentWidget(); while (current != 0) { if (current == possibleAncestor) @@ -1847,22 +1850,19 @@ static bool qt_mac_should_disable_menu(QMenuBar *menuBar, QWidget *modalWidget) { if (modalWidget == 0 || menuBar == 0) return false; - const Qt::WindowModality modality = modalWidget->windowModality(); - if (modality == Qt::ApplicationModal) { - return true; - } else if (modality == Qt::WindowModal) { - QWidget * parent = menuBar->parentWidget(); - - // Special case for the global menu bar: It's not associated - // with a window so don't disable it. - if (parent == 0) - return false; - // Disable menu entries in menu bars that belong to ancestors of - // the modal widget, leave entries in unrelated menu bars enabled. - return qt_mac_is_ancestor(parent, modalWidget); + // If there is an application modal window on + // screen, the entries of the menubar should be disabled: + QWidget *w = modalWidget; + while (w) { + if (w->isVisible() && w->windowModality() == Qt::ApplicationModal) + return true; + w = w->parentWidget(); } - return false; // modality == NonModal + + // INVARIANT: modalWidget is window modal. Disable menu entries + // if the menu bar belongs to an ancestor of modalWidget: + return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget); } static void cancelAllMenuTracking() -- cgit v0.12 From 766cf07cbe7ebfda01dad163bb070fff7e3077d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 29 May 2009 11:58:32 +0200 Subject: Call QFormBuilderExtra::instance less Reviewed-by: Friedemann Kleint --- tools/designer/src/lib/uilib/formbuilder.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/designer/src/lib/uilib/formbuilder.cpp b/tools/designer/src/lib/uilib/formbuilder.cpp index 414eb14..5a771b7 100644 --- a/tools/designer/src/lib/uilib/formbuilder.cpp +++ b/tools/designer/src/lib/uilib/formbuilder.cpp @@ -120,7 +120,8 @@ QFormBuilder::~QFormBuilder() */ QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget) { - QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(false); + QFormBuilderExtra *fb = QFormBuilderExtra::instance(this); + fb->setProcessingLayoutWidget(false); if (ui_widget->attributeClass() == QFormBuilderStrings::instance().qWidgetClass && !ui_widget->hasAttributeNative() && parentWidget #ifndef QT_NO_MAINWINDOW @@ -145,7 +146,7 @@ QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget) && !qobject_cast(parentWidget) #endif ) - QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(true); + fb->setProcessingLayoutWidget(true); return QAbstractFormBuilder::create(ui_widget, parentWidget); } @@ -369,9 +370,10 @@ QWidget *QFormBuilder::create(DomUI *ui, QWidget *parentWidget) */ QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget) { + QFormBuilderExtra *fb = QFormBuilderExtra::instance(this); // Is this a temporary layout widget used to represent QLayout hierarchies in Designer? // Set its margins to 0. - bool layoutWidget = QFormBuilderExtra::instance(this)->processingLayoutWidget(); + bool layoutWidget = fb->processingLayoutWidget(); QLayout *l = QAbstractFormBuilder::create(ui_layout, layout, parentWidget); if (layoutWidget) { const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); @@ -392,7 +394,7 @@ QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *pa bottom = prop->elementNumber(); l->setContentsMargins(left, top, right, bottom); - QFormBuilderExtra::instance(this)->setProcessingLayoutWidget(false); + fb->setProcessingLayoutWidget(false); } return l; } -- cgit v0.12 From 13815a0768236982a025833497d3e2a2f3b6acf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 29 May 2009 12:35:40 +0200 Subject: Fixed a crash in the GL 2 paintengine when drawing text. The new glyph cache may return null images for e.g. space characters. Task-number: 253468 Reviewed-by: Samuel BT: yes --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index a74f044..beb4da6 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -926,6 +926,9 @@ void QGL2PaintEngineEx::drawCachedGlyphs(const QPointF &p, const QTextItemInt &t const QImage &image = cache->image(); int margin = cache->glyphMargin(); + if (image.isNull()) + return; + glActiveTexture(QT_BRUSH_TEXTURE_UNIT); d->ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, true); -- cgit v0.12 From 7dfe8a7980172dccde7fb7920db31c1a8f80c61c Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 28 May 2009 18:05:24 +0200 Subject: extend QStringBuilder benchmark to handle QT_NO_CAST_FROM_ASCII defined and undefined. --- tests/benchmarks/qstringbuilder/main.cpp | 174 +++++++++++++++------ tests/benchmarks/qstringbuilder/qstringbuilder.pro | 4 - 2 files changed, 122 insertions(+), 56 deletions(-) diff --git a/tests/benchmarks/qstringbuilder/main.cpp b/tests/benchmarks/qstringbuilder/main.cpp index 8eb4e78..d4e2fa0 100644 --- a/tests/benchmarks/qstringbuilder/main.cpp +++ b/tests/benchmarks/qstringbuilder/main.cpp @@ -1,17 +1,64 @@ -#include "qstringbuilder.h" +// Select one of the scenarios below +#define SCENARIO 3 + +#if SCENARIO == 1 +// this is the "no harm done" version. Only operator% is active, +// with NO_CAST * defined +#define P % +#undef QT_USE_FAST_OPERATOR_PLUS +#undef QT_USE_FAST_CONCATENATION +#define QT_NO_CAST_FROM_ASCII +#define QT_NO_CAST_TO_ASCII +#endif -#include -#include -#include +#if SCENARIO == 2 +// this is the "full" version. Operator+ is replaced by a QStringBuilder +// based version +// with NO_CAST * defined +#define P % +#define QT_USE_FAST_OPERATOR_PLUS +#define QT_USE_FAST_CONCATENATION +#define QT_NO_CAST_FROM_ASCII +#define QT_NO_CAST_TO_ASCII +#endif + +#if SCENARIO == 3 +// this is the "no harm done" version. Only operator% is active, +// with NO_CAST * _not_ defined +#define P % +#undef QT_USE_FAST_OPERATOR_PLUS +#undef QT_USE_FAST_CONCATENATION +#undef QT_NO_CAST_FROM_ASCII +#undef QT_NO_CAST_TO_ASCII +#endif + +#if SCENARIO == 4 +// this is the "full" version. Operator+ is replaced by a QStringBuilder +// based version +// with NO_CAST * _not_ defined +#define P % +#define QT_USE_FAST_OPERATOR_PLUS +#define QT_USE_FAST_CONCATENATION +#undef QT_NO_CAST_FROM_ASCII +#undef QT_NO_CAST_TO_ASCII +#endif + +#include +#include +#include +#include + +#include #define COMPARE(a, b) QCOMPARE(a, b) //#define COMPARE(a, b) #define SEP(s) qDebug() << "\n\n-------- " s " ---------"; -#define L(s) QLatin1String(s) + +#define LITERAL "some string literal" class tst_qstringbuilder : public QObject { @@ -19,12 +66,16 @@ class tst_qstringbuilder : public QObject public: tst_qstringbuilder() - : l1literal("some string literal"), - l1string("some string literal"), - ba("some string literal"), + : l1literal(LITERAL), + l1string(LITERAL), + ba(LITERAL), string(l1string), stringref(&string, 2, 10), - achar('c') + achar('c'), + r2(QLatin1String(LITERAL LITERAL)), + r3(QLatin1String(LITERAL LITERAL LITERAL)), + r4(QLatin1String(LITERAL LITERAL LITERAL LITERAL)), + r5(QLatin1String(LITERAL LITERAL LITERAL LITERAL LITERAL)) {} @@ -51,10 +102,10 @@ public: int s = 0; for (int i = 0; i < N; ++i) { #if 0 - s += QString(l1literal % l1literal).size(); - s += QString(l1literal % l1literal % l1literal).size(); - s += QString(l1literal % l1literal % l1literal % l1literal).size(); - s += QString(l1literal % l1literal % l1literal % l1literal % l1literal).size(); + s += QString(l1literal P l1literal).size(); + s += QString(l1literal P l1literal P l1literal).size(); + s += QString(l1literal P l1literal P l1literal P l1literal).size(); + s += QString(l1literal P l1literal P l1literal P l1literal P l1literal).size(); #endif s += QString(achar % l1literal % achar).size(); } @@ -71,24 +122,30 @@ private slots: void separator_1() { SEP("literal + literal (builder first)"); } void b_2_l1literal() { - QBENCHMARK { r = l1literal % l1literal; } - COMPARE(r, QString(l1string + l1string)); + QBENCHMARK { r = l1literal P l1literal; } + COMPARE(r, r2); + } + #ifndef QT_NO_CAST_FROM_ASCII + void b_l1literal_LITERAL() { + QBENCHMARK { r = l1literal P LITERAL; } + COMPARE(r, r2); } + #endif void s_2_l1string() { QBENCHMARK { r = l1string + l1string; } - COMPARE(r, QString(l1literal % l1literal)); + COMPARE(r, r2); } void separator_2() { SEP("2 strings"); } void b_2_string() { - QBENCHMARK { r = string % string; } - COMPARE(r, QString(string + string)); + QBENCHMARK { r = string P string; } + COMPARE(r, r2); } void s_2_string() { QBENCHMARK { r = string + string; } - COMPARE(r, QString(string % string)); + COMPARE(r, r2); } @@ -107,12 +164,12 @@ private slots: void separator_2b() { SEP("3 strings"); } void b_3_string() { - QBENCHMARK { r = string % string % string; } - COMPARE(r, QString(string + string + string)); + QBENCHMARK { r = string P string P string; } + COMPARE(r, r3); } void s_3_string() { QBENCHMARK { r = string + string + string; } - COMPARE(r, QString(string % string % string)); + COMPARE(r, r3); } @@ -120,56 +177,66 @@ private slots: void b_string_l1literal() { QBENCHMARK { r = string % l1literal; } - COMPARE(r, QString(string + l1string)); + COMPARE(r, r2); } + #ifndef QT_NO_CAST_FROM_ASCII + void b_string_LITERAL() { + QBENCHMARK { r = string P LITERAL; } + COMPARE(r, r2); + } + void b_LITERAL_string() { + QBENCHMARK { r = LITERAL P string; } + COMPARE(r, r2); + } + #endif void b_string_l1string() { - QBENCHMARK { r = string % l1string; } - COMPARE(r, QString(string + l1string)); + QBENCHMARK { r = string P l1string; } + COMPARE(r, r2); } void s_string_l1literal() { QBENCHMARK { r = string + l1string; } - COMPARE(r, QString(string % l1literal)); + COMPARE(r, r2); } void s_string_l1string() { QBENCHMARK { r = string + l1string; } - COMPARE(r, QString(string % l1literal)); + COMPARE(r, r2); } void separator_3() { SEP("3 literals"); } void b_3_l1literal() { - QBENCHMARK { r = l1literal % l1literal % l1literal; } - COMPARE(r, QString(l1string + l1string + l1string)); + QBENCHMARK { r = l1literal P l1literal P l1literal; } + COMPARE(r, r3); } void s_3_l1string() { QBENCHMARK { r = l1string + l1string + l1string; } - COMPARE(r, QString(l1literal % l1literal % l1literal)); + COMPARE(r, r3); } void separator_4() { SEP("4 literals"); } void b_4_l1literal() { - QBENCHMARK { r = l1literal % l1literal % l1literal % l1literal; } - COMPARE(r, QString(l1string + l1string + l1string + l1string)); + QBENCHMARK { r = l1literal P l1literal P l1literal P l1literal; } + COMPARE(r, r4); } void s_4_l1string() { QBENCHMARK { r = l1string + l1string + l1string + l1string; } - COMPARE(r, QString(l1literal % l1literal % l1literal % l1literal)); + COMPARE(r, r4); } void separator_5() { SEP("5 literals"); } void b_5_l1literal() { - QBENCHMARK { r = l1literal % l1literal % l1literal % l1literal %l1literal; } - COMPARE(r, QString(l1string + l1string + l1string + l1string + l1string)); + QBENCHMARK { r = l1literal P l1literal P l1literal P l1literal P l1literal; } + COMPARE(r, r5); } void s_5_l1string() { QBENCHMARK { r = l1string + l1string + l1string + l1string + l1string; } - COMPARE(r, QString(l1literal % l1literal % l1literal % l1literal % l1literal)); + COMPARE(r, r5); } @@ -177,12 +244,12 @@ private slots: void b_string_4_char() { QBENCHMARK { r = string + achar + achar + achar + achar; } - COMPARE(r, QString(string % achar % achar % achar % achar)); + COMPARE(r, QString(string P achar P achar P achar P achar)); } void s_string_4_char() { QBENCHMARK { r = string + achar + achar + achar + achar; } - COMPARE(r, QString(string % achar % achar % achar % achar)); + COMPARE(r, QString(string P achar P achar P achar P achar)); } @@ -190,26 +257,26 @@ private slots: void b_char_string_char() { QBENCHMARK { r = achar + string + achar; } - COMPARE(r, QString(achar % string % achar)); + COMPARE(r, QString(achar P string P achar)); } void s_char_string_char() { QBENCHMARK { r = achar + string + achar; } - COMPARE(r, QString(achar % string % achar)); + COMPARE(r, QString(achar P string P achar)); } void separator_8() { SEP("string.arg"); } void b_string_arg() { - const QString pattern = l1string + QLatin1String("%1") + l1string; - QBENCHMARK { r = l1literal % string % l1literal; } - COMPARE(r, QString(l1string + string + l1string)); + const QString pattern = l1string + QString::fromLatin1("%1") + l1string; + QBENCHMARK { r = l1literal P string P l1literal; } + COMPARE(r, r3); } void s_string_arg() { const QString pattern = l1string + QLatin1String("%1") + l1string; QBENCHMARK { r = pattern.arg(string); } - COMPARE(r, QString(l1string + string + l1string)); + COMPARE(r, r3); } void s_bytearray_arg() { @@ -223,16 +290,16 @@ private slots: void b_reserve() { QBENCHMARK { r.clear(); - r = string % string % string % string; + r = string P string P string P string; } - COMPARE(r, QString(string + string + string + string)); + COMPARE(r, r4); } void b_reserve_lit() { QBENCHMARK { r.clear(); - r = string % l1literal % string % string; + r = string P l1literal P string P string; } - COMPARE(r, QString(string + string + string + string)); + COMPARE(r, r4); } void s_reserve() { QBENCHMARK { @@ -243,7 +310,7 @@ private slots: r += string; r += string; } - COMPARE(r, QString(string + string + string + string)); + COMPARE(r, r4); } void s_reserve_lit() { QBENCHMARK { @@ -256,7 +323,7 @@ private slots: r += string; r += string; } - COMPARE(r, QString(string + string + string + string)); + COMPARE(r, r4); } private: @@ -266,6 +333,7 @@ private: const QString string; const QStringRef stringref; const QLatin1Char achar; + const QString r2, r3, r4, r5; QString r; }; @@ -280,12 +348,14 @@ int main(int argc, char *argv[]) //QString("x") % 2; // Sanity test, should only compile when the // operator%(QString, int) is visible. - if (argc == 2 && (argv[1] == L("--run-builder") || argv[1] == L("-b"))) { + if (argc == 2 && (QLatin1String(argv[1]) == QLatin1String("--run-builder") + || QLatin1String(argv[1]) == QLatin1String("-b"))) { tst_qstringbuilder test; return test.run_builder(); } - if (argc == 2 && (argv[1] == L("--run-traditional") || argv[1] == L("-t"))) { + if (argc == 2 && (QLatin1String(argv[1]) == QLatin1String("--run-traditional") + || QLatin1String(argv[1]) == QLatin1String("-t"))) { tst_qstringbuilder test; return test.run_traditional(); } diff --git a/tests/benchmarks/qstringbuilder/qstringbuilder.pro b/tests/benchmarks/qstringbuilder/qstringbuilder.pro index 02daaaa..79171b4 100644 --- a/tests/benchmarks/qstringbuilder/qstringbuilder.pro +++ b/tests/benchmarks/qstringbuilder/qstringbuilder.pro @@ -2,10 +2,6 @@ load(qttest_p4) TEMPLATE = app TARGET = tst_qstringbuilder -# Uncomment to test compilation of the drop-in -# replacement operator+() -#DEFINES += QT_USE_FAST_OPERATOR_PLUS - QMAKE_CXXFLAGS += -g QMAKE_CFLAGS += -g -- cgit v0.12 From fe3b9390872bfb03a94be8c17cdc0ce6946369bb Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 29 May 2009 13:09:59 +0200 Subject: Fix qstringbuilder documentation. It was using !fn instead of \fn accidentally. --- src/corelib/tools/qstringbuilder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index b807a89..1ffe2c3 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -122,7 +122,7 @@ \sa QLatin1Literal, QString */ -/* !fn template QStringBuilder operator%(const A &a, const B &b) +/* \fn template QStringBuilder operator%(const A &a, const B &b) Returns a \c QStringBuilder object that is converted to a QString object when assigned to a variable of QString type or passed to a function that -- cgit v0.12 From b34d9b67fbdc6bf74f7ada972dd9b35153f47202 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 29 May 2009 13:43:48 +0200 Subject: Added the -showinternal flag to qdoc. When you set -showinternal on the command line, qdoc will include everything marked \internal in the documentation. This flag is not very useful at the moment for two reasons: (1) It generates hundreds of qdoc errors because most of the things marked with \internal don't have any documentation anyway, or the documentation has other errors in it that weren't being detected because of the \internal. (2) There is a bus error toward the end, which I haven't tracked down yet. For now, use -showinternal at your own risk. --- tools/qdoc3/codeparser.cpp | 14 +++++++++----- tools/qdoc3/codeparser.h | 1 + tools/qdoc3/config.h | 1 + tools/qdoc3/main.cpp | 22 +++++++++++++++------- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/tools/qdoc3/codeparser.cpp b/tools/qdoc3/codeparser.cpp index f0ff27e..20b37a0 100644 --- a/tools/qdoc3/codeparser.cpp +++ b/tools/qdoc3/codeparser.cpp @@ -47,6 +47,7 @@ #include "codeparser.h" #include "node.h" #include "tree.h" +#include "config.h" QT_BEGIN_NAMESPACE @@ -67,6 +68,7 @@ QT_BEGIN_NAMESPACE #define COMMAND_TITLE Doc::alias(QLatin1String("title")) QList CodeParser::parsers; +bool CodeParser::showInternal = false; /*! The constructor adds this code parser to the static @@ -87,11 +89,11 @@ CodeParser::~CodeParser() } /*! - Initializing a code parser is trivial. + Initialize the code parser base class. */ -void CodeParser::initializeParser(const Config & /* config */) +void CodeParser::initializeParser(const Config& config) { - // nothing. + showInternal = config.getBool(QLatin1String(CONFIG_SHOWINTERNAL)); } /*! @@ -217,8 +219,10 @@ void CodeParser::processCommonMetaCommand(const Location &location, node->setStatus(Node::Preliminary); } else if (command == COMMAND_INTERNAL) { - node->setAccess(Node::Private); - node->setStatus(Node::Internal); + if (!showInternal) { + node->setAccess(Node::Private); + node->setStatus(Node::Internal); + } } else if (command == COMMAND_REENTRANT) { node->setThreadSafeness(Node::Reentrant); diff --git a/tools/qdoc3/codeparser.h b/tools/qdoc3/codeparser.h index 019e806..0152b9c 100644 --- a/tools/qdoc3/codeparser.h +++ b/tools/qdoc3/codeparser.h @@ -87,6 +87,7 @@ class CodeParser private: static QList parsers; + static bool showInternal; }; QT_END_NAMESPACE diff --git a/tools/qdoc3/config.h b/tools/qdoc3/config.h index 9443f0d..7eb7048 100644 --- a/tools/qdoc3/config.h +++ b/tools/qdoc3/config.h @@ -147,6 +147,7 @@ class Config #define CONFIG_QHP "qhp" #define CONFIG_QUOTINGINFORMATION "quotinginformation" #define CONFIG_SLOW "slow" +#define CONFIG_SHOWINTERNAL "showinternal" #define CONFIG_SOURCEDIRS "sourcedirs" #define CONFIG_SOURCES "sources" #define CONFIG_SPURIOUS "spurious" diff --git a/tools/qdoc3/main.cpp b/tools/qdoc3/main.cpp index 514d06e..995d037 100644 --- a/tools/qdoc3/main.cpp +++ b/tools/qdoc3/main.cpp @@ -95,6 +95,7 @@ static const struct { }; static bool slow = false; +static bool showInternal = false; static QStringList defines; static QHash trees; @@ -120,14 +121,16 @@ static void printHelp() { Location::information(tr("Usage: qdoc [options] file1.qdocconf ...\n" "Options:\n" - " -help " + " -help " "Display this information and exit\n" - " -version " + " -version " "Display version of qdoc and exit\n" - " -D " + " -D " "Define as a macro while parsing sources\n" - " -slow " - "Turn on features that slow down qdoc") ); + " -slow " + "Turn on features that slow down qdoc" + " -showinternal " + "Include stuff marked internal") ); } /*! @@ -160,6 +163,8 @@ static void processQdocconfFile(const QString &fileName) ++i; } config.setStringList(CONFIG_SLOW, QStringList(slow ? "true" : "false")); + config.setStringList(CONFIG_SHOWINTERNAL, + QStringList(showInternal ? "true" : "false")); /* With the default configuration values in place, load @@ -326,10 +331,11 @@ static void processQdocconfFile(const QString &fileName) /* Generate the XML tag file, if it was requested. */ + QString tagFile = config.getString(CONFIG_TAGFILE); if (!tagFile.isEmpty()) tree->generateTagFile(tagFile); - + tree->setVersion(""); Generator::terminate(); CodeParser::terminate(); @@ -342,7 +348,6 @@ static void processQdocconfFile(const QString &fileName) foreach (QTranslator *translator, translators) delete translator; - delete tree; } @@ -426,6 +431,9 @@ int main(int argc, char **argv) else if (opt == "-slow") { slow = true; } + else if (opt == "-showinternal") { + showInternal = true; + } else { qdocFiles.append(opt); } -- cgit v0.12 From 7fc1d12ebd103539168be590b1cde91d49a3d75b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 29 May 2009 13:35:43 +0200 Subject: Do not hide the left edge of widget in statusbar Could be caused by change d2cba538 Reviewed-by: jbache Task-number: 254083 --- src/gui/widgets/qstatusbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qstatusbar.cpp b/src/gui/widgets/qstatusbar.cpp index c970838..3829bcb 100644 --- a/src/gui/widgets/qstatusbar.cpp +++ b/src/gui/widgets/qstatusbar.cpp @@ -144,7 +144,7 @@ QRect QStatusBarPrivate::messageRect() const if (rtl) left = qMax(left, item->w->x() + item->w->width() + 2); else - right = qMin(right, item->w->x()-1); + right = qMin(right, item->w->x() - 2); } break; } -- cgit v0.12 From 4193c81617e8f86f7939966465623a5170830b26 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 29 May 2009 14:40:01 +0200 Subject: static method, no instance needed --- src/corelib/kernel/qtranslator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 308ca24..1b42c4e 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -346,7 +346,7 @@ QTranslator::QTranslator(QObject * parent, const char * name) QTranslator::~QTranslator() { if (QCoreApplication::instance()) - QCoreApplication::instance()->removeTranslator(this); + QCoreApplication::removeTranslator(this); Q_D(QTranslator); d->clear(); } -- cgit v0.12 From 1d8a4f55ce40400fcb35a645f2e94837e6ab0a24 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 29 May 2009 14:40:50 +0200 Subject: typo fix --- tests/auto/test.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/test.pl b/tests/auto/test.pl index f2a1fe4..9fd5c9d 100755 --- a/tests/auto/test.pl +++ b/tests/auto/test.pl @@ -179,7 +179,7 @@ print " Tests started: $totalStarted \n"; print " Tests executed: $totalExecuted \n"; print " Tests timed out: $totalTimedOut \n"; -# This procedure takes care of handling death children on due time +# This procedure takes care of handling dead children on due time sub handleDeath { $buryChildren = 1; } -- cgit v0.12 From 4b00e265388ed09017702489437c79e0b1a19a44 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 29 May 2009 14:52:44 +0200 Subject: Enable overriding of the factory functions of QUiLoader. Move initialization of QAction/QActionGroups elsewhere. Detect the root widget by checking its parent against the parent widget passed in and apply only the size part of the geometry property to it. Task-number: 254824 Initial-patch-by: joao --- tools/designer/src/lib/uilib/abstractformbuilder.cpp | 7 ++----- tools/designer/src/lib/uilib/formbuilder.cpp | 15 ++++++++------- tools/designer/src/lib/uilib/formbuilderextra.cpp | 18 +++++++++++++----- tools/designer/src/lib/uilib/formbuilderextra_p.h | 8 +++++--- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp index 4dae28e..c5aefb1 100644 --- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp @@ -403,6 +403,7 @@ QAction *QAbstractFormBuilder::create(DomAction *ui_action, QObject *parent) if (!a) return 0; + m_actions.insert(ui_action->attributeName(), a); applyProperties(a, ui_action->elementProperty()); return a; } @@ -415,7 +416,7 @@ QActionGroup *QAbstractFormBuilder::create(DomActionGroup *ui_action_group, QObj QActionGroup *a = createActionGroup(parent, ui_action_group->attributeName()); if (!a) return 0; - + m_actionGroups.insert(ui_action_group->attributeName(), a); applyProperties(a, ui_action_group->elementProperty()); foreach (DomAction *ui_action, ui_action_group->elementAction()) { @@ -1184,8 +1185,6 @@ QAction *QAbstractFormBuilder::createAction(QObject *parent, const QString &name { QAction *action = new QAction(parent); action->setObjectName(name); - m_actions.insert(name, action); - return action; } @@ -1196,8 +1195,6 @@ QActionGroup *QAbstractFormBuilder::createActionGroup(QObject *parent, const QSt { QActionGroup *g = new QActionGroup(parent); g->setObjectName(name); - m_actionGroups.insert(name, g); - return g; } diff --git a/tools/designer/src/lib/uilib/formbuilder.cpp b/tools/designer/src/lib/uilib/formbuilder.cpp index 5a771b7..53d1e9d 100644 --- a/tools/designer/src/lib/uilib/formbuilder.cpp +++ b/tools/designer/src/lib/uilib/formbuilder.cpp @@ -121,6 +121,8 @@ QFormBuilder::~QFormBuilder() QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget) { QFormBuilderExtra *fb = QFormBuilderExtra::instance(this); + if (!fb->parentWidgetIsSet()) + fb->setParentWidget(parentWidget); fb->setProcessingLayoutWidget(false); if (ui_widget->attributeClass() == QFormBuilderStrings::instance().qWidgetClass && !ui_widget->hasAttributeNative() && parentWidget @@ -229,9 +231,6 @@ QWidget *QFormBuilder::createWidget(const QString &widgetName, QWidget *parentWi if (qobject_cast(w)) w->setParent(parentWidget); - if (!fb->rootWidget()) - fb->setRootWidget(w); - return w; } @@ -527,6 +526,7 @@ QList QFormBuilder::customWidgets() const /*! \internal */ + void QFormBuilder::applyProperties(QObject *o, const QList &properties) { typedef QList DomPropertyList; @@ -544,11 +544,12 @@ void QFormBuilder::applyProperties(QObject *o, const QList &proper continue; const QString attributeName = (*it)->attributeName(); - if (o == fb->rootWidget() && attributeName == strings.geometryProperty) { - // apply only the size for the rootWidget - fb->rootWidget()->resize(qvariant_cast(v).size()); + const bool isWidget = o->isWidgetType(); + if (isWidget && o->parent() == fb->parentWidget() && attributeName == strings.geometryProperty) { + // apply only the size part of a geometry for the root widget + static_cast(o)->resize(qvariant_cast(v).size()); } else if (fb->applyPropertyInternally(o, attributeName, v)) { - } else if (!qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) { + } else if (isWidget && !qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) { // ### special-casing for Line (QFrame) -- try to fix me o->setProperty("frameShape", v); // v is of QFrame::Shape enum } else { diff --git a/tools/designer/src/lib/uilib/formbuilderextra.cpp b/tools/designer/src/lib/uilib/formbuilderextra.cpp index cb82967..38fe2ae 100644 --- a/tools/designer/src/lib/uilib/formbuilderextra.cpp +++ b/tools/designer/src/lib/uilib/formbuilderextra.cpp @@ -81,7 +81,8 @@ QFormBuilderExtra::~QFormBuilderExtra() void QFormBuilderExtra::clear() { m_buddies.clear(); - m_rootWidget = 0; + m_parentWidget = 0; + m_parentWidgetIsSet = false; #ifndef QT_FORMBUILDER_NO_SCRIPT m_FormScriptRunner.clearErrors(); m_customWidgetScriptHash.clear(); @@ -136,14 +137,21 @@ bool QFormBuilderExtra::applyBuddy(const QString &buddyName, BuddyMode applyMode return false; } -const QPointer &QFormBuilderExtra::rootWidget() const +const QPointer &QFormBuilderExtra::parentWidget() const { - return m_rootWidget; + return m_parentWidget; } -void QFormBuilderExtra::setRootWidget(const QPointer &w) +bool QFormBuilderExtra::parentWidgetIsSet() const { - m_rootWidget = w; + return m_parentWidgetIsSet; +} + +void QFormBuilderExtra::setParentWidget(const QPointer &w) +{ + // Parent widget requires special handling of the geometry property. + m_parentWidget = w; + m_parentWidgetIsSet = true; } #ifndef QT_FORMBUILDER_NO_SCRIPT diff --git a/tools/designer/src/lib/uilib/formbuilderextra_p.h b/tools/designer/src/lib/uilib/formbuilderextra_p.h index f357239..9166c48 100644 --- a/tools/designer/src/lib/uilib/formbuilderextra_p.h +++ b/tools/designer/src/lib/uilib/formbuilderextra_p.h @@ -101,8 +101,9 @@ public: void applyInternalProperties() const; static bool applyBuddy(const QString &buddyName, BuddyMode applyMode, QLabel *label); - const QPointer &rootWidget() const; - void setRootWidget(const QPointer &w); + const QPointer &parentWidget() const; + bool parentWidgetIsSet() const; + void setParentWidget(const QPointer &w); #ifndef QT_FORMBUILDER_NO_SCRIPT QFormScriptRunner &formScriptRunner(); @@ -182,7 +183,8 @@ private: QResourceBuilder *m_resourceBuilder; QTextBuilder *m_textBuilder; - QPointer m_rootWidget; + QPointer m_parentWidget; + bool m_parentWidgetIsSet; }; void uiLibWarning(const QString &message); -- cgit v0.12 From 37f3aeae8198d98cf9e33990b85e9b6fc443d948 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 29 May 2009 14:58:19 +0200 Subject: Fixed docs for task 254824. Task-number: 254824 --- tools/designer/src/uitools/quiloader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/designer/src/uitools/quiloader.cpp b/tools/designer/src/uitools/quiloader.cpp index 2a66095..c6c2d80 100644 --- a/tools/designer/src/uitools/quiloader.cpp +++ b/tools/designer/src/uitools/quiloader.cpp @@ -613,8 +613,7 @@ void QUiLoaderPrivate::setupWidgetMap() const reason, you can subclass the QUiLoader class and reimplement these functions to intervene the process of constructing a user interface. For example, you might want to have a list of the actions created when loading - a form or creating a custom widget. However, in your reimplementation, you - must call QUiLoader's original implementation of these functions first. + a form or creating a custom widget. For a complete example using the QUiLoader class, see the \l{Calculator Builder Example}. -- cgit v0.12 From e3d744270d6ae4f1e893784e3e064d47e25c1fbe Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Fri, 29 May 2009 15:44:22 +0200 Subject: Doc - some changes to fix a qdoc warning --- src/corelib/tools/qstringbuilder.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 1ffe2c3..2b4a242 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -71,8 +71,8 @@ /*! \fn int QLatin1Literal::size() const - Returns the number of characters in the literal \i{excluding} the trailing - NUL char. + Returns the number of characters in the literal \e{excluding} the trailing + NULL char. */ /*! \fn char *QLatin1Literal::data() const -- cgit v0.12 From 28305c37a1874be6919c316be03fff2aaf3d94cb Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Fri, 29 May 2009 15:54:00 +0200 Subject: Remove unused variable. --- src/gui/kernel/qwidget_x11.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index e00c37c..6250fb77 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -1509,7 +1509,6 @@ QWidget *QWidget::keyboardGrabber() void QWidget::activateWindow() { - Q_D(QWidget); QWidget *tlw = window(); if (tlw->isVisible() && !tlw->d_func()->topData()->embedded && !X11->deferred_map.contains(tlw)) { if (X11->userTime == 0) -- cgit v0.12 From 58fa04d1ac4b961bae11dd2261861201823322cc Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 29 May 2009 15:48:06 +0200 Subject: Remove icon when setting an empty window icon on X11. We used to leave _NET_WM_ICON set forever, and removing an IconPixmapHint from WMHints didn't work properly. Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qwidget_x11.cpp | 53 ++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 7e41ea1..adb48a8 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -1359,17 +1359,10 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) // already been set return; - XWMHints *h = 0; - if (q->internalWinId()) - h = XGetWMHints(X11->display, q->internalWinId()); - XWMHints wm_hints; - if (!h) { - memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy - h = &wm_hints; - } - // preparing images to set the _NET_WM_ICON property QIcon icon = q->windowIcon(); + QVector icon_data; + Qt::HANDLE pixmap_handle = 0; if (!icon.isNull()) { QList availableSizes = icon.availableSizes(); if(availableSizes.isEmpty()) { @@ -1379,7 +1372,6 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) availableSizes.push_back(QSize(64,64)); availableSizes.push_back(QSize(128,128)); } - QVector icon_data; for(int i = 0; i < availableSizes.size(); ++i) { QSize size = availableSizes.at(i); QPixmap pixmap = icon.pixmap(size); @@ -1401,11 +1393,6 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) } } if (!icon_data.isEmpty()) { - if (q->internalWinId()) { - XChangeProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_ICON), XA_CARDINAL, 32, - PropModeReplace, (unsigned char *) icon_data.data(), - icon_data.size()); - } extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap); /* if the app is running on an unknown desktop, or it is not @@ -1419,22 +1406,44 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) // unknown DE or non-default visual/colormap, use 1bpp bitmap if (!forceReset || !topData->iconPixmap) topData->iconPixmap = new QBitmap(qt_toX11Pixmap(icon.pixmap(QSize(64,64)))); - h->icon_pixmap = topData->iconPixmap->handle(); + pixmap_handle = topData->iconPixmap->handle(); } else { // default depth, use a normal pixmap (even though this // violates the ICCCM), since this works on all DEs known to Qt if (!forceReset || !topData->iconPixmap) topData->iconPixmap = new QPixmap(qt_toX11Pixmap(icon.pixmap(QSize(64,64)))); - h->icon_pixmap = static_cast(topData->iconPixmap->data)->x11ConvertToDefaultDepth(); + pixmap_handle = static_cast(topData->iconPixmap->data)->x11ConvertToDefaultDepth(); } - h->flags |= IconPixmapHint; - } else { - h->flags &= ~(IconPixmapHint | IconMaskHint); } } - if (q->internalWinId()) - XSetWMHints(X11->display, q->internalWinId(), h); + if (!q->internalWinId()) + return; + + if (!icon_data.isEmpty()) { + XChangeProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_ICON), XA_CARDINAL, 32, + PropModeReplace, (unsigned char *) icon_data.data(), + icon_data.size()); + } else { + XDeleteProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_ICON)); + } + + XWMHints *h = XGetWMHints(X11->display, q->internalWinId()); + XWMHints wm_hints; + if (!h) { + memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy + h = &wm_hints; + } + + if (pixmap_handle) { + h->icon_pixmap = pixmap_handle; + h->flags |= IconPixmapHint; + } else { + h->icon_pixmap = 0; + h->flags &= ~(IconPixmapHint | IconMaskHint); + } + + XSetWMHints(X11->display, q->internalWinId(), h); if (h != &wm_hints) XFree((char *)h); } -- cgit v0.12 From 235818fdac5faf0d38f9b37c7bd5ee522935aed1 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 29 May 2009 10:11:29 +0200 Subject: Removed nested comment signature in the doc to fix a warning. Reviewed-by: David Boddie --- src/corelib/kernel/qobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index f1a1eb5..7e5f779 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2066,7 +2066,7 @@ void QObject::deleteLater() or - \tt{/*: ... \starslash} + \tt{\begincomment: ... \endcomment} Examples: -- cgit v0.12 From a322d3faacdb8e5a8649b478b3eaa8aa03d789d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 29 May 2009 13:59:19 +0200 Subject: Added check in GL pixmap backend to fall back to raster if FBO fails. --- src/opengl/qpixmapdata_gl.cpp | 69 +++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 85bcda5..8d94c8b 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -372,45 +372,50 @@ QPaintEngine* QGLPixmapData::paintEngine() const if (m_engine) return m_engine; - else if (!useFramebufferObjects()) { - m_dirty = true; - if (m_source.size() != size()) - m_source = QImage(size(), QImage::Format_ARGB32_Premultiplied); - if (m_hasFillColor) { - m_source.fill(PREMUL(m_fillColor.rgba())); - m_hasFillColor = false; - } - return m_source.paintEngine(); - } - extern QGLWidget* qt_gl_share_widget(); + if (useFramebufferObjects()) { + extern QGLWidget* qt_gl_share_widget(); - if (!QGLContext::currentContext()) - qt_gl_share_widget()->makeCurrent(); - QGLShareContextScope ctx(qt_gl_share_widget()->context()); + if (!QGLContext::currentContext()) + qt_gl_share_widget()->makeCurrent(); + QGLShareContextScope ctx(qt_gl_share_widget()->context()); - if (textureBufferStack.size() <= currentTextureBuffer) { - textureBufferStack << createTextureBuffer(size()); - } else { - QSize sz = textureBufferStack.at(currentTextureBuffer).fbo->size(); - if (sz.width() < m_width || sz.height() < m_height) { - if (sz.width() < m_width) - sz.setWidth(qMax(m_width, qRound(sz.width() * 1.5))); - if (sz.height() < m_height) - sz.setHeight(qMax(m_height, qRound(sz.height() * 1.5))); - delete textureBufferStack.at(currentTextureBuffer).fbo; - textureBufferStack[currentTextureBuffer] = - createTextureBuffer(sz, textureBufferStack.at(currentTextureBuffer).engine); - qDebug() << "Creating new pixmap texture buffer:" << sz; + if (textureBufferStack.size() <= currentTextureBuffer) { + textureBufferStack << createTextureBuffer(size()); + } else { + QSize sz = textureBufferStack.at(currentTextureBuffer).fbo->size(); + if (sz.width() < m_width || sz.height() < m_height) { + if (sz.width() < m_width) + sz.setWidth(qMax(m_width, qRound(sz.width() * 1.5))); + if (sz.height() < m_height) + sz.setHeight(qMax(m_height, qRound(sz.height() * 1.5))); + delete textureBufferStack.at(currentTextureBuffer).fbo; + textureBufferStack[currentTextureBuffer] = + createTextureBuffer(sz, textureBufferStack.at(currentTextureBuffer).engine); + qDebug() << "Creating new pixmap texture buffer:" << sz; + } } - } - m_renderFbo = textureBufferStack.at(currentTextureBuffer).fbo; - m_engine = textureBufferStack.at(currentTextureBuffer).engine; + if (textureBufferStack.at(currentTextureBuffer).fbo->isValid()) { + m_renderFbo = textureBufferStack.at(currentTextureBuffer).fbo; + m_engine = textureBufferStack.at(currentTextureBuffer).engine; + + ++currentTextureBuffer; + + return m_engine; + } - ++currentTextureBuffer; + qWarning() << "Failed to create pixmap texture buffer of size " << size() << ", falling back to raster paint engine"; + } - return m_engine; + m_dirty = true; + if (m_source.size() != size()) + m_source = QImage(size(), QImage::Format_ARGB32_Premultiplied); + if (m_hasFillColor) { + m_source.fill(PREMUL(m_fillColor.rgba())); + m_hasFillColor = false; + } + return m_source.paintEngine(); } GLuint QGLPixmapData::bind(bool copyBack) const -- cgit v0.12 From 07fbbf76bef1845bb6c490b15a0b7caabf23d888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 29 May 2009 14:00:45 +0200 Subject: Made GL2 engine default for QGLWidget, and added GL2 sync() function To allow mixing QPainter and raw OpenGL commands we need to have some way for the user to say that's he's about to use raw OpenGL so that we are free to do buffering optimizations in the paint engines and use either GL1 or GL2 paint engine. As there's already a syncState() function in QPaintEngine we've reused this and added QPaintEngineEx::sync() which takes care of syncing/flushing the paint engine. Reviewed-by: Trond --- dist/changes-4.6.0 | 5 +++ src/gui/painting/qpaintengine.cpp | 4 +++ src/gui/painting/qpaintengineex_p.h | 2 ++ .../gl2paintengineex/qpaintengineex_opengl2.cpp | 37 ++++++++++++++++++++++ .../gl2paintengineex/qpaintengineex_opengl2_p.h | 1 + src/opengl/qgl_p.h | 2 +- 6 files changed, 50 insertions(+), 1 deletion(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 6a94f26..bedf58a 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -49,3 +49,8 @@ information about a particular change. - QStyleOptionGraphicsItem::levelOfDetails is obsoleted and its value is always initialized to 1. For a more fine-grained value use QStyleOptionGraphicsItem::levelOfDetailFromTransform(const QTransform &). + + - When mixing OpenGL and QPainter calls you need to first call syncState() + on the paint engine, for example "painter->paintEngine()->syncState()". + This is to ensure that the engine flushes any pending drawing and sets up + the GL modelview/projection matrices properly. diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp index 7de1ec4..9859425 100644 --- a/src/gui/painting/qpaintengine.cpp +++ b/src/gui/painting/qpaintengine.cpp @@ -49,6 +49,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -302,6 +303,9 @@ void QPaintEngine::syncState() { Q_ASSERT(state); updateState(*state); + + if (isExtended()) + static_cast(this)->sync(); } static QPaintEngine *qt_polygon_recursion = 0; diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h index 593726c..1c55242 100644 --- a/src/gui/painting/qpaintengineex_p.h +++ b/src/gui/painting/qpaintengineex_p.h @@ -216,6 +216,8 @@ public: inline QPainterState *state() { return static_cast(QPaintEngine::state); } inline const QPainterState *state() const { return static_cast(QPaintEngine::state); } + virtual void sync() {} + virtual QPixmapFilter *createPixmapFilter(int /*type*/) const { return 0; } protected: diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index e7b6ee4..40f3a8d 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -449,6 +449,43 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } +void QGL2PaintEngineEx::sync() +{ + Q_D(QGL2PaintEngineEx); + ensureActive(); + d->transferMode(BrushDrawingMode); + + QGLContext *ctx = d->ctx; + glUseProgram(0); + +#ifndef QT_OPENGL_ES_2 + // be nice to people who mix OpenGL 1.x code with QPainter commands + // by setting modelview and projection matrices to mirror the GL 1 + // paint engine + const QTransform& mtx = state()->matrix; + + float mv_matrix[4][4] = + { + { mtx.m11(), mtx.m12(), 0, mtx.m13() }, + { mtx.m21(), mtx.m22(), 0, mtx.m23() }, + { 0, 0, 1, 0 }, + { mtx.dx(), mtx.dy(), 0, mtx.m33() } + }; + + const QSize sz = d->drawable.size(); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999); + + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(&mv_matrix[0][0]); +#endif + + glDisable(GL_BLEND); + glActiveTexture(GL_TEXTURE0); +} + void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) { if (newMode == mode) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index dececa3..7213474 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -126,6 +126,7 @@ public: return static_cast(QPaintEngineEx::state()); } void updateClipRegion(const QRegion &clipRegion, Qt::ClipOperation op); + virtual void sync(); private: Q_DISABLE_COPY(QGL2PaintEngineEx) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index b1a63b5..b3523d4 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -440,7 +440,7 @@ inline bool qt_gl_preferGL2Engine() return true; #else return (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) - && !qgetenv("QT_GL_USE_OPENGL2ENGINE").isEmpty(); + && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty(); #endif } -- cgit v0.12 From cc10cda46329866e229eb7f190b1e0aeff09f76d Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Fri, 29 May 2009 16:29:19 +0200 Subject: Wrong default argument for my previous fix. Argh! This was a private function and I assumed that I had the boolean correct, but I was wrong. Anyway, we don't need to do the group fade be default ever, so always have it false. --- src/gui/widgets/qmenu_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index 9654126..f08283d 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -220,7 +220,7 @@ public: virtual QList > calcCausedStack() const; QMenuCaused causedPopup; void hideUpToMenuBar(); - void hideMenu(QMenu *menu, bool delay = true); + void hideMenu(QMenu *menu, bool justRegister = false); //index mappings inline QAction *actionAt(int i) const { return q_func()->actions().at(i); } -- cgit v0.12 From 3cb304990f81799e6811b699b6b6ad1c32ec1107 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 29 May 2009 16:36:15 +0200 Subject: Fix compilation with -pedantic --- src/corelib/animation/qabstractanimation.cpp | 2 +- src/corelib/animation/qpropertyanimation.cpp | 2 +- src/corelib/animation/qpropertyanimation.h | 2 +- src/corelib/io/qfilesystemwatcher_dnotify.cpp | 2 +- src/corelib/io/qnoncontiguousbytedevice.cpp | 36 +++++++++++++-------------- src/corelib/plugin/qfactoryloader.cpp | 2 +- src/corelib/tools/qlocale_p.h | 2 +- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 16307e6..61d61df 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE -Q_GLOBAL_STATIC(QThreadStorage, unifiedTimer); +Q_GLOBAL_STATIC(QThreadStorage, unifiedTimer) QUnifiedTimer::QUnifiedTimer() : QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), consistentTiming(false) { diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 47361a5..43b5283 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE typedef QPair QPropertyAnimationPair; typedef QHash QPropertyAnimationHash; -Q_GLOBAL_STATIC(QPropertyAnimationHash, _q_runningAnimations); +Q_GLOBAL_STATIC(QPropertyAnimationHash, _q_runningAnimations) Q_GLOBAL_STATIC_WITH_ARGS(QMutex, guardHashLock, (QMutex::Recursive) ) void QPropertyAnimationPrivate::updateMetaProperty() diff --git a/src/corelib/animation/qpropertyanimation.h b/src/corelib/animation/qpropertyanimation.h index 39317ba..2fdd50c 100644 --- a/src/corelib/animation/qpropertyanimation.h +++ b/src/corelib/animation/qpropertyanimation.h @@ -76,7 +76,7 @@ protected: void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); private: - Q_PRIVATE_SLOT(d_func(), void _q_targetDestroyed()); + Q_PRIVATE_SLOT(d_func(), void _q_targetDestroyed()) Q_DISABLE_COPY(QPropertyAnimation) Q_DECLARE_PRIVATE(QPropertyAnimation) }; diff --git a/src/corelib/io/qfilesystemwatcher_dnotify.cpp b/src/corelib/io/qfilesystemwatcher_dnotify.cpp index e87375a..a8397f8 100644 --- a/src/corelib/io/qfilesystemwatcher_dnotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_dnotify.cpp @@ -114,7 +114,7 @@ private: bool isExecing; }; -Q_GLOBAL_STATIC(QDnotifySignalThread, dnotifySignal); +Q_GLOBAL_STATIC(QDnotifySignalThread, dnotifySignal) QDnotifySignalThread::QDnotifySignalThread() : isExecing(false) diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp index f50acdb..1ff3a4c 100644 --- a/src/corelib/io/qnoncontiguousbytedevice.cpp +++ b/src/corelib/io/qnoncontiguousbytedevice.cpp @@ -143,11 +143,11 @@ QT_BEGIN_NAMESPACE QNonContiguousByteDevice::QNonContiguousByteDevice() : QObject((QObject*)0), resetDisabled(false) { -}; +} QNonContiguousByteDevice::~QNonContiguousByteDevice() { -}; +} void QNonContiguousByteDevice::disableReset() { @@ -253,7 +253,7 @@ QNonContiguousByteDeviceRingBufferImpl::QNonContiguousByteDeviceRingBufferImpl(Q QNonContiguousByteDeviceRingBufferImpl::~QNonContiguousByteDeviceRingBufferImpl() { -}; +} const char* QNonContiguousByteDeviceRingBufferImpl::readPointer(qint64 maximumLength, qint64 &len) { @@ -268,19 +268,19 @@ const char* QNonContiguousByteDeviceRingBufferImpl::readPointer(qint64 maximumLe len = qMin(len, maximumLength); return returnValue; -}; +} bool QNonContiguousByteDeviceRingBufferImpl::advanceReadPointer(qint64 amount) { currentPosition += amount; emit readProgress(currentPosition, size()); return true; -}; +} bool QNonContiguousByteDeviceRingBufferImpl::atEnd() { return currentPosition >= size(); -}; +} bool QNonContiguousByteDeviceRingBufferImpl::reset() { @@ -289,12 +289,12 @@ bool QNonContiguousByteDeviceRingBufferImpl::reset() currentPosition = 0; return true; -}; +} qint64 QNonContiguousByteDeviceRingBufferImpl::size() { return ringBuffer->size(); -}; +} QNonContiguousByteDeviceIoDeviceImpl::QNonContiguousByteDeviceIoDeviceImpl(QIODevice *d) : QNonContiguousByteDevice(), @@ -306,12 +306,12 @@ QNonContiguousByteDeviceIoDeviceImpl::QNonContiguousByteDeviceIoDeviceImpl(QIODe initialPosition = d->pos(); connect(device, SIGNAL(readyRead()), this, SIGNAL(readyRead()), Qt::QueuedConnection); connect(device, SIGNAL(readChannelFinished()), this, SIGNAL(readyRead()), Qt::QueuedConnection); -}; +} QNonContiguousByteDeviceIoDeviceImpl::~QNonContiguousByteDeviceIoDeviceImpl() { delete currentReadBuffer; -}; +} const char* QNonContiguousByteDeviceIoDeviceImpl::readPointer(qint64 maximumLength, qint64 &len) { @@ -347,7 +347,7 @@ const char* QNonContiguousByteDeviceIoDeviceImpl::readPointer(qint64 maximumLeng len = haveRead; return currentReadBuffer->data(); -}; +} bool QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(qint64 amount) { @@ -377,12 +377,12 @@ bool QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(qint64 amount) emit readProgress(totalAdvancements, size()); return true; -}; +} bool QNonContiguousByteDeviceIoDeviceImpl::atEnd() { return eof == true; -}; +} bool QNonContiguousByteDeviceIoDeviceImpl::reset() { @@ -395,7 +395,7 @@ bool QNonContiguousByteDeviceIoDeviceImpl::reset() } return false; -}; +} qint64 QNonContiguousByteDeviceIoDeviceImpl::size() { @@ -405,7 +405,7 @@ qint64 QNonContiguousByteDeviceIoDeviceImpl::size() return -1; return device->size() - initialPosition; -}; +} QByteDeviceWrappingIoDevice::QByteDeviceWrappingIoDevice(QNonContiguousByteDevice *bd) : QIODevice((QObject*)0) { @@ -497,7 +497,7 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *dev // generic QIODevice return new QNonContiguousByteDeviceIoDeviceImpl(device); // FIXME -}; +} /*! \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QRingBuffer *ringBuffer); @@ -509,7 +509,7 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *dev QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QRingBuffer *ringBuffer) { return new QNonContiguousByteDeviceRingBufferImpl(ringBuffer); -}; +} /*! \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *byteArray); @@ -521,7 +521,7 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QRingBuffer *r QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *byteArray) { return new QNonContiguousByteDeviceByteArrayImpl(byteArray); -}; +} /*! \fn static QIODevice* QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice* byteDevice); diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 5163027..4740bf1 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE -Q_GLOBAL_STATIC(QList, qt_factory_loaders); +Q_GLOBAL_STATIC(QList, qt_factory_loaders) Q_GLOBAL_STATIC_WITH_ARGS(QMutex, qt_factoryloader_mutex, (QMutex::Recursive)) diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 9d36a83..b07b948 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -96,7 +96,7 @@ public: ShowBase = 0x80, UppercaseBase = 0x100, - ForcePoint = Alternate, + ForcePoint = Alternate }; enum GroupSeparatorMode { -- cgit v0.12 From 5f1ec2a20d13b9ca9bae1b7b40692925dcd99051 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 29 May 2009 11:17:11 -0700 Subject: Don't support porter duff |= source over DirectFB and Qt treats these things rather differently so the mapping just doesn't work very well. Only use DirectFB for SourceOver stuff (which is the default mode anyway) Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 120 +++++---------------- 1 file changed, 24 insertions(+), 96 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 7535090..2fb533a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -215,8 +215,8 @@ public: void setTransform(const QTransform &m); void setPen(const QPen &pen); - void setCompositionMode(QPainter::CompositionMode mode); - void setOpacity(quint8 value); + inline void setCompositionMode(QPainter::CompositionMode mode); + inline void setOpacity(quint8 value); void setRenderHints(QPainter::RenderHints hints); inline void setDFBColor(const QColor &color); @@ -276,14 +276,12 @@ private: quint8 opacity; - quint32 drawFlagsFromCompositionMode, blitFlagsFromCompositionMode; - DFBSurfacePorterDuffRule porterDuffRule; - bool dirtyClip; bool dfbHandledClip; bool ignoreSystemClip; QDirectFBPaintDevice *dfbDevice; void *lockedMemory; + bool unsupportedCompositionMode; QDirectFBPaintEngine *q; friend class QDirectFBPaintEngine; @@ -403,7 +401,7 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) Q_D(QDirectFBPaintEngine); d->updateClip(); const QBrush &brush = state()->brush; - if (!d->dfbCanHandleClip() || d->matrixRotShear + if (d->unsupportedCompositionMode || !d->dfbCanHandleClip() || d->matrixRotShear || !d->simplePen || !d->isSimpleBrush(brush)) { RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); @@ -428,7 +426,7 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) Q_D(QDirectFBPaintEngine); d->updateClip(); const QBrush &brush = state()->brush; - if (!d->dfbCanHandleClip() || d->matrixRotShear + if (d->unsupportedCompositionMode || !d->dfbCanHandleClip() || d->matrixRotShear || !d->simplePen || !d->isSimpleBrush(brush)) { RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); @@ -452,7 +450,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) { Q_D(QDirectFBPaintEngine); d->updateClip(); - if (!d->simplePen || !d->dfbCanHandleClip()) { + if (d->unsupportedCompositionMode || !d->simplePen || !d->dfbCanHandleClip()) { RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); @@ -470,7 +468,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) { Q_D(QDirectFBPaintEngine); d->updateClip(); - if (!d->simplePen || !d->dfbCanHandleClip()) { + if (d->unsupportedCompositionMode || !d->simplePen || !d->dfbCanHandleClip()) { RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); @@ -510,7 +508,8 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, d->updateClip(); #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE - if (d->matrixRotShear + if (d->unsupportedCompositionMode + || d->matrixRotShear || d->scale == QDirectFBPaintEnginePrivate::NegativeScale || !d->dfbCanHandleClip(r) #ifndef QT_DIRECTFB_IMAGECACHE @@ -554,7 +553,7 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); d->lock(); QRasterPaintEngine::drawPixmap(r, pixmap, sr); - } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear + } else if (d->unsupportedCompositionMode || !d->dfbCanHandleClip(r) || d->matrixRotShear || d->scale == QDirectFBPaintEnginePrivate::NegativeScale) { RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); @@ -586,7 +585,7 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); d->lock(); QRasterPaintEngine::drawTiledPixmap(r, pixmap, sp); - } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull() + } else if (d->unsupportedCompositionMode || !d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull() || d->scale == QDirectFBPaintEnginePrivate::NegativeScale) { RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp); const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); @@ -682,7 +681,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) { Q_D(QDirectFBPaintEngine); d->updateClip(); - if (d->dfbCanHandleClip(rect) && !d->matrixRotShear) { + if (!d->unsupportedCompositionMode && d->dfbCanHandleClip(rect) && !d->matrixRotShear) { switch (brush.style()) { case Qt::SolidPattern: { d->unlock(); @@ -712,7 +711,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) { Q_D(QDirectFBPaintEngine); d->updateClip(); - if (!d->dfbCanHandleClip() || d->matrixRotShear) { + if (d->unsupportedCompositionMode || !d->dfbCanHandleClip() || d->matrixRotShear) { RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); d->lock(); QRasterPaintEngine::fillRect(rect, color); @@ -791,9 +790,9 @@ void QDirectFBPaintEngine::initImageCache(int size) QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) : surface(0), antialiased(false), simplePen(false), matrixRotShear(false), scale(NoScale), lastLockedHeight(-1), - fbWidth(-1), fbHeight(-1), opacity(255), drawFlagsFromCompositionMode(0), - blitFlagsFromCompositionMode(0), porterDuffRule(DSPD_SRC_OVER), dirtyClip(true), - dfbHandledClip(false), dfbDevice(0), lockedMemory(0), q(p) + fbWidth(-1), fbHeight(-1), opacity(255), dirtyClip(true), + dfbHandledClip(false), dfbDevice(0), lockedMemory(0), + unsupportedCompositionMode(false), q(p) { fb = QDirectFBScreen::instance()->dfb(); ignoreSystemClip = QDirectFBScreen::instance()->directFBFlags() & QDirectFBScreen::IgnoreSystemClip; @@ -887,7 +886,7 @@ void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device) setTransform(QTransform()); antialiased = false; - opacity = 255; + setOpacity(255); setCompositionMode(q->state()->compositionMode()); dirtyClip = true; setPen(q->state()->pen); @@ -915,72 +914,13 @@ void QDirectFBPaintEnginePrivate::setPen(const QPen &p) void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode) { - blitFlagsFromCompositionMode = DSBLIT_NOFX; - drawFlagsFromCompositionMode = DSDRAW_NOFX; - - bool blend = true; - switch (mode) { - case QPainter::CompositionMode_SourceOver: - porterDuffRule = DSPD_SRC_OVER; - break; - case QPainter::CompositionMode_DestinationOver: - porterDuffRule = DSPD_DST_OVER; - break; - case QPainter::CompositionMode_Clear: - porterDuffRule = DSPD_CLEAR; - blend = false; - break; - case QPainter::CompositionMode_Source: - porterDuffRule = DSPD_SRC; - blend = false; - break; - case QPainter::CompositionMode_Destination: - porterDuffRule = DSPD_NONE; // ### need to double check this - blend = false; - return; - case QPainter::CompositionMode_SourceIn: - porterDuffRule = DSPD_SRC_IN; - break; - case QPainter::CompositionMode_DestinationIn: - porterDuffRule = DSPD_DST_IN; - break; - case QPainter::CompositionMode_SourceOut: - porterDuffRule = DSPD_SRC_OUT; - break; - case QPainter::CompositionMode_DestinationOut: - porterDuffRule = DSPD_DST_OUT; - break; - case QPainter::CompositionMode_Xor: - porterDuffRule = DSPD_XOR; - blitFlagsFromCompositionMode |= DSBLIT_XOR; - drawFlagsFromCompositionMode |= DSDRAW_XOR; - break; -// case QPainter::CompositionMode_Plus: // ??? -// porterDuffRule = DSPD_ADD; -// break; - default: - qWarning("QDirectFBPaintEnginePrivate::setCompositionMode(): " - "mode %d not implemented", mode); - return; - } - // intentially not comparing with current porterDuffRule. surface might have changed. - if (blend) { - blitFlagsFromCompositionMode |= DSBLIT_BLEND_ALPHACHANNEL; - drawFlagsFromCompositionMode |= DSDRAW_BLEND; - } - if (opacity != 255) { - setOpacity(opacity); - } + unsupportedCompositionMode = (mode != QPainter::CompositionMode_SourceOver); } + void QDirectFBPaintEnginePrivate::setOpacity(quint8 op) { opacity = op; - if (opacity == 255) { - blitFlagsFromCompositionMode &= ~DSBLIT_BLEND_COLORALPHA; - } else { - blitFlagsFromCompositionMode |= DSBLIT_BLEND_COLORALPHA; - } } void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints) @@ -994,15 +934,9 @@ void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints) void QDirectFBPaintEnginePrivate::prepareForBlit(bool alpha) { - quint32 blittingFlags = blitFlagsFromCompositionMode; - if (alpha) { - surface->SetPorterDuff(surface, - (blittingFlags & DSBLIT_BLEND_COLORALPHA) - ? DSPD_NONE - : porterDuffRule); - } else { - blittingFlags &= ~DSBLIT_BLEND_ALPHACHANNEL; - surface->SetPorterDuff(surface, DSPD_NONE); + quint32 blittingFlags = alpha ? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; + if (opacity != 255) { + blittingFlags |= DSBLIT_BLEND_COLORALPHA; } surface->SetColor(surface, 0xff, 0xff, 0xff, opacity); surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(blittingFlags)); @@ -1013,15 +947,9 @@ void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color) Q_ASSERT(surface); const quint8 alpha = (opacity == 255 ? color.alpha() : ALPHA_MUL(color.alpha(), opacity)); - surface->SetColor(surface, - color.red(), color.green(), color.blue(), alpha); - quint32 drawingFlags = drawFlagsFromCompositionMode; - if (alpha == 255) { - drawingFlags &= ~DSDRAW_BLEND; - } + surface->SetColor(surface, color.red(), color.green(), color.blue(), alpha); surface->SetPorterDuff(surface, DSPD_NONE); - // PorterDuff messes up alpha values for primitives - surface->SetDrawingFlags(surface, DFBSurfaceDrawingFlags(drawingFlags)); + surface->SetDrawingFlags(surface, alpha == 255 ? DSDRAW_NOFX : DSDRAW_BLEND); } void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) -- cgit v0.12 From d8ccdc88128999febfa7cc0c9d49f8a9ae8cc118 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 29 May 2009 18:42:51 -0400 Subject: Fixed sub-attaq example build --- examples/animation/sub-attaq/mainwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/animation/sub-attaq/mainwindow.cpp b/examples/animation/sub-attaq/mainwindow.cpp index 5e8e259..123363b 100644 --- a/examples/animation/sub-attaq/mainwindow.cpp +++ b/examples/animation/sub-attaq/mainwindow.cpp @@ -44,6 +44,8 @@ #include "graphicsscene.h" //Qt +#include + #ifdef QT_NO_OPENGL #include #include -- cgit v0.12 From 6e8bafefb9d8484c2fcd0b26c02d1af0e74e25e1 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 1 Jun 2009 12:51:32 +1000 Subject: prepend private/ for included private headers --- src/corelib/animation/qanimationgroup_p.h | 2 +- src/corelib/animation/qparallelanimationgroup_p.h | 2 +- src/corelib/animation/qpropertyanimation_p.h | 2 +- src/corelib/animation/qsequentialanimationgroup_p.h | 2 +- src/corelib/animation/qvariantanimation_p.h | 2 +- src/corelib/statemachine/qeventtransition_p.h | 2 +- src/corelib/statemachine/qhistorystate_p.h | 2 +- src/corelib/statemachine/qsignaltransition_p.h | 2 +- src/corelib/statemachine/qstate_p.h | 2 +- src/corelib/statemachine/qstatemachine_p.h | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/corelib/animation/qanimationgroup_p.h b/src/corelib/animation/qanimationgroup_p.h index a7bd0fa..0f07138 100644 --- a/src/corelib/animation/qanimationgroup_p.h +++ b/src/corelib/animation/qanimationgroup_p.h @@ -57,7 +57,7 @@ #include -#include "qabstractanimation_p.h" +#include "private/qabstractanimation_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/animation/qparallelanimationgroup_p.h b/src/corelib/animation/qparallelanimationgroup_p.h index f36d972..ecd6791 100644 --- a/src/corelib/animation/qparallelanimationgroup_p.h +++ b/src/corelib/animation/qparallelanimationgroup_p.h @@ -54,7 +54,7 @@ // #include "qparallelanimationgroup.h" -#include "qanimationgroup_p.h" +#include "private/qanimationgroup_p.h" #include QT_BEGIN_NAMESPACE diff --git a/src/corelib/animation/qpropertyanimation_p.h b/src/corelib/animation/qpropertyanimation_p.h index a4387dd..16c63ab 100644 --- a/src/corelib/animation/qpropertyanimation_p.h +++ b/src/corelib/animation/qpropertyanimation_p.h @@ -56,7 +56,7 @@ #include "qpropertyanimation.h" #include -#include "qvariantanimation_p.h" +#include "private/qvariantanimation_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h index 3ac90f8..c01aaf0 100644 --- a/src/corelib/animation/qsequentialanimationgroup_p.h +++ b/src/corelib/animation/qsequentialanimationgroup_p.h @@ -54,7 +54,7 @@ // #include "qsequentialanimationgroup.h" -#include "qanimationgroup_p.h" +#include "private/qanimationgroup_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h index aee2324..3ae0e39 100644 --- a/src/corelib/animation/qvariantanimation_p.h +++ b/src/corelib/animation/qvariantanimation_p.h @@ -58,7 +58,7 @@ #include #include -#include "qabstractanimation_p.h" +#include "private/qabstractanimation_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/statemachine/qeventtransition_p.h b/src/corelib/statemachine/qeventtransition_p.h index 600cec0..ab17ad3 100644 --- a/src/corelib/statemachine/qeventtransition_p.h +++ b/src/corelib/statemachine/qeventtransition_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include "qabstracttransition_p.h" +#include "private/qabstracttransition_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/statemachine/qhistorystate_p.h b/src/corelib/statemachine/qhistorystate_p.h index 5aaa64c..875dac8 100644 --- a/src/corelib/statemachine/qhistorystate_p.h +++ b/src/corelib/statemachine/qhistorystate_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include "qabstractstate_p.h" +#include "private/qabstractstate_p.h" #include diff --git a/src/corelib/statemachine/qsignaltransition_p.h b/src/corelib/statemachine/qsignaltransition_p.h index 339de63..aacb6fc 100644 --- a/src/corelib/statemachine/qsignaltransition_p.h +++ b/src/corelib/statemachine/qsignaltransition_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include "qabstracttransition_p.h" +#include "private/qabstracttransition_p.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h index 93744b9..eddd831 100644 --- a/src/corelib/statemachine/qstate_p.h +++ b/src/corelib/statemachine/qstate_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include "qabstractstate_p.h" +#include "private/qabstractstate_p.h" #include #include diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h index 54953b4..24073ca 100644 --- a/src/corelib/statemachine/qstatemachine_p.h +++ b/src/corelib/statemachine/qstatemachine_p.h @@ -62,7 +62,7 @@ #include #include "qstate.h" -#include "qstate_p.h" +#include "private/qstate_p.h" QT_BEGIN_NAMESPACE -- cgit v0.12 From 049619000c031964cf33ef351d3df619a6815f5e Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Mon, 1 Jun 2009 13:08:32 +1000 Subject: Fixed failure of tst_Selftests::checkXML. Cherry-pick of 548da9a5434d615456a7a6efda3380b7138c6000 and some earlier changes predating public repo. Note that this test is not failing if using Qt 4.5 only. However, it fails if using Qt 4.5 selftests against Qt master testlib. We want to be able to use master testlib to run 4.5 testcases, and this change does no harm when using Qt 4.5 testlib, so backport it to 4.5 for convenience. Original change description follows: A few tests use printf, which means they interfere with the XML test logging. Blacklist them for the XML test. Note that these tests happened to pass under the old test logger implementation. That was because the test logger always printed XML tags on a single line, and the printf calls contained no special XML characters. The test logs generated were technically valid XML but contained extraneous text. --- tests/auto/selftests/expected_skip.txt | 2 +- tests/auto/selftests/skip/tst_skip.cpp | 6 +++--- tests/auto/selftests/tst_selftests.cpp | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/auto/selftests/expected_skip.txt b/tests/auto/selftests/expected_skip.txt index ba41e67..f3be5b5 100644 --- a/tests/auto/selftests/expected_skip.txt +++ b/tests/auto/selftests/expected_skip.txt @@ -7,7 +7,7 @@ SKIP : tst_Skip::emptytest() skipping all Loc: [/home/fenglich/dev/qt-4.3/tests/auto/selftests/skip/tst_skip.cpp(45)] SKIP : tst_Skip::singleSkip(local 1) skipping one Loc: [/home/fenglich/dev/qt-4.3/tests/auto/selftests/skip/tst_skip.cpp(64)] -this line should only be reached once (true) +QDEBUG : tst_Skip::singleSkip(local 2) this line should only be reached once (true) PASS : tst_Skip::singleSkip() PASS : tst_Skip::cleanupTestCase() Totals: 3 passed, 0 failed, 3 skipped diff --git a/tests/auto/selftests/skip/tst_skip.cpp b/tests/auto/selftests/skip/tst_skip.cpp index b1a3936..437cf62 100644 --- a/tests/auto/selftests/skip/tst_skip.cpp +++ b/tests/auto/selftests/skip/tst_skip.cpp @@ -70,7 +70,7 @@ void tst_Skip::test_data() void tst_Skip::test() { - printf("this line should never be reached, since we skip in the _data function\n"); + qDebug("this line should never be reached, since we skip in the _data function"); } void tst_Skip::emptytest_data() @@ -80,7 +80,7 @@ void tst_Skip::emptytest_data() void tst_Skip::emptytest() { - printf("this line should never be reached, since we skip in the _data function\n"); + qDebug("this line should never be reached, since we skip in the _data function"); } void tst_Skip::singleSkip_data() @@ -95,7 +95,7 @@ void tst_Skip::singleSkip() QFETCH(bool, booll); if (!booll) QSKIP("skipping one", SkipSingle); - printf("this line should only be reached once (%s)\n", booll ? "true" : "false"); + qDebug("this line should only be reached once (%s)", booll ? "true" : "false"); } QTEST_MAIN(tst_Skip) diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 103fd79..6776b12 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -295,6 +295,11 @@ void tst_Selftests::initTestCase() m_checkXMLBlacklist.append("differentexec"); m_checkXMLBlacklist.append("qexecstringlist"); m_checkXMLBlacklist.append("benchliboptions"); + + /* These tests use printf and therefore corrupt the testlog */ + m_checkXMLBlacklist.append("subtest"); + m_checkXMLBlacklist.append("globaldata"); + m_checkXMLBlacklist.append("warnings"); } void tst_Selftests::checkXML() const -- cgit v0.12 From 0ff7b68f2e3f184d809cf6fd13ff930efa493e9f Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 1 Jun 2009 09:39:37 -0700 Subject: Improve readability of QDFBWindowSurface::scroll The batch-blits buys us nothing and this is much more readable. Reviewed-by: TrustMe --- .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 39 ++++++++++------------ 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index c7cae80..330eb88 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -239,31 +239,28 @@ void QDirectFBWindowSurface::setPermanentState(const QByteArray &state) #endif } -bool QDirectFBWindowSurface::scroll(const QRegion ®ion, int dx, int dy) +static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) { - if (!dfbSurface || !(flipFlags & DSFLIP_BLIT)) - return false; - - const QVector rects = region.rects(); - const int n = rects.size(); - - QVarLengthArray dfbRects(n); - QVarLengthArray dfbPoints(n); + surface->SetBlittingFlags(surface, DSBLIT_NOFX); + const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; + surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy); +} - for (int i = 0; i < n; ++i) { - const QRect r = rects.at(i); - dfbRects[i].x = r.x(); - dfbRects[i].y = r.y(); - dfbRects[i].w = r.width(); - dfbRects[i].h = r.height(); - dfbPoints[i].x = r.x() + dx; - dfbPoints[i].y = r.y() + dy; - } +bool QDirectFBWindowSurface::scroll(const QRegion ®ion, int dx, int dy) +{ + if (!dfbSurface || !(flipFlags & DSFLIP_BLIT) || region.isEmpty()) + return false; dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); - dfbSurface->BatchBlit(dfbSurface, dfbSurface, - dfbRects.data(), dfbPoints.data(), n); - dfbSurface->ReleaseSource(dfbSurface); + if (region.numRects() == 1) { + ::scrollSurface(dfbSurface, region.boundingRect(), dx, dy); + } else { + const QVector rects = region.rects(); + const int n = rects.size(); + for (int i=0; i Date: Tue, 2 Jun 2009 12:49:08 +1000 Subject: Optimize QMatrix4x4::mapRect() for translation and scale operations --- src/gui/math3d/qmatrix4x4.cpp | 69 +++++++++++++- src/gui/math3d/qmatrix4x4.h | 26 ------ tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp | 114 ++++++++++++++++++++++++ 3 files changed, 179 insertions(+), 30 deletions(-) diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index a8dabf3..d2f1ded 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -1411,8 +1411,6 @@ QTransform QMatrix4x4::toTransform() const #endif /*! - \fn QRect QMatrix4x4::mapRect(const QRect& rect) const - Maps \a rect by multiplying this matrix by the corners of \a rect and then forming a new rectangle from the results. The returned rectangle will be an ordinary 2D rectangle @@ -1420,10 +1418,43 @@ QTransform QMatrix4x4::toTransform() const \sa map() */ +QRect QMatrix4x4::mapRect(const QRect& rect) const +{ + if (flagBits == (Translation | Scale) || flagBits == Scale) { + qreal x = rect.x() * m[0][0] + m[3][0]; + qreal y = rect.y() * m[1][1] + m[3][1]; + qreal w = rect.width() * m[0][0]; + qreal h = rect.height() * m[1][1]; + if (w < 0) { + w = -w; + x -= w; + } + if (h < 0) { + h = -h; + y -= h; + } + return QRect(qRound(x), qRound(y), qRound(w), qRound(h)); + } else if (flagBits == Translation) { + return QRect(qRound(rect.x() + m[3][0]), + qRound(rect.y() + m[3][1]), + rect.width(), rect.height()); + } -/*! - \fn QRectF QMatrix4x4::mapRect(const QRectF& rect) const + QPoint tl = map(rect.topLeft()); + QPoint tr = map(QPoint(rect.x() + rect.width(), rect.y())); + QPoint bl = map(QPoint(rect.x(), rect.y() + rect.height())); + QPoint br = map(QPoint(rect.x() + rect.width(), + rect.y() + rect.height())); + + int xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x())); + int xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x())); + int ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y())); + int ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y())); + + return QRect(xmin, ymin, xmax - xmin, ymax - ymin); +} +/*! Maps \a rect by multiplying this matrix by the corners of \a rect and then forming a new rectangle from the results. The returned rectangle will be an ordinary 2D rectangle @@ -1431,6 +1462,36 @@ QTransform QMatrix4x4::toTransform() const \sa map() */ +QRectF QMatrix4x4::mapRect(const QRectF& rect) const +{ + if (flagBits == (Translation | Scale) || flagBits == Scale) { + qreal x = rect.x() * m[0][0] + m[3][0]; + qreal y = rect.y() * m[1][1] + m[3][1]; + qreal w = rect.width() * m[0][0]; + qreal h = rect.height() * m[1][1]; + if (w < 0) { + w = -w; + x -= w; + } + if (h < 0) { + h = -h; + y -= h; + } + return QRectF(x, y, w, h); + } else if (flagBits == Translation) { + return rect.translated(m[3][0], m[3][1]); + } + + QPointF tl = map(rect.topLeft()); QPointF tr = map(rect.topRight()); + QPointF bl = map(rect.bottomLeft()); QPointF br = map(rect.bottomRight()); + + qreal xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x())); + qreal xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x())); + qreal ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y())); + qreal ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y())); + + return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax)); +} /*! \fn float *QMatrix4x4::data() diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 2b485c1..00543f5 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -901,32 +901,6 @@ inline QVector4D QMatrix4x4::map(const QVector4D& point) const #endif -inline QRect QMatrix4x4::mapRect(const QRect& rect) const -{ - QPoint tl = map(rect.topLeft()); QPoint tr = map(rect.topRight()); - QPoint bl = map(rect.bottomLeft()); QPoint br = map(rect.bottomRight()); - - int xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x())); - int xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x())); - int ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y())); - int ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y())); - - return QRect(QPoint(xmin, ymin), QPoint(xmax, ymax)); -} - -inline QRectF QMatrix4x4::mapRect(const QRectF& rect) const -{ - QPointF tl = map(rect.topLeft()); QPointF tr = map(rect.topRight()); - QPointF bl = map(rect.bottomLeft()); QPointF br = map(rect.bottomRight()); - - qreal xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x())); - qreal xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x())); - qreal ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y())); - qreal ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y())); - - return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax)); -} - inline float *QMatrix4x4::data() { // We have to assume that the caller will modify the matrix elements, diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index bb510fc..936f9d6 100644 --- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -167,6 +167,9 @@ private slots: void fill(); + void mapRect_data(); + void mapRect(); + private: static void setMatrix(QMatrix2x2& m, const qreal *values); static void setMatrixFixed(QMatrix2x2& m, const qreal *values); @@ -3180,6 +3183,117 @@ void tst_QMatrix::fill() QVERIFY(isSame(m2, fillValues4x3)); } +// Test the mapRect() function for QRect and QRectF. +void tst_QMatrix::mapRect_data() +{ + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("width"); + QTest::addColumn("height"); + + QTest::newRow("null") + << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; + QTest::newRow("rect") + << (qreal)1.0f << (qreal)-20.5f << (qreal)100.0f << (qreal)63.75f; +} +void tst_QMatrix::mapRect() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(qreal, width); + QFETCH(qreal, height); + + QRectF rect(x, y, width, height); + QRect recti(qRound(x), qRound(y), qRound(width), qRound(height)); + + QMatrix4x4 m1; + QVERIFY(m1.mapRect(rect) == rect); + QVERIFY(m1.mapRect(recti) == recti); + + QMatrix4x4 m2; + m2.translate(-100.5f, 64.0f); + QRectF translated = rect.translated(-100.5f, 64.0f); + QRect translatedi = QRect(qRound(recti.x() - 100.5f), recti.y() + 64, + recti.width(), recti.height()); + QVERIFY(m2.mapRect(rect) == translated); + QVERIFY(m2.mapRect(recti) == translatedi); + + QMatrix4x4 m3; + m3.scale(-100.5f, 64.0f); + qreal scalex = x * -100.5f; + qreal scaley = y * 64.0f; + qreal scalewid = width * -100.5f; + qreal scaleht = height * 64.0f; + if (scalewid < 0.0f) { + scalewid = -scalewid; + scalex -= scalewid; + } + if (scaleht < 0.0f) { + scaleht = -scaleht; + scaley -= scaleht; + } + QRectF scaled(scalex, scaley, scalewid, scaleht); + QVERIFY(m3.mapRect(rect) == scaled); + scalex = recti.x() * -100.5f; + scaley = recti.y() * 64.0f; + scalewid = recti.width() * -100.5f; + scaleht = recti.height() * 64.0f; + if (scalewid < 0.0f) { + scalewid = -scalewid; + scalex -= scalewid; + } + if (scaleht < 0.0f) { + scaleht = -scaleht; + scaley -= scaleht; + } + QRect scaledi(qRound(scalex), qRound(scaley), + qRound(scalewid), qRound(scaleht)); + QVERIFY(m3.mapRect(recti) == scaledi); + + QMatrix4x4 m4; + m4.translate(-100.5f, 64.0f); + m4.scale(-2.5f, 4.0f); + qreal transx1 = x * -2.5f - 100.5f; + qreal transy1 = y * 4.0f + 64.0f; + qreal transx2 = (x + width) * -2.5f - 100.5f; + qreal transy2 = (y + height) * 4.0f + 64.0f; + if (transx1 > transx2) + qSwap(transx1, transx2); + if (transy1 > transy2) + qSwap(transy1, transy2); + QRectF trans(transx1, transy1, transx2 - transx1, transy2 - transy1); + QVERIFY(m4.mapRect(rect) == trans); + transx1 = recti.x() * -2.5f - 100.5f; + transy1 = recti.y() * 4.0f + 64.0f; + transx2 = (recti.x() + recti.width()) * -2.5f - 100.5f; + transy2 = (recti.y() + recti.height()) * 4.0f + 64.0f; + if (transx1 > transx2) + qSwap(transx1, transx2); + if (transy1 > transy2) + qSwap(transy1, transy2); + QRect transi(qRound(transx1), qRound(transy1), + qRound(transx2) - qRound(transx1), + qRound(transy2) - qRound(transy1)); + QVERIFY(m4.mapRect(recti) == transi); + + m4.rotate(45.0f, 0.0f, 0.0f, 1.0f); + + QTransform t4; + t4.translate(-100.5f, 64.0f); + t4.scale(-2.5f, 4.0f); + t4.rotate(45.0f); + QRectF mr = m4.mapRect(rect); + QRectF tr = t4.mapRect(rect); + QVERIFY(fuzzyCompare(mr.x(), tr.x())); + QVERIFY(fuzzyCompare(mr.y(), tr.y())); + QVERIFY(fuzzyCompare(mr.width(), tr.width())); + QVERIFY(fuzzyCompare(mr.height(), tr.height())); + + QRect mri = m4.mapRect(recti); + QRect tri = t4.mapRect(recti); + QVERIFY(mri == tri); +} + QTEST_APPLESS_MAIN(tst_QMatrix) #include "tst_qmatrixnxn.moc" -- cgit v0.12 From 5a7d208ee0730021b79310132d4dd384d7d15801 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 2 Jun 2009 11:55:31 +1000 Subject: QMatrix4x4::scale(qreal,qreal) and QMatrix4x4::translate(qreal,qreal) methods --- src/gui/math3d/qmatrix4x4.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++ src/gui/math3d/qmatrix4x4.h | 6 ++-- 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index d2f1ded..8ef4da3 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -740,6 +740,43 @@ QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector) \overload Multiplies this matrix by another that scales coordinates by the + components \a x, and \a y. Returns this matrix. + + \sa translate(), rotate() +*/ +QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y) +{ + float vx(x); + float vy(y); + if (flagBits == Identity) { + m[0][0] = vx; + m[1][1] = vy; + flagBits = Scale; + } else if (flagBits == Scale || flagBits == (Scale | Translation)) { + m[0][0] *= vx; + m[1][1] *= vy; + } else if (flagBits == Translation) { + m[0][0] = vx; + m[1][1] = vy; + flagBits |= Scale; + } else { + m[0][0] *= vx; + m[0][1] *= vx; + m[0][2] *= vx; + m[0][3] *= vx; + m[1][0] *= vy; + m[1][1] *= vy; + m[1][2] *= vy; + m[1][3] *= vy; + flagBits = General; + } + return *this; +} + +/*! + \overload + + Multiplies this matrix by another that scales coordinates by the components \a x, \a y, and \a z. Returns this matrix. \sa translate(), rotate() @@ -872,6 +909,46 @@ QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector) \overload Multiplies this matrix by another that translates coordinates + by the components \a x, and \a y. Returns this matrix. + + \sa scale(), rotate() +*/ +QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y) +{ + float vx(x); + float vy(y); + if (flagBits == Identity) { + m[3][0] = vx; + m[3][1] = vy; + flagBits = Translation; + } else if (flagBits == Translation) { + m[3][0] += vx; + m[3][1] += vy; + } else if (flagBits == Scale) { + m[3][0] = m[0][0] * vx; + m[3][1] = m[1][1] * vy; + m[3][2] = 0.; + flagBits |= Translation; + } else if (flagBits == (Scale | Translation)) { + m[3][0] += m[0][0] * vx; + m[3][1] += m[1][1] * vy; + } else { + m[3][0] += m[0][0] * vx + m[1][0] * vy; + m[3][1] += m[0][1] * vx + m[1][1] * vy; + m[3][2] += m[0][2] * vx + m[1][2] * vy; + m[3][3] += m[0][3] * vx + m[1][3] * vy; + if (flagBits == Rotation) + flagBits |= Translation; + else if (flagBits != (Rotation | Translation)) + flagBits = General; + } + return *this; +} + +/*! + \overload + + Multiplies this matrix by another that translates coordinates by the components \a x, \a y, and \a z. Returns this matrix. \sa scale(), rotate() diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 00543f5..cff4c1e 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -130,9 +130,11 @@ public: QMatrix4x4& translate(const QVector3D& vector); QMatrix4x4& rotate(qreal angle, const QVector3D& vector); #endif - QMatrix4x4& scale(qreal x, qreal y, qreal z = 1.0f); + QMatrix4x4& scale(qreal x, qreal y); + QMatrix4x4& scale(qreal x, qreal y, qreal z); QMatrix4x4& scale(qreal factor); - QMatrix4x4& translate(qreal x, qreal y, qreal z = 0.0f); + QMatrix4x4& translate(qreal x, qreal y); + QMatrix4x4& translate(qreal x, qreal y, qreal z); QMatrix4x4& rotate(qreal angle, qreal x, qreal y, qreal z = 0.0f); #ifndef QT_NO_QUATERNION QMatrix4x4& rotate(const QQuaternion& quaternion); -- cgit v0.12 From 32d87121d5102f01809a888dca5a42683a781b20 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 2 Jun 2009 13:01:09 +1000 Subject: Unit tests for 2D QMatrix4x4::translate() and scale() --- tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index 936f9d6..4d51e89 100644 --- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -1978,6 +1978,14 @@ void tst_QMatrix::scale4x4_data() 0.0f, 0.0f, 0.0f, 1.0f}; QTest::newRow("complex") << (qreal)2.0f << (qreal)11.0f << (qreal)-6.5f << (void *)complexScale; + + static const qreal complexScale2D[] = + {2.0f, 0.0f, 0.0f, 0.0f, + 0.0f, -11.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("complex2D") + << (qreal)2.0f << (qreal)-11.0f << (qreal)1.0f << (void *)complexScale2D; } void tst_QMatrix::scale4x4() { @@ -1996,6 +2004,12 @@ void tst_QMatrix::scale4x4() m2.scale(x, y, z); QVERIFY(isSame(m2, (const qreal *)resultValues)); + if (z == 1.0f) { + QMatrix4x4 m2b; + m2b.scale(x, y); + QVERIFY(m2b == m2); + } + QVector3D v1(2.0f, 3.0f, -4.0f); QVector3D v2 = m1 * v1; QCOMPARE(v2.x(), (qreal)(2.0f * x)); @@ -2049,6 +2063,12 @@ void tst_QMatrix::scale4x4() QVERIFY(isSame(m5, (const qreal *)resultValues)); } + if (z == 1.0f) { + QMatrix4x4 m4b(m3); + m4b.scale(x, y); + QVERIFY(m4b == m4); + } + // Test coverage when the special matrix type is unknown. QMatrix4x4 m6; @@ -2104,6 +2124,14 @@ void tst_QMatrix::translate4x4_data() 0.0f, 0.0f, 0.0f, 1.0f}; QTest::newRow("complex") << (qreal)2.0f << (qreal)11.0f << (qreal)-6.5f << (void *)complexTranslate; + + static const qreal complexTranslate2D[] = + {1.0f, 0.0f, 0.0f, 2.0f, + 0.0f, 1.0f, 0.0f, -11.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + QTest::newRow("complex2D") + << (qreal)2.0f << (qreal)-11.0f << (qreal)0.0f << (void *)complexTranslate2D; } void tst_QMatrix::translate4x4() { @@ -2122,6 +2150,12 @@ void tst_QMatrix::translate4x4() m2.translate(x, y, z); QVERIFY(isSame(m2, (const qreal *)resultValues)); + if (z == 0.0f) { + QMatrix4x4 m2b; + m2b.translate(x, y); + QVERIFY(m2b == m2); + } + QVector3D v1(2.0f, 3.0f, -4.0f); QVector3D v2 = m1 * v1; QCOMPARE(v2.x(), (qreal)(2.0f + x)); @@ -2156,6 +2190,12 @@ void tst_QMatrix::translate4x4() QMatrix4x4 m4(m3); m4.translate(x, y, z); QVERIFY(m4 == m3 * m1); + + if (z == 0.0f) { + QMatrix4x4 m4b(m3); + m4b.translate(x, y); + QVERIFY(m4b == m4); + } } // Test the generation and use of 4x4 rotation matrices. -- cgit v0.12 From 4636f6983aa253c7552bba5d7d8772844ea4c42c Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 2 Jun 2009 14:41:31 +1000 Subject: Add some performance tests for QMatrix4x4 --- tests/benchmarks/benchmarks.pro | 1 + tests/benchmarks/qmatrix4x4/qmatrix4x4.pro | 6 + tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp | 261 +++++++++++++++++++++++++ 3 files changed, 268 insertions(+) create mode 100644 tests/benchmarks/qmatrix4x4/qmatrix4x4.pro create mode 100644 tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index 4c39373..bc41125 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -9,6 +9,7 @@ SUBDIRS = containers-associative \ qpixmap \ blendbench \ qstringlist \ + qmatrix4x4 \ qobject \ qrect \ qregexp \ diff --git a/tests/benchmarks/qmatrix4x4/qmatrix4x4.pro b/tests/benchmarks/qmatrix4x4/qmatrix4x4.pro new file mode 100644 index 0000000..e82d9de --- /dev/null +++ b/tests/benchmarks/qmatrix4x4/qmatrix4x4.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qmatrix4x4 + +SOURCES += tst_qmatrix4x4.cpp + diff --git a/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp b/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp new file mode 100644 index 0000000..5046b17 --- /dev/null +++ b/tests/benchmarks/qmatrix4x4/tst_qmatrix4x4.cpp @@ -0,0 +1,261 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class tst_QMatrix4x4 : public QObject +{ + Q_OBJECT +public: + tst_QMatrix4x4() {} + ~tst_QMatrix4x4() {} + +private slots: + void multiply_data(); + void multiply(); + + void multiplyInPlace_data(); + void multiplyInPlace(); + + void multiplyDirect_data(); + void multiplyDirect(); + + void mapVector3D_data(); + void mapVector3D(); + + void mapVector2D_data(); + void mapVector2D(); + + void mapVectorDirect_data(); + void mapVectorDirect(); +}; + +static qreal const generalValues[16] = + {1.0f, 2.0f, 3.0f, 4.0f, + 5.0f, 6.0f, 7.0f, 8.0f, + 9.0f, 10.0f, 11.0f, 12.0f, + 13.0f, 14.0f, 15.0f, 16.0f}; + +void tst_QMatrix4x4::multiply_data() +{ + QTest::addColumn("m1"); + QTest::addColumn("m2"); + + QTest::newRow("identity * identity") + << QMatrix4x4() << QMatrix4x4(); + QTest::newRow("identity * general") + << QMatrix4x4() << QMatrix4x4(generalValues); + QTest::newRow("general * identity") + << QMatrix4x4(generalValues) << QMatrix4x4(); + QTest::newRow("general * general") + << QMatrix4x4(generalValues) << QMatrix4x4(generalValues); +} + +QMatrix4x4 mresult; + +void tst_QMatrix4x4::multiply() +{ + QFETCH(QMatrix4x4, m1); + QFETCH(QMatrix4x4, m2); + + QMatrix4x4 m3; + + QBENCHMARK { + m3 = m1 * m2; + } + + // Force the result to be stored so the compiler doesn't + // optimize away the contents of the benchmark loop. + mresult = m3; +} + +void tst_QMatrix4x4::multiplyInPlace_data() +{ + multiply_data(); +} + +void tst_QMatrix4x4::multiplyInPlace() +{ + QFETCH(QMatrix4x4, m1); + QFETCH(QMatrix4x4, m2); + + QMatrix4x4 m3; + + QBENCHMARK { + m3 = m1; + m3 *= m2; + } + + // Force the result to be stored so the compiler doesn't + // optimize away the contents of the benchmark loop. + mresult = m3; +} + +// Use a direct naive multiplication algorithm. This is used +// to compare against the optimized routines to see if they are +// actually faster than the naive implementation. +void tst_QMatrix4x4::multiplyDirect_data() +{ + multiply_data(); +} +void tst_QMatrix4x4::multiplyDirect() +{ + QFETCH(QMatrix4x4, m1); + QFETCH(QMatrix4x4, m2); + + QMatrix4x4 m3; + + const float *m1data = m1.constData(); + const float *m2data = m2.constData(); + float *m3data = m3.data(); + + QBENCHMARK { + for (int row = 0; row < 4; ++row) { + for (int col = 0; col < 4; ++col) { + m3data[col * 4 + row] = 0.0f; + for (int j = 0; j < 4; ++j) { + m3data[col * 4 + row] += + m1data[j * 4 + row] * m2data[col * 4 + j]; + } + } + } + } +} + +QVector3D vresult; + +void tst_QMatrix4x4::mapVector3D_data() +{ + QTest::addColumn("m1"); + + QTest::newRow("identity") << QMatrix4x4(); + QTest::newRow("general") << QMatrix4x4(generalValues); + + QMatrix4x4 t1; + t1.translate(-100.5f, 64.0f, 75.25f); + QTest::newRow("translate3D") << t1; + + QMatrix4x4 t2; + t2.translate(-100.5f, 64.0f); + QTest::newRow("translate2D") << t2; + + QMatrix4x4 s1; + s1.scale(-100.5f, 64.0f, 75.25f); + QTest::newRow("scale3D") << s1; + + QMatrix4x4 s2; + s2.scale(-100.5f, 64.0f); + QTest::newRow("scale2D") << s2; +} +void tst_QMatrix4x4::mapVector3D() +{ + QFETCH(QMatrix4x4, m1); + + QVector3D v(10.5f, -2.0f, 3.0f); + QVector3D result; + + m1.inferSpecialType(); + + QBENCHMARK { + result = m1 * v; + } + + // Force the result to be stored so the compiler doesn't + // optimize away the contents of the benchmark loop. + vresult = result; +} + +QPointF vresult2; + +void tst_QMatrix4x4::mapVector2D_data() +{ + mapVector3D_data(); +} +void tst_QMatrix4x4::mapVector2D() +{ + QFETCH(QMatrix4x4, m1); + + QPointF v(10.5f, -2.0f); + QPointF result; + + m1.inferSpecialType(); + + QBENCHMARK { + result = m1 * v; + } + + // Force the result to be stored so the compiler doesn't + // optimize away the contents of the benchmark loop. + vresult2 = result; +} + +// Use a direct naive multiplication algorithm. This is used +// to compare against the optimized routines to see if they are +// actually faster than the naive implementation. +void tst_QMatrix4x4::mapVectorDirect_data() +{ + mapVector3D_data(); +} +void tst_QMatrix4x4::mapVectorDirect() +{ + QFETCH(QMatrix4x4, m1); + + const float *m1data = m1.constData(); + float v[4] = {10.5f, -2.0f, 3.0f, 1.0f}; + float result[4]; + + QBENCHMARK { + for (int row = 0; row < 4; ++row) { + result[row] = 0.0f; + for (int col = 0; col < 4; ++col) { + result[row] += m1data[col * 4 + row] * v[col]; + } + } + result[0] /= result[3]; + result[1] /= result[3]; + result[2] /= result[3]; + } +} + +QTEST_MAIN(tst_QMatrix4x4) + +#include "tst_qmatrix4x4.moc" -- cgit v0.12 From 3245f19f8d3abbcba5fcd9adc3fc984ad4c7ddcb Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 2 Jun 2009 15:06:12 +1000 Subject: Optimize QMatrix4x4::map() for QVector3D/QPoint/QPointF Use the matrix "flagBits" to short-cut transformations when the matrix type is identity/translate/scale. --- src/gui/math3d/qmatrix4x4.h | 135 +++++++++++++++++++++++++++++--------------- 1 file changed, 90 insertions(+), 45 deletions(-) diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index cff4c1e..ba7f67f 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -631,26 +631,43 @@ inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix) inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector) { float x, y, z, w; - x = vector.xp * matrix.m[0][0] + - vector.yp * matrix.m[1][0] + - vector.zp * matrix.m[2][0] + - matrix.m[3][0]; - y = vector.xp * matrix.m[0][1] + - vector.yp * matrix.m[1][1] + - vector.zp * matrix.m[2][1] + - matrix.m[3][1]; - z = vector.xp * matrix.m[0][2] + - vector.yp * matrix.m[1][2] + - vector.zp * matrix.m[2][2] + - matrix.m[3][2]; - w = vector.xp * matrix.m[0][3] + - vector.yp * matrix.m[1][3] + - vector.zp * matrix.m[2][3] + - matrix.m[3][3]; - if (w == 1.0f) - return QVector3D(x, y, z, 1); - else - return QVector3D(x / w, y / w, z / w, 1); + if (matrix.flagBits == QMatrix4x4::Identity) { + return vector; + } else if (matrix.flagBits == QMatrix4x4::Translation) { + return QVector3D(vector.xp + matrix.m[3][0], + vector.yp + matrix.m[3][1], + vector.zp + matrix.m[3][2], 1); + } else if (matrix.flagBits == + (QMatrix4x4::Translation | QMatrix4x4::Scale)) { + return QVector3D(vector.xp * matrix.m[0][0] + matrix.m[3][0], + vector.yp * matrix.m[1][1] + matrix.m[3][1], + vector.zp * matrix.m[2][2] + matrix.m[3][2], 1); + } else if (matrix.flagBits == QMatrix4x4::Scale) { + return QVector3D(vector.xp * matrix.m[0][0], + vector.yp * matrix.m[1][1], + vector.zp * matrix.m[2][2], 1); + } else { + x = vector.xp * matrix.m[0][0] + + vector.yp * matrix.m[1][0] + + vector.zp * matrix.m[2][0] + + matrix.m[3][0]; + y = vector.xp * matrix.m[0][1] + + vector.yp * matrix.m[1][1] + + vector.zp * matrix.m[2][1] + + matrix.m[3][1]; + z = vector.xp * matrix.m[0][2] + + vector.yp * matrix.m[1][2] + + vector.zp * matrix.m[2][2] + + matrix.m[3][2]; + w = vector.xp * matrix.m[0][3] + + vector.yp * matrix.m[1][3] + + vector.zp * matrix.m[2][3] + + matrix.m[3][3]; + if (w == 1.0f) + return QVector3D(x, y, z, 1); + else + return QVector3D(x / w, y / w, z / w, 1); + } } #endif @@ -752,19 +769,33 @@ inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point) float x, y, w; xin = point.x(); yin = point.y(); - x = xin * matrix.m[0][0] + - yin * matrix.m[1][0] + - matrix.m[3][0]; - y = xin * matrix.m[0][1] + - yin * matrix.m[1][1] + - matrix.m[3][1]; - w = xin * matrix.m[0][3] + - yin * matrix.m[1][3] + - matrix.m[3][3]; - if (w == 1.0f) - return QPoint(qRound(x), qRound(y)); - else - return QPoint(qRound(x / w), qRound(y / w)); + if (matrix.flagBits == QMatrix4x4::Identity) { + return point; + } else if (matrix.flagBits == QMatrix4x4::Translation) { + return QPoint(qRound(xin + matrix.m[3][0]), + qRound(yin + matrix.m[3][1])); + } else if (matrix.flagBits == + (QMatrix4x4::Translation | QMatrix4x4::Scale)) { + return QPoint(qRound(xin * matrix.m[0][0] + matrix.m[3][0]), + qRound(yin * matrix.m[1][1] + matrix.m[3][1])); + } else if (matrix.flagBits == QMatrix4x4::Scale) { + return QPoint(qRound(xin * matrix.m[0][0]), + qRound(yin * matrix.m[1][1])); + } else { + x = xin * matrix.m[0][0] + + yin * matrix.m[1][0] + + matrix.m[3][0]; + y = xin * matrix.m[0][1] + + yin * matrix.m[1][1] + + matrix.m[3][1]; + w = xin * matrix.m[0][3] + + yin * matrix.m[1][3] + + matrix.m[3][3]; + if (w == 1.0f) + return QPoint(qRound(x), qRound(y)); + else + return QPoint(qRound(x / w), qRound(y / w)); + } } inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point) @@ -773,19 +804,33 @@ inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point) float x, y, w; xin = point.x(); yin = point.y(); - x = xin * matrix.m[0][0] + - yin * matrix.m[1][0] + - matrix.m[3][0]; - y = xin * matrix.m[0][1] + - yin * matrix.m[1][1] + - matrix.m[3][1]; - w = xin * matrix.m[0][3] + - yin * matrix.m[1][3] + - matrix.m[3][3]; - if (w == 1.0f) { - return QPointF(qreal(x), qreal(y)); + if (matrix.flagBits == QMatrix4x4::Identity) { + return point; + } else if (matrix.flagBits == QMatrix4x4::Translation) { + return QPointF(xin + matrix.m[3][0], + yin + matrix.m[3][1]); + } else if (matrix.flagBits == + (QMatrix4x4::Translation | QMatrix4x4::Scale)) { + return QPointF(xin * matrix.m[0][0] + matrix.m[3][0], + yin * matrix.m[1][1] + matrix.m[3][1]); + } else if (matrix.flagBits == QMatrix4x4::Scale) { + return QPointF(xin * matrix.m[0][0], + yin * matrix.m[1][1]); } else { - return QPointF(qreal(x / w), qreal(y / w)); + x = xin * matrix.m[0][0] + + yin * matrix.m[1][0] + + matrix.m[3][0]; + y = xin * matrix.m[0][1] + + yin * matrix.m[1][1] + + matrix.m[3][1]; + w = xin * matrix.m[0][3] + + yin * matrix.m[1][3] + + matrix.m[3][3]; + if (w == 1.0f) { + return QPointF(qreal(x), qreal(y)); + } else { + return QPointF(qreal(x / w), qreal(y / w)); + } } } -- cgit v0.12 From 63fba94e074c29f17e35c7cf9133d1878b18401f Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 2 Jun 2009 15:10:43 +1000 Subject: Fix signature for QGenericMatrix::fill() The signature was using qreal, when it should have used T. --- src/gui/math3d/qgenericmatrix.cpp | 2 +- src/gui/math3d/qgenericmatrix.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/math3d/qgenericmatrix.cpp b/src/gui/math3d/qgenericmatrix.cpp index a77ca42..6ecd878 100644 --- a/src/gui/math3d/qgenericmatrix.cpp +++ b/src/gui/math3d/qgenericmatrix.cpp @@ -116,7 +116,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QGenericMatrix::fill(qreal value) + \fn void QGenericMatrix::fill(T value) Fills all elements of this matrix with \a value. */ diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h index d0b22de..b4d3707 100644 --- a/src/gui/math3d/qgenericmatrix.h +++ b/src/gui/math3d/qgenericmatrix.h @@ -65,7 +65,7 @@ public: bool isIdentity() const; void setIdentity(); - void fill(qreal value); + void fill(T value); QGenericMatrix transposed() const; @@ -175,7 +175,7 @@ Q_OUTOFLINE_TEMPLATE void QGenericMatrix::setIdentity() } template -Q_OUTOFLINE_TEMPLATE void QGenericMatrix::fill(qreal value) +Q_OUTOFLINE_TEMPLATE void QGenericMatrix::fill(T value) { for (int col = 0; col < N; ++col) for (int row = 0; row < M; ++row) -- cgit v0.12 From 5dca661dc78d8eb0489e7debf342a0869ae75a43 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Tue, 2 Jun 2009 10:35:10 +0200 Subject: My changes for Qt 4.5.2. Better late than never. --- dist/changes-4.5.2 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dist/changes-4.5.2 b/dist/changes-4.5.2 index dcb77d6..98ea59e 100644 --- a/dist/changes-4.5.2 +++ b/dist/changes-4.5.2 @@ -46,6 +46,18 @@ Third party components Plugins (r41346, r43550, r43915, r43917, r43923) Clipboard (r41360) +- QMacStyle + * [253339] Don't draw arrows on toolbuttons that have a menu and text only. + * [252301] Ensure that small and mini spin boxes are drawn correctly. + +- QFontDialog + * [252000] Ensure that QFontDialog::getFont() works on Mac OS X. + +- QWidget + * [250668] Don't send extra wheel events when using the scroll wheel in Cocoa. + * [253448] Prevent a crash when using the Qt::WA_MacBrushedMetal attribute + in conjunction with style sheets. + **************************************************************************** * Database Drivers * **************************************************************************** @@ -65,6 +77,10 @@ Qt for Windows Qt for Mac OS X --------------- +[252795] Ensure that we send Apple Events in the Cocoa port even when Cocoa isn't ready. +[252176] Fix regression in drawing parts of pixmaps on Panther. +[253402] Fix a crash when a Cocoa window that used to be a QWidget would get events + after the QWidget was destroyed. Qt for Embedded Linux @@ -101,6 +117,8 @@ Qt for Windows CE of 'Fixed' on the main cointainer. * [253278] Made it possible to set QString-type properties using QDesignerFormWindowCursor::setProperty(). + * [253539] Prevent crash in Designer with the Cocoa port when when using a scroll + wheel to change a property. - Linguist - Linguist GUI -- cgit v0.12 From d018549a25761b5e50d90939d94384f23d7a01e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 29 May 2009 19:05:29 +0200 Subject: Fixes possible infinite loop in QApplication::topLevelAt KDE Bug: https://bugs.kde.org/show_bug.cgi?id=191759 Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qapplication_x11.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index a3c9406..12155f0 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -2955,10 +2955,10 @@ QWidget *QApplication::topLevelAt(const QPoint &p) Window wid = widget->internalWinId(); while (ctarget && !w) { X11->ignoreBadwindow(); - XTranslateCoordinates(X11->display, - QX11Info::appRootWindow(screen), - ctarget, x, y, &unused, &unused, &ctarget); - if (X11->badwindow()) + if (!XTranslateCoordinates(X11->display, + QX11Info::appRootWindow(screen), + ctarget, x, y, &unused, &unused, &ctarget) + || X11->badwindow()) break; if (ctarget == wid) { // Found! -- cgit v0.12 From d52fb58f34199e9a6e008929425cd21b92a2674a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 2 Jun 2009 10:42:21 +0200 Subject: Fixed bug in QClipData::fixup(). The bounding rect computed in fixup() is one pixel too wide, causing potential memory corruption by painting outside device boundaries. Reviewed-by: Trond --- src/gui/painting/qpaintengine_raster.cpp | 2 -- tests/auto/qpainter/tst_qpainter.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 3f85095..578a815 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -4475,14 +4475,12 @@ void QClipData::fixup() if (sl != left || sr != right) isRect = false; } - ++xmax; // qDebug("xmin=%d,xmax=%d,ymin=%d,ymax=%d %s", xmin, xmax, ymin, ymax, isRect ? "rectangular" : ""); if (isRect) { hasRectClip = true; clipRect.setRect(xmin, ymin, xmax - xmin, ymax - ymin); } - } /* diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 87f9c13..af0f6cf 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -226,6 +226,7 @@ private slots: void extendedBlendModes(); void zeroOpacity(); + void clippingBug(); private: void fillData(); @@ -4168,5 +4169,28 @@ void tst_QPainter::zeroOpacity() QCOMPARE(target.pixel(0, 0), 0xff000000); } +void tst_QPainter::clippingBug() +{ + QImage img(32, 32, QImage::Format_ARGB32_Premultiplied); + img.fill(0); + + QImage expected = img; + QPainter p(&expected); + p.fillRect(1, 1, 30, 30, Qt::red); + p.end(); + + QPainterPath path; + path.addRect(1, 1, 30, 30); + path.addRect(1, 1, 30, 30); + path.addRect(1, 1, 30, 30); + + p.begin(&img); + p.setClipPath(path); + p.fillRect(0, 0, 32, 32, Qt::red); + p.end(); + + QCOMPARE(img, expected); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" -- cgit v0.12 From 8f16a4f1638fd661e74c6aa60822cd9ef17e5003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 2 Jun 2009 11:02:21 +0200 Subject: My 4.5.2 changes for the changelog. --- dist/changes-4.5.2 | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/dist/changes-4.5.2 b/dist/changes-4.5.2 index 98ea59e..0cb3112 100644 --- a/dist/changes-4.5.2 +++ b/dist/changes-4.5.2 @@ -58,6 +58,26 @@ Third party components * [253448] Prevent a crash when using the Qt::WA_MacBrushedMetal attribute in conjunction with style sheets. +- QPainter + * [253783] Fixed text shaping bugs when using ligatures and different + scripts in a single text item. + * Fixed various inconsistencies for image drawing on non-integer + coordinates. + * Fixed bug with 0-opacity causing images to be drawn fully opaque. + * Fixed crash when drawing on a null pixmap. + * [251534] Fixed issue where text with non-opaque color from widget + palette would be blitted instead of blended. + +- QTransform + * Fixed issue in QTransform::type() causing a projective transform to be + treated as a scaling transform. + +- QtOpenGL + * [247083] Re-enabled antialiasing for large font sizes in OpenGL paint + engine. + * [251485] Fixed crash that could occur with projective transforms and + high quality antialiasing. + **************************************************************************** * Database Drivers * **************************************************************************** @@ -69,7 +89,11 @@ Third party components Qt for Linux/X11 ---------------- - +[253186] Fixed compile error in qfontengine_ft.cpp on 64-bit platforms with +legacy freetype headers. +[241361] Prevented asynchronous access to non-thread safe libfontconfig API. +[244362] Worked around X server crash when calling XFillPolygon with more than +200000 points by falling back to raster paint engine. Qt for Windows -------------- -- cgit v0.12 From 65b2f91df8376df97fed7d7096ac73db838e7d09 Mon Sep 17 00:00:00 2001 From: jieshuzheng Date: Sun, 31 May 2009 18:02:31 +0800 Subject: Remove the redundant timer kill and start when the two QTimer::start(int) is made in succession If you restart the QTimer like the following code snippet shows, the timer will get killed and started twice. QTimer timer; timer.start(100); timer.start(1000); Since QTimer::start(int msec) calls QTimer::setInterval(int msec), and QTimer::setInterval(int msec) will kill the timer and start another one if there is already a timer running. And QTimer::start() will do the same thing again. It is a performance penalty here. Under Windows, it will result in one extra call of SetTimer(). And under Symbian, it will result in one extra new and delete of CPeriodic and adding and removing it from AS. --- src/corelib/kernel/qtimer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 08821d4..8ca53b9 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -211,7 +211,7 @@ void QTimer::start() */ void QTimer::start(int msec) { - setInterval(msec); + inter = msec; start(); } -- cgit v0.12 From 7314c07a3e443b1d5349b419a03db8d41ca43f7e Mon Sep 17 00:00:00 2001 From: jasplin Date: Tue, 2 Jun 2009 10:57:42 +0200 Subject: BT: Fixed crash on Mac caused by erroneous handling of native focus events. On Mac, a widget with a NoFocus policy could still get focus (if only temporarily) as the result of a native focus event. In particular, a line edit with a completer should not lose focus (if only for a brief moment) as a result of the completer popup being shown. This will for example cause an item delegate to think that the user has navigated away from the cell and delete the line edit as a result. This will in turn cause the completer to access a null pointer. Reviewed-by: Richard Moe Gustavsen Task-number: 254456 and 254460 --- src/gui/kernel/qwidget_mac.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index f863428..c82b87d 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -1296,8 +1296,11 @@ OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event, if(part == kControlFocusNoPart){ if (widget->hasFocus()) QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason); - } else + } else if (widget->focusPolicy() != Qt::NoFocus) { widget->setFocus(); + } else { + handled_event = false; + } } if(!HIObjectIsOfClass((HIObjectRef)hiview, kObjectQWidget)) CallNextEventHandler(er, event); -- cgit v0.12 From 39fc672795fbb60118e8f506e4f2c49b1980b7c0 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Tue, 2 Jun 2009 11:48:34 +0200 Subject: Change QDesktopServices::TempLocation on Mac to be the same as QDir. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the past, TempLocation would return something like: /private/var/folders/4k/4k97GBy2Ha46D3DAWSLbQE+++TI/TemporaryItems Now it returns something like: /var/folders/4k/4k97GBy2Ha46D3DAWSLbQE+++TI/-Tmp- This isn't that different and it's a temporary location so it shouldn't effect many people (and it will be gone once the system reboots anyway), but the issue could be that TemporaryItems isn't there and that it's a bit more "Carbon" to use TemporaryItems. Also our own documentation claims they are equivalent and I'm happy to do that. I also enforced the Qt-style of if-statements and got rid of the extra qualifiers to make the code look nicer. Task-number: 253806 Reviewed-by: Morten Sørvig --- src/gui/util/qdesktopservices_mac.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gui/util/qdesktopservices_mac.cpp b/src/gui/util/qdesktopservices_mac.cpp index fb1e193..4f730b7 100644 --- a/src/gui/util/qdesktopservices_mac.cpp +++ b/src/gui/util/qdesktopservices_mac.cpp @@ -134,13 +134,15 @@ static QString getFullPath(const FSRef &ref) QString QDesktopServices::storageLocation(StandardLocation type) { - if (QDesktopServices::HomeLocation == type) + if (type == HomeLocation) return QDir::homePath(); + if (type == TempLocation) + return QDir::tempPath(); + short domain = kOnAppropriateDisk; - if (QDesktopServices::DataLocation == type - || QDesktopServices::CacheLocation == type) + if (type == DataLocation || type == CacheLocation) domain = kUserDomain; // http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html @@ -152,8 +154,7 @@ QString QDesktopServices::storageLocation(StandardLocation type) QString path = getFullPath(ref); QString appName = QCoreApplication::applicationName(); - if (!appName.isEmpty() && - (QDesktopServices::DataLocation == type || QDesktopServices::CacheLocation == type)) + if (!appName.isEmpty() && (type == DataLocation || type == CacheLocation)) path += QLatin1Char('/') + appName; return path; -- cgit v0.12 From c46126179dfb12e01d5787fdd2278cfc0788d9fa Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 2 Jun 2009 12:02:14 +0200 Subject: Improve detection of monotonic timer support Some older systems support monotonic timers, but not POSIX.1-2001. The sysconf() function is documented to return -1 if a feature is not supported, otherwise it returns a value that's dependent on it's argument. For POSIX.1-2001 compliant system, the value is 200112L, but on other systems it may just return 1, for example. Because of this, we check for the -1 return value (feature missing), instead of relying on a specific (positive) return value. --- src/corelib/kernel/qeventdispatcher_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index 6aa3b56..1b9cb93 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -263,7 +263,7 @@ QTimerInfoList::QTimerInfoList() # if (_POSIX_MONOTONIC_CLOCK == 0) // detect if the system support monotonic timers long x = sysconf(_SC_MONOTONIC_CLOCK); - useMonotonicTimers = x >= 200112L; + useMonotonicTimers = x != -1; # endif getTime(currentTime); -- cgit v0.12 From f001cda07f6aa026d59e448b49212c0182ed895c Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 2 Jun 2009 12:40:48 +0200 Subject: Removed an ifdef in QLocale that breaks the One Definition Rule. From a merge request #553 by Gordon Schumacher: During a build internal to Qt, if a header included by qlocale.cpp itself includes qlocale.h, then QLOCALE_CPP will never be set. If you attempt to build qmake from its own .pro file, qmake_pch.h includes qtextstream.h, which (now) includes qlocale.h, thus causing a compile error trying to call the QSystemLocale(bool) function Inspired-by: Gordon Schumacher --- src/corelib/tools/qlocale.cpp | 1 - src/corelib/tools/qlocale.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 9953155..4c2f59a 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -42,7 +42,6 @@ #include "qglobal.h" #ifndef QT_NO_SYSTEMLOCALE -#define QLOCALE_CPP QT_BEGIN_NAMESPACE class QSystemLocale; static QSystemLocale *QSystemLocale_globalSystemLocale(); diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index 5b611eb..987ab4e 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -99,11 +99,9 @@ public: virtual QVariant query(QueryType type, QVariant in) const; virtual QLocale fallbackLocale() const; -#ifdef QLOCALE_CPP private: QSystemLocale(bool); friend QSystemLocale *QSystemLocale_globalSystemLocale(); -#endif }; #endif -- cgit v0.12 From 9b53bb583ca7e74c737683d85593e4a97107a777 Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Tue, 2 Jun 2009 13:02:27 +0200 Subject: Doc - changing the "main layout" term to "top level widget's layout" to preserve some consistency. Also added a screenshot of the Object Insepector displaying a form where its widget has no top level layout. Reviewed-By: TrustMe --- doc/src/designer-manual.qdoc | 19 ++++++++++++------- doc/src/images/rgbController-no-toplevel-layout.png | Bin 0 -> 1343 bytes 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 doc/src/images/rgbController-no-toplevel-layout.png diff --git a/doc/src/designer-manual.qdoc b/doc/src/designer-manual.qdoc index 4b8de32..fc3adcf 100644 --- a/doc/src/designer-manual.qdoc +++ b/doc/src/designer-manual.qdoc @@ -465,18 +465,23 @@ spin boxes and sliders as well. The next step is to combine all three layouts into one \bold{main layout}. - It is important that your form has a main layout; otherwise, the widgets - on your form will not resize when your form is resized. To set the main - layout, \gui{Right click} anywhere on your form, outside of the three - separate layouts, and select \gui{Lay Out Horizontally}. Alternatively, you - could also select \gui{Lay Out in a Grid} -- you will still see the same - arrangement (shown below). + The main layout is the top level widget's (in this case, the QWidget) + layout. It is important that your top level widget has a layout; otherwise, + the widgets on your window will not resize when your window is resized. To + set the layout, \gui{Right click} anywhere on your form, outside of the + three separate layouts, and select \gui{Lay Out Horizontally}. + Alternatively, you could also select \gui{Lay Out in a Grid} -- you will + still see the same arrangement (shown below). \image rgbController-final-layout.png \note Main layouts cannot be seen on the form. To check if you have a main layout installed, try resizing your form; your widgets should resize - accordingly. + accordingly. Alternatively, you can take a look at \QD's + \gui{Object Inspector}. If your top level widget does not have a layout, + you will see the broken layout icon next to it, + \inlineimage rgbController-no-toplevel-layout.png + . When you click on the slider and drag it to a certain value, you want the spin box to display the slider's position. To accomplish this behavior, you diff --git a/doc/src/images/rgbController-no-toplevel-layout.png b/doc/src/images/rgbController-no-toplevel-layout.png new file mode 100644 index 0000000..0a9bc29 Binary files /dev/null and b/doc/src/images/rgbController-no-toplevel-layout.png differ -- cgit v0.12 From 9dc7a011e798c24b4dd8b19a74b42c61f52a1328 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 2 Jun 2009 13:08:10 +0200 Subject: Changelog for 4.5.2 --- dist/changes-4.5.2 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dist/changes-4.5.2 b/dist/changes-4.5.2 index 0cb3112..423bbdd 100644 --- a/dist/changes-4.5.2 +++ b/dist/changes-4.5.2 @@ -94,10 +94,15 @@ legacy freetype headers. [241361] Prevented asynchronous access to non-thread safe libfontconfig API. [244362] Worked around X server crash when calling XFillPolygon with more than 200000 points by falling back to raster paint engine. +[250326] Titlebar wasn't shown on X11 with Qt::CustomizeWindowHint for + fixed-size windows. +[251925] Improved showing QMessageBox on small screens. Qt for Windows -------------- +[251259] Switching to another app left text cursor in line edits with + QtMfc framework. Qt for Mac OS X --------------- -- cgit v0.12 From 983411366b3517fce2dd6fc6b72c6292e93f6824 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 2 Jun 2009 13:10:47 +0200 Subject: qdoc: Changed the css to make more people happy. No more fonts less than 100%. Toned down the green lines separating table rows, now gray (or we can try a softer green). Made the table widt 100%. More coming. the constructors still aren't aligned properly. --- tools/qdoc3/htmlgenerator.cpp | 2 +- tools/qdoc3/test/classic.css | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index e2e6950..4e4261f 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -2181,7 +2181,7 @@ void HtmlGenerator::generateSectionList(const Section& section, } if (name_alignment) { out() << "\n"; + << "cellspacing=\"0\" width=\"100%\">\n"; } else { if (twoColumn) diff --git a/tools/qdoc3/test/classic.css b/tools/qdoc3/test/classic.css index a6c2652..fa0167b 100644 --- a/tools/qdoc3/test/classic.css +++ b/tools/qdoc3/test/classic.css @@ -73,16 +73,16 @@ table td.memItemLeft { border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; - border-top-color: #66bc29; - border-right-color: #66bc29; - border-bottom-color: #66bc29; - border-left-color: #66bc29; + border-top-color: #E0E0E0; + border-right-color: #E0E0E0; + border-bottom-color: #E0E0E0; + border-left-color: #E0E0E0; border-top-style: solid; border-right-style: none; border-bottom-style: none; border-left-style: none; background-color: #FAFAFA; - font-size: 80%; + font-size: 100%; white-space: nowrap } table td.memItemRight { @@ -92,16 +92,16 @@ table td.memItemRight { border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; - border-top-color: #66bc29; - border-right-color: #66bc29; - border-bottom-color: #66bc29; - border-left-color: #66bc29; + border-top-color: #E0E0E0; + border-right-color: #E0E0E0; + border-bottom-color: #E0E0E0; + border-left-color: #E0E0E0; border-top-style: solid; border-right-style: none; border-bottom-style: none; border-left-style: none; background-color: #FAFAFA; - font-size: 80%; + font-size: 100%; } table tr.odd { -- cgit v0.12 From 3be8bd20537ea215c7accaf1be3ffb6673fd897b Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Tue, 2 Jun 2009 13:37:07 +0200 Subject: Ensure small and mini headers aren't bigger than "large" ones. We were only "constraining" headers if they were large, but ignoring the small and mini ones. This resulted in the small and mini headers looking bigger than their normal ones which looked strange. Since the headers have no real small or mini size for a header, we'll make sure to constrain them all the same. Task-number: 221115 Reviewed-by: Richard Moe Gustavsen --- src/gui/styles/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 2478f20..43efedf 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -851,7 +851,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg } break; case QStyle::CT_HeaderSection: - if (sz == QAquaSizeLarge && isTreeView(widg)) + if (isTreeView(widg)) ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricListHeaderHeight)); break; case QStyle::CT_MenuBar: -- cgit v0.12 From 4ae7a683217eb2a7e9fc2fe2ed173e7da277038b Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 2 Jun 2009 13:44:24 +0200 Subject: My Changelog for 4.5.2 --- dist/changes-4.5.2 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dist/changes-4.5.2 b/dist/changes-4.5.2 index 423bbdd..c87ad92 100644 --- a/dist/changes-4.5.2 +++ b/dist/changes-4.5.2 @@ -46,6 +46,9 @@ Third party components Plugins (r41346, r43550, r43915, r43917, r43923) Clipboard (r41360) +- QAbstractNetworkCache + * Only cache responses to HTTP GET by default, not HTTP PUT or POST + - QMacStyle * [253339] Don't draw arrows on toolbuttons that have a menu and text only. * [252301] Ensure that small and mini spin boxes are drawn correctly. @@ -53,6 +56,13 @@ Third party components - QFontDialog * [252000] Ensure that QFontDialog::getFont() works on Mac OS X. +- QNetworkCookie + * [251959] fix parsing of multiple cookies separated by a newline + +- QNetworkCookieJar + * [251467] do not allow cookies for domains like ".com" + * [228974] allow cookies whose domain attribute is missing a leading dot + - QWidget * [250668] Don't send extra wheel events when using the scroll wheel in Cocoa. * [253448] Prevent a crash when using the Qt::WA_MacBrushedMetal attribute -- cgit v0.12 From 5be3335436501c5e0d3f5cb047edba1371aeb187 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 2 Jun 2009 15:02:00 +0200 Subject: Use a QVarLengthArray instead of some hacky self-made container This won't leak on error case, and will work with arbitrary sizes. Also changed from int to short as instructed by Samuel. Reviewed-by: Samuel --- src/gui/painting/qpaintengine_raster.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 847904b..58ffb02 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3876,11 +3876,7 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r { Q_ASSERT(c1->clipSpanHeight == c2->clipSpanHeight && c1->clipSpanHeight == result->clipSpanHeight); - // ### buffer overflow possible - const int BUFFER_SIZE = 4096; - int buffer[BUFFER_SIZE]; - int *b = buffer; - int bsize = BUFFER_SIZE; + QVarLengthArray buffer; QClipData::ClipLine *c1ClipLines = const_cast(c1)->clipLines(); QClipData::ClipLine *c2ClipLines = const_cast(c2)->clipLines(); @@ -3907,11 +3903,8 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r // find required length int max = qMax(c1_spans[c1_count - 1].x + c1_spans[c1_count - 1].len, c2_spans[c2_count - 1].x + c2_spans[c2_count - 1].len); - if (max > bsize) { - b = (int *)realloc(bsize == BUFFER_SIZE ? 0 : b, max*sizeof(int)); - bsize = max; - } - memset(buffer, 0, BUFFER_SIZE * sizeof(int)); + buffer.resize(max); + memset(buffer.data(), 0, buffer.size() * sizeof(short)); // Fill with old spans. for (int i = 0; i < c1_count; ++i) { @@ -3947,8 +3940,6 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r result->appendSpan(sx, x - sx, y, coverage); } } - if (b != buffer) - free(b); } void QRasterPaintEnginePrivate::initializeRasterizer(QSpanData *data) -- cgit v0.12 From 7a095c52057633e9050e74622f8a990738c2741b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 2 Jun 2009 15:20:04 +0200 Subject: Fixed aspect ratio on Windows - When changing the aspect ratio, the video wouldn't update. - The VMR9 can in some cases try to manage the aspect ratio itself and then fights our system. This is now disabled. --- src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp | 1 + src/3rdparty/phonon/ds9/videowidget.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp b/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp index 298e9fa..81ebb8b 100644 --- a/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp +++ b/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp @@ -169,6 +169,7 @@ namespace Phonon Q_ASSERT(SUCCEEDED(hr)); ComPointer windowlessControl(m_filter, IID_IVMRWindowlessControl9); windowlessControl->SetVideoClippingWindow(reinterpret_cast(target->winId())); + windowlessControl->SetAspectRatioMode(VMR9ARMode_None); //we're in control of the size } QImage VideoRendererVMR9::snapshot() const diff --git a/src/3rdparty/phonon/ds9/videowidget.cpp b/src/3rdparty/phonon/ds9/videowidget.cpp index de7ce5f..0ef653f 100644 --- a/src/3rdparty/phonon/ds9/videowidget.cpp +++ b/src/3rdparty/phonon/ds9/videowidget.cpp @@ -261,6 +261,7 @@ namespace Phonon { m_aspectRatio = aspectRatio; updateVideoSize(); + m_widget->update(); } Phonon::VideoWidget::ScaleMode VideoWidget::scaleMode() const @@ -279,6 +280,7 @@ namespace Phonon { m_scaleMode = scaleMode; updateVideoSize(); + m_widget->update(); } void VideoWidget::setBrightness(qreal b) -- cgit v0.12 From d7700105933b3c4071f8df524915dbaa2092d82b Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Tue, 2 Jun 2009 15:48:27 +0200 Subject: Correct invalid font. QFont() returns the app font, not an invalid font. --- tests/auto/qcssparser/tst_cssparser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qcssparser/tst_cssparser.cpp b/tests/auto/qcssparser/tst_cssparser.cpp index 7c4fac1..b41a745 100644 --- a/tests/auto/qcssparser/tst_cssparser.cpp +++ b/tests/auto/qcssparser/tst_cssparser.cpp @@ -1475,7 +1475,7 @@ void tst_CssParser::extractFontFamily_data() QTest::newRow("unquoted-family-name2") << "font-family: Times New Roman" << QString("Times New Roman"); QTest::newRow("multiple") << "font-family: Times New Roman , foobar, 'baz'" << QString("Times New Roman"); QTest::newRow("multiple2") << "font-family: invalid, Times New Roman " << QString("Times New Roman"); - QTest::newRow("invalid") << "font-family: invalid" << QFont().family(); + QTest::newRow("invalid") << "font-family: invalid" << QFontInfo(QFont("invalid font")).family(); QTest::newRow("shorthand") << "font: 12pt Times New Roman" << QString("Times New Roman"); QTest::newRow("shorthand multiple quote") << "font: 12pt invalid, \"Times New Roman\" " << QString("Times New Roman"); QTest::newRow("shorthand multiple") << "font: 12pt invalid, Times New Roman " << QString("Times New Roman"); -- cgit v0.12 From ad46e77420449ede2cb6c1ea2a810a2614520db9 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Tue, 2 Jun 2009 16:09:58 +0200 Subject: BT: Remove duplicate code and fix font parsing. QFont has a feature that you can pass a comma-separated list and it will walk through the list and match the font that it hits first. There's a nice static function that X11 and Windows uses, but the Mac was using an older copied version of it. This old version didn't handle quoting which is what happens in the style sheet. So, using the same code makes everything work well. As a bonus, Creator looks correct again. Reviewed-by: Simon Hausmann --- src/gui/text/qfontdatabase.cpp | 2 +- src/gui/text/qfontdatabase_mac.cpp | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index c3fc9f5..5fb294f 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -827,6 +827,7 @@ static void getEngineData(const QFontPrivate *d, const QFontCache::Key &key) d->engineData->ref.ref(); } } +#endif static QStringList familyList(const QFontDef &req) { @@ -855,7 +856,6 @@ static QStringList familyList(const QFontDef &req) return family_list; } -#endif Q_GLOBAL_STATIC(QFontDatabasePrivate, privateDb) Q_GLOBAL_STATIC_WITH_ARGS(QMutex, fontDatabaseMutex, (QMutex::Recursive)) diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp index 80ddbd5..26d8687 100644 --- a/src/gui/text/qfontdatabase_mac.cpp +++ b/src/gui/text/qfontdatabase_mac.cpp @@ -281,14 +281,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script) } //find the font - QStringList family_list = req.family.split(QLatin1Char(',')); - // append the substitute list for each family in family_list - { - QStringList subs_list; - for(QStringList::ConstIterator it = family_list.constBegin(); it != family_list.constEnd(); ++it) - subs_list += QFont::substitutes(*it); - family_list += subs_list; - } + QStringList family_list = familyList(req); const char *stylehint = styleHint(req); if (stylehint) -- cgit v0.12 From 1a7da7096bbda17197738061902f4489af234bc0 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 2 Jun 2009 14:59:17 +0200 Subject: Setting a focus on a widget hierarchy which contains both visible and invisible widgets could cause a crash. Also, when there is a widget hierarchy A->B->C and A and C are marked as visible but B is hidden, when the user gives focus explicitely to C, we should remember that and respect it when B becomes visible. Task-number: 254563 Reviewed-by: Thierry Bastian --- src/gui/kernel/qwidget.cpp | 11 ++++++++++- tests/auto/qwidget/tst_qwidget.cpp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 5538c11..d436ffb 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5674,10 +5674,15 @@ void QWidget::setFocus(Qt::FocusReason reason) w = w->isWindow() ? 0 : w->parentWidget(); } } else { - while (w) { + while (w && w->isVisible()) { w->d_func()->focus_child = f; w = w->isWindow() ? 0 : w->parentWidget(); } + // a special case, if there is an invisible parent, notify him + // about the focus_child widget, so that if it becomes + // visible, the focus widget will be respected. + if (w) + w->d_func()->focus_child = f; } #ifndef QT_NO_GRAPHICSVIEW @@ -6729,6 +6734,10 @@ void QWidgetPrivate::show_helper() if (QApplicationPrivate::hidden_focus_widget == q) { QApplicationPrivate::hidden_focus_widget = 0; q->setFocus(Qt::OtherFocusReason); + } else if (focus_child) { + // if we are shown and there is an explicit focus child widget + // set, respect it by giving him focus. + focus_child->setFocus(Qt::OtherFocusReason); } // Process events when showing a Qt::SplashScreen widget before the event loop diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 23ead01..3fad366 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -350,6 +350,9 @@ private slots: void updateOnDestroyedSignal(); void toplevelLineEditFocus(); + void focusWidget_task254563(); + void focusWidget_mixed_widget_hierarchy(); + private: bool ensureScreenSize(int width, int height); QWidget *testWidget; @@ -8977,5 +8980,37 @@ void tst_QWidget::toplevelLineEditFocus() QCOMPARE(QApplication::focusWidget(), &w); } +void tst_QWidget::focusWidget_task254563() +{ + //having different visibility for widget is important + QWidget top; + top.show(); + QWidget container(&top); + QWidget *widget = new QWidget(&container); + widget->show(); + + widget->setFocus(); //set focus (will set the focus widget up to the toplevel to be 'widget') + container.setFocus(); + delete widget; // will call clearFocus but that doesn't help + QVERIFY(top.focusWidget() != widget); //dangling pointer +} + +void tst_QWidget::focusWidget_mixed_widget_hierarchy() +{ + QWidget top; + top.show(); + QWidget notvisible(&top); + QWidget *visible = new QWidget(¬visible); + visible->show(); + + visible->setFocus(); + notvisible.setFocus(); + notvisible.show(); + QCOMPARE(top.focusWidget(), visible); + QCOMPARE(notvisible.focusWidget(), visible); + QCOMPARE(visible->focusWidget(), visible); +} + + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" -- cgit v0.12 From a5b11b9031f9a2a97b65e9a6134244249845491a Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 2 Jun 2009 16:29:57 +0200 Subject: Avoid a crash when setting a focus in a widget hierarchy containing both visible and invisible widgets. This is a quick hack to avoid a crash in Qt when setting a focus on a visible widget that has invisible parent. Proper fix was committed into master 1a7da7096bbda17197738061902f4489af234bc0, see it's description for more details. Task-number: 254563 Reviewed-by: Thierry Bastian --- src/gui/kernel/qwidget.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index bbf6758..baf3278 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5804,8 +5804,9 @@ void QWidget::setFocus(Qt::FocusReason reason) void QWidget::clearFocus() { QWidget *w = this; - while (w && w->d_func()->focus_child == this) { - w->d_func()->focus_child = 0; + while (w) { + if (w->d_func()->focus_child == this) + w->d_func()->focus_child = 0; w = w->parentWidget(); } #ifndef QT_NO_GRAPHICSVIEW -- cgit v0.12 From be833a4f25a8ec8c3dd7a8ac4fa4b0507c93e7ee Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 2 Jun 2009 16:51:04 +0200 Subject: Revert "Avoid a crash when setting a focus in a widget hierarchy containing" This reverts commit a5b11b9031f9a2a97b65e9a6134244249845491a. The proper fix is 1a7da7096bbda17197738061902f4489af234bc0. --- src/gui/kernel/qwidget.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 451686f..d436ffb 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5757,9 +5757,8 @@ void QWidget::setFocus(Qt::FocusReason reason) void QWidget::clearFocus() { QWidget *w = this; - while (w) { - if (w->d_func()->focus_child == this) - w->d_func()->focus_child = 0; + while (w && w->d_func()->focus_child == this) { + w->d_func()->focus_child = 0; w = w->parentWidget(); } #ifndef QT_NO_GRAPHICSVIEW -- cgit v0.12 From 2b051b2a7dce75eee10c166edffb41a3b56b4a27 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 2 Jun 2009 18:33:28 +0200 Subject: Merged changes to the string builder class. Reviewed-by: Trust Me --- src/corelib/tools/qstringbuilder.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 2b4a242..4f24f76 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -64,7 +64,7 @@ \sa QStringBuilder, QLatin1String, QString, QStringRef */ -/*! \fn QLatin1Literal::QLatin1Literal(const char(&string)[]) +/*! \fn QLatin1Literal::QLatin1Literal(const char(&string)[N]) Constructs a new literal from the given \a string. */ @@ -93,7 +93,7 @@ \reentrant \since 4.6 - \brief QStringBuilder is a template class that provides a facility to build + \brief The QStringBuilder class is a template class that provides a facility to build up QStrings from smaller chunks. \ingroup tools @@ -102,7 +102,7 @@ \mainclass When creating strings from smaller chunks, typically \c QString::operator+() - is used, resulting in \i{n - 1} reallocations when operating on \i{n} chunks. + is used, resulting in \e{n - 1} reallocations when operating on \e{n} chunks. QStringBuilder uses expression templates to collect the individual parts, compute the total size, allocate memory for the resulting QString object, -- cgit v0.12 From d37de8e085bdc3ee5d0185b403879bac485ef834 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 2 Jun 2009 20:07:04 +0200 Subject: Doc: Modified the property documentation to relax the restriction on const getter functions. Task-number: 254722 Reviewed-by: Trust Me --- doc/src/properties.qdoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/src/properties.qdoc b/doc/src/properties.qdoc index d934f13..0251d3f 100644 --- a/doc/src/properties.qdoc +++ b/doc/src/properties.qdoc @@ -71,10 +71,10 @@ \list \o A \c READ accessor function is required. It is for reading the - property value. It must be const and must return either the - property's type or a pointer or reference to that type. e.g., - QWidget::focus is a read-only property with \c READ function - QWidget::hasFocus(). + property value. Ideally, a const function is used for this purpose, + and it must return either the property's type or a pointer or + reference to that type. e.g., QWidget::focus is a read-only property + with \c READ function, QWidget::hasFocus(). \o A \c WRITE accessor function is optional. It is for setting the property value. It must return void and must take exactly one -- cgit v0.12 From fa95af38594b09718b9eb9048b75b9628dc9a0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 2 Jun 2009 15:25:07 +0200 Subject: Implemented QGLTextureGlyphCache to avoid wasting glyph cache memory. Now there's only a copy of the texture glyph cache in graphics memory, avoiding the system memory copy that we used earlier. In addition the texture will use the GL_ALPHA texture format when possible, making it consume less graphics memory as well. Reviewed-by: Tom --- src/gui/painting/qtextureglyphcache.cpp | 69 ++++--- src/gui/painting/qtextureglyphcache_p.h | 3 +- .../gl2paintengineex/qglengineshadermanager.cpp | 29 +++ .../gl2paintengineex/qglengineshadermanager_p.h | 4 + .../gl2paintengineex/qglengineshadersource_p.h | 9 +- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 198 ++++++++++++++++++--- src/opengl/qgl.h | 1 + 7 files changed, 255 insertions(+), 58 deletions(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 89df869..6b195bf 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -157,6 +157,46 @@ void QTextureGlyphCache::populate(const QTextItemInt &ti, } +QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g) const +{ +#if defined(Q_WS_X11) + if (m_transform.type() > QTransform::TxTranslate) { + QFontEngineFT::GlyphFormat format = QFontEngineFT::Format_None; + QImage::Format imageFormat = QImage::Format_Invalid; + switch (m_type) { + case Raster_RGBMask: + format = QFontEngineFT::Format_A32; + imageFormat = QImage::Format_RGB32; + break; + case Raster_A8: + format = QFontEngineFT::Format_A8; + imageFormat = QImage::Format_Indexed8; + break; + case Raster_Mono: + format = QFontEngineFT::Format_Mono; + imageFormat = QImage::Format_Mono; + break; + }; + + QFontEngineFT *ft = static_cast (m_current_textitem->fontEngine); + QFontEngineFT::QGlyphSet *gset = ft->loadTransformedGlyphSet(m_transform); + + if (gset && ft->loadGlyphs(gset, &g, 1, format)) { + QFontEngineFT::Glyph *glyph = gset->glyph_data.value(g); + const int bytesPerLine = (format == QFontEngineFT::Format_Mono ? ((glyph->width + 31) & ~31) >> 3 + : (glyph->width + 3) & ~3); + return QImage(glyph->data, glyph->width, glyph->height, bytesPerLine, imageFormat); + } + } else +#endif + if (m_type == QFontEngineGlyphCache::Raster_RGBMask) + return m_current_textitem->fontEngine->alphaRGBMapForGlyph(g, glyphMargin(), m_transform); + else + return m_current_textitem->fontEngine->alphaMapForGlyph(g, m_transform); + + return QImage(); +} + /************************************************************************ * QImageTextureGlyphCache */ @@ -198,34 +238,7 @@ int QImageTextureGlyphCache::glyphMargin() const void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g) { - QImage mask; -#if defined(Q_WS_X11) - if (m_transform.type() > QTransform::TxTranslate) { - QFontEngineFT::GlyphFormat format = QFontEngineFT::Format_None; - switch (m_type) { - case Raster_RGBMask: - format = QFontEngineFT::Format_A32; break; - case Raster_A8: - format = QFontEngineFT::Format_A8; break; - case Raster_Mono: - format = QFontEngineFT::Format_Mono; break; - }; - - QFontEngineFT *ft = static_cast (m_current_textitem->fontEngine); - QFontEngineFT::QGlyphSet *gset = ft->loadTransformedGlyphSet(m_transform); - - if (gset && ft->loadGlyphs(gset, &g, 1, format)) { - QFontEngineFT::Glyph *glyph = gset->glyph_data.value(g); - const int bytesPerLine = (format == QFontEngineFT::Format_Mono ? ((glyph->width + 31) & ~31) >> 3 - : (glyph->width + 3) & ~3); - mask = QImage(glyph->data, glyph->width, glyph->height, bytesPerLine, m_image.format()); - } - } else -#endif - if (m_type == QFontEngineGlyphCache::Raster_RGBMask) - mask = m_current_textitem->fontEngine->alphaRGBMapForGlyph(g, glyphMargin(), m_transform); - else - mask = m_current_textitem->fontEngine->alphaMapForGlyph(g, m_transform); + QImage mask = textureMapForGlyph(g); #ifdef CACHE_DEBUG printf("fillTexture of %dx%d at %d,%d in the cache of %dx%d\n", c.w, c.h, c.x, c.y, m_image.width(), m_image.height()); diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index 7f2c478..cb5be75 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -108,6 +108,8 @@ public: QHash coords; + QImage textureMapForGlyph(glyph_t g) const; + protected: const QTextItemInt *m_current_textitem; @@ -116,7 +118,6 @@ protected: int m_cx; // current x int m_cy; // current y QFontEngineGlyphCache::Type m_type; - }; diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index f64af85..3159cbb 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -64,6 +64,7 @@ QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) maskType(NoMask), useTextureCoords(false), compositionMode(QPainter::CompositionMode_SourceOver), + blitShaderProg(0), simpleShaderProg(0), currentShaderProg(0) { @@ -83,6 +84,7 @@ QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) code[MainVertexShader] = qglslMainVertexShader; code[MainWithTexCoordsVertexShader] = qglslMainWithTexCoordsVertexShader; + code[UntransformedPositionVertexShader] = qglslUntransformedPositionVertexShader; code[PositionOnlyVertexShader] = qglslPositionOnlyVertexShader; code[PositionWithPatternBrushVertexShader] = qglslPositionWithPatternBrushVertexShader; code[PositionWithLinearGradientBrushVertexShader] = qglslPositionWithLinearGradientBrushVertexShader; @@ -160,6 +162,24 @@ QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) qCritical() << "Errors linking simple shader:" << simpleShaderProg->log(); } + + // Compile the blit shader: + blitShaderProg = new QGLShaderProgram(ctx, this); + compileNamedShader(MainWithTexCoordsVertexShader, QGLShader::PartialVertexShader); + compileNamedShader(UntransformedPositionVertexShader, QGLShader::PartialVertexShader); + compileNamedShader(MainFragmentShader, QGLShader::PartialFragmentShader); + compileNamedShader(ImageSrcFragmentShader, QGLShader::PartialFragmentShader); + blitShaderProg->addShader(compiledShaders[MainWithTexCoordsVertexShader]); + blitShaderProg->addShader(compiledShaders[UntransformedPositionVertexShader]); + blitShaderProg->addShader(compiledShaders[MainFragmentShader]); + blitShaderProg->addShader(compiledShaders[ImageSrcFragmentShader]); + blitShaderProg->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); + blitShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); + blitShaderProg->link(); + if (!blitShaderProg->isLinked()) { + qCritical() << "Errors linking blit shader:" + << blitShaderProg->log(); + } } QGLEngineShaderManager::~QGLEngineShaderManager() @@ -176,6 +196,11 @@ void QGLEngineShaderManager::optimiseForBrushTransform(const QTransform &transfo Q_UNUSED(transform); // Currently ignored } +void QGLEngineShaderManager::setDirty() +{ + shaderProgNeedsChanging = true; +} + void QGLEngineShaderManager::setSrcPixelType(Qt::BrushStyle style) { srcPixelType = style; @@ -222,6 +247,10 @@ QGLShaderProgram* QGLEngineShaderManager::simpleProgram() return simpleShaderProg; } +QGLShaderProgram* QGLEngineShaderManager::blitProgram() +{ + return blitShaderProg; +} diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index b8b2745..9bc81ef 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -279,15 +279,18 @@ public: void setMaskType(MaskType); void setCompositionMode(QPainter::CompositionMode); + void setDirty(); // someone has manually changed the current shader program bool useCorrectShaderProg(); // returns true if the shader program needed to be changed QGLShaderProgram* currentProgram(); // Returns pointer to the shader the manager has chosen QGLShaderProgram* simpleProgram(); // Used to draw into e.g. stencil buffers + QGLShaderProgram* blitProgram(); // Used to blit a texture into the framebuffer enum ShaderName { MainVertexShader, MainWithTexCoordsVertexShader, + UntransformedPositionVertexShader, PositionOnlyVertexShader, PositionWithPatternBrushVertexShader, PositionWithLinearGradientBrushVertexShader, @@ -365,6 +368,7 @@ private: bool useTextureCoords; QPainter::CompositionMode compositionMode; + QGLShaderProgram* blitShaderProg; QGLShaderProgram* simpleShaderProg; QGLShaderProgram* currentShaderProg; diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index fdbba72..920d0bc 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -89,6 +89,12 @@ static const char* const qglslPositionOnlyVertexShader = "\ gl_Position = pmvMatrix * vertexCoordsArray;\ }"; +static const char* const qglslUntransformedPositionVertexShader = "\ + attribute highp vec4 vertexCoordsArray;\ + void setPosition(void)\ + {\ + gl_Position = vertexCoordsArray;\ + }"; // Pattern Brush - This assumes the texture size is 8x8 and thus, the inverted size is 0.125 static const char* const qglslPositionWithPatternBrushVertexShader = "\ @@ -354,7 +360,7 @@ static const char* const qglslMaskFragmentShader = "\ lowp vec4 applyMask(lowp vec4 src) \ {\ lowp vec4 mask = texture2D(maskTexture, textureCoords); \ - return src * mask.r; \ + return src * mask.a; \ }"; /* @@ -375,7 +381,6 @@ static const char* const qglslMaskFragmentShader = "\ ExclusionCompositionModeFragmentShader, */ - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 40f3a8d..868adcf 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -79,18 +79,165 @@ #include "qglengineshadermanager_p.h" #include "qgl2pexvertexarray_p.h" - #include QT_BEGIN_NAMESPACE -extern QImage qt_imageForBrush(int brushStyle, bool invert); - static const GLuint QT_BRUSH_TEXTURE_UNIT = 0; static const GLuint QT_IMAGE_TEXTURE_UNIT = 0; //Can be the same as brush texture unit static const GLuint QT_MASK_TEXTURE_UNIT = 1; static const GLuint QT_BACKGROUND_TEXTURE_UNIT = 2; +class QGLTextureGlyphCache : public QTextureGlyphCache +{ +public: + QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix); + ~QGLTextureGlyphCache(); + + virtual void createTextureData(int width, int height); + virtual void resizeTextureData(int width, int height); + virtual void fillTexture(const Coord &c, glyph_t glyph); + + inline GLuint texture() const { return m_texture; } + + inline int width() const { return m_width; } + inline int height() const { return m_height; } + + inline void setPaintEnginePrivate(QGL2PaintEngineExPrivate *p) { pex = p; } + +private: + QGLContext *ctx; + + QGL2PaintEngineExPrivate *pex; + + GLuint m_texture; + GLuint m_fbo; + + int m_width; + int m_height; + + QGLShaderProgram *m_program; +}; + +QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix) + : QTextureGlyphCache(type, matrix) + , ctx(context) + , m_width(0) + , m_height(0) +{ + glGenFramebuffers(1, &m_fbo); +} + +QGLTextureGlyphCache::~QGLTextureGlyphCache() +{ + glDeleteFramebuffers(1, &m_fbo); + + if (m_width || m_height) + glDeleteTextures(1, &m_texture); +} + +void QGLTextureGlyphCache::createTextureData(int width, int height) +{ + glGenTextures(1, &m_texture); + glBindTexture(GL_TEXTURE_2D, m_texture); + + m_width = width; + m_height = height; + + QVarLengthArray data(width * height); + for (int i = 0; i < width * height; ++i) + data[i] = 0; + + if (m_type == QFontEngineGlyphCache::Raster_RGBMask) + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]); + else + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); +} + +void QGLTextureGlyphCache::resizeTextureData(int width, int height) +{ + // ### the QTextureGlyphCache API needs to be reworked to allow + // ### resizeTextureData to fail + + int oldWidth = m_width; + int oldHeight = m_height; + + GLuint oldTexture = m_texture; + createTextureData(width, height); + + glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo); + + GLuint colorBuffer; + glGenRenderbuffers(1, &colorBuffer); + glBindRenderbuffer(GL_RENDERBUFFER_EXT, colorBuffer); + glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_RGBA, oldWidth, oldHeight); + glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_RENDERBUFFER_EXT, colorBuffer); + glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0); + + glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); + glBindTexture(GL_TEXTURE_2D, oldTexture); + + pex->transferMode(BrushDrawingMode); + + glDisable(GL_SCISSOR_TEST); + glDisable(GL_DEPTH_TEST); + + glViewport(0, 0, oldWidth, oldHeight); + + float vertexCoordinateArray[] = { -1, -1, 1, -1, 1, 1, -1, 1 }; + float textureCoordinateArray[] = { 0, 0, 1, 0, 1, 1, 0, 1 }; + + glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); + glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); + + glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray); + glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray); + + pex->shaderManager->blitProgram()->enable(); + pex->shaderManager->blitProgram()->setUniformValue("imageTexture", QT_IMAGE_TEXTURE_UNIT); + pex->shaderManager->setDirty(); + + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + + glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); + glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); + + glBindTexture(GL_TEXTURE_2D, m_texture); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight); + + glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_RENDERBUFFER_EXT, 0); + glDeleteRenderbuffers(1, &colorBuffer); + glDeleteTextures(1, &oldTexture); + + glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo); + + glViewport(0, 0, pex->width, pex->height); + pex->updateDepthClip(); +} + +void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) +{ + QImage mask = textureMapForGlyph(glyph); + + const uint maskWidth = mask.width(); + const uint maskHeight = mask.height(); + + glBindTexture(GL_TEXTURE_2D, m_texture); + if (mask.format() == QImage::Format_RGB32) { + glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, m_height - c.y, maskWidth, maskHeight, GL_BGRA, GL_UNSIGNED_BYTE, mask.bits()); + } else { + mask = mask.convertToFormat(QImage::Format_Indexed8); + glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits()); + } +} + +extern QImage qt_imageForBrush(int brushStyle, bool invert); + ////////////////////////////////// Private Methods ////////////////////////////////////////// QGL2PaintEngineExPrivate::~QGL2PaintEngineExPrivate() @@ -141,6 +288,7 @@ void QGL2PaintEngineExPrivate::setBrush(const QBrush* brush) void QGL2PaintEngineExPrivate::useSimpleShader() { shaderManager->simpleProgram()->enable(); + shaderManager->setDirty(); if (matrixDirty) updateMatrix(); @@ -905,8 +1053,6 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextItemInt &ti) { - transferMode(TextDrawingMode); - Q_Q(QGL2PaintEngineEx); QOpenGL2PaintEngineState *s = q->state(); @@ -921,34 +1067,32 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) : QFontEngineGlyphCache::Raster_A8; - GLenum maskFormat = GL_RGBA; - if (glyphType == QFontEngineGlyphCache::Raster_A8) { - shaderManager->setMaskType(QGLEngineShaderManager::PixelMask); -// maskFormat = GL_ALPHA; + QGLTextureGlyphCache *cache = + (QGLTextureGlyphCache *) ti.fontEngine->glyphCache(ctx, s->matrix); + if (!cache) { + cache = new QGLTextureGlyphCache(ctx, glyphType, s->matrix); + ti.fontEngine->setGlyphCache(ctx, cache); } + + cache->setPaintEnginePrivate(this); + cache->populate(ti, glyphs, positions); + + if (cache->width() == 0 || cache->height() == 0) + return; + + transferMode(TextDrawingMode); + + if (glyphType == QFontEngineGlyphCache::Raster_A8) + shaderManager->setMaskType(QGLEngineShaderManager::PixelMask); else if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMask); //### TODO: Gamma correction shaderManager->setTextureCoordsEnabled(true); - - QImageTextureGlyphCache *cache = - (QImageTextureGlyphCache *) ti.fontEngine->glyphCache(glyphType, s->matrix); - if (!cache) { - cache = new QImageTextureGlyphCache(glyphType, s->matrix); - ti.fontEngine->setGlyphCache(glyphType, cache); - } - - cache->populate(ti, glyphs, positions); - - const QImage &image = cache->image(); int margin = cache->glyphMargin(); - if (image.isNull()) - return; - - GLfloat dx = 1.0 / image.width(); - GLfloat dy = 1.0 / image.height(); + GLfloat dx = 1.0 / cache->width(); + GLfloat dy = 1.0 / cache->height(); QGLPoint *oldVertexCoordinateDataPtr = vertexCoordinateArray.data(); QGLPoint *oldTextureCoordinateDataPtr = textureCoordinateArray.data(); @@ -962,11 +1106,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte int y = positions[i].y.toInt() - c.baseLineY - margin; vertexCoordinateArray.addRect(QRectF(x, y, c.w, c.h)); - textureCoordinateArray.addRect(QRectF(c.x*dx, 1 - c.y*dy, c.w * dx, -c.h * dy)); + textureCoordinateArray.addRect(QRectF(c.x*dx, c.y*dy, c.w * dx, c.h * dy)); } glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT); - ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, true); + glBindTexture(GL_TEXTURE_2D, cache->texture()); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false); QBrush pensBrush = q->state()->pen.brush(); diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 19d779a..6b511e2 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -363,6 +363,7 @@ private: friend class QGLWindowSurface; friend class QGLPixmapData; friend class QGLPixmapFilterBase; + friend class QGLTextureGlyphCache; friend QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags(); #ifdef Q_WS_MAC public: -- cgit v0.12 From e11ff338951954f08866aef15607e8fae2bc150c Mon Sep 17 00:00:00 2001 From: Frederik Schwarzer Date: Wed, 3 Jun 2009 09:25:20 +0200 Subject: missing opening paragraph tag Merge-request: 578 Reviewed-by: Simon Hausmann --- src/gui/dialogs/qmessagebox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index 1734e85..648cda8 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -1699,7 +1699,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title) "and Qt for Windows CE.

" "

Qt is available under three different licensing options designed " "to accommodate the needs of our various users.

" - "Qt licensed under our commercial license agreement is appropriate " + "

Qt licensed under our commercial license agreement is appropriate " "for development of proprietary/commercial software where you do not " "want to share any source code with third parties or otherwise cannot " "comply with the terms of the GNU LGPL version 2.1 or GNU GPL version " -- cgit v0.12 From ee735a39a333ddff4d5d0734062093ba553850f2 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 3 Jun 2009 11:23:33 +0200 Subject: use of QMutexPool to reduce the number of Q_GLOBAL_STATIC in the animation framework --- src/corelib/animation/qpropertyanimation.cpp | 47 +++++++++++++++------------- src/corelib/animation/qvariantanimation.cpp | 29 ++++++++--------- 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 43b5283..357a6ac 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -91,19 +91,17 @@ #include "qpropertyanimation.h" #include "qanimationgroup.h" -#include - #include "qpropertyanimation_p.h" #include #include +#include QT_BEGIN_NAMESPACE typedef QPair QPropertyAnimationPair; typedef QHash QPropertyAnimationHash; Q_GLOBAL_STATIC(QPropertyAnimationHash, _q_runningAnimations) -Q_GLOBAL_STATIC_WITH_ARGS(QMutex, guardHashLock, (QMutex::Recursive) ) void QPropertyAnimationPrivate::updateMetaProperty() { @@ -284,27 +282,32 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState, } QVariantAnimation::updateState(oldState, newState); - QMutexLocker locker(guardHashLock()); - QPropertyAnimationHash * hash = _q_runningAnimations(); - QPropertyAnimationPair key(d->target, d->propertyName); - if (newState == Running) { - d->updateMetaProperty(); - QPropertyAnimation *oldAnim = hash->value(key, 0); - if (oldAnim) { - // try to stop the top level group - QAbstractAnimation *current = oldAnim; - while (current->group() && current->state() != Stopped) - current = current->group(); - current->stop(); - } - hash->insert(key, this); - // update the default start value - if (oldState == Stopped) { - d->setDefaultStartValue(d->target->property(d->propertyName.constData())); + QPropertyAnimation *animToStop = 0; + { + QPropertyAnimationHash * hash = _q_runningAnimations(); + QMutexLocker locker(QMutexPool::globalInstanceGet(hash)); + QPropertyAnimationPair key(d->target, d->propertyName); + if (newState == Running) { + d->updateMetaProperty(); + animToStop = hash->value(key, 0); + hash->insert(key, this); + // update the default start value + if (oldState == Stopped) { + d->setDefaultStartValue(d->target->property(d->propertyName.constData())); + } + } else if (hash->value(key) == this) { + hash->remove(key); } - } else if (hash->value(key) == this) { - hash->remove(key); + } + + //we need to do that after the mutex was unlocked + if (animToStop) { + // try to stop the top level group + QAbstractAnimation *current = animToStop; + while (current->group() && current->state() != Stopped) + current = current->group(); + current->stop(); } } diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index e973ec5..a3fa93a 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -44,11 +44,10 @@ #include "qvariantanimation.h" #include "qvariantanimation_p.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include QT_BEGIN_NAMESPACE @@ -365,8 +364,8 @@ void QVariantAnimation::setEasingCurve(const QEasingCurve &easing) d->recalculateCurrentInterval(); } -Q_GLOBAL_STATIC(QVector, registeredInterpolators) -Q_GLOBAL_STATIC(QReadWriteLock, registeredInterpolatorsLock) +typedef QVector QInterpolatorVector; +Q_GLOBAL_STATIC(QInterpolatorVector, registeredInterpolators) /*! \fn void qRegisterAnimationInterpolator(QVariant (*func)(const T &from, const T &to, qreal progress)) @@ -398,10 +397,11 @@ Q_GLOBAL_STATIC(QReadWriteLock, registeredInterpolatorsLock) void QVariantAnimation::registerInterpolator(QVariantAnimation::Interpolator func, int interpolationType) { // will override any existing interpolators - QWriteLocker locker(registeredInterpolatorsLock()); - if (int(interpolationType) >= registeredInterpolators()->count()) - registeredInterpolators()->resize(int(interpolationType) + 1); - registeredInterpolators()->replace(interpolationType, func); + QInterpolatorVector *interpolators = registeredInterpolators(); + QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators)); + if (int(interpolationType) >= interpolators->count()) + interpolators->resize(int(interpolationType) + 1); + interpolators->replace(interpolationType, func); } @@ -412,10 +412,11 @@ template static inline QVariantAnimation::Interpolator castToInterpo QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator(int interpolationType) { - QReadLocker locker(registeredInterpolatorsLock()); + QInterpolatorVector *interpolators = registeredInterpolators(); + QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators)); QVariantAnimation::Interpolator ret = 0; - if (interpolationType < registeredInterpolators()->count()) { - ret = registeredInterpolators()->at(interpolationType); + if (interpolationType < interpolators->count()) { + ret = interpolators->at(interpolationType); if (ret) return ret; } -- cgit v0.12 From a3c0fd23dcac2389e20cf0731166c18374d481ec Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 3 Jun 2009 11:38:45 +0200 Subject: fix typos Copy&paste error; the classes are in Gui, not Core. --- src/gui/statemachine/qkeyeventtransition.h | 2 +- src/gui/statemachine/qmouseeventtransition.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/statemachine/qkeyeventtransition.h b/src/gui/statemachine/qkeyeventtransition.h index 3c8295f..d9c7760 100644 --- a/src/gui/statemachine/qkeyeventtransition.h +++ b/src/gui/statemachine/qkeyeventtransition.h @@ -48,7 +48,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(Core) +QT_MODULE(Gui) class QKeyEventTransitionPrivate; class Q_GUI_EXPORT QKeyEventTransition : public QEventTransition diff --git a/src/gui/statemachine/qmouseeventtransition.h b/src/gui/statemachine/qmouseeventtransition.h index 3f5f3ac..9c7af5b 100644 --- a/src/gui/statemachine/qmouseeventtransition.h +++ b/src/gui/statemachine/qmouseeventtransition.h @@ -48,7 +48,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(Core) +QT_MODULE(Gui) class QMouseEventTransitionPrivate; class QPainterPath; -- cgit v0.12 From f9aa7cbaea69168a4e7b9411cfdceb9e27cf75a9 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 3 Jun 2009 11:44:28 +0200 Subject: fix qdoc warning No need to link to the class in its own doc page. --- src/corelib/statemachine/qstatemachine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 84619d7..be816a6 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -92,7 +92,7 @@ QT_BEGIN_NAMESPACE QAbstractState) and transitions (descendants of QAbstractTransition) between those states; these states and transitions define a state graph. Once a state graph has been - built, the state machine can execute it. \l{QStateMachine}'s + built, the state machine can execute it. QStateMachine's execution algorithm is based on the \l{State Chart XML: State Machine Notation for Control Abstraction}{State Chart XML (SCXML)} algorithm. The framework's \l{The State Machine -- cgit v0.12 From e72285b0108f7649366a106f1c16ea73611dbcd4 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 3 Jun 2009 13:17:37 +0200 Subject: don't require use of SIGNAL macro in calls to addTransition() Just as with the QSignalTransition::signal property, this makes it possible to use the function from language bindings (e.g. QtScript). --- src/corelib/statemachine/qstate.cpp | 5 +++-- tests/auto/qstatemachine/tst_qstatemachine.cpp | 28 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index 5463059..ebb0b47 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -329,9 +329,10 @@ QSignalTransition *QState::addTransition(QObject *sender, const char *signal, qWarning("QState::addTransition: cannot add transition to null state"); return 0; } - if (*signal && sender->metaObject()->indexOfSignal(signal+1) == -1) { + int offset = (*signal == '0'+QSIGNAL_CODE) ? 1 : 0; + if (sender->metaObject()->indexOfSignal(signal+offset) == -1) { qWarning("QState::addTransition: no such signal %s::%s", - sender->metaObject()->className(), signal+1); + sender->metaObject()->className(), signal+offset); return 0; } QSignalTransition *trans = new QSignalTransition(sender, signal, QList() << target); diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 768a683..66e50ba 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -1768,6 +1768,34 @@ void tst_QStateMachine::signalTransitions() QState *s0 = new QState(machine.rootState()); QFinalState *s1 = new QFinalState(machine.rootState()); SignalEmitter emitter; + QSignalTransition *trans = s0->addTransition(&emitter, "signalWithNoArg()", s1); + QVERIFY(trans != 0); + QCOMPARE(trans->sourceState(), s0); + QCOMPARE(trans->targetState(), (QAbstractState*)s1); + QCOMPARE(trans->senderObject(), (QObject*)&emitter); + QCOMPARE(trans->signal(), QByteArray("signalWithNoArg()")); + + QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + machine.setInitialState(s0); + machine.start(); + QCoreApplication::processEvents(); + + emitter.emitSignalWithNoArg(); + + QTRY_COMPARE(finishedSpy.count(), 1); + + trans->setSignal("signalWithIntArg(int)"); + QCOMPARE(trans->signal(), QByteArray("signalWithIntArg(int)")); + machine.start(); + QCoreApplication::processEvents(); + emitter.emitSignalWithIntArg(123); + QTRY_COMPARE(finishedSpy.count(), 2); + } + { + QStateMachine machine; + QState *s0 = new QState(machine.rootState()); + QFinalState *s1 = new QFinalState(machine.rootState()); + SignalEmitter emitter; TestSignalTransition *trans = new TestSignalTransition(&emitter, SIGNAL(signalWithIntArg(int)), s1); s0->addTransition(trans); -- cgit v0.12 From a6cb0edd2f8f69ea7b878d65756d47ed166f4224 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 3 Jun 2009 13:21:43 +0200 Subject: fix signal signature bug in debug output The signal code (first character of const char *signal) is stripped internally, so the debug output code should not skip any characters. --- src/corelib/statemachine/qstatemachine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index be816a6..d5f6b76 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1329,7 +1329,7 @@ void QStateMachinePrivate::registerSignalTransition(QSignalTransition *transitio if (!ok) { #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": FAILED to add signal transition from" << transition->sourceState() - << ": ( sender =" << sender << ", signal =" << (signal.mid(1)) + << ": ( sender =" << sender << ", signal =" << signal << ", targets =" << transition->targetStates() << ')'; #endif return; @@ -1339,7 +1339,7 @@ void QStateMachinePrivate::registerSignalTransition(QSignalTransition *transitio QSignalTransitionPrivate::get(transition)->signalIndex = signalIndex; #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": added signal transition from" << transition->sourceState() - << ": ( sender =" << sender << ", signal =" << (signal.mid(1)) + << ": ( sender =" << sender << ", signal =" << signal << ", targets =" << transition->targetStates() << ')'; #endif } -- cgit v0.12 From 94376c5ab5caf1889caef29db66f981e34e7c4d5 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 3 Jun 2009 10:53:11 +0200 Subject: qdoc: Fixed constructor position in summary lists. The constructors had been displayed in the left column of the table in the summary list, because there was no type. It was caused by a strange test of the match index for 0, which was true for constructors and destructors, anything without a type. I removed that test, since I couldn't figure out what it was for. We might see problems elsewhere in the docs because of this, so beware. I didn't see any, but that test must have been there for some reason. --- tools/qdoc3/htmlgenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 4e4261f..db70862 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -2317,7 +2317,7 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, static const QString linkTag("link"); for (int i = 0, n = src.size(); i < n;) { if (src.at(i) == charLangle && src.at(i + 1).unicode() == '@') { - if (nameAlignment && (i != 0)) + if (nameAlignment) // && (i != 0)) Why was this here? html += " 

+ + + + + + + + @@ -621,12 +629,14 @@ in the \l{Qt for Windows CE Requirements} document. + + -- cgit v0.12 From c45a3295dd926d37ee9d16b109ad6678c850c965 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 4 Jun 2009 09:10:21 +1000 Subject: Fixes failure when attempting to run all tests. auto.pro added `qtransition' to SUBDIRS but there is no such directory. --- tests/auto/auto.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 27e3c74..a65c172 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -349,7 +349,6 @@ SUBDIRS += _networkselftest \ qtranslator \ qtransform \ qtransformedscreen \ - qtransition \ qtreeview \ qtreewidget \ qtreewidgetitemiterator \ -- cgit v0.12 From 7010a53cbd6bc6d9cc6d63e2170a7300ce2750d8 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 4 Jun 2009 10:13:54 +1000 Subject: Improvements to shader API in response to API review Task-number: QT-80 Reviewed-by: Ian Walters --- demos/boxes/scene.cpp | 2 +- examples/opengl/hellogl_es2/glwidget.cpp | 8 +- .../gl2paintengineex/qglengineshadermanager.cpp | 3 +- src/opengl/qglshaderprogram.cpp | 158 ++++++++++----------- src/opengl/qglshaderprogram.h | 16 +-- 5 files changed, 88 insertions(+), 99 deletions(-) diff --git a/demos/boxes/scene.cpp b/demos/boxes/scene.cpp index e2aa16b..2376782 100644 --- a/demos/boxes/scene.cpp +++ b/demos/boxes/scene.cpp @@ -559,7 +559,7 @@ void Scene::initGL() << ":/res/boxes/cubemap_negy.jpg" << ":/res/boxes/cubemap_posz.jpg" << ":/res/boxes/cubemap_negz.jpg"; m_environment = new GLTextureCube(list, qMin(1024, m_maxTextureSize)); m_environmentShader = new QGLShader(QGLShader::FragmentShader); - m_environmentShader->setSourceCode(environmentShaderText); + m_environmentShader->compile(environmentShaderText); m_environmentProgram = new QGLShaderProgram; m_environmentProgram->addShader(m_vertexShader); m_environmentProgram->addShader(m_environmentShader); diff --git a/examples/opengl/hellogl_es2/glwidget.cpp b/examples/opengl/hellogl_es2/glwidget.cpp index ee50670..cb4a48d 100644 --- a/examples/opengl/hellogl_es2/glwidget.cpp +++ b/examples/opengl/hellogl_es2/glwidget.cpp @@ -190,7 +190,7 @@ void GLWidget::initializeGL () " color = clamp(color, 0.0, 1.0);\n" " gl_Position = matrix * vertex;\n" "}\n"; - vshader1->setSourceCode(vsrc1); + vshader1->compile(vsrc1); QGLShader *fshader1 = new QGLShader(QGLShader::FragmentShader, this); const char *fsrc1 = @@ -199,7 +199,7 @@ void GLWidget::initializeGL () "{\n" " gl_FragColor = color;\n" "}\n"; - fshader1->setSourceCode(fsrc1); + fshader1->compile(fsrc1); program1.addShader(vshader1); program1.addShader(fshader1); @@ -224,7 +224,7 @@ void GLWidget::initializeGL () " gl_Position = matrix * vertex;\n" " texc = texCoord;\n" "}\n"; - vshader2->setSourceCode(vsrc2); + vshader2->compile(vsrc2); QGLShader *fshader2 = new QGLShader(QGLShader::FragmentShader); const char *fsrc2 = @@ -237,7 +237,7 @@ void GLWidget::initializeGL () " color = color * 0.2 + color * 0.8 * angle;\n" " gl_FragColor = vec4(clamp(color, 0.0, 1.0), 1.0);\n" "}\n"; - fshader2->setSourceCode(fsrc2); + fshader2->compile(fsrc2); program2.addShader(vshader2); program2.addShader(fshader2); diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 3159cbb..ea57fdf 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -481,8 +481,7 @@ void QGLEngineShaderManager::compileNamedShader(QGLEngineShaderManager::ShaderNa return; QGLShader *newShader = new QGLShader(type, ctx, this); - newShader->setSourceCode(qglEngineShaderSourceCode[name]); - // newShader->compile(); ### does not exist? + newShader->compile(qglEngineShaderSourceCode[name]); #if defined(QT_DEBUG) // Name the shader for easier debugging diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index d74b930..67fd9d0 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE \code QGLShader shader(QGLShader::VertexShader); - shader.setSourceCode(code); + shader.compile(code); QGLShaderProgram program(context); program.addShader(shader); @@ -265,7 +265,7 @@ public: QByteArray partialSource; bool create(); - bool compile(); + bool compile(QGLShader *q); }; #define ctx context @@ -293,7 +293,7 @@ bool QGLShaderPrivate::create() } } -bool QGLShaderPrivate::compile() +bool QGLShaderPrivate::compile(QGLShader *q) { // Partial shaders are compiled during QGLShaderProgram::link(). if (isPartial && hasPartialSource) { @@ -313,7 +313,11 @@ bool QGLShaderPrivate::compile() GLint len; glGetShaderInfoLog(shader, value, &len, logbuf); log = QString::fromLatin1(logbuf); - qWarning() << "QGLShader::compile:" << log; + QString name = q->objectName(); + if (name.isEmpty()) + qWarning() << "QGLShader::compile:" << log; + else + qWarning() << "QGLShader::compile[" << name << "]:" << log; delete [] logbuf; } return compiled; @@ -325,14 +329,14 @@ bool QGLShaderPrivate::compile() /*! Constructs a new QGLShader object of the specified \a type and attaches it to \a parent. If shader programs are not supported, - then isValid() will return false. + QGLShaderProgram::hasShaderPrograms() will return false. - This constructor is normally followed by a call to setSourceCode() - or setSourceCodeFile(). + This constructor is normally followed by a call to compile() + or compileFile(). The shader will be associated with the current QGLContext. - \sa setSourceCode(), setSourceCodeFile(), isValid() + \sa compile(), compileFile() */ QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent) : QObject(parent) @@ -346,11 +350,11 @@ QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent) and attaches it to \a parent. If the filename ends in \c{.fsh}, it is assumed to be a fragment shader, otherwise it is assumed to be a vertex shader (normally the extension is \c{.vsh} for vertex shaders). - If the shader could not be loaded, then isValid() will return false. + If the shader could not be loaded, then isCompiled() will return false. The shader will be associated with the current QGLContext. - \sa isValid() + \sa isCompiled() */ QGLShader::QGLShader(const QString& fileName, QObject *parent) : QObject(parent) @@ -359,7 +363,7 @@ QGLShader::QGLShader(const QString& fileName, QObject *parent) d = new QGLShaderPrivate(QGLShader::FragmentShader, QGLContext::currentContext()); else d = new QGLShaderPrivate(QGLShader::VertexShader, QGLContext::currentContext()); - if (d->create() && !setSourceCodeFile(fileName)) { + if (d->create() && !compileFile(fileName)) { if (d->shader) glDeleteShader(d->shader); d->shader = 0; @@ -369,18 +373,18 @@ QGLShader::QGLShader(const QString& fileName, QObject *parent) /*! Constructs a new QGLShader object of the specified \a type from the source code in \a fileName and attaches it to \a parent. - If the shader could not be loaded, then isValid() will return false. + If the shader could not be loaded, then isCompiled() will return false. The shader will be associated with the current QGLContext. - \sa isValid() + \sa isCompiled() */ QGLShader::QGLShader (const QString& fileName, QGLShader::ShaderType type, QObject *parent) : QObject(parent) { d = new QGLShaderPrivate(type, QGLContext::currentContext()); - if (d->create() && !setSourceCodeFile(fileName)) { + if (d->create() && !compileFile(fileName)) { if (d->shader) glDeleteShader(d->shader); d->shader = 0; @@ -390,14 +394,14 @@ QGLShader::QGLShader /*! Constructs a new QGLShader object of the specified \a type and attaches it to \a parent. If shader programs are not supported, - then isValid() will return false. + then QGLShaderProgram::hasShaderPrograms() will return false. - This constructor is normally followed by a call to setSourceCode() - or setSourceCodeFile(). + This constructor is normally followed by a call to compile() + or compileFile(). The shader will be associated with \a context. - \sa setSourceCode(), setSourceCodeFile(), isValid() + \sa compile(), compileFile() */ QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent) : QObject(parent) @@ -411,11 +415,11 @@ QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObj and attaches it to \a parent. If the filename ends in \c{.fsh}, it is assumed to be a fragment shader, otherwise it is assumed to be a vertex shader (normally the extension is \c{.vsh} for vertex shaders). - If the shader could not be loaded, then isValid() will return false. + If the shader could not be loaded, then isCompiled() will return false. The shader will be associated with \a context. - \sa isValid() + \sa isCompiled() */ QGLShader::QGLShader(const QString& fileName, const QGLContext *context, QObject *parent) : QObject(parent) @@ -424,7 +428,7 @@ QGLShader::QGLShader(const QString& fileName, const QGLContext *context, QObject d = new QGLShaderPrivate(QGLShader::FragmentShader, context); else d = new QGLShaderPrivate(QGLShader::VertexShader, context); - if (d->create() && !setSourceCodeFile(fileName)) { + if (d->create() && !compileFile(fileName)) { if (d->shader) glDeleteShader(d->shader); d->shader = 0; @@ -434,18 +438,18 @@ QGLShader::QGLShader(const QString& fileName, const QGLContext *context, QObject /*! Constructs a new QGLShader object of the specified \a type from the source code in \a fileName and attaches it to \a parent. - If the shader could not be loaded, then isValid() will return false. + If the shader could not be loaded, then isCompiled() will return false. The shader will be associated with \a context. - \sa isValid() + \sa isCompiled() */ QGLShader::QGLShader (const QString& fileName, QGLShader::ShaderType type, const QGLContext *context, QObject *parent) : QObject(parent) { d = new QGLShaderPrivate(type, context); - if (d->create() && !setSourceCodeFile(fileName)) { + if (d->create() && !compileFile(fileName)) { if (d->shader) glDeleteShader(d->shader); d->shader = 0; @@ -465,24 +469,6 @@ QGLShader::~QGLShader() } /*! - Returns true if this shader is valid. Shaders become invalid - when they are destroyed and no longer attached to a QGLShaderProgram. -*/ -bool QGLShader::isValid() const -{ - if (d->isPartial && d->hasPartialSource) - return true; - if (!d->shader) - return false; -#if defined(QT_OPENGL_ES_2) - return glIsShader(d->shader); -#else - // glIsShader() may not exist on some systems. - return (!glIsShader || glIsShader(d->shader)); -#endif -} - -/*! Returns the type of this shader. */ QGLShader::ShaderType QGLShader::shaderType() const @@ -509,13 +495,15 @@ static const char qualifierDefines[] = then this function will always return true, even if the source code is invalid. Partial shaders are compiled when QGLShaderProgram::link() is called. + + \sa compileFile() */ -bool QGLShader::setSourceCode(const char *source) +bool QGLShader::compile(const char *source) { if (d->isPartial) { d->partialSource = QByteArray(source); d->hasPartialSource = true; - return d->compile(); + return d->compile(this); } else if (d->shader) { QVarLengthArray src; #ifdef QGL_DEFINE_QUALIFIERS @@ -523,7 +511,7 @@ bool QGLShader::setSourceCode(const char *source) #endif src.append(source); glShaderSource(d->shader, src.size(), src.data(), 0); - return d->compile(); + return d->compile(this); } else { return false; } @@ -539,10 +527,12 @@ bool QGLShader::setSourceCode(const char *source) then this function will always return true, even if the source code is invalid. Partial shaders are compiled when QGLShaderProgram::link() is called. + + \sa compileFile() */ -bool QGLShader::setSourceCode(const QByteArray& source) +bool QGLShader::compile(const QByteArray& source) { - return setSourceCode(source.constData()); + return compile(source.constData()); } /*! @@ -555,10 +545,12 @@ bool QGLShader::setSourceCode(const QByteArray& source) then this function will always return true, even if the source code is invalid. Partial shaders are compiled when QGLShaderProgram::link() is called. + + \sa compileFile() */ -bool QGLShader::setSourceCode(const QString& source) +bool QGLShader::compile(const QString& source) { - return setSourceCode(source.toLatin1().constData()); + return compile(source.toLatin1().constData()); } /*! @@ -570,8 +562,10 @@ bool QGLShader::setSourceCode(const QString& source) then this function will always return true, even if the source code is invalid. Partial shaders are compiled when QGLShaderProgram::link() is called. + + \sa compile() */ -bool QGLShader::setSourceCodeFile(const QString& fileName) +bool QGLShader::compileFile(const QString& fileName) { QFile file(fileName); if (!file.open(QFile::ReadOnly)) { @@ -580,7 +574,7 @@ bool QGLShader::setSourceCodeFile(const QString& fileName) } QByteArray contents = file.readAll(); - return setSourceCode(contents.constData()); + return compile(contents.constData()); } /*! @@ -592,9 +586,11 @@ bool QGLShader::setSourceCodeFile(const QString& fileName) This function cannot be used with PartialVertexShader or PartialFragmentShader. + If this function succeeds, then the shader will be considered compiled. + \sa shaderBinaryFormats() */ -bool QGLShader::setBinaryCode(GLenum format, const void *binary, int length) +bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length) { #if !defined(QT_OPENGL_ES_2) if (!glShaderBinary) @@ -604,7 +600,8 @@ bool QGLShader::setBinaryCode(GLenum format, const void *binary, int length) return false; glGetError(); // Clear error state. glShaderBinary(1, &(d->shader), format, binary, length); - return (glGetError() == GL_NO_ERROR); + d->compiled = (glGetError() == GL_NO_ERROR); + return d->compiled; } /*! @@ -620,9 +617,11 @@ bool QGLShader::setBinaryCode(GLenum format, const void *binary, int length) This function cannot be used with PartialVertexShader or PartialFragmentShader. + If this function succeeds, then the shader will be considered compiled. + \sa shaderBinaryFormats() */ -bool QGLShader::setBinaryCode +bool QGLShader::setShaderBinary (QGLShader& otherShader, GLenum format, const void *binary, int length) { #if !defined(QT_OPENGL_ES_2) @@ -638,14 +637,16 @@ bool QGLShader::setBinaryCode shaders[0] = d->shader; shaders[1] = otherShader.d->shader; glShaderBinary(2, shaders, format, binary, length); - return (glGetError() == GL_NO_ERROR); + d->compiled = (glGetError() == GL_NO_ERROR); + otherShader.d->compiled = d->compiled; + return d->compiled; } /*! Returns a list of all binary formats that are supported by - setBinaryCode() on this system. + setShaderBinary() on this system. - \sa setBinaryCode() + \sa setShaderBinary() */ QList QGLShader::shaderBinaryFormats() { @@ -665,7 +666,7 @@ QList QGLShader::shaderBinaryFormats() /*! Returns the source code for this shader. - \sa setSourceCode() + \sa compile() */ QByteArray QGLShader::sourceCode() const { @@ -688,7 +689,7 @@ QByteArray QGLShader::sourceCode() const /*! Returns true if this shader has been compiled; false otherwise. - \sa setSourceCode() + \sa compile() */ bool QGLShader::isCompiled() const { @@ -698,7 +699,7 @@ bool QGLShader::isCompiled() const /*! Returns the errors and warnings that occurred during the last compile. - \sa setSourceCode() + \sa compile() */ QString QGLShader::log() const { @@ -762,7 +763,7 @@ public: The shader program will be associated with the current QGLContext. - \sa isValid(), addShader() + \sa addShader() */ QGLShaderProgram::QGLShaderProgram(QObject *parent) : QObject(parent) @@ -776,7 +777,7 @@ QGLShaderProgram::QGLShaderProgram(QObject *parent) The shader program will be associated with \a context. - \sa isValid(), addShader() + \sa addShader() */ QGLShaderProgram::QGLShaderProgram(const QGLContext *context, QObject *parent) : QObject(parent) @@ -815,21 +816,6 @@ bool QGLShaderProgram::init() } /*! - Returns true if this shader program object is valid, false otherwise. -*/ -bool QGLShaderProgram::isValid() const -{ - if (!d->program) - return false; -#if defined(QT_OPENGL_ES_2) - return glIsProgram(d->program); -#else - // glIsProgram() may not exist on some systems. - return (!glIsProgram || glIsProgram(d->program)); -#endif -} - -/*! Adds a compiled \a shader to this shader program. Returns true if the shader could be added, or false otherwise. @@ -881,7 +867,7 @@ bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const char *source) if (!init()) return false; QGLShader *shader = new QGLShader(type, this); - if (!shader->setSourceCode(source)) { + if (!shader->compile(source)) { d->log = shader->log(); delete shader; return false; @@ -1058,7 +1044,11 @@ bool QGLShaderProgram::setProgramBinary(int format, const QByteArray& binary) GLint len; glGetProgramInfoLog(d->program, value, &len, logbuf); d->log = QString::fromLatin1(logbuf); - qWarning() << "QGLShaderProgram::setProgramBinary:" << d->log; + QString name = objectName(); + if (name.isEmpty()) + qWarning() << "QGLShader::setProgramBinary:" << d->log; + else + qWarning() << "QGLShader::setProgramBinary[" << name << "]:" << d->log; delete [] logbuf; } return d->linked; @@ -1130,7 +1120,7 @@ bool QGLShaderProgram::link() d->vertexShader = new QGLShader(QGLShader::VertexShader, this); } - if (!d->vertexShader->setSourceCode(vertexSource)) { + if (!d->vertexShader->compile(vertexSource)) { d->log = d->vertexShader->log(); return false; } @@ -1147,7 +1137,7 @@ bool QGLShaderProgram::link() d->fragmentShader = new QGLShader(QGLShader::FragmentShader, this); } - if (!d->fragmentShader->setSourceCode(fragmentSource)) { + if (!d->fragmentShader->compile(fragmentSource)) { d->log = d->fragmentShader->log(); return false; } @@ -1166,7 +1156,11 @@ bool QGLShaderProgram::link() GLint len; glGetProgramInfoLog(d->program, value, &len, logbuf); d->log = QString::fromLatin1(logbuf); - qWarning() << "QGLShaderProgram::link:" << d->log; + QString name = objectName(); + if (name.isEmpty()) + qWarning() << "QGLShader::link:" << d->log; + else + qWarning() << "QGLShader::link[" << name << "]:" << d->log; delete [] logbuf; } return d->linked; diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h index b69d28e..ab30c32 100644 --- a/src/opengl/qglshaderprogram.h +++ b/src/opengl/qglshaderprogram.h @@ -79,17 +79,15 @@ public: QGLShader(const QString& fileName, QGLShader::ShaderType type, const QGLContext *context, QObject *parent = 0); virtual ~QGLShader(); - bool isValid() const; - QGLShader::ShaderType shaderType() const; - bool setSourceCode(const char *source); - bool setSourceCode(const QByteArray& source); - bool setSourceCode(const QString& source); - bool setSourceCodeFile(const QString& fileName); + bool compile(const char *source); + bool compile(const QByteArray& source); + bool compile(const QString& source); + bool compileFile(const QString& fileName); - bool setBinaryCode(GLenum format, const void *binary, int length); - bool setBinaryCode(QGLShader& otherShader, GLenum format, const void *binary, int length); + bool setShaderBinary(GLenum format, const void *binary, int length); + bool setShaderBinary(QGLShader& otherShader, GLenum format, const void *binary, int length); static QList shaderBinaryFormats(); @@ -118,8 +116,6 @@ public: explicit QGLShaderProgram(const QGLContext *context, QObject *parent = 0); virtual ~QGLShaderProgram(); - bool isValid() const; - bool addShader(QGLShader *shader); void removeShader(QGLShader *shader); QList shaders() const; -- cgit v0.12 From b1b09172aee658e085423ddf6abfea291a072c74 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 4 Jun 2009 11:41:44 +1000 Subject: Code cleanup - use constructor initializers in shader classes. Task-number: QT-80 Reviewed-by: Ian Walters --- src/opengl/qglshaderprogram.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 67fd9d0..37732dd 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -245,14 +245,14 @@ class QGLShaderPrivate { public: QGLShaderPrivate(QGLShader::ShaderType type, const QGLContext *ctx) + : context(ctx) + , shader(0) + , shaderType(type) + , compiled(false) + , isPartial(type == QGLShader::PartialVertexShader || + type == QGLShader::PartialFragmentShader) + , hasPartialSource(false) { - context = ctx; - shader = 0; - shaderType = type; - compiled = false; - isPartial = (type == QGLShader::PartialVertexShader || - type == QGLShader::PartialFragmentShader); - hasPartialSource = false; } const QGLContext *context; @@ -727,14 +727,14 @@ class QGLShaderProgramPrivate { public: QGLShaderProgramPrivate(const QGLContext *ctx) + : context(ctx) + , program(0) + , linked(false) + , inited(false) + , hasPartialShaders(false) + , vertexShader(0) + , fragmentShader(0) { - context = ctx; - program = 0; - linked = false; - inited = false; - hasPartialShaders = false; - vertexShader = 0; - fragmentShader = 0; } ~QGLShaderProgramPrivate() { -- cgit v0.12 From 85d6409aa650272e1956a7e8f2064d453a6203ad Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 4 Jun 2009 08:57:43 +0200 Subject: qdoc: Reset the memItemLeft width property to 200. --- tools/qdoc3/htmlgenerator.cpp | 2 +- tools/qdoc3/test/classic.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 422e956..a2a7184 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -2323,7 +2323,7 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, for (int i = 0, n = src.size(); i < n;) { if (src.at(i) == charLangle && src.at(i + 1).unicode() == '@') { if (nameAlignment) // && (i != 0)) Why was this here? - html += " 
"; i += 2; if (parseArg(src, linkTag, &i, n, &arg, &par1)) { -- cgit v0.12 From 8ccecbfef54fbb59eedb3e717c1e2838b96e4fe3 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 3 Jun 2009 14:06:49 +0200 Subject: qdoc: Fixed some spacing problems. --- tools/qdoc3/htmlgenerator.cpp | 31 +++++++++++++++++++------------ tools/qdoc3/test/classic.css | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index db70862..422e956 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1118,29 +1118,34 @@ void HtmlGenerator::generateClassLikeNode(const InnerNode *inner, names << (*m)->name(); if ((*m)->type() == Node::Function) { const FunctionNode *func = reinterpret_cast(*m); - if (func->metaness() == FunctionNode::Ctor || func->metaness() == FunctionNode::Dtor - || func->overloadNumber() != 1) + if (func->metaness() == FunctionNode::Ctor || + func->metaness() == FunctionNode::Dtor || + func->overloadNumber() != 1) names.clear(); - } else if ((*m)->type() == Node::Property) { + } + else if ((*m)->type() == Node::Property) { const PropertyNode *prop = reinterpret_cast(*m); - if (!prop->getters().isEmpty() && !names.contains(prop->getters().first()->name())) + if (!prop->getters().isEmpty() && + !names.contains(prop->getters().first()->name())) names << prop->getters().first()->name(); if (!prop->setters().isEmpty()) names << prop->setters().first()->name(); if (!prop->resetters().isEmpty()) names << prop->resetters().first()->name(); - } else if ((*m)->type() == Node::Enum) { - const EnumNode *enume = reinterpret_cast(*m); + } + else if ((*m)->type() == Node::Enum) { + const EnumNode *enume = reinterpret_cast(*m); if (enume->flagsType()) names << enume->flagsType()->name(); foreach (const QString &enumName, - enume->doc().enumItemNames().toSet() - - enume->doc().omitEnumItemNames().toSet()) - names << plainCode(marker->markedUpEnumValue(enumName, enume)); + enume->doc().enumItemNames().toSet() - + enume->doc().omitEnumItemNames().toSet()) + names << plainCode(marker->markedUpEnumValue(enumName, + enume)); } foreach (const QString &name, names) - classSection.keywords += qMakePair(name, linkForNode(*m, 0)); + classSection.keywords += qMakePair(name,linkForNode(*m,0)); } ++m; } @@ -3099,7 +3104,8 @@ void HtmlGenerator::generateDetailedMember(const Node *node, << " type is a typedef for " << "QFlags<" << protect(enume->name()) - << ">. It stores an OR combination of " << protect(enume->name()) + << ">. It stores an OR combination of " + << protect(enume->name()) << " values.

\n"; } } @@ -3113,7 +3119,8 @@ void HtmlGenerator::findAllClasses(const InnerNode *node) if ((*c)->access() != Node::Private && (*c)->url().isEmpty()) { if ((*c)->type() == Node::Class && !(*c)->doc().isEmpty()) { QString className = (*c)->name(); - if ((*c)->parent() && (*c)->parent()->type() == Node::Namespace && + if ((*c)->parent() && + (*c)->parent()->type() == Node::Namespace && !(*c)->parent()->name().isEmpty()) className = (*c)->parent()->name()+"::"+className; diff --git a/tools/qdoc3/test/classic.css b/tools/qdoc3/test/classic.css index fa0167b..5239856 100644 --- a/tools/qdoc3/test/classic.css +++ b/tools/qdoc3/test/classic.css @@ -66,7 +66,7 @@ body } table td.memItemLeft { - width: 200px; + width: 100px; padding: 1px 0px 0px 8px; margin: 4px; border-top-width: 1px; -- cgit v0.12 From ab873250fc93df5f5290fedbd5b17872cb1294c6 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 3 Jun 2009 13:31:44 +0200 Subject: Fix webkit import from the trunk. Updated the file list, the SVG filters have been removed. Reviewed-by: Trust me --- util/webkit/mkdist-webkit | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index 62264ec..730e8eb 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -109,6 +109,7 @@ excluded_directories="$excluded_directories WebCore/platform/image-decoders/png" excluded_directories="$excluded_directories WebCore/platform/image-decoders/ico" excluded_directories="$excluded_directories WebCore/platform/image-decoders/jpeg" excluded_directories="$excluded_directories WebCore/platform/image-decoders/xbm" +excluded_directories="$excluded_directories WebCore/platform/image-decoders/skia" excluded_directories="$excluded_directories WebCore/plugins/gtk" excluded_directories="$excluded_directories WebCore/plugins/chromium" @@ -120,11 +121,6 @@ excluded_directories="$excluded_directories WebKit/mac" excluded_directories="$excluded_directories WebKit/wx" excluded_directories="$excluded_directories WebKit/cf" -excluded_directories="$excluded_directories WebCore/svg/graphics/cg" -excluded_directories="$excluded_directories WebCore/svg/graphics/cairo" -excluded_directories="$excluded_directories WebCore/svg/graphics/filters/cg" -excluded_directories="$excluded_directories WebCore/svg/graphics/mac" - excluded_directories="$excluded_directories WebKit/English.lproj WebKit/WebKit.xcodeproj" excluded_directories="$excluded_directories WebCore/English.lproj" -- cgit v0.12 From c890793e7a58e1d75d1f88f5e2c88162eddcca44 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 28 May 2009 17:22:54 +0200 Subject: force activation of minimized windows on Windows mobile When pressing the <- key on a Windows mobile device, the window gets a minimized event (no other soft keys behave like that). Restoring the window via the app menu isn't possible, because the window get a WM_ACTIVATE but its internal state is still minimized. It makes sense to unminimize activated apps on Windows mobile. Task-number: 254673 Reviewed-by: thartman --- src/gui/kernel/qapplication_win.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 670058b..7e97784 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -2063,9 +2063,13 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam // WM_ACTIVATEAPP handles the "true" false case, as this is only when the application // loses focus. Doing it here would result in the widget getting focus to not know // where it got it from; it would simply get a 0 value as the old focus widget. +#ifndef Q_WS_WINCE_WM if (!(widget->windowState() & Qt::WindowMinimized)) { // Ignore the activate message send by WindowsXP to a minimized window -#ifdef Q_WS_WINCE_WM +#else + { + if (widget->windowState() & Qt::WindowMinimized) + widget->dataPtr()->window_state &= ~Qt::WindowMinimized; if (widget->windowState() & Qt::WindowFullScreen) qt_wince_hide_taskbar(widget->winId()); #endif -- cgit v0.12 From 5e0aef012a90598b88b547b1b73785f59ef135c1 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 3 Jun 2009 15:44:20 +0200 Subject: fix silly typo Yeesh. The function worked for the common case of the argument being a plain script object (obviously, otherwise this would have been discovered sooner), but it would never pick the less expensive path when replacing the QObject pointer of an existing proxy. And if you passed in a QVariant proxy (now who would ever do something like that...?), it would assert. --- src/script/qscriptengine.cpp | 2 +- tests/auto/qscriptengine/tst_qscriptengine.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/script/qscriptengine.cpp b/src/script/qscriptengine.cpp index d8908ed..97021fc 100644 --- a/src/script/qscriptengine.cpp +++ b/src/script/qscriptengine.cpp @@ -587,7 +587,7 @@ QScriptValue QScriptEngine::newQObject(const QScriptValue &scriptObject, QScriptValuePrivate *p = QScriptValuePrivate::get(scriptObject); if (!p || !p->value.isObject()) return newQObject(qtObject, ownership, options); - if (p->value.isVariant()) { + if (p->value.isQObject()) { QScript::ExtQObject::Instance *data; data = d->qobjectConstructor->get(p->value); Q_ASSERT(data != 0); diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 5339fb4..fe60cd0 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -636,9 +636,21 @@ void tst_QScriptEngine::newQObject() QScriptValue val = ret.property("objectName"); QVERIFY(val.isString()); } + // "promote" variant object to QObject + { + QScriptValue obj = eng.newVariant(123); + QVERIFY(obj.isVariant()); + QScriptValue originalProto = obj.prototype(); + QScriptValue ret = eng.newQObject(obj, this); + QVERIFY(ret.isQObject()); + QVERIFY(ret.strictlyEquals(obj)); + QVERIFY(obj.isQObject()); + QCOMPARE(ret.toQObject(), (QObject *)this); + QVERIFY(ret.prototype().strictlyEquals(originalProto)); + } // replace QObject* of existing object { - QScriptValue object = eng.newQObject(this); + QScriptValue object = eng.newVariant(123); QScriptValue originalProto = object.prototype(); QObject otherQObject; QScriptValue ret = eng.newQObject(object, &otherQObject); -- cgit v0.12 From bd14a25c84fc2c12bfaa594b338aa2d0c0d4d940 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 3 Jun 2009 11:53:27 +0200 Subject: Removed a warning (qreal should be used, and not float) --- src/gui/widgets/qmenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 50100af..bcfe0fb 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -398,7 +398,7 @@ QRect QMenuPrivate::actionRect(QAction *act) const return ret; } -static const float MenuFadeTimeInSec = 0.150; +static const qreal MenuFadeTimeInSec = 0.150; void QMenuPrivate::hideUpToMenuBar() { -- cgit v0.12 From a04e1c4733feb643eb8da7b4a94c175153691b38 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 3 Jun 2009 15:59:18 +0200 Subject: Fixed the QMenu to open submenus even if the pointing device is moving but the current highlighted item doesn't change Task-number: 254238 Reviewed-by: ogoffart --- src/gui/widgets/qmenu.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index bcfe0fb..711f1f4 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -547,10 +547,12 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason { Q_Q(QMenu); tearoffHighlighted = 0; - if (action == currentAction && !(action && action->menu() && action->menu() != activeMenu)) { - if(QMenu *menu = qobject_cast(causedPopup.widget)) { - if(causedPopup.action && menu->d_func()->activeMenu == q) - menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false); + if (action == currentAction) { + if (!action || !action->menu() || action->menu() == activeMenu) { + if(QMenu *menu = qobject_cast(causedPopup.widget)) { + if(causedPopup.action && menu->d_func()->activeMenu == q) + menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false); + } } return; } @@ -565,7 +567,7 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason QAction *previousAction = currentAction; #endif #ifdef QT3_SUPPORT - emitHighlighted = (action && action != currentAction); + emitHighlighted = action; #endif currentAction = action; if (action) { -- cgit v0.12 From 9d42ae152f660cfacad104060741b17b96269cd2 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Wed, 3 Jun 2009 16:07:26 +0200 Subject: Change crazy casts from QString to NSSting to qt_mac_QStringToNSString. These function exist for making code not look so crazy, so let's actually use that in code where it didn't exist before. --- src/gui/widgets/qmenu_mac.mm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 87c886c..786633c 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -623,7 +623,7 @@ static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader() static NSMenuItem *createNSMenuItem(const QString &title) { NSMenuItem *item = [[NSMenuItem alloc] - initWithTitle:reinterpret_cast(static_cast(QCFString(title))) + initWithTitle:qt_mac_QStringToNSString(title) action:@selector(qtDispatcherToQAction:) keyEquivalent:@""]; [item setTarget:getMenuLoader()]; return item; @@ -1381,18 +1381,18 @@ QMenuPrivate::QMacMenuPrivate::syncAction(QMacMenuAction *action) // Cocoa Font and title if (action->action->font().resolve()) { const QFont &actionFont = action->action->font(); - NSFont *customMenuFont = [NSFont fontWithName:reinterpret_cast(static_cast(QCFString(actionFont.family()))) + NSFont *customMenuFont = [NSFont fontWithName:qt_mac_QStringToNSString(actionFont.family()) size:actionFont.pointSize()]; NSArray *keys = [NSArray arrayWithObjects:NSFontAttributeName, nil]; NSArray *objects = [NSArray arrayWithObjects:customMenuFont, nil]; NSDictionary *attributes = [NSDictionary dictionaryWithObjects:objects forKeys:keys]; - NSAttributedString *str = [[[NSAttributedString alloc] initWithString:reinterpret_cast(static_cast(QCFString(finalString))) + NSAttributedString *str = [[[NSAttributedString alloc] initWithString:qt_mac_QStringToNSString(finalString) attributes:attributes] autorelease]; [item setAttributedTitle: str]; } else { - [item setTitle: reinterpret_cast(static_cast(QCFString(finalString)))]; + [item setTitle: qt_mac_QStringToNSString(finalString)]; } - [item setTitle:reinterpret_cast(static_cast(QCFString(qt_mac_removeMnemonics(text))))]; + [item setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(text))]; // Cocoa Enabled [item setEnabled: action->action->isEnabled()]; @@ -1694,7 +1694,7 @@ QMenuBarPrivate::QMacMenuBarPrivate::syncAction(QMacMenuAction *action) ChangeMenuAttributes(submenu, kMenuAttrHidden, 0); #else [item setSubmenu: submenu]; - [submenu setTitle:reinterpret_cast(static_cast(QCFString(qt_mac_removeMnemonics(action->action->text()))))]; + [submenu setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(action->action->text()))]; syncNSMenuItemVisiblity(item, visible); #endif if (release_submenu) { //no pointers to it @@ -1786,7 +1786,7 @@ OSMenuRef QMenuBarPrivate::macMenu() SetMenuItemHierarchicalMenu(mac_menubar->menu, index, mac_menubar->apple_menu); SetMenuItemProperty(mac_menubar->apple_menu, 0, kMenuCreatorQt, kMenuPropertyQWidget, sizeof(q), &q); #else - [mac_menubar->apple_menu setTitle:reinterpret_cast(static_cast(QCFString(QString(QChar(0x14)))))]; + [mac_menubar->apple_menu setTitle:qt_mac_QStringToNSString(QString(QChar(0x14)))]; NSMenuItem *apple_menuItem = [[NSMenuItem alloc] init]; [apple_menuItem setSubmenu:mac_menubar->menu]; [mac_menubar->apple_menu addItem:apple_menuItem]; -- cgit v0.12 From 43de28ba040bea21e2aee5b13be1351127503336 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 3 Jun 2009 17:27:03 +0200 Subject: Doc fix: moved the cldr version outside of the double-to-string license header --- src/corelib/tools/qlocale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 4c2f59a..8c740bd 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -1601,6 +1601,8 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l) This constructor converts the locale name to a language/country pair; it does not use the system locale database. + QLocale's data is based on Common Locale Data Repository v1.6.1. + The double-to-string and string-to-double conversion functions are covered by the following licenses: @@ -1621,8 +1623,6 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l) This product includes software developed by the University of California, Berkeley and its contributors. - QLocale's data is based on Common Locale Data Repository v1.6.1. - \sa QString::arg(), QString::toInt(), QString::toDouble() */ -- cgit v0.12 From ba2e1015f9efe584a1ea671ff1db00f743f4ee3c Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 3 Jun 2009 18:36:32 +0200 Subject: Doc: Added information about the Fontconfig and FreeType dependencies. Task-number: 250349 Reviewed-by: Trust Me --- doc/src/installation.qdoc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/src/installation.qdoc b/doc/src/installation.qdoc index 6a689f9..bc310c9 100644 --- a/doc/src/installation.qdoc +++ b/doc/src/installation.qdoc @@ -612,6 +612,14 @@ in the \l{Qt for Windows CE Requirements} document.
Xinerama libXinerama Multi-head support -xinerama or auto-detected1.1.0
Fontconfig libfontconfig Font customization and configuration-fontconfig or auto-detected2.1
FreeType libfreetype Font engine2.1.3
Xi libXi X11 Input Extensions -xinput or auto-detected1.3.0 Xext libXext X Extensions6.4.3
X11 libX11 X11 Client-Side Library6.2.1
SM libSM X Session Management -sm or auto-detected6.0.4
ICE libICE Inter-Client Exchange -sm or auto-detected6.3.5
glib libglib-2.0 Common event loop handling -glib or auto-detected2.8.3"; + html += ""; i += 2; if (parseArg(src, linkTag, &i, n, &arg, &par1)) { QString link = linkForNode( diff --git a/tools/qdoc3/test/classic.css b/tools/qdoc3/test/classic.css index 5239856..fa0167b 100644 --- a/tools/qdoc3/test/classic.css +++ b/tools/qdoc3/test/classic.css @@ -66,7 +66,7 @@ body } table td.memItemLeft { - width: 100px; + width: 200px; padding: 1px 0px 0px 8px; margin: 4px; border-top-width: 1px; -- cgit v0.12 From d227b12495bb88a78b98436eac38f240429dfa98 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 2 Jun 2009 11:25:21 +0200 Subject: Add some comparisons with std::string to the QStringBuilder benchmarks. --- tests/benchmarks/qstringbuilder/main.cpp | 86 +++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 18 deletions(-) diff --git a/tests/benchmarks/qstringbuilder/main.cpp b/tests/benchmarks/qstringbuilder/main.cpp index d4e2fa0..8b769a6 100644 --- a/tests/benchmarks/qstringbuilder/main.cpp +++ b/tests/benchmarks/qstringbuilder/main.cpp @@ -1,6 +1,6 @@ // Select one of the scenarios below -#define SCENARIO 3 +#define SCENARIO 1 #if SCENARIO == 1 // this is the "no harm done" version. Only operator% is active, @@ -17,7 +17,7 @@ // this is the "full" version. Operator+ is replaced by a QStringBuilder // based version // with NO_CAST * defined -#define P % +#define P + #define QT_USE_FAST_OPERATOR_PLUS #define QT_USE_FAST_CONCATENATION #define QT_NO_CAST_FROM_ASCII @@ -38,7 +38,7 @@ // this is the "full" version. Operator+ is replaced by a QStringBuilder // based version // with NO_CAST * _not_ defined -#define P % +#define P + #define QT_USE_FAST_OPERATOR_PLUS #define QT_USE_FAST_CONCATENATION #undef QT_NO_CAST_FROM_ASCII @@ -53,6 +53,8 @@ #include +#include + #define COMPARE(a, b) QCOMPARE(a, b) //#define COMPARE(a, b) @@ -70,6 +72,7 @@ public: l1string(LITERAL), ba(LITERAL), string(l1string), + stdstring(LITERAL), stringref(&string, 2, 10), achar('c'), r2(QLatin1String(LITERAL LITERAL)), @@ -115,8 +118,9 @@ public: private slots: void separator_0() { - qDebug() << "\nIn each block the QStringBuilder based result appear first, " - "QStringBased second.\n"; + qDebug() << "\nIn each block the QStringBuilder based result appear first " + "(with a 'b_' prefix), QStringBased second ('q_' prefix), std::string " + "last ('s_' prefix)\n"; } void separator_1() { SEP("literal + literal (builder first)"); } @@ -131,7 +135,7 @@ private slots: COMPARE(r, r2); } #endif - void s_2_l1string() { + void q_2_l1string() { QBENCHMARK { r = l1string + l1string; } COMPARE(r, r2); } @@ -143,10 +147,14 @@ private slots: QBENCHMARK { r = string P string; } COMPARE(r, r2); } - void s_2_string() { + void q_2_string() { QBENCHMARK { r = string + string; } COMPARE(r, r2); } + void s_2_string() { + QBENCHMARK { stdr = stdstring + stdstring; } + COMPARE(stdr, stdstring + stdstring); + } void separator_2c() { SEP("2 string refs"); } @@ -155,7 +163,7 @@ private slots: QBENCHMARK { r = stringref % stringref; } COMPARE(r, QString(stringref.toString() + stringref.toString())); } - void s_2_stringref() { + void q_2_stringref() { QBENCHMARK { r = stringref.toString() + stringref.toString(); } COMPARE(r, QString(stringref % stringref)); } @@ -167,10 +175,30 @@ private slots: QBENCHMARK { r = string P string P string; } COMPARE(r, r3); } - void s_3_string() { + void q_3_string() { QBENCHMARK { r = string + string + string; } COMPARE(r, r3); } + void s_3_string() { + QBENCHMARK { stdr = stdstring + stdstring + stdstring; } + COMPARE(stdr, stdstring + stdstring + stdstring); + } + + void separator_2e() { SEP("4 strings"); } + + void b_4_string() { + QBENCHMARK { r = string P string P string P string; } + COMPARE(r, r4); + } + void q_4_string() { + QBENCHMARK { r = string + string + string + string; } + COMPARE(r, r4); + } + void s_4_string() { + QBENCHMARK { stdr = stdstring + stdstring + stdstring + stdstring; } + COMPARE(stdr, stdstring + stdstring + stdstring + stdstring); + } + void separator_2a() { SEP("string + literal (builder first)"); } @@ -193,14 +221,18 @@ private slots: QBENCHMARK { r = string P l1string; } COMPARE(r, r2); } - void s_string_l1literal() { + void q_string_l1literal() { QBENCHMARK { r = string + l1string; } COMPARE(r, r2); } - void s_string_l1string() { + void q_string_l1string() { QBENCHMARK { r = string + l1string; } COMPARE(r, r2); } + void s_LITERAL_string() { + QBENCHMARK { stdr = LITERAL + stdstring; } + COMPARE(stdr, stdstring + stdstring); + } void separator_3() { SEP("3 literals"); } @@ -209,10 +241,14 @@ private slots: QBENCHMARK { r = l1literal P l1literal P l1literal; } COMPARE(r, r3); } - void s_3_l1string() { + void q_3_l1string() { QBENCHMARK { r = l1string + l1string + l1string; } COMPARE(r, r3); } + void s_3_l1string() { + QBENCHMARK { stdr = stdstring + LITERAL + LITERAL; } + COMPARE(stdr, stdstring + stdstring + stdstring); + } void separator_4() { SEP("4 literals"); } @@ -221,7 +257,7 @@ private slots: QBENCHMARK { r = l1literal P l1literal P l1literal P l1literal; } COMPARE(r, r4); } - void s_4_l1string() { + void q_4_l1string() { QBENCHMARK { r = l1string + l1string + l1string + l1string; } COMPARE(r, r4); } @@ -234,7 +270,7 @@ private slots: COMPARE(r, r5); } - void s_5_l1string() { + void q_5_l1string() { QBENCHMARK { r = l1string + l1string + l1string + l1string + l1string; } COMPARE(r, r5); } @@ -247,11 +283,16 @@ private slots: COMPARE(r, QString(string P achar P achar P achar P achar)); } - void s_string_4_char() { + void q_string_4_char() { QBENCHMARK { r = string + achar + achar + achar + achar; } COMPARE(r, QString(string P achar P achar P achar P achar)); } + void s_string_4_char() { + QBENCHMARK { stdr = stdstring + 'c' + 'c' + 'c' + 'c'; } + COMPARE(stdr, stdstring + 'c' + 'c' + 'c' + 'c'); + } + void separator_7() { SEP("char + string + char"); } @@ -260,11 +301,17 @@ private slots: COMPARE(r, QString(achar P string P achar)); } - void s_char_string_char() { + void q_char_string_char() { QBENCHMARK { r = achar + string + achar; } COMPARE(r, QString(achar P string P achar)); } + void s_char_string_char() { + QBENCHMARK { stdr = 'c' + stdstring + 'c'; } + COMPARE(stdr, 'c' + stdstring + 'c'); + } + + void separator_8() { SEP("string.arg"); } void b_string_arg() { @@ -273,13 +320,13 @@ private slots: COMPARE(r, r3); } - void s_string_arg() { + void q_string_arg() { const QString pattern = l1string + QLatin1String("%1") + l1string; QBENCHMARK { r = pattern.arg(string); } COMPARE(r, r3); } - void s_bytearray_arg() { + void q_bytearray_arg() { QByteArray result; QBENCHMARK { result = ba + ba + ba; } } @@ -331,11 +378,14 @@ private: const QLatin1String l1string; const QByteArray ba; const QString string; + const std::string stdstring; const QStringRef stringref; const QLatin1Char achar; const QString r2, r3, r4, r5; + // short cuts for results QString r; + std::string stdr; }; -- cgit v0.12 From d167d50234a977eae5c03cca20a78850437d5b87 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 4 Jun 2009 10:22:10 +0200 Subject: compile fix with namespaces --- demos/boxes/glbuffers.h | 2 ++ demos/boxes/scene.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/demos/boxes/glbuffers.h b/demos/boxes/glbuffers.h index 392924e..9e05fad 100644 --- a/demos/boxes/glbuffers.h +++ b/demos/boxes/glbuffers.h @@ -58,7 +58,9 @@ if (m_failed || !(assertion)) { returnStatement; \ } +QT_BEGIN_NAMESPACE class QMatrix4x4; +QT_END_NAMESPACE class GLTexture { diff --git a/demos/boxes/scene.h b/demos/boxes/scene.h index 48ecaba..9f8d2af 100644 --- a/demos/boxes/scene.h +++ b/demos/boxes/scene.h @@ -56,7 +56,10 @@ #define PI 3.14159265358979 +QT_BEGIN_NAMESPACE class QMatrix4x4; +QT_END_NAMESPACE + class ParameterEdit : public QWidget { public: -- cgit v0.12 From 397c3bb494e220af5ef1cf6e47cfdfc84b61540b Mon Sep 17 00:00:00 2001 From: jasplin Date: Thu, 4 Jun 2009 10:39:29 +0200 Subject: Fixed build error with Sun CC 5.5. Reviewed-by: TrustMe --- src/corelib/tools/qvector.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 7bdcba0..38254cd 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -94,7 +94,14 @@ template class QVector { typedef QVectorTypedData Data; - union { QVectorData *d; Data *p; }; + union { + QVectorData *d; +#if defined(Q_CC_SUN) && (__SUNPRO_CC <= 0x550) + QVectorTypedData *p; +#else + Data *p; +#endif + }; public: inline QVector() : d(&QVectorData::shared_null) { d->ref.ref(); } -- cgit v0.12