From 7142fbe52cfca2887cb8ee083d4d91c35ef249f8 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 8 Mar 2010 03:28:01 +0100 Subject: QTableView: fix navigating with keyboard with spans not scrolling We cannot use isIndexHidden in ScrollTo because that would return true if the index is in a span. Task-number: QTBUG-8777 Reviewed-by: Markus Goetz --- src/gui/itemviews/qtableview.cpp | 2 +- tests/auto/qtableview/tst_qtableview.cpp | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index cf1b542..c824a8a 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -2554,7 +2554,7 @@ void QTableView::scrollTo(const QModelIndex &index, ScrollHint hint) // check if we really need to do anything if (!d->isIndexValid(index) || (d->model->parent(index) != d->root) - || isIndexHidden(index)) + || isRowHidden(index.row()) || isColumnHidden(index.column())) return; QSpanCollection::Span span; diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 35fba52..54e32218 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -201,6 +201,7 @@ private slots: void taskQTBUG_5237_wheelEventOnHeader(); void taskQTBUG_8585_crashForNoGoodReason(); void taskQTBUG_7774_RtoLVisualRegionForSelection(); + void taskQTBUG_8777_scrollToSpans(); void mouseWheel_data(); void mouseWheel(); @@ -3994,7 +3995,6 @@ void tst_QTableView::taskQTBUG_8585_crashForNoGoodReason() } } - class TableView7774 : public QTableView { public: @@ -4020,5 +4020,19 @@ void tst_QTableView::taskQTBUG_7774_RtoLVisualRegionForSelection() QCOMPARE(region.rects().at(0), view.visualRect(range.topLeft()) | view.visualRect(range.bottomRight())); } +void tst_QTableView::taskQTBUG_8777_scrollToSpans() +{ + QTableWidget table(75,5); + for (int i=0; i<50; i++) + table.setSpan(2+i, 0, 1, 5); + table.setCurrentCell(0,2); + table.show(); + + for (int i = 0; i < 45; ++i) + QTest::keyClick(&table, Qt::Key_Down); + + QVERIFY(table.verticalScrollBar()->value() > 10); +} + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" -- cgit v0.12 From ff9f3fc24c57254b150c1afba2e5883da8ed2b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 8 Mar 2010 11:52:20 +0100 Subject: Prevent QRegion from crashing on large coordinates. Since we don't clip the x-coordinates that end up in the edge table of the QRegion rasterizer, we need to extend the coordinate range. Task-number: QTBUG-7699 Reviewed-by: Gunnar Sletta --- src/gui/painting/qregion.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 614d2c0..bea2b6e 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -3134,8 +3134,8 @@ SOFTWARE. ************************************************************************/ /* $XFree86: xc/lib/X11/PolyReg.c,v 1.1.1.2.8.2 1998/10/04 15:22:49 hohndel Exp $ */ -#define LARGE_COORDINATE 1000000 -#define SMALL_COORDINATE -LARGE_COORDINATE +#define LARGE_COORDINATE INT_MAX +#define SMALL_COORDINATE INT_MIN /* * InsertEdgeInET -- cgit v0.12 From 41437f55f911b32d17ed153a14eb1b1673f17c86 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 8 Mar 2010 14:07:32 +0100 Subject: Fix undocked widgets not being restored correctly as part of the layout Task-number: QTBUG-7921 Reviewed-by: ogoffart --- src/gui/widgets/qdockarealayout.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 0c39f42..794863b 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -1990,16 +1990,19 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList #ifdef QT_NO_TABBAR const int tabBarShape = 0; #endif - QDockAreaLayoutInfo *info = new QDockAreaLayoutInfo(sep, dockPos, o, - tabBarShape, mainWindow); - QDockAreaLayoutItem item(info); + QDockAreaLayoutItem item(new QDockAreaLayoutInfo(sep, dockPos, o, + tabBarShape, mainWindow)); stream >> item.pos >> item.size >> dummy >> dummy; - if (!info->restoreState(stream, widgets, testing)) + //we need to make sure the element is in the list so the dock widget can eventually be docked correctly + if (!testing) + item_list.append(item); + + //here we need to make sure we change the item in the item_list + QDockAreaLayoutItem &lastItem = testing ? item : item_list.last(); + + if (!lastItem.subinfo->restoreState(stream, widgets, testing)) return false; - if (!testing) { - item_list.append(item); - } } else { return false; } -- cgit v0.12 From b1c6482eaa8edd01077ac79ba390389bf6f8c71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 8 Mar 2010 15:14:18 +0100 Subject: Updated the QCursor docs regarding XOR'ed cursors. XOR'ed cursors under X11 or Mac OS X have never been supported by Qt, and the doc updates done some time ago where not correct. Task-number: related to QTBUG-1838 Reviewed-by: Gunnar --- src/gui/kernel/qcursor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index 0f0470c..6b21d56 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -342,7 +342,8 @@ QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY) \o B=1 and M=1 gives black. \o B=0 and M=1 gives white. \o B=0 and M=0 gives transparent. - \o B=1 and M=0 gives an XOR'd result. + \o B=1 and M=0 gives an XOR'd result under Windows, undefined + results on all other platforms. \endlist Use the global Qt color Qt::color0 to draw 0-pixels and Qt::color1 to -- cgit v0.12 From 298e91f240a3bc9db9450bf9b1ce7606531853ff Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 8 Mar 2010 16:21:56 +0100 Subject: QHostInfo: Compile fix Reviewed-by: TrustMe --- src/network/kernel/qhostinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 9092ad6..7150fb7 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -639,7 +639,7 @@ void qt_qhostinfo_clear_cache() } } -void Q_NETWORK_EXPORT qt_qhostinfo_enable_cache(bool e) +void Q_AUTOTEST_EXPORT qt_qhostinfo_enable_cache(bool e) { QHostInfoLookupManager* manager = theHostInfoLookupManager(); if (manager) { -- cgit v0.12 From 623e87d880812c848a8b438a2410b2f95cbeca1f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 8 Mar 2010 17:18:45 +0100 Subject: remove unneeded function pointer in qmenu_wince.cpp Reviewed-by: mauricek --- src/gui/widgets/qmenu_wince.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp index 28b6b8b..edef466 100644 --- a/src/gui/widgets/qmenu_wince.cpp +++ b/src/gui/widgets/qmenu_wince.cpp @@ -101,7 +101,6 @@ struct qt_SHMENUBARINFO COLORREF clrBk; }; -typedef int (WINAPI *superfunc)(int, int); typedef BOOL (WINAPI *AygCreateMenuBar)(qt_SHMENUBARINFO*); typedef HRESULT (WINAPI *AygEnableSoftKey)(HWND,UINT,BOOL,BOOL); -- cgit v0.12 From db20aff5bf81a6a935fbb89bf103351dc7a9215d Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 24 Feb 2010 16:45:30 +0100 Subject: QXmlSchema internals: include/import/redefine schemas only once According to the Schema standard, loading a schema needs only be done once for each schema location. Currently, there was a problem with indirect includes (and imports/redefines): a In this scenario, schema a would only remember to have loaded / \ b, but not d, which resulted in an error when c was loading d b c again and the types in d were redefined. | | d d Reviewed-by: Tobias Koenig Task-number: QTBUG-8394 --- src/xmlpatterns/schema/qxsdschemaparser.cpp | 48 ++++++++++++++++++++-- src/xmlpatterns/schema/qxsdschemaparser_p.h | 22 +++++++++- .../files/indirect-datatype.xsd | 6 +++ .../files/indirect-import-a.xsd | 5 +++ .../files/indirect-import-b.xsd | 4 ++ .../files/indirect-import-c.xsd | 4 ++ .../files/indirect-include-a.xsd | 5 +++ .../files/indirect-include-b.xsd | 4 ++ .../files/indirect-include-c.xsd | 4 ++ .../files/indirect-redefine-a.xsd | 5 +++ .../files/indirect-redefine-b.xsd | 4 ++ .../files/indirect-redefine-c.xsd | 4 ++ .../tst_xmlpatternsvalidator.cpp | 15 +++++++ 13 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 tests/auto/xmlpatternsvalidator/files/indirect-datatype.xsd create mode 100644 tests/auto/xmlpatternsvalidator/files/indirect-import-a.xsd create mode 100644 tests/auto/xmlpatternsvalidator/files/indirect-import-b.xsd create mode 100644 tests/auto/xmlpatternsvalidator/files/indirect-import-c.xsd create mode 100644 tests/auto/xmlpatternsvalidator/files/indirect-include-a.xsd create mode 100644 tests/auto/xmlpatternsvalidator/files/indirect-include-b.xsd create mode 100644 tests/auto/xmlpatternsvalidator/files/indirect-include-c.xsd create mode 100644 tests/auto/xmlpatternsvalidator/files/indirect-redefine-a.xsd create mode 100644 tests/auto/xmlpatternsvalidator/files/indirect-redefine-b.xsd create mode 100644 tests/auto/xmlpatternsvalidator/files/indirect-redefine-c.xsd diff --git a/src/xmlpatterns/schema/qxsdschemaparser.cpp b/src/xmlpatterns/schema/qxsdschemaparser.cpp index 6ed28af..fd0b95c 100644 --- a/src/xmlpatterns/schema/qxsdschemaparser.cpp +++ b/src/xmlpatterns/schema/qxsdschemaparser.cpp @@ -264,16 +264,31 @@ XsdSchemaParser::XsdSchemaParser(const XsdSchemaContext::Ptr &context, const Xsd setupBuiltinTypeNames(); } +void XsdSchemaParser::addIncludedSchemas(const NamespaceSet &schemas) +{ + m_includedSchemas += schemas; +} + void XsdSchemaParser::setIncludedSchemas(const NamespaceSet &schemas) { m_includedSchemas = schemas; } +void XsdSchemaParser::addImportedSchemas(const NamespaceSet &schemas) +{ + m_importedSchemas += schemas; +} + void XsdSchemaParser::setImportedSchemas(const NamespaceSet &schemas) { m_importedSchemas = schemas; } +void XsdSchemaParser::addRedefinedSchemas(const NamespaceSet &schemas) +{ + m_redefinedSchemas += schemas; +} + void XsdSchemaParser::setRedefinedSchemas(const NamespaceSet &schemas) { m_redefinedSchemas = schemas; @@ -297,6 +312,7 @@ void XsdSchemaParser::setDocumentURI(const QUrl &uri) // prevent to get included/imported/redefined twice m_includedSchemas.insert(uri); m_importedSchemas.insert(uri); + m_redefinedSchemas.insert(uri); } QUrl XsdSchemaParser::documentURI() const @@ -594,8 +610,14 @@ void XsdSchemaParser::parseInclude() parser.setIncludedSchemas(m_includedSchemas); parser.setImportedSchemas(m_importedSchemas); parser.setRedefinedSchemas(m_redefinedSchemas); - if (!parser.parse(XsdSchemaParser::IncludeParser)) + if (!parser.parse(XsdSchemaParser::IncludeParser)) { return; + } else { + // add indirectly loaded schemas to the list of already loaded ones + addIncludedSchemas(parser.m_includedSchemas); + addImportedSchemas(parser.m_importedSchemas); + addRedefinedSchemas(parser.m_redefinedSchemas); + } } } @@ -684,8 +706,14 @@ void XsdSchemaParser::parseImport() parser.setIncludedSchemas(m_includedSchemas); parser.setImportedSchemas(m_importedSchemas); parser.setRedefinedSchemas(m_redefinedSchemas); - if (!parser.parse(XsdSchemaParser::ImportParser)) + if (!parser.parse(XsdSchemaParser::ImportParser)) { return; + } else { + // add indirectly loaded schemas to the list of already loaded ones + addIncludedSchemas(parser.m_includedSchemas); + addImportedSchemas(parser.m_importedSchemas); + addRedefinedSchemas(parser.m_redefinedSchemas); + } } } } else { @@ -702,8 +730,14 @@ void XsdSchemaParser::parseImport() parser.setIncludedSchemas(m_includedSchemas); parser.setImportedSchemas(m_importedSchemas); parser.setRedefinedSchemas(m_redefinedSchemas); - if (!parser.parse(XsdSchemaParser::ImportParser)) + if (!parser.parse(XsdSchemaParser::ImportParser)) { return; + } else { + // add indirectly loaded schemas to the list of already loaded ones + addIncludedSchemas(parser.m_includedSchemas); + addImportedSchemas(parser.m_importedSchemas); + addRedefinedSchemas(parser.m_redefinedSchemas); + } } } } else { @@ -839,8 +873,14 @@ void XsdSchemaParser::parseRedefine() parser.setIncludedSchemas(m_includedSchemas); parser.setImportedSchemas(m_importedSchemas); parser.setRedefinedSchemas(m_redefinedSchemas); - if (!parser.parse(XsdSchemaParser::RedefineParser)) + if (!parser.parse(XsdSchemaParser::RedefineParser)) { return; + } else { + // add indirectly loaded schemas to the list of already loaded ones + addIncludedSchemas(parser.m_includedSchemas); + addImportedSchemas(parser.m_importedSchemas); + addRedefinedSchemas(parser.m_redefinedSchemas); + } delete reply; } diff --git a/src/xmlpatterns/schema/qxsdschemaparser_p.h b/src/xmlpatterns/schema/qxsdschemaparser_p.h index ad5e9ce..80d44a5 100644 --- a/src/xmlpatterns/schema/qxsdschemaparser_p.h +++ b/src/xmlpatterns/schema/qxsdschemaparser_p.h @@ -120,20 +120,38 @@ namespace QPatternist typedef QSet NamespaceSet; /** + * Adds @p schemas to the list of already included schemas, so the parser + * can detect multiple includes of the same schema. + */ + void addIncludedSchemas(const NamespaceSet &schemas); + + /** * Sets which @p schemas have been included already, so the parser - * can detect circular includes. + * can detect multiple includes of the same schema. */ void setIncludedSchemas(const NamespaceSet &schemas); /** + * Adds @p schemas to the list of already imported schemas, so the parser + * can detect multiple imports of the same schema. + */ + void addImportedSchemas(const NamespaceSet &schemas); + + /** * Sets which @p schemas have been imported already, so the parser * can detect circular imports. */ void setImportedSchemas(const NamespaceSet &schemas); /** + * Adds @p schemas to the list of already redefined schemas, so the parser + * can detect multiple redefines of the same schema. + */ + void addRedefinedSchemas(const NamespaceSet &schemas); + + /** * Sets which @p schemas have been redefined already, so the parser - * can detect circular redefines. + * can detect multiple redefines of the same schema. */ void setRedefinedSchemas(const NamespaceSet &schemas); diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-datatype.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-datatype.xsd new file mode 100644 index 0000000..60f3e4f --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-datatype.xsd @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-import-a.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-import-a.xsd new file mode 100644 index 0000000..e6da433 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-import-a.xsd @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-import-b.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-import-b.xsd new file mode 100644 index 0000000..88be377 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-import-b.xsd @@ -0,0 +1,4 @@ + + + + diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-import-c.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-import-c.xsd new file mode 100644 index 0000000..88be377 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-import-c.xsd @@ -0,0 +1,4 @@ + + + + diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-include-a.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-include-a.xsd new file mode 100644 index 0000000..02ca5c5 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-include-a.xsd @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-include-b.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-include-b.xsd new file mode 100644 index 0000000..efaba74 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-include-b.xsd @@ -0,0 +1,4 @@ + + + + diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-include-c.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-include-c.xsd new file mode 100644 index 0000000..efaba74 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-include-c.xsd @@ -0,0 +1,4 @@ + + + + diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-redefine-a.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-redefine-a.xsd new file mode 100644 index 0000000..4f0804c --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-redefine-a.xsd @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-redefine-b.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-redefine-b.xsd new file mode 100644 index 0000000..019a127 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-redefine-b.xsd @@ -0,0 +1,4 @@ + + + + diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-redefine-c.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-redefine-c.xsd new file mode 100644 index 0000000..019a127 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-redefine-c.xsd @@ -0,0 +1,4 @@ + + + + diff --git a/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp b/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp index 6d4ed69..7aab47f 100644 --- a/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp +++ b/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp @@ -196,6 +196,21 @@ void tst_XmlPatternsValidator::xsdSupport_data() const << 1 << (QStringList() << QLatin1String("files/instance.xml")) << QString(); + + QTest::newRow("A schema with an indirectly included type") + << 0 + << (QStringList() << QLatin1String("files/indirect-include-a.xsd")) + << QString(); + + QTest::newRow("A schema with an indirectly imported type") + << 0 + << (QStringList() << QLatin1String("files/indirect-import-a.xsd")) + << QString(); + + QTest::newRow("A schema with an indirectly redefined type") + << 0 + << (QStringList() << QLatin1String("files/indirect-redefine-a.xsd")) + << QString(); } QTEST_MAIN(tst_XmlPatternsValidator) -- cgit v0.12 From acd2e59f6b414d8bf2236c8059a8cf7f4b54998a Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 8 Mar 2010 13:13:27 -0800 Subject: Don't use DirectFB for non-existing pixmaps DirectFB will print a warning for this since the file doesn't exist but we might as well not try when we know the file doesn't exist. Reviewed-by: Donald Carr --- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index b5ac67d..4219f6f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -174,6 +174,8 @@ bool QDirectFBPixmapData::hasAlphaChannel(const QImage &img) bool QDirectFBPixmapData::fromFile(const QString &filename, const char *format, Qt::ImageConversionFlags flags) { + if (!QFile::exists(filename)) + return false; if (flags == Qt::AutoColor) { if (filename.startsWith(QLatin1Char(':'))) { // resource QFile file(filename); -- cgit v0.12 From 82a1fc3d05e794d7717006f2152ffa388d8538b8 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 9 Mar 2010 16:08:44 +1000 Subject: Fix obsolete URL's. Task-number: QT-3051 Reviewed-by: Trust Me --- dist/changes-4.5.4 | 10 +++++----- translations/qtconfig_ru.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/changes-4.5.4 b/dist/changes-4.5.4 index abaf4f0..ac91edb 100644 --- a/dist/changes-4.5.4 +++ b/dist/changes-4.5.4 @@ -9,12 +9,12 @@ The Qt version 4.5 series is binary compatible with the 4.4.x series. Applications compiled for 4.4 will continue to run with 4.5. Some of the changes listed in this file include issue tracking numbers -corresponding to tasks in the Task Tracker: +corresponding to tasks in the Qt Bug Tracker, the (now obsolete) Task +Tracker, or the Merge Request queue of the public source repository. - http://www.qtsoftware.com/developer/task-tracker - -Each of these identifiers can be entered in the task tracker to obtain more -information about a particular change. +Qt Bug Tracker: http://bugreports.qt.nokia.com +Task Tracker: http://qt.nokia.com/developer/task-tracker +Merge Request: http://qt.gitorious.org **************************************************************************** * General * diff --git a/translations/qtconfig_ru.ts b/translations/qtconfig_ru.ts index 334a801..7be0f04 100644 --- a/translations/qtconfig_ru.ts +++ b/translations/qtconfig_ru.ts @@ -892,7 +892,7 @@ p, li { white-space: pre-wrap; } <a href="http://www.kde.org">http://www.kde.org</a> </p> <p> -<a href="http://qtsoftware.com">http://qtsoftware.com</a> +<a href="http://qt.nokia.com">http://qt.nokia.com</a> </p> <p> <a href="http://www.kde.org">http://www.kde.org</a> -- cgit v0.12 From 065fdc4caba6305f45b53edf27391af29f496a1c Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 9 Mar 2010 09:37:35 +0200 Subject: Implemented QLibraryInfo::TranslationsPath for Symbian. Discussed with QtProd and they agreed "/resource/qt/translations" would be suitable path to return from QLibraryInfo::TranslationsPath. Task-number: QTBUG-8291 Reviewed-by: Miikka Heikkinen --- tools/configure/configureapp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 153df10..2555015 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1484,6 +1484,7 @@ void Configure::applySpecSpecifics() dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_INSTALL_PREFIX" ]; dictionary[ "QT_INSTALL_PREFIX" ] = ""; dictionary[ "QT_INSTALL_PLUGINS" ] = "\\resource\\qt\\plugins"; + dictionary[ "QT_INSTALL_TRANSLATIONS" ] = "\\resource\\qt\\translations"; dictionary[ "ARM_FPU_TYPE" ] = "softvfp"; dictionary[ "SQL_SQLITE" ] = "yes"; dictionary[ "SQL_SQLITE_LIB" ] = "system"; -- cgit v0.12 From d27163a7a8e81f05dae2e975e4d59d8226dbd9ec Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 9 Mar 2010 12:07:09 +0100 Subject: QGraphicsSceneEvent: add Q_DISABLE_COPY Add Q_DISABLE_COPY to QGraphicsSceneEvent and all the sublasses The code would anyway not compile before as the QScopedPointer does not know QGraphicsSceneEventPrivate in use code. But now we have better error reporting. Reviewed-by: Thierry Task-number: QTBUG-8803 (related) --- src/gui/graphicsview/qgraphicssceneevent.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/graphicsview/qgraphicssceneevent.h b/src/gui/graphicsview/qgraphicssceneevent.h index 033a996..c8a0028 100644 --- a/src/gui/graphicsview/qgraphicssceneevent.h +++ b/src/gui/graphicsview/qgraphicssceneevent.h @@ -77,6 +77,8 @@ protected: QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type type = None); QScopedPointer d_ptr; Q_DECLARE_PRIVATE(QGraphicsSceneEvent) +private: + Q_DISABLE_COPY(QGraphicsSceneEvent) }; class QGraphicsSceneMouseEventPrivate; @@ -124,6 +126,7 @@ public: private: Q_DECLARE_PRIVATE(QGraphicsSceneMouseEvent) + Q_DISABLE_COPY(QGraphicsSceneMouseEvent) }; class QGraphicsSceneWheelEventPrivate; @@ -156,6 +159,7 @@ public: private: Q_DECLARE_PRIVATE(QGraphicsSceneWheelEvent) + Q_DISABLE_COPY(QGraphicsSceneWheelEvent) }; class QGraphicsSceneContextMenuEventPrivate; @@ -184,6 +188,7 @@ public: private: Q_DECLARE_PRIVATE(QGraphicsSceneContextMenuEvent) + Q_DISABLE_COPY(QGraphicsSceneContextMenuEvent) }; class QGraphicsSceneHoverEventPrivate; @@ -216,6 +221,7 @@ public: private: Q_DECLARE_PRIVATE(QGraphicsSceneHoverEvent) + Q_DISABLE_COPY(QGraphicsSceneHoverEvent) }; class QGraphicsSceneHelpEventPrivate; @@ -233,6 +239,7 @@ public: private: Q_DECLARE_PRIVATE(QGraphicsSceneHelpEvent) + Q_DISABLE_COPY(QGraphicsSceneHelpEvent) }; class QGraphicsSceneDragDropEventPrivate; @@ -275,12 +282,14 @@ public: private: Q_DECLARE_PRIVATE(QGraphicsSceneDragDropEvent) + Q_DISABLE_COPY(QGraphicsSceneDragDropEvent) }; class QGraphicsSceneResizeEventPrivate; class Q_GUI_EXPORT QGraphicsSceneResizeEvent : public QGraphicsSceneEvent { Q_DECLARE_PRIVATE(QGraphicsSceneResizeEvent) + Q_DISABLE_COPY(QGraphicsSceneResizeEvent) public: QGraphicsSceneResizeEvent(); ~QGraphicsSceneResizeEvent(); @@ -296,6 +305,7 @@ class QGraphicsSceneMoveEventPrivate; class Q_GUI_EXPORT QGraphicsSceneMoveEvent : public QGraphicsSceneEvent { Q_DECLARE_PRIVATE(QGraphicsSceneMoveEvent) + Q_DISABLE_COPY(QGraphicsSceneMoveEvent) public: QGraphicsSceneMoveEvent(); ~QGraphicsSceneMoveEvent(); -- cgit v0.12 From 1517456a6be97260286faa10fd8263440c7b62a4 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Tue, 9 Mar 2010 15:24:19 +0100 Subject: Get the printDialog to check for default paperSize via CUPS Task-number: QTBUG-6471 Reviewed-by: Trond --- src/gui/dialogs/qprintdialog_unix.cpp | 38 ++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp index 23f5831..00dc3e6 100644 --- a/src/gui/dialogs/qprintdialog_unix.cpp +++ b/src/gui/dialogs/qprintdialog_unix.cpp @@ -154,6 +154,9 @@ public: bool checkFields(); void setupPrinter(); void setOptionsPane(QPrintDialogPrivate *pane); +#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) + void setCupsProperties(); +#endif // slots void _q_printerChanged(int index); @@ -942,7 +945,7 @@ bool QUnixPrintWidgetPrivate::checkFields() void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() { - if (propertiesDialog == 0) { + if (!propertiesDialog) { propertiesDialog = new QPrintPropertiesDialog(q); propertiesDialog->setResult(QDialog::Rejected); } @@ -962,6 +965,35 @@ void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() propertiesDialog->exec(); } +#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) +void QUnixPrintWidgetPrivate::setCupsProperties() +{ + if (cups && QCUPSSupport::isAvailable()) { + QPrintEngine *engine = printer->printEngine(); + const ppd_option_t* pageSizes = cups->pageSizes(); + QByteArray cupsPageSize; + for (int i = 0; i < pageSizes->num_choices; ++i) { + if (static_cast(pageSizes->choices[i].marked) == 1) + cupsPageSize = pageSizes->choices[i].choice; + } + engine->setProperty(PPK_CupsStringPageSize, QString::fromLatin1(cupsPageSize)); + engine->setProperty(PPK_CupsOptions, cups->options()); + + QRect pageRect = cups->pageRect(cupsPageSize); + engine->setProperty(PPK_CupsPageRect, pageRect); + + QRect paperRect = cups->paperRect(cupsPageSize); + engine->setProperty(PPK_CupsPaperRect, paperRect); + + for (int ps = 0; ps < QPrinter::NPaperSize; ++ps) { + QPdf::PaperSize size = QPdf::paperSize(QPrinter::PaperSize(ps)); + if (size.width == paperRect.width() && size.height == paperRect.height()) + printer->setPaperSize(static_cast(ps)); + } + } +} +#endif + void QUnixPrintWidgetPrivate::setupPrinter() { const int printerCount = widget.printers->count(); @@ -986,6 +1018,10 @@ void QUnixPrintWidgetPrivate::setupPrinter() if (propertiesDialog && propertiesDialog->result() == QDialog::Accepted) propertiesDialog->setupPrinter(); +#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) + if (!propertiesDialog) + setCupsProperties(); +#endif } -- cgit v0.12 From 42b69b1383375a52818758bf89198e8dc97902d3 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 9 Mar 2010 15:39:40 +0100 Subject: Cursor would remain in a non-focused QLineEdit after clearing its selection QLineEditPrivate::_q_selectionChanged() did not take into account whether the widget had focus. Reviewed-by: Olivier Task-number: QTBUG-8634 --- src/gui/widgets/qlineedit_p.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp index 2c76a5c..468c111 100644 --- a/src/gui/widgets/qlineedit_p.cpp +++ b/src/gui/widgets/qlineedit_p.cpp @@ -134,7 +134,7 @@ void QLineEditPrivate::_q_selectionChanged() q->initStyleOption(&opt); bool showCursor = control->hasSelectedText() ? q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q): - true; + q->hasFocus(); setCursorVisible(showCursor); } -- cgit v0.12 From efd43128848e4b0898a828e7441ebdfcfb5c30b1 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 9 Mar 2010 15:53:26 +0100 Subject: Added very simple JPEG loading benchmark (using QImageReader) Reviewed-by: joao --- .../benchmarks/plugins/imageformats/jpeg/jpeg.cpp | 92 +++++++++++++++++++++ .../benchmarks/plugins/imageformats/jpeg/jpeg.pro | 18 ++++ .../benchmarks/plugins/imageformats/jpeg/n900.jpeg | Bin 0 -> 19016 bytes 3 files changed, 110 insertions(+) create mode 100644 tests/benchmarks/plugins/imageformats/jpeg/jpeg.cpp create mode 100644 tests/benchmarks/plugins/imageformats/jpeg/jpeg.pro create mode 100644 tests/benchmarks/plugins/imageformats/jpeg/n900.jpeg diff --git a/tests/benchmarks/plugins/imageformats/jpeg/jpeg.cpp b/tests/benchmarks/plugins/imageformats/jpeg/jpeg.cpp new file mode 100644 index 0000000..2cb9421 --- /dev/null +++ b/tests/benchmarks/plugins/imageformats/jpeg/jpeg.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + +class tst_jpeg : public QObject +{ + Q_OBJECT +private slots: + void jpegDecodingQtWebkitStyle(); +}; + +void tst_jpeg::jpegDecodingQtWebkitStyle() +{ + // QtWebkit currently calls size() to get the image size for layouting purposes. + // Then when it is in the viewport (we assume that here) it actually gets decoded. + QFile inputJpeg(SRCDIR "n900.jpeg"); + QVERIFY(inputJpeg.exists()); + inputJpeg.open(QIODevice::ReadOnly); + QByteArray imageData = inputJpeg.readAll(); + QBuffer buffer; + buffer.setData(imageData); + buffer.open(QBuffer::ReadOnly); + QCOMPARE(buffer.size(), qint64(19016)); + + + QBENCHMARK{ + for (int i = 0; i < 50; i++) { + QImageReader reader(&buffer, "jpeg"); + QSize size = reader.size(); + QVERIFY(!size.isNull()); + QByteArray format = reader.format(); + QVERIFY(!format.isEmpty()); + QImage img = reader.read(); + QVERIFY(!img.isNull()); + buffer.reset(); + } + } +} + +QTEST_MAIN(tst_jpeg) + +#include "jpeg.moc" diff --git a/tests/benchmarks/plugins/imageformats/jpeg/jpeg.pro b/tests/benchmarks/plugins/imageformats/jpeg/jpeg.pro new file mode 100644 index 0000000..e106f3e --- /dev/null +++ b/tests/benchmarks/plugins/imageformats/jpeg/jpeg.pro @@ -0,0 +1,18 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = jpeg +DEPENDPATH += . +INCLUDEPATH += . + +CONFIG += release + +wince*: { + DEFINES += SRCDIR=\\\"\\\" +} else:symbian { + # SRCDIR and SVGFILE defined in code in symbian +}else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} + +# Input +SOURCES += jpeg.cpp diff --git a/tests/benchmarks/plugins/imageformats/jpeg/n900.jpeg b/tests/benchmarks/plugins/imageformats/jpeg/n900.jpeg new file mode 100644 index 0000000..681989a Binary files /dev/null and b/tests/benchmarks/plugins/imageformats/jpeg/n900.jpeg differ -- cgit v0.12 From 95dd8a45b0da50fb32843dd275b2028ce77b2492 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 9 Mar 2010 17:16:02 +0100 Subject: Memory leak! Multiple insertions of the same (key, value) pair in a QMultiHash. Reviewed-by: Olivier Task-number: QTBUG-8862 --- src/gui/text/qtextformat.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index dca2da5..140cf43 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -3085,7 +3085,8 @@ int QTextFormatCollection::indexForFormat(const QTextFormat &format) f.d = new QTextFormatPrivate; f.d->resolveFont(defaultFnt); - hashes.insert(hash, idx); + if (!hashes.contains(hash, idx)) + hashes.insert(hash, idx); } QT_CATCH(...) { formats.pop_back(); -- cgit v0.12 From dac32b0d5ac4ed79584aba23134849956c787f75 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 9 Mar 2010 09:49:31 -0800 Subject: Improve scrolling in DirectFB Since DirectFB always uses the front buffer of a double buffered surface as the source when blitting we needed to make sure that the front buffer was valid and hence we called Flip for each scroll. This had negative performance impacts since you could end up with various parts of a window being updated at different times. With this patch we store whether the front-buffer is up to date inside the window surface and only call Flip in scroll if it's not. Reviewed-by: Jervey Kong --- .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 29 +++++++++------------- .../gfxdrivers/directfb/qdirectfbwindowsurface.h | 1 + 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index a8bdb65..51969fc 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -61,6 +61,7 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect #endif , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) + , flushPending(false) { #ifdef QT_NO_DIRECTFB_WM mode = Offscreen; @@ -80,6 +81,7 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect #endif , flipFlags(flip) , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) + , flushPending(false) { SurfaceFlags flags = 0; if (!widget || widget->window()->windowOpacity() == 0xff) @@ -299,28 +301,19 @@ void QDirectFBWindowSurface::setPermanentState(const QByteArray &state) } } -static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) -{ - const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; - surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy); - const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy }; - surface->Flip(surface, ®ion, DSFLIP_BLIT); -} - bool QDirectFBWindowSurface::scroll(const QRegion ®ion, int dx, int dy) { - if (!dfbSurface || !(flipFlags & DSFLIP_BLIT) || region.isEmpty()) + if (!dfbSurface || !(flipFlags & DSFLIP_BLIT) || region.rectCount() != 1) return false; - dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); - if (region.rectCount() == 1) { - scrollSurface(dfbSurface, region.boundingRect(), dx, dy); + if (flushPending) { + dfbSurface->Flip(dfbSurface, 0, DSFLIP_BLIT); } else { - const QVector rects = region.rects(); - const int n = rects.size(); - for (int i=0; iSetBlittingFlags(dfbSurface, DSBLIT_NOFX); + const QRect r = region.boundingRect(); + const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; + dfbSurface->Blit(dfbSurface, dfbSurface, &rect, r.x() + dx, r.y() + dy); return true; } @@ -384,6 +377,7 @@ void QDirectFBWindowSurface::flush(QWidget *widget, const QRegion ®ion, timer.restart(); } #endif + flushPending = false; } void QDirectFBWindowSurface::beginPaint(const QRegion &) @@ -391,6 +385,7 @@ void QDirectFBWindowSurface::beginPaint(const QRegion &) if (!engine) { engine = new QDirectFBPaintEngine(this); } + flushPending = true; } void QDirectFBWindowSurface::endPaint(const QRegion &) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index a6138f6..4370a8f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -114,6 +114,7 @@ private: DFBSurfaceFlipFlags flipFlags; bool boundingRectFlip; + bool flushPending; #ifdef QT_DIRECTFB_TIMING int frames; QTime timer; -- cgit v0.12 From 6b69385a53d39961225a45f09b3353dc95508a78 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 9 Mar 2010 20:18:20 +0100 Subject: fix qm file installation from shadow build --- translations/translations.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/translations/translations.pro b/translations/translations.pro index f1b9c99..8f37451 100644 --- a/translations/translations.pro +++ b/translations/translations.pro @@ -42,5 +42,6 @@ isEmpty(vcproj) { translations.path = $$[QT_INSTALL_TRANSLATIONS] translations.files = $$TRANSLATIONS translations.files ~= s,\\.ts$,.qm,g +translations.files ~= s,^,$$OUT_PWD/,g translations.CONFIG += no_check_exist INSTALLS += translations -- cgit v0.12 From a90117092e4bc5ecc1cb1640a16c70569a342759 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 9 Mar 2010 14:35:51 -0800 Subject: Compile without QT3_SUPPORT QList::remove() is QT3_SUPPORT, replace with erase(). Reviewed-by: Jervey Kong --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 7dce516..b76c6a7 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -216,12 +216,12 @@ static void initRasterFallbacksMasks(int *warningMask, int *disableMask) int idx = warning.indexOf(name); if (idx != -1) { *warningMask |= operations[i].operation; - warning.remove(warning.begin() + idx); + warning.erase(warning.begin() + idx); } idx = disable.indexOf(name); if (idx != -1) { *disableMask |= operations[i].operation; - disable.remove(disable.begin() + idx); + disable.erase(disable.begin() + idx); } } } -- cgit v0.12 From 83e73a69d5a1c6b94c5c83f91141f35d65d27f36 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 10 Mar 2010 10:01:11 +1000 Subject: Fixed invokeMethod in alsa implementation. Reviewed-by:Dmytro Poplavskiy --- src/multimedia/audio/qaudiooutput_alsa_p.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp index e49c75a..7eb38b6 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -648,7 +648,7 @@ void QAudioOutputPrivate::userFeed() void QAudioOutputPrivate::feedback() { - QMetaObject::invokeMethod(this, SLOT(updateAvailable()), Qt::QueuedConnection); + QMetaObject::invokeMethod(this, "updateAvailable", Qt::QueuedConnection); } void QAudioOutputPrivate::updateAvailable() -- cgit v0.12 From 346b0f6247f1f8ca967f6686a849aa7464cb6b87 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 10 Mar 2010 12:06:52 +1000 Subject: Fixed deadlock introduced by change 83e73a69d5a1c6b94c5c83f91141f35d65d27f36. alsa callback was deadlocking with QEventDispatcherGlib. Reviewed-by:Dmytro Poplavskiy --- src/multimedia/audio/qaudiooutput_alsa_p.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp index 7eb38b6..1cef335 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -648,9 +648,10 @@ void QAudioOutputPrivate::userFeed() void QAudioOutputPrivate::feedback() { - QMetaObject::invokeMethod(this, "updateAvailable", Qt::QueuedConnection); + updateAvailable(); } + void QAudioOutputPrivate::updateAvailable() { #ifdef DEBUG_AUDIO -- cgit v0.12 From 1ae64d1dcf2e9613d2580075a7b716910a6bf972 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 10 Mar 2010 13:41:29 +1000 Subject: Parallelize DB autotests, also some factorization Add local machine parallelization of auto-tests, not just host to host. Reviewed-by: Justin McPherson --- tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp | 97 ++-- .../q3sqlselectcursor/tst_q3sqlselectcursor.cpp | 20 +- tests/auto/qsqldatabase/tst_databases.h | 26 +- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 301 ++++++------ tests/auto/qsqldriver/tst_qsqldriver.cpp | 19 +- tests/auto/qsqlquery/tst_qsqlquery.cpp | 517 +++++++++++---------- tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp | 79 ++-- .../tst_qsqlrelationaltablemodel.cpp | 221 ++++----- tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp | 117 ++--- tests/auto/qsqlthread/tst_qsqlthread.cpp | 39 +- 10 files changed, 738 insertions(+), 698 deletions(-) diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp index 874eb7b..f837564 100644 --- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp +++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp @@ -48,6 +48,7 @@ #include "../qsqldatabase/tst_databases.h" +const QString qtest(qTableName( "qtest", __FILE__ )); //TESTED_FILES= @@ -142,26 +143,26 @@ void tst_Q3SqlCursor::createTestTables( QSqlDatabase db ) // please never ever change this table; otherwise fix all tests ;) if ( tst_Databases::isMSAccess( db ) ) { - QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null," + QVERIFY_SQL(q, exec( "create table " + qtest + " ( id int not null, t_varchar varchar(40) not null," "t_char char(40), t_numeric number, primary key (id, t_varchar) )" )); } else { - QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null," + QVERIFY_SQL(q, exec( "create table " + qtest + " ( id int not null, t_varchar varchar(40) not null," "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar) )" )); } if ( tst_Databases::isSqlServer( db ) ) { //workaround for SQL SERVER since he can store unicode only in nvarchar fields - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode") + " (id int not null, " + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode", __FILE__) + " (id int not null, " "t_varchar nvarchar(80) not null, t_char nchar(80) )" )); } else { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode") + " (id int not null, " + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode", __FILE__) + " (id int not null, " "t_varchar varchar(100) not null," "t_char char(100))" )); } if (tst_Databases::isMSAccess(db)) { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision") + " (col1 number)")); + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision", __FILE__) + " (col1 number)")); } else { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision") + " (col1 numeric(15, 14))")); + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision", __FILE__) + " (col1 numeric(15, 14))")); } } @@ -170,12 +171,12 @@ void tst_Q3SqlCursor::dropTestTables( QSqlDatabase db ) if ( !db.isValid() ) return; QStringList tableNames; - tableNames << qTableName( "qtest" ) - << qTableName( "qtest_unicode" ) - << qTableName( "qtest_precision" ) - << qTableName( "qtest_ovchar" ) - << qTableName( "qtest_onvchar" ) - << qTableName( "qtestPK" ); + tableNames << qtest + << qTableName( "qtest_unicode", __FILE__ ) + << qTableName( "qtest_precision", __FILE__ ) + << qTableName( "qtest_ovchar", __FILE__ ) + << qTableName( "qtest_onvchar", __FILE__ ) + << qTableName( "qtestPK", __FILE__ ); tst_Databases::safeDropTables( db, tableNames ); } @@ -185,8 +186,8 @@ void tst_Q3SqlCursor::populateTestTables( QSqlDatabase db ) return; QSqlQuery q( db ); - q.exec( "delete from " + qTableName( "qtest" ) ); //not fatal - QVERIFY_SQL(q, prepare("insert into " + qTableName( "qtest" ) + " (id, t_varchar, t_char, t_numeric) values (?, ?, ?, ?)")); + q.exec( "delete from " + qtest ); //not fatal + QVERIFY_SQL(q, prepare("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (?, ?, ?, ?)")); q.addBindValue(QVariantList() << 0 << 1 << 2 << 3); q.addBindValue(QVariantList() << "VarChar0" << "VarChar1" << "VarChar2" << "VarChar3"); q.addBindValue(QVariantList() << "Char0" << "Char1" << "Char2" << "Char3"); @@ -243,7 +244,7 @@ void tst_Q3SqlCursor::copyConstructor() Q3SqlCursor cur2; { - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); QVERIFY_SQL(cur, select( cur.index( QString("id") ) )); cur2 = Q3SqlCursor( cur ); // let "cur" run out of scope... @@ -266,7 +267,7 @@ void tst_Q3SqlCursor::value() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); QVERIFY_SQL(cur, select( cur.index( QString("id") ) )); int i = 0; while ( cur.next() ) { @@ -281,7 +282,7 @@ void tst_Q3SqlCursor::primaryIndex() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); QSqlIndex index = cur.primaryIndex(); if ( tst_Databases::isMSAccess( db ) ) { QCOMPARE( index.fieldName(1).upper(), QString( "ID" ) ); @@ -300,7 +301,7 @@ void tst_Q3SqlCursor::insert() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); QSqlRecord* irec = cur.primeInsert(); QVERIFY( irec != 0 ); @@ -338,7 +339,7 @@ void tst_Q3SqlCursor::insertSpecial() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); QSqlRecord* irec = cur.primeInsert(); QVERIFY( irec != 0 ); @@ -386,9 +387,9 @@ void tst_Q3SqlCursor::batchInsert() CHECK_DATABASE( db ); QSqlQuery q( db ); - q.exec( "delete from " + qTableName( "qtest" ) ); + q.exec( "delete from " + qtest ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); int i = 0; for ( ; i < 100; ++i ) { @@ -420,7 +421,7 @@ void tst_Q3SqlCursor::batchInsert() } i = 0; - QVERIFY_SQL(q, exec( "select * from " + qTableName( "qtest" ) + " order by id" )); + QVERIFY_SQL(q, exec( "select * from " + qtest + " order by id" )); while ( q.next() ) { QCOMPARE( q.value( 0 ).toInt(), i ); i++; @@ -452,11 +453,11 @@ void tst_Q3SqlCursor::insertORA() /****** CHARSET TEST ******/ QSqlQuery q( db ); - QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest_ovchar" ) + " ( id int primary key, t_char varchar(40) )" )); + QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest_ovchar", __FILE__ ) + " ( id int primary key, t_char varchar(40) )" )); static const QString val1( "blah1" ); - Q3SqlCursor cur ( qTableName( "qtest_ovchar" ), true, db ); + Q3SqlCursor cur ( qTableName( "qtest_ovchar", __FILE__ ), true, db ); QSqlRecord* irec = cur.primeInsert(); irec->setValue( "id", 1 ); irec->setValue( "t_char", val1 ); @@ -486,9 +487,9 @@ void tst_Q3SqlCursor::insertORA() /****** NCHARSET TEST ********/ - QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest_onvchar" ) + " ( id int primary key, t_nchar nvarchar2(40) )" )); + QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest_onvchar", __FILE__ ) + " ( id int primary key, t_nchar nvarchar2(40) )" )); - Q3SqlCursor cur2 ( qTableName( "qtest_onvchar" ), true, db ); + Q3SqlCursor cur2 ( qTableName( "qtest_onvchar", __FILE__ ), true, db ); irec = cur2.primeInsert(); irec->setValue( "id", 1 ); irec->setValue( "t_nchar", val1 ); @@ -529,7 +530,7 @@ void tst_Q3SqlCursor::unicode() if(db.driverName().startsWith("QIBASE") && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb")) QSKIP("Can't transliterate extended unicode to ascii", SkipSingle); - Q3SqlCursor cur( qTableName( "qtest_unicode" ), true, db ); + Q3SqlCursor cur( qTableName( "qtest_unicode", __FILE__ ), true, db ); QSqlRecord* irec = cur.primeInsert(); irec->setValue( 0, 500 ); irec->setValue( 1, utf8str ); @@ -566,7 +567,7 @@ void tst_Q3SqlCursor::precision() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest_precision" ), true, db ); + Q3SqlCursor cur( qTableName( "qtest_precision", __FILE__ ), true, db ); cur.setTrimmed( "col1", true ); QSqlRecord* irec = cur.primeInsert(); irec->setValue( 0, precStr ); @@ -589,7 +590,7 @@ void tst_Q3SqlCursor::setFilter() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); cur.setFilter( "id = 2" ); QVERIFY_SQL(cur, select()); @@ -619,23 +620,23 @@ void tst_Q3SqlCursor::select() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); QVERIFY_SQL(cur, select()); QVERIFY( cur.next() ); QVERIFY( cur.next() ); - Q3SqlCursor cur2( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur2( qtest, true, db ); QVERIFY_SQL(cur2, select( "id = 1" )); QVERIFY( cur2.next() ); QCOMPARE( cur2.value( 0 ).toInt(), 1 ); - Q3SqlCursor cur3( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur3( qtest, true, db ); QVERIFY_SQL(cur3, select( cur3.primaryIndex( false ) )); QVERIFY( cur3.next() ); QVERIFY( cur3.next() ); QCOMPARE( cur3.value( 0 ).toInt(), 1 ); - Q3SqlCursor cur4( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur4( qtest, true, db ); QSqlIndex idx = cur4.primaryIndex( false ); QCOMPARE( (int)idx.count(), 2 ); if ( tst_Databases::isMSAccess( db ) ) { @@ -667,17 +668,17 @@ void tst_Q3SqlCursor::setName() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor c2( qTableName( "qtest" ), true, db ); - QCOMPARE( c2.name(), qTableName( "qtest" ) ); + Q3SqlCursor c2( qtest, true, db ); + QCOMPARE( c2.name(), qtest ); QCOMPARE( c2.fieldName( 0 ).lower(), QString( "id" ) ); Q3SqlCursor c( QString(), true, db ); - c.setName( qTableName( "qtest" ) ); - QCOMPARE( c.name(), qTableName( "qtest" ) ); + c.setName( qtest ); + QCOMPARE( c.name(), qtest ); QCOMPARE( c.fieldName( 0 ).lower(), QString( "id" ) ); - c.setName( qTableName( "qtest_precision" ) ); - QCOMPARE( c.name(), qTableName( "qtest_precision" ) ); + c.setName( qTableName( "qtest_precision", __FILE__ ) ); + QCOMPARE( c.name(), qTableName( "qtest_precision", __FILE__ ) ); QCOMPARE( c.fieldName( 0 ).lower(), QString( "col1" ) ); } @@ -689,9 +690,9 @@ void tst_Q3SqlCursor::updateNoPK() CHECK_DATABASE( db ); QSqlQuery q(db); - QVERIFY_SQL(q, exec("create table " + qTableName( "qtestPK" ) + " (id int, name varchar(20), num numeric)")); + QVERIFY_SQL(q, exec("create table " + qTableName( "qtestPK", __FILE__ ) + " (id int, name varchar(20), num numeric)")); - Q3SqlCursor cur(qTableName("qtestPK"), true, db); + Q3SqlCursor cur(qTableName("qtestPK", __FILE__), true, db); QSqlRecord* rec = cur.primeInsert(); Q_ASSERT(rec); rec->setNull(0); @@ -705,14 +706,14 @@ void tst_Q3SqlCursor::updateNoPK() db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QODBC") || db.driverName().startsWith("QOCI")) { - QString query = QString::fromLatin1("insert into " + qTableName("qtestPK") + + QString query = QString::fromLatin1("insert into " + qTableName("qtestPK", __FILE__) + " (" + db.driver()->escapeIdentifier("id", QSqlDriver::FieldName) + ',' + db.driver()->escapeIdentifier("name", QSqlDriver::FieldName) + ',' + db.driver()->escapeIdentifier("num", QSqlDriver::FieldName) + ')' + " values (NULL,NULL,NULL)"); QCOMPARE(cur.lastQuery(), query); } else { - QCOMPARE(cur.lastQuery(), QString::fromLatin1("insert into " + qTableName("qtestPK") + + QCOMPARE(cur.lastQuery(), QString::fromLatin1("insert into " + qTableName("qtestPK", __FILE__) + " (\"id\",\"name\",\"num\") values (NULL,NULL,NULL)")); } } @@ -724,12 +725,12 @@ void tst_Q3SqlCursor::updateNoPK() rec->setNull(2); // Sqlite returns 2, don't ask why. QVERIFY(cur.update() != 0); - QString expect = "update " + qTableName("qtestPK") + + QString expect = "update " + qTableName("qtestPK", __FILE__) + " set "+db.driver()->escapeIdentifier("id", QSqlDriver::FieldName)+" = 1 , " +db.driver()->escapeIdentifier("name", QSqlDriver::FieldName)+" = NULL , " - +db.driver()->escapeIdentifier("num", QSqlDriver::FieldName)+" = NULL where " + qTableName("qtestPK") + ".id" - " IS NULL and " + qTableName("qtestPK") + ".name IS NULL and " + - qTableName("qtestPK") + ".num IS NULL"; + +db.driver()->escapeIdentifier("num", QSqlDriver::FieldName)+" = NULL where " + qTableName("qtestPK", __FILE__) + ".id" + " IS NULL and " + qTableName("qtestPK", __FILE__) + ".name IS NULL and " + + qTableName("qtestPK", __FILE__) + ".num IS NULL"; if (!db.driver()->hasFeature(QSqlDriver::PreparedQueries)) { if (!db.driverName().startsWith("QSQLITE")) { QCOMPARE(cur.lastQuery(), expect); @@ -760,7 +761,7 @@ void tst_Q3SqlCursor::insertFieldNameContainsWS() { return; } - QString tableName = qTableName("qtestws"); + QString tableName = qTableName("qtestws", __FILE__); QSqlQuery q(db); tst_Databases::safeDropTable(db, tableName); diff --git a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp index c19f9fd..b69ae79 100644 --- a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp +++ b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp @@ -111,16 +111,16 @@ void tst_Q3SqlSelectCursor::createTestTables( QSqlDatabase db ) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); // please never ever change this table; otherwise fix all tests ;) if (tst_Databases::isMSAccess(db)) - QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null," + QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest", __FILE__ ) + " ( id int not null, t_varchar varchar(40) not null," "t_char char(40), t_numeric number, primary key (id, t_varchar) )" )); else - QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null," + QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest", __FILE__ ) + " ( id int not null, t_varchar varchar(40) not null," "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar) )" )); } void tst_Q3SqlSelectCursor::dropTestTables( QSqlDatabase db ) { - tst_Databases::safeDropTable( db, qTableName( "qtest" ) ); + tst_Databases::safeDropTable( db, qTableName( "qtest", __FILE__ ) ); } void tst_Q3SqlSelectCursor::populateTestTables( QSqlDatabase db ) @@ -129,11 +129,11 @@ void tst_Q3SqlSelectCursor::populateTestTables( QSqlDatabase db ) return; QSqlQuery q( db ); - q.exec( "delete from " + qTableName( "qtest" ) ); //non-fatal - QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest" ) + " (id, t_varchar, t_char, t_numeric) values ( 0, 'VarChar0', 'Char0', 1.1 )" )); - QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest" ) + " (id, t_varchar, t_char, t_numeric) values ( 1, 'VarChar1', 'Char1', 2.2 )" )); - QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest" ) + " (id, t_varchar, t_char, t_numeric) values ( 2, 'VarChar2', 'Char2', 3.3 )" )); - QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest" ) + " (id, t_varchar, t_char, t_numeric) values ( 3, 'VarChar3', 'Char3', 4.4 )" )); + q.exec( "delete from " + qTableName( "qtest", __FILE__ ) ); //non-fatal + QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest", __FILE__ ) + " (id, t_varchar, t_char, t_numeric) values ( 0, 'VarChar0', 'Char0', 1.1 )" )); + QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest", __FILE__ ) + " (id, t_varchar, t_char, t_numeric) values ( 1, 'VarChar1', 'Char1', 2.2 )" )); + QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest", __FILE__ ) + " (id, t_varchar, t_char, t_numeric) values ( 2, 'VarChar2', 'Char2', 3.3 )" )); + QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest", __FILE__ ) + " (id, t_varchar, t_char, t_numeric) values ( 3, 'VarChar3', 'Char3', 4.4 )" )); } void tst_Q3SqlSelectCursor::initTestCase() @@ -184,7 +184,7 @@ void tst_Q3SqlSelectCursor::value() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlSelectCursor cur( "select * from " + qTableName( "qtest" ) + " order by id", db ); + Q3SqlSelectCursor cur( "select * from " + qTableName( "qtest", __FILE__ ) + " order by id", db ); QVERIFY( cur.select() ); QVERIFY_SQL(cur, isActive()); int i = 0; @@ -203,7 +203,7 @@ void tst_Q3SqlSelectCursor::_exec() Q3SqlSelectCursor cur( QString(), db ); QVERIFY_SQL(cur, isActive() == false); - cur.exec( "select * from " + qTableName( "qtest" ) ); //nothing should happen + cur.exec( "select * from " + qTableName( "qtest", __FILE__ ) ); //nothing should happen QVERIFY_SQL(cur, isActive()); int i = 0; while ( cur.next() ) { diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h index 4e99f18..5837719 100644 --- a/tests/auto/qsqldatabase/tst_databases.h +++ b/tests/auto/qsqldatabase/tst_databases.h @@ -95,12 +95,14 @@ static QString qGetHostName() // to prevent nameclashes on our database server, each machine // will use its own set of table names. Call this function to get // "tablename_hostname" -inline static QString qTableName( const QString& prefix, QSqlDriver* driver = 0 ) +inline static QString qTableName( const QString& prefix, const char *sourceFileName ) { - if ( !driver ) - return prefix + "_" + qGetHostName().replace( "-", "_" ); - else - return driver->escapeIdentifier( prefix + "_" + qGetHostName(), QSqlDriver::TableName ); + return QLatin1String("dbtst")+QString::number(qHash(QLatin1String(sourceFileName) + "_" + qGetHostName().replace( "-", "_" )), 16)+"_"+prefix; +} + +inline static QString qTableName( const QString& prefix, QSqlDriver* driver ) +{ + return driver->escapeIdentifier( prefix + "_" + qGetHostName(), QSqlDriver::TableName ); } inline static bool testWhiteSpaceNames( const QString &name ) @@ -250,8 +252,8 @@ public: // addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=iceblink.nokia.troll.no\\ICEBLINK", "troll", "trond", "" ); // addDb( "QODBC3", "DRIVER={SQL Native Client};SERVER=silence.nokia.troll.no\\SQLEXPRESS", "troll", "trond", "" ); -// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=mysql5-nokia.trolltech.com.au;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); -// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=mysql4-nokia.trolltech.com.au;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=bq-mysql50.apac.nokia.com;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=bq-mysql51.apac.nokia.com;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); // addDb( "QODBC", "DRIVER={FreeTDS};SERVER=horsehead.nokia.troll.no;DATABASE=testdb;PORT=4101;UID=troll;PWD=trondk", "troll", "trondk", "" ); // addDb( "QODBC", "DRIVER={FreeTDS};SERVER=silence.nokia.troll.no;DATABASE=testdb;PORT=2392;UID=troll;PWD=trond", "troll", "trond", "" ); // addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2003-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "", "", "" ); @@ -261,7 +263,7 @@ public: // addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2003-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" ); // addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2008-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" ); // addDb( "QODBC", "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\dbs\\access\\testdb.mdb", "", "", "" ); -// addDb( "QODBC", "DRIVER={Postgresql};SERVER=postgres81-nokia.trolltech.com.au;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC", "DRIVER={Postgresql};SERVER=bq-pgsql84.apac.nokia.com;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); } void open() @@ -338,7 +340,7 @@ public: foreach(const QString &table2, dbtables.filter(table, Qt::CaseInsensitive)) { if(table2.compare(table.section('.', -1, -1), Qt::CaseInsensitive) == 0) { table=db.driver()->escapeIdentifier(table2, QSqlDriver::TableName); - if(db.driverName().startsWith( "QPSQL" )) + if(isPostgreSQL(db)) wasDropped = q.exec( "drop table " + table + " cascade"); else wasDropped = q.exec( "drop table " + table); @@ -483,16 +485,16 @@ public: static bool isPostgreSQL( QSqlDatabase db ) { - return db.driverName().startsWith("QPSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("PostgreSQL") ); + return db.driverName().startsWith("QPSQL") || (db.driverName().startsWith("QODBC") && ( db.databaseName().contains("PostgreSQL", Qt::CaseInsensitive) || db.databaseName().contains("pgsql", Qt::CaseInsensitive) ) ); } static bool isMySQL( QSqlDatabase db ) { - return db.driverName().startsWith("QMYSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("MySQL") ); + return db.driverName().startsWith("QMYSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("MySQL", Qt::CaseInsensitive) ); } static bool isDB2( QSqlDatabase db ) { - return db.driverName().startsWith("QDB2") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("db2") ); + return db.driverName().startsWith("QDB2") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("db2", Qt::CaseInsensitive) ); } // -1 on fail, else Oracle version diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index fe084fa..b2b592b 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -259,10 +259,10 @@ struct FieldDef { // excluding the primary key field static int createFieldTable(const FieldDef fieldDefs[], QSqlDatabase db) { - tst_Databases::safeDropTable(db, qTableName("qtestfields")); + tst_Databases::safeDropTable(db, qTableName("qtestfields", __FILE__)); QSqlQuery q(db); // construct a create table statement consisting of all fieldtypes - QString qs = "create table " + qTableName("qtestfields"); + QString qs = "create table " + qTableName("qtestfields", __FILE__); QString autoName = tst_Databases::autoFieldName(db); if (tst_Databases::isMSAccess(db)) qs.append(" (id int not null"); @@ -316,18 +316,18 @@ void tst_QSqlDatabase::createTestTables(QSqlDatabase db) // please never ever change this table; otherwise fix all tests ;) if (tst_Databases::isMSAccess(db)) { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest") + + QVERIFY_SQL(q, exec("create table " + qTableName("qtest", __FILE__) + " (id int not null, t_varchar varchar(40) not null, t_char char(40), " "t_numeric number, primary key (id, t_varchar))")); } else { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest") + + QVERIFY_SQL(q, exec("create table " + qTableName("qtest", __FILE__) + " (id integer not null, t_varchar varchar(40) not null, " "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar))")); } if (testWhiteSpaceNames(db.driverName())) { QString qry = "create table " - + db.driver()->escapeIdentifier(qTableName("qtest") + " test", QSqlDriver::TableName) + + db.driver()->escapeIdentifier(qTableName("qtest", __FILE__) + " test", QSqlDriver::TableName) + '(' + db.driver()->escapeIdentifier(QLatin1String("test test"), QSqlDriver::FieldName) + " int not null primary key)"; @@ -346,45 +346,45 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db) } // drop the view first, otherwise we'll get dependency problems - tst_Databases::safeDropViews(db, QStringList() << qTableName("qtest_view") << qTableName("qtest_view2")); + tst_Databases::safeDropViews(db, QStringList() << qTableName("qtest_view", __FILE__) << qTableName("qtest_view2", __FILE__)); QStringList tableNames; - tableNames << qTableName("qtest") - << qTableName("qtestfields") - << qTableName("qtestalter") - << qTableName("qtest_temp") - << qTableName("qtest_bigint") - << qTableName("qtest_xmltype") - << qTableName("latin1table") - << qTableName("qtest_sqlguid") - << qTableName("batable") - << qTableName("qtest_prec") - << qTableName("uint") - << qTableName("strings") - << qTableName("numericfields") - << qTableName("qtest_ibaseblobs") - << qTableName("qtestBindBool") - << qTableName("testqGetString") - << qTableName("qtest_sqlguid") - << qTableName("uint_table") - << qTableName("uint_test") - << qTableName("bug_249059"); + tableNames << qTableName("qtest", __FILE__) + << qTableName("qtestfields", __FILE__) + << qTableName("qtestalter", __FILE__) + << qTableName("qtest_temp", __FILE__) + << qTableName("qtest_bigint", __FILE__) + << qTableName("qtest_xmltype", __FILE__) + << qTableName("latin1table", __FILE__) + << qTableName("qtest_sqlguid", __FILE__) + << qTableName("batable", __FILE__) + << qTableName("qtest_prec", __FILE__) + << qTableName("uint", __FILE__) + << qTableName("strings", __FILE__) + << qTableName("numericfields", __FILE__) + << qTableName("qtest_ibaseblobs", __FILE__) + << qTableName("qtestBindBool", __FILE__) + << qTableName("testqGetString", __FILE__) + << qTableName("qtest_sqlguid", __FILE__) + << qTableName("uint_table", __FILE__) + << qTableName("uint_test", __FILE__) + << qTableName("bug_249059", __FILE__); QSqlQuery q(0, db); if (db.driverName().startsWith("QPSQL")) { - q.exec("drop schema " + qTableName("qtestschema") + " cascade"); - q.exec("drop schema " + qTableName("qtestScHeMa") + " cascade"); + q.exec("drop schema " + qTableName("qtestschema", __FILE__) + " cascade"); + q.exec("drop schema " + qTableName("qtestScHeMa", __FILE__) + " cascade"); } if (testWhiteSpaceNames(db.driverName())) - tableNames << db.driver()->escapeIdentifier(qTableName("qtest") + " test", QSqlDriver::TableName); + tableNames << db.driver()->escapeIdentifier(qTableName("qtest", __FILE__) + " test", QSqlDriver::TableName); tst_Databases::safeDropTables(db, tableNames); if (db.driverName().startsWith("QOCI")) { - q.exec("drop user "+qTableName("CREATOR")+" cascade"); - q.exec("drop user "+qTableName("APPUSER")+" cascade"); - q.exec("DROP TABLE system."+qTableName("mypassword")); + q.exec("drop user "+qTableName("CREATOR", __FILE__)+" cascade"); + q.exec("drop user "+qTableName("APPUSER", __FILE__)+" cascade"); + q.exec("DROP TABLE system."+qTableName("mypassword", __FILE__)); } } @@ -394,13 +394,14 @@ void tst_QSqlDatabase::populateTestTables(QSqlDatabase db) if (!db.isValid()) return; QSqlQuery q(db); + const QString qtest(qTableName("qtest", __FILE__)); - q.exec("delete from " + qTableName("qtest")); //non-fatal - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (0, 'VarChar0', 'Char0', 1.1)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (1, 'VarChar1', 'Char1', 2.2)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (2, 'VarChar2', 'Char2', 3.3)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (3, 'VarChar3', 'Char3', 4.4)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (4, 'VarChar4', NULL, NULL)")); + q.exec("delete from " + qtest); //non-fatal + QVERIFY_SQL(q, exec("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (0, 'VarChar0', 'Char0', 1.1)")); + QVERIFY_SQL(q, exec("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (1, 'VarChar1', 'Char1', 2.2)")); + QVERIFY_SQL(q, exec("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (2, 'VarChar2', 'Char2', 3.3)")); + QVERIFY_SQL(q, exec("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (3, 'VarChar3', 'Char3', 4.4)")); + QVERIFY_SQL(q, exec("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (4, 'VarChar4', NULL, NULL)")); } void tst_QSqlDatabase::initTestCase() @@ -496,7 +497,7 @@ void tst_QSqlDatabase::recordNonSelect() Q3SqlRecordInfo rInf = db.recordInfo(q); QVERIFY(rInf.isEmpty()); - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_temp") + " (id int)")); + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_temp", __FILE__) + " (id int)")); // query without result set should return empty record rec = db.record(q); @@ -512,6 +513,8 @@ void tst_QSqlDatabase::tables() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString qtest(qTableName("qtest", __FILE__)), qtest_view(qTableName("qtest_view", __FILE__)), temp_tab(qTableName("test_tab", __FILE__)); + bool views = true; bool tempTables = false; @@ -520,50 +523,50 @@ void tst_QSqlDatabase::tables() QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); - if (!q.exec("CREATE VIEW " + qTableName("qtest_view") + " as select * from " + qTableName("qtest"))) { + if (!q.exec("CREATE VIEW " + qtest_view + " as select * from " + qtest)) { qDebug(QString("DBMS '%1' cannot handle VIEWs: %2").arg( tst_Databases::dbToString(db)).arg(QString(tst_Databases::printError(q.lastError()))).toLatin1()); views = false; } if (db.driverName().startsWith("QSQLITE3")) { - QVERIFY_SQL(q, exec("CREATE TEMPORARY TABLE " + qTableName("temp_tab") + " (id int)")); + QVERIFY_SQL(q, exec("CREATE TEMPORARY TABLE " + temp_tab + " (id int)")); tempTables = true; } QStringList tables = db.tables(QSql::Tables); - QVERIFY(tables.contains(qTableName("qtest"), Qt::CaseInsensitive)); + QVERIFY(tables.contains(qtest, Qt::CaseInsensitive)); QVERIFY(!tables.contains("sql_features", Qt::CaseInsensitive)); //check for postgres 7.4 internal tables if (views) { - QVERIFY(!tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)); + QVERIFY(!tables.contains(qtest_view, Qt::CaseInsensitive)); } if (tempTables) - QVERIFY(tables.contains(qTableName("temp_tab"), Qt::CaseInsensitive)); + QVERIFY(tables.contains(temp_tab, Qt::CaseInsensitive)); tables = db.tables(QSql::Views); if (views) { - if(!tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)) - qDebug() << "failed to find" << qTableName("qtest_view") << "in" << tables; - QVERIFY(tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)); + if(!tables.contains(qtest_view, Qt::CaseInsensitive)) + qDebug() << "failed to find" << qtest_view << "in" << tables; + QVERIFY(tables.contains(qtest_view, Qt::CaseInsensitive)); } if (tempTables) - QVERIFY(!tables.contains(qTableName("temp_tab"), Qt::CaseInsensitive)); - QVERIFY(!tables.contains(qTableName("qtest"), Qt::CaseInsensitive)); + QVERIFY(!tables.contains(temp_tab, Qt::CaseInsensitive)); + QVERIFY(!tables.contains(qtest, Qt::CaseInsensitive)); tables = db.tables(QSql::SystemTables); - QVERIFY(!tables.contains(qTableName("qtest"), Qt::CaseInsensitive)); - QVERIFY(!tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)); - QVERIFY(!tables.contains(qTableName("temp_tab"), Qt::CaseInsensitive)); + QVERIFY(!tables.contains(qtest, Qt::CaseInsensitive)); + QVERIFY(!tables.contains(qtest_view, Qt::CaseInsensitive)); + QVERIFY(!tables.contains(temp_tab, Qt::CaseInsensitive)); tables = db.tables(QSql::AllTables); if (views) - QVERIFY(tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)); + QVERIFY(tables.contains(qtest_view, Qt::CaseInsensitive)); if (tempTables) - QVERIFY(tables.contains(qTableName("temp_tab"), Qt::CaseInsensitive)); - QVERIFY(tables.contains(qTableName("qtest"), Qt::CaseInsensitive)); + QVERIFY(tables.contains(temp_tab, Qt::CaseInsensitive)); + QVERIFY(tables.contains(qtest, Qt::CaseInsensitive)); if (db.driverName().startsWith("QPSQL")) { - QVERIFY(tables.contains(qTableName("qtest") + " test")); + QVERIFY(tables.contains(qtest + " test")); } } @@ -574,7 +577,7 @@ void tst_QSqlDatabase::whitespaceInIdentifiers() CHECK_DATABASE(db); if (testWhiteSpaceNames(db.driverName())) { - QString tableName = qTableName("qtest") + " test"; + const QString tableName(qTableName("qtest", __FILE__) + " test"); QVERIFY(db.tables().contains(tableName, Qt::CaseInsensitive)); QSqlRecord rec = db.record(db.driver()->escapeIdentifier(tableName, QSqlDriver::TableName)); @@ -602,14 +605,15 @@ void tst_QSqlDatabase::alterTable() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString qtestalter(qTableName("qtestalter", __FILE__)); QSqlQuery q(db); - QVERIFY_SQL(q, exec("create table " + qTableName("qtestalter") + " (F1 char(20), F2 char(20), F3 char(20))")); - QSqlRecord rec = db.record(qTableName("qtestalter")); + QVERIFY_SQL(q, exec("create table " + qtestalter + " (F1 char(20), F2 char(20), F3 char(20))")); + QSqlRecord rec = db.record(qtestalter); QCOMPARE((int)rec.count(), 3); #ifdef QT3_SUPPORT - Q3SqlRecordInfo rinf = db.recordInfo(qTableName("qtestalter")); + Q3SqlRecordInfo rinf = db.recordInfo(qtestalter); QCOMPARE((int)rinf.count(), 3); #endif @@ -622,13 +626,13 @@ void tst_QSqlDatabase::alterTable() #endif } - if (!q.exec("alter table " + qTableName("qtestalter") + " drop column F2")) { + if (!q.exec("alter table " + qtestalter + " drop column F2")) { QSKIP("DBMS doesn't support dropping columns in ALTER TABLE statement", SkipSingle); } - rec = db.record(qTableName("qtestalter")); + rec = db.record(qtestalter); #ifdef QT3_SUPPORT - rinf = db.recordInfo(qTableName("qtestalter")); + rinf = db.recordInfo(qtestalter); #endif QCOMPARE((int)rec.count(), 2); @@ -643,7 +647,7 @@ void tst_QSqlDatabase::alterTable() QCOMPARE(rinf[ 1 ].name().upper(), QString("F3")); #endif - q.exec("select * from " + qTableName("qtestalter")); + q.exec("select * from " + qtestalter); #ifdef QT3_SUPPORT rec = db.record(q); @@ -730,17 +734,17 @@ void tst_QSqlDatabase::commonFieldTest(const FieldDef fieldDefs[], QSqlDatabase // check whether recordInfo returns the right types #ifdef QT3_SUPPORT - Q3SqlRecordInfo inf = db.recordInfo(qTableName("qtestfields")); + Q3SqlRecordInfo inf = db.recordInfo(qTableName("qtestfields", __FILE__)); QCOMPARE((int)inf.count(), fieldCount+1); testRecordInfo(fieldDefs, inf); #endif - QSqlRecord rec = db.record(qTableName("qtestfields")); + QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__)); QCOMPARE((int)rec.count(), fieldCount+1); testRecord(fieldDefs, rec, db); QSqlQuery q(db); - QVERIFY_SQL(q, exec("select * from " + qTableName("qtestfields"))); + QVERIFY_SQL(q, exec("select * from " + qTableName("qtestfields", __FILE__))); #ifdef QT3_SUPPORT inf = db.recordInfo(q); @@ -760,7 +764,7 @@ void tst_QSqlDatabase::checkValues(const FieldDef fieldDefs[], QSqlDatabase db) #ifdef QT3_SUPPORT CHECK_DATABASE(db); - Q3SqlCursor cur(qTableName("qtestfields"), true, db); + Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db); QVERIFY_SQL(cur, select()); QSqlRecord* rec = cur.primeInsert(); Q_ASSERT(rec); @@ -821,7 +825,7 @@ void tst_QSqlDatabase::checkNullValues(const FieldDef fieldDefs[], QSqlDatabase #ifdef QT3_SUPPORT CHECK_DATABASE(db); - Q3SqlCursor cur(qTableName("qtestfields"), true, db); + Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db); QVERIFY_SQL(cur, select()); QSqlRecord* rec = cur.primeInsert(); Q_ASSERT(rec); @@ -955,12 +959,12 @@ void tst_QSqlDatabase::recordOCI() checkValues(fieldDefs, db); // some additional tests - QSqlRecord rec = db.record(qTableName("qtestfields")); + QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__)); QCOMPARE(rec.field("T_NUMBER").length(), 10); QCOMPARE(rec.field("T_NUMBER").precision(), 5); QSqlQuery q(db); - QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtestfields"))); + QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtestfields", __FILE__))); rec = q.record(); QCOMPARE(rec.field("T_NUMBER").length(), 10); QCOMPARE(rec.field("T_NUMBER").precision(), 5); @@ -1024,11 +1028,11 @@ void tst_QSqlDatabase::recordPSQL() if(tst_Databases::isPostgreSQL(db)) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - q.exec("drop sequence " + qTableName("qtestfields") + "_t_bigserial_seq"); - q.exec("drop sequence " + qTableName("qtestfields") + "_t_serial_seq"); + q.exec("drop sequence " + qTableName("qtestfields", __FILE__) + "_t_bigserial_seq"); + q.exec("drop sequence " + qTableName("qtestfields", __FILE__) + "_t_serial_seq"); // older psql cut off the table name - q.exec("drop sequence " + qTableName("qtestfields").left(15) + "_t_bigserial_seq"); - q.exec("drop sequence " + qTableName("qtestfields").left(18) + "_t_serial_seq"); + q.exec("drop sequence " + qTableName("qtestfields", __FILE__).left(15) + "_t_bigserial_seq"); + q.exec("drop sequence " + qTableName("qtestfields", __FILE__).left(18) + "_t_serial_seq"); const int fieldCount = createFieldTable(fieldDefs, db); QVERIFY(fieldCount > 0); @@ -1325,6 +1329,7 @@ void tst_QSqlDatabase::transaction() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString qtest(qTableName("qtest", __FILE__)); if (!db.driver()->hasFeature(QSqlDriver::Transactions)) { QSKIP("DBMS not transaction capable", SkipSingle); @@ -1333,8 +1338,8 @@ void tst_QSqlDatabase::transaction() QVERIFY(db.transaction()); QSqlQuery q(db); - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " values (40, 'VarChar40', 'Char40', 40.40)")); - QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 40")); + QVERIFY_SQL(q, exec("insert into " + qtest + " values (40, 'VarChar40', 'Char40', 40.40)")); + QVERIFY_SQL(q, exec("select * from " + qtest + " where id = 40")); QVERIFY(q.next()); QCOMPARE(q.value(0).toInt(), 40); q.clear(); @@ -1342,15 +1347,15 @@ void tst_QSqlDatabase::transaction() QVERIFY(db.commit()); QVERIFY(db.transaction()); - QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 40")); + QVERIFY_SQL(q, exec("select * from " + qtest + " where id = 40")); QVERIFY(q.next()); QCOMPARE(q.value(0).toInt(), 40); q.clear(); QVERIFY(db.commit()); QVERIFY(db.transaction()); - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " values (41, 'VarChar41', 'Char41', 41.41)")); - QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 41")); + QVERIFY_SQL(q, exec("insert into " + qtest + " values (41, 'VarChar41', 'Char41', 41.41)")); + QVERIFY_SQL(q, exec("select * from " + qtest + " where id = 41")); QVERIFY(q.next()); QCOMPARE(q.value(0).toInt(), 41); q.clear(); // for SQLite which does not allow any references on rows that shall be rolled back @@ -1363,7 +1368,7 @@ void tst_QSqlDatabase::transaction() } } - QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 41")); + QVERIFY_SQL(q, exec("select * from " + qtest + " where id = 41")); if(db.driverName().startsWith("QODBC") && dbName.contains("MySQL")) QEXPECT_FAIL("", "Some odbc drivers don't actually roll back despite telling us they do, especially the mysql driver", Continue); QVERIFY(!q.next()); @@ -1377,6 +1382,7 @@ void tst_QSqlDatabase::bigIntField() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); QString drvName = db.driverName(); + const QString qtest_bigint(qTableName("qtest_bigint", __FILE__)); QSqlQuery q(db); q.setForwardOnly(true); @@ -1384,19 +1390,19 @@ void tst_QSqlDatabase::bigIntField() q.setNumericalPrecisionPolicy(QSql::LowPrecisionInt64); if (drvName.startsWith("QMYSQL")) { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bigint") + " (id int, t_s64bit bigint, t_u64bit bigint unsigned)")); + QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit bigint, t_u64bit bigint unsigned)")); } else if (drvName.startsWith("QPSQL") || drvName.startsWith("QDB2") || tst_Databases::isSqlServer(db)) { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bigint") + "(id int, t_s64bit bigint, t_u64bit bigint)")); + QVERIFY_SQL(q, exec("create table " + qtest_bigint + "(id int, t_s64bit bigint, t_u64bit bigint)")); } else if (drvName.startsWith("QOCI")) { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bigint") + " (id int, t_s64bit int, t_u64bit int)")); + QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit int, t_u64bit int)")); //} else if (drvName.startsWith("QIBASE")) { - // QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bigint") + " (id int, t_s64bit int64, t_u64bit int64)")); + // QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit int64, t_u64bit int64)")); } else { QSKIP("no 64 bit integer support", SkipAll); } - QVERIFY(q.prepare("insert into " + qTableName("qtest_bigint") + " values (?, ?, ?)")); + QVERIFY(q.prepare("insert into " + qtest_bigint + " values (?, ?, ?)")); qlonglong ll = Q_INT64_C(9223372036854775807); qulonglong ull = Q_UINT64_C(18446744073709551615); @@ -1420,7 +1426,7 @@ void tst_QSqlDatabase::bigIntField() q.bindValue(2, (qlonglong) ull); QVERIFY_SQL(q, exec()); } - QVERIFY(q.exec("select * from " + qTableName("qtest_bigint") + " order by id")); + QVERIFY(q.exec("select * from " + qtest_bigint + " order by id")); QVERIFY(q.next()); QCOMPARE(q.value(1).toDouble(), (double)ll); QCOMPARE(q.value(1).toLongLong(), ll); @@ -1447,32 +1453,32 @@ void tst_QSqlDatabase::caseSensivity() || db.driverName().startsWith("QODBC")) cs = true; - QSqlRecord rec = db.record(qTableName("qtest")); + QSqlRecord rec = db.record(qTableName("qtest", __FILE__)); QVERIFY((int)rec.count() > 0); if (!cs) { - rec = db.record(qTableName("QTEST").toUpper()); + rec = db.record(qTableName("QTEST", __FILE__).toUpper()); QVERIFY((int)rec.count() > 0); - rec = db.record(qTableName("qTesT")); + rec = db.record(qTableName("qTesT", __FILE__)); QVERIFY((int)rec.count() > 0); } #ifdef QT3_SUPPORT - Q3SqlRecordInfo rInf = db.recordInfo(qTableName("qtest")); + Q3SqlRecordInfo rInf = db.recordInfo(qTableName("qtest", __FILE__)); QVERIFY((int)rInf.count() > 0); if (!cs) { - rInf = db.recordInfo(qTableName("QTEST").upper()); + rInf = db.recordInfo(qTableName("QTEST", __FILE__).upper()); QVERIFY((int)rInf.count() > 0); - rInf = db.recordInfo(qTableName("qTesT")); + rInf = db.recordInfo(qTableName("qTesT", __FILE__)); QVERIFY((int)rInf.count() > 0); } #endif - rec = db.primaryIndex(qTableName("qtest")); + rec = db.primaryIndex(qTableName("qtest", __FILE__)); QVERIFY((int)rec.count() > 0); if (!cs) { - rec = db.primaryIndex(qTableName("QTEST").toUpper()); + rec = db.primaryIndex(qTableName("QTEST", __FILE__).toUpper()); QVERIFY((int)rec.count() > 0); - rec = db.primaryIndex(qTableName("qTesT")); + rec = db.primaryIndex(qTableName("qTesT", __FILE__)); QVERIFY((int)rec.count() > 0); } } @@ -1488,7 +1494,7 @@ void tst_QSqlDatabase::noEscapedFieldNamesInRecord() fieldname = fieldname.toUpper(); QSqlQuery q(db); - QString query = "SELECT " + db.driver()->escapeIdentifier(fieldname, QSqlDriver::FieldName) + " FROM " + qTableName("qtest"); + QString query = "SELECT " + db.driver()->escapeIdentifier(fieldname, QSqlDriver::FieldName) + " FROM " + qTableName("qtest", __FILE__); QVERIFY_SQL(q, exec(query)); QCOMPARE(q.record().fieldName(0), fieldname); } @@ -1508,9 +1514,9 @@ void tst_QSqlDatabase::psql_schemas() QVERIFY_SQL( q, exec("set client_min_messages='warning'")); } - QVERIFY_SQL(q, exec("CREATE SCHEMA " + qTableName("qtestschema"))); + QVERIFY_SQL(q, exec("CREATE SCHEMA " + qTableName("qtestschema", __FILE__))); - QString table = qTableName("qtestschema") + '.' + qTableName("qtesttable"); + QString table = qTableName("qtestschema", __FILE__) + '.' + qTableName("qtesttable", __FILE__); QVERIFY_SQL(q, exec("CREATE TABLE " + table + " (id int primary key, name varchar(20))")); QVERIFY(db.tables().contains(table)); @@ -1546,10 +1552,10 @@ void tst_QSqlDatabase::psql_escapedIdentifiers() if(tst_Databases::isPostgreSQL(db)) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - QString schemaName = qTableName("qtestScHeMa"); - QString tableName = qTableName("qtest"); - QString field1Name = QString("fIeLdNaMe"); - QString field2Name = QString("ZuLu"); + const QString schemaName(qTableName("qtestScHeMa", __FILE__)), + tableName(qTableName("qtest", __FILE__)), + field1Name(QLatin1String("fIeLdNaMe")), + field2Name(QLatin1String("ZuLu")); q.exec(QString("DROP SCHEMA \"%1\" CASCADE").arg(schemaName)); QString createSchema = QString("CREATE SCHEMA \"%1\"").arg(schemaName); @@ -1576,7 +1582,6 @@ void tst_QSqlDatabase::psql_escapedIdentifiers() q.exec(QString("DROP SCHEMA \"%1\" CASCADE").arg(schemaName)); } - void tst_QSqlDatabase::psql_escapeBytea() { QFETCH(QString, dbName); @@ -1587,7 +1592,7 @@ void tst_QSqlDatabase::psql_escapeBytea() QByteArray ba(dta, 4); QSqlQuery q(db); - QString tableName = qTableName("batable"); + const QString tableName(qTableName("batable", __FILE__)); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (ba bytea)").arg(tableName))); QSqlQuery iq(db); @@ -1620,7 +1625,7 @@ void tst_QSqlDatabase::bug_249059() QSKIP("Test requires PostgreSQL >= 7.3", SkipSingle); QSqlQuery q(db); - QString tableName = qTableName("bug_249059"); + const QString tableName(qTableName("bug_249059", __FILE__)); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (dt timestamp, t time)").arg(tableName))); QSqlQuery iq(db); @@ -1655,7 +1660,7 @@ void tst_QSqlDatabase::precisionPolicy() // DBMS_SPECIFIC(db, "QPSQL"); QSqlQuery q(db); - QString tableName = qTableName("qtest_prec"); + const QString tableName(qTableName("qtest_prec", __FILE__)); if(!db.driver()->hasFeature(QSqlDriver::LowPrecisionNumbers)) QSKIP("Driver or database doesn't support setting precision policy", SkipSingle); @@ -1752,7 +1757,7 @@ void tst_QSqlDatabase::mysqlOdbc_unsignedIntegers() } QSqlQuery q(db); - QString tableName = qTableName("uint"); + const QString tableName(qTableName("uint", __FILE__)); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (foo integer(10) unsigned, bar integer(10))").arg(tableName))); QVERIFY_SQL(q, exec(QString("INSERT INTO %1 VALUES (-4000000000, -4000000000)").arg(tableName))); QVERIFY_SQL(q, exec(QString("INSERT INTO %1 VALUES (4000000000, 4000000000)").arg(tableName))); @@ -1778,7 +1783,7 @@ void tst_QSqlDatabase::accessOdbc_strings() } QSqlQuery q(db); - QString tableName = qTableName("strings"); + const QString tableName(qTableName("strings", __FILE__)); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (aStr memo, bStr memo, cStr memo, dStr memo" ", eStr memo, fStr memo, gStr memo, hStr memo)").arg(tableName))); @@ -1816,7 +1821,7 @@ void tst_QSqlDatabase::ibase_numericFields() CHECK_DATABASE(db); QSqlQuery q(db); - QString tableName = qTableName("numericfields"); + const QString tableName(qTableName("numericfields", __FILE__)); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (id int not null, num1 NUMERIC(2,1), " "num2 NUMERIC(5,2), num3 NUMERIC(10,3), " "num4 NUMERIC(18,4))").arg(tableName))); @@ -1888,7 +1893,7 @@ void tst_QSqlDatabase::ibase_fetchBlobs() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tableName = qTableName("qtest_ibaseblobs"); + const QString tableName(qTableName("qtest_ibaseblobs", __FILE__)); QSqlQuery q(db); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (blob1 BLOB segment size 256)").arg(tableName))); @@ -1921,7 +1926,7 @@ void tst_QSqlDatabase::ibase_procWithoutReturnValues() CHECK_DATABASE(db); QSqlQuery q(db); - QString procName = qTableName("qtest_proc1"); + const QString procName(qTableName("qtest_proc1", __FILE__)); q.exec(QString("drop procedure %1").arg(procName)); QVERIFY_SQL(q, exec("CREATE PROCEDURE " + procName + " (str VARCHAR(10))\nAS BEGIN\nstr='test';\nEND;")); QVERIFY_SQL(q, exec(QString("execute procedure %1('qtest')").arg(procName))); @@ -1939,7 +1944,7 @@ void tst_QSqlDatabase::ibase_procWithReturnValues() return; } - QString procName = qTableName("qtest_proc2"); + const QString procName(qTableName("qtest_proc2", __FILE__)); QSqlQuery q(db); q.exec(QString("drop procedure %1").arg(procName)); @@ -1981,11 +1986,11 @@ void tst_QSqlDatabase::formatValueTrimStrings() QSqlQuery q(db); - QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (50, 'Trim Test ', 'Trim Test 2 ')").arg(qTableName("qtest")))); - QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (51, 'TrimTest', 'Trim Test 2')").arg(qTableName("qtest")))); - QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (52, ' ', ' ')").arg(qTableName("qtest")))); + QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (50, 'Trim Test ', 'Trim Test 2 ')").arg(qTableName("qtest", __FILE__)))); + QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (51, 'TrimTest', 'Trim Test 2')").arg(qTableName("qtest", __FILE__)))); + QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (52, ' ', ' ')").arg(qTableName("qtest", __FILE__)))); - QVERIFY_SQL(q, exec(QString("SELECT t_varchar, t_char FROM %1 WHERE id >= 50 AND id <= 52 ORDER BY id").arg(qTableName("qtest")))); + QVERIFY_SQL(q, exec(QString("SELECT t_varchar, t_char FROM %1 WHERE id >= 50 AND id <= 52 ORDER BY id").arg(qTableName("qtest", __FILE__)))); QVERIFY_SQL(q, next()); @@ -2009,10 +2014,10 @@ void tst_QSqlDatabase::odbc_reopenDatabase() CHECK_DATABASE(db); QSqlQuery q(db); - QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest"))); + QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest", __FILE__))); QVERIFY_SQL(q, next()); db.open(); - QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest"))); + QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest", __FILE__))); QVERIFY_SQL(q, next()); db.open(); } @@ -2029,10 +2034,10 @@ void tst_QSqlDatabase::odbc_bindBoolean() } QSqlQuery q(db); - QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtestBindBool") + "(id int, boolvalue bit)")); + QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtestBindBool", __FILE__) + "(id int, boolvalue bit)")); // Bind and insert - QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("qtestBindBool") + " VALUES(?, ?)")); + QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("qtestBindBool", __FILE__) + " VALUES(?, ?)")); q.bindValue(0, 1); q.bindValue(1, true); QVERIFY_SQL(q, exec()); @@ -2041,7 +2046,7 @@ void tst_QSqlDatabase::odbc_bindBoolean() QVERIFY_SQL(q, exec()); // Retrive - QVERIFY_SQL(q, exec("SELECT id, boolvalue FROM " + qTableName("qtestBindBool") + " ORDER BY id")); + QVERIFY_SQL(q, exec("SELECT id, boolvalue FROM " + qTableName("qtestBindBool", __FILE__) + " ORDER BY id")); QVERIFY_SQL(q, next()); QCOMPARE(q.value(0).toInt(), 1); QCOMPARE(q.value(1).toBool(), true); @@ -2055,20 +2060,21 @@ void tst_QSqlDatabase::odbc_testqGetString() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString testqGetString(qTableName("testqGetString", __FILE__)); QSqlQuery q(db); if (tst_Databases::isSqlServer(db)) - QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(MAX))")); + QVERIFY_SQL(q, exec("CREATE TABLE " + testqGetString + "(id int, vcvalue varchar(MAX))")); else if(tst_Databases::isMSAccess(db)) - QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue memo)")); + QVERIFY_SQL(q, exec("CREATE TABLE " + testqGetString + "(id int, vcvalue memo)")); else - QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(65538))")); + QVERIFY_SQL(q, exec("CREATE TABLE " + testqGetString + "(id int, vcvalue varchar(65538))")); QString largeString; largeString.fill('A', 65536); // Bind and insert - QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("testqGetString") + " VALUES(?, ?)")); + QVERIFY_SQL(q, prepare("INSERT INTO " + testqGetString + " VALUES(?, ?)")); q.bindValue(0, 1); q.bindValue(1, largeString); QVERIFY_SQL(q, exec()); @@ -2080,7 +2086,7 @@ void tst_QSqlDatabase::odbc_testqGetString() QVERIFY_SQL(q, exec()); // Retrive - QVERIFY_SQL(q, exec("SELECT id, vcvalue FROM " + qTableName("testqGetString") + " ORDER BY id")); + QVERIFY_SQL(q, exec("SELECT id, vcvalue FROM " + testqGetString + " ORDER BY id")); QVERIFY_SQL(q, next()); QCOMPARE(q.value(0).toInt(), 1); QCOMPARE(q.value(1).toString().length(), 65536); @@ -2098,6 +2104,7 @@ void tst_QSqlDatabase::mysql_multiselect() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString qtest(qTableName("qtest", __FILE__)); QSqlQuery q(db); QString version=tst_Databases::getMySqlVersion( db ); @@ -2105,11 +2112,11 @@ void tst_QSqlDatabase::mysql_multiselect() if (ver < 4.1) QSKIP("Test requires MySQL >= 4.1", SkipSingle); - QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtest") + "; SELECT * FROM " + qTableName("qtest"))); + QVERIFY_SQL(q, exec("SELECT * FROM " + qtest + "; SELECT * FROM " + qtest)); QVERIFY_SQL(q, next()); - QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtest") + "; SELECT * FROM " + qTableName("qtest"))); + QVERIFY_SQL(q, exec("SELECT * FROM " + qtest + "; SELECT * FROM " + qtest)); QVERIFY_SQL(q, next()); - QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtest"))); + QVERIFY_SQL(q, exec("SELECT * FROM " + qtest)); } void tst_QSqlDatabase::ibase_useCustomCharset() @@ -2123,7 +2130,7 @@ void tst_QSqlDatabase::ibase_useCustomCharset() db.setConnectOptions("ISC_DPB_LC_CTYPE=Latin1"); db.open(); - QString tableName = qTableName("latin1table"); + const QString tableName(qTableName("latin1table", __FILE__)); QSqlQuery q(db); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(text VARCHAR(6) CHARACTER SET Latin1)").arg(tableName))); @@ -2161,7 +2168,7 @@ void tst_QSqlDatabase::oci_xmltypeSupport() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tableName = qTableName("qtest_xmltype"); + const QString tableName(qTableName("qtest_xmltype", __FILE__)); QString xml("MY_TABLE"); QSqlQuery q(db); @@ -2189,7 +2196,7 @@ void tst_QSqlDatabase::oci_fieldLength() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tableName = qTableName("qtest"); + const QString tableName(qTableName("qtest", __FILE__)); QSqlQuery q(db); QVERIFY_SQL(q, exec(QString("SELECT t_varchar, t_char FROM %1").arg(tableName))); @@ -2205,7 +2212,7 @@ void tst_QSqlDatabase::oci_synonymstest() CHECK_DATABASE(db); QSqlQuery q(db); - QString creator(qTableName("CREATOR")), appuser(qTableName("APPUSER")), table1(qTableName("TABLE1")); + const QString creator(qTableName("CREATOR", __FILE__)), appuser(qTableName("APPUSER", __FILE__)), table1(qTableName("TABLE1", __FILE__)); // QVERIFY_SQL(q, exec("drop public synonym "+table1)); QVERIFY_SQL(q, exec(QString("create user %1 identified by %2 default tablespace users temporary tablespace temp").arg(creator).arg(creator))); QVERIFY_SQL(q, exec(QString("grant CONNECT to %1").arg(creator))); @@ -2223,8 +2230,8 @@ void tst_QSqlDatabase::oci_synonymstest() db3.close(); QVERIFY_SQL(db3, open(appuser,appuser)); QSqlQuery q3(db3); - QVERIFY_SQL(q3, exec("create synonym "+appuser+'.'+qTableName("synonyms")+" for "+creator+'.'+table1)); - QVERIFY_SQL(db3, tables().filter(qTableName("synonyms"), Qt::CaseInsensitive).count() >= 1); + QVERIFY_SQL(q3, exec("create synonym "+appuser+'.'+qTableName("synonyms", __FILE__)+" for "+creator+'.'+table1)); + QVERIFY_SQL(db3, tables().filter(qTableName("synonyms", __FILE__), Qt::CaseInsensitive).count() >= 1); } @@ -2240,7 +2247,7 @@ void tst_QSqlDatabase::odbc_uniqueidentifier() return; } - QString tableName = qTableName("qtest_sqlguid"); + const QString tableName(qTableName("qtest_sqlguid", __FILE__)); QString guid = QString("AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE"); QString invalidGuid = QString("GAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE"); @@ -2283,7 +2290,7 @@ void tst_QSqlDatabase::odbc_uintfield() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tableName = qTableName("uint_table"); + const QString tableName(qTableName("uint_table", __FILE__)); unsigned int val = 4294967295U; QSqlQuery q(db); @@ -2347,7 +2354,7 @@ void tst_QSqlDatabase::eventNotificationIBase() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString procedureName = qTableName("posteventProc"); + const QString procedureName(qTableName("posteventProc", __FILE__)); QSqlDriver *driver=db.driver(); QVERIFY_SQL(*driver, subscribeToNotification(procedureName)); QTest::qWait(300); // Interbase needs some time to call the driver callback. @@ -2381,7 +2388,7 @@ void tst_QSqlDatabase::eventNotificationPSQL() #endif QSqlQuery query(db); - QString procedureName = qTableName("posteventProc"); + QString procedureName = qTableName("posteventProc", __FILE__); QSqlDriver &driver=*(db.driver()); QVERIFY_SQL(driver, subscribeToNotification(procedureName)); @@ -2405,7 +2412,7 @@ void tst_QSqlDatabase::sqlite_bindAndFetchUInt() } QSqlQuery q(db); - QString tableName = qTableName("uint_test"); + const QString tableName(qTableName("uint_test", __FILE__)); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(uint_field UNSIGNED INTEGER)").arg(tableName))); QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 VALUES(?)").arg(tableName))); q.addBindValue(4000000000U); @@ -2425,7 +2432,7 @@ void tst_QSqlDatabase::db2_valueCacheUpdate() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tableName = qTableName("qtest"); + const QString tableName(qTableName("qtest", __FILE__)); QSqlQuery q(db); q.exec(QString("SELECT id, t_varchar, t_char, t_numeric FROM %1").arg(tableName)); q.next(); @@ -2448,7 +2455,7 @@ void tst_QSqlDatabase::sqlStatementUseIsNull_189093() // select a record with NULL value QSqlQuery q(QString::null, db); - QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 4")); + QVERIFY_SQL(q, exec("select * from " + qTableName("qtest", __FILE__) + " where id = 4")); QVERIFY_SQL(q, next()); QSqlDriver *driver = db.driver(); @@ -2471,7 +2478,7 @@ void tst_QSqlDatabase::mysql_savepointtest() QSqlQuery q(db); QVERIFY_SQL(q, exec("begin")); - QVERIFY_SQL(q, exec("insert into "+qTableName("qtest")+" VALUES (54, 'foo', 'foo', 54.54)")); + QVERIFY_SQL(q, exec("insert into "+qTableName("qtest", __FILE__)+" VALUES (54, 'foo', 'foo', 54.54)")); QVERIFY_SQL(q, exec("savepoint foo")); } @@ -2481,7 +2488,7 @@ void tst_QSqlDatabase::oci_tables() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); QSqlQuery q(db); - QString systemTableName("system."+qTableName("mypassword")); + const QString systemTableName("system."+qTableName("mypassword", __FILE__)); QVERIFY_SQL(q, exec("CREATE TABLE "+systemTableName+"(name VARCHAR(20))")); QVERIFY(!db.tables().contains(systemTableName.toUpper())); QVERIFY(db.tables(QSql::SystemTables).contains(systemTableName.toUpper())); @@ -2501,8 +2508,8 @@ void tst_QSqlDatabase::sqlite_enable_cache_mode() db2.setConnectOptions("QSQLITE_ENABLE_SHARED_CACHE"); QVERIFY_SQL(db2, open()); QSqlQuery q(db), q2(db2); - QVERIFY_SQL(q, exec("select * from "+qTableName("qtest"))); - QVERIFY_SQL(q2, exec("select * from "+qTableName("qtest"))); + QVERIFY_SQL(q, exec("select * from "+qTableName("qtest", __FILE__))); + QVERIFY_SQL(q2, exec("select * from "+qTableName("qtest", __FILE__))); } QTEST_MAIN(tst_QSqlDatabase) diff --git a/tests/auto/qsqldriver/tst_qsqldriver.cpp b/tests/auto/qsqldriver/tst_qsqldriver.cpp index 19e4001..f2393ba 100644 --- a/tests/auto/qsqldriver/tst_qsqldriver.cpp +++ b/tests/auto/qsqldriver/tst_qsqldriver.cpp @@ -84,18 +84,19 @@ void tst_QSqlDriver::initTestCase_data() void tst_QSqlDriver::recreateTestTables(QSqlDatabase db) { QSqlQuery q(db); + const QString relTEST1(qTableName("relTEST1", __FILE__)); if(tst_Databases::isPostgreSQL(db)) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - tst_Databases::safeDropTable( db, qTableName( "relTEST1" ) ); + tst_Databases::safeDropTable( db, relTEST1 ); - QVERIFY_SQL( q, exec("create table " + qTableName("relTEST1") + + QVERIFY_SQL( q, exec("create table " + relTEST1 + " (id int not null primary key, name varchar(20), title_key int, another_title_key int)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("relTEST1") + " values(1, 'harry', 1, 2)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("relTEST1") + " values(2, 'trond', 2, 1)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("relTEST1") + " values(3, 'vohi', 1, 2)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("relTEST1") + " values(4, 'boris', 2, 2)")); + QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(1, 'harry', 1, 2)")); + QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(2, 'trond', 2, 1)")); + QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(3, 'vohi', 1, 2)")); + QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(4, 'boris', 2, 2)")); } void tst_QSqlDriver::initTestCase() @@ -108,7 +109,7 @@ void tst_QSqlDriver::cleanupTestCase() { foreach (const QString &dbName, dbs.dbNames) { QSqlDatabase db = QSqlDatabase::database(dbName); - tst_Databases::safeDropTable( db, qTableName( "relTEST1" ) ); + tst_Databases::safeDropTable( db, qTableName( "relTEST1", __FILE__ ) ); } dbs.close(); } @@ -127,7 +128,7 @@ void tst_QSqlDriver::record() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tablename = qTableName("relTEST1"); + QString tablename(qTableName("relTEST1", __FILE__)); QStringList fields; fields << "id" << "name" << "title_key" << "another_title_key"; @@ -180,7 +181,7 @@ void tst_QSqlDriver::primaryIndex() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tablename = qTableName("relTEST1"); + QString tablename(qTableName("relTEST1", __FILE__)); //check that we can get primary index using unquoted mixed case table name QSqlIndex index = db.driver()->primaryIndex(tablename); QCOMPARE(index.count(), 1); diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 5339132..b9ab73f 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -44,6 +44,8 @@ #include "../qsqldatabase/tst_databases.h" +const QString qtest(qTableName( "qtest", __FILE__ )); + //TESTED_FILES= class tst_QSqlQuery : public QObject @@ -295,56 +297,56 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) { QStringList tablenames; // drop all the table in case a testcase failed - tablenames << qTableName( "qtest" ) - << qTableName( "qtest_null" ) - << qTableName( "qtest_blob" ) - << qTableName( "qtest_bittest" ) - << qTableName( "qtest_nullblob" ) - << qTableName( "qtest_rawtest" ) - << qTableName( "qtest_precision" ) - << qTableName( "qtest_prepare" ) - << qTableName( "qtestj1" ) - << qTableName( "qtestj2" ) - << qTableName( "char1Select" ) - << qTableName( "char1SelectUnicode" ) - << qTableName( "qxmltest" ) - << qTableName( "qtest_exerr" ) - << qTableName( "qtest_empty" ) - << qTableName( "clobby" ) - << qTableName( "bindtest" ) - << qTableName( "more_results" ) - << qTableName( "blobstest" ) - << qTableName( "oraRowId" ) - << qTableName( "qtest_batch" ) - << qTableName("bug6421").toUpper() - << qTableName("bug5765") - << qTableName("bug6852") - << qTableName( "qtest_lockedtable" ) - << qTableName( "Planet" ) - << qTableName( "task_250026" ) - << qTableName( "task_234422" ) - << qTableName("test141895"); + tablenames << qtest + << qTableName( "qtest_null", __FILE__ ) + << qTableName( "qtest_blob", __FILE__ ) + << qTableName( "qtest_bittest", __FILE__ ) + << qTableName( "qtest_nullblob", __FILE__ ) + << qTableName( "qtest_rawtest", __FILE__ ) + << qTableName( "qtest_precision", __FILE__ ) + << qTableName( "qtest_prepare", __FILE__ ) + << qTableName( "qtestj1", __FILE__ ) + << qTableName( "qtestj2", __FILE__ ) + << qTableName( "char1Select", __FILE__ ) + << qTableName( "char1SU", __FILE__ ) + << qTableName( "qxmltest", __FILE__ ) + << qTableName( "qtest_exerr", __FILE__ ) + << qTableName( "qtest_empty", __FILE__ ) + << qTableName( "clobby", __FILE__ ) + << qTableName( "bindtest", __FILE__ ) + << qTableName( "more_results", __FILE__ ) + << qTableName( "blobstest", __FILE__ ) + << qTableName( "oraRowId", __FILE__ ) + << qTableName( "qtest_batch", __FILE__ ) + << qTableName("bug6421", __FILE__).toUpper() + << qTableName("bug5765", __FILE__) + << qTableName("bug6852", __FILE__) + << qTableName( "qtest_lockedtable", __FILE__ ) + << qTableName( "Planet", __FILE__ ) + << qTableName( "task_250026", __FILE__ ) + << qTableName( "task_234422", __FILE__ ) + << qTableName("test141895", __FILE__); if ( db.driverName().startsWith("QPSQL") ) - tablenames << qTableName("task_233829"); + tablenames << qTableName("task_233829", __FILE__); if ( db.driverName().startsWith("QSQLITE") ) - tablenames << qTableName( "record_sqlite" ); + tablenames << qTableName( "record_sqlite", __FILE__ ); if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QOCI" ) ) - tablenames << qTableName( "qtest_longstr" ); + tablenames << qTableName( "qtest_longstr", __FILE__ ); if (tst_Databases::isSqlServer( db )) - db.exec("DROP PROCEDURE " + qTableName("test141895_proc")); + db.exec("DROP PROCEDURE " + qTableName("test141895_proc", __FILE__)); if (tst_Databases::isMySQL( db )) - db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc")); + db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc", __FILE__)); tst_Databases::safeDropTables( db, tablenames ); if ( db.driverName().startsWith( "QOCI" ) ) { QSqlQuery q( db ); - q.exec( "DROP PACKAGE " + qTableName("pkg") ); + q.exec( "DROP PACKAGE " + qTableName("pkg", __FILE__) ); } } @@ -360,31 +362,32 @@ void tst_QSqlQuery::createTestTables( QSqlDatabase db ) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); if(tst_Databases::isPostgreSQL(db)) - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest" ) + " (id serial NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id)) WITH OIDS" ) ); + QVERIFY_SQL( q, exec( "create table " + qtest + " (id serial NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id)) WITH OIDS" ) ); else - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest" ) + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) ); + QVERIFY_SQL( q, exec( "create table " + qtest + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) ); if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) ) - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null" ) + " (id int null, t_varchar varchar(20) null)" ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null", __FILE__ ) + " (id int null, t_varchar varchar(20) null)" ) ); else - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null" ) + " (id int, t_varchar varchar(20))" ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null", __FILE__ ) + " (id int, t_varchar varchar(20))" ) ); } void tst_QSqlQuery::populateTestTables( QSqlDatabase db ) { QSqlQuery q( db ); - q.exec( "delete from " + qTableName( "qtest" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (1, 'VarChar1', 'Char1')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (2, 'VarChar2', 'Char2')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (3, 'VarChar3', 'Char3')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (4, 'VarChar4', 'Char4')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (5, 'VarChar5', 'Char5')" ) ); + const QString qtest_null(qTableName( "qtest_null", __FILE__ )); + q.exec( "delete from " + qtest ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (1, 'VarChar1', 'Char1')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (2, 'VarChar2', 'Char2')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (3, 'VarChar3', 'Char3')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (4, 'VarChar4', 'Char4')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (5, 'VarChar5', 'Char5')" ) ); - q.exec( "delete from " + qTableName( "qtest_null" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_null" ) + " values (0, NULL)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_null" ) + " values (1, 'n')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_null" ) + " values (2, 'i')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_null" ) + " values (3, NULL)" ) ); + q.exec( "delete from " + qtest_null ); + QVERIFY_SQL( q, exec( "insert into " + qtest_null + " values (0, NULL)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_null + " values (1, 'n')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_null + " values (2, 'i')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_null + " values (3, NULL)" ) ); } // There were problems with char fields of size 1 @@ -396,9 +399,9 @@ void tst_QSqlQuery::char1Select() { QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "char1Select" ) + " (id char(1))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "char1Select" ) + " values ('a')" ) ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "char1Select" ) ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "char1Select", __FILE__ ) + " (id char(1))" ) ); + QVERIFY_SQL( q, exec( "insert into " + qTableName( "char1Select", __FILE__ ) + " values ('a')" ) ); + QVERIFY_SQL( q, exec( "select * from " + qTableName( "char1Select", __FILE__ ) ) ); QVERIFY( q.next() ); if ( db.driverName().startsWith( "QIBASE" ) ) @@ -427,31 +430,32 @@ void tst_QSqlQuery::char1SelectUnicode() QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); QString createQuery; + const QString char1SelectUnicode(qTableName( "char1SU", __FILE__ )); if ( tst_Databases::isSqlServer( db ) ) - createQuery = "create table " + qTableName( "char1SelectUnicode" ) + "(id nchar(1))"; + createQuery = "create table " + char1SelectUnicode + "(id nchar(1))"; else if ( db.driverName().startsWith( "QDB2" ) || db.driverName().startsWith( "QOCI" ) || db.driverName().startsWith( "QPSQL" ) ) - createQuery = "create table " + qTableName( "char1SelectUnicode" ) + " (id char(3))"; + createQuery = "create table " + char1SelectUnicode + " (id char(3))"; else if ( db.driverName().startsWith( "QIBASE" ) ) - createQuery = "create table " + qTableName( "char1SelectUnicode" ) + + createQuery = "create table " + char1SelectUnicode + " (id char(1) character set unicode_fss)"; else if ( db.driverName().startsWith( "QMYSQL" ) ) - createQuery = "create table " + qTableName( "char1SelectUnicode" ) + " (id char(1)) " + createQuery = "create table " + char1SelectUnicode + " (id char(1)) " "default character set 'utf8'"; else - createQuery = "create table " + qTableName( "char1SelectUnicode" ) + " (id char(1))"; + createQuery = "create table " + char1SelectUnicode + " (id char(1))"; QVERIFY_SQL( q, exec( createQuery ) ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "char1SelectUnicode" ) + " values(?)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + char1SelectUnicode + " values(?)" ) ); q.bindValue( 0, uniStr ); QVERIFY_SQL( q, exec() ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "char1SelectUnicode" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + char1SelectUnicode ) ); QVERIFY( q.next() ); @@ -471,24 +475,25 @@ void tst_QSqlQuery::oraRowId() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString oraRowId(qTableName("oraRowId", __FILE__)); QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "select rowid from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select rowid from " + qtest ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).type(), QVariant::String ); QVERIFY( !q.value( 0 ).toString().isEmpty() ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "oraRowId" ) + " (id char(1))" ) ); + QVERIFY_SQL( q, exec( "create table " + oraRowId + " (id char(1))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "oraRowId" ) + " values('a')" ) ); + QVERIFY_SQL( q, exec( "insert into " + oraRowId + " values('a')" ) ); QVariant v1 = q.lastInsertId(); QVERIFY( v1.isValid() ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "oraRowId" ) + " values('b')" ) ); + QVERIFY_SQL( q, exec( "insert into " + oraRowId + " values('b')" ) ); QVariant v2 = q.lastInsertId(); QVERIFY( v2.isValid() ); - QVERIFY_SQL( q, prepare( "select * from " + qTableName( "oraRowId" ) + " where rowid = ?" ) ); + QVERIFY_SQL( q, prepare( "select * from " + oraRowId + " where rowid = ?" ) ); q.addBindValue( v1 ); QVERIFY_SQL( q, exec() ); QVERIFY( q.next() ); @@ -505,49 +510,50 @@ void tst_QSqlQuery::mysqlOutValues() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString hello(qTableName( "hello", __FILE__ )), qtestproc(qTableName( "qtestproc", __FILE__ )); QSqlQuery q( db ); if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 ) QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); - q.exec( "drop function " + qTableName( "hello" ) ); + q.exec( "drop function " + hello ); - QVERIFY_SQL( q, exec( "create function " + qTableName( "hello" ) + " (s char(20)) returns varchar(50) return concat('Hello ', s)" ) ); + QVERIFY_SQL( q, exec( "create function " + hello + " (s char(20)) returns varchar(50) return concat('Hello ', s)" ) ); - QVERIFY_SQL( q, exec( "select " + qTableName( "hello" ) + "('world')" ) ); + QVERIFY_SQL( q, exec( "select " + hello + "('world')" ) ); QVERIFY_SQL( q, next() ); QCOMPARE( q.value( 0 ).toString(), QString( "Hello world" ) ); - QVERIFY_SQL( q, prepare( "select " + qTableName( "hello" ) + "('harald')" ) ); + QVERIFY_SQL( q, prepare( "select " + hello + "('harald')" ) ); QVERIFY_SQL( q, exec() ); QVERIFY_SQL( q, next() ); QCOMPARE( q.value( 0 ).toString(), QString( "Hello harald" ) ); - QVERIFY_SQL( q, exec( "drop function " + qTableName( "hello" ) ) ); + QVERIFY_SQL( q, exec( "drop function " + hello ) ); - q.exec( "drop procedure " + qTableName( "qtestproc" ) ); + q.exec( "drop procedure " + qtestproc ); - QVERIFY_SQL( q, exec( "create procedure " + qTableName( "qtestproc" ) + " () " - "BEGIN select * from " + qTableName( "qtest" ) + " order by id; END" ) ); - QVERIFY_SQL( q, exec( "call " + qTableName( "qtestproc" ) + "()" ) ); + QVERIFY_SQL( q, exec( "create procedure " + qtestproc + " () " + "BEGIN select * from " + qtest + " order by id; END" ) ); + QVERIFY_SQL( q, exec( "call " + qtestproc + "()" ) ); QVERIFY_SQL( q, next() ); QCOMPARE( q.value( 1 ).toString(), QString( "VarChar1" ) ); - QVERIFY_SQL( q, exec( "drop procedure " + qTableName( "qtestproc" ) ) ); + QVERIFY_SQL( q, exec( "drop procedure " + qtestproc ) ); - QVERIFY_SQL( q, exec( "create procedure " + qTableName( "qtestproc" ) + " (OUT param1 INT) " + QVERIFY_SQL( q, exec( "create procedure " + qtestproc + " (OUT param1 INT) " "BEGIN set param1 = 42; END" ) ); - QVERIFY_SQL( q, exec( "call " + qTableName( "qtestproc" ) + " (@out)" ) ); + QVERIFY_SQL( q, exec( "call " + qtestproc + " (@out)" ) ); QVERIFY_SQL( q, exec( "select @out" ) ); QCOMPARE( q.record().fieldName( 0 ), QString( "@out" ) ); QVERIFY_SQL( q, next() ); QCOMPARE( q.value( 0 ).toInt(), 42 ); - QVERIFY_SQL( q, exec( "drop procedure " + qTableName( "qtestproc" ) ) ); + QVERIFY_SQL( q, exec( "drop procedure " + qtestproc ) ); } void tst_QSqlQuery::oraOutValues() @@ -555,6 +561,7 @@ void tst_QSqlQuery::oraOutValues() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString tst_outValues(qTableName("tst_outValues", __FILE__)); if ( !db.driver()->hasFeature( QSqlDriver::PreparedQueries ) ) { QSKIP( "Test requires prepared query support", SkipSingle ); @@ -566,11 +573,11 @@ void tst_QSqlQuery::oraOutValues() q.setForwardOnly( true ); /*** outvalue int ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x out int) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x out int) is\n" "begin\n" " x := 42;\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); q.addBindValue( 0, QSql::Out ); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValue( 0 ).toInt(), 42 ); @@ -582,11 +589,11 @@ void tst_QSqlQuery::oraOutValues() QVERIFY( !q.boundValue( 0 ).isNull() ); /*** outvalue varchar ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x out varchar) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x out varchar) is\n" "begin\n" " x := 'blah';\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); QString s1( "12345" ); s1.reserve( 512 ); q.addBindValue( s1, QSql::Out ); @@ -594,51 +601,51 @@ void tst_QSqlQuery::oraOutValues() QCOMPARE( q.boundValue( 0 ).toString(), QString( "blah" ) ); /*** in/outvalue numeric ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x in out numeric) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x in out numeric) is\n" "begin\n" " x := x + 10;\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); q.addBindValue( 10, QSql::Out ); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValue( 0 ).toInt(), 20 ); /*** in/outvalue varchar ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x in out varchar) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x in out varchar) is\n" "begin\n" " x := 'homer';\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); q.addBindValue( QString( "maggy" ), QSql::Out ); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValue( 0 ).toString(), QString( "homer" ) ); /*** in/outvalue varchar ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x in out varchar) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x in out varchar) is\n" "begin\n" " x := NULL;\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); q.addBindValue( QString( "maggy" ), QSql::Out ); QVERIFY_SQL( q, exec() ); QVERIFY( q.boundValue( 0 ).isNull() ); /*** in/outvalue int ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x in out int) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x in out int) is\n" "begin\n" " x := NULL;\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); q.addBindValue( 42, QSql::Out ); QVERIFY_SQL( q, exec() ); QVERIFY( q.boundValue( 0 ).isNull() ); /*** in/outvalue varchar ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x in varchar, y out varchar) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x in varchar, y out varchar) is\n" "begin\n" " y := x||'bubulalakikikokololo';\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?, ?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?, ?)" ) ); q.addBindValue( QString( "fifi" ), QSql::In ); QString out; out.reserve( 50 ); @@ -652,30 +659,31 @@ void tst_QSqlQuery::oraClob() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString clobby(qTableName("clobby", __FILE__)); QSqlQuery q( db ); // simple short string - QVERIFY_SQL( q, exec( "create table " + qTableName( "clobby" ) + "(id int primary key, cl clob, bl blob)" ) ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "clobby" ) + " (id, cl, bl) values(?, ?, ?)" ) ); + QVERIFY_SQL( q, exec( "create table " + clobby + "(id int primary key, cl clob, bl blob)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + clobby + " (id, cl, bl) values(?, ?, ?)" ) ); q.addBindValue( 1 ); q.addBindValue( "bubu" ); q.addBindValue( QByteArray("bubu") ); QVERIFY_SQL( q, exec() ); - QVERIFY_SQL( q, exec( "select bl, cl from " + qTableName( "clobby" ) + " where id = 1" ) ); + QVERIFY_SQL( q, exec( "select bl, cl from " + clobby + " where id = 1" ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toString(), QString( "bubu" ) ); QCOMPARE( q.value( 1 ).toString(), QString( "bubu" ) ); // simple short string with binding - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "clobby" ) + " (id, cl, bl) values(?, ?, ?)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + clobby + " (id, cl, bl) values(?, ?, ?)" ) ); q.addBindValue( 2 ); q.addBindValue( "lala", QSql::Binary ); q.addBindValue( QByteArray("lala"), QSql::Binary ); QVERIFY_SQL( q, exec() ); - QVERIFY_SQL( q, exec( "select bl, cl from " + qTableName( "clobby" ) + " where id = 2" ) ); + QVERIFY_SQL( q, exec( "select bl, cl from " + clobby + " where id = 2" ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toString(), QString( "lala" ) ); QCOMPARE( q.value( 1 ).toString(), QString( "lala" ) ); @@ -683,13 +691,13 @@ void tst_QSqlQuery::oraClob() // loooong string QString loong; loong.fill( QLatin1Char( 'A' ), 25000 ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "clobby" ) + " (id, cl, bl) values(?, ?, ?)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + clobby + " (id, cl, bl) values(?, ?, ?)" ) ); q.addBindValue( 3 ); q.addBindValue( loong, QSql::Binary ); q.addBindValue( loong.toLatin1(), QSql::Binary ); QVERIFY_SQL( q, exec() ); - QVERIFY_SQL( q, exec( "select bl, cl from " + qTableName( "clobby" ) + " where id = 3" ) ); + QVERIFY_SQL( q, exec( "select bl, cl from " + clobby + " where id = 3" ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toString().count(), loong.count() ); QVERIFY( q.value( 0 ).toString() == loong ); @@ -704,16 +712,16 @@ void tst_QSqlQuery::storedProceduresIBase() CHECK_DATABASE( db ); QSqlQuery q( db ); - q.exec( "drop procedure " + qTableName( "TESTPROC" ) ); + q.exec( "drop procedure " + qTableName( "TESTPROC", __FILE__ ) ); - QVERIFY_SQL( q, exec( "create procedure " + qTableName( "TESTPROC" ) + + QVERIFY_SQL( q, exec( "create procedure " + qTableName( "TESTPROC", __FILE__ ) + " RETURNS (x integer, y varchar(20)) " "AS BEGIN " " x = 42; " " y = 'Hello Anders'; " "END" ) ); - QVERIFY_SQL( q, prepare( "execute procedure " + qTableName( "TestProc" ) ) ); + QVERIFY_SQL( q, prepare( "execute procedure " + qTableName( "TestProc", __FILE__ ) ) ); QVERIFY_SQL( q, exec() ); // check for a valid result set @@ -730,7 +738,7 @@ void tst_QSqlQuery::storedProceduresIBase() // the second next shall fail QVERIFY( !q.next() ); - q.exec( "drop procedure " + qTableName( "TestProc" ) ); + q.exec( "drop procedure " + qTableName( "TestProc", __FILE__ ) ); } void tst_QSqlQuery::outValuesDB2() @@ -748,8 +756,8 @@ void tst_QSqlQuery::outValuesDB2() q.setForwardOnly( true ); - q.exec( "drop procedure " + qTableName( "tst_outValues" ) ); //non-fatal - QVERIFY_SQL( q, exec( "CREATE PROCEDURE " + qTableName( "tst_outValues" ) + + q.exec( "drop procedure " + qTableName( "tst_outValues", __FILE__ ) ); //non-fatal + QVERIFY_SQL( q, exec( "CREATE PROCEDURE " + qTableName( "tst_outValues", __FILE__ ) + " (OUT x int, OUT x2 double, OUT x3 char(20))\n" "LANGUAGE SQL\n" "P1: BEGIN\n" @@ -758,7 +766,7 @@ void tst_QSqlQuery::outValuesDB2() " SET x3 = 'Homer';\n" "END P1" ) ); - QVERIFY_SQL( q, prepare( "call " + qTableName( "tst_outValues" ) + "(?, ?, ?)" ) ); + QVERIFY_SQL( q, prepare( "call " + qTableName( "tst_outValues", __FILE__ ) + "(?, ?, ?)" ) ); q.addBindValue( 0, QSql::Out ); q.addBindValue( 0.0, QSql::Out ); @@ -776,6 +784,7 @@ void tst_QSqlQuery::outValues() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString tst_outValues(qTableName("tst_outValues", __FILE__)); if ( !db.driver()->hasFeature( QSqlDriver::PreparedQueries ) ) { QSKIP( "Test requires prepared query support", SkipSingle ); @@ -787,26 +796,26 @@ void tst_QSqlQuery::outValues() q.setForwardOnly( true ); if ( db.driverName().startsWith( "QOCI" ) ) { - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x out int) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x out int) is\n" "begin\n" " x := 42;\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); } else if ( db.driverName().startsWith( "QDB2" ) ) { - q.exec( "drop procedure " + qTableName( "tst_outValues" ) ); //non-fatal - QVERIFY_SQL( q, exec( "CREATE PROCEDURE " + qTableName( "tst_outValues" ) + " (OUT x int)\n" + q.exec( "drop procedure " + tst_outValues ); //non-fatal + QVERIFY_SQL( q, exec( "CREATE PROCEDURE " + tst_outValues + " (OUT x int)\n" "LANGUAGE SQL\n" "P1: BEGIN\n" " SET x = 42;\n" "END P1" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outValues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); } else if ( tst_Databases::isSqlServer( db ) ) { - q.exec( "drop procedure " + qTableName( "tst_outValues" ) ); //non-fatal - QVERIFY_SQL( q, exec( "create procedure " + qTableName( "tst_outValues" ) + " (@x int out) as\n" + q.exec( "drop procedure " + tst_outValues ); //non-fatal + QVERIFY_SQL( q, exec( "create procedure " + tst_outValues + " (@x int out) as\n" "begin\n" " set @x = 42\n" "end\n" ) ); - QVERIFY( q.prepare( "{call " + qTableName( "tst_outvalues" ) + "(?)}" ) ); + QVERIFY( q.prepare( "{call " + tst_outValues + "(?)}" ) ); } else { QSKIP( "Don't know how to create a stored procedure for this database server, please fix this test", SkipSingle ); return; @@ -843,11 +852,11 @@ void tst_QSqlQuery::blob() q.setForwardOnly( true ); - QString queryString = QString( "create table " + qTableName( "qtest_blob" ) + + QString queryString = QString( "create table " + qTableName( "qtest_blob", __FILE__ ) + " (id int not null primary key, t_blob %1)" ).arg( tst_Databases::blobTypeName( db, BLOBSIZE ) ); QVERIFY_SQL( q, exec( queryString ) ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_blob" ) + " (id, t_blob) values (?, ?)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_blob", __FILE__ ) + " (id, t_blob) values (?, ?)" ) ); for ( i = 0; i < BLOBCOUNT; ++i ) { q.addBindValue( i ); @@ -855,7 +864,7 @@ void tst_QSqlQuery::blob() QVERIFY_SQL( q, exec() ); } - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_blob" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_blob", __FILE__ ) ) ); for ( i = 0; i < BLOBCOUNT; ++i ) { QVERIFY( q.next() ); @@ -878,7 +887,7 @@ void tst_QSqlQuery::value() CHECK_DATABASE( db ); QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qTableName( "qtest" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qtest + " order by id" ) ); int i = 1; while ( q.next() ) { @@ -910,7 +919,7 @@ void tst_QSqlQuery::record() QSqlQuery q( db ); QVERIFY( q.record().isEmpty() ); - QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qTableName( "qtest" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qtest + " order by id" ) ); QSqlRecord rec = q.record(); QCOMPARE( q.record().fieldName( 0 ).toLower(), QString( "id" ) ); QCOMPARE( q.record().fieldName( 1 ).toLower(), QString( "t_varchar" ) ); @@ -934,7 +943,7 @@ void tst_QSqlQuery::isValid() QSqlQuery q( db ); QVERIFY( !q.isValid() ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.first() ); QVERIFY( q.isValid() ); } @@ -947,7 +956,7 @@ void tst_QSqlQuery::isActive() QSqlQuery q( db ); QVERIFY( !q.isActive() ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.isActive() ); QVERIFY( q.last() ); @@ -957,15 +966,15 @@ void tst_QSqlQuery::isActive() QVERIFY( q.isActive() ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (41, 'VarChar41', 'Char41')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (41, 'VarChar41', 'Char41')" ) ); QVERIFY( q.isActive() ); - QVERIFY_SQL( q, exec( "update " + qTableName( "qtest" ) + " set id = 42 where id = 41" ) ); + QVERIFY_SQL( q, exec( "update " + qtest + " set id = 42 where id = 41" ) ); QVERIFY( q.isActive() ); - QVERIFY_SQL( q, exec( "delete from " + qTableName( "qtest" ) + " where id = 42" ) ); + QVERIFY_SQL( q, exec( "delete from " + qtest + " where id = 42" ) ); QVERIFY( q.isActive() ); } @@ -979,7 +988,7 @@ void tst_QSqlQuery::numRowsAffected() QSqlQuery q( db ); QCOMPARE( q.numRowsAffected(), -1 ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); int i = 0; while ( q.next() ) @@ -993,21 +1002,21 @@ void tst_QSqlQuery::numRowsAffected() qDebug( "Expected numRowsAffected to be -1, 0 or %d, got %d", i, q.numRowsAffected() ); } - QVERIFY_SQL( q, exec( "update " + qTableName( "qtest" ) + " set id = 100 where id = 1" ) ); + QVERIFY_SQL( q, exec( "update " + qtest + " set id = 100 where id = 1" ) ); QCOMPARE( q.numRowsAffected(), 1 ); QCOMPARE( q.numRowsAffected(), 1 ); // yes, we check twice - QVERIFY_SQL( q, exec( "update " + qTableName( "qtest" ) + " set id = id + 100" ) ); + QVERIFY_SQL( q, exec( "update " + qtest + " set id = id + 100" ) ); QCOMPARE( q.numRowsAffected(), i ); QCOMPARE( q.numRowsAffected(), i ); // yes, we check twice - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (42000, 'homer', 'marge')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (42000, 'homer', 'marge')" ) ); QCOMPARE( q.numRowsAffected(), 1 ); QCOMPARE( q.numRowsAffected(), 1 ); // yes, we check twice QSqlQuery q2( db ); - QVERIFY_SQL( q2, exec( "insert into " + qTableName( "qtest" ) + " values (42001, 'homer', 'marge')" ) ); + QVERIFY_SQL( q2, exec( "insert into " + qtest + " values (42001, 'homer', 'marge')" ) ); if ( !db.driverName().startsWith( "QSQLITE2" ) ) { // SQLite 2.x accumulates changed rows in nested queries. See task 33794 @@ -1025,7 +1034,7 @@ void tst_QSqlQuery::size() QSqlQuery q( db ); QCOMPARE( q.size(), -1 ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); int i = 0; while ( q.next() ) @@ -1039,7 +1048,7 @@ void tst_QSqlQuery::size() QCOMPARE( q.size(), -1 ); // yes, twice } - QSqlQuery q2( "select * from " + qTableName( "qtest" ), db ); + QSqlQuery q2( "select * from " + qtest, db ); if ( db.driver()->hasFeature( QSqlDriver::QuerySize ) ) QCOMPARE( q.size(), i ); @@ -1048,7 +1057,7 @@ void tst_QSqlQuery::size() q2.clear(); - QVERIFY_SQL( q, exec( "update " + qTableName( "qtest" ) + " set id = 100 where id = 1" ) ); + QVERIFY_SQL( q, exec( "update " + qtest + " set id = 100 where id = 1" ) ); QCOMPARE( q.size(), -1 ); QCOMPARE( q.size(), -1 ); // yes, twice } @@ -1060,10 +1069,10 @@ void tst_QSqlQuery::isSelect() CHECK_DATABASE( db ); QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.isSelect() ); - QVERIFY_SQL( q, exec( "update " + qTableName( "qtest" ) + " set id = 1 where id = 1" ) ); + QVERIFY_SQL( q, exec( "update " + qtest + " set id = 1 where id = 1" ) ); QVERIFY( q.isSelect() == false ); } @@ -1075,7 +1084,7 @@ void tst_QSqlQuery::first() QSqlQuery q( db ); QVERIFY( q.at() == QSql::BeforeFirstRow ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.last() ); QVERIFY_SQL( q, first() ); QVERIFY( q.at() == 0 ); @@ -1089,7 +1098,7 @@ void tst_QSqlQuery::next() QSqlQuery q( db ); QVERIFY( q.at() == QSql::BeforeFirstRow ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.first() ); QVERIFY( q.next() ); QVERIFY( q.at() == 1 ); @@ -1103,7 +1112,7 @@ void tst_QSqlQuery::prev() QSqlQuery q( db ); QVERIFY( q.at() == QSql::BeforeFirstRow ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.first() ); QVERIFY( q.next() ); QVERIFY( q.previous() ); @@ -1118,7 +1127,7 @@ void tst_QSqlQuery::last() QSqlQuery q( db ); QCOMPARE( q.at(), int( QSql::BeforeFirstRow ) ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); int i = 0; while ( q.next() ) @@ -1132,7 +1141,7 @@ void tst_QSqlQuery::last() // Access doesn't return the correct position QCOMPARE( q.at(), ( i-1 ) ); - QSqlQuery q2( "select * from " + qTableName( "qtest" ), db ); + QSqlQuery q2( "select * from " + qtest, db ); QVERIFY( q2.last() ); @@ -1148,7 +1157,7 @@ void tst_QSqlQuery::seek() CHECK_DATABASE( db ); QSqlQuery q( db ); QVERIFY( q.at() == QSql::BeforeFirstRow ); - QVERIFY_SQL( q, exec( QString( "select id from %1 order by id" ).arg( qTableName( "qtest" ) ) ) ); + QVERIFY_SQL( q, exec( QString( "select id from %1 order by id" ).arg( qtest ) ) ); // NB! The order of the calls below are important! QVERIFY( q.last() ); @@ -1184,7 +1193,7 @@ void tst_QSqlQuery::seekForwardOnlyQuery() QVERIFY( !q.isForwardOnly() ); QVERIFY( q.at() == QSql::BeforeFirstRow ); - QVERIFY_SQL( q, exec( QString( "select id from %1 order by id" ).arg( qTableName( "qtest" ) ) ) ); + QVERIFY_SQL( q, exec( QString( "select id from %1 order by id" ).arg( qtest ) ) ); QSqlRecord rec; @@ -1223,7 +1232,7 @@ void tst_QSqlQuery::forwardOnly() q.setForwardOnly( true ); QVERIFY( q.isForwardOnly() ); QVERIFY( q.at() == QSql::BeforeFirstRow ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest + " order by id" ) ); QVERIFY( q.at() == QSql::BeforeFirstRow ); QVERIFY( q.first() ); QCOMPARE( q.at(), 0 ); @@ -1248,7 +1257,7 @@ void tst_QSqlQuery::forwardOnly() QCOMPARE( q.at(), 3 ); QCOMPARE( q.value( 0 ).toInt(), 4 ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); int i = 0; while ( q.next() ) @@ -1260,7 +1269,7 @@ void tst_QSqlQuery::forwardOnly() QVERIFY( q2.isForwardOnly() ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest + " order by id" ) ); QVERIFY( q.isForwardOnly() ); @@ -1306,7 +1315,7 @@ void tst_QSqlQuery::query_exec() QSqlQuery q( db ); QVERIFY( !q.isValid() ); QVERIFY( !q.isActive() ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.isActive() ); QVERIFY( q.next() ); QVERIFY( q.isValid() ); @@ -1319,7 +1328,7 @@ void tst_QSqlQuery::isNull() CHECK_DATABASE( db ); QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "select id, t_varchar from " + qTableName( "qtest_null" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "select id, t_varchar from " + qTableName( "qtest_null", __FILE__ ) + " order by id" ) ); QVERIFY( q.next() ); QVERIFY( !q.isNull( 0 ) ); QVERIFY( q.isNull( 1 ) ); @@ -1345,13 +1354,13 @@ void tst_QSqlQuery::bitField() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_bittest" ) + " (bitty bit)" ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_bittest", __FILE__ ) + " (bitty bit)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_bittest" ) + " values (0)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_bittest", __FILE__ ) + " values (0)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_bittest" ) + " values (1)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_bittest", __FILE__ ) + " values (1)" ) ); - QVERIFY_SQL( q, exec( "select bitty from " + qTableName( "qtest_bittest" ) ) ); + QVERIFY_SQL( q, exec( "select bitty from " + qTableName( "qtest_bittest", __FILE__ ) ) ); QVERIFY( q.next() ); @@ -1369,15 +1378,16 @@ void tst_QSqlQuery::nullBlob() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString qtest_nullblob(qTableName("qtest_nullblob", __FILE__)); QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_nullblob" ) + " (id int primary key, bb blob)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_nullblob" ) + " values (0, EMPTY_BLOB())" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_nullblob" ) + " values (1, NULL)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_nullblob" ) + " values (2, 'aabbcc00112233445566')" ) ); + QVERIFY_SQL( q, exec( "create table " + qtest_nullblob + " (id int primary key, bb blob)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_nullblob + " values (0, EMPTY_BLOB())" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_nullblob + " values (1, NULL)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_nullblob + " values (2, 'aabbcc00112233445566')" ) ); // necessary otherwise oracle will bombard you with internal errors q.setForwardOnly( true ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_nullblob" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest_nullblob + " order by id" ) ); QVERIFY( q.next() ); QCOMPARE(( int )q.value( 1 ).toByteArray().size(), 0 ); @@ -1398,14 +1408,15 @@ void tst_QSqlQuery::rawField() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString qtest_rawtest(qTableName("qtest_rawtest", __FILE__)); QSqlQuery q( db ); q.setForwardOnly( true ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_rawtest" ) + + QVERIFY_SQL( q, exec( "create table " + qtest_rawtest + " (id int, col raw(20))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_rawtest" ) + " values (0, NULL)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_rawtest" ) + " values (1, '00aa1100ddeeff')" ) ); - QVERIFY_SQL( q, exec( "select col from " + qTableName( "qtest_rawtest" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_rawtest + " values (0, NULL)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_rawtest + " values (1, '00aa1100ddeeff')" ) ); + QVERIFY_SQL( q, exec( "select col from " + qtest_rawtest + " order by id" ) ); QVERIFY( q.next() ); QVERIFY( q.isNull( 0 ) ); QCOMPARE(( int )q.value( 0 ).toByteArray().size(), 0 ); @@ -1422,6 +1433,7 @@ void tst_QSqlQuery::precision() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString qtest_precision(qTableName( "qtest_precision", __FILE__ )); static const char* precStr = "1.2345678901234567891"; @@ -1433,13 +1445,13 @@ void tst_QSqlQuery::precision() QSqlQuery q( db ); if ( tst_Databases::isMSAccess( db ) ) - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_precision" ) + " (col1 number)" ) ); + QVERIFY_SQL( q, exec( "create table " + qtest_precision + " (col1 number)" ) ); else - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_precision" ) + " (col1 numeric(21, 20))" ) ); + QVERIFY_SQL( q, exec( "create table " + qtest_precision + " (col1 numeric(21, 20))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_precision" ) + " (col1) values (1.2345678901234567891)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_precision + " (col1) values (1.2345678901234567891)" ) ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_precision" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest_precision ) ); QVERIFY( q.next() ); QString val = q.value( 0 ).toString(); @@ -1472,7 +1484,7 @@ void tst_QSqlQuery::nullResult() CHECK_DATABASE( db ); QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) + " where id > 50000" ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest + " where id > 50000" ) ); if ( q.driver()->hasFeature( QSqlDriver::QuerySize ) ) QCOMPARE( q.size(), 0 ); @@ -1513,9 +1525,9 @@ void tst_QSqlQuery::transaction() // test a working transaction q.exec( startTransactionStr ); - QVERIFY_SQL( q, exec( "insert into" + qTableName( "qtest" ) + " values (40, 'VarChar40', 'Char40')" ) ); + QVERIFY_SQL( q, exec( "insert into" + qtest + " values (40, 'VarChar40', 'Char40')" ) ); - QVERIFY_SQL( q, exec( "select * from" + qTableName( "qtest" ) + " where id = 40" ) ); + QVERIFY_SQL( q, exec( "select * from" + qtest + " where id = 40" ) ); QVERIFY( q.next() ); @@ -1523,7 +1535,7 @@ void tst_QSqlQuery::transaction() QVERIFY_SQL( q, exec( "commit" ) ); - QVERIFY_SQL( q, exec( "select * from" + qTableName( "qtest" ) + " where id = 40" ) ); + QVERIFY_SQL( q, exec( "select * from" + qtest + " where id = 40" ) ); QVERIFY( q.next() ); @@ -1532,9 +1544,9 @@ void tst_QSqlQuery::transaction() // test a rollback q.exec( startTransactionStr ); - QVERIFY_SQL( q, exec( "insert into" + qTableName( "qtest" ) + " values (41, 'VarChar41', 'Char41')" ) ); + QVERIFY_SQL( q, exec( "insert into" + qtest + " values (41, 'VarChar41', 'Char41')" ) ); - QVERIFY_SQL( q, exec( "select * from" + qTableName( "qtest" ) + " where id = 41" ) ); + QVERIFY_SQL( q, exec( "select * from" + qtest + " where id = 41" ) ); QVERIFY( q.next() ); @@ -1548,18 +1560,18 @@ void tst_QSqlQuery::transaction() QFAIL( "Could not rollback transaction: " + tst_Databases::printError( q.lastError() ) ); } - QVERIFY_SQL( q, exec( "select * from" + qTableName( "qtest" ) + " where id = 41" ) ); + QVERIFY_SQL( q, exec( "select * from" + qtest + " where id = 41" ) ); QVERIFY( q.next() == false ); // test concurrent access q.exec( startTransactionStr ); - QVERIFY_SQL( q, exec( "insert into" + qTableName( "qtest" ) + " values (42, 'VarChar42', 'Char42')" ) ); - QVERIFY_SQL( q, exec( "select * from" + qTableName( "qtest" ) + " where id = 42" ) ); + QVERIFY_SQL( q, exec( "insert into" + qtest + " values (42, 'VarChar42', 'Char42')" ) ); + QVERIFY_SQL( q, exec( "select * from" + qtest + " where id = 42" ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toInt(), 42 ); - QVERIFY_SQL( q2, exec( "select * from" + qTableName( "qtest" ) + " where id = 42" ) ); + QVERIFY_SQL( q2, exec( "select * from" + qtest + " where id = 42" ) ); if ( q2.next() ) qDebug( QString( "DBMS '%1' doesn't support query based transactions with concurrent access" ).arg( @@ -1567,7 +1579,7 @@ void tst_QSqlQuery::transaction() QVERIFY_SQL( q, exec( "commit" ) ); - QVERIFY_SQL( q2, exec( "select * from" + qTableName( "qtest" ) + " where id = 42" ) ); + QVERIFY_SQL( q2, exec( "select * from" + qtest + " where id = 42" ) ); QVERIFY( q2.next() ); @@ -1579,6 +1591,7 @@ void tst_QSqlQuery::joins() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString qtestj1(qTableName("qtestj1", __FILE__)), qtestj2(qTableName("qtestj2", __FILE__)); if ( db.driverName().startsWith( "QOCI" ) || db.driverName().startsWith( "QTDS" ) @@ -1592,17 +1605,17 @@ void tst_QSqlQuery::joins() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtestj1" ) + " (id1 int, id2 int)" ) ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtestj2" ) + " (id int, name varchar(20))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtestj1" ) + " values (1, 1)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtestj1" ) + " values (1, 2)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtestj2" ) + " values(1, 'trenton')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtestj2" ) + " values(2, 'marius')" ) ); + QVERIFY_SQL( q, exec( "create table " + qtestj1 + " (id1 int, id2 int)" ) ); + QVERIFY_SQL( q, exec( "create table " + qtestj2 + " (id int, name varchar(20))" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtestj1 + " values (1, 1)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtestj1 + " values (1, 2)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtestj2 + " values(1, 'trenton')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtestj2 + " values(2, 'marius')" ) ); QVERIFY_SQL( q, exec( "select qtestj1.id1, qtestj1.id2, qtestj2.id, qtestj2.name, qtestj3.id, qtestj3.name " - "from " + qTableName( "qtestj1" ) + " qtestj1 left outer join " + qTableName( "qtestj2" ) + + "from " + qtestj1 + " qtestj1 left outer join " + qtestj2 + " qtestj2 on (qtestj1.id1 = qtestj2.id) " - "left outer join " + qTableName( "qtestj2" ) + " as qtestj3 on (qtestj1.id2 = qtestj3.id)" ) ); + "left outer join " + qtestj2 + " as qtestj3 on (qtestj1.id2 = qtestj3.id)" ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toInt(), 1 ); @@ -1628,7 +1641,7 @@ void tst_QSqlQuery::synonyms() CHECK_DATABASE( db ); QSqlQuery q(db); - QVERIFY_SQL( q, exec("select a.id, a.t_char, a.t_varchar from " + qTableName( "qtest" ) + " a where a.id = 1") ); + QVERIFY_SQL( q, exec("select a.id, a.t_char, a.t_varchar from " + qtest + " a where a.id = 1") ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toInt(), 1 ); QCOMPARE( q.value( 1 ).toString().trimmed(), QString( "Char1" ) ); @@ -1647,6 +1660,8 @@ void tst_QSqlQuery::prepare_bind_exec() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString qtest_prepare(qTableName("qtest_prepare", __FILE__)); + if(db.driverName().startsWith("QIBASE") && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb")) QSKIP("Can't transliterate extended unicode to ascii", SkipSingle); if(db.driverName().startsWith("QDB2")) @@ -1671,15 +1686,15 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY_SQL( q, exec("set client_min_messages='warning'")); if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) ) - createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int primary key, name nvarchar(200) null)"; + createQuery = "create table " + qtest_prepare + " (id int primary key, name nvarchar(200) null)"; else if ( tst_Databases::isMySQL(db) && useUnicode ) - createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int not null primary key, name varchar(200) character set utf8)"; + createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200) character set utf8)"; else - createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int not null primary key, name varchar(200))"; + createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200))"; QVERIFY_SQL( q, exec( createQuery ) ); - QVERIFY( q.prepare( "insert into " + qTableName( "qtest_prepare" ) + " (id, name) values (:id, :name)" ) ); + QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (:id, :name)" ) ); int i; for ( i = 0; i < 6; ++i ) { @@ -1702,7 +1717,7 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY_SQL( q, exec() ); } - QVERIFY_SQL( q, exec( "SELECT * FROM " + qTableName( "qtest_prepare" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "SELECT * FROM " + qtest_prepare + " order by id" ) ); for ( i = 0; i < 6; ++i ) { QVERIFY( q.next() ); @@ -1721,12 +1736,12 @@ void tst_QSqlQuery::prepare_bind_exec() QCOMPARE( q.value( 0 ).toInt(), 8 ); QCOMPARE( q.value( 1 ).toString(), values[5] ); - QVERIFY( q.prepare( "insert into " + qTableName( "qtest_prepare" ) + " (id, name) values (:id, 'Bart')" ) ); + QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (:id, 'Bart')" ) ); q.bindValue( ":id", 99 ); QVERIFY_SQL( q, exec() ); q.bindValue( ":id", 100 ); QVERIFY_SQL( q, exec() ); - QVERIFY( q.exec( "select * from " + qTableName( "qtest_prepare" ) + " where id > 98 order by id" ) ); + QVERIFY( q.exec( "select * from " + qtest_prepare + " where id > 98 order by id" ) ); for ( i = 99; i <= 100; ++i ) { QVERIFY( q.next() ); @@ -1735,7 +1750,7 @@ void tst_QSqlQuery::prepare_bind_exec() } /*** SELECT stuff ***/ - QVERIFY( q.prepare( "select * from " + qTableName( "qtest_prepare" ) + " where id = :id" ) ); + QVERIFY( q.prepare( "select * from " + qtest_prepare + " where id = :id" ) ); for ( i = 0; i < 6; ++i ) { q.bindValue( ":id", i ); @@ -1750,9 +1765,9 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY( !q.next() ); } - QVERIFY_SQL( q, exec( "DELETE FROM " + qTableName( "qtest_prepare" ) ) ); + QVERIFY_SQL( q, exec( "DELETE FROM " + qtest_prepare ) ); - QVERIFY( q.prepare( "insert into " + qTableName( "qtest_prepare" ) + " (id, name) values (?, ?)" ) ); + QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (?, ?)" ) ); q.bindValue( 0, 0 ); q.bindValue( 1, values[ 0 ] ); QVERIFY_SQL( q, exec() ); @@ -1781,7 +1796,7 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY_SQL( q, exec() ); } - QVERIFY_SQL( q, exec( "SELECT * FROM " + qTableName( "qtest_prepare" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "SELECT * FROM " + qtest_prepare + " order by id" ) ); for ( i = 0; i < 6; ++i ) { QVERIFY( q.next() ); @@ -1800,13 +1815,13 @@ void tst_QSqlQuery::prepare_bind_exec() QCOMPARE( q.value( 1 ).toString(), utf8str ); } - QVERIFY( q.prepare( "insert into " + qTableName( "qtest_prepare" ) + " (id, name) values (?, 'Bart')" ) ); + QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (?, 'Bart')" ) ); q.bindValue( 0, 99 ); QVERIFY_SQL( q, exec() ); q.addBindValue( 100 ); QVERIFY_SQL( q, exec() ); - QVERIFY( q.exec( "select * from " + qTableName( "qtest_prepare" ) + " where id > 98 order by id" ) ); + QVERIFY( q.exec( "select * from " + qtest_prepare + " where id > 98 order by id" ) ); for ( i = 99; i <= 100; ++i ) { QVERIFY( q.next() ); @@ -1815,7 +1830,7 @@ void tst_QSqlQuery::prepare_bind_exec() } /* insert a duplicate id and make sure the db bails out */ - QVERIFY( q.prepare( "insert into " + qTableName( "qtest_prepare" ) + " (id, name) values (?, ?)" ) ); + QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (?, ?)" ) ); q.addBindValue( 99 ); @@ -1837,7 +1852,7 @@ void tst_QSqlQuery::prepared_select() CHECK_DATABASE( db ); QSqlQuery q( db ); - QVERIFY_SQL( q, prepare( "select a.id, a.t_char, a.t_varchar from " + qTableName( "qtest" ) + " a where a.id = ?" ) ); + QVERIFY_SQL( q, prepare( "select a.id, a.t_char, a.t_varchar from " + qtest + " a where a.id = ?" ) ); q.bindValue( 0, 1 ); QVERIFY_SQL( q, exec() ); @@ -1857,7 +1872,7 @@ void tst_QSqlQuery::prepared_select() QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toInt(), 3 ); - QVERIFY_SQL( q, prepare( "select a.id, a.t_char, a.t_varchar from " + qTableName( "qtest" ) + " a where a.id = ?" ) ); + QVERIFY_SQL( q, prepare( "select a.id, a.t_char, a.t_varchar from " + qtest + " a where a.id = ?" ) ); QCOMPARE( q.at(), ( int )QSql::BeforeFirstRow ); QVERIFY( !q.first() ); } @@ -1873,9 +1888,9 @@ void tst_QSqlQuery::sqlServerLongStrings() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "CREATE TABLE " + qTableName( "qtest_longstr" ) + " (id int primary key, longstring ntext)" ) ); + QVERIFY_SQL( q, exec( "CREATE TABLE " + qTableName( "qtest_longstr", __FILE__ ) + " (id int primary key, longstring ntext)" ) ); - QVERIFY_SQL( q, prepare( "INSERT INTO " + qTableName( "qtest_longstr" ) + " VALUES (?, ?)" ) ); + QVERIFY_SQL( q, prepare( "INSERT INTO " + qTableName( "qtest_longstr", __FILE__ ) + " VALUES (?, ?)" ) ); q.addBindValue( 0 ); @@ -1893,7 +1908,7 @@ void tst_QSqlQuery::sqlServerLongStrings() QVERIFY_SQL( q, exec() ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_longstr" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_longstr", __FILE__ ) ) ); QVERIFY_SQL( q, next() ); @@ -1957,7 +1972,7 @@ void tst_QSqlQuery::batchExec() QSKIP( "Database can't do BatchOperations", SkipSingle ); QSqlQuery q( db ); - QString tableName = qTableName( "qtest_batch" ); + const QString tableName = qTableName( "qtest_batch", __FILE__ ); QVERIFY_SQL( q, exec( "create table " + tableName + " (id int, name varchar(20), dt date, num numeric(8, 4))" ) ); QVERIFY_SQL( q, prepare( "insert into " + tableName + " (id, name, dt, num) values (?, ?, ?, ?)" ) ); @@ -2101,9 +2116,9 @@ void tst_QSqlQuery::record_sqlite() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table "+qTableName( "record_sqlite" )+"(id integer primary key, name varchar, title int)" ) ); + QVERIFY_SQL( q, exec( "create table "+qTableName( "record_sqlite", __FILE__ )+"(id integer primary key, name varchar, title int)" ) ); - QSqlRecord rec = db.record( qTableName( "record_sqlite" ) ); + QSqlRecord rec = db.record( qTableName( "record_sqlite", __FILE__ ) ); QCOMPARE( rec.count(), 3 ); QCOMPARE( rec.field( 0 ).type(), QVariant::Int ); @@ -2111,7 +2126,7 @@ void tst_QSqlQuery::record_sqlite() QCOMPARE( rec.field( 2 ).type(), QVariant::Int ); /* important - select from an empty table */ - QVERIFY_SQL( q, exec( "select id, name, title from "+qTableName( "record_sqlite" ) ) ); + QVERIFY_SQL( q, exec( "select id, name, title from "+qTableName( "record_sqlite", __FILE__ ) ) ); rec = q.record(); QCOMPARE( rec.count(), 3 ); @@ -2130,13 +2145,13 @@ void tst_QSqlQuery::oraLong() QString aLotOfText( 127000, QLatin1Char( 'H' ) ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_longstr" ) + " (id int primary key, astr long)" ) ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_longstr" ) + " (id, astr) values (?, ?)" ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_longstr", __FILE__ ) + " (id int primary key, astr long)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_longstr", __FILE__ ) + " (id, astr) values (?, ?)" ) ); q.addBindValue( 1 ); q.addBindValue( aLotOfText ); QVERIFY_SQL( q, exec() ); - QVERIFY_SQL( q, exec( "select id,astr from " + qTableName( "qtest_longstr" ) ) ); + QVERIFY_SQL( q, exec( "select id,astr from " + qTableName( "qtest_longstr", __FILE__ ) ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toInt(), 1 ); @@ -2151,8 +2166,8 @@ void tst_QSqlQuery::execErrorRecovery() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_exerr" ) + " (id int not null primary key)" ) ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_exerr" ) + " values (?)" ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_exerr", __FILE__ ) + " (id int not null primary key)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_exerr", __FILE__ ) + " values (?)" ) ); q.addBindValue( 1 ); QVERIFY_SQL( q, exec() ); @@ -2175,7 +2190,7 @@ void tst_QSqlQuery::lastInsertId() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (41, 'VarChar41', 'Char41')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (41, 'VarChar41', 'Char41')" ) ); QVariant v = q.lastInsertId(); @@ -2189,7 +2204,7 @@ void tst_QSqlQuery::lastQuery() CHECK_DATABASE( db ); QSqlQuery q( db ); - QString sql = "select * from " + qTableName( "qtest" ); + QString sql = "select * from " + qtest; QVERIFY_SQL( q, exec( sql ) ); QCOMPARE( q.lastQuery(), sql ); QCOMPARE( q.executedQuery(), sql ); @@ -2208,7 +2223,7 @@ void tst_QSqlQuery::bindWithDoubleColonCastOperator() return; } - QString tablename = qTableName( "bindtest" ); + const QString tablename(qTableName( "bindtest", __FILE__ )); QSqlQuery q( db ); @@ -2282,7 +2297,7 @@ void tst_QSqlQuery::createQueryOnClosedDatabase() QSqlQuery q( db ); db.open(); - QVERIFY_SQL( q, exec( QString( "select * from %1 where id = 1" ).arg( qTableName( "qtest" ) ) ) ); + QVERIFY_SQL( q, exec( QString( "select * from %1 where id = 1" ).arg( qtest ) ) ); QVERIFY_SQL( q, next() ); QCOMPARE( q.value( 0 ).toInt(), 1 ); @@ -2290,7 +2305,7 @@ void tst_QSqlQuery::createQueryOnClosedDatabase() QCOMPARE( q.value( 2 ).toString().trimmed(), QLatin1String( "Char1" ) ); db.close(); - QVERIFY2( !q.exec( QString( "select * from %1 where id = 1" ).arg( qTableName( "qtest" ) ) ), + QVERIFY2( !q.exec( QString( "select * from %1 where id = 1" ).arg( qtest ) ), qPrintable( QString( "This can't happen! The query should not have been executed!" ) ) ); } @@ -2303,7 +2318,7 @@ void tst_QSqlQuery::reExecutePreparedForwardOnlyQuery() QSqlQuery q( db ); q.setForwardOnly( true ); - QVERIFY_SQL( q, prepare( QString( "SELECT id, t_varchar, t_char FROM %1 WHERE id = :id" ).arg( qTableName( "qtest" ) ) ) ); + QVERIFY_SQL( q, prepare( QString( "SELECT id, t_varchar, t_char FROM %1 WHERE id = :id" ).arg( qtest ) ) ); q.bindValue( ":id", 1 ); QVERIFY_SQL( q, exec() ); @@ -2328,7 +2343,7 @@ void tst_QSqlQuery::finish() CHECK_DATABASE( db ); QSqlQuery q( db ); - QVERIFY_SQL( q, prepare( "SELECT id FROM " + qTableName( "qtest" ) + " WHERE id = ?" ) ); + QVERIFY_SQL( q, prepare( "SELECT id FROM " + qtest + " WHERE id = ?" ) ); int id = 4; q.bindValue( 0, id ); @@ -2349,7 +2364,7 @@ void tst_QSqlQuery::finish() q.finish(); QVERIFY( !q.isActive() ); - QVERIFY_SQL( q, exec( "SELECT id FROM " + qTableName( "qtest" ) + " WHERE id = 1" ) ); + QVERIFY_SQL( q, exec( "SELECT id FROM " + qtest + " WHERE id = 1" ) ); QVERIFY( q.isActive() ); QVERIFY_SQL( q, next() ); QCOMPARE( q.value( 0 ).toInt(), 1 ); @@ -2374,7 +2389,7 @@ void tst_QSqlQuery::sqlite_finish() db2.setDatabaseName( db.databaseName() ); QVERIFY_SQL( db2, open() ); - QString tableName = qTableName( "qtest_lockedtable" ); + const QString tableName(qTableName( "qtest_lockedtable", __FILE__ )); QSqlQuery q( db ); tst_Databases::safeDropTable( db, tableName ); @@ -2424,7 +2439,7 @@ void tst_QSqlQuery::nextResult() else if ( db.driverName().startsWith( "QDB2" ) ) driverType = DB2; - QString tableName = qTableName( "more_results" ); + const QString tableName(qTableName( "more_results", __FILE__ )); QVERIFY_SQL( q, exec( "CREATE TABLE " + tableName + " (id integer, text varchar(20), num numeric(6, 3), empty varchar(10));" ) ); @@ -2528,7 +2543,7 @@ void tst_QSqlQuery::nextResult() } // Stored procedure with multiple result sets - QString procName = qTableName( "proc_more_res" ); + const QString procName(qTableName( "proc_more_res", __FILE__ )); q.exec( QString( "DROP PROCEDURE %1;" ).arg( procName ) ); @@ -2606,7 +2621,7 @@ void tst_QSqlQuery::blobsPreparedQuery() if ( !db.driver()->hasFeature( QSqlDriver::BLOB ) || !db.driver()->hasFeature( QSqlDriver::PreparedQueries ) ) QSKIP( "DBMS does not support BLOBs or prepared queries", SkipSingle ); - QString tableName = qTableName( "blobstest" ); + const QString tableName(qTableName( "blobstest", __FILE__ )); QSqlQuery q( db ); q.setForwardOnly( true ); // This is needed to make the test work with DB2. @@ -2661,8 +2676,8 @@ void tst_QSqlQuery::emptyTableNavigate() { QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_empty" ) + " (id char(10))" ) ); - QVERIFY_SQL( q, prepare( "select * from " + qTableName( "qtest_empty" ) ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_empty", __FILE__ ) + " (id char(10))" ) ); + QVERIFY_SQL( q, prepare( "select * from " + qTableName( "qtest_empty", __FILE__ ) ) ); QVERIFY_SQL( q, exec() ); QVERIFY( !q.next() ); QCOMPARE( q.lastError().isValid(), false ); @@ -2675,19 +2690,20 @@ void tst_QSqlQuery::task_217003() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); QSqlQuery q( db ); + const QString Planet(qTableName( "Planet", __FILE__)); - QVERIFY_SQL( q, exec( "create table " + qTableName( "Planet" ) + " (Name varchar(20))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "Planet" ) + " VALUES ('Mercury')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "Planet" ) + " VALUES ('Venus')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "Planet" ) + " VALUES ('Earth')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "Planet" ) + " VALUES ('Mars')" ) ); + QVERIFY_SQL( q, exec( "create table " + Planet + " (Name varchar(20))" ) ); + QVERIFY_SQL( q, exec( "insert into " + Planet + " VALUES ('Mercury')" ) ); + QVERIFY_SQL( q, exec( "insert into " + Planet + " VALUES ('Venus')" ) ); + QVERIFY_SQL( q, exec( "insert into " + Planet + " VALUES ('Earth')" ) ); + QVERIFY_SQL( q, exec( "insert into " + Planet + " VALUES ('Mars')" ) ); - QVERIFY_SQL( q, exec( "SELECT Name FROM "+qTableName( "Planet" ) ) ); + QVERIFY_SQL( q, exec( "SELECT Name FROM " + Planet ) ); QVERIFY_SQL( q, seek( 3 ) ); QCOMPARE( q.value( 0 ).toString(), QString( "Mars" ) ); QVERIFY_SQL( q, seek( 1 ) ); QCOMPARE( q.value( 0 ).toString(), QString( "Venus" ) ); - QVERIFY_SQL( q, exec( "SELECT Name FROM "+qTableName( "Planet" ) ) ); + QVERIFY_SQL( q, exec( "SELECT Name FROM " + Planet ) ); QVERIFY_SQL( q, seek( 3 ) ); QCOMPARE( q.value( 0 ).toString(), QString( "Mars" ) ); QVERIFY_SQL( q, seek( 0 ) ); @@ -2704,7 +2720,7 @@ void tst_QSqlQuery::task_250026() CHECK_DATABASE( db ); QSqlQuery q( db ); - QString tableName = qTableName( "task_250026" ); + const QString tableName(qTableName( "task_250026", __FILE__ )); if ( !q.exec( "create table " + tableName + " (longfield varchar(1100))" ) ) { qDebug() << "Error" << q.lastError(); @@ -2752,7 +2768,7 @@ void tst_QSqlQuery::task_229811() QSqlQuery q( db ); - QString tableName = qTableName( "task_229811" ); + const QString tableName(qTableName( "task_229811", __FILE__ )); if ( !q.exec( "CREATE TABLE " + tableName + " (Word varchar(20))" ) ) { qDebug() << "Warning" << q.lastError(); @@ -2799,7 +2815,7 @@ void tst_QSqlQuery::task_234422() m_airlines << "Lufthansa" << "SAS" << "United" << "KLM" << "Aeroflot"; m_countries << "DE" << "SE" << "US" << "NL" << "RU"; - QString tableName = qTableName( "task_234422" ); + const QString tableName(qTableName( "task_234422", __FILE__ )); QVERIFY_SQL(query,exec("CREATE TABLE " + tableName + " (id int primary key, " "name varchar(20), homecountry varchar(2))")); @@ -2831,7 +2847,7 @@ void tst_QSqlQuery::task_233829() CHECK_DATABASE( db ); QSqlQuery q( db ); - QString tableName = qTableName("task_233829"); + const QString tableName(qTableName("task_233829", __FILE__)); QVERIFY_SQL(q,exec("CREATE TABLE " + tableName + "(dbl1 double precision,dbl2 double precision) without oids;")); QString queryString("INSERT INTO " + tableName +"(dbl1, dbl2) VALUES(?,?)"); @@ -2851,7 +2867,7 @@ void tst_QSqlQuery::sqlServerReturn0() if (!tst_Databases::isSqlServer( db )) QSKIP("SQL Server specific test", SkipSingle); - QString tableName(qTableName("test141895")), procName(qTableName("test141895_proc")); + const QString tableName(qTableName("test141895", __FILE__)), procName(qTableName("test141895_proc", __FILE__)); QSqlQuery q( db ); q.exec("DROP TABLE " + tableName); q.exec("DROP PROCEDURE " + procName); @@ -2877,7 +2893,7 @@ void tst_QSqlQuery::QTBUG_551() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); QSqlQuery q(db); - QString pkgname=qTableName("pkg"); + const QString pkgname(qTableName("pkg", __FILE__)); QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE "+pkgname+" IS \n\ \n\ TYPE IntType IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;\n\ @@ -2923,17 +2939,18 @@ void tst_QSqlQuery::QTBUG_5251() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString timetest(qTableName("timetest", __FILE__)); if (!db.driverName().startsWith( "QPSQL" )) return; QSqlQuery q(db); - q.exec("DROP TABLE " + qTableName("timetest")); - QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("timetest") + " (t TIME)")); - QVERIFY_SQL(q, exec("INSERT INTO " + qTableName("timetest") + " VALUES ('1:2:3.666')")); + q.exec("DROP TABLE " + timetest); + QVERIFY_SQL(q, exec("CREATE TABLE " + timetest + " (t TIME)")); + QVERIFY_SQL(q, exec("INSERT INTO " + timetest + " VALUES ('1:2:3.666')")); QSqlTableModel timetestModel(0,db); timetestModel.setEditStrategy(QSqlTableModel::OnManualSubmit); - timetestModel.setTable(qTableName("timetest")); + timetestModel.setTable(timetest); QVERIFY_SQL(timetestModel, select()); QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("01:02:03.666")); @@ -2942,7 +2959,7 @@ void tst_QSqlQuery::QTBUG_5251() QVERIFY_SQL(timetestModel, submitAll()); QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:12:34.500")); - QVERIFY_SQL(q, exec("UPDATE " + qTableName("timetest") + " SET t = '0:11:22.33'")); + QVERIFY_SQL(q, exec("UPDATE " + timetest + " SET t = '0:11:22.33'")); QVERIFY_SQL(timetestModel, select()); QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:11:22.330")); @@ -2955,7 +2972,7 @@ void tst_QSqlQuery::QTBUG_6421() CHECK_DATABASE( db ); QSqlQuery q(db); - QString tableName=qTableName(QLatin1String("bug6421")).toUpper(); + const QString tableName(qTableName("bug6421", __FILE__).toUpper()); QVERIFY_SQL(q, exec("create table "+tableName+"(COL1 char(10), COL2 char(10), COL3 char(10))")); QVERIFY_SQL(q, exec("create index INDEX1 on "+tableName+" (COL1 desc)")); @@ -2980,16 +2997,16 @@ void tst_QSqlQuery::QTBUG_6618() QSKIP("SQL Server specific test", SkipSingle); QSqlQuery q(db); - q.exec( "drop procedure " + qTableName( "tst_raiseError" ) ); //non-fatal + q.exec( "drop procedure " + qTableName( "tst_raiseError", __FILE__ ) ); //non-fatal QString errorString; for (int i=0;i<110;i++) errorString+="reallylong"; errorString+=" error"; - QVERIFY_SQL( q, exec("create procedure " + qTableName( "tst_raiseError" ) + " as\n" + QVERIFY_SQL( q, exec("create procedure " + qTableName( "tst_raiseError", __FILE__ ) + " as\n" "begin\n" " raiserror('" + errorString + "', 16, 1)\n" "end\n" )); - q.exec( "{call " + qTableName( "tst_raiseError" ) + "}" ); + q.exec( "{call " + qTableName( "tst_raiseError", __FILE__ ) + "}" ); QVERIFY(q.lastError().text().contains(errorString)); } @@ -3002,7 +3019,7 @@ void tst_QSqlQuery::QTBUG_6852() QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); QSqlQuery q(db); - QString tableName(qTableName(QLatin1String("bug6852"))), procName(qTableName(QLatin1String("bug6852_proc"))); + const QString tableName(qTableName("bug6852", __FILE__)), procName(qTableName("bug6852_proc", __FILE__)); QVERIFY_SQL(q, exec("DROP PROCEDURE IF EXISTS "+procName)); QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+"(\n" @@ -3036,7 +3053,7 @@ void tst_QSqlQuery::QTBUG_5765() QSKIP( "Test requires MySQL >= 4.1", SkipSingle ); QSqlQuery q(db); - QString tableName(qTableName(QLatin1String("bug5765"))); + const QString tableName(qTableName("bug5765", __FILE__)); QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+"(testval TINYINT(1) DEFAULT 0)")); q.prepare("INSERT INTO "+tableName+" SET testval = :VALUE"); @@ -3074,7 +3091,7 @@ void tst_QSqlQuery::benchmark() QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); QSqlQuery q(db); - QString tableName(qTableName(QLatin1String("benchmark"))); + const QString tableName(qTableName("benchmark", __FILE__)); tst_Databases::safeDropTable( db, tableName ); diff --git a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp index 7e75d28..b64d599 100644 --- a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp +++ b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp @@ -148,10 +148,10 @@ void tst_QSqlQueryModel::cleanupTestCase() void tst_QSqlQueryModel::dropTestTables(QSqlDatabase db) { QStringList tableNames; - tableNames << qTableName("test") - << qTableName("test2") - << qTableName("test3") - << qTableName("many"); + tableNames << qTableName("test", __FILE__) + << qTableName("test2", __FILE__) + << qTableName("test3", __FILE__) + << qTableName("many", __FILE__); tst_Databases::safeDropTables(db, tableNames); } @@ -161,10 +161,10 @@ void tst_QSqlQueryModel::createTestTables(QSqlDatabase db) QSqlQuery q(db); if(tst_Databases::isPostgreSQL(db)) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - QVERIFY_SQL( q, exec("create table " + qTableName("test") + "(id integer not null, name varchar(20), title integer, primary key (id))")); - QVERIFY_SQL( q, exec("create table " + qTableName("test2") + "(id integer not null, title varchar(20), primary key (id))")); - QVERIFY_SQL( q, exec("create table " + qTableName("test3") + "(id integer not null, primary key (id))")); - QVERIFY_SQL( q, exec("create table " + qTableName("many") + "(id integer not null, name varchar(20), primary key (id))")); + QVERIFY_SQL( q, exec("create table " + qTableName("test", __FILE__) + "(id integer not null, name varchar(20), title integer, primary key (id))")); + QVERIFY_SQL( q, exec("create table " + qTableName("test2", __FILE__) + "(id integer not null, title varchar(20), primary key (id))")); + QVERIFY_SQL( q, exec("create table " + qTableName("test3", __FILE__) + "(id integer not null, primary key (id))")); + QVERIFY_SQL( q, exec("create table " + qTableName("many", __FILE__) + "(id integer not null, name varchar(20), primary key (id))")); } void tst_QSqlQueryModel::populateTestTables(QSqlDatabase db) @@ -174,38 +174,38 @@ void tst_QSqlQueryModel::populateTestTables(QSqlDatabase db) QSqlQuery q(db), q2(db); - tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp") << qTableName("test3tmp")); - QVERIFY_SQL(q, exec("create table " + qTableName("manytmp") + "(id integer not null, name varchar(20), primary key (id))")); - QVERIFY_SQL(q, exec("create table " + qTableName("test3tmp") + "(id integer not null, primary key (id))")); + tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp", __FILE__) << qTableName("test3tmp", __FILE__)); + QVERIFY_SQL(q, exec("create table " + qTableName("manytmp", __FILE__) + "(id integer not null, name varchar(20), primary key (id))")); + QVERIFY_SQL(q, exec("create table " + qTableName("test3tmp", __FILE__) + "(id integer not null, primary key (id))")); if (hasTransactions) QVERIFY_SQL(db, transaction()); - QVERIFY_SQL(q, exec("insert into " + qTableName("test") + " values(1, 'harry', 1)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test") + " values(2, 'trond', 2)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test2") + " values(1, 'herr')")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test2") + " values(2, 'mister')")); + QVERIFY_SQL(q, exec("insert into " + qTableName("test", __FILE__) + " values(1, 'harry', 1)")); + QVERIFY_SQL(q, exec("insert into " + qTableName("test", __FILE__) + " values(2, 'trond', 2)")); + QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__) + " values(1, 'herr')")); + QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__) + " values(2, 'mister')")); - QVERIFY_SQL(q, exec(QString("insert into " + qTableName("test3") + " values(0)"))); - QVERIFY_SQL(q, prepare("insert into "+qTableName("test3")+"(id) select id + ? from "+qTableName("test3tmp"))); + QVERIFY_SQL(q, exec(QString("insert into " + qTableName("test3", __FILE__) + " values(0)"))); + QVERIFY_SQL(q, prepare("insert into "+qTableName("test3", __FILE__)+"(id) select id + ? from "+qTableName("test3tmp", __FILE__))); for (int i=1; i<260; i*=2) { - q2.exec("delete from "+qTableName("test3tmp")); - QVERIFY_SQL(q2, exec("insert into "+qTableName("test3tmp")+"(id) select id from "+qTableName("test3"))); + q2.exec("delete from "+qTableName("test3tmp", __FILE__)); + QVERIFY_SQL(q2, exec("insert into "+qTableName("test3tmp", __FILE__)+"(id) select id from "+qTableName("test3", __FILE__))); q.bindValue(0, i); QVERIFY_SQL(q, exec()); } - QVERIFY_SQL(q, exec(QString("insert into " + qTableName("many") + "(id, name) values (0, \'harry\')"))); - QVERIFY_SQL(q, prepare("insert into "+qTableName("many")+"(id, name) select id + ?, name from "+qTableName("manytmp"))); + QVERIFY_SQL(q, exec(QString("insert into " + qTableName("many", __FILE__) + "(id, name) values (0, \'harry\')"))); + QVERIFY_SQL(q, prepare("insert into "+qTableName("many", __FILE__)+"(id, name) select id + ?, name from "+qTableName("manytmp", __FILE__))); for (int i=1; i < 2048; i*=2) { - q2.exec("delete from "+qTableName("manytmp")); - QVERIFY_SQL(q2, exec("insert into "+qTableName("manytmp")+"(id, name) select id, name from "+qTableName("many"))); + q2.exec("delete from "+qTableName("manytmp", __FILE__)); + QVERIFY_SQL(q2, exec("insert into "+qTableName("manytmp", __FILE__)+"(id, name) select id, name from "+qTableName("many", __FILE__))); q.bindValue(0, i); QVERIFY_SQL(q, exec()); } if (hasTransactions) QVERIFY_SQL(db, commit()); - tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp") << qTableName("test3tmp")); + tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp", __FILE__) << qTableName("test3tmp", __FILE__)); } void tst_QSqlQueryModel::generic_data(const QString& engine) @@ -233,7 +233,7 @@ void tst_QSqlQueryModel::removeColumn() CHECK_DATABASE(db); DBTestModel model; - model.setQuery(QSqlQuery("select * from " + qTableName("test"), db)); + model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db)); model.fetchMore(); QSignalSpy spy(&model, SIGNAL(columnsAboutToBeRemoved(QModelIndex, int, int))); @@ -315,7 +315,7 @@ void tst_QSqlQueryModel::insertColumn() CHECK_DATABASE(db); DBTestModel model; - model.setQuery(QSqlQuery("select * from " + qTableName("test"), db)); + model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db)); model.fetchMore(); // necessary??? QSignalSpy spy(&model, SIGNAL(columnsInserted(QModelIndex, int, int))); @@ -395,7 +395,7 @@ void tst_QSqlQueryModel::record() CHECK_DATABASE(db); QSqlQueryModel model; - model.setQuery(QSqlQuery("select * from " + qTableName("test"), db)); + model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db)); QSqlRecord rec = model.record(); @@ -429,7 +429,7 @@ void tst_QSqlQueryModel::setHeaderData() QVERIFY(!model.setHeaderData(5, Qt::Vertical, "foo")); QVERIFY(model.headerData(5, Qt::Vertical).isValid()); - model.setQuery(QSqlQuery("select * from " + qTableName("test"), db)); + model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db)); qRegisterMetaType("Qt::Orientation"); QSignalSpy spy(&model, SIGNAL(headerDataChanged(Qt::Orientation, int, int))); @@ -459,7 +459,7 @@ void tst_QSqlQueryModel::fetchMore() QSqlQueryModel model; QSignalSpy spy(&model, SIGNAL(rowsInserted(QModelIndex, int, int))); - model.setQuery(QSqlQuery("select * from " + qTableName("many"), db)); + model.setQuery(QSqlQuery("select * from " + qTableName("many", __FILE__), db)); int rowCount = model.rowCount(); QCOMPARE(spy.value(0).value(1).toInt(), 0); @@ -491,7 +491,7 @@ void tst_QSqlQueryModel::withSortFilterProxyModel() QSKIP("Test applies only for drivers not reporting the query size.", SkipSingle); QSqlQueryModel model; - model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3"), db)); + model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__), db)); QSortFilterProxyModel proxy; proxy.setSourceModel(&model); @@ -500,7 +500,7 @@ void tst_QSqlQueryModel::withSortFilterProxyModel() QSignalSpy modelRowsRemovedSpy(&model, SIGNAL(rowsRemoved(const QModelIndex &, int, int))); QSignalSpy modelRowsInsertedSpy(&model, SIGNAL(rowsInserted(const QModelIndex &, int, int))); - model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3"), db)); + model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__), db)); view.scrollToBottom(); QTestEventLoop::instance().enterLoop(1); @@ -536,12 +536,12 @@ void tst_QSqlQueryModel::setQuerySignalEmission() QSignalSpy modelRowsRemovedSpy(&model, SIGNAL(rowsRemoved(const QModelIndex &, int, int))); // First select, the model was empty and no rows had to be removed! - model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test"), db)); + model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__), db)); QCOMPARE(modelRowsAboutToBeRemovedSpy.count(), 0); QCOMPARE(modelRowsRemovedSpy.count(), 0); // Second select, the model wasn't empty and two rows had to be removed! - model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test"), db)); + model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__), db)); QCOMPARE(modelRowsAboutToBeRemovedSpy.count(), 1); QCOMPARE(modelRowsAboutToBeRemovedSpy.value(0).value(1).toInt(), 0); QCOMPARE(modelRowsAboutToBeRemovedSpy.value(0).value(2).toInt(), 1); @@ -564,7 +564,7 @@ void tst_QSqlQueryModel::setQueryWithNoRowsInResultSet() // The query's result set will be empty so no signals should be emitted! QSqlQuery query(db); - QVERIFY_SQL(query, exec("SELECT * FROM " + qTableName("test") + " where 0 = 1")); + QVERIFY_SQL(query, exec("SELECT * FROM " + qTableName("test", __FILE__) + " where 0 = 1")); model.setQuery(query); QCOMPARE(modelRowsAboutToBeInsertedSpy.count(), 0); QCOMPARE(modelRowsInsertedSpy.count(), 0); @@ -578,13 +578,14 @@ void tst_QSqlQueryModel::task_180617() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString test3(qTableName("test3", __FILE__)); QTableView view; QCOMPARE(view.columnAt(0), -1); QCOMPARE(view.rowAt(0), -1); QSqlQueryModel model; - model.setQuery( "SELECT TOP 0 * FROM " + qTableName("test3"), db ); + model.setQuery( "SELECT TOP 0 * FROM " + test3, db ); view.setModel(&model); bool error = false; @@ -595,10 +596,10 @@ void tst_QSqlQueryModel::task_180617() QCOMPARE(view.columnAt(0), (error)?-1:0 ); QCOMPARE(view.rowAt(0), -1); - model.setQuery( "SELECT TOP 0 * FROM " + qTableName("test3"), db ); - model.setQuery( "SELECT TOP 0 * FROM " + qTableName("test3"), db ); - model.setQuery( "SELECT TOP 0 * FROM " + qTableName("test3"), db ); - model.setQuery( "SELECT TOP 0 * FROM " + qTableName("test3"), db ); + model.setQuery( "SELECT TOP 0 * FROM " + test3, db ); + model.setQuery( "SELECT TOP 0 * FROM " + test3, db ); + model.setQuery( "SELECT TOP 0 * FROM " + test3, db ); + model.setQuery( "SELECT TOP 0 * FROM " + test3, db ); QCOMPARE(view.columnAt(0), (error)?-1:0 ); QCOMPARE(view.rowAt(0), -1); diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index eab1364..c4bd540 100644 --- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -45,6 +45,11 @@ #include "../qsqldatabase/tst_databases.h" +const QString reltest1(qTableName("reltest1", __FILE__)), + reltest2(qTableName("reltest2", __FILE__)), + reltest3(qTableName("reltest3", __FILE__)), + reltest4(qTableName("reltest4", __FILE__)), + reltest5(qTableName("reltest5", __FILE__)); //TESTED_CLASS= @@ -107,37 +112,37 @@ void tst_QSqlRelationalTableModel::recreateTestTables(QSqlDatabase db) dropTestTables(db); QSqlQuery q(db); - QVERIFY_SQL( q, exec("create table " + qTableName("reltest1") + + QVERIFY_SQL( q, exec("create table " + reltest1 + " (id int not null primary key, name varchar(20), title_key int, another_title_key int)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest1") + " values(1, 'harry', 1, 2)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest1") + " values(2, 'trond', 2, 1)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest1") + " values(3, 'vohi', 1, 2)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest1") + " values(4, 'boris', 2, 2)")); + QVERIFY_SQL( q, exec("insert into " + reltest1 + " values(1, 'harry', 1, 2)")); + QVERIFY_SQL( q, exec("insert into " + reltest1 + " values(2, 'trond', 2, 1)")); + QVERIFY_SQL( q, exec("insert into " + reltest1 + " values(3, 'vohi', 1, 2)")); + QVERIFY_SQL( q, exec("insert into " + reltest1 + " values(4, 'boris', 2, 2)")); - QVERIFY_SQL( q, exec("create table " + qTableName("reltest2") + " (tid int not null primary key, title varchar(20))")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest2") + " values(1, 'herr')")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest2") + " values(2, 'mister')")); + QVERIFY_SQL( q, exec("create table " + reltest2 + " (tid int not null primary key, title varchar(20))")); + QVERIFY_SQL( q, exec("insert into " + reltest2 + " values(1, 'herr')")); + QVERIFY_SQL( q, exec("insert into " + reltest2 + " values(2, 'mister')")); - QVERIFY_SQL( q, exec("create table " + qTableName("reltest3") + " (id int not null primary key, name varchar(20), city_key int)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest3") + " values(1, 'Gustav', 1)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest3") + " values(2, 'Heidi', 2)")); + QVERIFY_SQL( q, exec("create table " + reltest3 + " (id int not null primary key, name varchar(20), city_key int)")); + QVERIFY_SQL( q, exec("insert into " + reltest3 + " values(1, 'Gustav', 1)")); + QVERIFY_SQL( q, exec("insert into " + reltest3 + " values(2, 'Heidi', 2)")); - QVERIFY_SQL( q, exec("create table " + qTableName("reltest4") + " (id int not null primary key, name varchar(20))")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest4") + " values(1, 'Oslo')")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest4") + " values(2, 'Trondheim')")); + QVERIFY_SQL( q, exec("create table " + reltest4 + " (id int not null primary key, name varchar(20))")); + QVERIFY_SQL( q, exec("insert into " + reltest4 + " values(1, 'Oslo')")); + QVERIFY_SQL( q, exec("insert into " + reltest4 + " values(2, 'Trondheim')")); - QVERIFY_SQL( q, exec("create table " + qTableName("reltest5") + " (title varchar(20) not null primary key, abbrev varchar(20))")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest5") + " values('herr', 'Hr')")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest5") + " values('mister', 'Mr')")); + QVERIFY_SQL( q, exec("create table " + reltest5 + " (title varchar(20) not null primary key, abbrev varchar(20))")); + QVERIFY_SQL( q, exec("insert into " + reltest5 + " values('herr', 'Hr')")); + QVERIFY_SQL( q, exec("insert into " + reltest5 + " values('mister', 'Mr')")); if (testWhiteSpaceNames(db.driverName())) { - QString reltest6 = db.driver()->escapeIdentifier(qTableName("rel test6"), QSqlDriver::TableName); + QString reltest6 = db.driver()->escapeIdentifier(qTableName("rel", __FILE__)+" test6", QSqlDriver::TableName); QVERIFY_SQL( q, exec("create table " + reltest6 + " (id int not null primary key, " + db.driver()->escapeIdentifier("city key", QSqlDriver::FieldName) + " int, " + db.driver()->escapeIdentifier("extra field", QSqlDriver::FieldName) + " int)")); QVERIFY_SQL( q, exec("insert into " + reltest6 + " values(1, 1,9)")); QVERIFY_SQL( q, exec("insert into " + reltest6 + " values(2, 2,8)")); - QString reltest7 = db.driver()->escapeIdentifier(qTableName("rel test7"), QSqlDriver::TableName); + QString reltest7 = db.driver()->escapeIdentifier(qTableName("rel", __FILE__)+" test7", QSqlDriver::TableName); QVERIFY_SQL( q, exec("create table " + reltest7 + " (" + db.driver()->escapeIdentifier("city id", QSqlDriver::TableName) + " int not null primary key, " + db.driver()->escapeIdentifier("city name", QSqlDriver::FieldName) + " varchar(20))")); QVERIFY_SQL( q, exec("insert into " + reltest7 + " values(1, 'New York')")); QVERIFY_SQL( q, exec("insert into " + reltest7 + " values(2, 'Washington')")); @@ -173,19 +178,19 @@ void tst_QSqlRelationalTableModel::cleanupTestCase() void tst_QSqlRelationalTableModel::dropTestTables( QSqlDatabase db ) { QStringList tableNames; - tableNames << qTableName( "reltest1" ) - << qTableName( "reltest2" ) - << qTableName( "reltest3" ) - << qTableName( "reltest4" ) - << qTableName( "reltest5" ) - << qTableName( "rel test6" ) - << qTableName( "rel test7" ) - << qTableName("CASETEST1" ) - << qTableName("casetest1" ); + tableNames << reltest1 + << reltest2 + << reltest3 + << reltest4 + << reltest5 + << (qTableName( "rel", __FILE__)+" test6") + << (qTableName( "rel", __FILE__)+" test7") + << qTableName("CASETEST1", db.driver() ) + << qTableName("casetest1", db.driver() ); tst_Databases::safeDropTables( db, tableNames ); - db.exec("DROP SCHEMA "+qTableName("QTBUG_5373")+" CASCADE"); - db.exec("DROP SCHEMA "+qTableName("QTBUG_5373_s2")+" CASCADE"); + db.exec("DROP SCHEMA "+qTableName("QTBUG_5373", __FILE__)+" CASCADE"); + db.exec("DROP SCHEMA "+qTableName("QTBUG_5373_s2", __FILE__)+" CASCADE"); } void tst_QSqlRelationalTableModel::init() @@ -204,8 +209,8 @@ void tst_QSqlRelationalTableModel::data() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.columnCount(), 4); @@ -219,8 +224,8 @@ void tst_QSqlRelationalTableModel::data() //check data retrieval when relational key is a non-integer type //in this case a string QSqlRelationalTableModel model2(0,db); - model2.setTable(qTableName("reltest2")); - model2.setRelation(1, QSqlRelation(qTableName("reltest5"),"title","abbrev")); + model2.setTable(reltest2); + model2.setRelation(1, QSqlRelation(reltest5,"title","abbrev")); QVERIFY_SQL(model2, select()); QCOMPARE(model2.data(model2.index(0, 1)).toString(), QString("Hr")); @@ -237,9 +242,9 @@ void tst_QSqlRelationalTableModel::setData() { QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); model.setSort(0, Qt::AscendingOrder); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QVERIFY(model.setData(model.index(0, 1), QString("harry2"))); @@ -260,7 +265,7 @@ void tst_QSqlRelationalTableModel::setData() } { //verify values QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -269,7 +274,7 @@ void tst_QSqlRelationalTableModel::setData() QCOMPARE(model.data(model.index(3, 1)).toString(), QString("boris2")); QCOMPARE(model.data(model.index(3, 2)).toInt(), 1); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister")); QCOMPARE(model.data(model.index(3,2)).toString(), QString("herr")); @@ -279,10 +284,10 @@ void tst_QSqlRelationalTableModel::setData() //set the values using OnFieldChange strategy { QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); model.setEditStrategy(QSqlTableModel::OnFieldChange); model.setSort(0, Qt::AscendingOrder); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QVERIFY(model.setData(model.index(1,1), QString("trond2"))); @@ -293,14 +298,14 @@ void tst_QSqlRelationalTableModel::setData() } { //verify values QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(1, 1)).toString(), QString("trond2")); QCOMPARE(model.data(model.index(2, 2)).toInt(), 2); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(2, 2)).toString(), QString("mister")); } @@ -309,13 +314,13 @@ void tst_QSqlRelationalTableModel::setData() { QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); //sybase doesn't allow tables with the same alias used twice as col names //so don't set up an identical relation when using the tds driver if (!db.driverName().startsWith("QTDS")) - model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); model.setEditStrategy(QSqlTableModel::OnManualSubmit); model.setSort(0, Qt::AscendingOrder); @@ -336,7 +341,7 @@ void tst_QSqlRelationalTableModel::setData() } { //verify values QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -344,9 +349,9 @@ void tst_QSqlRelationalTableModel::setData() QCOMPARE(model.data(model.index(3, 2)).toInt(), 1); QCOMPARE(model.data(model.index(0, 3)).toInt(), 1); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); if (!db.driverName().startsWith("QTDS")) - model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr")); @@ -361,8 +366,8 @@ void tst_QSqlRelationalTableModel::setData() { QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest2")); - model.setRelation(1, QSqlRelation(qTableName("reltest5"), "title", "abbrev")); + model.setTable(reltest2); + model.setRelation(1, QSqlRelation(reltest5, "title", "abbrev")); model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); @@ -385,9 +390,9 @@ void tst_QSqlRelationalTableModel::multipleRelation() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); - model.setRelation(3, QSqlRelation(qTableName("reltest4"), "id", "name")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); + model.setRelation(3, QSqlRelation(reltest4, "id", "name")); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -407,8 +412,8 @@ void tst_QSqlRelationalTableModel::insertRecord() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -449,8 +454,8 @@ void tst_QSqlRelationalTableModel::setRecord() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -502,12 +507,12 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); model.setSort(0, Qt::AscendingOrder); if (!db.driverName().startsWith("QTDS")) - model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(0,0)).toInt(), 1); @@ -608,8 +613,8 @@ void tst_QSqlRelationalTableModel::removeColumn() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QVERIFY_SQL(model, removeColumn(3)); @@ -639,8 +644,8 @@ void tst_QSqlRelationalTableModel::filter() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); model.setFilter("title = 'herr'"); QVERIFY_SQL(model, select()); @@ -657,10 +662,10 @@ void tst_QSqlRelationalTableModel::sort() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); if (!db.driverName().startsWith("QTDS")) - model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); model.setSort(2, Qt::DescendingOrder); QVERIFY_SQL(model, select()); @@ -755,9 +760,9 @@ void tst_QSqlRelationalTableModel::revert() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); - model.setRelation(3, QSqlRelation(qTableName("reltest4"), "id", "name")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); + model.setRelation(3, QSqlRelation(reltest4, "id", "name")); model.setSort(0, Qt::AscendingOrder); @@ -781,11 +786,11 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); if (!db.driverName().startsWith("QTDS")) - model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); model.setSort(1, Qt::AscendingOrder); model.setEditStrategy(QSqlTableModel::OnManualSubmit); @@ -833,19 +838,19 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames() CHECK_DATABASE(db); QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest3")); + model.setTable(reltest3); model.setEditStrategy(QSqlTableModel::OnManualSubmit); model.setSort(0, Qt::AscendingOrder); // Duplication of "name", used in both reltest3 and reltest4. - model.setRelation(2, QSqlRelation(qTableName("reltest4"), "id", "name")); + model.setRelation(2, QSqlRelation(reltest4, "id", "name")); QVERIFY_SQL(model, select()); if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) { - QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name_2")).toUpper()).toString(), + QCOMPARE(model.record(1).value((reltest4+QLatin1String("_name_2")).toUpper()).toString(), QString("Trondheim")); } else { - QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name_2"))).toString(), + QCOMPARE(model.record(1).value((reltest4+QLatin1String("_name_2"))).toString(), QString("Trondheim")); } @@ -864,9 +869,9 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames() // The duplicate field names is aliased because it's comes from the relation's display column. if(db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) - QCOMPARE(rec.fieldName(2), (qTableName("reltest4").append(QLatin1String("_name_2"))).toUpper()); + QCOMPARE(rec.fieldName(2), (reltest4+QLatin1String("_name_2")).toUpper()); else - QCOMPARE(rec.fieldName(2), qTableName("reltest4").append(QLatin1String("_name_2"))); + QCOMPARE(rec.fieldName(2), reltest4+QLatin1String("_name_2")); QVERIFY(model.insertRecord(-1, rec)); QCOMPARE(model.data(model.index(2, 2)).toString(), QString("Oslo")); @@ -881,8 +886,8 @@ void tst_QSqlRelationalTableModel::invalidData() CHECK_DATABASE(db); QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); //try set a non-existent relational key @@ -900,8 +905,8 @@ void tst_QSqlRelationalTableModel::relationModel() CHECK_DATABASE(db); QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QVERIFY(model.relationModel(0) == NULL); @@ -910,7 +915,7 @@ void tst_QSqlRelationalTableModel::relationModel() QVERIFY(model.relationModel(3) == NULL); QVERIFY(model.relationModel(4) == NULL); - model.setRelation(3, QSqlRelation(qTableName("reltest4"), "id", "name")); + model.setRelation(3, QSqlRelation(reltest4, "id", "name")); QVERIFY_SQL(model, select()); QVERIFY(model.relationModel(0) == NULL); @@ -981,7 +986,7 @@ void tst_QSqlRelationalTableModel::casing() QSqlRelationalTableModel model(0, db); model.setTable(qTableName("CASETEST1", db.driver()).toUpper()); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(0, 0)).toInt(), 1); @@ -997,15 +1002,15 @@ void tst_QSqlRelationalTableModel::escapedRelations() recreateTestTables(db); QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); //try with relation table name quoted if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) { - model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(qTableName("reltest2").toUpper(),QSqlDriver::TableName), + model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(reltest2.toUpper(),QSqlDriver::TableName), "tid", "title")); } else { - model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(qTableName("reltest2"),QSqlDriver::TableName), + model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(reltest2,QSqlDriver::TableName), "tid", "title")); @@ -1018,11 +1023,11 @@ void tst_QSqlRelationalTableModel::escapedRelations() //try with index column quoted if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) { - model.setRelation(2, QSqlRelation(qTableName("reltest2"), + model.setRelation(2, QSqlRelation(reltest2, db.driver()->escapeIdentifier("tid", QSqlDriver::FieldName).toUpper(), "title")); } else { - model.setRelation(2, QSqlRelation(qTableName("reltest2"), + model.setRelation(2, QSqlRelation(reltest2, db.driver()->escapeIdentifier("tid", QSqlDriver::FieldName), "title")); } @@ -1036,11 +1041,11 @@ void tst_QSqlRelationalTableModel::escapedRelations() if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) { - model.setRelation(2, QSqlRelation(qTableName("reltest2"), + model.setRelation(2, QSqlRelation(reltest2, "tid", db.driver()->escapeIdentifier("title", QSqlDriver::FieldName).toUpper())); } else { - model.setRelation(2, QSqlRelation(qTableName("reltest2"), + model.setRelation(2, QSqlRelation(reltest2, "tid", db.driver()->escapeIdentifier("title", QSqlDriver::FieldName))); } @@ -1054,11 +1059,11 @@ void tst_QSqlRelationalTableModel::escapedRelations() //try with tablename and index and display columns quoted in the relation if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) { - model.setRelation(2, QSqlRelation(qTableName("reltest2"), + model.setRelation(2, QSqlRelation(reltest2, "tid", db.driver()->escapeIdentifier("title", QSqlDriver::FieldName).toUpper())); } else { - model.setRelation(2, QSqlRelation(qTableName("reltest2"), + model.setRelation(2, QSqlRelation(reltest2, "tid", db.driver()->escapeIdentifier("title", QSqlDriver::FieldName))); } @@ -1080,12 +1085,12 @@ void tst_QSqlRelationalTableModel::escapedTableName() QSqlRelationalTableModel model(0, db); if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) { - model.setTable(db.driver()->escapeIdentifier(qTableName("reltest1").toUpper(), QSqlDriver::TableName)); + model.setTable(db.driver()->escapeIdentifier(reltest1.toUpper(), QSqlDriver::TableName)); } else { - model.setTable(db.driver()->escapeIdentifier(qTableName("reltest1"), QSqlDriver::TableName)); + model.setTable(db.driver()->escapeIdentifier(reltest1, QSqlDriver::TableName)); } model.setSort(0, Qt::AscendingOrder); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QVERIFY(model.setData(model.index(0, 1), QString("harry2"))); @@ -1106,7 +1111,7 @@ void tst_QSqlRelationalTableModel::escapedTableName() } { //verify values QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -1115,7 +1120,7 @@ void tst_QSqlRelationalTableModel::escapedTableName() QCOMPARE(model.data(model.index(3, 1)).toString(), QString("boris2")); QCOMPARE(model.data(model.index(3, 2)).toInt(), 1); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister")); QCOMPARE(model.data(model.index(3,2)).toString(), QString("herr")); @@ -1132,9 +1137,9 @@ void tst_QSqlRelationalTableModel::whiteSpaceInIdentifiers() if (!testWhiteSpaceNames(db.driverName())) QSKIP("White space test irrelevant for driver", SkipAll); QSqlRelationalTableModel model(0, db); - model.setTable(db.driver()->escapeIdentifier(qTableName("rel test6"), QSqlDriver::TableName)); + model.setTable(db.driver()->escapeIdentifier(qTableName("rel", __FILE__)+" test6", QSqlDriver::TableName)); model.setSort(0, Qt::DescendingOrder); - model.setRelation(1, QSqlRelation(db.driver()->escapeIdentifier(qTableName("rel test7"), QSqlDriver::TableName), + model.setRelation(1, QSqlRelation(db.driver()->escapeIdentifier(qTableName("rel", __FILE__)+" test7", QSqlDriver::TableName), db.driver()->escapeIdentifier("city id", QSqlDriver::FieldName), db.driver()->escapeIdentifier("city name", QSqlDriver::FieldName))); QVERIFY_SQL(model, select()); @@ -1210,13 +1215,13 @@ void tst_QSqlRelationalTableModel::psqlSchemaTest() } QSqlRelationalTableModel model(0, db); QSqlQuery q(db); - QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373"))); - QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373_s2"))); - QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373")+"."+qTableName("document")+"(document_id int primary key, relatingid int, userid int)")); - QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373_s2")+"."+qTableName("user")+"(userid int primary key, username char(40))")); - model.setTable(qTableName("QTBUG_5373")+"."+qTableName("document")); - model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2")+"."+qTableName("user"), "userid", "username")); - model.setRelation(2, QSqlRelation(qTableName("QTBUG_5373_s2")+"."+qTableName("user"), "userid", "username")); + QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373", __FILE__))); + QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373_s2", __FILE__))); + QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373", __FILE__)+"."+qTableName("document", __FILE__)+"(document_id int primary key, relatingid int, userid int)")); + QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373_s2", __FILE__)+"."+qTableName("user", __FILE__)+"(userid int primary key, username char(40))")); + model.setTable(qTableName("QTBUG_5373", __FILE__)+"."+qTableName("document", __FILE__)); + model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__)+"."+qTableName("user", __FILE__), "userid", "username")); + model.setRelation(2, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__)+"."+qTableName("user", __FILE__), "userid", "username")); QVERIFY_SQL(model, select()); } diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp index b295838..8a084bb 100644 --- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp @@ -44,6 +44,10 @@ #include "../qsqldatabase/tst_databases.h" #include +const QString test(qTableName("test", __FILE__)), + test2(qTableName("test2", __FILE__)), + test3(qTableName("test3", __FILE__)); + //TESTED_CLASS= //TESTED_FILES= @@ -147,20 +151,20 @@ void tst_QSqlTableModel::dropTestTables() QVERIFY_SQL( q, exec("set client_min_messages='warning'")); QStringList tableNames; - tableNames << qTableName("test") - << qTableName("test2") - << qTableName("test3") - << qTableName("test4") - << qTableName("emptytable") - << qTableName("bigtable") - << qTableName("foo"); + tableNames << test + << test2 + << test3 + << qTableName("test4", __FILE__) + << qTableName("emptytable", __FILE__) + << qTableName("bigtable", __FILE__) + << qTableName("foo", __FILE__); if (testWhiteSpaceNames(db.driverName())) tableNames << qTableName("qtestw hitespace", db.driver()); tst_Databases::safeDropTables(db, tableNames); if (db.driverName().startsWith("QPSQL")) { - q.exec("DROP SCHEMA " + qTableName("testschema") + " CASCADE"); + q.exec("DROP SCHEMA " + qTableName("testschema", __FILE__) + " CASCADE"); } } } @@ -171,15 +175,15 @@ void tst_QSqlTableModel::createTestTables() QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); - QVERIFY_SQL( q, exec("create table " + qTableName("test") + "(id int, name varchar(20), title int)")); + QVERIFY_SQL( q, exec("create table " + test + "(id int, name varchar(20), title int)")); - QVERIFY_SQL( q, exec("create table " + qTableName("test2") + "(id int, title varchar(20))")); + QVERIFY_SQL( q, exec("create table " + test2 + "(id int, title varchar(20))")); - QVERIFY_SQL( q, exec("create table " + qTableName("test3") + "(id int, random varchar(20), randomtwo varchar(20))")); + QVERIFY_SQL( q, exec("create table " + test3 + "(id int, random varchar(20), randomtwo varchar(20))")); - QVERIFY_SQL( q, exec("create table " + qTableName("test4") + "(column1 varchar(50), column2 varchar(50), column3 varchar(50))")); + QVERIFY_SQL( q, exec("create table " + qTableName("test4", __FILE__) + "(column1 varchar(50), column2 varchar(50), column3 varchar(50))")); - QVERIFY_SQL( q, exec("create table " + qTableName("emptytable") + "(id int)")); + QVERIFY_SQL( q, exec("create table " + qTableName("emptytable", __FILE__) + "(id int)")); if (testWhiteSpaceNames(db.driverName())) { QString qry = "create table " + qTableName("qtestw hitespace", db.driver()) + " ("+ db.driver()->escapeIdentifier("a field", QSqlDriver::FieldName) + " int)"; @@ -194,18 +198,18 @@ void tst_QSqlTableModel::repopulateTestTables() QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); - q.exec("delete from " + qTableName("test")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(1, 'harry', 1)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(2, 'trond', 2)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(3, 'vohi', 3)")); + q.exec("delete from " + test); + QVERIFY_SQL( q, exec("insert into " + test + " values(1, 'harry', 1)")); + QVERIFY_SQL( q, exec("insert into " + test + " values(2, 'trond', 2)")); + QVERIFY_SQL( q, exec("insert into " + test + " values(3, 'vohi', 3)")); - q.exec("delete from " + qTableName("test2")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test2") + " values(1, 'herr')")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test2") + " values(2, 'mister')")); + q.exec("delete from " + test2); + QVERIFY_SQL( q, exec("insert into " + test2 + " values(1, 'herr')")); + QVERIFY_SQL( q, exec("insert into " + test2 + " values(2, 'mister')")); - q.exec("delete from " + qTableName("test3")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test3") + " values(1, 'foo', 'bar')")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test3") + " values(2, 'baz', 'joe')")); + q.exec("delete from " + test3); + QVERIFY_SQL( q, exec("insert into " + test3 + " values(1, 'foo', 'bar')")); + QVERIFY_SQL( q, exec("insert into " + test3 + " values(2, 'baz', 'joe')")); } } @@ -253,7 +257,7 @@ void tst_QSqlTableModel::select() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -294,7 +298,7 @@ void tst_QSqlTableModel::setRecord() QSqlTableModel model(0, db); model.setEditStrategy((QSqlTableModel::EditStrategy)submitpolicy); - model.setTable(qTableName("test3")); + model.setTable(test3); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -336,7 +340,7 @@ void tst_QSqlTableModel::insertRow() QSqlTableModel model(0, db); model.setEditStrategy(QSqlTableModel::OnRowChange); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -361,7 +365,7 @@ void tst_QSqlTableModel::insertRecord() QSqlTableModel model(0, db); model.setEditStrategy(QSqlTableModel::OnManualSubmit); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -394,7 +398,7 @@ void tst_QSqlTableModel::insertMultiRecords() QSqlTableModel model(0, db); model.setEditStrategy(QSqlTableModel::OnManualSubmit); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -421,7 +425,7 @@ void tst_QSqlTableModel::insertMultiRecords() QVERIFY(model.submitAll()); model.clear(); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -442,7 +446,7 @@ void tst_QSqlTableModel::submitAll() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); @@ -477,7 +481,7 @@ void tst_QSqlTableModel::removeRow() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); @@ -502,7 +506,7 @@ void tst_QSqlTableModel::removeRow() recreateTestTables(); - model.setTable(qTableName("test")); + model.setTable(test); model.setEditStrategy(QSqlTableModel::OnRowChange); QVERIFY_SQL(model, select()); QCOMPARE(model.rowCount(), 3); @@ -523,7 +527,7 @@ void tst_QSqlTableModel::removeRows() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); model.setEditStrategy(QSqlTableModel::OnFieldChange); QVERIFY_SQL(model, select()); @@ -539,7 +543,7 @@ void tst_QSqlTableModel::removeRows() model.clear(); recreateTestTables(); - model.setTable(qTableName("test")); + model.setTable(test); model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); QCOMPARE(model.rowCount(), 3); @@ -574,7 +578,7 @@ void tst_QSqlTableModel::removeInsertedRow() for (int i = 0; i <= 1; ++i) { QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); model.setEditStrategy(i == 0 @@ -607,7 +611,7 @@ void tst_QSqlTableModel::emptyTable() QCOMPARE(model.rowCount(), 0); QCOMPARE(model.columnCount(), 0); - model.setTable(qTableName("emptytable")); + model.setTable(qTableName("emptytable", __FILE__)); QCOMPARE(model.rowCount(), 0); QCOMPARE(model.columnCount(), 1); @@ -623,9 +627,9 @@ void tst_QSqlTableModel::tablesAndSchemas() CHECK_DATABASE(db); QSqlQuery q(db); - q.exec("DROP SCHEMA " + qTableName("testschema") + " CASCADE"); - QVERIFY_SQL( q, exec("create schema " + qTableName("testschema"))); - QString tableName = qTableName("testschema") + '.' + qTableName("testtable"); + q.exec("DROP SCHEMA " + qTableName("testschema", __FILE__) + " CASCADE"); + QVERIFY_SQL( q, exec("create schema " + qTableName("testschema", __FILE__))); + QString tableName = qTableName("testschema", __FILE__) + '.' + qTableName("testtable", __FILE__); QVERIFY_SQL( q, exec("create table " + tableName + "(id int)")); QVERIFY_SQL( q, exec("insert into " + tableName + " values(1)")); QVERIFY_SQL( q, exec("insert into " + tableName + " values(2)")); @@ -664,10 +668,10 @@ void tst_QSqlTableModel::primaryKeyOrder() if(tst_Databases::isPostgreSQL(db)) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - QVERIFY_SQL( q, exec("create table "+qTableName("foo")+"(a varchar(20), id int not null primary key, b varchar(20))")); + QVERIFY_SQL( q, exec("create table "+qTableName("foo", __FILE__)+"(a varchar(20), id int not null primary key, b varchar(20))")); QSqlTableModel model(0, db); - model.setTable(qTableName("foo")); + model.setTable(qTableName("foo", __FILE__)); QSqlIndex pk = model.primaryKey(); QCOMPARE(pk.count(), 1); @@ -693,7 +697,7 @@ void tst_QSqlTableModel::setInvalidFilter() // set an invalid filter, make sure it fails QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setFilter("blahfahsel"); QCOMPARE(model.filter(), QString("blahfahsel")); @@ -711,7 +715,7 @@ void tst_QSqlTableModel::setFilter() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setFilter("id = 1"); QCOMPARE(model.filter(), QString("id = 1")); QVERIFY_SQL(model, select()); @@ -762,12 +766,13 @@ void tst_QSqlTableModel::sqlite_bigTable() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString bigtable(qTableName("bigtable", __FILE__)); bool hasTransactions = db.driver()->hasFeature(QSqlDriver::Transactions); if (hasTransactions) QVERIFY(db.transaction()); QSqlQuery q(db); - QVERIFY_SQL( q, exec("create table "+qTableName("bigtable")+"(id int primary key, name varchar)")); - QVERIFY_SQL( q, prepare("insert into "+qTableName("bigtable")+"(id, name) values (?, ?)")); + QVERIFY_SQL( q, exec("create table "+bigtable+"(id int primary key, name varchar)")); + QVERIFY_SQL( q, prepare("insert into "+bigtable+"(id, name) values (?, ?)")); QTime startTime; startTime.start(); for (int i = 0; i < 10000; ++i) { @@ -781,7 +786,7 @@ void tst_QSqlTableModel::sqlite_bigTable() if (hasTransactions) QVERIFY(db.commit()); QSqlTableModel model(0, db); - model.setTable(qTableName("bigtable")); + model.setTable(bigtable); QVERIFY_SQL(model, select()); QSqlRecord rec = model.record(); @@ -801,7 +806,7 @@ void tst_QSqlTableModel::insertRecordBeforeSelect() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); QCOMPARE(model.lastError().type(), QSqlError::NoError); QSqlRecord buffer = model.record(); @@ -820,7 +825,7 @@ void tst_QSqlTableModel::insertRecordBeforeSelect() QCOMPARE(model.rowCount(), 0); QSqlTableModel model2(0, db); - model2.setTable(qTableName("test")); + model2.setTable(test); QVERIFY_SQL(model2, select()); QCOMPARE(model2.rowCount(), rowCount); } @@ -838,7 +843,7 @@ void tst_QSqlTableModel::submitAllOnInvalidTable() // setTable returns a void, so the error can only be caught by // manually checking lastError(). ### Qt5: This should be changed! - model.setTable(qTableName("invalidTable")); + model.setTable(qTableName("invalidTable", __FILE__)); QCOMPARE(model.lastError().type(), QSqlError::StatementError); // This will give us an empty record which is expected behavior @@ -866,7 +871,7 @@ void tst_QSqlTableModel::insertRecordsInLoop() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setEditStrategy(QSqlTableModel::OnManualSubmit); model.select(); @@ -952,7 +957,7 @@ void tst_QSqlTableModel::tableModifyWithBlank() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test4")); + model.setTable(qTableName("test4", __FILE__)); model.select(); //generate a time stamp for the test. Add one second to the current time to make sure @@ -1008,7 +1013,7 @@ void tst_QSqlTableModel::removeColumnAndRow() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); QCOMPARE(model.rowCount(), 3); @@ -1023,7 +1028,7 @@ void tst_QSqlTableModel::removeColumnAndRow() // check with another table because the model has been modified // but not the sql table QSqlTableModel model2(0, db); - model2.setTable(qTableName("test")); + model2.setTable(test); QVERIFY_SQL(model2, select()); QCOMPARE(model2.rowCount(), 2); QCOMPARE(model2.columnCount(), 3); @@ -1036,11 +1041,11 @@ void tst_QSqlTableModel::insertBeforeDelete() CHECK_DATABASE(db); QSqlQuery q(db); - QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(9, 'andrew', 9)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(10, 'justin', 10)")); + QVERIFY_SQL( q, exec("insert into " + test + " values(9, 'andrew', 9)")); + QVERIFY_SQL( q, exec("insert into " + test + " values(10, 'justin', 10)")); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); diff --git a/tests/auto/qsqlthread/tst_qsqlthread.cpp b/tests/auto/qsqlthread/tst_qsqlthread.cpp index 632586a28..971766b 100644 --- a/tests/auto/qsqlthread/tst_qsqlthread.cpp +++ b/tests/auto/qsqlthread/tst_qsqlthread.cpp @@ -53,6 +53,7 @@ #include #endif +const QString qtest(qTableName("qtest", __FILE__)); // set this define if Oracle is built with threading support //#define QOCI_THREADED @@ -115,7 +116,7 @@ public: QVERIFY_SQL(db, open()); int sum = 0; - QSqlQuery q("select id from " + qTableName("test"), db); + QSqlQuery q("select id from " + qtest, db); QVERIFY_SQL(q, isActive()); while (q.next()) sum += q.value(0).toInt(); @@ -150,7 +151,7 @@ public: QSqlDatabase db = QSqlDatabase::cloneDatabase(sourceDb, dbName); QVERIFY_SQL(db, open()); QSqlQuery q(db); - QVERIFY_SQL(q, prepare("insert into " + qTableName("test") + " values (?, ?, ?)")); + QVERIFY_SQL(q, prepare("insert into " + qtest + " values (?, ?, ?)")); int id = 10; for (int i = 0; i < ProdConIterations; ++i) { q.bindValue(0, ++id); @@ -187,10 +188,10 @@ public: QSqlDatabase db = QSqlDatabase::cloneDatabase(sourceDb, dbName); QVERIFY_SQL(db, open()); QSqlQuery q1(db), q2(db); - QVERIFY_SQL(q2, prepare("delete from " + qTableName("test") + " where id = :id")); + QVERIFY_SQL(q2, prepare("delete from " + qtest + " where id = :id")); for (int i = 0; i < ProdConIterations; ++i) { - QVERIFY_SQL(q1, exec("select max(id) from " + qTableName("test"))); + QVERIFY_SQL(q1, exec("select max(id) from " + qtest)); q1.first(); q2.bindValue("id", q1.value(0)); q1.clear(); @@ -231,7 +232,7 @@ public: // Executes a Query for reading, iterates over the first 4 results QSqlQuery q(sourceDb); for (int j = 0; j < ProdConIterations; ++j) { - QVERIFY_SQL(q, exec("select id,name from " + qTableName("test") + " order by id")); + QVERIFY_SQL(q, exec("select id,name from " + qtest + " order by id")); for (int i = 1; i < 4; ++i) { QVERIFY_SQL(q, next()); QCOMPARE(q.value(0).toInt(), i); @@ -242,7 +243,7 @@ public: // Executes a query for writing (appends a new row) QSqlQuery q(sourceDb); for (int j = 0; j < ProdConIterations; ++j) { - QVERIFY_SQL(q, exec(QString("insert into " + qTableName("test") + QVERIFY_SQL(q, exec(QString("insert into " + qtest + " (id, name) values(%1, '%2')") .arg(counter.fetchAndAddRelaxed(1)).arg("Robert"))); } @@ -250,7 +251,7 @@ public: case PreparedReading: { // Prepares a query for reading and iterates over the results QSqlQuery q(sourceDb); - QVERIFY_SQL(q, prepare("select id, name from " + qTableName("test") + " where id = ?")); + QVERIFY_SQL(q, prepare("select id, name from " + qtest + " where id = ?")); for (int j = 0; j < ProdConIterations; ++j) { q.addBindValue(j % 3 + 1); QVERIFY_SQL(q, exec()); @@ -260,7 +261,7 @@ public: break; } case PreparedWriting: { QSqlQuery q(sourceDb); - QVERIFY_SQL(q, prepare("insert into " + qTableName("test") + " (id, name) " + QVERIFY_SQL(q, prepare("insert into " + qtest + " (id, name) " "values(?, ?)")); for (int i = 0; i < ProdConIterations; ++i) { q.addBindValue(counter.fetchAndAddRelaxed(1)); @@ -302,7 +303,7 @@ void tst_QSqlThread::dropTestTables() QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); - tst_Databases::safeDropTables(db, QStringList() << qTableName("test") << qTableName("test2") << qTableName("emptytable")); + tst_Databases::safeDropTables(db, QStringList() << qtest << qTableName("qtest2", __FILE__) << qTableName("emptytable", __FILE__)); } } @@ -312,13 +313,13 @@ void tst_QSqlThread::createTestTables() QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); - QVERIFY_SQL(q, exec("create table " + qTableName("test") + QVERIFY_SQL(q, exec("create table " + qtest + "(id int NOT NULL primary key, name varchar(20), title int)")); - QVERIFY_SQL(q, exec("create table " + qTableName("test2") + QVERIFY_SQL(q, exec("create table " + qTableName("qtest2", __FILE__) + "(id int NOT NULL primary key, title varchar(20))")); - QVERIFY_SQL(q, exec("create table " + qTableName("emptytable") + QVERIFY_SQL(q, exec("create table " + qTableName("emptytable", __FILE__) + "(id int NOT NULL primary key)")); } } @@ -329,14 +330,14 @@ void tst_QSqlThread::repopulateTestTables() QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); - QVERIFY_SQL(q, exec("delete from " + qTableName("test"))); - QVERIFY_SQL(q, exec("insert into " + qTableName("test") + " values(1, 'harry', 1)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test") + " values(2, 'trond', 2)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test") + " values(3, 'vohi', 3)")); + QVERIFY_SQL(q, exec("delete from " + qtest)); + QVERIFY_SQL(q, exec("insert into " + qtest + " values(1, 'harry', 1)")); + QVERIFY_SQL(q, exec("insert into " + qtest + " values(2, 'trond', 2)")); + QVERIFY_SQL(q, exec("insert into " + qtest + " values(3, 'vohi', 3)")); - QVERIFY_SQL(q, exec("delete from " + qTableName("test2"))); - QVERIFY_SQL(q, exec("insert into " + qTableName("test2") + " values(1, 'herr')")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test2") + " values(2, 'mister')")); + QVERIFY_SQL(q, exec("delete from " + qTableName("test2", __FILE__))); + QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__) + " values(1, 'herr')")); + QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__) + " values(2, 'mister')")); } } -- cgit v0.12 From 4b276240e07de5bb7fd5728aae0249643aeb6ec5 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 10 Mar 2010 17:01:00 +1000 Subject: Fixes QSqlThread autotest --- tests/auto/qsqlthread/tst_qsqlthread.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qsqlthread/tst_qsqlthread.cpp b/tests/auto/qsqlthread/tst_qsqlthread.cpp index 971766b..791f804 100644 --- a/tests/auto/qsqlthread/tst_qsqlthread.cpp +++ b/tests/auto/qsqlthread/tst_qsqlthread.cpp @@ -335,9 +335,9 @@ void tst_QSqlThread::repopulateTestTables() QVERIFY_SQL(q, exec("insert into " + qtest + " values(2, 'trond', 2)")); QVERIFY_SQL(q, exec("insert into " + qtest + " values(3, 'vohi', 3)")); - QVERIFY_SQL(q, exec("delete from " + qTableName("test2", __FILE__))); - QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__) + " values(1, 'herr')")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__) + " values(2, 'mister')")); + QVERIFY_SQL(q, exec("delete from " + qTableName("qtest2", __FILE__))); + QVERIFY_SQL(q, exec("insert into " + qTableName("qtest2", __FILE__) + " values(1, 'herr')")); + QVERIFY_SQL(q, exec("insert into " + qTableName("qtest2", __FILE__) + " values(2, 'mister')")); } } -- cgit v0.12 From 7e78d2668e508f929243fe2169e1d9937b8d2b67 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 10 Mar 2010 10:18:03 +0200 Subject: Fixed paint crash in Symbian for trasnclucent dialogs. In Symbian Qt::WA_TrasnclucentBackground is set for QDialogs. In QTBUG-8706 there is setVisible(false) call for widget before orientation is switched from portrait to landscape with SW APIs. This setVisible call invalidates/marks the widget area, basically whole portrait screen (0,0, 360, 640 in 5800XM) dirty. The orientation switch changes backingstore/windowsurface size to 640, 360, and invalidates that area. As an consequnce the widget dirty area after these two operations is 0, 0, 640, 640. Now when the widget is made visible again, the dirty region is larger than a screen and causes a crash when trying to access windowsurface bitmap data outside its bounds. Fixed the issue by using QPainter instead of own implementation. QPainter handles intersecting with image automatically. Another benefit of QPainter is that it uses platform specific drawHelpers if available to speed-up drawing. Task-number: QTBUG-8706 Reviewed-by: Jani Hautakangas --- src/gui/painting/qwindowsurface_s60.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp index 028ec48..d05c7e4 100644 --- a/src/gui/painting/qwindowsurface_s60.cpp +++ b/src/gui/painting/qwindowsurface_s60.cpp @@ -70,13 +70,13 @@ QS60WindowSurface::QS60WindowSurface(QWidget* widget) // We create empty CFbsBitmap here -> it will be resized in setGeometry CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); // CBase derived object needs check on new qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) ); - + QS60PixmapData *data = new QS60PixmapData(QPixmapData::PixmapType); if (data) { data->fromSymbianBitmap(bitmap, true); d_ptr->device = QPixmap(data); } - + setStaticContentsSupport(true); } QS60WindowSurface::~QS60WindowSurface() @@ -89,24 +89,15 @@ void QS60WindowSurface::beginPaint(const QRegion &rgn) if (!qt_widget_private(window())->isOpaque) { QS60PixmapData *pixmapData = static_cast(d_ptr->device.data_ptr().data()); pixmapData->beginDataAccess(); - QImage &image = pixmapData->image; - QRgb *data = reinterpret_cast(image.bits()); - const int row_stride = image.bytesPerLine() / 4; + QPainter p(&pixmapData->image); + p.setCompositionMode(QPainter::CompositionMode_Source); const QVector rects = rgn.rects(); + const QColor blank = Qt::transparent; for (QVector::const_iterator it = rects.begin(); it != rects.end(); ++it) { - const int x_start = it->x(); - const int width = it->width(); - - const int y_start = it->y(); - const int height = it->height(); - - QRgb *row = data + row_stride * y_start; - for (int y = 0; y < height; ++y) { - qt_memfill(row + x_start, 0U, width); - row += row_stride; - } + p.fillRect(*it, blank); } + pixmapData->endDataAccess(); } } @@ -128,7 +119,7 @@ QImage* QS60WindowSurface::buffer(const QWidget *widget) const QPoint off = offset(widget); QImage *img = &(static_cast(d_ptr->device.data_ptr().data())->image); - + QRect rect(off, widget->size()); rect &= QRect(QPoint(), img->size()); -- cgit v0.12 From 5342a81075f3efa17fd4c495411b2c2bd2a369d1 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 10 Mar 2010 10:21:53 +0100 Subject: fix menu handling on Windows CE Don't recreate the menu handles on every rebuild. Now, we clear the menu before rebuilding. Also, we have to clear the menu before destroying the menu bar handle. Otherwise, DestroyWindow kills our menu handles. Task-number: QTBUG-8754 Reviewed-by: thartman --- src/gui/widgets/qmenu_p.h | 2 +- src/gui/widgets/qmenu_wince.cpp | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index aaed6b1..495872c 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -347,7 +347,7 @@ public: void syncAction(QWceMenuAction *); inline void syncAction(QAction *a) { syncAction(findAction(a)); } void removeAction(QWceMenuAction *); - void rebuild(bool reCreate = false); + void rebuild(); inline void removeAction(QAction *a) { removeAction(findAction(a)); } inline QWceMenuAction *findAction(QAction *a) { for(int i = 0; i < actionItems.size(); i++) { diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp index edef466..1577f0a 100644 --- a/src/gui/widgets/qmenu_wince.cpp +++ b/src/gui/widgets/qmenu_wince.cpp @@ -253,6 +253,12 @@ static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action, bool create } } +// Removes all items from the menu without destroying the handles. +static void qt_wce_clear_menu(HMENU hMenu) +{ + while (RemoveMenu(hMenu, 0, MF_BYPOSITION)); +} + /*! \internal @@ -403,7 +409,8 @@ QMenuPrivate::QWceMenuPrivate::QWceMenuPrivate() { QMenuPrivate::QWceMenuPrivate::~QWceMenuPrivate() { qt_wce_delete_action_list(&actionItems); - menuHandle = 0; + if (menuHandle) + DestroyMenu(menuHandle); } void QMenuPrivate::QWceMenuPrivate::addAction(QAction *a, QWceMenuAction *before) { @@ -438,14 +445,17 @@ HMENU QMenuPrivate::wceMenu(bool create) { if (!wce_menu) wce_menu = new QWceMenuPrivate; if (!wce_menu->menuHandle || create) - wce_menu->rebuild(create); + wce_menu->rebuild(); return wce_menu->menuHandle; } -void QMenuPrivate::QWceMenuPrivate::rebuild(bool reCreate) { - if (menuHandle && !reCreate) - DestroyMenu(menuHandle); - menuHandle = CreatePopupMenu(); +void QMenuPrivate::QWceMenuPrivate::rebuild() +{ + if (!menuHandle) + menuHandle = CreatePopupMenu(); + else + qt_wce_clear_menu(menuHandle); + for (int i = 0; i < actionItems.size(); ++i) { QWceMenuAction *action = actionItems.at(i); action->menuHandle = menuHandle; @@ -521,6 +531,7 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() { resourceHandle = IDR_MAIN_MENU5; } Q_ASSERT_X(menubarHandle, "rebuild !created", "menubar already deleted"); + qt_wce_clear_menu(menuHandle); DestroyWindow(menubarHandle); menubarHandle = qt_wce_create_menubar(parentWindowHandle, qt_wce_get_module_handle(), resourceHandle); Q_ASSERT_X(menubarHandle, "rebuild classic menu", "cannot create menubar from resource"); @@ -562,6 +573,7 @@ void QMenuBarPrivate::QWceMenuBarPrivate::rebuild() { leftButtonIsMenu = (leftButtonAction && leftButtonAction->menu()); Q_ASSERT_X(menubarHandle, "rebuild !created", "menubar already deleted"); + qt_wce_clear_menu(menuHandle); DestroyWindow(menubarHandle); if (leftButtonIsMenu) { menubarHandle = qt_wce_create_menubar(parentWindowHandle, qt_wce_get_module_handle(), IDR_MAIN_MENU2); -- cgit v0.12 From 4a0b21f43a2ce59c4fa4a79fe33fa7f19822eb04 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 10 Mar 2010 10:40:37 +0100 Subject: compile fix for plugins\sqldrivers\sqlite on WinCE 6 Don't use localtime_s. Reviewed-by: thartman --- src/plugins/sqldrivers/sqlite/sqlite.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/sqldrivers/sqlite/sqlite.pro b/src/plugins/sqldrivers/sqlite/sqlite.pro index c609a9e..fb31233 100644 --- a/src/plugins/sqldrivers/sqlite/sqlite.pro +++ b/src/plugins/sqldrivers/sqlite/sqlite.pro @@ -14,4 +14,6 @@ SOURCES = smain.cpp \ QMAKE_CXXFLAGS *= $$QT_CFLAGS_SQLITE } +wince*: DEFINES += HAVE_LOCALTIME_S=0 + include(../qsqldriverbase.pri) -- cgit v0.12 From fe172ae65bae00ad31199ff74b10c61f4d4adbd5 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 9 Mar 2010 12:06:03 +0200 Subject: Added some missing IBY export paths to platform_path.prf Also removed some IBY export paths that target layers below middleware, as those are not likely to be ever needed by Qt projects, since Qt itself is part of the middleware layer. Reviewed-by: Janne Anttila --- mkspecs/features/symbian/platform_paths.prf | 96 +++++++++++++---------------- 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/mkspecs/features/symbian/platform_paths.prf b/mkspecs/features/symbian/platform_paths.prf index c723d8c..a55e842 100644 --- a/mkspecs/features/symbian/platform_paths.prf +++ b/mkspecs/features/symbian/platform_paths.prf @@ -230,33 +230,6 @@ exists($${EPOCROOT}epoc32/include/platform_paths.prf) { OS_LAYER_LIBUTILITY_SYSTEMINCLUDE = $$OS_LAYER_PLATFORM_EXPORT_PATH(stdapis/utility) - # --------------------------------------- - # Definitions to export IBY files to different folders where they will be taken - # to ROM image - # --------------------------------------- - - defineReplace(CORE_APP_LAYER_IBY_EXPORT_PATH) { - return(/epoc32/rom/include/core/app/$$1) - } - defineReplace(CORE_MW_LAYER_IBY_EXPORT_PATH) { - return(/epoc32/rom/include/core/mw/$$1) - } - defineReplace(CORE_OSEXT_LAYER_IBY_EXPORT_PATH) { - return(/epoc32/rom/include/core/os/$$1) - } - defineReplace(CORE_OS_LAYER_IBY_EXPORT_PATH) { - return(/epoc32/rom/include/core/os/$$1) - } - defineReplace(CORE_ADAPT_LAYER_IBY_EXPORT_PATH) { - return(/epoc32/rom/include/$$1) - } - - # You need to define the following in pro-file, if you are using the stllib: - # QMAKE_CXXFLAGS.CW *= $$STLLIB_USAGE_CW_FLAGS - # DEFINES *= $$STLLIB_USAGE_DEFINES - STLLIB_USAGE_CW_FLAGS = "-wchar_t on" - STLLIB_USAGE_DEFINES = _WCHAR_T_DECLARED - } else { # Old pre-SF structure # --------------------------------------- @@ -450,34 +423,49 @@ exists($${EPOCROOT}epoc32/include/platform_paths.prf) { OS_LAYER_LIBUTILITY_SYSTEMINCLUDE = $$OS_LAYER_PLATFORM_EXPORT_PATH(stdapis/utility) \ /epoc32/include/stdapis/utility - # --------------------------------------- - # Definitions to export IBY files to different folders where they will be taken - # to ROM image - # --------------------------------------- - - defineReplace(CORE_APP_LAYER_IBY_EXPORT_PATH) { - return(/epoc32/rom/include/core/app/$$1) - } - defineReplace(CORE_MW_LAYER_IBY_EXPORT_PATH) { - return(/epoc32/rom/include/core/mw/$$1) - } - defineReplace(CORE_OSEXT_LAYER_IBY_EXPORT_PATH) { - return(/epoc32/rom/include/core/osext/$$1) - } - defineReplace(CORE_OS_LAYER_IBY_EXPORT_PATH) { - return(/epoc32/rom/include/core/osext/$$1) - } - defineReplace(CORE_ADAPT_LAYER_IBY_EXPORT_PATH) { - return(/epoc32/rom/include/$$1) - } - - # You need to define the following in pro-file, if you are using the stllib: - # QMAKE_CXXFLAGS.CW *= $$STLLIB_USAGE_CW_FLAGS - # DEFINES *= $$STLLIB_USAGE_DEFINES - STLLIB_USAGE_CW_FLAGS = "-wchar_t on" - STLLIB_USAGE_DEFINES = _WCHAR_T_DECLARED - } + + # Definitions common to both structures + + # --------------------------------------- + # Definitions to export IBY files to different folders where they will be taken + # to ROM image + # --------------------------------------- + + defineReplace(CORE_APP_LAYER_IBY_EXPORT_PATH) { + return(/epoc32/rom/include/core/app/$$1) + } + defineReplace(CORE_MW_LAYER_IBY_EXPORT_PATH) { + return(/epoc32/rom/include/core/mw/$$1) + } + + defineReplace(LANGUAGE_APP_LAYER_IBY_EXPORT_PATH) { + return(/epoc32/rom/include/language/app/$$1) + } + defineReplace(LANGUAGE_MW_LAYER_IBY_EXPORT_PATH) { + return(/epoc32/rom/include/language/mw/$$1) + } + + defineReplace(CUSTOMER_APP_LAYER_IBY_EXPORT_PATH) { + return(/epoc32/rom/include/customer/app/$$1) + } + defineReplace(CUSTOMER_MW_LAYER_IBY_EXPORT_PATH) { + return(/epoc32/rom/include/customer/mw/$$1) + } + + defineReplace(CUSTOMER_VARIANT_APP_LAYER_IBY_EXPORT_PATH) { + return(/epoc32/rom/include/customervariant/app/$$1) + } + defineReplace(CUSTOMER_VARIANT_MW_LAYER_IBY_EXPORT_PATH) { + return(/epoc32/rom/include/customervariant/mw/$$1) + } + + # You need to define the following in pro-file, if you are using the stllib: + # QMAKE_CXXFLAGS.CW *= $$STLLIB_USAGE_CW_FLAGS + # DEFINES *= $$STLLIB_USAGE_DEFINES + STLLIB_USAGE_CW_FLAGS = "-wchar_t on" + STLLIB_USAGE_DEFINES = _WCHAR_T_DECLARED + } -- cgit v0.12 From 42a7c756482f645a011ff6fe3607038d749c1d88 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 9 Mar 2010 12:08:30 +0200 Subject: Export qtdemoapps.iby to proper location Part of QtP delta reduction effort Reviewed-by: Janne Anttila --- src/s60installs/s60installs.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 1f3b4a6..86deb40 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -125,5 +125,5 @@ symbian: { } BLD_INF_RULES.prj_exports += "qt.iby $$CORE_MW_LAYER_IBY_EXPORT_PATH(qt.iby)" - BLD_INF_RULES.prj_exports += "qtdemoapps.iby $$CORE_APP_LAYER_IBY_EXPORT_PATH(qtdemoapps.iby)" + BLD_INF_RULES.prj_exports += "qtdemoapps.iby $$CUSTOMER_VARIANT_APP_LAYER_IBY_EXPORT_PATH(qtdemoapps.iby)" } -- cgit v0.12 From 7b774c71d2c146a9c79bf9ffbe78cbc8ae95d7f8 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 9 Mar 2010 12:18:03 +0200 Subject: Fix sqlite3_v9.2.zip to export sqlite3.iby to correct location. sqlite3.iby needs to be exported under epoc32/rom/include/core/mw, instead of epoc32/rom/include. Part of QtP delta reduction effort Reviewed-by: TrustMe --- .../sqldrivers/sqlite_symbian/SQLite3_v9.2.zip | Bin 3155605 -> 3119273 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/plugins/sqldrivers/sqlite_symbian/SQLite3_v9.2.zip b/src/plugins/sqldrivers/sqlite_symbian/SQLite3_v9.2.zip index 923cca4..df78644 100644 Binary files a/src/plugins/sqldrivers/sqlite_symbian/SQLite3_v9.2.zip and b/src/plugins/sqldrivers/sqlite_symbian/SQLite3_v9.2.zip differ -- cgit v0.12 From 3ff22aa66c8e6c2cb34c8ea9dc9533143bf4cd52 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 9 Mar 2010 12:37:39 +0200 Subject: QUnixPrintWidget should not be declared in Symbian Having QUnixPrintWidget declaration causes build breaks in some environments, so defined it out in Symbian. Part of QtP delta reduction effort. Reviewed-by: Janne Anttila --- src/gui/dialogs/qprintdialog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qprintdialog.h b/src/gui/dialogs/qprintdialog.h index ecd50c1..94177ea 100644 --- a/src/gui/dialogs/qprintdialog.h +++ b/src/gui/dialogs/qprintdialog.h @@ -56,7 +56,7 @@ class QPrintDialogPrivate; class QPushButton; class QPrinter; -#if defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC) +#if defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN) class QUnixPrintWidgetPrivate; class Q_GUI_EXPORT QUnixPrintWidget : public QWidget -- cgit v0.12 From db067f7467b3116e72b34c56408ba7dd4ef7cd91 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 9 Mar 2010 13:18:30 +0200 Subject: Added forwarding headers for qplatformdefs.h in Symbian mkspecs Missing qplatformdefs.h file caused configure to fail on Linux environments. Part of QtP delta reduction effort. Reviewed-by: axis --- mkspecs/symbian-abld/qplatformdefs.h | 43 +++++++++++++++++++++++++++++++++++ mkspecs/symbian-sbsv2/qplatformdefs.h | 43 +++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 mkspecs/symbian-abld/qplatformdefs.h create mode 100644 mkspecs/symbian-sbsv2/qplatformdefs.h diff --git a/mkspecs/symbian-abld/qplatformdefs.h b/mkspecs/symbian-abld/qplatformdefs.h new file mode 100644 index 0000000..4cd0d73 --- /dev/null +++ b/mkspecs/symbian-abld/qplatformdefs.h @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../common/symbian/qplatformdefs.h" + diff --git a/mkspecs/symbian-sbsv2/qplatformdefs.h b/mkspecs/symbian-sbsv2/qplatformdefs.h new file mode 100644 index 0000000..4cd0d73 --- /dev/null +++ b/mkspecs/symbian-sbsv2/qplatformdefs.h @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../common/symbian/qplatformdefs.h" + -- cgit v0.12 From 66619b3e6dd8c94564d8d63295780a42ca87e6d3 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 9 Mar 2010 14:38:40 +0200 Subject: Enabled some examples by default in Symbian builds Part of QtP delta reduction effort. Reviewed-by: Janne Anttila --- examples/animation/animatedtiles/animatedtiles.pro | 5 +++++ examples/animation/appchooser/appchooser.pro | 5 +++++ examples/animation/easing/easing.pro | 5 +++++ examples/animation/moveblocks/moveblocks.pro | 5 +++++ examples/animation/states/states.pro | 5 +++++ examples/animation/stickman/stickman.pro | 5 +++++ examples/examples.pro | 2 ++ examples/gestures/imagegestures/imagegestures.pro | 5 +++++ examples/sql/masterdetail/masterdetail.pro | 5 ++++- examples/sql/sql.pro | 6 ++++-- 10 files changed, 45 insertions(+), 3 deletions(-) diff --git a/examples/animation/animatedtiles/animatedtiles.pro b/examples/animation/animatedtiles/animatedtiles.pro index 1840b17..d700642 100644 --- a/examples/animation/animatedtiles/animatedtiles.pro +++ b/examples/animation/animatedtiles/animatedtiles.pro @@ -6,3 +6,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/animation/animatedtiles sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS animatedtiles.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/animation/animatedtiles INSTALLS += target sources + +symbian { + TARGET.UID3 = 0xA000D7D1 + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) +} diff --git a/examples/animation/appchooser/appchooser.pro b/examples/animation/appchooser/appchooser.pro index 847b60a..7d45da2 100644 --- a/examples/animation/appchooser/appchooser.pro +++ b/examples/animation/appchooser/appchooser.pro @@ -6,3 +6,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/animation/appchooser sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS appchooser.pro sources.path = $$[QT_INSTALL_EXAMPLES]/animation/appchooser INSTALLS += target sources + +symbian { + TARGET.UID3 = 0xA000E3F5 + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) +} diff --git a/examples/animation/easing/easing.pro b/examples/animation/easing/easing.pro index 8e8a35f..a8eda70 100644 --- a/examples/animation/easing/easing.pro +++ b/examples/animation/easing/easing.pro @@ -12,3 +12,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/animation/easing sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS easing.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/animation/easing INSTALLS += target sources + +symbian { + TARGET.UID3 = 0xA000E3F6 + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) +} diff --git a/examples/animation/moveblocks/moveblocks.pro b/examples/animation/moveblocks/moveblocks.pro index b8e88b2..0a32ecf 100644 --- a/examples/animation/moveblocks/moveblocks.pro +++ b/examples/animation/moveblocks/moveblocks.pro @@ -5,3 +5,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/animation/moveblocks sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS moveblocks.pro sources.path = $$[QT_INSTALL_EXAMPLES]/animation/moveblocks INSTALLS += target sources + +symbian { + TARGET.UID3 = 0xA000E3F7 + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) +} diff --git a/examples/animation/states/states.pro b/examples/animation/states/states.pro index f4d1e0b..9d9a9c1 100644 --- a/examples/animation/states/states.pro +++ b/examples/animation/states/states.pro @@ -6,3 +6,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/animation/states sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS states.pro sources.path = $$[QT_INSTALL_EXAMPLES]/animation/states INSTALLS += target sources + +symbian { + TARGET.UID3 = 0xA000E3F8 + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) +} diff --git a/examples/animation/stickman/stickman.pro b/examples/animation/stickman/stickman.pro index 487ff3a..37ff8d3 100644 --- a/examples/animation/stickman/stickman.pro +++ b/examples/animation/stickman/stickman.pro @@ -17,3 +17,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/animation/stickman sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS stickman.pro sources.path = $$[QT_INSTALL_EXAMPLES]/animation/stickman INSTALLS += target sources + +symbian { + TARGET.UID3 = 0xA000E3F9 + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) +} diff --git a/examples/examples.pro b/examples/examples.pro index d11e36b..7d9aa05 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -36,6 +36,8 @@ symbian: SUBDIRS = \ mainwindows \ sql \ uitools \ + animation \ + gestures \ xml contains(QT_CONFIG, multimedia) { diff --git a/examples/gestures/imagegestures/imagegestures.pro b/examples/gestures/imagegestures/imagegestures.pro index 8c947e4..5365558 100644 --- a/examples/gestures/imagegestures/imagegestures.pro +++ b/examples/gestures/imagegestures/imagegestures.pro @@ -14,3 +14,8 @@ sources.files = $$SOURCES \ sources.path = $$[QT_INSTALL_EXAMPLES]/gestures/imagegestures INSTALLS += target \ sources + +symbian { + TARGET.UID3 = 0xA000D7D0 + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) +} diff --git a/examples/sql/masterdetail/masterdetail.pro b/examples/sql/masterdetail/masterdetail.pro index 89e7e73..41a0274 100644 --- a/examples/sql/masterdetail/masterdetail.pro +++ b/examples/sql/masterdetail/masterdetail.pro @@ -15,4 +15,7 @@ sources.files = $$SOURCES *.h $$RESOURCES $$FORMS masterdetail.pro *.xml images sources.path = $$[QT_INSTALL_EXAMPLES]/sql/masterdetail INSTALLS += target sources -symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) +symbian { + TARGET.UID3 = 0xA000D7CF + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) +} diff --git a/examples/sql/sql.pro b/examples/sql/sql.pro index 644e2c7..331a210 100644 --- a/examples/sql/sql.pro +++ b/examples/sql/sql.pro @@ -5,10 +5,12 @@ SUBDIRS = drilldown relationaltablemodel \ sqlwidgetmapper +!wince*: SUBDIRS += masterdetail + !wince*:!symbian: SUBDIRS += \ querymodel \ - tablemodel \ - masterdetail + tablemodel + # install sources.files = connection.h sql.pro README -- cgit v0.12 From 8dd695793dd41dc57ded6506aadbd23786e11cf4 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 9 Mar 2010 14:51:06 +0200 Subject: Add '.' dir as the first include directory in Symbian RVCT seems to use '.' directory implictly as the first include path, but WINSCW compiler doesn't do this, so add it explicitly to make sure both builds have similar include order. Part of QtP delta reduction effort. Reviewed-by: Janne Anttila --- mkspecs/common/symbian/symbian.conf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index a90ef91..77b42a9 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -120,14 +120,17 @@ MMP_RULES += PAGED BYTEPAIRCOMPRESSTARGET MMP_RULES += $$MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA SYMBIAN_PLATFORMS = WINSCW GCCE ARMV5 ARMV6 -# Legacy support requires some hardcoded stdapis paths. INCLUDEPATH = \ $$[QT_INSTALL_PREFIX]/mkspecs/common/symbian/stl-off \ $$[QT_INSTALL_PREFIX]/mkspecs/common/symbian \ $${EPOCROOT}epoc32/include \ $$OS_LAYER_LIBC_SYSTEMINCLUDE \ $$INCLUDEPATH - + +# Ensure '.' directory is the first in include path. +# RVCT seems to do this automatically, but WINSCW compiler does not, so add it here. +MMP_RULES += "USERINCLUDE ." + # Supports S60 3.0, 3.1, 3.2 and 5.0 by default default_deployment.pkg_prerules = \ "; Default HW/platform dependencies" \ -- cgit v0.12 From de66b772294e314828d85cb9cdd5db82221f317a Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 9 Mar 2010 15:02:25 +0200 Subject: Added check for null pointer in qt_vg_unregister_pixmap. The method qt_vg_unregister_pixmap is sometimes called when the QVGSharedContext is already destroyed. Do not try to access it if it is null. Part of QtP delta reduction effort. Reviewed-by: Jason Barron --- src/openvg/qwindowsurface_vgegl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp index 9c44545..693312a 100644 --- a/src/openvg/qwindowsurface_vgegl.cpp +++ b/src/openvg/qwindowsurface_vgegl.cpp @@ -177,7 +177,8 @@ void qt_vg_unregister_pixmap(QVGPixmapData *pd) pd->prev->next = pd->next; } else { QVGSharedContext *shared = sharedContext(); - shared->firstPixmap = pd->next; + if (shared) + shared->firstPixmap = pd->next; } } -- cgit v0.12 From b9408cb1c0d46ef5532a0a8c646a677e8794210d Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 9 Mar 2010 15:59:53 +0200 Subject: Renamed test benchmark targets. Many of the benchmarks generate executables with same names as the autotests. This is a big problem for Symbian, where all binaries are stored into single directory. Renamed benchmark targets to include 'bench' in their name to ensure no overlap in target names. Part of QtP delta reduction effort. Reviewed-by: Liang Qi --- tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro | 2 +- tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro | 2 +- tests/benchmarks/corelib/io/qfile/qfile.pro | 2 +- tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro | 2 +- tests/benchmarks/corelib/io/qiodevice/qiodevice.pro | 2 +- tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro | 2 +- tests/benchmarks/corelib/kernel/events/events.pro | 2 +- tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro | 2 +- tests/benchmarks/corelib/kernel/qobject/qobject.pro | 2 +- tests/benchmarks/corelib/kernel/qvariant/qvariant.pro | 2 +- tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro | 2 +- .../corelib/tools/containers-associative/containers-associative.pro | 2 +- .../corelib/tools/containers-sequential/containers-sequential.pro | 2 +- tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro | 2 +- tests/benchmarks/corelib/tools/qrect/qrect.pro | 2 +- tests/benchmarks/corelib/tools/qregexp/qregexp.pro | 2 +- tests/benchmarks/corelib/tools/qstring/qstring.pro | 2 +- tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro | 2 +- tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro | 2 +- tests/benchmarks/gui/animation/qanimation/qanimation.pro | 2 +- .../gui/graphicsview/qgraphicsanchorlayout/qgraphicsanchorlayout.pro | 2 +- tests/benchmarks/gui/graphicsview/qgraphicsitem/qgraphicsitem.pro | 2 +- tests/benchmarks/gui/graphicsview/qgraphicsscene/qgraphicsscene.pro | 2 +- tests/benchmarks/gui/graphicsview/qgraphicsview/qgraphicsview.pro | 2 +- tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro | 2 +- tests/benchmarks/gui/image/blendbench/blendbench.pro | 2 +- tests/benchmarks/gui/image/qimagereader/qimagereader.pro | 2 +- tests/benchmarks/gui/image/qpixmap/qpixmap.pro | 2 +- tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro | 2 +- tests/benchmarks/gui/itemviews/qtableview/qtableview.pro | 2 +- tests/benchmarks/gui/kernel/qapplication/qapplication.pro | 2 +- tests/benchmarks/gui/kernel/qwidget/qwidget.pro | 2 +- tests/benchmarks/gui/math3d/qmatrix4x4/qmatrix4x4.pro | 2 +- tests/benchmarks/gui/math3d/qquaternion/qquaternion.pro | 2 +- tests/benchmarks/gui/painting/qpainter/qpainter.pro | 2 +- tests/benchmarks/gui/painting/qregion/qregion.pro | 2 +- tests/benchmarks/gui/painting/qtransform/qtransform.pro | 2 +- tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro | 2 +- tests/benchmarks/gui/text/qfontmetrics/qfontmetrics.pro | 2 +- tests/benchmarks/gui/text/qtext/qtext.pro | 2 +- .../qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro | 2 +- tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro | 2 +- tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro | 2 +- tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro | 2 +- tests/benchmarks/opengl/opengl.pro | 2 +- tests/benchmarks/script/qscriptclass/qscriptclass.pro | 2 +- tests/benchmarks/script/qscriptengine/qscriptengine.pro | 2 +- tests/benchmarks/script/qscriptvalue/qscriptvalue.pro | 2 +- tests/benchmarks/svg/qsvgrenderer/qsvgrenderer.pro | 2 +- 49 files changed, 49 insertions(+), 49 deletions(-) diff --git a/tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro b/tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro index 3167f26..23f0e00 100644 --- a/tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro +++ b/tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro @@ -1,5 +1,5 @@ load(qttest_p4) -TARGET = tst_qtextcodec +TARGET = tst_bench_qtextcodec QT -= gui SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro index e06d746..320746c 100755 --- a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro +++ b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qdiriterator +TARGET = tst_bench_qdiriterator DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/io/qfile/qfile.pro b/tests/benchmarks/corelib/io/qfile/qfile.pro index 99505c3..8663cab 100644 --- a/tests/benchmarks/corelib/io/qfile/qfile.pro +++ b/tests/benchmarks/corelib/io/qfile/qfile.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qfile +TARGET = tst_bench_qfile QT -= gui win32: DEFINES+= _CRT_SECURE_NO_WARNINGS diff --git a/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro b/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro index eca619f..3edf6a6 100644 --- a/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro +++ b/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qfileinfo +TARGET = tst_bench_qfileinfo DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro b/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro index 749a4d6..2e0f6a1 100755 --- a/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro +++ b/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qiodevice +TARGET = tst_bench_qiodevice TARGET.EPOCHEAPSIZE = 0x100000 0x2000000 DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro b/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro index c1b04f4..74fd534 100644 --- a/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro +++ b/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qtemporaryfile +TARGET = tst_bench_qtemporaryfile DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/kernel/events/events.pro b/tests/benchmarks/corelib/kernel/events/events.pro index adf2317..43a7131 100644 --- a/tests/benchmarks/corelib/kernel/events/events.pro +++ b/tests/benchmarks/corelib/kernel/events/events.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_events +TARGET = tst_bench_events DEPENDPATH += . INCLUDEPATH += . # Input diff --git a/tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro b/tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro index 78300f6..a02273f 100644 --- a/tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro +++ b/tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro @@ -1,5 +1,5 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qmetaobject +TARGET = tst_bench_qmetaobject SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/kernel/qobject/qobject.pro b/tests/benchmarks/corelib/kernel/qobject/qobject.pro index 2855de4..1baaf58 100644 --- a/tests/benchmarks/corelib/kernel/qobject/qobject.pro +++ b/tests/benchmarks/corelib/kernel/qobject/qobject.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qobject +TARGET = tst_bench_qobject DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/kernel/qvariant/qvariant.pro b/tests/benchmarks/corelib/kernel/qvariant/qvariant.pro index 63b5442..f3dd66a 100644 --- a/tests/benchmarks/corelib/kernel/qvariant/qvariant.pro +++ b/tests/benchmarks/corelib/kernel/qvariant/qvariant.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qvariant +TARGET = tst_bench_qvariant DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro b/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro index f9c1978..654b7b6 100644 --- a/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro +++ b/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qthreadstorage +TARGET = tst_bench_qthreadstorage SOURCES += tst_qthreadstorage.cpp diff --git a/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro b/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro index c6f3fa6..3e3bf2b 100644 --- a/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro +++ b/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_containers-associative +TARGET = tst_bench_containers-associative DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro b/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro index bf6db44..4236b35 100644 --- a/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro +++ b/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_containers-sequential +TARGET = tst_bench_containers-sequential DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro b/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro index a0bf021..3474dd0 100755 --- a/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro +++ b/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qbytearray +TARGET = tst_bench_qbytearray DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/tools/qrect/qrect.pro b/tests/benchmarks/corelib/tools/qrect/qrect.pro index 6e35119..4bd05aa 100644 --- a/tests/benchmarks/corelib/tools/qrect/qrect.pro +++ b/tests/benchmarks/corelib/tools/qrect/qrect.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qrect +TARGET = tst_bench_qrect DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro b/tests/benchmarks/corelib/tools/qregexp/qregexp.pro index 83d723c..e0f47c9 100644 --- a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro +++ b/tests/benchmarks/corelib/tools/qregexp/qregexp.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qregexp +TARGET = tst_bench_qregexp DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/tools/qstring/qstring.pro b/tests/benchmarks/corelib/tools/qstring/qstring.pro index 2e7c86a..fa4310e 100644 --- a/tests/benchmarks/corelib/tools/qstring/qstring.pro +++ b/tests/benchmarks/corelib/tools/qstring/qstring.pro @@ -1,5 +1,5 @@ load(qttest_p4) -TARGET = tst_qstring +TARGET = tst_bench_qstring QT -= gui SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro b/tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro index 79171b4..948657e 100644 --- a/tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro +++ b/tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qstringbuilder +TARGET = tst_bench_qstringbuilder QMAKE_CXXFLAGS += -g QMAKE_CFLAGS += -g diff --git a/tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro b/tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro index 11cceb0..21007d1 100644 --- a/tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro +++ b/tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro @@ -1,5 +1,5 @@ load(qttest_p4) -TARGET = tst_qstringlist +TARGET = tst_bench_qstringlist QT -= gui SOURCES += main.cpp diff --git a/tests/benchmarks/gui/animation/qanimation/qanimation.pro b/tests/benchmarks/gui/animation/qanimation/qanimation.pro index 55cd75e..53a139a 100644 --- a/tests/benchmarks/gui/animation/qanimation/qanimation.pro +++ b/tests/benchmarks/gui/animation/qanimation/qanimation.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qanimation +TARGET = tst_bench_qanimation DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsanchorlayout/qgraphicsanchorlayout.pro b/tests/benchmarks/gui/graphicsview/qgraphicsanchorlayout/qgraphicsanchorlayout.pro index 0d563b9..3ede6e8 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsanchorlayout/qgraphicsanchorlayout.pro +++ b/tests/benchmarks/gui/graphicsview/qgraphicsanchorlayout/qgraphicsanchorlayout.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qgraphicsanchorlayout +TARGET = tst_bench_qgraphicsanchorlayout SOURCES += tst_qgraphicsanchorlayout.cpp diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsitem/qgraphicsitem.pro b/tests/benchmarks/gui/graphicsview/qgraphicsitem/qgraphicsitem.pro index 726bb96..d4935c0 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsitem/qgraphicsitem.pro +++ b/tests/benchmarks/gui/graphicsview/qgraphicsitem/qgraphicsitem.pro @@ -1,5 +1,5 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qgraphicsitem +TARGET = tst_bench_qgraphicsitem SOURCES += tst_qgraphicsitem.cpp diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsscene/qgraphicsscene.pro b/tests/benchmarks/gui/graphicsview/qgraphicsscene/qgraphicsscene.pro index b460e2a..1b7a5dc 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsscene/qgraphicsscene.pro +++ b/tests/benchmarks/gui/graphicsview/qgraphicsscene/qgraphicsscene.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qgraphicsscene +TARGET = tst_bench_qgraphicsscene SOURCES += tst_qgraphicsscene.cpp diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/qgraphicsview.pro b/tests/benchmarks/gui/graphicsview/qgraphicsview/qgraphicsview.pro index 927d731..6e044f9 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsview/qgraphicsview.pro +++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/qgraphicsview.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qgraphicsview +TARGET = tst_bench_qgraphicsview SOURCES += tst_qgraphicsview.cpp RESOURCES += qgraphicsview.qrc diff --git a/tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro b/tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro index f1ec54e..ed53237 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro +++ b/tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qgraphicswidget +TARGET = tst_bench_qgraphicswidget TEMPLATE = app # Input SOURCES += tst_qgraphicswidget.cpp diff --git a/tests/benchmarks/gui/image/blendbench/blendbench.pro b/tests/benchmarks/gui/image/blendbench/blendbench.pro index a3228c5..aa6ab95 100644 --- a/tests/benchmarks/gui/image/blendbench/blendbench.pro +++ b/tests/benchmarks/gui/image/blendbench/blendbench.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_blendbench +TARGET = tst_bench_blendbench DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/gui/image/qimagereader/qimagereader.pro b/tests/benchmarks/gui/image/qimagereader/qimagereader.pro index 276ac33..d67f4be 100644 --- a/tests/benchmarks/gui/image/qimagereader/qimagereader.pro +++ b/tests/benchmarks/gui/image/qimagereader/qimagereader.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qimagereader +TARGET = tst_bench_qimagereader SOURCES += tst_qimagereader.cpp diff --git a/tests/benchmarks/gui/image/qpixmap/qpixmap.pro b/tests/benchmarks/gui/image/qpixmap/qpixmap.pro index e8330bd..201ac9e 100644 --- a/tests/benchmarks/gui/image/qpixmap/qpixmap.pro +++ b/tests/benchmarks/gui/image/qpixmap/qpixmap.pro @@ -1,5 +1,5 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qpixmap +TARGET = tst_bench_qpixmap SOURCES += tst_qpixmap.cpp diff --git a/tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro b/tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro index e0d7543..78ac97d 100644 --- a/tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro +++ b/tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qpixmapcache +TARGET = tst_bench_qpixmapcache TEMPLATE = app # Input SOURCES += tst_qpixmapcache.cpp diff --git a/tests/benchmarks/gui/itemviews/qtableview/qtableview.pro b/tests/benchmarks/gui/itemviews/qtableview/qtableview.pro index 02bc530..3f4d4e1 100644 --- a/tests/benchmarks/gui/itemviews/qtableview/qtableview.pro +++ b/tests/benchmarks/gui/itemviews/qtableview/qtableview.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qtableview +TARGET = tst_bench_qtableview SOURCES += tst_qtableview.cpp diff --git a/tests/benchmarks/gui/kernel/qapplication/qapplication.pro b/tests/benchmarks/gui/kernel/qapplication/qapplication.pro index f8601e4..e12a60c 100644 --- a/tests/benchmarks/gui/kernel/qapplication/qapplication.pro +++ b/tests/benchmarks/gui/kernel/qapplication/qapplication.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qapplication +TARGET = tst_bench_qapplication DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/gui/kernel/qwidget/qwidget.pro b/tests/benchmarks/gui/kernel/qwidget/qwidget.pro index ff47445..4c6e5c7 100644 --- a/tests/benchmarks/gui/kernel/qwidget/qwidget.pro +++ b/tests/benchmarks/gui/kernel/qwidget/qwidget.pro @@ -1,4 +1,4 @@ load(qttest_p4) -TARGET = tst_qwidget +TARGET = tst_bench_qwidget SOURCES += tst_qwidget.cpp diff --git a/tests/benchmarks/gui/math3d/qmatrix4x4/qmatrix4x4.pro b/tests/benchmarks/gui/math3d/qmatrix4x4/qmatrix4x4.pro index e82d9de..b6a2046 100644 --- a/tests/benchmarks/gui/math3d/qmatrix4x4/qmatrix4x4.pro +++ b/tests/benchmarks/gui/math3d/qmatrix4x4/qmatrix4x4.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qmatrix4x4 +TARGET = tst_bench_qmatrix4x4 SOURCES += tst_qmatrix4x4.cpp diff --git a/tests/benchmarks/gui/math3d/qquaternion/qquaternion.pro b/tests/benchmarks/gui/math3d/qquaternion/qquaternion.pro index cd68423..bd6a0d3 100644 --- a/tests/benchmarks/gui/math3d/qquaternion/qquaternion.pro +++ b/tests/benchmarks/gui/math3d/qquaternion/qquaternion.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qquaternion +TARGET = tst_bench_qquaternion SOURCES += tst_qquaternion.cpp diff --git a/tests/benchmarks/gui/painting/qpainter/qpainter.pro b/tests/benchmarks/gui/painting/qpainter/qpainter.pro index 5ac8c64..6603aba 100644 --- a/tests/benchmarks/gui/painting/qpainter/qpainter.pro +++ b/tests/benchmarks/gui/painting/qpainter/qpainter.pro @@ -1,5 +1,5 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qpainter +TARGET = tst_bench_qpainter SOURCES += tst_qpainter.cpp diff --git a/tests/benchmarks/gui/painting/qregion/qregion.pro b/tests/benchmarks/gui/painting/qregion/qregion.pro index fc67177..ec93a62 100644 --- a/tests/benchmarks/gui/painting/qregion/qregion.pro +++ b/tests/benchmarks/gui/painting/qregion/qregion.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qregion +TARGET = tst_bench_qregion DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/gui/painting/qtransform/qtransform.pro b/tests/benchmarks/gui/painting/qtransform/qtransform.pro index 8d87656..dc60407 100644 --- a/tests/benchmarks/gui/painting/qtransform/qtransform.pro +++ b/tests/benchmarks/gui/painting/qtransform/qtransform.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qtransform +TARGET = tst_bench_qtransform SOURCES += tst_qtransform.cpp diff --git a/tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro b/tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro index c097307..f4bf9ab 100644 --- a/tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro +++ b/tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qstylesheetstyle +TARGET = tst_bench_qstylesheetstyle DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/gui/text/qfontmetrics/qfontmetrics.pro b/tests/benchmarks/gui/text/qfontmetrics/qfontmetrics.pro index b6c7b92..973f881 100644 --- a/tests/benchmarks/gui/text/qfontmetrics/qfontmetrics.pro +++ b/tests/benchmarks/gui/text/qfontmetrics/qfontmetrics.pro @@ -1,5 +1,5 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_QFontMetrics +TARGET = tst_bench_QFontMetrics SOURCES += main.cpp diff --git a/tests/benchmarks/gui/text/qtext/qtext.pro b/tests/benchmarks/gui/text/qtext/qtext.pro index 9e8860f..a1b6a22 100644 --- a/tests/benchmarks/gui/text/qtext/qtext.pro +++ b/tests/benchmarks/gui/text/qtext/qtext.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_QText +TARGET = tst_bench_QText SOURCES += main.cpp diff --git a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro index 89f5d31..0949af7 100644 --- a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro +++ b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qfile_vs_qnetworkaccessmanager +TARGET = tst_bench_qfile_vs_qnetworkaccessmanager DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro b/tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro index 1e67d81..9d96dc7 100644 --- a/tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro +++ b/tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qnetworkreply +TARGET = tst_bench_qnetworkreply DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro b/tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro index f18d6d7..e621d50 100755 --- a/tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro +++ b/tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qhostinfo +TARGET = tst_bench_qhostinfo DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro b/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro index e7bf13a..e5b9346 100644 --- a/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro +++ b/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qtcpserver +TARGET = tst_bench_qtcpserver DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/opengl/opengl.pro b/tests/benchmarks/opengl/opengl.pro index 1458b5e..5c58751 100644 --- a/tests/benchmarks/opengl/opengl.pro +++ b/tests/benchmarks/opengl/opengl.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_opengl +TARGET = tst_bench_opengl DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/script/qscriptclass/qscriptclass.pro b/tests/benchmarks/script/qscriptclass/qscriptclass.pro index f0ffeb7..90c9582 100644 --- a/tests/benchmarks/script/qscriptclass/qscriptclass.pro +++ b/tests/benchmarks/script/qscriptclass/qscriptclass.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qscriptclass +TARGET = tst_bench_qscriptclass SOURCES += tst_qscriptclass.cpp diff --git a/tests/benchmarks/script/qscriptengine/qscriptengine.pro b/tests/benchmarks/script/qscriptengine/qscriptengine.pro index df6dbb3..72a547a 100644 --- a/tests/benchmarks/script/qscriptengine/qscriptengine.pro +++ b/tests/benchmarks/script/qscriptengine/qscriptengine.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qscriptengine +TARGET = tst_bench_qscriptengine SOURCES += tst_qscriptengine.cpp diff --git a/tests/benchmarks/script/qscriptvalue/qscriptvalue.pro b/tests/benchmarks/script/qscriptvalue/qscriptvalue.pro index 04ea324..1c26438 100644 --- a/tests/benchmarks/script/qscriptvalue/qscriptvalue.pro +++ b/tests/benchmarks/script/qscriptvalue/qscriptvalue.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qscriptvalue +TARGET = tst_bench_qscriptvalue SOURCES += tst_qscriptvalue.cpp diff --git a/tests/benchmarks/svg/qsvgrenderer/qsvgrenderer.pro b/tests/benchmarks/svg/qsvgrenderer/qsvgrenderer.pro index 8222a09..9e59eb7 100644 --- a/tests/benchmarks/svg/qsvgrenderer/qsvgrenderer.pro +++ b/tests/benchmarks/svg/qsvgrenderer/qsvgrenderer.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qsvgrenderer +TARGET = tst_bench_qsvgrenderer SOURCES += tst_qsvgrenderer.cpp RESOURCES += qsvgrenderer.qrc -- cgit v0.12 From 032d4ac63687d209ffef594bf6ef60e3db20bfa3 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 10 Mar 2010 11:45:02 +0200 Subject: Fix build break caused by undefined symbol SetDialogPreference A recent sym_iap_util.h change make it depend on different libraries. Fixed LIBS statements on relevant examples and demos. Reviewed-by: Janne Anttila --- demos/embedded/anomaly/anomaly.pro | 2 +- demos/embedded/flightinfo/flightinfo.pro | 2 +- demos/embedded/lightmaps/lightmaps.pro | 2 +- demos/embedded/weatherinfo/weatherinfo.pro | 2 +- examples/network/fortuneclient/fortuneclient.pro | 2 +- examples/network/fortuneserver/fortuneserver.pro | 2 +- examples/network/network-chat/network-chat.pro | 3 ++- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/demos/embedded/anomaly/anomaly.pro b/demos/embedded/anomaly/anomaly.pro index 165ce89..e16ef66 100644 --- a/demos/embedded/anomaly/anomaly.pro +++ b/demos/embedded/anomaly/anomaly.pro @@ -27,7 +27,7 @@ symbian { TARGET.UID3 = 0xA000CF71 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h - LIBS += -lesock -linsock -lconnmon + LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/demos/embedded/flightinfo/flightinfo.pro b/demos/embedded/flightinfo/flightinfo.pro index 8e5535c..7391f88 100644 --- a/demos/embedded/flightinfo/flightinfo.pro +++ b/demos/embedded/flightinfo/flightinfo.pro @@ -9,7 +9,7 @@ symbian { TARGET.UID3 = 0xA000CF74 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h - LIBS += -lesock -lconnmon -linsock + LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices } diff --git a/demos/embedded/lightmaps/lightmaps.pro b/demos/embedded/lightmaps/lightmaps.pro index c9bfa0a..ef1a0a6 100644 --- a/demos/embedded/lightmaps/lightmaps.pro +++ b/demos/embedded/lightmaps/lightmaps.pro @@ -6,7 +6,7 @@ symbian { TARGET.UID3 = 0xA000CF75 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h - LIBS += -lesock -lconnmon -linsock + LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/demos/embedded/weatherinfo/weatherinfo.pro b/demos/embedded/weatherinfo/weatherinfo.pro index 57f1684..f007bbb 100644 --- a/demos/embedded/weatherinfo/weatherinfo.pro +++ b/demos/embedded/weatherinfo/weatherinfo.pro @@ -8,7 +8,7 @@ symbian { TARGET.UID3 = 0xA000CF77 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h - LIBS += -lesock -lconnmon -linsock + LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = NetworkServices } diff --git a/examples/network/fortuneclient/fortuneclient.pro b/examples/network/fortuneclient/fortuneclient.pro index c9dc39a..2b65f2f 100644 --- a/examples/network/fortuneclient/fortuneclient.pro +++ b/examples/network/fortuneclient/fortuneclient.pro @@ -12,7 +12,7 @@ INSTALLS += target sources symbian { include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h - LIBS += -lesock + LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = "NetworkServices ReadUserData WriteUserData" TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/examples/network/fortuneserver/fortuneserver.pro b/examples/network/fortuneserver/fortuneserver.pro index 4dbc2e8..acb285b 100644 --- a/examples/network/fortuneserver/fortuneserver.pro +++ b/examples/network/fortuneserver/fortuneserver.pro @@ -13,7 +13,7 @@ symbian { TARGET.UID3 = 0xA000CF71 include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h - LIBS += -lesock + LIBS += -lesock -lcommdb -linsock # For IAP selection TARGET.CAPABILITY = "All -TCB" TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } diff --git a/examples/network/network-chat/network-chat.pro b/examples/network/network-chat/network-chat.pro index 16c11e3..7438641 100644 --- a/examples/network/network-chat/network-chat.pro +++ b/examples/network/network-chat/network-chat.pro @@ -21,7 +21,8 @@ INSTALLS += target sources symbian { include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h - LIBS += -lesock -lconnmon -lcharconv -linsock + LIBS += -lesock -lcommdb -linsock # For IAP selection + LIBS += -lcharconv TARGET.CAPABILITY = "NetworkServices ReadUserData WriteUserData" TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 } -- cgit v0.12 From 64cd7dea0e2f3d6544e6cc47ccd857b1ce3d44e7 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Fri, 5 Mar 2010 16:24:48 +0100 Subject: Fix SDP files are not supported. The Phonon glue code rejected SDPs based on the MIME type for SDPs. Task-number: QTBUG-8702 Reviewed-by: Gareth Stockwell --- src/3rdparty/phonon/mmf/utils.cpp | 22 +++++---- tests/auto/mediaobject/media/test.sdp | 32 +++++++++++++ tests/auto/mediaobject/mediaobject.pro | 6 +++ tests/auto/mediaobject/mediaobject.qrc | 1 + tests/auto/mediaobject/tst_mediaobject.cpp | 75 ++++++++++++++++++++++++++---- 5 files changed, 118 insertions(+), 18 deletions(-) create mode 100644 tests/auto/mediaobject/media/test.sdp diff --git a/src/3rdparty/phonon/mmf/utils.cpp b/src/3rdparty/phonon/mmf/utils.cpp index 2d17bd2..c556afc 100644 --- a/src/3rdparty/phonon/mmf/utils.cpp +++ b/src/3rdparty/phonon/mmf/utils.cpp @@ -52,22 +52,24 @@ void MMF::Utils::panic(PanicCode code) User::Panic(PanicCategory, code); } - -static const TInt KMimePrefixLength = 6; // either "audio/" or "video/" _LIT(KMimePrefixAudio, "audio/"); _LIT(KMimePrefixVideo, "video/"); +_LIT(KMimeSDP, "application/sdp"); + +enum ConstantStringLengths { + KMimePrefixLength = 6, // either "audio/" or "video/", + KMimeSDPLength = 15 // "application/sdp" +}; MMF::MediaType MMF::Utils::mimeTypeToMediaType(const TDesC& mimeType) { - MediaType result = MediaTypeUnknown; - if (mimeType.Left(KMimePrefixLength).Compare(KMimePrefixAudio) == 0) { - result = MediaTypeAudio; - } else if (mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0) { - result = MediaTypeVideo; - } - - return result; + return MediaTypeAudio; + } else if (mimeType.Left(KMimePrefixLength).Compare(KMimePrefixVideo) == 0 || + mimeType.Left(KMimeSDPLength).Compare(KMimeSDP) == 0) { + return MediaTypeVideo; + } else + return MediaTypeUnknown; } QString MMF::Utils::symbianErrorToString(int errorCode) diff --git a/tests/auto/mediaobject/media/test.sdp b/tests/auto/mediaobject/media/test.sdp new file mode 100644 index 0000000..0d8706c --- /dev/null +++ b/tests/auto/mediaobject/media/test.sdp @@ -0,0 +1,32 @@ +v=0 +o=- 3476526279 2351211129 IN IP4 XXX.XXX.XXX.XXX +s=SOME STRING +e=support@localhost +c=IN IP4 XXX.XXX.XXX.XXX +t=0 0 +a=range:npt=now- +a=random_access_denied +a=control:rtsp://link +m=video 0 RTP/AVP 96 +b=AS:100 +b=RR:2500 +b=RS:2500 +a=control:rtsp://link +a=rtpmap:96 MP4V-ES/90000 +a=3GPP-Adaptation-Support:1 +a=cliprect:0,0,144,176 +a=mpeg4-esid:201 +a=x-envivio-verid:00022B15 +a=fmtp:96 profile-level-id=2;config=000001b002000001b50ea020202f000001000000012000c788ba9850584121463f +a=framerate:15.0 +m=audio 0 RTP/AVP 97 +b=AS:14 +b=RR:350 +b=RS:350 +a=control:rtsp://link +a=rtpmap:97 AMR/8000 +a=3GPP-Adaptation-Support:1 +a=mpeg4-esid:101 +a=x-envivio-verid:00022B15 +a=fmtp:97 octet-align=1 +a=maxptime:200 diff --git a/tests/auto/mediaobject/mediaobject.pro b/tests/auto/mediaobject/mediaobject.pro index 5d4a098..bef2fe9 100755 --- a/tests/auto/mediaobject/mediaobject.pro +++ b/tests/auto/mediaobject/mediaobject.pro @@ -14,3 +14,9 @@ wince*{ DEFINES += tst_MediaObject=tst_MediaObject_waveout } +symbian*:{ + addFiles.sources = media/test.sdp + addFiles.path = media + DEPLOYMENT += addFiles +} + diff --git a/tests/auto/mediaobject/mediaobject.qrc b/tests/auto/mediaobject/mediaobject.qrc index 4f46213..77954f4 100644 --- a/tests/auto/mediaobject/mediaobject.qrc +++ b/tests/auto/mediaobject/mediaobject.qrc @@ -3,5 +3,6 @@ media/sax.wav media/sax.ogg media/sax.mp3 +media/test.sdp diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp index 16b2611..4cb08fb 100644 --- a/tests/auto/mediaobject/tst_mediaobject.cpp +++ b/tests/auto/mediaobject/tst_mediaobject.cpp @@ -139,6 +139,7 @@ class tst_MediaObject : public QObject void pauseToPause(); void pauseToPlay(); void pauseToStop(); + void playSDP(); void testPrefinishMark(); void testSeek(); @@ -160,6 +161,11 @@ class tst_MediaObject : public QObject Phonon::MediaObject *m_media; QSignalSpy *m_stateChangedSignalSpy; QString m_tmpFileName; + + static void copyMediaFile(const QString &original, + const QString &name, + QString &resultFilePath, + QUrl *const asURL = 0); #endif //QT_NO_PHONON bool m_success; }; @@ -352,6 +358,24 @@ void tst_MediaObject::_pausePlayback() m_success = true; } +/*! + Copies the file \a name to the testing area. The resulting file name path is + returned in resultFilePath, and also set as a URL in \a asURL. + */ +void tst_MediaObject::copyMediaFile(const QString &original, + const QString &name, + QString &resultFilePath, + QUrl *const asURL) +{ + resultFilePath = QDir::toNativeSeparators(QDir::tempPath() + name); + if (asURL) + *asURL = QUrl::fromLocalFile(resultFilePath); + + QFile::remove(resultFilePath); + QVERIFY(QFile::copy(original, resultFilePath)); + QFile::setPermissions(resultFilePath, QFile::permissions(resultFilePath) | QFile::WriteOther); +} + void tst_MediaObject::initTestCase() { QCoreApplication::setApplicationName("tst_MediaObject"); @@ -375,14 +399,8 @@ void tst_MediaObject::initTestCase() QVERIFY(m_stateChangedSignalSpy->isValid()); m_stateChangedSignalSpy->clear(); - if (m_url.isEmpty()) { - m_tmpFileName = QDir::toNativeSeparators(QDir::tempPath() + MEDIA_FILE); - QFile::remove(m_tmpFileName); - QVERIFY(QFile::copy(MEDIA_FILEPATH, m_tmpFileName)); - QFile::Permissions p = QFile::permissions(m_tmpFileName); - QFile::setPermissions(m_tmpFileName, p | QFile::WriteOther); - m_url = QUrl::fromLocalFile(m_tmpFileName); - } + if (m_url.isEmpty()) + copyMediaFile(MEDIA_FILEPATH, MEDIA_FILE, m_tmpFileName, &m_url); qDebug() << "Using url:" << m_url.toString(); @@ -533,6 +551,47 @@ void tst_MediaObject::pauseToStop() stopPlayback(Phonon::PausedState); } +/*! + + We attempt to play a SDP file. An SDP file essentially describes different + media streams and is hence a layer in front of the actual media(s). + Sometimes the backend handles the SDP file, in other cases not. + + Some Phonon backends doesn't support SDP at all, ifdef appropriately. Real + Player and Helix, the two backends for Symbian, are known to support SDP. + */ +void tst_MediaObject::playSDP() +{ +#ifdef Q_OS_SYMBIAN + QString sdpFile; + copyMediaFile(QLatin1String(":/media/test.sdp"), QLatin1String("test.sdp"), sdpFile); + + // Let's verify our test setup. + QVERIFY(QFileInfo(sdpFile).isReadable()); + + // We need a window in order to setup the video. + QWidget widget; + widget.show(); + + const MediaSource oldSource(m_media->currentSource()); + const MediaSource sdpSource(sdpFile); + m_media->setCurrentSource(sdpSource); + if (m_media->state() != Phonon::StoppedState) + QTest::waitForSignal(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000); + + // At this point we're in error state due to absent media, but it has now loaded the SDP: + QCOMPARE(m_media->errorString(), QString::fromLatin1("Buffering clip failed: Unknown error (-39)")); + + // We cannot play the SDP, we can neither attempt to play it, because we + // won't get a state change from ErrorState to ErrorState, and hence block + // on a never occuring signal. + m_media->setCurrentSource(oldSource); + +#else + QSKIP("Unsupported on this platform.", SkipAll); +#endif +} + void tst_MediaObject::testPrefinishMark() { const qint32 requestedPrefinishMarkTime = 2000; -- cgit v0.12 From fdf85116102ed03a56dae3947f4251bf0f889f33 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 10 Mar 2010 13:37:36 +0100 Subject: Do qFatal() on unsupported screen format instead of crashing later MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: Related to QTBUG-5117 Reviewed-by: Jørgen Lind --- src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp b/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp index e78fec1..f5ad70c 100644 --- a/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp +++ b/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp @@ -2163,6 +2163,9 @@ bool QVNCScreen::connect(const QString &displaySpec) if (QScreenDriverFactory::keys().contains(driver, Qt::CaseInsensitive)) { const int id = getDisplayId(dspec); QScreen *s = qt_get_screen(id, dspec.toLatin1().constData()); + if (s->pixelFormat() == QImage::Format_Indexed8 + || s->pixelFormat() == QImage::Format_Invalid && s->depth() == 8) + qFatal("QVNCScreen: unsupported screen format"); setScreen(s); } else { // create virtual screen #if Q_BYTE_ORDER == Q_BIG_ENDIAN -- cgit v0.12 From 6d44daddab9f36fd8c34bb3776c0fb0d93635e6e Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 10 Mar 2010 15:56:25 +0200 Subject: Fixed dialog resize not to move the dialog for Symbian. QDialog::resize() also moved the dialog in Symbian. This occured since adjustPosition was called as an result of resize and that method did not check if dialog position was explicitly set. In addition it was found that in Symbian WA_Resized and WA_Moved attributes were basically set for almost all top-level widgets by system. This was also fixed and a new auto test was introduced to verify these attributes in all platforms. Windows platform also suffers from bug in this area, and a separate task QTBUG-5897 for it was created Task-number: QTBUG-5897 Reviewed-by: Sami Merila --- src/gui/dialogs/qdialog.cpp | 11 ++++++-- src/gui/kernel/qapplication_s60.cpp | 2 +- src/gui/kernel/qwidget_s60.cpp | 7 ++++- tests/auto/qwidget/tst_qwidget.cpp | 53 +++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 4 deletions(-) diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp index d86d63e..d8ac9a8 100644 --- a/src/gui/dialogs/qdialog.cpp +++ b/src/gui/dialogs/qdialog.cpp @@ -415,8 +415,15 @@ bool QDialog::event(QEvent *e) result = true; } #else - if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize )) - adjustPosition(parentWidget()); + if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize )) { + if (!testAttribute(Qt::WA_Moved)) { + Qt::WindowStates state = windowState(); + adjustPosition(parentWidget()); + setAttribute(Qt::WA_Moved, false); // not really an explicit position + if (state != windowState()) + setWindowState(state); + } + } #endif return result; } diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 395ceca..79b2bff 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1034,7 +1034,7 @@ void QSymbianControl::HandleResourceChange(int resourceType) qwidget->adjustSize(); qwidget->setAttribute(Qt::WA_Resized, false); //not a user resize } - if (!qwidget->testAttribute(Qt::WA_Moved)) { + if (!qwidget->testAttribute(Qt::WA_Moved) && qwidget->windowType() != Qt::Dialog) { TRect r = static_cast(S60->appUi())->ClientRect(); SetPosition(r.iTl); qwidget->setAttribute(Qt::WA_Moved, false); // not really an explicit position diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 7fb21d2..81c4198 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -1052,6 +1052,8 @@ void QWidget::setWindowState(Qt::WindowStates newstate) return; if (isWindow()) { + const bool wasResized = testAttribute(Qt::WA_Resized); + const bool wasMoved = testAttribute(Qt::WA_Moved); QSymbianControl *window = static_cast(effectiveWinId()); if (window && newstate & Qt::WindowMinimized) { @@ -1090,7 +1092,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) createWinId(); Q_ASSERT(testAttribute(Qt::WA_WState_Created)); // Ensure the initial size is valid, since we store it as normalGeometry below. - if (!testAttribute(Qt::WA_Resized) && !isVisible()) + if (!wasResized && !isVisible()) adjustSize(); QTLWExtra *top = d->topData(); @@ -1105,6 +1107,9 @@ void QWidget::setWindowState(Qt::WindowStates newstate) //restore normal geometry top->normalGeometry = normalGeometry; + + setAttribute(Qt::WA_Resized, wasResized); + setAttribute(Qt::WA_Moved, wasMoved); } data->window_state = newstate; diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index abd9604..f03b7d7 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -402,6 +402,7 @@ private slots: void scrollWithoutBackingStore(); void taskQTBUG_7532_tabOrderWithFocusProxy(); + void movedAndResizedAttributes(); private: bool ensureScreenSize(int width, int height); @@ -10040,5 +10041,57 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy() // No Q_ASSERT, then it's allright. } +void tst_QWidget::movedAndResizedAttributes() +{ + QWidget w; + w.show(); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.setWindowState(Qt::WindowFullScreen); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.setWindowState(Qt::WindowMaximized); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.setWindowState(Qt::WindowMinimized); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.showNormal(); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.showMaximized(); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.showFullScreen(); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.showNormal(); + w.move(10,10); + QVERIFY(w.testAttribute(Qt::WA_Moved)); +#if defined(Q_OS_WIN) + QEXPECT_FAIL("", "FixMe, QTBUG-8911", Abort); +#endif + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.resize(100, 100); + QVERIFY(w.testAttribute(Qt::WA_Moved)); + QVERIFY(w.testAttribute(Qt::WA_Resized)); + +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" -- cgit v0.12 From 7dc470fd96f50eff923208cdc6e273161062e2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 10 Mar 2010 15:13:25 +0100 Subject: Worked around driver bug causing clipping errors on N900. Apparently the driver does some optimization which causes it to behave erratically when stencil testing is enabled. Multiplying the return value from the texture lookup by 1.0 disables the optimization. Task-number: QTBUG-8753 Reviewed-by: Trond --- src/opengl/gl2paintengineex/qglengineshadersource_p.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index ee04166..c88c041 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -331,9 +331,14 @@ static const char* const qglslImageSrcFragmentShader = "\n\ varying highp vec2 textureCoords; \n\ uniform lowp sampler2D imageTexture; \n\ lowp vec4 srcPixel() \n\ - { \n\ - return texture2D(imageTexture, textureCoords); \n\ - }\n"; + { \n" +#ifdef QT_OPENGL_ES_2 + // work-around for driver bug + "return 1.0 * texture2D(imageTexture, textureCoords); \n" +#else + "return texture2D(imageTexture, textureCoords); \n" +#endif + "}\n"; static const char* const qglslCustomSrcFragmentShader = "\n\ varying highp vec2 textureCoords; \n\ -- cgit v0.12 From ed659771c8f21cd8ca8a06d29b105288439f4e75 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 10 Mar 2010 19:24:09 +0100 Subject: Doc: Solaris 10 is supported as Tier 2 on x86 architecture as well. Rev-by: Jesper --- doc/src/platforms/supported-platforms.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/platforms/supported-platforms.qdoc b/doc/src/platforms/supported-platforms.qdoc index a84ad56..578ec37 100644 --- a/doc/src/platforms/supported-platforms.qdoc +++ b/doc/src/platforms/supported-platforms.qdoc @@ -116,7 +116,7 @@ \o aCC 3.57, gcc 3.4 \row \o HPUXi 11.23 \o aCC 6.10 - \row \o Solaris 10 UltraSparc + \row \o Solaris 10 (UltraSparc, x86) \o Sun Studio 12 \row \o AIX 6 \o Power5 xlC 7 -- cgit v0.12 From 747a4dfc5a333c2f7066d344f7da1684226551bd Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 11 Mar 2010 08:04:13 +1000 Subject: SIGSEGV after QAudioOutput closed. Task-number:QTBUG-8755 Reviewed-by:Derick Hawcroft --- src/multimedia/audio/qaudiooutput_win32_p.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index c5792b6..f3ba079 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -455,6 +455,9 @@ void QAudioOutputPrivate::feedback() bool QAudioOutputPrivate::deviceReady() { + if(deviceState == QAudio::StoppedState) + return false; + if(pullMode) { int chunks = bytesAvailable/period_size; #ifdef DEBUG_AUDIO -- cgit v0.12 From ba707e24a65f88c05b6133b20531a152f2315064 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 11 Mar 2010 11:09:25 +1000 Subject: QAudioInput::processedUSecs() incorrect Bug introduced by change 04532ba052559b265b1bc85dc143d8aeeb02149f Was calculating time assuming totalTimeValue was in frames but it is stored as bytes in alsa input case. Reviewed-by:Dmytro Poplavskiy --- src/multimedia/audio/qaudioinput_alsa_p.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 6010f3c..5eb23d0 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -588,7 +588,11 @@ int QAudioInputPrivate::notifyInterval() const qint64 QAudioInputPrivate::processedUSecs() const { - return qint64(1000000) * totalTimeValue / settings.frequency(); + qint64 result = qint64(1000000) * totalTimeValue / + (settings.channels()*(settings.sampleSize()/8)) / + settings.frequency(); + + return result; } void QAudioInputPrivate::suspend() -- cgit v0.12 From ed8103e715aee24c3ff6963c68a6b3bb9e3a7288 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Thu, 11 Mar 2010 17:06:04 +1000 Subject: Documentation fix. Reviewed-by:Dmytro Poplavskiy --- src/multimedia/audio/qaudioinput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index fd892dd..10bab01 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -95,7 +95,7 @@ QT_BEGIN_NAMESPACE format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleType(QAudioFormat::UnSignedInt); - if (QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice()); + QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice(); if (!info.isFormatSupported(format)) { qWarning()<<"default format not supported try to use nearest"; format = info.nearestFormat(format); -- cgit v0.12 From 870c2d0012f95d1bd43b725104c042e3231d5012 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Thu, 11 Mar 2010 17:06:35 +1000 Subject: Ensure audio converter member is initialized. Reviewed-by:Dmytro Poplavskiy --- src/multimedia/audio/qaudioinput_mac_p.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp index bd2de52..f394ca4 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.cpp +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -229,6 +229,7 @@ public: QObject* parent): QObject(parent), m_deviceError(false), + m_audioConverter(0), m_inputFormat(inputFormat), m_outputFormat(outputFormat) { -- cgit v0.12 From af2f85585cd90c27b39600c75bdcefa78d52c4ea Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Thu, 11 Mar 2010 10:32:33 +0200 Subject: XFAIL for a new qwidget autotest on MAC and QWS. Widget attributes seems to be inconsistently set on different platforms. There are two task to harmonize the attributes on different platforms: QTBUG-8941 and QTBUG-8911 The tests were XFAIL:d in order that S60 integration is not blocked. Reviewed-by: Jason Barron --- tests/auto/qwidget/tst_qwidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index f03b7d7..65f4945 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -10043,6 +10043,10 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy() void tst_QWidget::movedAndResizedAttributes() { +#if defined (Q_OS_MAC) || defined(Q_WS_QWS) + QEXPECT_FAIL("", "FixMe, QTBUG-8941", Abort); + QVERIFY(false); +#else QWidget w; w.show(); @@ -10090,7 +10094,7 @@ void tst_QWidget::movedAndResizedAttributes() w.resize(100, 100); QVERIFY(w.testAttribute(Qt::WA_Moved)); QVERIFY(w.testAttribute(Qt::WA_Resized)); - +#endif } QTEST_MAIN(tst_QWidget) -- cgit v0.12 From fbb600a7a92b60b388406fecf2d8a94f0d4f5586 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 10 Mar 2010 19:31:54 +0100 Subject: QVarLenghtArray: Call constructor when resizing the array for Movable types. The constructor of complex type that are declared as Movable (such as many of our containers) were not being called. The raison is that the 's' was set to 'asize' right after the qMemCopy So we need to reset 's' to old size in the movable case (in all cases) In the static case, 's' has already be incremented to osize The 's = asize;' can be removed as it is anyway done at the very end of the function Task-number: QTBUG-6718 Reviewed-by: Harald Fernengel --- src/corelib/tools/qvarlengtharray.h | 3 +- tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp | 47 +++++++++++++++++++++- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 1069b816..aecb66e 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -222,7 +222,6 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray::realloc(int asize, int a } } else { qMemCopy(ptr, oldPtr, qMin(asize, osize) * sizeof(T)); - s = asize; } } else { ptr = oldPtr; @@ -233,7 +232,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray::realloc(int asize, int a if (QTypeInfo::isComplex) { while (osize > asize) (oldPtr+(--osize))->~T(); - if( oldPtr == ptr ) + if (!QTypeInfo::isStatic) s = osize; } diff --git a/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp index 0fcde21..1c43069 100644 --- a/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp @@ -42,6 +42,7 @@ #include #include +#include const int N = 1; @@ -61,6 +62,7 @@ private slots: void removeLast(); void oldTests(); void task214223(); + void QTBUG6718_resize(); }; int fooCtor = 0; @@ -71,7 +73,7 @@ struct Foo int *p; Foo() { p = new int; ++fooCtor; } - Foo(const Foo &other) { p = new int; ++fooCtor; } + Foo(const Foo &/*other*/) { p = new int; ++fooCtor; } void operator=(const Foo & /* other */) { } @@ -244,9 +246,50 @@ void tst_QVarLengthArray::task214223() // will make the next call to append(const T&) corrupt the memory // you should get a segfault pretty soon after that :-) QVarLengthArray d(1); - for (int i=0; i<30; i++) + for (int i=0; i<30; i++) d.append(i); } +void tst_QVarLengthArray::QTBUG6718_resize() +{ + //MOVABLE + { + QVarLengthArray values(1); + QCOMPARE(values.size(), 1); + values[0] = 1; + values.resize(2); + QCOMPARE(values[1], QVariant()); + QCOMPARE(values[0], QVariant(1)); + values[1] = 2; + QCOMPARE(values[1], QVariant(2)); + QCOMPARE(values.size(), 2); + } + + //POD + { + QVarLengthArray values(1); + QCOMPARE(values.size(), 1); + values[0] = 1; + values.resize(2); + QCOMPARE(values[0], 1); + values[1] = 2; + QCOMPARE(values[1], 2); + QCOMPARE(values.size(), 2); + } + + //COMPLEX + { + QVarLengthArray,1> values(1); + QCOMPARE(values.size(), 1); + values[0].resize(10); + values.resize(2); + QCOMPARE(values[1].size(), 0); + QCOMPARE(values[0].size(), 10); + values[1].resize(20); + QCOMPARE(values[1].size(), 20); + QCOMPARE(values.size(), 2); + } +} + QTEST_APPLESS_MAIN(tst_QVarLengthArray) #include "tst_qvarlengtharray.moc" -- cgit v0.12 From aa351766d6cecd6cad43cb40596d3ae9166a9647 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 11 Mar 2010 14:03:14 +0100 Subject: Avoid unnecessary memory allocation in the jpeg handler's image detection The handler calls peek with 2 bytes to inspect the first two bytes. Instead of calling the overload of peek() that returns a new QByteArray with just two bytes, allocate 2 bytes on the stack and call the overload of peek() that writes into the specified buffer. Reviewed-by: Joao --- src/plugins/imageformats/jpeg/qjpeghandler.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index 6cb93ad..98bd88f 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -1188,7 +1188,11 @@ bool QJpegHandler::canRead(QIODevice *device) return false; } - return device->peek(2) == "\xFF\xD8"; + char buffer[2]; + if (device->peek(buffer, 2) != 2) + return false; + + return uchar(buffer[0]) == 0xff && uchar(buffer[1]) == 0xd8; } bool QJpegHandler::read(QImage *image) -- cgit v0.12 From 90363486e7be80ec533be670cc54aee934c808db Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 11 Mar 2010 15:08:30 +0200 Subject: Fixed RSS_RULES statement in application_icon.prf RSS_RULES were being overwritten instead of being appended to in applicaton_icon.prf. Reviewed-by: Janne Anttila --- mkspecs/features/symbian/application_icon.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/symbian/application_icon.prf b/mkspecs/features/symbian/application_icon.prf index 1edbe14..3a26325 100644 --- a/mkspecs/features/symbian/application_icon.prf +++ b/mkspecs/features/symbian/application_icon.prf @@ -3,7 +3,7 @@ load(data_caging_paths) # If no_icon keyword exist, the S60 UI app is just made hidden. This because S60 app FW # requires the registration resource file to exist always contains( CONFIG, no_icon ) { - symbian:RSS_RULES ="hidden = KAppIsHidden;" + symbian:RSS_RULES += "hidden = KAppIsHidden;" CONFIG -= no_icon } else { # There is no point in compiling the MIF icon if no_icon CONFIGS is set -- cgit v0.12 From 0e91875345c4505abac54f6d2cb03252332fcbfb Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 11 Mar 2010 15:17:46 +0200 Subject: Support for adding user specified list type content in rss file Added support for the following RSS_RULES variables to improve control over placement of user defined rules inside application registration resource file: RSS_RULES.header - Rule placed before APP_REGISTRATION_INFO RSS_RULES.footer - Rule placed after APP_REGISTRATION_INFO RSS_RULES.service_list - Rule placed inside a SERVICE_INFO item in the service_list of APP_REGISTRATION_INFO RSS_RULES.file_ownership_list - Rule placed inside a FILE_OWNERSHIP_INFO item in the file_ownership_list of APP_REGISTRATION_INFO RSS_RULES.datatype_list - Rule placed inside a DATATYPE item in the datatype_list of APP_REGISTRATION_INFO Task-number: QT-3083 Reviewed-by: Janne Anttila --- doc/src/development/qmake-manual.qdoc | 40 +++++++++---- doc/src/snippets/code/doc_src_qmake-manual.qdoc | 5 ++ qmake/generators/symbian/symmake.cpp | 79 +++++++++++++++++++++---- qmake/generators/symbian/symmake.h | 14 ++++- 4 files changed, 114 insertions(+), 24 deletions(-) diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index 3157536..7ab3cd2 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -2884,9 +2884,9 @@ For example: \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 144 - This will add the specified statement to the end of the generated - registration resource file. As an impact of this statement, the application - will not be visible in application shell. + This will add the specified statement to the end of the \c APP_REGISTRATION_INFO + resource struct in the generated registration resource file. + As an impact of this statement, the application will not be visible in application shell. It is also possible to add multiple rows in a single block. Each double quoted string will be placed on a new row in the registration resource file. @@ -2899,16 +2899,36 @@ For example: platform application shell. In addition it will make the application to be launched in background. - For detailed list of possible RSS statements, please refer to the - Symbian platform help. + For detailed list of possible \c APP_REGISTRATION_INFO statements, please refer to the + Symbian platform help. \note You should not use \c RSS_RULES variable to set the following RSS statements: - - app_file - localisable_resource_file - localisable_resource_id + \c app_file, \c localisable_resource_file, and \c localisable_resource_id. + + These statements are internally handled by qmake. + + There is a number of special modifiers you can attach to \c RSS_RULES to specify where + in the application registration file the rule will be written: + + \table + \header \o Modifier \o Location of the rule + \row \o \o Inside \c APP_REGISTRATION_INFO resource struct. + \row \o .header \o Before \c APP_REGISTRATION_INFO resource struct. + \row \o .footer \o After \c APP_REGISTRATION_INFO resource struct. + \row \o .service_list \o Inside a \c SERVICE_INFO item in the \c service_list + of \c APP_REGISTRATION_INFO + \row \o .file_ownership_list \o Inside a \c FILE_OWNERSHIP_INFO item in the + \c file_ownership_list of \c APP_REGISTRATION_INFO + \row \o .datatype_list \o Inside a \c DATATYPE item in the \c datatype_list of + \c APP_REGISTRATION_INFO + \endtable + + For example: + + \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 151 - These statements are internally handled by qmake. + This example will define service information for a fictional service that requires + an icon to be supplied via the \c opaque_data of the service information. \target S60_VERSION \section1 S60_VERSION diff --git a/doc/src/snippets/code/doc_src_qmake-manual.qdoc b/doc/src/snippets/code/doc_src_qmake-manual.qdoc index e8c00d3..36676ae 100644 --- a/doc/src/snippets/code/doc_src_qmake-manual.qdoc +++ b/doc/src/snippets/code/doc_src_qmake-manual.qdoc @@ -996,3 +996,8 @@ symbian { emulator_dll.condition = WINSCW } //! [150] + +//! [151] +RSS_RULES.service_list += "uid = 0x12345678; datatype_list = \{\}; opaque_data = r_my_icon;" +RSS_RULES.footer +="RESOURCE CAPTION_AND_ICON_INFO r_my_icon \{ icon_file =\"$$PWD/my_icon.svg\"; \}" +//! [151] diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index 9ade699..f906c76 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -69,6 +69,12 @@ #define RSS_RULES_BASE "RSS_RULES." #define RSS_TAG_NBROFICONS "number_of_icons" #define RSS_TAG_ICONFILE "icon_file" +#define RSS_TAG_HEADER "header" +#define RSS_TAG_SERVICE_LIST "service_list" +#define RSS_TAG_FILE_OWNERSHIP_LIST "file_ownership_list" +#define RSS_TAG_DATATYPE_LIST "datatype_list" +#define RSS_TAG_FOOTER "footer" +#define RSS_TAG_DEFAULT "default_rules" // Same as just giving rules without tag #define MMP_TARGET "TARGET" #define MMP_TARGETTYPE "TARGETTYPE" @@ -200,7 +206,7 @@ bool SymbianMakefileGenerator::writeMakefile(QTextStream &t) QString numberOfIcons; QString iconFile; - QStringList userRssRules; + QMap userRssRules; readRssRules(numberOfIcons, iconFile, userRssRules); // Get the application translations and convert to symbian OS lang code, i.e. decical number @@ -1426,7 +1432,7 @@ void SymbianMakefileGenerator::writeBldInfContent(QTextStream &t, bool addDeploy } } -void SymbianMakefileGenerator::writeRegRssFile(QStringList &userItems) +void SymbianMakefileGenerator::writeRegRssFile(QMap &userItems) { QString filename(fixedTarget); filename.append("_reg.rss"); @@ -1443,6 +1449,8 @@ void SymbianMakefileGenerator::writeRegRssFile(QStringList &userItems) t << endl; t << "#include <" << fixedTarget << ".rsg>" << endl; t << "#include " << endl; + foreach(QString item, userItems[RSS_TAG_HEADER]) + t << item << endl; t << endl; t << "UID2 KUidAppRegistrationResourceFile" << endl; t << "UID3 " << uid3 << endl << endl; @@ -1450,16 +1458,51 @@ void SymbianMakefileGenerator::writeRegRssFile(QStringList &userItems) t << "\t{" << endl; t << "\tapp_file=\"" << fixedTarget << "\";" << endl; t << "\tlocalisable_resource_file=\"" RESOURCE_DIRECTORY_RESOURCE << fixedTarget << "\";" << endl; + + writeRegRssList(t, userItems[RSS_TAG_SERVICE_LIST], + QLatin1String(RSS_TAG_SERVICE_LIST), + QLatin1String("SERVICE_INFO")); + writeRegRssList(t, userItems[RSS_TAG_FILE_OWNERSHIP_LIST], + QLatin1String(RSS_TAG_FILE_OWNERSHIP_LIST), + QLatin1String("FILE_OWNERSHIP_INFO")); + writeRegRssList(t, userItems[RSS_TAG_DATATYPE_LIST], + QLatin1String(RSS_TAG_DATATYPE_LIST), + QLatin1String("DATATYPE")); t << endl; - foreach(QString item, userItems) - t << "\t" << item << endl; + foreach(QString item, userItems[RSS_TAG_DEFAULT]) + t << "\t" << item.replace("\n","\n\t") << endl; t << "\t}" << endl; + + foreach(QString item, userItems[RSS_TAG_FOOTER]) + t << item << endl; } else { PRINT_FILE_CREATE_ERROR(filename) } } +void SymbianMakefileGenerator::writeRegRssList(QTextStream &t, + QStringList &userList, + const QString &listTag, + const QString &listItem) +{ + int itemCount = userList.count(); + if (itemCount) { + t << "\t" << listTag << " ="<< endl; + t << "\t\t{" << endl; + foreach(QString item, userList) { + t << "\t\t" << listItem << endl; + t << "\t\t\t{" << endl; + t << "\t\t\t" << item.replace("\n","\n\t\t\t") << endl; + t << "\t\t\t}"; + if (--itemCount) + t << ","; + t << endl; + } + t << "\t\t}; "<< endl; + } +} + void SymbianMakefileGenerator::writeRssFile(QString &numberOfIcons, QString &iconFile) { QString filename(fixedTarget); @@ -1538,7 +1581,9 @@ void SymbianMakefileGenerator::writeLocFile(QStringList &symbianLangCodes) } } -void SymbianMakefileGenerator::readRssRules(QString &numberOfIcons, QString &iconFile, QStringList &userRssRules) +void SymbianMakefileGenerator::readRssRules(QString &numberOfIcons, + QString &iconFile, QMap &userRssRules) { for (QMap::iterator it = project->variables().begin(); it != project->variables().end(); ++it) { if (it.key().startsWith(RSS_RULES_BASE)) { @@ -1550,14 +1595,16 @@ void SymbianMakefileGenerator::readRssRules(QString &numberOfIcons, QString &ico QStringList newValues; QStringList values = it.value(); foreach(QString item, values) { - // If there is no stringlist defined for a rule, use rule name directly + // If there is no stringlist defined for a rule, use rule value directly // This is convenience for defining single line statements if (project->values(item).isEmpty()) { newValues << item; } else { + QStringList itemList; foreach(QString itemRow, project->values(item)) { - newValues << itemRow; + itemList << itemRow; } + newValues << itemList.join("\n"); } } // Verify thet there is exactly one value in RSS_TAG_NBROFICONS @@ -1578,6 +1625,14 @@ void SymbianMakefileGenerator::readRssRules(QString &numberOfIcons, QString &ico RSS_RULES_BASE, RSS_TAG_ICONFILE); continue; } + } else if (newKey == RSS_TAG_HEADER + || newKey == RSS_TAG_SERVICE_LIST + || newKey == RSS_TAG_FILE_OWNERSHIP_LIST + || newKey == RSS_TAG_DATATYPE_LIST + || newKey == RSS_TAG_FOOTER + || newKey == RSS_TAG_DEFAULT) { + userRssRules[newKey] = newValues; + continue; } else { fprintf(stderr, "Warning: Unsupported key:'%s%s'\n", RSS_RULES_BASE, newKey.toLatin1().constData()); @@ -1586,15 +1641,17 @@ void SymbianMakefileGenerator::readRssRules(QString &numberOfIcons, QString &ico } } + QStringList newValues; foreach(QString item, project->values(RSS_RULES)) { - // If there is no stringlist defined for a rule, use rule name directly - // This is convenience for defining single line mmp statements + // If there is no stringlist defined for a rule, use rule value directly + // This is convenience for defining single line statements if (project->values(item).isEmpty()) { - userRssRules << item; + newValues << item; } else { - userRssRules << project->values(item); + newValues << project->values(item); } } + userRssRules[RSS_TAG_DEFAULT] << newValues; // Validate that either both RSS_TAG_NBROFICONS and RSS_TAG_ICONFILE keys exist // or neither of them exist diff --git a/qmake/generators/symbian/symmake.h b/qmake/generators/symbian/symmake.h index ca697b4..9de852a 100644 --- a/qmake/generators/symbian/symmake.h +++ b/qmake/generators/symbian/symmake.h @@ -107,7 +107,10 @@ protected: QString &checkString); void writeHeader(QTextStream &t); - void writeBldInfContent(QTextStream& t, bool addDeploymentExtension, const QString &iconFile, DeploymentList &depList); + void writeBldInfContent(QTextStream& t, + bool addDeploymentExtension, + const QString &iconFile, + DeploymentList &depList); static bool removeDuplicatedStrings(QStringList& stringList); @@ -127,10 +130,15 @@ protected: void writeCustomDefFile(); - void writeRegRssFile(QStringList &useritems); + void writeRegRssFile(QMap &useritems); + void writeRegRssList(QTextStream &t, QStringList &userList, + const QString &listTag, + const QString &listItem); void writeRssFile(QString &numberOfIcons, QString &iconfile); void writeLocFile(QStringList &symbianLangCodes); - void readRssRules(QString &numberOfIcons, QString &iconFile, QStringList &userRssRules); + void readRssRules(QString &numberOfIcons, + QString &iconFile, + QMap &userRssRules); QStringList symbianLangCodesFromTsFiles(); void fillQt2S60LangMapTable(); -- cgit v0.12 From 41bd30db724aa5cb816f6dea2b9fc5fd2cf7351c Mon Sep 17 00:00:00 2001 From: Carlos Manuel Duclos Vergara Date: Thu, 11 Mar 2010 16:50:39 +0100 Subject: Minisplitter doesn't paint to the bottom/right The problem is not related to the Splitter handle but related to an optimization in the paintengine. We were comparing if the size of the widget had changed before setting the new mask, which might not be correct. We could have changed the mask without changing the widget size. Task-number: QTCREATORBUG-753 Reviewed-by: Morten Reviewed-by: Samuel --- src/gui/kernel/qwidget_mac.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 5bce17f..bee93b5 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4682,8 +4682,10 @@ void QWidgetPrivate::syncCocoaMask() if (!q->testAttribute(Qt::WA_WState_Created) || !extra) return; - if (extra->hasMask && extra->maskBits.size() != q->size()) { - extra->maskBits = QImage(q->size(), QImage::Format_Mono); + if (extra->hasMask) { + if(extra->maskBits.size() != q->size()) { + extra->maskBits = QImage(q->size(), QImage::Format_Mono); + } extra->maskBits.fill(QColor(Qt::color1).rgba()); extra->maskBits.setNumColors(2); extra->maskBits.setColor(0, QColor(Qt::color0).rgba()); -- cgit v0.12 From 5058983c6ee286ca89598e0fed862f55250db26b Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 11 Mar 2010 14:27:03 +0100 Subject: Doc: Removed lie that access to QBuffer is unbuffered. In fact QIODevice still _does_ buffer access through QBuffer currently. Reviewed-by: Markus Goetz Reviewed-by: Joao --- src/corelib/io/qiodevice.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 662100a..c93f0c3 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -282,8 +282,7 @@ QIODevicePrivate::~QIODevicePrivate() Certain flags, such as \c Unbuffered and \c Truncate, are meaningless when used with some subclasses. Some of these restrictions are implied by the type of device that is represented - by a subclass; for example, access to a QBuffer is always - unbuffered. In other cases, the restriction may be due to the + by a subclass. In other cases, the restriction may be due to the implementation, or may be imposed by the underlying platform; for example, QTcpSocket does not support \c Unbuffered mode, and limitations in the native API prevent QFile from supporting \c -- cgit v0.12 From 37353a95fd11ec03ccde5c4e85ef2f0a605b85db Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 11 Mar 2010 17:23:21 +0100 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( 266a6c4f1938dd9edf4a8125faf91c62495e3ce2 ) Changes in WebKit/qt since the last update: [Qt] Avoid double-buffering with Qt image decoders http://trac.webkit.org/changeset/55844 --- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 13 +++++++++++++ .../webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 6a2e75f..a2d5f37 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - f3110d2f94c825477afac054ed448e45d47f5670 + 266a6c4f1938dd9edf4a8125faf91c62495e3ce2 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 61c2227..a3f70d3 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,16 @@ +2010-03-11 Simon Hausmann + + Reviewed by Tor Arne Vestbø. + + [Qt] Avoid double-buffering with Qt image decoders + + Pass QIODevice::Unbuffered when opening the QBuffer that + wraps the image data, to hint to Qt that no extra buffering + is needed. + + * platform/graphics/qt/ImageDecoderQt.cpp: + (WebCore::ImageDecoderQt::setData): + 2010-01-14 Diego Gonzalez Reviewed by Kenneth Christiansen. diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp index b6823dd..9bcb3e9 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp @@ -79,7 +79,7 @@ void ImageDecoderQt::setData(SharedBuffer* data, bool allDataReceived) QByteArray imageData = QByteArray::fromRawData(m_data->data(), m_data->size()); m_buffer = new QBuffer; m_buffer->setData(imageData); - m_buffer->open(QBuffer::ReadOnly); + m_buffer->open(QBuffer::ReadOnly | QIODevice::Unbuffered); m_reader = new QImageReader(m_buffer, m_format); } -- cgit v0.12 From 4fc638c0b4562f4b1e9c9a367535e4b570602942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 11 Mar 2010 15:21:43 +0100 Subject: Fixed bug in QTransform::type() after using operator/ or operator*. The m_dirty variable is not a bit flag any more. This caused the switch in QTransform::type() to not match any of the transformation types, and m_type was left at TxNone. Task-number: QTBUG-8557 Reviewed-by: Gunnar Sletta --- src/gui/painting/qtransform.h | 7 ++++--- tests/auto/qtransform/tst_qtransform.cpp | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index 9909643..212a582 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -293,7 +293,8 @@ inline QTransform &QTransform::operator*=(qreal num) affine._dx *= num; affine._dy *= num; m_33 *= num; - m_dirty |= TxScale; + if (m_dirty < TxScale) + m_dirty = TxScale; return *this; } inline QTransform &QTransform::operator/=(qreal div) @@ -316,7 +317,7 @@ inline QTransform &QTransform::operator+=(qreal num) affine._dx += num; affine._dy += num; m_33 += num; - m_dirty |= TxProject; + m_dirty = TxProject; return *this; } inline QTransform &QTransform::operator-=(qreal num) @@ -332,7 +333,7 @@ inline QTransform &QTransform::operator-=(qreal num) affine._dx -= num; affine._dy -= num; m_33 -= num; - m_dirty |= TxProject; + m_dirty = TxProject; return *this; } diff --git a/tests/auto/qtransform/tst_qtransform.cpp b/tests/auto/qtransform/tst_qtransform.cpp index 827a486..a3ded8e 100644 --- a/tests/auto/qtransform/tst_qtransform.cpp +++ b/tests/auto/qtransform/tst_qtransform.cpp @@ -610,6 +610,11 @@ void tst_QTransform::types() m4.rotate(45); QCOMPARE(m4.type(), QTransform::TxRotate); + + QTransform m5; + m5.scale(5, 5); + m5 = m5.adjoint() / m5.determinant(); + QCOMPARE(m5.type(), QTransform::TxScale); } -- cgit v0.12 From e6134f1bb7e77d6c1441a03e4829351f3f3bca95 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 11 Mar 2010 20:46:51 +0100 Subject: isalpha() is unspecified for values outside uchar and EOF Task-number: QTBUG-8907 --- tools/linguist/linguist/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp index 6e5c656..321fe8c 100644 --- a/tools/linguist/linguist/mainwindow.cpp +++ b/tools/linguist/linguist/mainwindow.cpp @@ -2370,7 +2370,7 @@ static bool haveMnemonic(const QString &str) // because we get a lot of false positives. if (c != '&' && c != ' ' && QChar(c).isPrint()) { const ushort *pp = p; - for (; ::isalpha(*p); p++) ; + for (; *p < 256 && ::isalpha(*p); p++) ; if (pp == p || *p != ';') return true; // This looks like a HTML &entity;, so ignore it. As a HTML string -- cgit v0.12 From b7ef079177ceec96f821393796c6c5b14c21704e Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Fri, 12 Mar 2010 09:31:57 +1000 Subject: QAudioInput sometimes not writing to QIODevice Handle error recovery better. Task-number:QTBUG-8893 Reviewed-by:Derick Hawcroft --- src/multimedia/audio/qaudioinput_alsa_p.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 5eb23d0..ead9995 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -121,6 +121,11 @@ int QAudioInputPrivate::xrun_recovery(int err) err = snd_pcm_prepare(handle); if(err < 0) reset = true; + else { + bytesAvailable = bytesReady(); + if (bytesAvailable <= 0) + reset = true; + } } else if((err == -ESTRPIPE)||(err == -EIO)) { errorState = QAudio::IOError; @@ -443,6 +448,7 @@ int QAudioInputPrivate::bytesReady() const if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) return 0; int frames = snd_pcm_avail_update(handle); + if (frames < 0) return frames; if((int)frames > (int)buffer_frames) frames = buffer_frames; @@ -459,6 +465,20 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) bytesAvailable = bytesReady(); + if (bytesAvailable < 0) { + // bytesAvailable as negative is error code, try to recover from it. + xrun_recovery(bytesAvailable); + bytesAvailable = bytesReady(); + if (bytesAvailable < 0) { + // recovery failed must stop and set error. + close(); + errorState = QAudio::IOError; + deviceState = QAudio::StoppedState; + emit stateChanged(deviceState); + return 0; + } + } + int count=0, err = 0; while(count < 5) { int chunks = bytesAvailable/period_size; -- cgit v0.12 From 89d015151924b2e9386b8bdf36156de5c6914e4e Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 12 Mar 2010 07:18:11 +0100 Subject: Ensure that the entire CLOB can be returned from an Oracle database The original CLOB was being truncated at 4000 bytes, even though the CLOB can hold up to 4gig, this ensures that its possible to get the whole thing. There is already a test in qsqlquery for this. Task-number: QTBUG-3875 Reviewed-by: Bill King --- src/sql/drivers/oci/qsql_oci.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp index 01c4124..4a211fc 100644 --- a/src/sql/drivers/oci/qsql_oci.cpp +++ b/src/sql/drivers/oci/qsql_oci.cpp @@ -517,7 +517,7 @@ QVariant::Type qDecodeOCIType(const QString& ocitype, QSql::NumericalPrecisionPo } else if (ocitype == QLatin1String("LONG") || ocitype == QLatin1String("NCLOB") || ocitype == QLatin1String("CLOB")) - type = QVariant::String; + type = QVariant::ByteArray; else if (ocitype == QLatin1String("RAW") || ocitype == QLatin1String("LONG RAW") || ocitype == QLatin1String("ROWID") || ocitype == QLatin1String("BLOB") || ocitype == QLatin1String("CFILE") || ocitype == QLatin1String("BFILE")) @@ -543,7 +543,6 @@ QVariant::Type qDecodeOCIType(int ocitype, QSql::NumericalPrecisionPolicy precis case SQLT_AVC: case SQLT_RDD: case SQLT_LNG: - case SQLT_CLOB: #ifdef SQLT_INTERVAL_YM case SQLT_INTERVAL_YM: #endif @@ -581,6 +580,7 @@ QVariant::Type qDecodeOCIType(int ocitype, QSql::NumericalPrecisionPolicy precis case SQLT_LVC: case SQLT_LVB: case SQLT_BLOB: + case SQLT_CLOB: case SQLT_FILE: case SQLT_NTY: case SQLT_REF: -- cgit v0.12 From 76bbc26d9d510570002baee91352f71a6dd46832 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Fri, 12 Mar 2010 08:34:08 +0200 Subject: Removed compiler warning from qdesktopwidget_s60.cpp. Reviewed-By: TrustMe --- src/gui/kernel/qdesktopwidget_s60.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/kernel/qdesktopwidget_s60.cpp b/src/gui/kernel/qdesktopwidget_s60.cpp index 84e3c5d..e4d0bf3 100644 --- a/src/gui/kernel/qdesktopwidget_s60.cpp +++ b/src/gui/kernel/qdesktopwidget_s60.cpp @@ -88,6 +88,7 @@ QDesktopWidgetPrivate::~QDesktopWidgetPrivate() void QDesktopWidgetPrivate::init(QDesktopWidget *that) { + Q_UNUSED(that); // int screenCount=0; // ### TODO: Implement proper multi-display support -- cgit v0.12 From 72ac56cd49c3c50b8b293b0f9843bafa8e197fcd Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Fri, 12 Mar 2010 08:38:42 +0200 Subject: HotFix for fluidlauncher default size caused by 6d44dadd. It seems that in Symbian we cannot restore Qt::WA_Moved and Qt::WA_Resized attributes in setWindowState method to the same ones what the attributes were when method was called. Thus we currently make sure that Qt::WA_Moved and Qt::WA_Resized attributes are not touched when normal window state is applied. There is a new task QTBUG-8977 to sort out when those attributes should be set and when not. Reviewed-By: Sami Merila --- src/gui/kernel/qwidget_s60.cpp | 21 +++++++++++++++++++-- tests/auto/qwidget/tst_qwidget.cpp | 4 ++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 81c4198..79702af 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -1037,6 +1037,17 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const return widgetPos; } +static Qt::WindowStates effectiveState(Qt::WindowStates state) +{ + if (state & Qt::WindowMinimized) + return Qt::WindowMinimized; + else if (state & Qt::WindowFullScreen) + return Qt::WindowFullScreen; + else if (state & Qt::WindowMaximized) + return Qt::WindowMaximized; + return Qt::WindowNoState; +} + void QWidget::setWindowState(Qt::WindowStates newstate) { Q_D(QWidget); @@ -1108,8 +1119,14 @@ void QWidget::setWindowState(Qt::WindowStates newstate) //restore normal geometry top->normalGeometry = normalGeometry; - setAttribute(Qt::WA_Resized, wasResized); - setAttribute(Qt::WA_Moved, wasMoved); + // FixMe QTBUG-8977 + // In some platforms, WA_Resized and WA_Moved are also not set when application window state is + // anything else than normal. In Symbian we can restore them only for normal window state since + // restoring for other modes, will make fluidlauncher to be launched in wrong size (200x100) + if (effectiveState(newstate) == Qt::WindowNoState) { + setAttribute(Qt::WA_Resized, wasResized); + setAttribute(Qt::WA_Moved, wasMoved); + } } data->window_state = newstate; diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 65f4945..76e20b9 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -10043,8 +10043,8 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy() void tst_QWidget::movedAndResizedAttributes() { -#if defined (Q_OS_MAC) || defined(Q_WS_QWS) - QEXPECT_FAIL("", "FixMe, QTBUG-8941", Abort); +#if defined (Q_OS_MAC) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) + QEXPECT_FAIL("", "FixMe, QTBUG-8941 and QTBUG-8977", Abort); QVERIFY(false); #else QWidget w; -- cgit v0.12 From 7829fe1507741c7196fe3904d90ea10178625393 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Fri, 12 Mar 2010 13:32:38 +0200 Subject: Moved softkey "Options" action handling from QMainWindow to QMenuBar. This change is done to enable QMenuBar usage and related "Options" softkey also on other than QMainWindow objects. For example with this change it is possible to create menubar and set it to QLayout by using setMenuBar, and it will then be usable via "Options" softkey. This functionality makes it easy to use different menus for different views in QStackedWidget. Task-number: QT-2275 (Not yet finished, but related) Reviewed-by: Sami Merila Reviewed-by: Alessandro Portale --- src/gui/widgets/qmainwindow.cpp | 25 ------------------- src/gui/widgets/qmenu_symbian.cpp | 8 ++++++ src/gui/widgets/qmenubar.cpp | 51 +++++++++++++++++++++++++++++++++------ src/gui/widgets/qmenubar_p.h | 5 +++- 4 files changed, 55 insertions(+), 34 deletions(-) diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 7e59bb0..16a7c31 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -65,9 +65,6 @@ QT_BEGIN_NAMESPACE extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp QT_END_NAMESPACE #endif -#ifdef QT_SOFTKEYS_ENABLED -#include -#endif QT_BEGIN_NAMESPACE @@ -80,9 +77,6 @@ public: #ifdef Q_WS_MAC , useHIToolBar(false) #endif -#ifdef QT_SOFTKEYS_ENABLED - , menuBarAction(0) -#endif #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) , hasOldCursor(false) , cursorAdjusted(false) #endif @@ -94,9 +88,6 @@ public: #ifdef Q_WS_MAC bool useHIToolBar; #endif -#ifdef QT_SOFTKEYS_ENABLED - QAction *menuBarAction; -#endif void init(); QList hoverSeparator; QPoint hoverPos; @@ -117,10 +108,6 @@ void QMainWindowPrivate::init() const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); iconSize = QSize(metric, metric); q->setAttribute(Qt::WA_Hover); -#ifdef QT_SOFTKEYS_ENABLED - menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, q); - menuBarAction->setVisible(false); -#endif } /* @@ -492,13 +479,6 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar) oldMenuBar->deleteLater(); } d->layout->setMenuBar(menuBar); - -#ifdef QT_SOFTKEYS_ENABLED - if (menuBar) - addAction(d->menuBarAction); - else - removeAction(d->menuBarAction); -#endif } /*! @@ -1427,11 +1407,6 @@ bool QMainWindow::event(QEvent *event) } break; #endif -#ifdef QT_SOFTKEYS_ENABLED - case QEvent::LanguageChange: - d->menuBarAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::MenuSoftKey)); - break; -#endif default: break; } diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index e46688c..7224768 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -324,6 +324,14 @@ void QMenuBarPrivate::symbianDestroyMenuBar() symbian_menubar = 0; } +void QMenuBarPrivate::reparentMenuBar(QWidget *oldParent, QWidget *newParent) +{ + if (menubars()->contains(oldParent)) { + QMenuBarPrivate *object = menubars()->take(oldParent); + menubars()->insert(newParent, object); + } +} + QMenuBarPrivate::QSymbianMenuBarPrivate::QSymbianMenuBarPrivate(QMenuBarPrivate *menubar) { d = menubar; diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 9caadb7..13aa02b 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -71,6 +71,10 @@ extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp #endif +#ifdef QT_SOFTKEYS_ENABLED +#include +#endif + QT_BEGIN_NAMESPACE class QMenuBarExtension : public QToolButton @@ -740,17 +744,14 @@ void QMenuBarPrivate::init() QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true); } #endif -#ifdef Q_WS_S60 - symbianCreateMenuBar(q->parentWidget()); - if(symbian_menubar) - q->hide(); -#endif - q->setBackgroundRole(QPalette::Button); oldWindow = oldParent = 0; #ifdef QT3_SUPPORT doAutoResize = false; #endif +#ifdef QT_SOFTKEYS_ENABLED + menuBarAction = 0; +#endif handleReparent(); q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q)); @@ -1384,10 +1385,38 @@ void QMenuBarPrivate::handleReparent() wce_menubar->rebuild(); #endif #ifdef Q_WS_S60 - if (symbian_menubar) + + // Construct symbian_menubar when this code path is entered first time + // and when newParent != NULL + if (!symbian_menubar) + symbianCreateMenuBar(newParent); + + // Reparent and rebuild menubar when parent is changed + if (symbian_menubar) { + if (oldParent != newParent) + reparentMenuBar(oldParent, newParent); + q->hide(); symbian_menubar->rebuild(); -#endif + } +#ifdef QT_SOFTKEYS_ENABLED + // Constuct menuBarAction when this code path is entered first time + if (!menuBarAction) { + if (newParent) { + menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, newParent); + menuBarAction->setVisible(false); + newParent->addAction(menuBarAction); + } + } else { + // If reparenting i.e. we already have menuBarAction, remove it from old parent + // and add for a new parent + if (oldParent) + oldParent->removeAction(menuBarAction); + if (newParent) + newParent->addAction(menuBarAction); + } +#endif // QT_SOFTKEYS_ENABLED +#endif // Q_WS_S60 } #ifdef QT3_SUPPORT @@ -1440,7 +1469,13 @@ void QMenuBar::changeEvent(QEvent *e) || e->type() == QEvent::ApplicationFontChange) { d->itemsDirty = true; d->updateGeometries(); +#ifdef QT_SOFTKEYS_ENABLED + } else if (e->type() == QEvent::LanguageChange) { + if (d->menuBarAction) + d->menuBarAction->setText(QSoftKeyManager::standardSoftKeyText(QSoftKeyManager::MenuSoftKey)); +#endif } + QWidget::changeEvent(e); } diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h index f2e5357..e4db6ce 100644 --- a/src/gui/widgets/qmenubar_p.h +++ b/src/gui/widgets/qmenubar_p.h @@ -243,6 +243,7 @@ public: #ifdef Q_WS_S60 void symbianCreateMenuBar(QWidget *); void symbianDestroyMenuBar(); + void reparentMenuBar(QWidget *oldParent, QWidget *newParent); struct QSymbianMenuBarPrivate { QList actionItems; QMenuBarPrivate *d; @@ -267,7 +268,9 @@ public: } *symbian_menubar; static int symbianCommands(int command); - +#ifdef QT_SOFTKEYS_ENABLED + QAction *menuBarAction; +#endif #endif }; #endif -- cgit v0.12 From f87f8078cdda79aad81cbd3fab3c5077bef3e2f6 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 12 Mar 2010 14:10:05 +0200 Subject: Fixed filename cases to support building Qt for Symbian in Linux Part of QtP delta reduction effort. Task-number: QT-3055 Reviewed-by: Janne Koskinen --- src/gui/kernel/qapplication_s60.cpp | 2 +- src/gui/kernel/qdnd_s60.cpp | 2 +- src/gui/kernel/qsound_s60.cpp | 2 +- src/gui/kernel/qt_s60_p.h | 4 ++-- src/gui/s60framework/qs60maindocument.h | 2 +- src/gui/s60framework/s60framework.pri | 2 +- src/gui/styles/qs60style_s60.cpp | 14 +++++++------- src/gui/styles/styles.pri | 24 ++++++++++++------------ src/gui/text/qfontdatabase_s60.cpp | 2 +- src/gui/text/qfontengine_s60_p.h | 2 +- src/gui/util/qdesktopservices_s60.cpp | 4 ++-- src/gui/util/util.pri | 2 +- src/plugins/s60/3_2/3_2.pro | 2 +- src/plugins/s60/5_0/5_0.pro | 2 +- src/plugins/s60/src/qdesktopservices_3_2.cpp | 2 +- 15 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 79b2bff..4a15cf2 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -63,7 +63,7 @@ #include "private/qsoftkeymanager_p.h" #include "apgwgnam.h" // For CApaWindowGroupName -#include // For CMdaAudioToneUtility +#include // For CMdaAudioToneUtility #if defined(Q_WS_S60) # if !defined(QT_NO_IM) diff --git a/src/gui/kernel/qdnd_s60.cpp b/src/gui/kernel/qdnd_s60.cpp index 24f0090..1aa30af 100644 --- a/src/gui/kernel/qdnd_s60.cpp +++ b/src/gui/kernel/qdnd_s60.cpp @@ -52,7 +52,7 @@ #include "qdnd_p.h" #include "qt_s60_p.h" -#include +#include // pointer cursor #include #include diff --git a/src/gui/kernel/qsound_s60.cpp b/src/gui/kernel/qsound_s60.cpp index 1832b85..df2830b 100644 --- a/src/gui/kernel/qsound_s60.cpp +++ b/src/gui/kernel/qsound_s60.cpp @@ -51,7 +51,7 @@ #include #include -#include +#include QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 735ca7a..cedede1 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -68,12 +68,12 @@ #include #ifdef Q_WS_S60 -#include // AknLayoutUtils +#include // AknLayoutUtils #include // EEikStatusPaneUidTitle #include // CAknTitlePane #include // CAknContextPane #include // CEikStatusPane -#include // MAknFadedComponent and TAknPopupFader +#include // MAknFadedComponent and TAknPopupFader #endif QT_BEGIN_NAMESPACE diff --git a/src/gui/s60framework/qs60maindocument.h b/src/gui/s60framework/qs60maindocument.h index 438b80c..553675f 100644 --- a/src/gui/s60framework/qs60maindocument.h +++ b/src/gui/s60framework/qs60maindocument.h @@ -46,7 +46,7 @@ #ifdef Q_WS_S60 -#include +#include class CEikApplication; diff --git a/src/gui/s60framework/s60framework.pri b/src/gui/s60framework/s60framework.pri index 5884b68..6080e6d 100644 --- a/src/gui/s60framework/s60framework.pri +++ b/src/gui/s60framework/s60framework.pri @@ -5,7 +5,7 @@ minimalAppResource31 = \ "SOURCEPATH s60framework" \ "START RESOURCE s60main.rss" \ "HEADER" \ - "TARGETPATH resource\apps" \ + "TARGETPATH /resource/apps" \ "END" MMP_RULES += minimalAppResource31 diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index d57b187..5202701 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -50,17 +50,17 @@ #include "qapplication.h" #include -#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include -#include +#include #include #include #include diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index 676f59e..5084442 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -164,17 +164,17 @@ contains( styles, windowsmobile ) { } contains( styles, s60 ):contains(QT_CONFIG, s60) { - HEADERS += \ - styles/qs60style.h \ - styles/qs60style_p.h - SOURCES += styles/qs60style.cpp - symbian { - SOURCES += styles/qs60style_s60.cpp - LIBS += -laknicon -laknskins -laknskinsrv -lfontutils -legul -lbmpanim - } else { - SOURCES += styles/qs60style_simulated.cpp - RESOURCES += styles/qstyle_s60_simulated.qrc - } + HEADERS += \ + styles/qs60style.h \ + styles/qs60style_p.h + SOURCES += styles/qs60style.cpp + symbian { + SOURCES += styles/qs60style_s60.cpp + LIBS += -lAknIcon -lAKNSKINS -lAKNSKINSRV -lFontUtils -legul -lbmpanim + } else { + SOURCES += styles/qs60style_simulated.cpp + RESOURCES += styles/qstyle_s60_simulated.qrc + } } else { - DEFINES += QT_NO_STYLE_S60 + DEFINES += QT_NO_STYLE_S60 } diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 7e5397d..87a73df 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -50,7 +50,7 @@ #include "qendian.h" #include #if defined(QT_NO_FREETYPE) -#include +#include #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS #include // COpenFontRasterizer has moved to a new header file #endif // SYMBIAN_ENABLE_SPLIT_HEADERS diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h index 78f8a9a..5834cc4 100644 --- a/src/gui/text/qfontengine_s60_p.h +++ b/src/gui/text/qfontengine_s60_p.h @@ -56,7 +56,7 @@ #include "qconfig.h" #include "qfontengine_p.h" #include "qsize.h" -#include +#include class CFont; diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp index adc4fc1..39240e6 100644 --- a/src/gui/util/qdesktopservices_s60.cpp +++ b/src/gui/util/qdesktopservices_s60.cpp @@ -62,8 +62,8 @@ const TUid KUidMsgTypeSMTP = {0x10001028}; // 268439592 #ifdef Q_WS_S60 # include // PathInfo # ifdef USE_DOCUMENTHANDLER -# include // CDocumentHandler -# include +# include // CDocumentHandler +# include # endif #else # warning CDocumentHandler requires support for S60 diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri index cdbb7cc..3074367 100644 --- a/src/gui/util/util.pri +++ b/src/gui/util/util.pri @@ -41,5 +41,5 @@ embedded { symbian { LIBS += -lsendas2 -letext -lapmime - contains(QT_CONFIG, s60): LIBS += -lplatformenv -lcommonui + contains(QT_CONFIG, s60): LIBS += -lplatformenv -lCommonUI } diff --git a/src/plugins/s60/3_2/3_2.pro b/src/plugins/s60/3_2/3_2.pro index 4b28eb9..468197d 100644 --- a/src/plugins/s60/3_2/3_2.pro +++ b/src/plugins/s60/3_2/3_2.pro @@ -10,7 +10,7 @@ contains(S60_VERSION, 3.1) { SOURCES += ../src/qlocale_3_2.cpp \ ../src/qdesktopservices_3_2.cpp \ ../src/qcoreapplication_3_2.cpp - LIBS += -ldirectorylocalizer -lefsrv + LIBS += -lDirectoryLocalizer -lefsrv INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE } diff --git a/src/plugins/s60/5_0/5_0.pro b/src/plugins/s60/5_0/5_0.pro index 4cdce12..86e3dc9 100644 --- a/src/plugins/s60/5_0/5_0.pro +++ b/src/plugins/s60/5_0/5_0.pro @@ -10,7 +10,7 @@ contains(S60_VERSION, 3.1) { SOURCES += ../src/qlocale_3_2.cpp \ ../src/qdesktopservices_3_2.cpp \ ../src/qcoreapplication_3_2.cpp - LIBS += -ldirectorylocalizer -lefsrv + LIBS += -lDirectoryLocalizer -lefsrv INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE } diff --git a/src/plugins/s60/src/qdesktopservices_3_2.cpp b/src/plugins/s60/src/qdesktopservices_3_2.cpp index a2f30f2..b4ca9a3 100644 --- a/src/plugins/s60/src/qdesktopservices_3_2.cpp +++ b/src/plugins/s60/src/qdesktopservices_3_2.cpp @@ -45,7 +45,7 @@ #ifdef Q_WS_S60 #include // CBase -> Required by cdirectorylocalizer.h -#include // CDirectoryLocalizer +#include // CDirectoryLocalizer EXPORT_C QString localizedDirectoryName(QString& rawPath) { -- cgit v0.12 From 8f94e47bb1066e420a410eb271502d1df4065663 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 12 Mar 2010 16:00:04 +0200 Subject: Updated qt.iby - Dependencies were removed as they cause difficulties for maintaining ROM build configurations. - PAGED flags were removed as paging configuration should be handled via other means. - MMF Phonon backend was commented out by default as normally ROM builds have Helix backend for Phonon included. Part of QtP delta reduction effort. Reviewed-by: Iain --- src/s60installs/qt.iby | 104 ++++++++++++++++--------------------------------- 1 file changed, 34 insertions(+), 70 deletions(-) diff --git a/src/s60installs/qt.iby b/src/s60installs/qt.iby index 724451b..ec019e2 100644 --- a/src/s60installs/qt.iby +++ b/src/s60installs/qt.iby @@ -3,92 +3,57 @@ #include -// Dependancies for more than one module -#include -#include // QtCore, QtGui, QtNetwork, QtOpenGL, QSvgIconEngine, -#include // QtGui, QtOpenGL -#include // for std C++ support - -// QtGui dependancies -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// QtNetwork dependancies -#include -#include - -// QtOpenGL dependancies -///@todo Problem here as we need libegl.dll and libglesv2.dll but they may come from a variety of places -/// depending on the platform we're on - #warning("qt.iby: hack - BINARY_SELECTION_ORDER really needs to be at the baseport/device level as it depends on the device type"); BINARY_SELECTION_ORDER ARMV6,ARMV5 // hack - this really needs to be at the baseport/device level as it depends on the device type -file=ABI_DIR\BUILD_DIR\QtCore.dll SHARED_LIB_DIR\QtCore.dll PAGED -file=ABI_DIR\BUILD_DIR\QtGui.dll SHARED_LIB_DIR\QtGui.dll PAGED -file=ABI_DIR\BUILD_DIR\QtOpenGL.dll SHARED_LIB_DIR\QtOpenGL.dll PAGED -file=ABI_DIR\BUILD_DIR\QtOpenVG.dll SHARED_LIB_DIR\QtOpenVG.dll PAGED -file=ABI_DIR\BUILD_DIR\QtSvg.dll SHARED_LIB_DIR\QtSvg.dll PAGED -file=ABI_DIR\BUILD_DIR\QtSql.dll SHARED_LIB_DIR\QtSql.dll PAGED -file=ABI_DIR\BUILD_DIR\QtXml.dll SHARED_LIB_DIR\QtXml.dll PAGED -file=ABI_DIR\BUILD_DIR\QtNetwork.dll SHARED_LIB_DIR\QtNetwork.dll PAGED -file=ABI_DIR\BUILD_DIR\QtScript.dll SHARED_LIB_DIR\QtScript.dll PAGED -file=ABI_DIR\BUILD_DIR\QtTest.dll SHARED_LIB_DIR\QtTest.dll PAGED -file=ABI_DIR\BUILD_DIR\QtWebKit.dll SHARED_LIB_DIR\QtWebKit.dll PAGED -file=ABI_DIR\BUILD_DIR\phonon.dll SHARED_LIB_DIR\phonon.dll PAGED -file=ABI_DIR\BUILD_DIR\QtMultimedia.dll SHARED_LIB_DIR\QtMultimedia.dll PAGED -file=ABI_DIR\BUILD_DIR\QtXmlPatterns.dll SHARED_LIB_DIR\QtXmlPatterns.dll PAGED -file=ABI_DIR\BUILD_DIR\QtDeclarative.dll SHARED_LIB_DIR\QtDeclarative.dll PAGED +file=ABI_DIR\BUILD_DIR\QtCore.dll SHARED_LIB_DIR\QtCore.dll +file=ABI_DIR\BUILD_DIR\QtGui.dll SHARED_LIB_DIR\QtGui.dll +file=ABI_DIR\BUILD_DIR\QtOpenVG.dll SHARED_LIB_DIR\QtOpenVG.dll +file=ABI_DIR\BUILD_DIR\QtSvg.dll SHARED_LIB_DIR\QtSvg.dll +file=ABI_DIR\BUILD_DIR\QtSql.dll SHARED_LIB_DIR\QtSql.dll +file=ABI_DIR\BUILD_DIR\QtXml.dll SHARED_LIB_DIR\QtXml.dll +file=ABI_DIR\BUILD_DIR\QtNetwork.dll SHARED_LIB_DIR\QtNetwork.dll +file=ABI_DIR\BUILD_DIR\QtScript.dll SHARED_LIB_DIR\QtScript.dll +file=ABI_DIR\BUILD_DIR\QtTest.dll SHARED_LIB_DIR\QtTest.dll +file=ABI_DIR\BUILD_DIR\QtWebKit.dll SHARED_LIB_DIR\QtWebKit.dll +file=ABI_DIR\BUILD_DIR\phonon.dll SHARED_LIB_DIR\phonon.dll +file=ABI_DIR\BUILD_DIR\QtMultimedia.dll SHARED_LIB_DIR\QtMultimedia.dll +file=ABI_DIR\BUILD_DIR\QtXmlPatterns.dll SHARED_LIB_DIR\QtXmlPatterns.dll +file=ABI_DIR\BUILD_DIR\QtDeclarative.dll SHARED_LIB_DIR\QtDeclarative.dll // imageformats -file=ABI_DIR\BUILD_DIR\qgif.dll SHARED_LIB_DIR\qgif.dll PAGED -file=ABI_DIR\BUILD_DIR\qico.dll SHARED_LIB_DIR\qico.dll PAGED -file=ABI_DIR\BUILD_DIR\qjpeg.dll SHARED_LIB_DIR\qjpeg.dll PAGED -file=ABI_DIR\BUILD_DIR\qmng.dll SHARED_LIB_DIR\qmng.dll PAGED -file=ABI_DIR\BUILD_DIR\qsvg.dll SHARED_LIB_DIR\qsvg.dll PAGED -file=ABI_DIR\BUILD_DIR\qtiff.dll SHARED_LIB_DIR\qtiff.dll PAGED +file=ABI_DIR\BUILD_DIR\qgif.dll SHARED_LIB_DIR\qgif.dll +file=ABI_DIR\BUILD_DIR\qico.dll SHARED_LIB_DIR\qico.dll +file=ABI_DIR\BUILD_DIR\qjpeg.dll SHARED_LIB_DIR\qjpeg.dll +file=ABI_DIR\BUILD_DIR\qmng.dll SHARED_LIB_DIR\qmng.dll +file=ABI_DIR\BUILD_DIR\qsvg.dll SHARED_LIB_DIR\qsvg.dll +file=ABI_DIR\BUILD_DIR\qtiff.dll SHARED_LIB_DIR\qtiff.dll // codecs -file=ABI_DIR\BUILD_DIR\qcncodecs.dll SHARED_LIB_DIR\qcncodecs.dll PAGED -file=ABI_DIR\BUILD_DIR\qjpcodecs.dll SHARED_LIB_DIR\qjpcodecs.dll PAGED -file=ABI_DIR\BUILD_DIR\qkrcodecs.dll SHARED_LIB_DIR\qkrcodecs.dll PAGED -file=ABI_DIR\BUILD_DIR\qtwcodecs.dll SHARED_LIB_DIR\qtwcodecs.dll PAGED +file=ABI_DIR\BUILD_DIR\qcncodecs.dll SHARED_LIB_DIR\qcncodecs.dll +file=ABI_DIR\BUILD_DIR\qjpcodecs.dll SHARED_LIB_DIR\qjpcodecs.dll +file=ABI_DIR\BUILD_DIR\qkrcodecs.dll SHARED_LIB_DIR\qkrcodecs.dll +file=ABI_DIR\BUILD_DIR\qtwcodecs.dll SHARED_LIB_DIR\qtwcodecs.dll // iconengines -file=ABI_DIR\BUILD_DIR\qsvgicon.dll SHARED_LIB_DIR\qsvgicon.dll PAGED +file=ABI_DIR\BUILD_DIR\qsvgicon.dll SHARED_LIB_DIR\qsvgicon.dll // Phonon MMF backend -file=ABI_DIR\BUILD_DIR\phonon_mmf.dll SHARED_LIB_DIR\phonon_mmf.dll PAGED +// This is commented out by default, as normally Helix backend will be used. +// If the Helix backend is present, it will override MMF backend, so make sure to remove it from +// image creation in addition to uncommenting the following lines if you want to use MMF backend. +//file=ABI_DIR\BUILD_DIR\phonon_mmf.dll SHARED_LIB_DIR\phonon_mmf.dll +//data=\epoc32\data\z\resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin // QtMultimedia audio backend -file=ABI_DIR\BUILD_DIR\qaudio.dll SHARED_LIB_DIR\qaudio.dll PAGED +file=ABI_DIR\BUILD_DIR\qaudio.dll SHARED_LIB_DIR\qaudio.dll // graphicssystems -file=ABI_DIR\BUILD_DIR\qvggraphicssystem.dll SHARED_LIB_DIR\qvggraphicssystem.dll PAGED +file=ABI_DIR\BUILD_DIR\qvggraphicssystem.dll SHARED_LIB_DIR\qvggraphicssystem.dll // S60 version compatibility plugins for 5.0 (3.1 and 3.2 devices are never likely to have this in ROM, // so don't bother including those plugins -file=ABI_DIR\BUILD_DIR\qts60plugin_5_0.dll SHARED_LIB_DIR\qts60plugin_5_0.dll PAGED +file=ABI_DIR\BUILD_DIR\qts60plugin_5_0.dll SHARED_LIB_DIR\qts60plugin_5_0.dll S60_APP_RESOURCE(s60main) @@ -109,8 +74,6 @@ data=\epoc32\data\z\resource\qt\plugins\codecs\qtwcodecs.qtplugin resou // iconengines stubs data=\epoc32\data\z\resource\qt\plugins\iconengines\qsvgicon.qtplugin resource\qt\plugins\iconengines\qsvgicon.qtplugin -// Phonon MMF backend -data=\epoc32\data\z\resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin // QtMultimedia audio backend data=\epoc32\data\qt\qtlibspluginstubs\qaudio.qtplugin resource\qt\plugins\audio\qaudio.qtplugin @@ -123,3 +86,4 @@ data=ZSYSTEM\install\qt_stub.sis System\Install\qt_stub.sis data=ZSYSTEM\install\qtwebkit_stub.sis System\Install\qtwebkit_stub.sis #endif // __QT_IBY__ + -- cgit v0.12 From bd4329cc96d9dadb1e4ef490884c17bcd1201741 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 12 Mar 2010 15:22:39 +0000 Subject: Updated Symbian DEF files Marked as absent a symbol removed by 971f1947 Reviewed-by: trustme --- src/s60installs/bwins/QtGuiu.def | 2 +- src/s60installs/eabi/QtGuiu.def | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 4f30cb5..8e758d0 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -8995,7 +8995,7 @@ EXPORTS ?setFocus@QTextControl@@QAEX_NW4FocusReason@Qt@@@Z @ 8994 NONAME ; void QTextControl::setFocus(bool, enum Qt::FocusReason) ?setFocus@QWidget@@QAEXW4FocusReason@Qt@@@Z @ 8995 NONAME ; void QWidget::setFocus(enum Qt::FocusReason) ?setFocus@QWidget@@QAEXXZ @ 8996 NONAME ; void QWidget::setFocus(void) - ?setFocusHelper@QGraphicsItemPrivate@@QAEXW4FocusReason@Qt@@_N@Z @ 8997 NONAME ; void QGraphicsItemPrivate::setFocusHelper(enum Qt::FocusReason, bool) + ?setFocusHelper@QGraphicsItemPrivate@@QAEXW4FocusReason@Qt@@_N@Z @ 8997 NONAME ABSENT ; void QGraphicsItemPrivate::setFocusHelper(enum Qt::FocusReason, bool) ?setFocusItem@QGraphicsScene@@QAEXPAVQGraphicsItem@@W4FocusReason@Qt@@@Z @ 8998 NONAME ; void QGraphicsScene::setFocusItem(class QGraphicsItem *, enum Qt::FocusReason) ?setFocusPolicy@QGraphicsWidget@@QAEXW4FocusPolicy@Qt@@@Z @ 8999 NONAME ; void QGraphicsWidget::setFocusPolicy(enum Qt::FocusPolicy) ?setFocusPolicy@QWidget@@QAEXW4FocusPolicy@Qt@@@Z @ 9000 NONAME ; void QWidget::setFocusPolicy(enum Qt::FocusPolicy) diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 5cf700b..373f66d 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -4663,7 +4663,7 @@ EXPORTS _ZN20QGraphicsItemPrivate12resolveDepthEv @ 4662 NONAME _ZN20QGraphicsItemPrivate12setPosHelperERK7QPointF @ 4663 NONAME _ZN20QGraphicsItemPrivate13clearSubFocusEP13QGraphicsItem @ 4664 NONAME - _ZN20QGraphicsItemPrivate14setFocusHelperEN2Qt11FocusReasonEb @ 4665 NONAME + _ZN20QGraphicsItemPrivate14setFocusHelperEN2Qt11FocusReasonEb @ 4665 NONAME ABSENT _ZN20QGraphicsItemPrivate15resetFocusProxyEv @ 4666 NONAME _ZN20QGraphicsItemPrivate16setEnabledHelperEbbb @ 4667 NONAME _ZN20QGraphicsItemPrivate16setVisibleHelperEbbb @ 4668 NONAME -- cgit v0.12 From d73df73c556b0a225fdde7341549ed834bc691f4 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 12 Mar 2010 12:58:45 +0000 Subject: Moved Symbian audio backend into QtMultimedia.dll Changed backend from being a plugin, to being statically compiled into QtMultimedia.dll. This is to achieve consistency with the backends for other plugins, and to allow the plugin API to be modified. Task-number: QTBUG-8994 Reviewed-by: trustme --- src/multimedia/audio/audio.pri | 15 + src/multimedia/audio/qaudio_symbian_p.cpp | 395 ++++++++++++ src/multimedia/audio/qaudio_symbian_p.h | 156 +++++ src/multimedia/audio/qaudiodevicefactory.cpp | 16 +- .../audio/qaudiodeviceinfo_symbian_p.cpp | 200 ++++++ src/multimedia/audio/qaudiodeviceinfo_symbian_p.h | 107 ++++ src/multimedia/audio/qaudioinput_symbian_p.cpp | 594 ++++++++++++++++++ src/multimedia/audio/qaudioinput_symbian_p.h | 188 ++++++ src/multimedia/audio/qaudiooutput_symbian_p.cpp | 696 ++++++++++++++++++++ src/multimedia/audio/qaudiooutput_symbian_p.h | 210 +++++++ src/plugins/audio/audio.pro | 6 - src/plugins/audio/symbian/main.cpp | 121 ---- src/plugins/audio/symbian/symbian.pro | 31 - src/plugins/audio/symbian/symbianaudio.h | 76 --- .../audio/symbian/symbianaudiodeviceinfo.cpp | 191 ------ src/plugins/audio/symbian/symbianaudiodeviceinfo.h | 94 --- src/plugins/audio/symbian/symbianaudioinput.cpp | 595 ------------------ src/plugins/audio/symbian/symbianaudioinput.h | 177 ------ src/plugins/audio/symbian/symbianaudiooutput.cpp | 697 --------------------- src/plugins/audio/symbian/symbianaudiooutput.h | 199 ------ src/plugins/audio/symbian/symbianaudioutils.cpp | 395 ------------ src/plugins/audio/symbian/symbianaudioutils.h | 125 ---- src/s60installs/s60installs.pro | 6 - 23 files changed, 2571 insertions(+), 2719 deletions(-) create mode 100644 src/multimedia/audio/qaudio_symbian_p.cpp create mode 100644 src/multimedia/audio/qaudio_symbian_p.h create mode 100644 src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp create mode 100644 src/multimedia/audio/qaudiodeviceinfo_symbian_p.h create mode 100644 src/multimedia/audio/qaudioinput_symbian_p.cpp create mode 100644 src/multimedia/audio/qaudioinput_symbian_p.h create mode 100644 src/multimedia/audio/qaudiooutput_symbian_p.cpp create mode 100644 src/multimedia/audio/qaudiooutput_symbian_p.h delete mode 100644 src/plugins/audio/symbian/main.cpp delete mode 100644 src/plugins/audio/symbian/symbian.pro delete mode 100644 src/plugins/audio/symbian/symbianaudio.h delete mode 100644 src/plugins/audio/symbian/symbianaudiodeviceinfo.cpp delete mode 100644 src/plugins/audio/symbian/symbianaudiodeviceinfo.h delete mode 100644 src/plugins/audio/symbian/symbianaudioinput.cpp delete mode 100644 src/plugins/audio/symbian/symbianaudioinput.h delete mode 100644 src/plugins/audio/symbian/symbianaudiooutput.cpp delete mode 100644 src/plugins/audio/symbian/symbianaudiooutput.h delete mode 100644 src/plugins/audio/symbian/symbianaudioutils.cpp delete mode 100644 src/plugins/audio/symbian/symbianaudioutils.h diff --git a/src/multimedia/audio/audio.pri b/src/multimedia/audio/audio.pri index 625b871c..ae28a26 100644 --- a/src/multimedia/audio/audio.pri +++ b/src/multimedia/audio/audio.pri @@ -41,6 +41,21 @@ mac { !wince*:LIBS += -lwinmm wince*:LIBS += -lcoredll +} else:symbian { + INCLUDEPATH += /epoc32/include/mmf/common + INCLUDEPATH += /epoc32/include/mmf/server + + HEADERS += $$PWD/qaudio_symbian_p.h \ + $$PWD/qaudiodeviceinfo_symbian_p.h \ + $$PWD/qaudioinput_symbian_p.h \ + $$PWD/qaudiooutput_symbian_p.h + + SOURCES += $$PWD/qaudio_symbian_p.cpp \ + $$PWD/qaudiodeviceinfo_symbian_p.cpp \ + $$PWD/qaudioinput_symbian_p.cpp \ + $$PWD/qaudiooutput_symbian_p.cpp + + LIBS += -lmmfdevsound } else:unix { unix:contains(QT_CONFIG, alsa) { linux-*|freebsd-*|openbsd-*:{ diff --git a/src/multimedia/audio/qaudio_symbian_p.cpp b/src/multimedia/audio/qaudio_symbian_p.cpp new file mode 100644 index 0000000..58e3745 --- /dev/null +++ b/src/multimedia/audio/qaudio_symbian_p.cpp @@ -0,0 +1,395 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qaudio_symbian_p.h" +#include + +QT_BEGIN_NAMESPACE + +namespace SymbianAudio { + +DevSoundCapabilities::DevSoundCapabilities(CMMFDevSound &devsound, + QAudio::Mode mode) +{ + QT_TRAP_THROWING(constructL(devsound, mode)); +} + +DevSoundCapabilities::~DevSoundCapabilities() +{ + m_fourCC.Close(); +} + +void DevSoundCapabilities::constructL(CMMFDevSound &devsound, + QAudio::Mode mode) +{ + m_caps = devsound.Capabilities(); + + TMMFPrioritySettings settings; + + switch (mode) { + case QAudio::AudioOutput: + settings.iState = EMMFStatePlaying; + devsound.GetSupportedInputDataTypesL(m_fourCC, settings); + break; + + case QAudio::AudioInput: + settings.iState = EMMFStateRecording; + devsound.GetSupportedInputDataTypesL(m_fourCC, settings); + break; + + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); + } +} + +namespace Utils { + +//----------------------------------------------------------------------------- +// Static data +//----------------------------------------------------------------------------- + +// Sample rate / frequency + +typedef TMMFSampleRate SampleRateNative; +typedef int SampleRateQt; + +const int SampleRateCount = 12; + +const SampleRateNative SampleRateListNative[SampleRateCount] = { + EMMFSampleRate8000Hz + , EMMFSampleRate11025Hz + , EMMFSampleRate12000Hz + , EMMFSampleRate16000Hz + , EMMFSampleRate22050Hz + , EMMFSampleRate24000Hz + , EMMFSampleRate32000Hz + , EMMFSampleRate44100Hz + , EMMFSampleRate48000Hz + , EMMFSampleRate64000Hz + , EMMFSampleRate88200Hz + , EMMFSampleRate96000Hz +}; + +const SampleRateQt SampleRateListQt[SampleRateCount] = { + 8000 + , 11025 + , 12000 + , 16000 + , 22050 + , 24000 + , 32000 + , 44100 + , 48000 + , 64000 + , 88200 + , 96000 +}; + +// Channels + +typedef TMMFMonoStereo ChannelsNative; +typedef int ChannelsQt; + +const int ChannelsCount = 2; + +const ChannelsNative ChannelsListNative[ChannelsCount] = { + EMMFMono + , EMMFStereo +}; + +const ChannelsQt ChannelsListQt[ChannelsCount] = { + 1 + , 2 +}; + +// Encoding + +const int EncodingCount = 6; + +const TUint32 EncodingFourCC[EncodingCount] = { + KMMFFourCCCodePCM8 // 0 + , KMMFFourCCCodePCMU8 // 1 + , KMMFFourCCCodePCM16 // 2 + , KMMFFourCCCodePCMU16 // 3 + , KMMFFourCCCodePCM16B // 4 + , KMMFFourCCCodePCMU16B // 5 +}; + +// The characterised DevSound API specification states that the iEncoding +// field in TMMFCapabilities is ignored, and that the FourCC should be used +// to specify the PCM encoding. +// See "SGL.GT0287.102 Multimedia DevSound Baseline Compatibility.doc" in the +// mm_info/mm_docs repository. +const TMMFSoundEncoding EncodingNative[EncodingCount] = { + EMMFSoundEncoding16BitPCM // 0 + , EMMFSoundEncoding16BitPCM // 1 + , EMMFSoundEncoding16BitPCM // 2 + , EMMFSoundEncoding16BitPCM // 3 + , EMMFSoundEncoding16BitPCM // 4 + , EMMFSoundEncoding16BitPCM // 5 +}; + + +const int EncodingSampleSize[EncodingCount] = { + 8 // 0 + , 8 // 1 + , 16 // 2 + , 16 // 3 + , 16 // 4 + , 16 // 5 +}; + +const QAudioFormat::Endian EncodingByteOrder[EncodingCount] = { + QAudioFormat::LittleEndian // 0 + , QAudioFormat::LittleEndian // 1 + , QAudioFormat::LittleEndian // 2 + , QAudioFormat::LittleEndian // 3 + , QAudioFormat::BigEndian // 4 + , QAudioFormat::BigEndian // 5 +}; + +const QAudioFormat::SampleType EncodingSampleType[EncodingCount] = { + QAudioFormat::SignedInt // 0 + , QAudioFormat::UnSignedInt // 1 + , QAudioFormat::SignedInt // 2 + , QAudioFormat::UnSignedInt // 3 + , QAudioFormat::SignedInt // 4 + , QAudioFormat::UnSignedInt // 5 +}; + + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +// Helper functions for implementing parameter conversions + +template +bool findValue(const Input *inputArray, int length, Input input, int &index) { + bool result = false; + for (int i=0; !result && i +bool convertValue(const Input *inputArray, const Output *outputArray, + int length, Input input, Output &output) { + int index; + const bool result = findValue(inputArray, length, input, index); + if (result) + output = outputArray[index]; + return result; +} + +/** + * Macro which is used to generate the implementation of the conversion + * functions. The implementation is just a wrapper around the templated + * convertValue function, e.g. + * + * CONVERSION_FUNCTION_IMPL(SampleRate, Qt, Native) + * + * expands to + * + * bool SampleRateQtToNative(int input, TMMFSampleRate &output) { + * return convertValue + * (SampleRateListQt, SampleRateListNative, SampleRateCount, + * input, output); + * } + */ +#define CONVERSION_FUNCTION_IMPL(FieldLc, Field, Input, Output) \ +bool FieldLc##Input##To##Output(Field##Input input, Field##Output &output) { \ + return convertValue(Field##List##Input, \ + Field##List##Output, Field##Count, input, output); \ +} + +//----------------------------------------------------------------------------- +// Local helper functions +//----------------------------------------------------------------------------- + +CONVERSION_FUNCTION_IMPL(sampleRate, SampleRate, Qt, Native) +CONVERSION_FUNCTION_IMPL(sampleRate, SampleRate, Native, Qt) +CONVERSION_FUNCTION_IMPL(channels, Channels, Qt, Native) +CONVERSION_FUNCTION_IMPL(channels, Channels, Native, Qt) + +bool sampleInfoQtToNative(int inputSampleSize, + QAudioFormat::Endian inputByteOrder, + QAudioFormat::SampleType inputSampleType, + TUint32 &outputFourCC, + TMMFSoundEncoding &outputEncoding) { + + bool found = false; + + for (int i=0; i &frequencies, + QList &channels, + QList &sampleSizes, + QList &byteOrders, + QList &sampleTypes) { + + frequencies.clear(); + sampleSizes.clear(); + byteOrders.clear(); + sampleTypes.clear(); + channels.clear(); + + for (int i=0; i +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace SymbianAudio { + +/** + * Default values used by audio input and output classes, when underlying + * DevSound instance has not yet been created. + */ + +const int DefaultBufferSize = 4096; // bytes +const int DefaultNotifyInterval = 1000; // ms + +/** + * Enumeration used to track state of internal DevSound instances. + * Values are translated to the corresponding QAudio::State values by + * SymbianAudio::Utils::stateNativeToQt. + */ +enum State { + ClosedState + , InitializingState + , ActiveState + , IdleState + , SuspendedState +}; + +/* + * Helper class for querying DevSound codec / format support + */ +class DevSoundCapabilities { +public: + DevSoundCapabilities(CMMFDevSound &devsound, QAudio::Mode mode); + ~DevSoundCapabilities(); + + const RArray& fourCC() const { return m_fourCC; } + const TMMFCapabilities& caps() const { return m_caps; } + +private: + void constructL(CMMFDevSound &devsound, QAudio::Mode mode); + +private: + RArray m_fourCC; + TMMFCapabilities m_caps; +}; + +namespace Utils { + +/** + * Convert native audio capabilities to QAudio lists. + */ +void capabilitiesNativeToQt(const DevSoundCapabilities &caps, + QList &frequencies, + QList &channels, + QList &sampleSizes, + QList &byteOrders, + QList &sampleTypes); + +/** + * Check whether format is supported. + */ +bool isFormatSupported(const QAudioFormat &format, + const DevSoundCapabilities &caps); + +/** + * Convert QAudioFormat to native format types. + * + * Note that, despite the name, DevSound uses TMMFCapabilities to specify + * single formats as well as capabilities. + * + * Note that this function does not modify outputFormat.iBufferSize. + */ +bool formatQtToNative(const QAudioFormat &inputFormat, + TUint32 &outputFourCC, + TMMFCapabilities &outputFormat); + +/** + * Convert internal states to QAudio states. + */ +QAudio::State stateNativeToQt(State nativeState, + QAudio::State initializingState); + +/** + * Convert data length to number of samples. + */ +qint64 bytesToSamples(const QAudioFormat &format, qint64 length); + +/** + * Convert number of samples to data length. + */ +qint64 samplesToBytes(const QAudioFormat &format, qint64 samples); + +} // namespace Utils +} // namespace SymbianAudio + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/audio/qaudiodevicefactory.cpp b/src/multimedia/audio/qaudiodevicefactory.cpp index 459b7f5..4f45110 100644 --- a/src/multimedia/audio/qaudiodevicefactory.cpp +++ b/src/multimedia/audio/qaudiodevicefactory.cpp @@ -58,6 +58,10 @@ #include "qaudiodeviceinfo_alsa_p.h" #include "qaudiooutput_alsa_p.h" #include "qaudioinput_alsa_p.h" +#elif defined(Q_OS_SYMBIAN) +#include "qaudiodeviceinfo_symbian_p.h" +#include "qaudiooutput_symbian_p.h" +#include "qaudioinput_symbian_p.h" #endif #endif @@ -128,7 +132,7 @@ QList QAudioDeviceFactory::availableDevices(QAudio::Mode mode) { QList devices; #ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode)) devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode); #endif @@ -158,7 +162,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultInputDevice() return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioInput); } #ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultInputDevice(), QAudio::AudioInput); #endif #endif @@ -175,7 +179,7 @@ QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); } #ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) return QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultOutputDevice(), QAudio::AudioOutput); #endif #endif @@ -187,7 +191,7 @@ QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &re QAbstractAudioDeviceInfo *rc = 0; #ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) if (realm == QLatin1String("builtin")) return new QAudioDeviceInfoInternal(handle, mode); #endif @@ -216,7 +220,7 @@ QAbstractAudioInput* QAudioDeviceFactory::createInputDevice(QAudioDeviceInfo con if (deviceInfo.isNull()) return new QNullInputDevice(); #ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) if (deviceInfo.realm() == QLatin1String("builtin")) return new QAudioInputPrivate(deviceInfo.handle(), format); #endif @@ -235,7 +239,7 @@ QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceInfo c if (deviceInfo.isNull()) return new QNullOutputDevice(); #ifndef QT_NO_AUDIO_BACKEND -#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA)) +#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) if (deviceInfo.realm() == QLatin1String("builtin")) return new QAudioOutputPrivate(deviceInfo.handle(), format); #endif diff --git a/src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp new file mode 100644 index 0000000..36284d3 --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.cpp @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qaudiodeviceinfo_symbian_p.h" +#include "qaudio_symbian_p.h" + +QT_BEGIN_NAMESPACE + +QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray device, + QAudio::Mode mode) + : m_deviceName(QLatin1String(device)) + , m_mode(mode) + , m_updated(false) +{ + QT_TRAP_THROWING(m_devsound.reset(CMMFDevSound::NewL())); +} + +QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() +{ + +} + +QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const +{ + QAudioFormat format; + switch (m_mode) { + case QAudio::AudioOutput: + format.setFrequency(44100); + format.setChannels(2); + format.setSampleSize(16); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setSampleType(QAudioFormat::SignedInt); + format.setCodec(QLatin1String("audio/pcm")); + break; + + case QAudio::AudioInput: + format.setFrequency(8000); + format.setChannels(1); + format.setSampleSize(16); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setSampleType(QAudioFormat::SignedInt); + format.setCodec(QLatin1String("audio/pcm")); + break; + + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); + } + + if (!isFormatSupported(format)) { + if (m_frequencies.size()) + format.setFrequency(m_frequencies[0]); + if (m_channels.size()) + format.setChannels(m_channels[0]); + if (m_sampleSizes.size()) + format.setSampleSize(m_sampleSizes[0]); + if (m_byteOrders.size()) + format.setByteOrder(m_byteOrders[0]); + if (m_sampleTypes.size()) + format.setSampleType(m_sampleTypes[0]); + } + + return format; +} + +bool QAudioDeviceInfoInternal::isFormatSupported( + const QAudioFormat &format) const +{ + getSupportedFormats(); + const bool supported = + m_codecs.contains(format.codec()) + && m_frequencies.contains(format.frequency()) + && m_channels.contains(format.channels()) + && m_sampleSizes.contains(format.sampleSize()) + && m_byteOrders.contains(format.byteOrder()) + && m_sampleTypes.contains(format.sampleType()); + + return supported; +} + +QAudioFormat QAudioDeviceInfoInternal::nearestFormat(const QAudioFormat &format) const +{ + if (isFormatSupported(format)) + return format; + else + return preferredFormat(); +} + +QString QAudioDeviceInfoInternal::deviceName() const +{ + return m_deviceName; +} + +QStringList QAudioDeviceInfoInternal::codecList() +{ + getSupportedFormats(); + return m_codecs; +} + +QList QAudioDeviceInfoInternal::frequencyList() +{ + getSupportedFormats(); + return m_frequencies; +} + +QList QAudioDeviceInfoInternal::channelsList() +{ + getSupportedFormats(); + return m_channels; +} + +QList QAudioDeviceInfoInternal::sampleSizeList() +{ + getSupportedFormats(); + return m_sampleSizes; +} + +QList QAudioDeviceInfoInternal::byteOrderList() +{ + getSupportedFormats(); + return m_byteOrders; +} + +QList QAudioDeviceInfoInternal::sampleTypeList() +{ + getSupportedFormats(); + return m_sampleTypes; +} + +QByteArray QAudioDeviceInfoInternal::defaultInputDevice() +{ + return QByteArray("default"); +} + +QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() +{ + return QByteArray("default"); +} + +QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode) +{ + QList result; + result += QByteArray("default"); + return result; +} + +void QAudioDeviceInfoInternal::getSupportedFormats() const +{ + if (!m_updated) { + QScopedPointer caps( + new SymbianAudio::DevSoundCapabilities(*m_devsound, m_mode)); + + SymbianAudio::Utils::capabilitiesNativeToQt(*caps, + m_frequencies, m_channels, m_sampleSizes, + m_byteOrders, m_sampleTypes); + + m_codecs.append(QLatin1String("audio/pcm")); + + m_updated = true; + } +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiodeviceinfo_symbian_p.h b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.h new file mode 100644 index 0000000..89e539f --- /dev/null +++ b/src/multimedia/audio/qaudiodeviceinfo_symbian_p.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIODEVICEINFO_SYMBIAN_P_H +#define QAUDIODEVICEINFO_SYMBIAN_P_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QAudioDeviceInfoInternal + : public QAbstractAudioDeviceInfo +{ + Q_OBJECT + +public: + QAudioDeviceInfoInternal(QByteArray device, QAudio::Mode mode); + ~QAudioDeviceInfoInternal(); + + // QAbstractAudioDeviceInfo + QAudioFormat preferredFormat() const; + bool isFormatSupported(const QAudioFormat &format) const; + QAudioFormat nearestFormat(const QAudioFormat &format) const; + QString deviceName() const; + QStringList codecList(); + QList frequencyList(); + QList channelsList(); + QList sampleSizeList(); + QList byteOrderList(); + QList sampleTypeList(); + static QByteArray defaultInputDevice(); + static QByteArray defaultOutputDevice(); + static QList availableDevices(QAudio::Mode); + +private: + void getSupportedFormats() const; + +private: + QScopedPointer m_devsound; + + QString m_deviceName; + QAudio::Mode m_mode; + + // Mutable to allow lazy initialization when called from const-qualified + // public functions (isFormatSupported, nearestFormat) + mutable bool m_updated; + mutable QStringList m_codecs; + mutable QList m_frequencies; + mutable QList m_channels; + mutable QList m_sampleSizes; + mutable QList m_byteOrders; + mutable QList m_sampleTypes; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/audio/qaudioinput_symbian_p.cpp b/src/multimedia/audio/qaudioinput_symbian_p.cpp new file mode 100644 index 0000000..52daa88 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_symbian_p.cpp @@ -0,0 +1,594 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qaudioinput_symbian_p.h" + +QT_BEGIN_NAMESPACE + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const int PushInterval = 50; // ms + + +//----------------------------------------------------------------------------- +// Private class +//----------------------------------------------------------------------------- + +SymbianAudioInputPrivate::SymbianAudioInputPrivate( + QAudioInputPrivate *audioDevice) + : m_audioDevice(audioDevice) +{ + +} + +SymbianAudioInputPrivate::~SymbianAudioInputPrivate() +{ + +} + +qint64 SymbianAudioInputPrivate::readData(char *data, qint64 len) +{ + qint64 totalRead = 0; + + if (m_audioDevice->state() == QAudio::ActiveState || + m_audioDevice->state() == QAudio::IdleState) { + + while (totalRead < len) { + const qint64 read = m_audioDevice->read(data + totalRead, + len - totalRead); + if (read > 0) + totalRead += read; + else + break; + } + } + + return totalRead; +} + +qint64 SymbianAudioInputPrivate::writeData(const char *data, qint64 len) +{ + Q_UNUSED(data) + Q_UNUSED(len) + return 0; +} + +void SymbianAudioInputPrivate::dataReady() +{ + emit readyRead(); +} + + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, + const QAudioFormat &format) + : m_device(device) + , m_format(format) + , m_clientBufferSize(SymbianAudio::DefaultBufferSize) + , m_notifyInterval(SymbianAudio::DefaultNotifyInterval) + , m_notifyTimer(new QTimer(this)) + , m_error(QAudio::NoError) + , m_internalState(SymbianAudio::ClosedState) + , m_externalState(QAudio::StoppedState) + , m_pullMode(false) + , m_sink(0) + , m_pullTimer(new QTimer(this)) + , m_devSoundBuffer(0) + , m_devSoundBufferSize(0) + , m_totalBytesReady(0) + , m_devSoundBufferPos(0) + , m_totalSamplesRecorded(0) +{ + connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); + + SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC, + m_nativeFormat); + + m_pullTimer->setInterval(PushInterval); + connect(m_pullTimer.data(), SIGNAL(timeout()), this, SLOT(pullData())); +} + +QAudioInputPrivate::~QAudioInputPrivate() +{ + close(); +} + +QIODevice* QAudioInputPrivate::start(QIODevice *device) +{ + stop(); + + open(); + if (SymbianAudio::ClosedState != m_internalState) { + if (device) { + m_pullMode = true; + m_sink = device; + } else { + m_sink = new SymbianAudioInputPrivate(this); + m_sink->open(QIODevice::ReadOnly | QIODevice::Unbuffered); + } + + m_elapsed.restart(); + } + + return m_sink; +} + +void QAudioInputPrivate::stop() +{ + close(); +} + +void QAudioInputPrivate::reset() +{ + m_totalSamplesRecorded += getSamplesRecorded(); + m_devSound->Stop(); + startRecording(); +} + +void QAudioInputPrivate::suspend() +{ + if (SymbianAudio::ActiveState == m_internalState + || SymbianAudio::IdleState == m_internalState) { + m_notifyTimer->stop(); + m_pullTimer->stop(); + m_devSound->Pause(); + const qint64 samplesRecorded = getSamplesRecorded(); + m_totalSamplesRecorded += samplesRecorded; + + if (m_devSoundBuffer) { + m_devSoundBufferQ.append(m_devSoundBuffer); + m_devSoundBuffer = 0; + } + + setState(SymbianAudio::SuspendedState); + } +} + +void QAudioInputPrivate::resume() +{ + if (SymbianAudio::SuspendedState == m_internalState) + startDataTransfer(); +} + +int QAudioInputPrivate::bytesReady() const +{ + Q_ASSERT(m_devSoundBufferPos <= m_totalBytesReady); + return m_totalBytesReady - m_devSoundBufferPos; +} + +int QAudioInputPrivate::periodSize() const +{ + return bufferSize(); +} + +void QAudioInputPrivate::setBufferSize(int value) +{ + // Note that DevSound does not allow its client to specify the buffer size. + // This functionality is available via custom interfaces, but since these + // cannot be guaranteed to work across all DevSound implementations, we + // do not use them here. + // In order to comply with the expected bevahiour of QAudioInput, we store + // the value and return it from bufferSize(), but the underlying DevSound + // buffer size remains unchanged. + if (value > 0) + m_clientBufferSize = value; +} + +int QAudioInputPrivate::bufferSize() const +{ + return m_devSoundBufferSize ? m_devSoundBufferSize : m_clientBufferSize; +} + +void QAudioInputPrivate::setNotifyInterval(int ms) +{ + if (ms > 0) { + const int oldNotifyInterval = m_notifyInterval; + m_notifyInterval = ms; + if (m_notifyTimer->isActive() && ms != oldNotifyInterval) + m_notifyTimer->start(m_notifyInterval); + } +} + +int QAudioInputPrivate::notifyInterval() const +{ + return m_notifyInterval; +} + +qint64 QAudioInputPrivate::processedUSecs() const +{ + int samplesPlayed = 0; + if (m_devSound && SymbianAudio::SuspendedState != m_internalState) + samplesPlayed = getSamplesRecorded(); + + // Protect against division by zero + Q_ASSERT_X(m_format.frequency() > 0, Q_FUNC_INFO, "Invalid frequency"); + + const qint64 result = qint64(1000000) * + (samplesPlayed + m_totalSamplesRecorded) + / m_format.frequency(); + + return result; +} + +qint64 QAudioInputPrivate::elapsedUSecs() const +{ + const qint64 result = (QAudio::StoppedState == state()) ? + 0 : m_elapsed.elapsed() * 1000; + return result; +} + +QAudio::Error QAudioInputPrivate::error() const +{ + return m_error; +} + +QAudio::State QAudioInputPrivate::state() const +{ + return m_externalState; +} + +QAudioFormat QAudioInputPrivate::format() const +{ + return m_format; +} + +//----------------------------------------------------------------------------- +// MDevSoundObserver implementation +//----------------------------------------------------------------------------- + +void QAudioInputPrivate::InitializeComplete(TInt aError) +{ + Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, + Q_FUNC_INFO, "Invalid state"); + + if (KErrNone == aError) + startRecording(); +} + +void QAudioInputPrivate::ToneFinished(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound's tone playback functions, so should + // never receive this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioInputPrivate::BufferToBeFilled(CMMFBuffer *aBuffer) +{ + Q_UNUSED(aBuffer) + // This class doesn't use DevSound in play mode, so should never receive + // this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioInputPrivate::PlayError(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound in play mode, so should never receive + // this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioInputPrivate::BufferToBeEmptied(CMMFBuffer *aBuffer) +{ + // Following receipt of this callback, DevSound should not provide another + // buffer until we have returned the current one. + Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); + + CMMFDataBuffer *const buffer = static_cast(aBuffer); + + if (!m_devSoundBufferSize) + m_devSoundBufferSize = buffer->Data().MaxLength(); + + m_totalBytesReady += buffer->Data().Length(); + + if (SymbianAudio::SuspendedState == m_internalState) { + m_devSoundBufferQ.append(buffer); + } else { + // Will be returned to DevSound by bufferEmptied(). + m_devSoundBuffer = buffer; + m_devSoundBufferPos = 0; + + if (bytesReady() && !m_pullMode) + pushData(); + } +} + +void QAudioInputPrivate::RecordError(TInt aError) +{ + Q_UNUSED(aError) + setError(QAudio::IOError); +} + +void QAudioInputPrivate::ConvertError(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound's format conversion functions, so + // should never receive this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioInputPrivate::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) +{ + Q_UNUSED(aMessageType) + Q_UNUSED(aMsg) + // Ignore this callback. +} + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void QAudioInputPrivate::open() +{ + Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState, + Q_FUNC_INFO, "DevSound already opened"); + + QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) ) + + QScopedPointer caps( + new SymbianAudio::DevSoundCapabilities(*m_devSound, QAudio::AudioInput)); + + int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ? + KErrNone : KErrNotSupported; + + if (KErrNone == err) { + setState(SymbianAudio::InitializingState); + TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC, + EMMFStateRecording)); + } + + if (KErrNone != err) { + setError(QAudio::OpenError); + m_devSound.reset(); + } +} + +void QAudioInputPrivate::startRecording() +{ + const int samplesRecorded = m_devSound->SamplesRecorded(); + Q_ASSERT(samplesRecorded == 0); + + TRAPD(err, startDevSoundL()); + if (KErrNone == err) { + startDataTransfer(); + } else { + setError(QAudio::OpenError); + close(); + } +} + +void QAudioInputPrivate::startDevSoundL() +{ + TMMFCapabilities nativeFormat = m_devSound->Config(); + m_nativeFormat.iBufferSize = nativeFormat.iBufferSize; + m_devSound->SetConfigL(m_nativeFormat); + m_devSound->RecordInitL(); +} + +void QAudioInputPrivate::startDataTransfer() +{ + m_notifyTimer->start(m_notifyInterval); + + if (m_pullMode) + m_pullTimer->start(); + + if (bytesReady()) { + setState(SymbianAudio::ActiveState); + if (!m_pullMode) + pushData(); + } else { + if (SymbianAudio::SuspendedState == m_internalState) + setState(SymbianAudio::ActiveState); + else + setState(SymbianAudio::IdleState); + } +} + +CMMFDataBuffer* QAudioInputPrivate::currentBuffer() const +{ + CMMFDataBuffer *result = m_devSoundBuffer; + if (!result && !m_devSoundBufferQ.empty()) + result = m_devSoundBufferQ.front(); + return result; +} + +void QAudioInputPrivate::pushData() +{ + Q_ASSERT_X(bytesReady(), Q_FUNC_INFO, "No data available"); + Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, "pushData called when in pull mode"); + qobject_cast(m_sink)->dataReady(); +} + +qint64 QAudioInputPrivate::read(char *data, qint64 len) +{ + // SymbianAudioInputPrivate is ready to read data + + Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, + "read called when in pull mode"); + + qint64 bytesRead = 0; + + CMMFDataBuffer *buffer = 0; + while ((buffer = currentBuffer()) && (bytesRead < len)) { + if (SymbianAudio::IdleState == m_internalState) + setState(SymbianAudio::ActiveState); + + TDesC8 &inputBuffer = buffer->Data(); + + const qint64 inputBytes = bytesReady(); + const qint64 outputBytes = len - bytesRead; + const qint64 copyBytes = outputBytes < inputBytes ? + outputBytes : inputBytes; + + memcpy(data, inputBuffer.Ptr() + m_devSoundBufferPos, copyBytes); + + m_devSoundBufferPos += copyBytes; + data += copyBytes; + bytesRead += copyBytes; + + if (!bytesReady()) + bufferEmptied(); + } + + return bytesRead; +} + +void QAudioInputPrivate::pullData() +{ + Q_ASSERT_X(m_pullMode, Q_FUNC_INFO, + "pullData called when in push mode"); + + CMMFDataBuffer *buffer = 0; + while (buffer = currentBuffer()) { + if (SymbianAudio::IdleState == m_internalState) + setState(SymbianAudio::ActiveState); + + TDesC8 &inputBuffer = buffer->Data(); + + const qint64 inputBytes = bytesReady(); + const qint64 bytesPushed = m_sink->write( + (char*)inputBuffer.Ptr() + m_devSoundBufferPos, inputBytes); + + m_devSoundBufferPos += bytesPushed; + + if (!bytesReady()) + bufferEmptied(); + + if (!bytesPushed) + break; + } +} + +void QAudioInputPrivate::bufferEmptied() +{ + m_devSoundBufferPos = 0; + + if (m_devSoundBuffer) { + m_totalBytesReady -= m_devSoundBuffer->Data().Length(); + m_devSoundBuffer = 0; + m_devSound->RecordData(); + } else { + Q_ASSERT(!m_devSoundBufferQ.empty()); + m_totalBytesReady -= m_devSoundBufferQ.front()->Data().Length(); + m_devSoundBufferQ.erase(m_devSoundBufferQ.begin()); + + // If the queue has been emptied, resume transfer from the hardware + if (m_devSoundBufferQ.empty()) + m_devSound->RecordInitL(); + } + + Q_ASSERT(m_totalBytesReady >= 0); +} + +void QAudioInputPrivate::close() +{ + m_notifyTimer->stop(); + m_pullTimer->stop(); + + m_error = QAudio::NoError; + + if (m_devSound) + m_devSound->Stop(); + m_devSound.reset(); + m_devSoundBuffer = 0; + m_devSoundBufferSize = 0; + m_totalBytesReady = 0; + + if (!m_pullMode) // m_sink is owned + delete m_sink; + m_pullMode = false; + m_sink = 0; + + m_devSoundBufferQ.clear(); + m_devSoundBufferPos = 0; + m_totalSamplesRecorded = 0; + + setState(SymbianAudio::ClosedState); +} + +qint64 QAudioInputPrivate::getSamplesRecorded() const +{ + qint64 result = 0; + if (m_devSound) + result = qint64(m_devSound->SamplesRecorded()); + return result; +} + +void QAudioInputPrivate::setError(QAudio::Error error) +{ + m_error = error; + + // Although no state transition actually occurs here, a stateChanged event + // must be emitted to inform the client that the call to start() was + // unsuccessful. + if (QAudio::OpenError == error) + emit stateChanged(QAudio::StoppedState); + + // Close the DevSound instance. This causes a transition to StoppedState. + // This must be done asynchronously in case the current function was called + // from a DevSound event handler, in which case deleting the DevSound + // instance may cause an exception. + QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); +} + +void QAudioInputPrivate::setState(SymbianAudio::State newInternalState) +{ + const QAudio::State oldExternalState = m_externalState; + m_internalState = newInternalState; + m_externalState = SymbianAudio::Utils::stateNativeToQt( + m_internalState, initializingState()); + + if (m_externalState != oldExternalState) + emit stateChanged(m_externalState); +} + +QAudio::State QAudioInputPrivate::initializingState() const +{ + return QAudio::IdleState; +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudioinput_symbian_p.h b/src/multimedia/audio/qaudioinput_symbian_p.h new file mode 100644 index 0000000..ca3ccf7 --- /dev/null +++ b/src/multimedia/audio/qaudioinput_symbian_p.h @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIOINPUT_SYMBIAN_P_H +#define QAUDIOINPUT_SYMBIAN_P_H + +#include +#include +#include +#include +#include "qaudio_symbian_p.h" + +QT_BEGIN_NAMESPACE + +class QAudioInputPrivate; + +class SymbianAudioInputPrivate : public QIODevice +{ + friend class QAudioInputPrivate; + Q_OBJECT +public: + SymbianAudioInputPrivate(QAudioInputPrivate *audio); + ~SymbianAudioInputPrivate(); + + qint64 readData(char *data, qint64 len); + qint64 writeData(const char *data, qint64 len); + + void dataReady(); + +private: + QAudioInputPrivate *const m_audioDevice; +}; + +class QAudioInputPrivate + : public QAbstractAudioInput + , public MDevSoundObserver +{ + friend class SymbianAudioInputPrivate; + Q_OBJECT +public: + QAudioInputPrivate(const QByteArray &device, + const QAudioFormat &audioFormat); + ~QAudioInputPrivate(); + + // QAbstractAudioInput + QIODevice* start(QIODevice *device = 0); + void stop(); + void reset(); + void suspend(); + void resume(); + int bytesReady() const; + int periodSize() const; + void setBufferSize(int value); + int bufferSize() const; + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + QAudio::Error error() const; + QAudio::State state() const; + QAudioFormat format() const; + + // MDevSoundObserver + void InitializeComplete(TInt aError); + void ToneFinished(TInt aError); + void BufferToBeFilled(CMMFBuffer *aBuffer); + void PlayError(TInt aError); + void BufferToBeEmptied(CMMFBuffer *aBuffer); + void RecordError(TInt aError); + void ConvertError(TInt aError); + void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); + +private slots: + void pullData(); + +private: + void open(); + void startRecording(); + void startDevSoundL(); + void startDataTransfer(); + CMMFDataBuffer* currentBuffer() const; + void pushData(); + qint64 read(char *data, qint64 len); + void bufferEmptied(); + Q_INVOKABLE void close(); + + qint64 getSamplesRecorded() const; + + void setError(QAudio::Error error); + void setState(SymbianAudio::State state); + + QAudio::State initializingState() const; + +private: + const QByteArray m_device; + const QAudioFormat m_format; + + int m_clientBufferSize; + int m_notifyInterval; + QScopedPointer m_notifyTimer; + QTime m_elapsed; + QAudio::Error m_error; + + SymbianAudio::State m_internalState; + QAudio::State m_externalState; + + bool m_pullMode; + QIODevice *m_sink; + + QScopedPointer m_pullTimer; + + QScopedPointer m_devSound; + TUint32 m_nativeFourCC; + TMMFCapabilities m_nativeFormat; + + // Latest buffer provided by DevSound, to be empied of data. + CMMFDataBuffer *m_devSoundBuffer; + + int m_devSoundBufferSize; + + // Total amount of data in buffers provided by DevSound + int m_totalBytesReady; + + // Queue of buffers returned after call to CMMFDevSound::Pause(). + QList m_devSoundBufferQ; + + // Current read position within m_devSoundBuffer + qint64 m_devSoundBufferPos; + + // Samples recorded up to the last call to suspend(). It is necessary + // to cache this because suspend() is implemented using + // CMMFDevSound::Stop(), which resets DevSound's SamplesRecorded() counter. + quint32 m_totalSamplesRecorded; + +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/multimedia/audio/qaudiooutput_symbian_p.cpp b/src/multimedia/audio/qaudiooutput_symbian_p.cpp new file mode 100644 index 0000000..945a08d --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_symbian_p.cpp @@ -0,0 +1,696 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qaudiooutput_symbian_p.h" + +QT_BEGIN_NAMESPACE + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- + +const int UnderflowTimerInterval = 50; // ms + + +//----------------------------------------------------------------------------- +// Private class +//----------------------------------------------------------------------------- + +SymbianAudioOutputPrivate::SymbianAudioOutputPrivate( + QAudioOutputPrivate *audioDevice) + : m_audioDevice(audioDevice) +{ + +} + +SymbianAudioOutputPrivate::~SymbianAudioOutputPrivate() +{ + +} + +qint64 SymbianAudioOutputPrivate::readData(char *data, qint64 len) +{ + Q_UNUSED(data) + Q_UNUSED(len) + return 0; +} + +qint64 SymbianAudioOutputPrivate::writeData(const char *data, qint64 len) +{ + qint64 totalWritten = 0; + + if (m_audioDevice->state() == QAudio::ActiveState || + m_audioDevice->state() == QAudio::IdleState) { + + while (totalWritten < len) { + const qint64 written = m_audioDevice->pushData(data + totalWritten, + len - totalWritten); + if (written > 0) + totalWritten += written; + else + break; + } + } + + return totalWritten; +} + + +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, + const QAudioFormat &format) + : m_device(device) + , m_format(format) + , m_clientBufferSize(SymbianAudio::DefaultBufferSize) + , m_notifyInterval(SymbianAudio::DefaultNotifyInterval) + , m_notifyTimer(new QTimer(this)) + , m_error(QAudio::NoError) + , m_internalState(SymbianAudio::ClosedState) + , m_externalState(QAudio::StoppedState) + , m_pullMode(false) + , m_source(0) + , m_devSoundBuffer(0) + , m_devSoundBufferSize(0) + , m_bytesWritten(0) + , m_pushDataReady(false) + , m_bytesPadding(0) + , m_underflow(false) + , m_lastBuffer(false) + , m_underflowTimer(new QTimer(this)) + , m_samplesPlayed(0) + , m_totalSamplesPlayed(0) +{ + connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); + + SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC, + m_nativeFormat); + + m_underflowTimer->setInterval(UnderflowTimerInterval); + connect(m_underflowTimer.data(), SIGNAL(timeout()), this, + SLOT(underflowTimerExpired())); +} + +QAudioOutputPrivate::~QAudioOutputPrivate() +{ + close(); +} + +QIODevice* QAudioOutputPrivate::start(QIODevice *device) +{ + stop(); + + // We have to set these before the call to open() because of the + // logic in initializingState() + if (device) { + m_pullMode = true; + m_source = device; + } + + open(); + + if (SymbianAudio::ClosedState != m_internalState) { + if (device) { + connect(m_source, SIGNAL(readyRead()), this, SLOT(dataReady())); + } else { + m_source = new SymbianAudioOutputPrivate(this); + m_source->open(QIODevice::WriteOnly | QIODevice::Unbuffered); + } + + m_elapsed.restart(); + } + + return m_source; +} + +void QAudioOutputPrivate::stop() +{ + close(); +} + +void QAudioOutputPrivate::reset() +{ + m_totalSamplesPlayed += getSamplesPlayed(); + m_devSound->Stop(); + m_bytesPadding = 0; + startPlayback(); +} + +void QAudioOutputPrivate::suspend() +{ + if (SymbianAudio::ActiveState == m_internalState + || SymbianAudio::IdleState == m_internalState) { + m_notifyTimer->stop(); + m_underflowTimer->stop(); + + const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples( + m_format, m_bytesWritten); + m_bytesWritten = 0; + + const qint64 samplesPlayed = getSamplesPlayed(); + + // CMMFDevSound::Pause() is not guaranteed to work correctly in all + // implementations, for play-mode DevSound sessions. We therefore + // have to implement suspend() by calling CMMFDevSound::Stop(). + // Because this causes buffered data to be dropped, we replace the + // lost data with silence following a call to resume(), in order to + // ensure that processedUSecs() returns the correct value. + m_devSound->Stop(); + m_totalSamplesPlayed += samplesPlayed; + + // Calculate the amount of data dropped + const qint64 paddingSamples = samplesWritten - samplesPlayed; + m_bytesPadding = SymbianAudio::Utils::samplesToBytes(m_format, + paddingSamples); + + setState(SymbianAudio::SuspendedState); + } +} + +void QAudioOutputPrivate::resume() +{ + if (SymbianAudio::SuspendedState == m_internalState) + startPlayback(); +} + +int QAudioOutputPrivate::bytesFree() const +{ + int result = 0; + if (m_devSoundBuffer) { + const TDes8 &outputBuffer = m_devSoundBuffer->Data(); + result = outputBuffer.MaxLength() - outputBuffer.Length(); + } + return result; +} + +int QAudioOutputPrivate::periodSize() const +{ + return bufferSize(); +} + +void QAudioOutputPrivate::setBufferSize(int value) +{ + // Note that DevSound does not allow its client to specify the buffer size. + // This functionality is available via custom interfaces, but since these + // cannot be guaranteed to work across all DevSound implementations, we + // do not use them here. + // In order to comply with the expected bevahiour of QAudioOutput, we store + // the value and return it from bufferSize(), but the underlying DevSound + // buffer size remains unchanged. + if (value > 0) + m_clientBufferSize = value; +} + +int QAudioOutputPrivate::bufferSize() const +{ + return m_devSoundBufferSize ? m_devSoundBufferSize : m_clientBufferSize; +} + +void QAudioOutputPrivate::setNotifyInterval(int ms) +{ + if (ms > 0) { + const int oldNotifyInterval = m_notifyInterval; + m_notifyInterval = ms; + if (m_notifyTimer->isActive() && ms != oldNotifyInterval) + m_notifyTimer->start(m_notifyInterval); + } +} + +int QAudioOutputPrivate::notifyInterval() const +{ + return m_notifyInterval; +} + +qint64 QAudioOutputPrivate::processedUSecs() const +{ + int samplesPlayed = 0; + if (m_devSound && SymbianAudio::SuspendedState != m_internalState) + samplesPlayed = getSamplesPlayed(); + + // Protect against division by zero + Q_ASSERT_X(m_format.frequency() > 0, Q_FUNC_INFO, "Invalid frequency"); + + const qint64 result = qint64(1000000) * + (samplesPlayed + m_totalSamplesPlayed) + / m_format.frequency(); + + return result; +} + +qint64 QAudioOutputPrivate::elapsedUSecs() const +{ + const qint64 result = (QAudio::StoppedState == state()) ? + 0 : m_elapsed.elapsed() * 1000; + return result; +} + +QAudio::Error QAudioOutputPrivate::error() const +{ + return m_error; +} + +QAudio::State QAudioOutputPrivate::state() const +{ + return m_externalState; +} + +QAudioFormat QAudioOutputPrivate::format() const +{ + return m_format; +} + +//----------------------------------------------------------------------------- +// MDevSoundObserver implementation +//----------------------------------------------------------------------------- + +void QAudioOutputPrivate::InitializeComplete(TInt aError) +{ + Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, + Q_FUNC_INFO, "Invalid state"); + + if (KErrNone == aError) + startPlayback(); +} + +void QAudioOutputPrivate::ToneFinished(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound's tone playback functions, so should + // never receive this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioOutputPrivate::BufferToBeFilled(CMMFBuffer *aBuffer) +{ + // Following receipt of this callback, DevSound should not provide another + // buffer until we have returned the current one. + Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); + + // Will be returned to DevSound by bufferFilled(). + m_devSoundBuffer = static_cast(aBuffer); + + if (!m_devSoundBufferSize) + m_devSoundBufferSize = m_devSoundBuffer->Data().MaxLength(); + + writePaddingData(); + + if (m_pullMode && isDataReady() && !m_bytesPadding) + pullData(); +} + +void QAudioOutputPrivate::PlayError(TInt aError) +{ + switch (aError) { + case KErrUnderflow: + m_underflow = true; + if (m_pullMode && !m_lastBuffer) + setError(QAudio::UnderrunError); + else + setState(SymbianAudio::IdleState); + break; + default: + setError(QAudio::IOError); + break; + } +} + +void QAudioOutputPrivate::BufferToBeEmptied(CMMFBuffer *aBuffer) +{ + Q_UNUSED(aBuffer) + // This class doesn't use DevSound in record mode, so should never receive + // this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioOutputPrivate::RecordError(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound in record mode, so should never receive + // this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioOutputPrivate::ConvertError(TInt aError) +{ + Q_UNUSED(aError) + // This class doesn't use DevSound's format conversion functions, so + // should never receive this callback. + Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); +} + +void QAudioOutputPrivate::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) +{ + Q_UNUSED(aMessageType) + Q_UNUSED(aMsg) + // Ignore this callback. +} + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +void QAudioOutputPrivate::dataReady() +{ + // Client-provided QIODevice has data ready to read. + + Q_ASSERT_X(m_source->bytesAvailable(), Q_FUNC_INFO, + "readyRead signal received, but no data available"); + + if (!m_bytesPadding) + pullData(); +} + +void QAudioOutputPrivate::underflowTimerExpired() +{ + const TInt samplesPlayed = getSamplesPlayed(); + if (m_samplesPlayed && (samplesPlayed == m_samplesPlayed)) { + setError(QAudio::UnderrunError); + } else { + m_samplesPlayed = samplesPlayed; + m_underflowTimer->start(); + } +} + +void QAudioOutputPrivate::open() +{ + Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState, + Q_FUNC_INFO, "DevSound already opened"); + + QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) ) + + QScopedPointer caps( + new SymbianAudio::DevSoundCapabilities(*m_devSound, + QAudio::AudioOutput)); + + int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ? + KErrNone : KErrNotSupported; + + if (KErrNone == err) { + setState(SymbianAudio::InitializingState); + TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC, + EMMFStatePlaying)); + } + + if (KErrNone != err) { + setError(QAudio::OpenError); + m_devSound.reset(); + } +} + +void QAudioOutputPrivate::startPlayback() +{ + TRAPD(err, startDevSoundL()); + if (KErrNone == err) { + if (isDataReady()) + setState(SymbianAudio::ActiveState); + else + setState(SymbianAudio::IdleState); + + m_notifyTimer->start(m_notifyInterval); + m_underflow = false; + + Q_ASSERT(m_devSound->SamplesPlayed() == 0); + + writePaddingData(); + + if (m_pullMode && m_source->bytesAvailable() && !m_bytesPadding) + dataReady(); + } else { + setError(QAudio::OpenError); + close(); + } +} + +void QAudioOutputPrivate::startDevSoundL() +{ + TMMFCapabilities nativeFormat = m_devSound->Config(); + m_nativeFormat.iBufferSize = nativeFormat.iBufferSize; + m_devSound->SetConfigL(m_nativeFormat); + m_devSound->PlayInitL(); +} + +void QAudioOutputPrivate::writePaddingData() +{ + // See comments in suspend() + + while (m_devSoundBuffer && m_bytesPadding) { + if (SymbianAudio::IdleState == m_internalState) + setState(SymbianAudio::ActiveState); + + TDes8 &outputBuffer = m_devSoundBuffer->Data(); + const qint64 outputBytes = bytesFree(); + const qint64 paddingBytes = outputBytes < m_bytesPadding ? + outputBytes : m_bytesPadding; + unsigned char *ptr = const_cast(outputBuffer.Ptr()); + Mem::FillZ(ptr, paddingBytes); + outputBuffer.SetLength(outputBuffer.Length() + paddingBytes); + m_bytesPadding -= paddingBytes; + + if (m_pullMode && m_source->atEnd()) + lastBufferFilled(); + if (paddingBytes == outputBytes) + bufferFilled(); + } +} + +qint64 QAudioOutputPrivate::pushData(const char *data, qint64 len) +{ + // Data has been written to SymbianAudioOutputPrivate + + Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, + "pushData called when in pull mode"); + + const unsigned char *const inputPtr = + reinterpret_cast(data); + qint64 bytesWritten = 0; + + if (SymbianAudio::IdleState == m_internalState) + setState(SymbianAudio::ActiveState); + + while (m_devSoundBuffer && (bytesWritten < len)) { + // writePaddingData() is called from BufferToBeFilled(), so we should + // never have any padding data left at this point. + Q_ASSERT_X(0 == m_bytesPadding, Q_FUNC_INFO, + "Padding bytes remaining in pushData"); + + TDes8 &outputBuffer = m_devSoundBuffer->Data(); + + const qint64 outputBytes = bytesFree(); + const qint64 inputBytes = len - bytesWritten; + const qint64 copyBytes = outputBytes < inputBytes ? + outputBytes : inputBytes; + + outputBuffer.Append(inputPtr + bytesWritten, copyBytes); + bytesWritten += copyBytes; + + bufferFilled(); + } + + m_pushDataReady = (bytesWritten < len); + + // If DevSound is still initializing (m_internalState == InitializingState), + // we cannot transition m_internalState to ActiveState, but we must emit + // an (external) state change from IdleState to ActiveState. The following + // call triggers this signal. + setState(m_internalState); + + return bytesWritten; +} + +void QAudioOutputPrivate::pullData() +{ + Q_ASSERT_X(m_pullMode, Q_FUNC_INFO, + "pullData called when in push mode"); + + if (m_bytesPadding) + m_bytesPadding = 1; + + // writePaddingData() is called by BufferToBeFilled() before pullData(), + // so we should never have any padding data left at this point. + Q_ASSERT_X(0 == m_bytesPadding, Q_FUNC_INFO, + "Padding bytes remaining in pullData"); + + qint64 inputBytes = m_source->bytesAvailable(); + while (m_devSoundBuffer && inputBytes) { + if (SymbianAudio::IdleState == m_internalState) + setState(SymbianAudio::ActiveState); + + TDes8 &outputBuffer = m_devSoundBuffer->Data(); + + const qint64 outputBytes = bytesFree(); + const qint64 copyBytes = outputBytes < inputBytes ? + outputBytes : inputBytes; + + char *outputPtr = (char*)(outputBuffer.Ptr() + outputBuffer.Length()); + const qint64 bytesCopied = m_source->read(outputPtr, copyBytes); + Q_ASSERT(bytesCopied == copyBytes); + outputBuffer.SetLength(outputBuffer.Length() + bytesCopied); + inputBytes -= bytesCopied; + + if (m_source->atEnd()) + lastBufferFilled(); + else if (copyBytes == outputBytes) + bufferFilled(); + } +} + +void QAudioOutputPrivate::bufferFilled() +{ + Q_ASSERT_X(m_devSoundBuffer, Q_FUNC_INFO, "No buffer to return"); + + const TDes8 &outputBuffer = m_devSoundBuffer->Data(); + m_bytesWritten += outputBuffer.Length(); + + m_devSoundBuffer = 0; + + m_samplesPlayed = getSamplesPlayed(); + m_underflowTimer->start(); + + if (QAudio::UnderrunError == m_error) + m_error = QAudio::NoError; + + m_devSound->PlayData(); +} + +void QAudioOutputPrivate::lastBufferFilled() +{ + Q_ASSERT_X(m_devSoundBuffer, Q_FUNC_INFO, "No buffer to fill"); + Q_ASSERT_X(!m_lastBuffer, Q_FUNC_INFO, "Last buffer already sent"); + m_lastBuffer = true; + m_devSoundBuffer->SetLastBuffer(ETrue); + bufferFilled(); +} + +void QAudioOutputPrivate::close() +{ + m_notifyTimer->stop(); + m_underflowTimer->stop(); + + m_error = QAudio::NoError; + + if (m_devSound) + m_devSound->Stop(); + m_devSound.reset(); + m_devSoundBuffer = 0; + m_devSoundBufferSize = 0; + + if (!m_pullMode) // m_source is owned + delete m_source; + m_pullMode = false; + m_source = 0; + + m_bytesWritten = 0; + m_pushDataReady = false; + m_bytesPadding = 0; + m_underflow = false; + m_lastBuffer = false; + m_samplesPlayed = 0; + m_totalSamplesPlayed = 0; + + setState(SymbianAudio::ClosedState); +} + +qint64 QAudioOutputPrivate::getSamplesPlayed() const +{ + qint64 result = 0; + if (m_devSound) { + const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples( + m_format, m_bytesWritten); + + if (m_underflow) { + result = samplesWritten; + } else { + // This is necessary because some DevSound implementations report + // that they have played more data than has actually been provided to them + // by the client. + const qint64 devSoundSamplesPlayed(m_devSound->SamplesPlayed()); + result = qMin(devSoundSamplesPlayed, samplesWritten); + } + } + return result; +} + +void QAudioOutputPrivate::setError(QAudio::Error error) +{ + m_error = error; + + // Although no state transition actually occurs here, a stateChanged event + // must be emitted to inform the client that the call to start() was + // unsuccessful. + if (QAudio::OpenError == error) + emit stateChanged(QAudio::StoppedState); + + if (QAudio::UnderrunError == error) + setState(SymbianAudio::IdleState); + else + // Close the DevSound instance. This causes a transition to + // StoppedState. This must be done asynchronously in case the + // current function was called from a DevSound event handler, in which + // case deleting the DevSound instance may cause an exception. + QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); +} + +void QAudioOutputPrivate::setState(SymbianAudio::State newInternalState) +{ + const QAudio::State oldExternalState = m_externalState; + m_internalState = newInternalState; + m_externalState = SymbianAudio::Utils::stateNativeToQt( + m_internalState, initializingState()); + + if (m_externalState != oldExternalState) + emit stateChanged(m_externalState); +} + +bool QAudioOutputPrivate::isDataReady() const +{ + return (m_source && m_source->bytesAvailable()) + || m_bytesPadding + || m_pushDataReady; +} + +QAudio::State QAudioOutputPrivate::initializingState() const +{ + return isDataReady() ? QAudio::ActiveState : QAudio::IdleState; +} + +QT_END_NAMESPACE diff --git a/src/multimedia/audio/qaudiooutput_symbian_p.h b/src/multimedia/audio/qaudiooutput_symbian_p.h new file mode 100644 index 0000000..00ccb24 --- /dev/null +++ b/src/multimedia/audio/qaudiooutput_symbian_p.h @@ -0,0 +1,210 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef QAUDIOOUTPUT_SYMBIAN_P_H +#define QAUDIOOUTPUT_SYMBIAN_P_H + +#include +#include +#include +#include +#include "qaudio_symbian_p.h" + +QT_BEGIN_NAMESPACE + +class QAudioOutputPrivate; + +class SymbianAudioOutputPrivate : public QIODevice +{ + friend class QAudioOutputPrivate; + Q_OBJECT +public: + SymbianAudioOutputPrivate(QAudioOutputPrivate *audio); + ~SymbianAudioOutputPrivate(); + + qint64 readData(char *data, qint64 len); + qint64 writeData(const char *data, qint64 len); + +private: + QAudioOutputPrivate *const m_audioDevice; +}; + +class QAudioOutputPrivate + : public QAbstractAudioOutput + , public MDevSoundObserver +{ + friend class SymbianAudioOutputPrivate; + Q_OBJECT +public: + QAudioOutputPrivate(const QByteArray &device, + const QAudioFormat &audioFormat); + ~QAudioOutputPrivate(); + + // QAbstractAudioOutput + QIODevice* start(QIODevice *device = 0); + void stop(); + void reset(); + void suspend(); + void resume(); + int bytesFree() const; + int periodSize() const; + void setBufferSize(int value); + int bufferSize() const; + void setNotifyInterval(int milliSeconds); + int notifyInterval() const; + qint64 processedUSecs() const; + qint64 elapsedUSecs() const; + QAudio::Error error() const; + QAudio::State state() const; + QAudioFormat format() const; + + // MDevSoundObserver + void InitializeComplete(TInt aError); + void ToneFinished(TInt aError); + void BufferToBeFilled(CMMFBuffer *aBuffer); + void PlayError(TInt aError); + void BufferToBeEmptied(CMMFBuffer *aBuffer); + void RecordError(TInt aError); + void ConvertError(TInt aError); + void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); + +private slots: + void dataReady(); + void underflowTimerExpired(); + +private: + void open(); + void startPlayback(); + void startDevSoundL(); + void writePaddingData(); + qint64 pushData(const char *data, qint64 len); + void pullData(); + void bufferFilled(); + void lastBufferFilled(); + Q_INVOKABLE void close(); + + qint64 getSamplesPlayed() const; + + void setError(QAudio::Error error); + void setState(SymbianAudio::State state); + + bool isDataReady() const; + QAudio::State initializingState() const; + +private: + const QByteArray m_device; + const QAudioFormat m_format; + + int m_clientBufferSize; + int m_notifyInterval; + QScopedPointer m_notifyTimer; + QTime m_elapsed; + QAudio::Error m_error; + + SymbianAudio::State m_internalState; + QAudio::State m_externalState; + + bool m_pullMode; + QIODevice *m_source; + + QScopedPointer m_devSound; + TUint32 m_nativeFourCC; + TMMFCapabilities m_nativeFormat; + + // Buffer provided by DevSound, to be filled with data. + CMMFDataBuffer *m_devSoundBuffer; + + int m_devSoundBufferSize; + + // Number of bytes transferred from QIODevice to QAudioOutput. It is + // necessary to count this because data is dropped when suspend() is + // called. The difference between the position reported by DevSound and + // this value allows us to calculate m_bytesPadding; + quint32 m_bytesWritten; + + // True if client has provided data while the audio subsystem was not + // ready to consume it. + bool m_pushDataReady; + + // Number of zero bytes which will be written when client calls resume(). + quint32 m_bytesPadding; + + // True if PlayError(KErrUnderflow) has been called. + bool m_underflow; + + // True if a buffer marked with the "last buffer" flag has been provided + // to DevSound. + bool m_lastBuffer; + + // Some DevSound implementations ignore all underflow errors raised by the + // audio driver, unless the last buffer flag has been set by the client. + // In push-mode playback, this flag will never be set, so the underflow + // error will never be reported. In order to work around this, a timer + // is used, which gets reset every time the client provides more data. If + // the timer expires, an underflow error is raised by this object. + QScopedPointer m_underflowTimer; + + // Result of previous call to CMMFDevSound::SamplesPlayed(). This value is + // used to determine whether, when m_underflowTimer expires, an + // underflow error has actually occurred. + quint32 m_samplesPlayed; + + // Samples played up to the last call to suspend(). It is necessary + // to cache this because suspend() is implemented using + // CMMFDevSound::Stop(), which resets DevSound's SamplesPlayed() counter. + quint32 m_totalSamplesPlayed; + +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/audio/audio.pro b/src/plugins/audio/audio.pro index 5f75a8d..b7a775b 100644 --- a/src/plugins/audio/audio.pro +++ b/src/plugins/audio/audio.pro @@ -1,9 +1,3 @@ TEMPLATE = subdirs SUBDIRS = -contains(QT_CONFIG, audio-backend) { - symbian { - SUBDIRS += symbian - } -} - diff --git a/src/plugins/audio/symbian/main.cpp b/src/plugins/audio/symbian/main.cpp deleted file mode 100644 index 536a8ec..0000000 --- a/src/plugins/audio/symbian/main.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include -#include -#include -#include - -#include "symbianaudiodeviceinfo.h" -#include "symbianaudioinput.h" -#include "symbianaudiooutput.h" - -QT_BEGIN_NAMESPACE - -class SymbianAudioPlugin : public QAudioEnginePlugin -{ -public: - SymbianAudioPlugin(QObject *parent = 0); - ~SymbianAudioPlugin(); - - QStringList keys() const; - - QList availableDevices(QAudio::Mode) const; - QAbstractAudioInput* createInput(const QByteArray& device, - const QAudioFormat& format = QAudioFormat()); - QAbstractAudioOutput* createOutput(const QByteArray& device, - const QAudioFormat& format = QAudioFormat()); - QAbstractAudioDeviceInfo* createDeviceInfo(const QByteArray& device, - QAudio::Mode mode); -}; - -SymbianAudioPlugin::SymbianAudioPlugin(QObject *parent) - : QAudioEnginePlugin(parent) -{ - -} - -SymbianAudioPlugin::~SymbianAudioPlugin() -{ - -} - -QStringList SymbianAudioPlugin::keys() const -{ - QStringList keys(QLatin1String("default")); - keys << QLatin1String("default"); - return keys; -} - -QList SymbianAudioPlugin::availableDevices(QAudio::Mode mode) const -{ - Q_UNUSED(mode) - QList devices; - devices.append("default"); - return devices; -} - -QAbstractAudioInput* SymbianAudioPlugin::createInput( - const QByteArray &device, const QAudioFormat &format) -{ - return new SymbianAudioInput(device, format); -} - -QAbstractAudioOutput* SymbianAudioPlugin::createOutput( - const QByteArray &device, const QAudioFormat &format) -{ - return new SymbianAudioOutput(device, format); -} - -QAbstractAudioDeviceInfo* SymbianAudioPlugin::createDeviceInfo( - const QByteArray& device, QAudio::Mode mode) -{ - return new SymbianAudioDeviceInfo(device, mode); -} - -Q_EXPORT_STATIC_PLUGIN(SymbianAudioPlugin) -Q_EXPORT_PLUGIN2(qaudio, SymbianAudioPlugin) - -QT_END_NAMESPACE - diff --git a/src/plugins/audio/symbian/symbian.pro b/src/plugins/audio/symbian/symbian.pro deleted file mode 100644 index 7355daa..0000000 --- a/src/plugins/audio/symbian/symbian.pro +++ /dev/null @@ -1,31 +0,0 @@ -QT += multimedia -TARGET = qaudio - -# Paths to DevSound headers -INCLUDEPATH += /epoc32/include/mmf/common -INCLUDEPATH += /epoc32/include/mmf/server - -HEADERS += \ - symbianaudio.h \ - symbianaudiodeviceinfo.h \ - symbianaudioinput.h \ - symbianaudiooutput.h \ - symbianaudioutils.h - -SOURCES += \ - main.cpp \ - symbianaudiodeviceinfo.cpp \ - symbianaudioinput.cpp \ - symbianaudiooutput.cpp \ - symbianaudioutils.cpp - -LIBS += -lmmfdevsound - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/audio -target.path = $$[QT_INSTALL_PLUGINS]/audio -INSTALLS += target - -include(../../qpluginbase.pri) - -TARGET.UID3 = 0x2001E630 - diff --git a/src/plugins/audio/symbian/symbianaudio.h b/src/plugins/audio/symbian/symbianaudio.h deleted file mode 100644 index 3fc0419..0000000 --- a/src/plugins/audio/symbian/symbianaudio.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SYMBIANAUDIO_H -#define SYMBIANAUDIO_H - -#include - -QT_BEGIN_NAMESPACE - -namespace SymbianAudio { - -/** - * Default values used by audio input and output classes, when underlying - * DevSound instance has not yet been created. - */ - -const int DefaultBufferSize = 4096; // bytes -const int DefaultNotifyInterval = 1000; // ms - -/** - * Enumeration used to track state of internal DevSound instances. - * Values are translated to the corresponding QAudio::State values by - * SymbianAudio::Utils::stateNativeToQt. - */ -enum State { - ClosedState - , InitializingState - , ActiveState - , IdleState - , SuspendedState -}; - -} // namespace SymbianAudio - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/audio/symbian/symbianaudiodeviceinfo.cpp b/src/plugins/audio/symbian/symbianaudiodeviceinfo.cpp deleted file mode 100644 index 9701dad..0000000 --- a/src/plugins/audio/symbian/symbianaudiodeviceinfo.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "symbianaudiodeviceinfo.h" -#include "symbianaudioutils.h" - -QT_BEGIN_NAMESPACE - -SymbianAudioDeviceInfo::SymbianAudioDeviceInfo(QByteArray device, - QAudio::Mode mode) - : m_deviceName(device) - , m_mode(mode) - , m_updated(false) -{ - QT_TRAP_THROWING(m_devsound.reset(CMMFDevSound::NewL())); -} - -SymbianAudioDeviceInfo::~SymbianAudioDeviceInfo() -{ - -} - -QAudioFormat SymbianAudioDeviceInfo::preferredFormat() const -{ - QAudioFormat format; - switch (m_mode) { - case QAudio::AudioOutput: - format.setFrequency(44100); - format.setChannels(2); - format.setSampleSize(16); - format.setByteOrder(QAudioFormat::LittleEndian); - format.setSampleType(QAudioFormat::SignedInt); - format.setCodec(QLatin1String("audio/pcm")); - break; - - case QAudio::AudioInput: - format.setFrequency(8000); - format.setChannels(1); - format.setSampleSize(16); - format.setByteOrder(QAudioFormat::LittleEndian); - format.setSampleType(QAudioFormat::SignedInt); - format.setCodec(QLatin1String("audio/pcm")); - break; - - default: - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); - } - - if (!isFormatSupported(format)) { - if (m_frequencies.size()) - format.setFrequency(m_frequencies[0]); - if (m_channels.size()) - format.setChannels(m_channels[0]); - if (m_sampleSizes.size()) - format.setSampleSize(m_sampleSizes[0]); - if (m_byteOrders.size()) - format.setByteOrder(m_byteOrders[0]); - if (m_sampleTypes.size()) - format.setSampleType(m_sampleTypes[0]); - } - - return format; -} - -bool SymbianAudioDeviceInfo::isFormatSupported( - const QAudioFormat &format) const -{ - getSupportedFormats(); - const bool supported = - m_codecs.contains(format.codec()) - && m_frequencies.contains(format.frequency()) - && m_channels.contains(format.channels()) - && m_sampleSizes.contains(format.sampleSize()) - && m_byteOrders.contains(format.byteOrder()) - && m_sampleTypes.contains(format.sampleType()); - - return supported; -} - -QAudioFormat SymbianAudioDeviceInfo::nearestFormat(const QAudioFormat &format) const -{ - if (isFormatSupported(format)) - return format; - else - return preferredFormat(); -} - -QString SymbianAudioDeviceInfo::deviceName() const -{ - return m_deviceName; -} - -QStringList SymbianAudioDeviceInfo::codecList() -{ - getSupportedFormats(); - return m_codecs; -} - -QList SymbianAudioDeviceInfo::frequencyList() -{ - getSupportedFormats(); - return m_frequencies; -} - -QList SymbianAudioDeviceInfo::channelsList() -{ - getSupportedFormats(); - return m_channels; -} - -QList SymbianAudioDeviceInfo::sampleSizeList() -{ - getSupportedFormats(); - return m_sampleSizes; -} - -QList SymbianAudioDeviceInfo::byteOrderList() -{ - getSupportedFormats(); - return m_byteOrders; -} - -QList SymbianAudioDeviceInfo::sampleTypeList() -{ - getSupportedFormats(); - return m_sampleTypes; -} - -QList SymbianAudioDeviceInfo::deviceList(QAudio::Mode mode) -{ - Q_UNUSED(mode) - QList devices; - devices.append("default"); - return devices; -} - -void SymbianAudioDeviceInfo::getSupportedFormats() const -{ - if (!m_updated) { - QScopedPointer caps( - new SymbianAudio::DevSoundCapabilities(*m_devsound, m_mode)); - - SymbianAudio::Utils::capabilitiesNativeToQt(*caps, - m_frequencies, m_channels, m_sampleSizes, - m_byteOrders, m_sampleTypes); - - m_codecs.append(QLatin1String("audio/pcm")); - - m_updated = true; - } -} - -QT_END_NAMESPACE diff --git a/src/plugins/audio/symbian/symbianaudiodeviceinfo.h b/src/plugins/audio/symbian/symbianaudiodeviceinfo.h deleted file mode 100644 index 250804d..0000000 --- a/src/plugins/audio/symbian/symbianaudiodeviceinfo.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SYMBIANAUDIODEVICEINFO_H -#define SYMBIANAUDIODEVICEINFO_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class SymbianAudioDeviceInfo - : public QAbstractAudioDeviceInfo -{ - Q_OBJECT - -public: - SymbianAudioDeviceInfo(QByteArray device, QAudio::Mode mode); - ~SymbianAudioDeviceInfo(); - - // QAbstractAudioDeviceInfo - QAudioFormat preferredFormat() const; - bool isFormatSupported(const QAudioFormat &format) const; - QAudioFormat nearestFormat(const QAudioFormat &format) const; - QString deviceName() const; - QStringList codecList(); - QList frequencyList(); - QList channelsList(); - QList sampleSizeList(); - QList byteOrderList(); - QList sampleTypeList(); - QList deviceList(QAudio::Mode); - -private: - void getSupportedFormats() const; - -private: - QScopedPointer m_devsound; - - QString m_deviceName; - QAudio::Mode m_mode; - - // Mutable to allow lazy initialization when called from const-qualified - // public functions (isFormatSupported, nearestFormat) - mutable bool m_updated; - mutable QStringList m_codecs; - mutable QList m_frequencies; - mutable QList m_channels; - mutable QList m_sampleSizes; - mutable QList m_byteOrders; - mutable QList m_sampleTypes; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/audio/symbian/symbianaudioinput.cpp b/src/plugins/audio/symbian/symbianaudioinput.cpp deleted file mode 100644 index 8200925..0000000 --- a/src/plugins/audio/symbian/symbianaudioinput.cpp +++ /dev/null @@ -1,595 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "symbianaudioinput.h" -#include "symbianaudioutils.h" - -QT_BEGIN_NAMESPACE - -//----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -const int PushInterval = 50; // ms - - -//----------------------------------------------------------------------------- -// Private class -//----------------------------------------------------------------------------- - -SymbianAudioInputPrivate::SymbianAudioInputPrivate( - SymbianAudioInput *audioDevice) - : m_audioDevice(audioDevice) -{ - -} - -SymbianAudioInputPrivate::~SymbianAudioInputPrivate() -{ - -} - -qint64 SymbianAudioInputPrivate::readData(char *data, qint64 len) -{ - qint64 totalRead = 0; - - if (m_audioDevice->state() == QAudio::ActiveState || - m_audioDevice->state() == QAudio::IdleState) { - - while (totalRead < len) { - const qint64 read = m_audioDevice->read(data + totalRead, - len - totalRead); - if (read > 0) - totalRead += read; - else - break; - } - } - - return totalRead; -} - -qint64 SymbianAudioInputPrivate::writeData(const char *data, qint64 len) -{ - Q_UNUSED(data) - Q_UNUSED(len) - return 0; -} - -void SymbianAudioInputPrivate::dataReady() -{ - emit readyRead(); -} - - -//----------------------------------------------------------------------------- -// Public functions -//----------------------------------------------------------------------------- - -SymbianAudioInput::SymbianAudioInput(const QByteArray &device, - const QAudioFormat &format) - : m_device(device) - , m_format(format) - , m_clientBufferSize(SymbianAudio::DefaultBufferSize) - , m_notifyInterval(SymbianAudio::DefaultNotifyInterval) - , m_notifyTimer(new QTimer(this)) - , m_error(QAudio::NoError) - , m_internalState(SymbianAudio::ClosedState) - , m_externalState(QAudio::StoppedState) - , m_pullMode(false) - , m_sink(0) - , m_pullTimer(new QTimer(this)) - , m_devSoundBuffer(0) - , m_devSoundBufferSize(0) - , m_totalBytesReady(0) - , m_devSoundBufferPos(0) - , m_totalSamplesRecorded(0) -{ - connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); - - SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC, - m_nativeFormat); - - m_pullTimer->setInterval(PushInterval); - connect(m_pullTimer.data(), SIGNAL(timeout()), this, SLOT(pullData())); -} - -SymbianAudioInput::~SymbianAudioInput() -{ - close(); -} - -QIODevice* SymbianAudioInput::start(QIODevice *device) -{ - stop(); - - open(); - if (SymbianAudio::ClosedState != m_internalState) { - if (device) { - m_pullMode = true; - m_sink = device; - } else { - m_sink = new SymbianAudioInputPrivate(this); - m_sink->open(QIODevice::ReadOnly | QIODevice::Unbuffered); - } - - m_elapsed.restart(); - } - - return m_sink; -} - -void SymbianAudioInput::stop() -{ - close(); -} - -void SymbianAudioInput::reset() -{ - m_totalSamplesRecorded += getSamplesRecorded(); - m_devSound->Stop(); - startRecording(); -} - -void SymbianAudioInput::suspend() -{ - if (SymbianAudio::ActiveState == m_internalState - || SymbianAudio::IdleState == m_internalState) { - m_notifyTimer->stop(); - m_pullTimer->stop(); - m_devSound->Pause(); - const qint64 samplesRecorded = getSamplesRecorded(); - m_totalSamplesRecorded += samplesRecorded; - - if (m_devSoundBuffer) { - m_devSoundBufferQ.append(m_devSoundBuffer); - m_devSoundBuffer = 0; - } - - setState(SymbianAudio::SuspendedState); - } -} - -void SymbianAudioInput::resume() -{ - if (SymbianAudio::SuspendedState == m_internalState) - startDataTransfer(); -} - -int SymbianAudioInput::bytesReady() const -{ - Q_ASSERT(m_devSoundBufferPos <= m_totalBytesReady); - return m_totalBytesReady - m_devSoundBufferPos; -} - -int SymbianAudioInput::periodSize() const -{ - return bufferSize(); -} - -void SymbianAudioInput::setBufferSize(int value) -{ - // Note that DevSound does not allow its client to specify the buffer size. - // This functionality is available via custom interfaces, but since these - // cannot be guaranteed to work across all DevSound implementations, we - // do not use them here. - // In order to comply with the expected bevahiour of QAudioInput, we store - // the value and return it from bufferSize(), but the underlying DevSound - // buffer size remains unchanged. - if (value > 0) - m_clientBufferSize = value; -} - -int SymbianAudioInput::bufferSize() const -{ - return m_devSoundBufferSize ? m_devSoundBufferSize : m_clientBufferSize; -} - -void SymbianAudioInput::setNotifyInterval(int ms) -{ - if (ms > 0) { - const int oldNotifyInterval = m_notifyInterval; - m_notifyInterval = ms; - if (m_notifyTimer->isActive() && ms != oldNotifyInterval) - m_notifyTimer->start(m_notifyInterval); - } -} - -int SymbianAudioInput::notifyInterval() const -{ - return m_notifyInterval; -} - -qint64 SymbianAudioInput::processedUSecs() const -{ - int samplesPlayed = 0; - if (m_devSound && SymbianAudio::SuspendedState != m_internalState) - samplesPlayed = getSamplesRecorded(); - - // Protect against division by zero - Q_ASSERT_X(m_format.frequency() > 0, Q_FUNC_INFO, "Invalid frequency"); - - const qint64 result = qint64(1000000) * - (samplesPlayed + m_totalSamplesRecorded) - / m_format.frequency(); - - return result; -} - -qint64 SymbianAudioInput::elapsedUSecs() const -{ - const qint64 result = (QAudio::StoppedState == state()) ? - 0 : m_elapsed.elapsed() * 1000; - return result; -} - -QAudio::Error SymbianAudioInput::error() const -{ - return m_error; -} - -QAudio::State SymbianAudioInput::state() const -{ - return m_externalState; -} - -QAudioFormat SymbianAudioInput::format() const -{ - return m_format; -} - -//----------------------------------------------------------------------------- -// MDevSoundObserver implementation -//----------------------------------------------------------------------------- - -void SymbianAudioInput::InitializeComplete(TInt aError) -{ - Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, - Q_FUNC_INFO, "Invalid state"); - - if (KErrNone == aError) - startRecording(); -} - -void SymbianAudioInput::ToneFinished(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's tone playback functions, so should - // never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void SymbianAudioInput::BufferToBeFilled(CMMFBuffer *aBuffer) -{ - Q_UNUSED(aBuffer) - // This class doesn't use DevSound in play mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void SymbianAudioInput::PlayError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound in play mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void SymbianAudioInput::BufferToBeEmptied(CMMFBuffer *aBuffer) -{ - // Following receipt of this callback, DevSound should not provide another - // buffer until we have returned the current one. - Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); - - CMMFDataBuffer *const buffer = static_cast(aBuffer); - - if (!m_devSoundBufferSize) - m_devSoundBufferSize = buffer->Data().MaxLength(); - - m_totalBytesReady += buffer->Data().Length(); - - if (SymbianAudio::SuspendedState == m_internalState) { - m_devSoundBufferQ.append(buffer); - } else { - // Will be returned to DevSound by bufferEmptied(). - m_devSoundBuffer = buffer; - m_devSoundBufferPos = 0; - - if (bytesReady() && !m_pullMode) - pushData(); - } -} - -void SymbianAudioInput::RecordError(TInt aError) -{ - Q_UNUSED(aError) - setError(QAudio::IOError); -} - -void SymbianAudioInput::ConvertError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's format conversion functions, so - // should never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void SymbianAudioInput::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) -{ - Q_UNUSED(aMessageType) - Q_UNUSED(aMsg) - // Ignore this callback. -} - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -void SymbianAudioInput::open() -{ - Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState, - Q_FUNC_INFO, "DevSound already opened"); - - QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) ) - - QScopedPointer caps( - new SymbianAudio::DevSoundCapabilities(*m_devSound, QAudio::AudioInput)); - - int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ? - KErrNone : KErrNotSupported; - - if (KErrNone == err) { - setState(SymbianAudio::InitializingState); - TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC, - EMMFStateRecording)); - } - - if (KErrNone != err) { - setError(QAudio::OpenError); - m_devSound.reset(); - } -} - -void SymbianAudioInput::startRecording() -{ - const int samplesRecorded = m_devSound->SamplesRecorded(); - Q_ASSERT(samplesRecorded == 0); - - TRAPD(err, startDevSoundL()); - if (KErrNone == err) { - startDataTransfer(); - } else { - setError(QAudio::OpenError); - close(); - } -} - -void SymbianAudioInput::startDevSoundL() -{ - TMMFCapabilities nativeFormat = m_devSound->Config(); - m_nativeFormat.iBufferSize = nativeFormat.iBufferSize; - m_devSound->SetConfigL(m_nativeFormat); - m_devSound->RecordInitL(); -} - -void SymbianAudioInput::startDataTransfer() -{ - m_notifyTimer->start(m_notifyInterval); - - if (m_pullMode) - m_pullTimer->start(); - - if (bytesReady()) { - setState(SymbianAudio::ActiveState); - if (!m_pullMode) - pushData(); - } else { - if (SymbianAudio::SuspendedState == m_internalState) - setState(SymbianAudio::ActiveState); - else - setState(SymbianAudio::IdleState); - } -} - -CMMFDataBuffer* SymbianAudioInput::currentBuffer() const -{ - CMMFDataBuffer *result = m_devSoundBuffer; - if (!result && !m_devSoundBufferQ.empty()) - result = m_devSoundBufferQ.front(); - return result; -} - -void SymbianAudioInput::pushData() -{ - Q_ASSERT_X(bytesReady(), Q_FUNC_INFO, "No data available"); - Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, "pushData called when in pull mode"); - qobject_cast(m_sink)->dataReady(); -} - -qint64 SymbianAudioInput::read(char *data, qint64 len) -{ - // SymbianAudioInputPrivate is ready to read data - - Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, - "read called when in pull mode"); - - qint64 bytesRead = 0; - - CMMFDataBuffer *buffer = 0; - while ((buffer = currentBuffer()) && (bytesRead < len)) { - if (SymbianAudio::IdleState == m_internalState) - setState(SymbianAudio::ActiveState); - - TDesC8 &inputBuffer = buffer->Data(); - - const qint64 inputBytes = bytesReady(); - const qint64 outputBytes = len - bytesRead; - const qint64 copyBytes = outputBytes < inputBytes ? - outputBytes : inputBytes; - - memcpy(data, inputBuffer.Ptr() + m_devSoundBufferPos, copyBytes); - - m_devSoundBufferPos += copyBytes; - data += copyBytes; - bytesRead += copyBytes; - - if (!bytesReady()) - bufferEmptied(); - } - - return bytesRead; -} - -void SymbianAudioInput::pullData() -{ - Q_ASSERT_X(m_pullMode, Q_FUNC_INFO, - "pullData called when in push mode"); - - CMMFDataBuffer *buffer = 0; - while (buffer = currentBuffer()) { - if (SymbianAudio::IdleState == m_internalState) - setState(SymbianAudio::ActiveState); - - TDesC8 &inputBuffer = buffer->Data(); - - const qint64 inputBytes = bytesReady(); - const qint64 bytesPushed = m_sink->write( - (char*)inputBuffer.Ptr() + m_devSoundBufferPos, inputBytes); - - m_devSoundBufferPos += bytesPushed; - - if (!bytesReady()) - bufferEmptied(); - - if (!bytesPushed) - break; - } -} - -void SymbianAudioInput::bufferEmptied() -{ - m_devSoundBufferPos = 0; - - if (m_devSoundBuffer) { - m_totalBytesReady -= m_devSoundBuffer->Data().Length(); - m_devSoundBuffer = 0; - m_devSound->RecordData(); - } else { - Q_ASSERT(!m_devSoundBufferQ.empty()); - m_totalBytesReady -= m_devSoundBufferQ.front()->Data().Length(); - m_devSoundBufferQ.erase(m_devSoundBufferQ.begin()); - - // If the queue has been emptied, resume transfer from the hardware - if (m_devSoundBufferQ.empty()) - m_devSound->RecordInitL(); - } - - Q_ASSERT(m_totalBytesReady >= 0); -} - -void SymbianAudioInput::close() -{ - m_notifyTimer->stop(); - m_pullTimer->stop(); - - m_error = QAudio::NoError; - - if (m_devSound) - m_devSound->Stop(); - m_devSound.reset(); - m_devSoundBuffer = 0; - m_devSoundBufferSize = 0; - m_totalBytesReady = 0; - - if (!m_pullMode) // m_sink is owned - delete m_sink; - m_pullMode = false; - m_sink = 0; - - m_devSoundBufferQ.clear(); - m_devSoundBufferPos = 0; - m_totalSamplesRecorded = 0; - - setState(SymbianAudio::ClosedState); -} - -qint64 SymbianAudioInput::getSamplesRecorded() const -{ - qint64 result = 0; - if (m_devSound) - result = qint64(m_devSound->SamplesRecorded()); - return result; -} - -void SymbianAudioInput::setError(QAudio::Error error) -{ - m_error = error; - - // Although no state transition actually occurs here, a stateChanged event - // must be emitted to inform the client that the call to start() was - // unsuccessful. - if (QAudio::OpenError == error) - emit stateChanged(QAudio::StoppedState); - - // Close the DevSound instance. This causes a transition to StoppedState. - // This must be done asynchronously in case the current function was called - // from a DevSound event handler, in which case deleting the DevSound - // instance may cause an exception. - QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); -} - -void SymbianAudioInput::setState(SymbianAudio::State newInternalState) -{ - const QAudio::State oldExternalState = m_externalState; - m_internalState = newInternalState; - m_externalState = SymbianAudio::Utils::stateNativeToQt( - m_internalState, initializingState()); - - if (m_externalState != oldExternalState) - emit stateChanged(m_externalState); -} - -QAudio::State SymbianAudioInput::initializingState() const -{ - return QAudio::IdleState; -} - -QT_END_NAMESPACE diff --git a/src/plugins/audio/symbian/symbianaudioinput.h b/src/plugins/audio/symbian/symbianaudioinput.h deleted file mode 100644 index 34b7d38..0000000 --- a/src/plugins/audio/symbian/symbianaudioinput.h +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SYMBIANAUDIOINPUT_H -#define SYMBIANAUDIOINPUT_H - -#include -#include -#include -#include -#include "symbianaudio.h" - -QT_BEGIN_NAMESPACE - -class SymbianAudioInput; - -class SymbianAudioInputPrivate : public QIODevice -{ - friend class SymbianAudioInput; - Q_OBJECT -public: - SymbianAudioInputPrivate(SymbianAudioInput *audio); - ~SymbianAudioInputPrivate(); - - qint64 readData(char *data, qint64 len); - qint64 writeData(const char *data, qint64 len); - - void dataReady(); - -private: - SymbianAudioInput *const m_audioDevice; -}; - -class SymbianAudioInput - : public QAbstractAudioInput - , public MDevSoundObserver -{ - friend class SymbianAudioInputPrivate; - Q_OBJECT -public: - SymbianAudioInput(const QByteArray &device, - const QAudioFormat &audioFormat); - ~SymbianAudioInput(); - - // QAbstractAudioInput - QIODevice* start(QIODevice *device = 0); - void stop(); - void reset(); - void suspend(); - void resume(); - int bytesReady() const; - int periodSize() const; - void setBufferSize(int value); - int bufferSize() const; - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - QAudio::Error error() const; - QAudio::State state() const; - QAudioFormat format() const; - - // MDevSoundObserver - void InitializeComplete(TInt aError); - void ToneFinished(TInt aError); - void BufferToBeFilled(CMMFBuffer *aBuffer); - void PlayError(TInt aError); - void BufferToBeEmptied(CMMFBuffer *aBuffer); - void RecordError(TInt aError); - void ConvertError(TInt aError); - void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); - -private slots: - void pullData(); - -private: - void open(); - void startRecording(); - void startDevSoundL(); - void startDataTransfer(); - CMMFDataBuffer* currentBuffer() const; - void pushData(); - qint64 read(char *data, qint64 len); - void bufferEmptied(); - Q_INVOKABLE void close(); - - qint64 getSamplesRecorded() const; - - void setError(QAudio::Error error); - void setState(SymbianAudio::State state); - - QAudio::State initializingState() const; - -private: - const QByteArray m_device; - const QAudioFormat m_format; - - int m_clientBufferSize; - int m_notifyInterval; - QScopedPointer m_notifyTimer; - QTime m_elapsed; - QAudio::Error m_error; - - SymbianAudio::State m_internalState; - QAudio::State m_externalState; - - bool m_pullMode; - QIODevice *m_sink; - - QScopedPointer m_pullTimer; - - QScopedPointer m_devSound; - TUint32 m_nativeFourCC; - TMMFCapabilities m_nativeFormat; - - // Latest buffer provided by DevSound, to be empied of data. - CMMFDataBuffer *m_devSoundBuffer; - - int m_devSoundBufferSize; - - // Total amount of data in buffers provided by DevSound - int m_totalBytesReady; - - // Queue of buffers returned after call to CMMFDevSound::Pause(). - QList m_devSoundBufferQ; - - // Current read position within m_devSoundBuffer - qint64 m_devSoundBufferPos; - - // Samples recorded up to the last call to suspend(). It is necessary - // to cache this because suspend() is implemented using - // CMMFDevSound::Stop(), which resets DevSound's SamplesRecorded() counter. - quint32 m_totalSamplesRecorded; - -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/audio/symbian/symbianaudiooutput.cpp b/src/plugins/audio/symbian/symbianaudiooutput.cpp deleted file mode 100644 index 385e169..0000000 --- a/src/plugins/audio/symbian/symbianaudiooutput.cpp +++ /dev/null @@ -1,697 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "symbianaudiooutput.h" -#include "symbianaudioutils.h" - -QT_BEGIN_NAMESPACE - -//----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -const int UnderflowTimerInterval = 50; // ms - - -//----------------------------------------------------------------------------- -// Private class -//----------------------------------------------------------------------------- - -SymbianAudioOutputPrivate::SymbianAudioOutputPrivate( - SymbianAudioOutput *audioDevice) - : m_audioDevice(audioDevice) -{ - -} - -SymbianAudioOutputPrivate::~SymbianAudioOutputPrivate() -{ - -} - -qint64 SymbianAudioOutputPrivate::readData(char *data, qint64 len) -{ - Q_UNUSED(data) - Q_UNUSED(len) - return 0; -} - -qint64 SymbianAudioOutputPrivate::writeData(const char *data, qint64 len) -{ - qint64 totalWritten = 0; - - if (m_audioDevice->state() == QAudio::ActiveState || - m_audioDevice->state() == QAudio::IdleState) { - - while (totalWritten < len) { - const qint64 written = m_audioDevice->pushData(data + totalWritten, - len - totalWritten); - if (written > 0) - totalWritten += written; - else - break; - } - } - - return totalWritten; -} - - -//----------------------------------------------------------------------------- -// Public functions -//----------------------------------------------------------------------------- - -SymbianAudioOutput::SymbianAudioOutput(const QByteArray &device, - const QAudioFormat &format) - : m_device(device) - , m_format(format) - , m_clientBufferSize(SymbianAudio::DefaultBufferSize) - , m_notifyInterval(SymbianAudio::DefaultNotifyInterval) - , m_notifyTimer(new QTimer(this)) - , m_error(QAudio::NoError) - , m_internalState(SymbianAudio::ClosedState) - , m_externalState(QAudio::StoppedState) - , m_pullMode(false) - , m_source(0) - , m_devSoundBuffer(0) - , m_devSoundBufferSize(0) - , m_bytesWritten(0) - , m_pushDataReady(false) - , m_bytesPadding(0) - , m_underflow(false) - , m_lastBuffer(false) - , m_underflowTimer(new QTimer(this)) - , m_samplesPlayed(0) - , m_totalSamplesPlayed(0) -{ - connect(m_notifyTimer.data(), SIGNAL(timeout()), this, SIGNAL(notify())); - - SymbianAudio::Utils::formatQtToNative(m_format, m_nativeFourCC, - m_nativeFormat); - - m_underflowTimer->setInterval(UnderflowTimerInterval); - connect(m_underflowTimer.data(), SIGNAL(timeout()), this, - SLOT(underflowTimerExpired())); -} - -SymbianAudioOutput::~SymbianAudioOutput() -{ - close(); -} - -QIODevice* SymbianAudioOutput::start(QIODevice *device) -{ - stop(); - - // We have to set these before the call to open() because of the - // logic in initializingState() - if (device) { - m_pullMode = true; - m_source = device; - } - - open(); - - if (SymbianAudio::ClosedState != m_internalState) { - if (device) { - connect(m_source, SIGNAL(readyRead()), this, SLOT(dataReady())); - } else { - m_source = new SymbianAudioOutputPrivate(this); - m_source->open(QIODevice::WriteOnly | QIODevice::Unbuffered); - } - - m_elapsed.restart(); - } - - return m_source; -} - -void SymbianAudioOutput::stop() -{ - close(); -} - -void SymbianAudioOutput::reset() -{ - m_totalSamplesPlayed += getSamplesPlayed(); - m_devSound->Stop(); - m_bytesPadding = 0; - startPlayback(); -} - -void SymbianAudioOutput::suspend() -{ - if (SymbianAudio::ActiveState == m_internalState - || SymbianAudio::IdleState == m_internalState) { - m_notifyTimer->stop(); - m_underflowTimer->stop(); - - const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples( - m_format, m_bytesWritten); - m_bytesWritten = 0; - - const qint64 samplesPlayed = getSamplesPlayed(); - - // CMMFDevSound::Pause() is not guaranteed to work correctly in all - // implementations, for play-mode DevSound sessions. We therefore - // have to implement suspend() by calling CMMFDevSound::Stop(). - // Because this causes buffered data to be dropped, we replace the - // lost data with silence following a call to resume(), in order to - // ensure that processedUSecs() returns the correct value. - m_devSound->Stop(); - m_totalSamplesPlayed += samplesPlayed; - - // Calculate the amount of data dropped - const qint64 paddingSamples = samplesWritten - samplesPlayed; - m_bytesPadding = SymbianAudio::Utils::samplesToBytes(m_format, - paddingSamples); - - setState(SymbianAudio::SuspendedState); - } -} - -void SymbianAudioOutput::resume() -{ - if (SymbianAudio::SuspendedState == m_internalState) - startPlayback(); -} - -int SymbianAudioOutput::bytesFree() const -{ - int result = 0; - if (m_devSoundBuffer) { - const TDes8 &outputBuffer = m_devSoundBuffer->Data(); - result = outputBuffer.MaxLength() - outputBuffer.Length(); - } - return result; -} - -int SymbianAudioOutput::periodSize() const -{ - return bufferSize(); -} - -void SymbianAudioOutput::setBufferSize(int value) -{ - // Note that DevSound does not allow its client to specify the buffer size. - // This functionality is available via custom interfaces, but since these - // cannot be guaranteed to work across all DevSound implementations, we - // do not use them here. - // In order to comply with the expected bevahiour of QAudioOutput, we store - // the value and return it from bufferSize(), but the underlying DevSound - // buffer size remains unchanged. - if (value > 0) - m_clientBufferSize = value; -} - -int SymbianAudioOutput::bufferSize() const -{ - return m_devSoundBufferSize ? m_devSoundBufferSize : m_clientBufferSize; -} - -void SymbianAudioOutput::setNotifyInterval(int ms) -{ - if (ms > 0) { - const int oldNotifyInterval = m_notifyInterval; - m_notifyInterval = ms; - if (m_notifyTimer->isActive() && ms != oldNotifyInterval) - m_notifyTimer->start(m_notifyInterval); - } -} - -int SymbianAudioOutput::notifyInterval() const -{ - return m_notifyInterval; -} - -qint64 SymbianAudioOutput::processedUSecs() const -{ - int samplesPlayed = 0; - if (m_devSound && SymbianAudio::SuspendedState != m_internalState) - samplesPlayed = getSamplesPlayed(); - - // Protect against division by zero - Q_ASSERT_X(m_format.frequency() > 0, Q_FUNC_INFO, "Invalid frequency"); - - const qint64 result = qint64(1000000) * - (samplesPlayed + m_totalSamplesPlayed) - / m_format.frequency(); - - return result; -} - -qint64 SymbianAudioOutput::elapsedUSecs() const -{ - const qint64 result = (QAudio::StoppedState == state()) ? - 0 : m_elapsed.elapsed() * 1000; - return result; -} - -QAudio::Error SymbianAudioOutput::error() const -{ - return m_error; -} - -QAudio::State SymbianAudioOutput::state() const -{ - return m_externalState; -} - -QAudioFormat SymbianAudioOutput::format() const -{ - return m_format; -} - -//----------------------------------------------------------------------------- -// MDevSoundObserver implementation -//----------------------------------------------------------------------------- - -void SymbianAudioOutput::InitializeComplete(TInt aError) -{ - Q_ASSERT_X(SymbianAudio::InitializingState == m_internalState, - Q_FUNC_INFO, "Invalid state"); - - if (KErrNone == aError) - startPlayback(); -} - -void SymbianAudioOutput::ToneFinished(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's tone playback functions, so should - // never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void SymbianAudioOutput::BufferToBeFilled(CMMFBuffer *aBuffer) -{ - // Following receipt of this callback, DevSound should not provide another - // buffer until we have returned the current one. - Q_ASSERT_X(!m_devSoundBuffer, Q_FUNC_INFO, "Buffer already held"); - - // Will be returned to DevSound by bufferFilled(). - m_devSoundBuffer = static_cast(aBuffer); - - if (!m_devSoundBufferSize) - m_devSoundBufferSize = m_devSoundBuffer->Data().MaxLength(); - - writePaddingData(); - - if (m_pullMode && isDataReady() && !m_bytesPadding) - pullData(); -} - -void SymbianAudioOutput::PlayError(TInt aError) -{ - switch (aError) { - case KErrUnderflow: - m_underflow = true; - if (m_pullMode && !m_lastBuffer) - setError(QAudio::UnderrunError); - else - setState(SymbianAudio::IdleState); - break; - default: - setError(QAudio::IOError); - break; - } -} - -void SymbianAudioOutput::BufferToBeEmptied(CMMFBuffer *aBuffer) -{ - Q_UNUSED(aBuffer) - // This class doesn't use DevSound in record mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void SymbianAudioOutput::RecordError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound in record mode, so should never receive - // this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void SymbianAudioOutput::ConvertError(TInt aError) -{ - Q_UNUSED(aError) - // This class doesn't use DevSound's format conversion functions, so - // should never receive this callback. - Q_ASSERT_X(false, Q_FUNC_INFO, "Unexpected callback"); -} - -void SymbianAudioOutput::DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) -{ - Q_UNUSED(aMessageType) - Q_UNUSED(aMsg) - // Ignore this callback. -} - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -void SymbianAudioOutput::dataReady() -{ - // Client-provided QIODevice has data ready to read. - - Q_ASSERT_X(m_source->bytesAvailable(), Q_FUNC_INFO, - "readyRead signal received, but no data available"); - - if (!m_bytesPadding) - pullData(); -} - -void SymbianAudioOutput::underflowTimerExpired() -{ - const TInt samplesPlayed = getSamplesPlayed(); - if (m_samplesPlayed && (samplesPlayed == m_samplesPlayed)) { - setError(QAudio::UnderrunError); - } else { - m_samplesPlayed = samplesPlayed; - m_underflowTimer->start(); - } -} - -void SymbianAudioOutput::open() -{ - Q_ASSERT_X(SymbianAudio::ClosedState == m_internalState, - Q_FUNC_INFO, "DevSound already opened"); - - QT_TRAP_THROWING( m_devSound.reset(CMMFDevSound::NewL()) ) - - QScopedPointer caps( - new SymbianAudio::DevSoundCapabilities(*m_devSound, - QAudio::AudioOutput)); - - int err = SymbianAudio::Utils::isFormatSupported(m_format, *caps) ? - KErrNone : KErrNotSupported; - - if (KErrNone == err) { - setState(SymbianAudio::InitializingState); - TRAP(err, m_devSound->InitializeL(*this, m_nativeFourCC, - EMMFStatePlaying)); - } - - if (KErrNone != err) { - setError(QAudio::OpenError); - m_devSound.reset(); - } -} - -void SymbianAudioOutput::startPlayback() -{ - TRAPD(err, startDevSoundL()); - if (KErrNone == err) { - if (isDataReady()) - setState(SymbianAudio::ActiveState); - else - setState(SymbianAudio::IdleState); - - m_notifyTimer->start(m_notifyInterval); - m_underflow = false; - - Q_ASSERT(m_devSound->SamplesPlayed() == 0); - - writePaddingData(); - - if (m_pullMode && m_source->bytesAvailable() && !m_bytesPadding) - dataReady(); - } else { - setError(QAudio::OpenError); - close(); - } -} - -void SymbianAudioOutput::startDevSoundL() -{ - TMMFCapabilities nativeFormat = m_devSound->Config(); - m_nativeFormat.iBufferSize = nativeFormat.iBufferSize; - m_devSound->SetConfigL(m_nativeFormat); - m_devSound->PlayInitL(); -} - -void SymbianAudioOutput::writePaddingData() -{ - // See comments in suspend() - - while (m_devSoundBuffer && m_bytesPadding) { - if (SymbianAudio::IdleState == m_internalState) - setState(SymbianAudio::ActiveState); - - TDes8 &outputBuffer = m_devSoundBuffer->Data(); - const qint64 outputBytes = bytesFree(); - const qint64 paddingBytes = outputBytes < m_bytesPadding ? - outputBytes : m_bytesPadding; - unsigned char *ptr = const_cast(outputBuffer.Ptr()); - Mem::FillZ(ptr, paddingBytes); - outputBuffer.SetLength(outputBuffer.Length() + paddingBytes); - m_bytesPadding -= paddingBytes; - - if (m_pullMode && m_source->atEnd()) - lastBufferFilled(); - if (paddingBytes == outputBytes) - bufferFilled(); - } -} - -qint64 SymbianAudioOutput::pushData(const char *data, qint64 len) -{ - // Data has been written to SymbianAudioOutputPrivate - - Q_ASSERT_X(!m_pullMode, Q_FUNC_INFO, - "pushData called when in pull mode"); - - const unsigned char *const inputPtr = - reinterpret_cast(data); - qint64 bytesWritten = 0; - - if (SymbianAudio::IdleState == m_internalState) - setState(SymbianAudio::ActiveState); - - while (m_devSoundBuffer && (bytesWritten < len)) { - // writePaddingData() is called from BufferToBeFilled(), so we should - // never have any padding data left at this point. - Q_ASSERT_X(0 == m_bytesPadding, Q_FUNC_INFO, - "Padding bytes remaining in pushData"); - - TDes8 &outputBuffer = m_devSoundBuffer->Data(); - - const qint64 outputBytes = bytesFree(); - const qint64 inputBytes = len - bytesWritten; - const qint64 copyBytes = outputBytes < inputBytes ? - outputBytes : inputBytes; - - outputBuffer.Append(inputPtr + bytesWritten, copyBytes); - bytesWritten += copyBytes; - - bufferFilled(); - } - - m_pushDataReady = (bytesWritten < len); - - // If DevSound is still initializing (m_internalState == InitializingState), - // we cannot transition m_internalState to ActiveState, but we must emit - // an (external) state change from IdleState to ActiveState. The following - // call triggers this signal. - setState(m_internalState); - - return bytesWritten; -} - -void SymbianAudioOutput::pullData() -{ - Q_ASSERT_X(m_pullMode, Q_FUNC_INFO, - "pullData called when in push mode"); - - if (m_bytesPadding) - m_bytesPadding = 1; - - // writePaddingData() is called by BufferToBeFilled() before pullData(), - // so we should never have any padding data left at this point. - Q_ASSERT_X(0 == m_bytesPadding, Q_FUNC_INFO, - "Padding bytes remaining in pullData"); - - qint64 inputBytes = m_source->bytesAvailable(); - while (m_devSoundBuffer && inputBytes) { - if (SymbianAudio::IdleState == m_internalState) - setState(SymbianAudio::ActiveState); - - TDes8 &outputBuffer = m_devSoundBuffer->Data(); - - const qint64 outputBytes = bytesFree(); - const qint64 copyBytes = outputBytes < inputBytes ? - outputBytes : inputBytes; - - char *outputPtr = (char*)(outputBuffer.Ptr() + outputBuffer.Length()); - const qint64 bytesCopied = m_source->read(outputPtr, copyBytes); - Q_ASSERT(bytesCopied == copyBytes); - outputBuffer.SetLength(outputBuffer.Length() + bytesCopied); - inputBytes -= bytesCopied; - - if (m_source->atEnd()) - lastBufferFilled(); - else if (copyBytes == outputBytes) - bufferFilled(); - } -} - -void SymbianAudioOutput::bufferFilled() -{ - Q_ASSERT_X(m_devSoundBuffer, Q_FUNC_INFO, "No buffer to return"); - - const TDes8 &outputBuffer = m_devSoundBuffer->Data(); - m_bytesWritten += outputBuffer.Length(); - - m_devSoundBuffer = 0; - - m_samplesPlayed = getSamplesPlayed(); - m_underflowTimer->start(); - - if (QAudio::UnderrunError == m_error) - m_error = QAudio::NoError; - - m_devSound->PlayData(); -} - -void SymbianAudioOutput::lastBufferFilled() -{ - Q_ASSERT_X(m_devSoundBuffer, Q_FUNC_INFO, "No buffer to fill"); - Q_ASSERT_X(!m_lastBuffer, Q_FUNC_INFO, "Last buffer already sent"); - m_lastBuffer = true; - m_devSoundBuffer->SetLastBuffer(ETrue); - bufferFilled(); -} - -void SymbianAudioOutput::close() -{ - m_notifyTimer->stop(); - m_underflowTimer->stop(); - - m_error = QAudio::NoError; - - if (m_devSound) - m_devSound->Stop(); - m_devSound.reset(); - m_devSoundBuffer = 0; - m_devSoundBufferSize = 0; - - if (!m_pullMode) // m_source is owned - delete m_source; - m_pullMode = false; - m_source = 0; - - m_bytesWritten = 0; - m_pushDataReady = false; - m_bytesPadding = 0; - m_underflow = false; - m_lastBuffer = false; - m_samplesPlayed = 0; - m_totalSamplesPlayed = 0; - - setState(SymbianAudio::ClosedState); -} - -qint64 SymbianAudioOutput::getSamplesPlayed() const -{ - qint64 result = 0; - if (m_devSound) { - const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples( - m_format, m_bytesWritten); - - if (m_underflow) { - result = samplesWritten; - } else { - // This is necessary because some DevSound implementations report - // that they have played more data than has actually been provided to them - // by the client. - const qint64 devSoundSamplesPlayed(m_devSound->SamplesPlayed()); - result = qMin(devSoundSamplesPlayed, samplesWritten); - } - } - return result; -} - -void SymbianAudioOutput::setError(QAudio::Error error) -{ - m_error = error; - - // Although no state transition actually occurs here, a stateChanged event - // must be emitted to inform the client that the call to start() was - // unsuccessful. - if (QAudio::OpenError == error) - emit stateChanged(QAudio::StoppedState); - - if (QAudio::UnderrunError == error) - setState(SymbianAudio::IdleState); - else - // Close the DevSound instance. This causes a transition to - // StoppedState. This must be done asynchronously in case the - // current function was called from a DevSound event handler, in which - // case deleting the DevSound instance may cause an exception. - QMetaObject::invokeMethod(this, "close", Qt::QueuedConnection); -} - -void SymbianAudioOutput::setState(SymbianAudio::State newInternalState) -{ - const QAudio::State oldExternalState = m_externalState; - m_internalState = newInternalState; - m_externalState = SymbianAudio::Utils::stateNativeToQt( - m_internalState, initializingState()); - - if (m_externalState != oldExternalState) - emit stateChanged(m_externalState); -} - -bool SymbianAudioOutput::isDataReady() const -{ - return (m_source && m_source->bytesAvailable()) - || m_bytesPadding - || m_pushDataReady; -} - -QAudio::State SymbianAudioOutput::initializingState() const -{ - return isDataReady() ? QAudio::ActiveState : QAudio::IdleState; -} - -QT_END_NAMESPACE diff --git a/src/plugins/audio/symbian/symbianaudiooutput.h b/src/plugins/audio/symbian/symbianaudiooutput.h deleted file mode 100644 index 8994e46..0000000 --- a/src/plugins/audio/symbian/symbianaudiooutput.h +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SYMBIANAUDIOOUTPUT_H -#define SYMBIANAUDIOOUTPUT_H - -#include -#include -#include -#include -#include "symbianaudio.h" - -QT_BEGIN_NAMESPACE - -class SymbianAudioOutput; - -class SymbianAudioOutputPrivate : public QIODevice -{ - friend class SymbianAudioOutput; - Q_OBJECT -public: - SymbianAudioOutputPrivate(SymbianAudioOutput *audio); - ~SymbianAudioOutputPrivate(); - - qint64 readData(char *data, qint64 len); - qint64 writeData(const char *data, qint64 len); - -private: - SymbianAudioOutput *const m_audioDevice; -}; - -class SymbianAudioOutput - : public QAbstractAudioOutput - , public MDevSoundObserver -{ - friend class SymbianAudioOutputPrivate; - Q_OBJECT -public: - SymbianAudioOutput(const QByteArray &device, - const QAudioFormat &audioFormat); - ~SymbianAudioOutput(); - - // QAbstractAudioOutput - QIODevice* start(QIODevice *device = 0); - void stop(); - void reset(); - void suspend(); - void resume(); - int bytesFree() const; - int periodSize() const; - void setBufferSize(int value); - int bufferSize() const; - void setNotifyInterval(int milliSeconds); - int notifyInterval() const; - qint64 processedUSecs() const; - qint64 elapsedUSecs() const; - QAudio::Error error() const; - QAudio::State state() const; - QAudioFormat format() const; - - // MDevSoundObserver - void InitializeComplete(TInt aError); - void ToneFinished(TInt aError); - void BufferToBeFilled(CMMFBuffer *aBuffer); - void PlayError(TInt aError); - void BufferToBeEmptied(CMMFBuffer *aBuffer); - void RecordError(TInt aError); - void ConvertError(TInt aError); - void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg); - -private slots: - void dataReady(); - void underflowTimerExpired(); - -private: - void open(); - void startPlayback(); - void startDevSoundL(); - void writePaddingData(); - qint64 pushData(const char *data, qint64 len); - void pullData(); - void bufferFilled(); - void lastBufferFilled(); - Q_INVOKABLE void close(); - - qint64 getSamplesPlayed() const; - - void setError(QAudio::Error error); - void setState(SymbianAudio::State state); - - bool isDataReady() const; - QAudio::State initializingState() const; - -private: - const QByteArray m_device; - const QAudioFormat m_format; - - int m_clientBufferSize; - int m_notifyInterval; - QScopedPointer m_notifyTimer; - QTime m_elapsed; - QAudio::Error m_error; - - SymbianAudio::State m_internalState; - QAudio::State m_externalState; - - bool m_pullMode; - QIODevice *m_source; - - QScopedPointer m_devSound; - TUint32 m_nativeFourCC; - TMMFCapabilities m_nativeFormat; - - // Buffer provided by DevSound, to be filled with data. - CMMFDataBuffer *m_devSoundBuffer; - - int m_devSoundBufferSize; - - // Number of bytes transferred from QIODevice to QAudioOutput. It is - // necessary to count this because data is dropped when suspend() is - // called. The difference between the position reported by DevSound and - // this value allows us to calculate m_bytesPadding; - quint32 m_bytesWritten; - - // True if client has provided data while the audio subsystem was not - // ready to consume it. - bool m_pushDataReady; - - // Number of zero bytes which will be written when client calls resume(). - quint32 m_bytesPadding; - - // True if PlayError(KErrUnderflow) has been called. - bool m_underflow; - - // True if a buffer marked with the "last buffer" flag has been provided - // to DevSound. - bool m_lastBuffer; - - // Some DevSound implementations ignore all underflow errors raised by the - // audio driver, unless the last buffer flag has been set by the client. - // In push-mode playback, this flag will never be set, so the underflow - // error will never be reported. In order to work around this, a timer - // is used, which gets reset every time the client provides more data. If - // the timer expires, an underflow error is raised by this object. - QScopedPointer m_underflowTimer; - - // Result of previous call to CMMFDevSound::SamplesPlayed(). This value is - // used to determine whether, when m_underflowTimer expires, an - // underflow error has actually occurred. - quint32 m_samplesPlayed; - - // Samples played up to the last call to suspend(). It is necessary - // to cache this because suspend() is implemented using - // CMMFDevSound::Stop(), which resets DevSound's SamplesPlayed() counter. - quint32 m_totalSamplesPlayed; - -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/audio/symbian/symbianaudioutils.cpp b/src/plugins/audio/symbian/symbianaudioutils.cpp deleted file mode 100644 index f04c198..0000000 --- a/src/plugins/audio/symbian/symbianaudioutils.cpp +++ /dev/null @@ -1,395 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtMultimedia 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 Technology Preview License Agreement accompanying -** this package. -** -** 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.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "symbianaudioutils.h" -#include - -QT_BEGIN_NAMESPACE - -namespace SymbianAudio { - -DevSoundCapabilities::DevSoundCapabilities(CMMFDevSound &devsound, - QAudio::Mode mode) -{ - QT_TRAP_THROWING(constructL(devsound, mode)); -} - -DevSoundCapabilities::~DevSoundCapabilities() -{ - m_fourCC.Close(); -} - -void DevSoundCapabilities::constructL(CMMFDevSound &devsound, - QAudio::Mode mode) -{ - m_caps = devsound.Capabilities(); - - TMMFPrioritySettings settings; - - switch (mode) { - case QAudio::AudioOutput: - settings.iState = EMMFStatePlaying; - devsound.GetSupportedInputDataTypesL(m_fourCC, settings); - break; - - case QAudio::AudioInput: - settings.iState = EMMFStateRecording; - devsound.GetSupportedInputDataTypesL(m_fourCC, settings); - break; - - default: - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode"); - } -} - -namespace Utils { - -//----------------------------------------------------------------------------- -// Static data -//----------------------------------------------------------------------------- - -// Sample rate / frequency - -typedef TMMFSampleRate SampleRateNative; -typedef int SampleRateQt; - -const int SampleRateCount = 12; - -const SampleRateNative SampleRateListNative[SampleRateCount] = { - EMMFSampleRate8000Hz - , EMMFSampleRate11025Hz - , EMMFSampleRate12000Hz - , EMMFSampleRate16000Hz - , EMMFSampleRate22050Hz - , EMMFSampleRate24000Hz - , EMMFSampleRate32000Hz - , EMMFSampleRate44100Hz - , EMMFSampleRate48000Hz - , EMMFSampleRate64000Hz - , EMMFSampleRate88200Hz - , EMMFSampleRate96000Hz -}; - -const SampleRateQt SampleRateListQt[SampleRateCount] = { - 8000 - , 11025 - , 12000 - , 16000 - , 22050 - , 24000 - , 32000 - , 44100 - , 48000 - , 64000 - , 88200 - , 96000 -}; - -// Channels - -typedef TMMFMonoStereo ChannelsNative; -typedef int ChannelsQt; - -const int ChannelsCount = 2; - -const ChannelsNative ChannelsListNative[ChannelsCount] = { - EMMFMono - , EMMFStereo -}; - -const ChannelsQt ChannelsListQt[ChannelsCount] = { - 1 - , 2 -}; - -// Encoding - -const int EncodingCount = 6; - -const TUint32 EncodingFourCC[EncodingCount] = { - KMMFFourCCCodePCM8 // 0 - , KMMFFourCCCodePCMU8 // 1 - , KMMFFourCCCodePCM16 // 2 - , KMMFFourCCCodePCMU16 // 3 - , KMMFFourCCCodePCM16B // 4 - , KMMFFourCCCodePCMU16B // 5 -}; - -// The characterised DevSound API specification states that the iEncoding -// field in TMMFCapabilities is ignored, and that the FourCC should be used -// to specify the PCM encoding. -// See "SGL.GT0287.102 Multimedia DevSound Baseline Compatibility.doc" in the -// mm_info/mm_docs repository. -const TMMFSoundEncoding EncodingNative[EncodingCount] = { - EMMFSoundEncoding16BitPCM // 0 - , EMMFSoundEncoding16BitPCM // 1 - , EMMFSoundEncoding16BitPCM // 2 - , EMMFSoundEncoding16BitPCM // 3 - , EMMFSoundEncoding16BitPCM // 4 - , EMMFSoundEncoding16BitPCM // 5 -}; - - -const int EncodingSampleSize[EncodingCount] = { - 8 // 0 - , 8 // 1 - , 16 // 2 - , 16 // 3 - , 16 // 4 - , 16 // 5 -}; - -const QAudioFormat::Endian EncodingByteOrder[EncodingCount] = { - QAudioFormat::LittleEndian // 0 - , QAudioFormat::LittleEndian // 1 - , QAudioFormat::LittleEndian // 2 - , QAudioFormat::LittleEndian // 3 - , QAudioFormat::BigEndian // 4 - , QAudioFormat::BigEndian // 5 -}; - -const QAudioFormat::SampleType EncodingSampleType[EncodingCount] = { - QAudioFormat::SignedInt // 0 - , QAudioFormat::UnSignedInt // 1 - , QAudioFormat::SignedInt // 2 - , QAudioFormat::UnSignedInt // 3 - , QAudioFormat::SignedInt // 4 - , QAudioFormat::UnSignedInt // 5 -}; - - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -// Helper functions for implementing parameter conversions - -template -bool findValue(const Input *inputArray, int length, Input input, int &index) { - bool result = false; - for (int i=0; !result && i -bool convertValue(const Input *inputArray, const Output *outputArray, - int length, Input input, Output &output) { - int index; - const bool result = findValue(inputArray, length, input, index); - if (result) - output = outputArray[index]; - return result; -} - -/** - * Macro which is used to generate the implementation of the conversion - * functions. The implementation is just a wrapper around the templated - * convertValue function, e.g. - * - * CONVERSION_FUNCTION_IMPL(SampleRate, Qt, Native) - * - * expands to - * - * bool SampleRateQtToNative(int input, TMMFSampleRate &output) { - * return convertValue - * (SampleRateListQt, SampleRateListNative, SampleRateCount, - * input, output); - * } - */ -#define CONVERSION_FUNCTION_IMPL(FieldLc, Field, Input, Output) \ -bool FieldLc##Input##To##Output(Field##Input input, Field##Output &output) { \ - return convertValue(Field##List##Input, \ - Field##List##Output, Field##Count, input, output); \ -} - -//----------------------------------------------------------------------------- -// Local helper functions -//----------------------------------------------------------------------------- - -CONVERSION_FUNCTION_IMPL(sampleRate, SampleRate, Qt, Native) -CONVERSION_FUNCTION_IMPL(sampleRate, SampleRate, Native, Qt) -CONVERSION_FUNCTION_IMPL(channels, Channels, Qt, Native) -CONVERSION_FUNCTION_IMPL(channels, Channels, Native, Qt) - -bool sampleInfoQtToNative(int inputSampleSize, - QAudioFormat::Endian inputByteOrder, - QAudioFormat::SampleType inputSampleType, - TUint32 &outputFourCC, - TMMFSoundEncoding &outputEncoding) { - - bool found = false; - - for (int i=0; i &frequencies, - QList &channels, - QList &sampleSizes, - QList &byteOrders, - QList &sampleTypes) { - - frequencies.clear(); - sampleSizes.clear(); - byteOrders.clear(); - sampleTypes.clear(); - channels.clear(); - - for (int i=0; i -#include -#include -#include -#include "symbianaudio.h" - -QT_BEGIN_NAMESPACE - -namespace SymbianAudio { - -/* - * Helper class for querying DevSound codec / format support - */ -class DevSoundCapabilities { -public: - DevSoundCapabilities(CMMFDevSound &devsound, QAudio::Mode mode); - ~DevSoundCapabilities(); - - const RArray& fourCC() const { return m_fourCC; } - const TMMFCapabilities& caps() const { return m_caps; } - -private: - void constructL(CMMFDevSound &devsound, QAudio::Mode mode); - -private: - RArray m_fourCC; - TMMFCapabilities m_caps; -}; - -namespace Utils { - -/** - * Convert native audio capabilities to QAudio lists. - */ -void capabilitiesNativeToQt(const DevSoundCapabilities &caps, - QList &frequencies, - QList &channels, - QList &sampleSizes, - QList &byteOrders, - QList &sampleTypes); - -/** - * Check whether format is supported. - */ -bool isFormatSupported(const QAudioFormat &format, - const DevSoundCapabilities &caps); - -/** - * Convert QAudioFormat to native format types. - * - * Note that, despite the name, DevSound uses TMMFCapabilities to specify - * single formats as well as capabilities. - * - * Note that this function does not modify outputFormat.iBufferSize. - */ -bool formatQtToNative(const QAudioFormat &inputFormat, - TUint32 &outputFourCC, - TMMFCapabilities &outputFormat); - -/** - * Convert internal states to QAudio states. - */ -QAudio::State stateNativeToQt(State nativeState, - QAudio::State initializingState); - -/** - * Convert data length to number of samples. - */ -qint64 bytesToSamples(const QAudioFormat &format, qint64 length); - -/** - * Convert number of samples to data length. - */ -qint64 samplesToBytes(const QAudioFormat &format, qint64 samples); - -} // namespace Utils -} // namespace SymbianAudio - -QT_END_NAMESPACE - -#endif diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 86deb40..1b1e965 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -78,12 +78,6 @@ symbian: { DEPLOYMENT += phonon_backend_plugins } - contains(QT_CONFIG, audio-backend) { - qaudio_backend_plugins.sources += qaudio.dll - qaudio_backend_plugins.path = c:$$QT_PLUGINS_BASE_DIR/audio - DEPLOYMENT += qaudio_backend_plugins - } - # Support backup & restore for Qt libraries qtbackup.sources = backup_registration.xml qtbackup.path = c:/private/10202D56/import/packages/$$replace(TARGET.UID3, 0x,) -- cgit v0.12 From a591b4c3a537757781197dd78ad326c27c3aef66 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Sun, 14 Mar 2010 17:14:07 +0100 Subject: Typo fix in qtestlib Reviewed-by: TrustMe --- src/testlib/qtestcase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 5eff8a8..6591481 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -964,7 +964,7 @@ static void qParseArgs(int argc, char *argv[]) " -xunitxml : Outputs results as XML XUnit document\n" " -xml : Outputs results as XML document\n" " -lightxml : Outputs results as stream of XML tags\n" - " -flush : Flushes the resutls\n" + " -flush : Flushes the results\n" " -o filename: Writes all output into a file\n" " -silent : Only outputs warnings and failures\n" " -v1 : Print enter messages for each testfunction\n" -- cgit v0.12 From 6eb6424a12dfa672afa8c2602a067699e09c0db9 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 10 Mar 2010 13:37:04 +0100 Subject: QSslKey: Do not make OpenSSL prompt for a password on stdin Task-number: QTBUG-2515 Reviewed-by: Andreas Aardal Hanssen --- src/network/ssl/qsslkey.cpp | 4 +- tests/auto/qsslkey/rsa-with-passphrase.pem | 18 +++++++ tests/auto/qsslkey/rsa-without-passphrase.pem | 15 ++++++ tests/auto/qsslkey/tst_qsslkey.cpp | 72 +++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 tests/auto/qsslkey/rsa-with-passphrase.pem create mode 100644 tests/auto/qsslkey/rsa-without-passphrase.pem diff --git a/src/network/ssl/qsslkey.cpp b/src/network/ssl/qsslkey.cpp index 41b2384..da39662 100644 --- a/src/network/ssl/qsslkey.cpp +++ b/src/network/ssl/qsslkey.cpp @@ -119,9 +119,7 @@ void QSslKeyPrivate::decodePem(const QByteArray &pem, const QByteArray &passPhra if (!bio) return; - void *phrase = passPhrase.isEmpty() - ? (void *)0 - : (void *)passPhrase.constData(); + void *phrase = (void *)passPhrase.constData(); if (algorithm == QSsl::Rsa) { RSA *result = (type == QSsl::PublicKey) diff --git a/tests/auto/qsslkey/rsa-with-passphrase.pem b/tests/auto/qsslkey/rsa-with-passphrase.pem new file mode 100644 index 0000000..cb29bec --- /dev/null +++ b/tests/auto/qsslkey/rsa-with-passphrase.pem @@ -0,0 +1,18 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-CBC,36BD1242254C5E1E + +sqt8qlQfkjJiz0djd0WYjhN/IGxA/nU/wVKuf5RWDAghDBrABzJ3dU4Jh1WIsS4+ +f22TBr6fwgjpPxGkt361Z9oxon/QeyBZLFtyUxnFSqZcVMMR3vndtMyYJbVKjRm1 +lvF3BjFWNh6+SZe20cut2GiUJDqhw7RbjaAN6LaCpFqwusY6vbjW6vzB8ezDvLou +5jQAkwArGoI0KqUMwBOYukiWdBA0iERavspKGRnB3mGtgv5ziTEFzx58mn1Lv3Qs +LYQqTYgzpFyAMP9SZaRv4m/y5O9foAXnlh0GhmDWBQ2D5flwZqrIAzoJ5BcZKU6/ +HJCh4snw3kheeE8NhrlzypEONedvu4ifUbqN5idMU7S4t40NAmQ/dF0Z4wDen/M/ +iFbt5tTWh6sXK82XzJtAfprH07odtJHK7CMeurCi5BupmnLtPbUrl6hpKItBzu+g +7MB5AyNk548V9Y8+kKBtEG5EgYZrMYX4yqQ+Z8F1hy0UUMXu9cAnO06OTavxLtWJ +ikmwYJNy421Hj+oZVSagCUILQyUfgx6fXWwDRqy/stlX+hpPPjVmd/A2WBm5x/Sf +5CGfUtddZRuAZpChBXV6a/R+nMzDXhkKl4XTkN8hg3yXLY6xy3CR3RIYDlKkn85y +VziP32V6Bc8ucGifsZLNnvj8CFXTZP+8CWun9yLSkcq+wm4cQOLswztEMA8bbPJQ +g7Gp59BC4ofN5bMZ1R1z+l96x+YMY9btkyjE1uEyRT88dHwxnkhC5AKBx2P6sg0C +doe5Dh8Ny5Ic24ibwyvZbAS46tSVdha7ACGnGXV4Z3iqBfN0b0UNmw== +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/qsslkey/rsa-without-passphrase.pem b/tests/auto/qsslkey/rsa-without-passphrase.pem new file mode 100644 index 0000000..f7c834b --- /dev/null +++ b/tests/auto/qsslkey/rsa-without-passphrase.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQC1mZlLC6g8/vaw8XEOQ59gwQ5WxIvcKCSx7B5SHaeN8zzbENpl +32BtyfrCccHF7j6qwfMZ2RwM5RTlFw/eBF4SSXAgp/P5CgcugSs1dOJUfPveos/5 +h3fmnUcKeQIU4m5EGcQicmR8//WUUfdtHDp/fJ0dRXcY2tTOx89vNPEtgwIDAQAB +AoGBAKqE2f4vqf/sYPPxInmEYclWPgKXd8R4JUy0LBxrIAQYXBJPluOFhmRQ/hdK +/eq/NTTd/UlOJhqtmJsstoeAjlsELl2AejX2n1B9aSffQ0WzdB5gVMNotPGRKRIG +eOq2pp2JOFkGps11LUAqDEMNUb3EV6HiBucoGEOUpdITLrRxAkEA4Ul3o44wMvIb +muwp7/erSvDMWRZ1GjksEmBMAHL6y8avZd9UgrjHeCy8uHXrT0id4Cig8FA+nQA5 +UwTr9y5e9wJBAM5bc8xuAuCg4Si3exssFfxQIxFTmPzhkVubglO9IcLqfXLl3k5S +CxgRb/4pBMKVRCMRXAkaZpjJqTIofjp4ptUCQQC4hySnot932zchPi9bjtGPII1A +q1RfllSy+I1IEOW745HnL3ZZXGCF3p71uCB1YFVwNdcc/51Jm9VYWr+sRx8hAkBL +KoTDsk7aA8AAVNVC0Iwxm/8qEIlpk8Ce3cZbOklR9pg7gf+4B6qC2dcxfT9+oWBw +ZaJgrn0wqkQ3QQi5w7kBAkBAR2tKc2OqnljMPnXYEreRyHHjhqCsJYFAE7u16cY/ +NQGJq9jBAD5WANclrYRxKtD6yohi+Y7Vi7+SXve3pGdF +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/qsslkey/tst_qsslkey.cpp b/tests/auto/qsslkey/tst_qsslkey.cpp index d156344..3c8ae11 100644 --- a/tests/auto/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/qsslkey/tst_qsslkey.cpp @@ -99,6 +99,7 @@ private slots: void toEncryptedPemOrDer_data(); void toEncryptedPemOrDer(); + void passphraseChecks(); #endif }; @@ -371,6 +372,77 @@ void tst_QSslKey::toEncryptedPemOrDer() // ### add a test to verify that public keys are _decrypted_ correctly (by the ctor) } +void tst_QSslKey::passphraseChecks() +{ + { + QString fileName(SRCDIR "/rsa-with-passphrase.pem"); + QFile keyFile(fileName); + QVERIFY(keyFile.exists()); + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey); + QVERIFY(key.isNull()); // null passphrase => should not be able to decode key + } + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, ""); + QVERIFY(key.isNull()); // empty passphrase => should not be able to decode key + } + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "WRONG!"); + QVERIFY(key.isNull()); // wrong passphrase => should not be able to decode key + } + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "123"); + QVERIFY(!key.isNull()); // correct passphrase + } + } + + { + // be sure and check a key without passphrase too + QString fileName(SRCDIR "/rsa-without-passphrase.pem"); + QFile keyFile(fileName); + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey); + QVERIFY(!key.isNull()); // null passphrase => should be able to decode key + } + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, ""); + QVERIFY(!key.isNull()); // empty passphrase => should be able to decode key + } + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "xxx"); + QVERIFY(!key.isNull()); // passphrase given but key is not encrypted anyway => should work + } + } +} + #endif QTEST_MAIN(tst_QSslKey) -- cgit v0.12