From f2bfd1f7913e21f8946ea9aa2f96ee4e38a942eb Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 8 Jun 2011 16:01:33 +0200 Subject: Fix errors in qsocketnotifier test Fixed the posixSockets test on linux Skipped the bogusFds test everywhere but symbian, as there is no behavioural consistency of QSocketNotifier with invalid fds between different OS. Reviewed-By: mread --- tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp index 550cef9..eb9a260 100644 --- a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp @@ -57,7 +57,7 @@ #include #endif #include -#include +#include class tst_QSocketNotifier : public QObject { @@ -180,7 +180,7 @@ void tst_QSocketNotifier::unexpectedDisconnection() // we have to wait until sequence value changes // as any event can make us jump out processing QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); - QVERIFY(timer.isActive); //escape if test would hang + QVERIFY(timer.isActive()); //escape if test would hang } while(tester.sequence <= 0); QVERIFY(readEnd1.state() == QAbstractSocket::ConnectedState); @@ -294,7 +294,7 @@ void tst_QSocketNotifier::posixSockets() QTestEventLoop::instance().enterLoop(3); QCOMPARE(readSpy.count(), 1); - QCOMPARE(writeSpy.count(), 0); + writeSpy.clear(); //depending on OS, write notifier triggers on creation or not. QCOMPARE(errorSpy.count(), 0); char buffer[100]; @@ -315,18 +315,17 @@ void tst_QSocketNotifier::posixSockets() void tst_QSocketNotifier::bogusFds() { -#ifndef Q_OS_WIN +#ifndef Q_OS_SYMBIAN + //behaviour of QSocketNotifier with an invalid fd is totally different across OS + //main point of this test was to check symbian backend doesn't crash + QSKIP("test only for symbian", SkipAll); +#else QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error"); -#endif QSocketNotifier max(std::numeric_limits::max(), QSocketNotifier::Read); QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Invalid socket specified"); -#ifndef Q_OS_WIN QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error"); -#endif QSocketNotifier min(std::numeric_limits::min(), QSocketNotifier::Write); -#ifndef Q_OS_WIN QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error"); -#endif //bogus magic number is the first pseudo socket descriptor from symbian socket engine. QSocketNotifier bogus(0x40000000, QSocketNotifier::Exception); QSocketNotifier largestlegal(FD_SETSIZE - 1, QSocketNotifier::Read); @@ -350,6 +349,7 @@ void tst_QSocketNotifier::bogusFds() QCOMPARE(minspy.count(), 0); QCOMPARE(bogspy.count(), 0); QCOMPARE(llspy.count(), 0); +#endif } QTEST_MAIN(tst_QSocketNotifier) -- cgit v0.12 From 597e21952e7fc2a18f09dda4619c23c30ea2dde6 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 9 Jun 2011 17:34:12 +0200 Subject: add a benchmark for QCFString optimizations follows... Merge-request: 2615 Reviewed-by: Denis Dzyubenko --- tests/benchmarks/corelib/tools/qstring/main.cpp | 100 ++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp index 87322a5..5b5f0f7 100644 --- a/tests/benchmarks/corelib/tools/qstring/main.cpp +++ b/tests/benchmarks/corelib/tools/qstring/main.cpp @@ -48,7 +48,12 @@ #define SRCDIR "" #endif +#if !defined(QWS) && defined(Q_OS_MAC) +#include "private/qcore_mac_p.h" +#endif + #ifdef Q_OS_UNIX +#include #include #include #endif @@ -76,6 +81,18 @@ private slots: void fromLatin1Alternatives() const; void fromUtf8Alternatives_data() const; void fromUtf8Alternatives() const; + +#if !defined(QWS) && defined(Q_OS_MAC) + void QCFString_data() const; + void QCFString_toCFStringRef_data() const; + void QCFString_toCFStringRef() const; + void QCFString_operatorCFStringRef_data() const; + void QCFString_operatorCFStringRef() const; + void QCFString_toQString_data() const; + void QCFString_toQString() const; + void QCFString_operatorQString_data() const; + void QCFString_operatorQString() const; +#endif // !defined(QWS) && defined(Q_OS_MAC) }; void tst_QString::equals() const @@ -2596,6 +2613,89 @@ void tst_QString::fromUtf8Alternatives() const } } +#if !defined(QWS) && defined(Q_OS_MAC) +void tst_QString::QCFString_data() const +{ + QTest::addColumn("string"); + + QString base(QLatin1String("I'm some cool string")); + QTest::newRow("base") << base; + + base = base.repeated(25); + QTest::newRow("25 bases") << base; + + QTest::newRow("raw 25 bases") << QString::fromRawData(base.constData(), base.size()); +} + +void tst_QString::QCFString_toCFStringRef_data() const +{ + QCFString_data(); +} + +void tst_QString::QCFString_toCFStringRef() const +{ + QFETCH(QString, string); + + QBENCHMARK { + CFStringRef cfstr = QCFString::toCFStringRef(string); + CFRelease(cfstr); + } +} + +void tst_QString::QCFString_operatorCFStringRef_data() const +{ + QCFString_data(); +} + +void tst_QString::QCFString_operatorCFStringRef() const +{ + QFETCH(QString, string); + + CFStringRef cfstr; + QBENCHMARK { + QCFString qcfstr(string); + cfstr = qcfstr; + } +} + +void tst_QString::QCFString_toQString_data() const +{ + QCFString_data(); +} + +void tst_QString::QCFString_toQString() const +{ + QFETCH(QString, string); + + QCFString qcfstr(string); + + QString qstr; + QBENCHMARK { + qstr = QCFString::toQString(qcfstr); + } + QVERIFY(qstr == string); +} + +void tst_QString::QCFString_operatorQString_data() const +{ + QCFString_data(); +} + +void tst_QString::QCFString_operatorQString() const +{ + QFETCH(QString, string); + + QCFString qcfstr_base(string); + + QString qstr; + QBENCHMARK { + QCFString qcfstr(qcfstr_base); + qstr = qcfstr; + } + QVERIFY(qstr == string); +} +#endif // !defined(QWS) && defined(Q_OS_MAC) + QTEST_MAIN(tst_QString) #include "main.moc" -- cgit v0.12 From bf540659718c78706622a6cf168387998dd725fd Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 9 Jun 2011 17:34:13 +0200 Subject: get rid of extra copying by some (unknown) reason, the QVarLengthArray was used as an intermediate buffer for the UniChar data that was copied again few lines later via the QString's c-tor; add check for (length == 0) as it equals to the old (!chars) test but avoids an unnecessary fallback code execution Merge-request: 2615 Reviewed-by: Denis Dzyubenko --- src/corelib/kernel/qcore_mac.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp index 0814c1a..e0dae37 100644 --- a/src/corelib/kernel/qcore_mac.cpp +++ b/src/corelib/kernel/qcore_mac.cpp @@ -41,22 +41,22 @@ #include #include -#include "qvarlengtharray.h" QT_BEGIN_NAMESPACE QString QCFString::toQString(CFStringRef str) { - if(!str) + if (!str) return QString(); + CFIndex length = CFStringGetLength(str); - const UniChar *chars = CFStringGetCharactersPtr(str); - if (chars) - return QString(reinterpret_cast(chars), length); + if (length == 0) + return QString(); - QVarLengthArray buffer(length); - CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data()); - return QString(reinterpret_cast(buffer.constData()), length); + QString string(length, Qt::Uninitialized); + CFStringGetCharacters(str, CFRangeMake(0, length), reinterpret_cast(const_cast(string.unicode()))); + + return string; } QCFString::operator QString() const -- cgit v0.12 From 628fd7d141013dcda06d13fa644f44029f317a8c Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 9 Jun 2011 17:34:14 +0200 Subject: get rid of extra copying (another one) in the static toCFStringRef(const QString &string) method, the string's lifecycle is unkown and thus, to ensure the data consistency, it copies the string's data to the newly created CFStringRef object. but operator CFStringRef() is an other case - here we know that the source string's lifetime is limited by the same QCFString object as the resulting CFStringRef; so, we could use the string's internal buffer as a CFStringRef's one w/o any visible changes (well, except of some speed-up :) ) Merge-request: 2615 Reviewed-by: Denis Dzyubenko --- src/corelib/kernel/qcore_mac.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp index e0dae37..80cbac9 100644 --- a/src/corelib/kernel/qcore_mac.cpp +++ b/src/corelib/kernel/qcore_mac.cpp @@ -74,8 +74,13 @@ CFStringRef QCFString::toCFStringRef(const QString &string) QCFString::operator CFStringRef() const { - if (!type) - const_cast(this)->type = toCFStringRef(string); + if (!type) { + const_cast(this)->type = + CFStringCreateWithCharactersNoCopy(0, + reinterpret_cast(string.unicode()), + string.length(), + kCFAllocatorNull); + } return type; } -- cgit v0.12 From 292a953258cac0107b820490b09231c0f700bdbe Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 9 Jun 2011 17:34:16 +0200 Subject: make the previous change foolproof in order to preserve the old behavior in a (corner) case where string was created from the raw data with a shorter lifecycle, just call QString's realloc() that will copy the data and thus guarantee it's consistence later. example: QCFString str; { QString qstr("I'm stupid"); str = QCFString(QString::fromRawData(qstr.data(), qstr.size()); } Merge-request: 2615 Reviewed-by: Denis Dzyubenko --- src/corelib/kernel/qcore_mac.cpp | 2 ++ src/corelib/tools/qstring.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp index 80cbac9..e45ef50 100644 --- a/src/corelib/kernel/qcore_mac.cpp +++ b/src/corelib/kernel/qcore_mac.cpp @@ -75,6 +75,8 @@ CFStringRef QCFString::toCFStringRef(const QString &string) QCFString::operator CFStringRef() const { if (!type) { + if (string.d->data != string.d->array) + const_cast(this)->string.realloc(); // ### Qt5: do we really need this stupid user protection? const_cast(this)->type = CFStringCreateWithCharactersNoCopy(0, reinterpret_cast(string.unicode()), diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index c61d09e..bf0a0ad 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -639,6 +639,7 @@ private: static Data *fromAscii_helper(const char *str, int size = -1); void replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen); friend class QCharRef; + friend class QCFString; friend class QTextCodec; friend class QStringRef; friend struct QAbstractConcatenable; -- cgit v0.12 From 2cb398e1d901e62384bb2b388761cfd18fc8804a Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 9 Jun 2011 17:34:17 +0200 Subject: move some internal helper functions from qglobal.cpp to qcore_mac* namely: void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding = 0, int len = -1); QString qt_mac_from_pascal_string(const Str255 pstr); OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref); OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec); remove relevant "extern" declarations all over the Qt sources Merge-request: 2615 Reviewed-by: Denis Dzyubenko --- src/corelib/global/qglobal.cpp | 55 ++--------------------------- src/corelib/kernel/qcore_mac.cpp | 50 ++++++++++++++++++++++++++ src/corelib/kernel/qcore_mac_p.h | 7 ++++ src/gui/dialogs/qfiledialog_mac.mm | 3 -- src/gui/kernel/qapplication_mac.mm | 1 - src/gui/kernel/qmime_mac.cpp | 4 --- src/gui/kernel/qt_mac.cpp | 1 - src/gui/text/qfontdatabase_mac.cpp | 2 -- src/opengl/qgl_mac.mm | 1 - src/qt3support/dialogs/q3filedialog_mac.cpp | 2 -- 10 files changed, 59 insertions(+), 67 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index c144871..f6eaedc 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1648,64 +1648,13 @@ static const unsigned int qt_one = 1; const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian); #endif -#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) +#if !defined(QWS) && defined(Q_OS_MAC) QT_BEGIN_INCLUDE_NAMESPACE #include "private/qcore_mac_p.h" #include "qnamespace.h" QT_END_INCLUDE_NAMESPACE -Q_CORE_EXPORT OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref) -{ - return FSPathMakeRef(reinterpret_cast(file.toUtf8().constData()), fsref, 0); -} - -// Don't use this function, it won't work in 10.5 (Leopard) and up -Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec) -{ - FSRef fsref; - OSErr ret = qt_mac_create_fsref(file, &fsref); - if (ret == noErr) - ret = FSGetCatalogInfo(&fsref, kFSCatInfoNone, 0, 0, spec, 0); - return ret; -} - -Q_CORE_EXPORT void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding=0, int len=-1) -{ - if(len == -1) - len = s.length(); -#if 0 - UnicodeMapping mapping; - mapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault, - kTextEncodingDefaultVariant, - kUnicode16BitFormat); - mapping.otherEncoding = (encoding ? encoding : ); - mapping.mappingVersion = kUnicodeUseLatestMapping; - - UnicodeToTextInfo info; - OSStatus err = CreateUnicodeToTextInfo(&mapping, &info); - if(err != noErr) { - qDebug("Qt: internal: Unable to create pascal string '%s'::%d [%ld]", - s.left(len).latin1(), (int)encoding, err); - return; - } - const int unilen = len * 2; - const UniChar *unibuf = (UniChar *)s.unicode(); - ConvertFromUnicodeToPString(info, unilen, unibuf, str); - DisposeUnicodeToTextInfo(&info); -#else - Q_UNUSED(encoding); - CFStringGetPascalString(QCFString(s), str, 256, CFStringGetSystemEncoding()); -#endif -} - -Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) { - return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding())); -} -#endif //!defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) - -#if !defined(QWS) && defined(Q_OS_MAC) - static QSysInfo::MacVersion macVersion() { #ifndef QT_NO_CORESERVICES @@ -2105,7 +2054,7 @@ static void mac_default_handler(const char *msg) { if (qt_is_gui_used) { Str255 pmsg; - qt_mac_to_pascal_string(msg, pmsg); + qt_mac_to_pascal_string(QString::fromAscii(msg), pmsg); DebugStr(pmsg); } else { fprintf(stderr, msg); diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp index e45ef50..e705c31 100644 --- a/src/corelib/kernel/qcore_mac.cpp +++ b/src/corelib/kernel/qcore_mac.cpp @@ -86,4 +86,54 @@ QCFString::operator CFStringRef() const return type; } + +void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding, int len) +{ + if(len == -1) + len = s.length(); +#if 0 + UnicodeMapping mapping; + mapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault, + kTextEncodingDefaultVariant, + kUnicode16BitFormat); + mapping.otherEncoding = (encoding ? encoding : ); + mapping.mappingVersion = kUnicodeUseLatestMapping; + + UnicodeToTextInfo info; + OSStatus err = CreateUnicodeToTextInfo(&mapping, &info); + if(err != noErr) { + qDebug("Qt: internal: Unable to create pascal string '%s'::%d [%ld]", + s.left(len).latin1(), (int)encoding, err); + return; + } + const int unilen = len * 2; + const UniChar *unibuf = (UniChar *)s.unicode(); + ConvertFromUnicodeToPString(info, unilen, unibuf, str); + DisposeUnicodeToTextInfo(&info); +#else + Q_UNUSED(encoding); + CFStringGetPascalString(QCFString(s), str, 256, CFStringGetSystemEncoding()); +#endif +} + +QString qt_mac_from_pascal_string(const Str255 pstr) +{ + return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding())); +} + +OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref) +{ + return FSPathMakeRef(reinterpret_cast(file.toUtf8().constData()), fsref, 0); +} + +// Don't use this function, it won't work in 10.5 (Leopard) and up +OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec) +{ + FSRef fsref; + OSErr ret = qt_mac_create_fsref(file, &fsref); + if (ret == noErr) + ret = FSGetCatalogInfo(&fsref, kFSCatInfoNone, 0, 0, spec, 0); + return ret; +} + QT_END_NAMESPACE diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index adbad83..4b8c16f 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -148,6 +148,13 @@ private: QString string; }; +Q_CORE_EXPORT void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding = 0, int len = -1); +Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr); + +Q_CORE_EXPORT OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref); +// Don't use this function, it won't work in 10.5 (Leopard) and up +Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec); + QT_END_NAMESPACE #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5) diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index 885ce77..fb52274 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -553,9 +553,6 @@ void QFileDialogPrivate::QNSOpenSavePanelDelegate_filterSelected(int menuIndex) emit q_func()->filterSelected(nameFilters.at(menuIndex)); } -extern OSErr qt_mac_create_fsref(const QString &, FSRef *); // qglobal.cpp -extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding=0, int len=-1); // qglobal.cpp - void QFileDialogPrivate::setDirectory_sys(const QString &directory) { #ifndef QT_MAC_USE_COCOA diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index eb0fd8d..5268698 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -218,7 +218,6 @@ extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.cpp extern QWidget *qt_mac_find_window(OSWindowRef); //qwidget_mac.cpp extern void qt_mac_set_cursor(const QCursor *); //qcursor_mac.cpp extern bool qt_mac_is_macsheet(const QWidget *); //qwidget_mac.cpp -extern QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp extern void qt_mac_command_set_enabled(MenuRef, UInt32, bool); //qmenu_mac.cpp extern bool qt_sendSpontaneousEvent(QObject *obj, QEvent *event); // qapplication.cpp extern void qt_mac_update_cursor(); // qcursor_mac.mm diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp index a1df34e..8b47d8e 100644 --- a/src/gui/kernel/qmime_mac.cpp +++ b/src/gui/kernel/qmime_mac.cpp @@ -119,10 +119,6 @@ const QStringList& qEnabledDraggedTypes() *****************************************************************************/ //#define DEBUG_MIME_MAPS -//functions -extern QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp -extern void qt_mac_from_pascal_string(QString, Str255, TextEncoding encoding=0, int len=-1); //qglobal.cpp - ScrapFlavorType qt_mac_mime_type = 'CUTE'; CFStringRef qt_mac_mime_typeUTI = CFSTR("com.pasteboard.trolltech.marker"); diff --git a/src/gui/kernel/qt_mac.cpp b/src/gui/kernel/qt_mac.cpp index 339bc82..69f0034 100644 --- a/src/gui/kernel/qt_mac.cpp +++ b/src/gui/kernel/qt_mac.cpp @@ -61,7 +61,6 @@ QFont qfontForThemeFont(ThemeFontID themeID) SInt16 f_size; Style f_style; GetThemeFont(themeID, Script, f_name, &f_size, &f_style); - extern QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp return QFont(qt_mac_from_pascal_string(f_name), f_size, (f_style & ::bold) ? QFont::Bold : QFont::Normal, (bool)(f_style & ::italic)); diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp index 6fdaf06..954b5c2 100644 --- a/src/gui/text/qfontdatabase_mac.cpp +++ b/src/gui/text/qfontdatabase_mac.cpp @@ -362,7 +362,6 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) if(fnt->data.isEmpty()) { #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { - extern OSErr qt_mac_create_fsref(const QString &, FSRef *); // qglobal.cpp FSRef ref; if(qt_mac_create_fsref(fnt->fileName, &ref) != noErr) return; @@ -372,7 +371,6 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) #endif { #ifndef Q_WS_MAC64 - extern Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &, FSSpec *); // global.cpp FSSpec spec; if(qt_mac_create_fsspec(fnt->fileName, &spec) != noErr) return; diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm index d4b2a40..c3dac87 100644 --- a/src/opengl/qgl_mac.mm +++ b/src/opengl/qgl_mac.mm @@ -114,7 +114,6 @@ extern int qt_mac_pixmap_get_bytes_per_line(const QPixmap *); extern RgnHandle qt_mac_get_rgn(); //qregion_mac.cpp extern void qt_mac_dispose_rgn(RgnHandle); //qregion_mac.cpp extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp -extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding=0, int len=-1); //qglobal.cpp /* QGLTemporaryContext implementation diff --git a/src/qt3support/dialogs/q3filedialog_mac.cpp b/src/qt3support/dialogs/q3filedialog_mac.cpp index f82a8ac..c5db944 100644 --- a/src/qt3support/dialogs/q3filedialog_mac.cpp +++ b/src/qt3support/dialogs/q3filedialog_mac.cpp @@ -248,8 +248,6 @@ static const NavEventUPP make_navProcUPP() } -extern OSErr qt_mac_create_fsref(const QString &, FSRef *); //qglobal.cpp - QStringList Q3FileDialog::macGetOpenFileNames(const QString &filter, QString *pwd, QWidget *parent, const char* /*name*/, const QString& caption, QString *selectedFilter, -- cgit v0.12 From 6b91affb9a355e668bc9d06dee580d95230ac63a Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 10 Jun 2011 11:10:49 +0200 Subject: fix an incorrect OpenMode flags handling in QBuffer::open() which leads to absurd statement (QBuffer::open() == !QBuffer::isOpen()) to be true. also treat Truncate as (Truncate | WriteOnly) to satisfy lazy ones Reviewed-by: Joao Merge-request: 2612 --- src/corelib/io/qbuffer.cpp | 17 +++++-------- tests/auto/qbuffer/tst_qbuffer.cpp | 50 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 11 deletions(-) diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp index 38e406b..35e7b68 100644 --- a/src/corelib/io/qbuffer.cpp +++ b/src/corelib/io/qbuffer.cpp @@ -333,23 +333,18 @@ bool QBuffer::open(OpenMode flags) { Q_D(QBuffer); - if ((flags & Append) == Append) + if ((flags & (Append | Truncate)) != 0) flags |= WriteOnly; - setOpenMode(flags); - if (!(isReadable() || isWritable())) { - qWarning("QFile::open: File access not specified"); + if ((flags & (ReadOnly | WriteOnly)) == 0) { + qWarning("QBuffer::open: Buffer access not specified"); return false; } - if ((flags & QIODevice::Truncate) == QIODevice::Truncate) { + if ((flags & Truncate) == Truncate) d->buf->resize(0); - } - if ((flags & QIODevice::Append) == QIODevice::Append) // append to end of buffer - seek(d->buf->size()); - else - seek(0); + d->ioIndex = (flags & Append) == Append ? d->buf->size() : 0; - return true; + return QIODevice::open(flags); } /*! diff --git a/tests/auto/qbuffer/tst_qbuffer.cpp b/tests/auto/qbuffer/tst_qbuffer.cpp index 776935d..bf4842f 100644 --- a/tests/auto/qbuffer/tst_qbuffer.cpp +++ b/tests/auto/qbuffer/tst_qbuffer.cpp @@ -56,6 +56,7 @@ public: tst_QBuffer(); private slots: + void open(); void getSetCheck(); void readBlock(); void readBlockPastEnd(); @@ -104,6 +105,55 @@ tst_QBuffer::tst_QBuffer() { } +void tst_QBuffer::open() +{ + QByteArray data(10, 'f'); + + QBuffer b; + + QTest::ignoreMessage(QtWarningMsg, "QBuffer::open: Buffer access not specified"); + QVERIFY(!b.open(QIODevice::NotOpen)); + QVERIFY(!b.isOpen()); + b.close(); + + QTest::ignoreMessage(QtWarningMsg, "QBuffer::open: Buffer access not specified"); + QVERIFY(!b.open(QIODevice::Text)); + QVERIFY(!b.isOpen()); + b.close(); + + QTest::ignoreMessage(QtWarningMsg, "QBuffer::open: Buffer access not specified"); + QVERIFY(!b.open(QIODevice::Unbuffered)); + QVERIFY(!b.isOpen()); + b.close(); + + QVERIFY(b.open(QIODevice::ReadOnly)); + QVERIFY(b.isReadable()); + b.close(); + + QVERIFY(b.open(QIODevice::WriteOnly)); + QVERIFY(b.isWritable()); + b.close(); + + b.setData(data); + QVERIFY(b.open(QIODevice::Append)); + QVERIFY(b.isWritable()); + QCOMPARE(b.size(), qint64(10)); + QCOMPARE(b.pos(), b.size()); + b.close(); + + b.setData(data); + QVERIFY(b.open(QIODevice::Truncate)); + QVERIFY(b.isWritable()); + QCOMPARE(b.size(), qint64(0)); + QCOMPARE(b.pos(), qint64(0)); + b.close(); + + QVERIFY(b.open(QIODevice::ReadWrite)); + QVERIFY(b.isReadable()); + QVERIFY(b.isWritable()); + b.close(); +} + // some status() tests, too void tst_QBuffer::readBlock() { -- cgit v0.12 From a9364af090fd3209b92ed5e07a1374488d22b1c4 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 10 Jun 2011 11:22:00 +0200 Subject: Fix a case of SP_MediaSkipForward returning the wrong pixmap. This fixes QTBUG-18311. Merge-request: 2621 Reviewed-by: Joao --- src/gui/styles/qcommonstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index e5171d8..ad0e151 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -5292,7 +5292,7 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti pixmap = QIcon::fromTheme(QLatin1String("media-seek-backward")).pixmap(16); break; case SP_MediaSkipForward: - pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16); + pixmap = QIcon::fromTheme(QLatin1String("media-skip-forward")).pixmap(16); break; case SP_MediaSkipBackward: pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16); -- cgit v0.12 From 16158cd65e16af99bc07bbf2af7a9ee3417ff7a4 Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Wed, 1 Jun 2011 12:38:34 +0200 Subject: tst_qnetworkreply: add a test for http abort. Change-Id: Iec5fe195ff2befe92e759f77768240728bef31bd (cherry picked from commit 752d807797a0021e412a20b0a8fcc34b4fd8e380) --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 58 +++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 25925bd..45f501c 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -6195,16 +6195,62 @@ void tst_QNetworkReply::synchronousRequestSslFailure() } #endif -void tst_QNetworkReply::httpAbort() +class HttpAbortHelper : public QObject { - // FIXME: Implement a test that aborts a big HTTP reply - // a) after the first readyRead() - // b) immediatly after the get() - // c) after the finished() - // The goal is no crash and no irrelevant signals after the abort + Q_OBJECT +public: + HttpAbortHelper(QNetworkReply *parent) + : QObject(parent) + { + mReply = parent; + connect(parent, SIGNAL(readyRead()), this, SLOT(readyRead())); + } + + ~HttpAbortHelper() + { + } + +public slots: + void readyRead() + { + mReply->abort(); + QMetaObject::invokeMethod(&QTestEventLoop::instance(), "exitLoop", Qt::QueuedConnection); + } + +private: + QNetworkReply *mReply; +}; +void tst_QNetworkReply::httpAbort() +{ // FIXME Also implement one where we do a big upload and then abort(). // It must not crash either. + + // Abort after the first readyRead() + QNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + QNetworkReplyPtr reply; + reply = manager.get(request); + HttpAbortHelper replyHolder(reply); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + QCOMPARE(reply->error(), QNetworkReply::OperationCanceledError); + QVERIFY(reply->isFinished()); + + // Abort immediatly after the get() + QNetworkReplyPtr reply2 = manager.get(request); + connect(reply2, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + reply2->abort(); + QCOMPARE(reply2->error(), QNetworkReply::OperationCanceledError); + QVERIFY(reply2->isFinished()); + + // Abort after the finished() + QNetworkRequest request3("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); + QNetworkReplyPtr reply3 = manager.get(request3); + connect(reply3, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(reply3->isFinished()); + reply3->abort(); + QCOMPARE(reply3->error(), QNetworkReply::NoError); } void tst_QNetworkReply::dontInsertPartialContentIntoTheCache() -- cgit v0.12 From a59dab3c6785b7db38f2f43a2fcd8e29c96775af Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Mon, 20 Jun 2011 13:03:40 +0200 Subject: QAuthenticator::setUser() parse user name in form user@domain Task-number: QTBUG-19894 Change-Id: I063dbc66e5f47a83cc1c0aee8913062b4b5e42bc (cherry picked from commit d3313bc2f095dc15718b2a1ed613489ab1ae0927) --- src/network/kernel/qauthenticator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 818aab7..4f7f4ed 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -223,7 +223,7 @@ void QAuthenticator::setUser(const QString &user) } else if((separatorPosn = user.indexOf(QLatin1String("@"))) != -1) { //domain name is present d->realm.clear(); - d->userDomain = user.left(separatorPosn); + d->userDomain = user.mid(separatorPosn + 1); d->extractedUser = user.left(separatorPosn); d->user = user; } else { -- cgit v0.12 From 9d5b0e31f287ce502eaf9a2c0876d900424c80ab Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 23 Jun 2011 14:56:45 +0200 Subject: my changelog for 4.8.0 --- dist/changes-4.8.0 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index 1703633..0fa4451 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -53,6 +53,7 @@ QtCore - QStringBuilder: added support for QByteArray - qSwap now uses std::swap, specialized std::swap for our container to work better with stl algoritms - QVariant: deprecated global function qVariantSetValue, qVariantValue, qVariantCanConvert, qVariantFromValue + - QUrl: add method for retrieving effective top level domain [QTBUG-13601] (MR-1205) QtGui ----- @@ -63,6 +64,21 @@ QtGui - QListView diverses optimisations [QTBUG-11438] - QTreeWidget/QListWidget: use localeAwareCompare for string comparisons [QTBUG-10839] +QtNetwork +--------- + + - SSL: Switch default version to TLS 1.0 + - SSL: enable Server Name Indication (SNI) by default + - QSslCertificate: report fraudulent certificates as invalid ("Comodogate") [QTBUG-18338] + - QSslCertificate: display non-ASCII names from subject and issuerInfo (MR-922) + - QSslCertificate: loat root certificates on demand on Unix (excluding Mac) [QTBUG-14016] + - QNetworkCookie: retain quotes in value attribute [QTBUG-17746] + - QNetworkCookie: allow spaces in unquoted values [QTBUG-18876] + - HTTP API: add support for HTTP multipart messages [QTBUG-6222] + - HTTP cache: do not load resources from cache that must be revalidated [QTBUG-18983] + - HTTP cache: change file organization (MR-2505) + + QtOpenGL -------- - Removed dependency of OpenGL Utility Library (GLU) -- cgit v0.12