summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarah Smith <sarah.j.smith@nokia.com>2009-09-17 08:48:44 (GMT)
committerSarah Smith <sarah.j.smith@nokia.com>2009-09-17 08:48:44 (GMT)
commit2ec5d3977e454815a11ad0a9b6e95f77b7e17d0f (patch)
treee66b6cfc3f477966c713f68e5156dd914a516a53
parent11566a349f8b9d5b6bcaf1dff64e30266a55411f (diff)
parente7c36fc2e420f1cee4370020b9f50bb5a6dfe92a (diff)
downloadQt-2ec5d3977e454815a11ad0a9b6e95f77b7e17d0f.zip
Qt-2ec5d3977e454815a11ad0a9b6e95f77b7e17d0f.tar.gz
Qt-2ec5d3977e454815a11ad0a9b6e95f77b7e17d0f.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
-rw-r--r--src/3rdparty/phonon/gstreamer/mediaobject.cpp14
-rw-r--r--src/corelib/tools/qregexp.cpp95
-rw-r--r--src/corelib/tools/qregexp.h8
-rw-r--r--src/gui/painting/qpainter.cpp6
-rw-r--r--src/gui/text/qfontdatabase_mac.cpp31
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp10
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp32
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp11
-rw-r--r--tests/auto/qkeysequence/qkeysequence.pro4
-rw-r--r--tests/auto/qkeysequence/qkeysequence.qrc6
-rw-r--r--tests/auto/qkeysequence/qt_de.qmbin0 -> 186240 bytes
-rw-r--r--tests/auto/qkeysequence/tst_qkeysequence.cpp4
-rw-r--r--tests/auto/qregexp/tst_qregexp.cpp75
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp38
14 files changed, 299 insertions, 35 deletions
diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp
index 74fc1b4..13f9734 100644
--- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp
+++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp
@@ -965,11 +965,15 @@ void MediaObject::getStreamInfo()
gint64 titleCount;
GstFormat format = gst_format_get_by_nick("track");
if (gst_element_query_duration (m_pipeline, &format, &titleCount)) {
- int oldAvailableTitles = m_availableTitles;
- m_availableTitles = (int)titleCount;
- if (m_availableTitles != oldAvailableTitles) {
- emit availableTitlesChanged(m_availableTitles);
- m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this);
+ //check if returned format is still "track",
+ //gstreamer sometimes returns the total time, if tracks information is not available.
+ if (qstrcmp(gst_format_get_name(format), "track") == 0) {
+ int oldAvailableTitles = m_availableTitles;
+ m_availableTitles = (int)titleCount;
+ if (m_availableTitles != oldAvailableTitles) {
+ emit availableTitlesChanged(m_availableTitles);
+ m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this);
+ }
}
}
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 8d7a75d..1f23211 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -522,6 +522,10 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
outside, backslash has no special meaning.
\endtable
+ In the mode Wildcard, the wildcard characters cannot be
+ escaped. In the mode WildcardUnix, the character '\' escapes the
+ wildcard.
+
For example if we are in wildcard mode and have strings which
contain filenames we could identify HTML files with \bold{*.html}.
This will match zero or more characters followed by a dot followed
@@ -751,50 +755,100 @@ static void mergeInto(QVector<int> *a, const QVector<int> &b)
/*
Translates a wildcard pattern to an equivalent regular expression
pattern (e.g., *.cpp to .*\.cpp).
+
+ If enableEscaping is true, it is possible to escape the wildcard
+ characters with \
*/
-static QString wc2rx(const QString &wc_str)
+static QString wc2rx(const QString &wc_str, const bool enableEscaping)
{
- int wclen = wc_str.length();
+ const int wclen = wc_str.length();
QString rx;
int i = 0;
+ bool isEscaping = false; // the previous character is '\'
const QChar *wc = wc_str.unicode();
+
while (i < wclen) {
- QChar c = wc[i++];
+ const QChar c = wc[i++];
switch (c.unicode()) {
+ case '\\':
+ if (enableEscaping) {
+ if (isEscaping) {
+ rx += QLatin1String("\\\\");
+ } // we insert the \\ later if necessary
+ if (i+1 == wclen) { // the end
+ rx += QLatin1String("\\\\");
+ }
+ } else {
+ rx += QLatin1String("\\\\");
+ }
+ isEscaping = true;
+ break;
case '*':
- rx += QLatin1String(".*");
+ if (isEscaping) {
+ rx += QLatin1String("\\*");
+ isEscaping = false;
+ } else {
+ rx += QLatin1String(".*");
+ }
break;
case '?':
- rx += QLatin1Char('.');
+ if (isEscaping) {
+ rx += QLatin1String("\\?");
+ isEscaping = false;
+ } else {
+ rx += QLatin1Char('.');
+ }
+
break;
case '$':
case '(':
case ')':
case '+':
case '.':
- case '\\':
case '^':
case '{':
case '|':
case '}':
+ if (isEscaping) {
+ isEscaping = false;
+ rx += QLatin1String("\\\\");
+ }
rx += QLatin1Char('\\');
rx += c;
break;
- case '[':
- rx += c;
- if (wc[i] == QLatin1Char('^'))
- rx += wc[i++];
- if (i < wclen) {
- if (rx[i] == QLatin1Char(']'))
- rx += wc[i++];
- while (i < wclen && wc[i] != QLatin1Char(']')) {
- if (wc[i] == QLatin1Char('\\'))
- rx += QLatin1Char('\\');
+ case '[':
+ if (isEscaping) {
+ isEscaping = false;
+ rx += QLatin1String("\\[");
+ } else {
+ rx += c;
+ if (wc[i] == QLatin1Char('^'))
rx += wc[i++];
+ if (i < wclen) {
+ if (rx[i] == QLatin1Char(']'))
+ rx += wc[i++];
+ while (i < wclen && wc[i] != QLatin1Char(']')) {
+ if (wc[i] == QLatin1Char('\\'))
+ rx += QLatin1Char('\\');
+ rx += wc[i++];
+ }
}
}
+ break;
+
+ case ']':
+ if(isEscaping){
+ isEscaping = false;
+ rx += QLatin1String("\\");
+ }
+ rx += c;
break;
+
default:
+ if(isEscaping){
+ isEscaping = false;
+ rx += QLatin1String("\\\\");
+ }
rx += c;
}
}
@@ -1272,7 +1326,10 @@ Q_CORE_EXPORT QString qt_regexp_toCanonical(const QString &pattern, QRegExp::Pat
switch (patternSyntax) {
#ifndef QT_NO_REGEXP_WILDCARD
case QRegExp::Wildcard:
- return wc2rx(pattern);
+ return wc2rx(pattern, false);
+ break;
+ case QRegExp::WildcardUnix:
+ return wc2rx(pattern, true);
break;
#endif
case QRegExp::FixedString:
@@ -3715,6 +3772,10 @@ static void invalidateEngine(QRegExpPrivate *priv)
similar to that used by shells (command interpreters) for "file
globbing". See \l{Wildcard Matching}.
+ \value WildcardUnix This is similar to Wildcard but with the
+ behavior of a Unix shell. The wildcard characters can be escaped
+ with the character "\".
+
\value FixedString The pattern is a fixed string. This is
equivalent to using the RegExp pattern on a string in
which all metacharacters are escaped using escape().
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index c03e9e4..1a7cf53 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -61,7 +61,13 @@ class QStringList;
class Q_CORE_EXPORT QRegExp
{
public:
- enum PatternSyntax { RegExp, Wildcard, FixedString, RegExp2, W3CXmlSchema11 };
+ enum PatternSyntax {
+ RegExp,
+ Wildcard,
+ FixedString,
+ RegExp2,
+ WildcardUnix,
+ W3CXmlSchema11 };
enum CaretMode { CaretAtZero, CaretAtOffset, CaretWontMatch };
QRegExp();
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index b3aef71..53d2102 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -7535,7 +7535,11 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,
bool hidemnmemonic = (tf & Qt::TextHideMnemonic);
Qt::LayoutDirection layout_direction;
- if(option)
+ if (tf & Qt::TextForceLeftToRight)
+ layout_direction = Qt::LeftToRight;
+ else if (tf & Qt::TextForceRightToLeft)
+ layout_direction = Qt::RightToLeft;
+ else if (option)
layout_direction = option->textDirection();
else if (painter)
layout_direction = painter->layoutDirection();
diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp
index d65910c..2584003 100644
--- a/src/gui/text/qfontdatabase_mac.cpp
+++ b/src/gui/text/qfontdatabase_mac.cpp
@@ -308,6 +308,21 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
if (familyRef) {
fontRef = ATSFontFindFromName(QCFString(db->families[k]->name), kATSOptionFlagsDefault);
goto FamilyFound;
+ } else {
+#if defined(QT_MAC_USE_COCOA)
+ // ATS and CT disagrees on what the family name should be,
+ // use CT to look up the font if ATS fails.
+ QCFString familyName = QString::fromAscii(family_name);
+ QCFType<CTFontRef> CTfontRef = CTFontCreateWithName(familyName, 12, NULL);
+ QCFType<CTFontDescriptorRef> fontDescriptor = CTFontCopyFontDescriptor(CTfontRef);
+ QCFString displayName = (CFStringRef)CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontDisplayNameAttribute);
+
+ familyRef = ATSFontFamilyFindFromName(displayName, kATSOptionFlagsDefault);
+ if (familyRef) {
+ fontRef = ATSFontFindFromName(displayName, kATSOptionFlagsDefault);
+ goto FamilyFound;
+ }
+#endif
}
}
}
@@ -456,11 +471,27 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
return;
fnt->families.clear();
+#if defined(QT_MAC_USE_COCOA)
+ // Make sure that the family name set on the font matches what
+ // kCTFontFamilyNameAttribute returns in initializeDb().
+ // So far the best solution seems find the installed font
+ // using CoreText and get the family name from it.
+ // (ATSFontFamilyGetName appears to be the correct API, but also
+ // returns the font display name.)
+ for(int i = 0; i < containedFonts.size(); ++i) {
+ QCFString fontPostScriptName;
+ ATSFontGetPostScriptName(containedFonts[i], kATSOptionFlagsDefault, &fontPostScriptName);
+ QCFType<CTFontDescriptorRef> font = CTFontDescriptorCreateWithNameAndSize(fontPostScriptName, 14);
+ QCFString familyName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
+ fnt->families.append(familyName);
+ }
+#else
for(int i = 0; i < containedFonts.size(); ++i) {
QCFString family;
ATSFontGetName(containedFonts[i], kATSOptionFlagsDefault, &family);
fnt->families.append(family);
}
+#endif
fnt->handle = handle;
}
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index 22f446d..7cf5e8b 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -882,6 +882,11 @@ bool QODBCResult::reset (const QString& query)
return false;
}
+ SQLINTEGER isScrollable, bufferLength;
+ r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength);
+ if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
+ setForwardOnly(isScrollable==SQL_NONSCROLLABLE);
+
SQLSMALLINT count;
SQLNumResultCols(d->hStmt, &count);
if (count) {
@@ -1500,6 +1505,11 @@ bool QODBCResult::exec()
return false;
}
+ SQLINTEGER isScrollable, bufferLength;
+ r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength);
+ if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
+ setForwardOnly(isScrollable==SQL_NONSCROLLABLE);
+
SQLSMALLINT count;
SQLNumResultCols(d->hStmt, &count);
if (count) {
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 304330e..fa163d8 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -246,6 +246,7 @@ private slots:
void itemClipsToShape();
void itemClipsChildrenToShape();
void itemClipsChildrenToShape2();
+ void itemClipsChildrenToShape3();
void itemClipsTextChildToShape();
void itemClippingDiscovery();
void ancestorFlags();
@@ -5050,6 +5051,37 @@ void tst_QGraphicsItem::itemClipsChildrenToShape2()
#endif
}
+void tst_QGraphicsItem::itemClipsChildrenToShape3()
+{
+ // Construct a scene with nested children, each 50 pixels offset from the elder.
+ // Set a top-level clipping flag
+ QGraphicsScene scene;
+ QGraphicsRectItem *parent = scene.addRect( 0, 0, 150, 150 );
+ QGraphicsRectItem *child = scene.addRect( 0, 0, 150, 150 );
+ QGraphicsRectItem *grandchild = scene.addRect( 0, 0, 150, 150 );
+ child->setParentItem(parent);
+ grandchild->setParentItem(child);
+ child->setPos( 50, 50 );
+ grandchild->setPos( 50, 50 );
+ parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+
+ QCOMPARE(scene.itemAt(25,25), (QGraphicsItem *)parent);
+ QCOMPARE(scene.itemAt(75,75), (QGraphicsItem *)child);
+ QCOMPARE(scene.itemAt(125,125), (QGraphicsItem *)grandchild);
+ QCOMPARE(scene.itemAt(175,175), (QGraphicsItem *)0);
+
+ // Move child to fully overlap the parent. The grandchild should
+ // now occupy two-thirds of the scene
+ child->prepareGeometryChange();
+ child->setPos( 0, 0 );
+
+ QCOMPARE(scene.itemAt(25,25), (QGraphicsItem *)child);
+ QCOMPARE(scene.itemAt(75,75), (QGraphicsItem *)grandchild);
+ QCOMPARE(scene.itemAt(125,125), (QGraphicsItem *)grandchild);
+ QCOMPARE(scene.itemAt(175,175), (QGraphicsItem *)0);
+}
+
+
void tst_QGraphicsItem::itemClipsTextChildToShape()
{
// Construct a scene with a rect that clips its children, with one text
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index cab8fda..c0d5051 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -719,13 +719,14 @@ void tst_QImageReader::gifHandlerBugs()
void tst_QImageReader::animatedGif()
{
- QImageReader io(prefix + "qt.gif");
- QImage image= io.read();
- int i=0;
+ QImageReader io(":images/qt.gif");
+ QImage image = io.read();
+ QVERIFY(!image.isNull());
+ int i = 0;
while(!image.isNull()){
- QString frameName = QString(prefix + "qt%1.gif").arg(++i);
+ QString frameName = QString(":images/qt%1.gif").arg(++i);
QCOMPARE(image, QImage(frameName));
- image=io.read();
+ image = io.read();
}
}
#endif
diff --git a/tests/auto/qkeysequence/qkeysequence.pro b/tests/auto/qkeysequence/qkeysequence.pro
index 6566340..bd85402 100644
--- a/tests/auto/qkeysequence/qkeysequence.pro
+++ b/tests/auto/qkeysequence/qkeysequence.pro
@@ -1,6 +1,4 @@
load(qttest_p4)
SOURCES += tst_qkeysequence.cpp
-TRANSLATIONS += keys_de.ts
-
-
+RESOURCES += qkeysequence.qrc \ No newline at end of file
diff --git a/tests/auto/qkeysequence/qkeysequence.qrc b/tests/auto/qkeysequence/qkeysequence.qrc
new file mode 100644
index 0000000..e224faa
--- /dev/null
+++ b/tests/auto/qkeysequence/qkeysequence.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource>
+ <file>keys_de.qm</file>
+ <file>qt_de.qm</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/qkeysequence/qt_de.qm b/tests/auto/qkeysequence/qt_de.qm
new file mode 100644
index 0000000..595e4d7
--- /dev/null
+++ b/tests/auto/qkeysequence/qt_de.qm
Binary files differ
diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp
index 88d1d55..1c257bf 100644
--- a/tests/auto/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp
@@ -166,9 +166,9 @@ tst_QKeySequence::~tst_QKeySequence()
void tst_QKeySequence::initTestCase()
{
ourTranslator = new QTranslator(this);
- ourTranslator->load(QLatin1String("keys_de"), ".");
+ ourTranslator->load(":/keys_de");
qtTranslator = new QTranslator(this);
- qtTranslator->load(QLatin1String("qt_de"), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+ qtTranslator->load(":/qt_de");
}
void tst_QKeySequence::operatorQString_data()
diff --git a/tests/auto/qregexp/tst_qregexp.cpp b/tests/auto/qregexp/tst_qregexp.cpp
index 7496ec6..86d831e 100644
--- a/tests/auto/qregexp/tst_qregexp.cpp
+++ b/tests/auto/qregexp/tst_qregexp.cpp
@@ -70,6 +70,10 @@ private slots:
void matchedLength();
void wildcard_data();
void wildcard();
+ void testEscapingWildcard_data();
+ void testEscapingWildcard();
+ void testInvalidWildcard_data();
+ void testInvalidWildcard();
void caretAnchoredOptimization();
void isEmpty();
void prepareEngineOptimization();
@@ -909,10 +913,79 @@ void tst_QRegExp::wildcard()
QFETCH( int, foundIndex );
QRegExp r( rxp );
- r.setPatternSyntax(QRegExp::Wildcard);
+ r.setPatternSyntax(QRegExp::WildcardUnix);
QCOMPARE( r.indexIn( string ), foundIndex );
}
+void tst_QRegExp::testEscapingWildcard_data(){
+ QTest::addColumn<QString>("pattern");
+ QTest::addColumn<QString>("teststring");
+ QTest::addColumn<bool>("isMatching");
+
+ QTest::newRow("[ Not escaped") << "[Qt;" << "[Qt;" << false;
+ QTest::newRow("[ Escaped") << "\\[Qt;" << "[Qt;" << true;
+
+ QTest::newRow("] Not escaped") << "]Ik;" << "]Ik;" << false;
+ QTest::newRow("] Escaped") << "\\]Ip;" << "]Ip;" << true;
+
+ QTest::newRow("? Not escaped valid") << "?Ou:" << ".Ou:" << true;
+ QTest::newRow("? Not escaped invalid") << "?Tr;" << "Tr;" << false;
+ QTest::newRow("? Escaped") << "\\?O;" << "?O;" << true;
+
+ QTest::newRow("[] not escaped") << "[lL]" << "l" << true;
+ QTest::newRow("case [[]") << "[[abc]" << "[" << true;
+ QTest::newRow("case []abc] match ]") << "[]abc]" << "]" << true;
+ QTest::newRow("case []abc] match a") << "[]abc]" << "a" << true;
+ QTest::newRow("case [abc] match a") << "[abc]" << "a" << true;
+ QTest::newRow("case []] don't match [") << "[]abc]" << "[" << false;
+ QTest::newRow("case [^]abc] match d") << "[^]abc]" << "d" << true;
+ QTest::newRow("case [^]abc] don't match ]") << "[^]abc]" << "]" << false;
+
+ QTest::newRow("* Not escaped with char") << "*Te;" << "12345Te;" << true;
+ QTest::newRow("* Not escaped without char") << "*Ch;" << "Ch;" << true;
+ QTest::newRow("* Not escaped invalid") << "*Ro;" << "o;" << false;
+ QTest::newRow("* Escaped") << "\\[Cks;" << "[Cks;" << true;
+
+ QTest::newRow("a true '\\' in input") << "\\Qt;" << "\\Qt;" << true;
+ QTest::newRow("two true '\\' in input") << "\\\\Qt;" << "\\\\Qt;" << true;
+ QTest::newRow("a '\\' at the end") << "\\\\Qt;" << "\\\\Qt;" << true;
+
+}
+void tst_QRegExp::testEscapingWildcard(){
+ QFETCH(QString, pattern);
+
+ QRegExp re(pattern);
+ re.setPatternSyntax(QRegExp::WildcardUnix);
+
+ QFETCH(QString, teststring);
+ QFETCH(bool, isMatching);
+ QCOMPARE(re.exactMatch(teststring), isMatching);
+}
+
+void tst_QRegExp::testInvalidWildcard_data(){
+ QTest::addColumn<QString>("pattern");
+ QTest::addColumn<bool>("isValid");
+
+ QTest::newRow("valid []") << "[abc]" << true;
+ QTest::newRow("invalid [") << "[abc" << false;
+ QTest::newRow("ending [") << "abc[" << false;
+ QTest::newRow("ending ]") << "abc]" << false;
+ QTest::newRow("ending [^") << "abc[^" << false;
+ QTest::newRow("ending [\\") << "abc[\\" << false;
+ QTest::newRow("ending []") << "abc[]" << false;
+ QTest::newRow("ending [[") << "abc[[" << false;
+
+}
+void tst_QRegExp::testInvalidWildcard(){
+ QFETCH(QString, pattern);
+
+ QRegExp re(pattern);
+ re.setPatternSyntax(QRegExp::Wildcard);
+
+ QFETCH(bool, isValid);
+ QCOMPARE(re.isValid(), isValid);
+}
+
void tst_QRegExp::caretAnchoredOptimization()
{
QString s = "---babnana----";
diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp
index 4bea26d..eb95d611c 100644
--- a/tests/auto/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp
@@ -191,6 +191,9 @@ private slots:
void task_233829_data() { generic_data("QPSQL"); }
void task_233829();
+ void sqlServerReturn0_data() { generic_data(); }
+ void sqlServerReturn0();
+
private:
// returns all database connections
@@ -312,6 +315,13 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db )
tablenames << qTableName( "task_250026" );
tablenames << qTableName( "task_234422" );
+ if (tst_Databases::isSqlServer( db )) {
+ QSqlQuery q( db );
+ q.exec("DROP PROCEDURE " + qTableName("test141895_proc"));
+ }
+
+ tablenames << qTableName("test141895");
+
tst_Databases::safeDropTables( db, tablenames );
}
@@ -2808,5 +2818,33 @@ void tst_QSqlQuery::task_233829()
QVERIFY_SQL(q,exec());
}
+void tst_QSqlQuery::sqlServerReturn0()
+{
+ QFETCH( QString, dbName );
+ QSqlDatabase db = QSqlDatabase::database( dbName );
+ CHECK_DATABASE( db );
+ if (!tst_Databases::isSqlServer( db ))
+ QSKIP("SQL Server specific test", SkipSingle);
+
+ QString tableName(qTableName("test141895")), procName(qTableName("test141895_proc"));
+ QSqlQuery q( db );
+ q.exec("DROP TABLE " + tableName);
+ q.exec("DROP PROCEDURE " + procName);
+ QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+" (id integer)"));
+ QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" (id) VALUES (1)"));
+ QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" (id) VALUES (2)"));
+ QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" (id) VALUES (2)"));
+ QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" (id) VALUES (3)"));
+ QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" (id) VALUES (1)"));
+ QVERIFY_SQL(q, exec("CREATE PROCEDURE "+procName+
+ " AS "
+ "SELECT * FROM "+tableName+" WHERE ID = 2 "
+ "RETURN 0"));
+
+ QVERIFY_SQL(q, exec("{CALL "+procName+"}"));
+
+ QVERIFY_SQL(q, next());
+}
+
QTEST_MAIN( tst_QSqlQuery )
#include "tst_qsqlquery.moc"