diff --git a/configure b/configure index 625c3ff430..12b08aa9c8 100755 --- a/configure +++ b/configure @@ -8471,22 +8471,6 @@ fi #------------------------------------------------------------------------------- QTMODULE="$outpath/mkspecs/qmodule.pri" -cat >>"$QTMODULE.tmp" <> "$QTMODULE.tmp" @@ -8537,13 +8521,6 @@ if [ "$CFG_MAC_XARCH" = "no" ]; then echo "QMAKE_MAC_XARCH = no" >> "$QTMODULE.tmp" fi -#dump the qmake spec -if [ -d "$outpath/mkspecs/$XPLATFORM" ]; then - echo "QMAKESPEC = \$\$QT_BUILD_TREE/mkspecs/$XPLATFORM" >> "$QTMODULE.tmp" -else - echo "QMAKESPEC = $XPLATFORM" >> "$QTMODULE.tmp" -fi - # cmdline args cat "$QMAKE_VARS_FILE" >> "$QTMODULE.tmp" rm -f "$QMAKE_VARS_FILE" 2>/dev/null @@ -8562,6 +8539,19 @@ fi CACHEFILE="$outpath/.qmake.cache" [ -f "$CACHEFILE.tmp" ] && rm -f "$CACHEFILE.tmp" cat >>"$CACHEFILE.tmp" <> "$CACHEFILE.tmp" +else + echo "QMAKESPEC = $XPLATFORM" >> "$CACHEFILE.tmp" +fi + # incrementals INCREMENTAL="" [ "$CFG_INCREMENTAL" = "auto" ] && "$WHICH" p4 >/dev/null 2>&1 && [ "$CFG_DEV" = "yes" ] && CFG_INCREMENTAL="yes" diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index b8cc62600e..170363352d 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -39,12 +39,29 @@ QtCore - Removed support for QT_NO_THREAD define for QHostInfo. - Optimized plugin loading on ELF platforms. Print failure reason at runtime with QT_DEBUG_PLUGINS=1 in environment. + - QMutexLocker: improved performence of the non contended case by inlining some function + - QThreadStorage: Added possibility to store object by value instead of by pointer [QTBUG-15033] + - QThread: fixed few race conditions [QTBUG-17257, QTBUG-15030] + - QtConcurrent: added support for c++0x lambda in few functions + - QObject: Improved performence of the signal activation + - QObject: added ways to connect signals using QMetaMethod + - QObject: deprecated qFindChild and qFindChildren + - QObject: optimize constructions and destruction of objects + - QObject: Qt::BlockingQueuedConnection can handle the return value [QTBUG-10440] + - QList/QVector/QStringList: added C++0x initilizer lists constructors. + - QVarLenghtArray: added method for consistency with QVector + - 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 QtGui ----- - QTabBar: reduced minimumSizeHint if ElideMode is set. - QComboBox: Fixed a color propagation issue with the lineedit. [QTBUG-5950] + - Deprecate qGenericMatrixFromMatrix4x4 and qGenericMatrixToMatrix4x4 + - QListView diverses optimisations [QTBUG-11438] + - QTreeWidget/QListWidget: use localeAwareCompare for string comparisons [QTBUG-10839] QtOpenGL -------- @@ -54,6 +71,10 @@ QtGui - Including will not work in combination with GLEW, as QGLFunctions will undefine GLEW's defines. +QtScript +-------- + - Deprecated qScriptValueFromQMetaObject, qScriptValueToValue, qScriptValueFromValue + **************************************************************************** * Database Drivers * @@ -136,6 +157,7 @@ Qt for Windows CE - qtconfig + * removed Qt3support dependency - qt3to4 diff --git a/examples/opengl/cube/geometryengine.cpp b/examples/opengl/cube/geometryengine.cpp index 2f6f65948d..01a33f3bb7 100644 --- a/examples/opengl/cube/geometryengine.cpp +++ b/examples/opengl/cube/geometryengine.cpp @@ -21,6 +21,8 @@ GeometryEngine::~GeometryEngine() void GeometryEngine::init() { + initializeGLFunctions(); + //! [0] // Generate 2 VBOs glGenBuffers(2, vboIds); diff --git a/examples/opengl/cube/mainwidget.cpp b/examples/opengl/cube/mainwidget.cpp index bead5f79ed..682ce5c9e7 100644 --- a/examples/opengl/cube/mainwidget.cpp +++ b/examples/opengl/cube/mainwidget.cpp @@ -78,6 +78,8 @@ void MainWidget::timerEvent(QTimerEvent *e) void MainWidget::initializeGL() { + initializeGLFunctions(); + qglClearColor(Qt::black); qDebug() << "Initializing shaders..."; diff --git a/examples/opengl/cube/mainwidget.h b/examples/opengl/cube/mainwidget.h index 595173b65d..75d069d2f6 100644 --- a/examples/opengl/cube/mainwidget.h +++ b/examples/opengl/cube/mainwidget.h @@ -2,6 +2,7 @@ #define MAINWIDGET_H #include +#include #include #include @@ -12,7 +13,7 @@ class QGLShaderProgram; class GeometryEngine; -class MainWidget : public QGLWidget +class MainWidget : public QGLWidget, protected QGLFunctions { Q_OBJECT public: diff --git a/examples/qtestlib/tutorial1/tutorial1.pro b/examples/qtestlib/tutorial1/tutorial1.pro index 2a9d032dd5..ca4c795fdb 100644 --- a/examples/qtestlib/tutorial1/tutorial1.pro +++ b/examples/qtestlib/tutorial1/tutorial1.pro @@ -1,5 +1,5 @@ SOURCES = testqstring.cpp -CONFIG += qtestlib +QT += testlib # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtestlib/tutorial1 diff --git a/examples/qtestlib/tutorial2/tutorial2.pro b/examples/qtestlib/tutorial2/tutorial2.pro index b459d25b97..8ff0f4b818 100644 --- a/examples/qtestlib/tutorial2/tutorial2.pro +++ b/examples/qtestlib/tutorial2/tutorial2.pro @@ -1,5 +1,5 @@ SOURCES = testqstring.cpp -CONFIG += qtestlib +QT += testlib # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtestlib/tutorial2 diff --git a/examples/qtestlib/tutorial3/tutorial3.pro b/examples/qtestlib/tutorial3/tutorial3.pro index 4985858d3d..732c7be6bd 100644 --- a/examples/qtestlib/tutorial3/tutorial3.pro +++ b/examples/qtestlib/tutorial3/tutorial3.pro @@ -1,5 +1,5 @@ SOURCES = testgui.cpp -CONFIG += qtestlib +QT += testlib # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtestlib/tutorial3 diff --git a/examples/qtestlib/tutorial4/tutorial4.pro b/examples/qtestlib/tutorial4/tutorial4.pro index 02d9020b84..9fa2f110d3 100644 --- a/examples/qtestlib/tutorial4/tutorial4.pro +++ b/examples/qtestlib/tutorial4/tutorial4.pro @@ -1,5 +1,5 @@ SOURCES = testgui.cpp -CONFIG += qtestlib +QT += testlib # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtestlib/tutorial4 diff --git a/examples/qtestlib/tutorial5/tutorial5.pro b/examples/qtestlib/tutorial5/tutorial5.pro index efdb1ce055..15a8b85956 100644 --- a/examples/qtestlib/tutorial5/tutorial5.pro +++ b/examples/qtestlib/tutorial5/tutorial5.pro @@ -1,5 +1,5 @@ SOURCES = benchmarking.cpp -CONFIG += qtestlib +QT += testlib # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtestlib/tutorial5 diff --git a/examples/widgets/applicationicon/applicationicon.svg b/examples/widgets/applicationicon/applicationicon.svg new file mode 100644 index 0000000000..aa2835b08f --- /dev/null +++ b/examples/widgets/applicationicon/applicationicon.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/widgets/applicationicon/main.cpp b/examples/widgets/applicationicon/main.cpp new file mode 100644 index 0000000000..099bdac218 --- /dev/null +++ b/examples/widgets/applicationicon/main.cpp @@ -0,0 +1,14 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QLabel label(QObject::tr("Hello, world!")); +#if defined(Q_WS_S60) + label.showMaximized(); +#else + label.show(); +#endif + return a.exec(); +} diff --git a/examples/widgets/elidedlabel/elidedlabel.cpp b/examples/widgets/elidedlabel/elidedlabel.cpp new file mode 100644 index 0000000000..4f3ac5e843 --- /dev/null +++ b/examples/widgets/elidedlabel/elidedlabel.cpp @@ -0,0 +1,71 @@ +#include "elidedlabel.h" + +#include +#include +#include + +//! [0] +ElidedLabel::ElidedLabel(const QString &text, QWidget *parent) + : QFrame(parent) + , elided(false) + , content(text) +{ + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); +} +//! [0] + +//! [1] +void ElidedLabel::setText(const QString &newText) +{ + content = newText; + update(); +} +//! [1] + +//! [2] +void ElidedLabel::paintEvent(QPaintEvent *event) +{ + QFrame::paintEvent(event); + + QPainter painter(this); + QFontMetrics fontMetrics = painter.fontMetrics(); + + bool didElide = false; + int lineSpacing = fontMetrics.lineSpacing(); + int y = 0; + + QTextLayout textLayout(content, painter.font()); + textLayout.beginLayout(); + forever { + QTextLine line = textLayout.createLine(); + + if (!line.isValid()) + break; + + line.setLineWidth(width()); + int nextLineY = y + lineSpacing; + + if (height() >= nextLineY + lineSpacing) { + line.draw(&painter, QPoint(0, y)); + y = nextLineY; + //! [2] + //! [3] + } else { + QString lastLine = content.mid(line.textStart()); + QString elidedLastLine = fontMetrics.elidedText(lastLine, Qt::ElideRight, width()); + painter.drawText(QPoint(0, y + fontMetrics.ascent()), elidedLastLine); + line = textLayout.createLine(); + didElide = line.isValid(); + break; + } + } + textLayout.endLayout(); + //! [3] + + //! [4] + if (didElide != elided) { + elided = didElide; + emit elisionChanged(didElide); + } +} +//! [4] diff --git a/examples/widgets/elidedlabel/elidedlabel.h b/examples/widgets/elidedlabel/elidedlabel.h new file mode 100644 index 0000000000..b68f605248 --- /dev/null +++ b/examples/widgets/elidedlabel/elidedlabel.h @@ -0,0 +1,36 @@ +#ifndef ELIDEDLABEL_H +#define ELIDEDLABEL_H + +#include +#include +#include +#include +#include + +//! [0] +class ElidedLabel : public QFrame +{ + Q_OBJECT + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(bool isElided READ isElided) + +public: + ElidedLabel(const QString &text, QWidget *parent = 0); + + void setText(const QString &text); + const QString & text() const { return content; } + bool isElided() const { return elided; } + +protected: + void paintEvent(QPaintEvent *event); + +signals: + void elisionChanged(bool elided); + +private: + bool elided; + QString content; +}; +//! [0] + +#endif // TEXTWRAPPINGWIDGET_H diff --git a/examples/widgets/elidedlabel/main.cpp b/examples/widgets/elidedlabel/main.cpp new file mode 100644 index 0000000000..1346d25e24 --- /dev/null +++ b/examples/widgets/elidedlabel/main.cpp @@ -0,0 +1,13 @@ +#include "testwidget.h" + +#include + +//! [0] +int main( int argc, char *argv[] ) +{ + QApplication application( argc, argv ); + TestWidget w; + w.showFullScreen(); + return application.exec(); +} +//! [0] diff --git a/examples/widgets/elidedlabel/testwidget.cpp b/examples/widgets/elidedlabel/testwidget.cpp new file mode 100644 index 0000000000..d3bf521832 --- /dev/null +++ b/examples/widgets/elidedlabel/testwidget.cpp @@ -0,0 +1,124 @@ +#include "testwidget.h" +#include "elidedlabel.h" + +#include +#include +#include +#include + +//! [0] +TestWidget::TestWidget(QWidget *parent): + QWidget(parent) +{ + const QString romeo = tr( + "But soft, what light through yonder window breaks? / " + "It is the east, and Juliet is the sun. / " + "Arise, fair sun, and kill the envious moon, / " + "Who is already sick and pale with grief / " + "That thou, her maid, art far more fair than she." + ); + + const QString macbeth = tr( + "To-morrow, and to-morrow, and to-morrow, / " + "Creeps in this petty pace from day to day, / " + "To the last syllable of recorded time; / " + "And all our yesterdays have lighted fools / " + "The way to dusty death. Out, out, brief candle! / " + "Life's but a walking shadow, a poor player, / " + "That struts and frets his hour upon the stage, / " + "And then is heard no more. It is a tale / " + "Told by an idiot, full of sound and fury, / " + "Signifying nothing." + ); + + const QString harry = tr("Feeling lucky, punk?"); + + textSamples << romeo << macbeth << harry; + //! [0] + + //! [1] + sampleIndex = 0; + elidedText = new ElidedLabel(textSamples[sampleIndex], this); + elidedText->setFrameStyle(QFrame::Box); + //! [1] + + //! [2] + QPushButton *switchButton = new QPushButton(tr("Switch text")); + connect(switchButton, SIGNAL(clicked(bool)), this, SLOT(switchText())); + + QPushButton *exitButton = new QPushButton(tr("Exit")); + connect(exitButton, SIGNAL(clicked(bool)), this, SLOT(close())); + + QLabel *label = new QLabel(tr("Elided")); + label->setVisible(elidedText->isElided()); + connect(elidedText, SIGNAL(elisionChanged(bool)), label, SLOT(setVisible(bool))); + //! [2] + + //! [3] + widthSlider = new QSlider(Qt::Horizontal); + widthSlider->setMinimum(0); + connect(widthSlider, SIGNAL(valueChanged(int)), this, SLOT(onWidthChanged(int))); + + heightSlider = new QSlider(Qt::Vertical); + heightSlider->setInvertedAppearance(true); + heightSlider->setMinimum(0); + connect(heightSlider, SIGNAL(valueChanged(int)), this, SLOT(onHeightChanged(int))); + //! [3] + + //! [4] + QGridLayout *layout = new QGridLayout(); + layout->addWidget(label, 0, 1, Qt::AlignCenter); + layout->addWidget(switchButton, 0, 2); + layout->addWidget(exitButton, 0, 3); + layout->addWidget(widthSlider, 1, 1, 1, 3); + layout->addWidget(heightSlider, 2, 0); + layout->addWidget(elidedText, 2, 1, 1, 3, Qt::AlignTop | Qt::AlignLeft); + + setLayout(layout); + //! [4] + + //! [5] +#ifdef Q_WS_MAEMO_5 + setAttribute(Qt::WA_Maemo5AutoOrientation, true); +#endif +} +//! [5] + +//! [6] +void TestWidget::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event) + + int maxWidth = widthSlider->width(); + widthSlider->setMaximum(maxWidth); + widthSlider->setValue(maxWidth / 2); + + int maxHeight = heightSlider->height(); + heightSlider->setMaximum(maxHeight); + heightSlider->setValue(maxHeight / 2); + + elidedText->setFixedSize(widthSlider->value(), heightSlider->value()); +} +//! [6] + +//! [7] +void TestWidget::switchText() +{ + sampleIndex = (sampleIndex + 1) % textSamples.size(); + elidedText->setText(textSamples.at(sampleIndex)); +} +//! [7] + +//! [8] +void TestWidget::onWidthChanged(int width) +{ + elidedText->setFixedWidth(width); +} + +void TestWidget::onHeightChanged(int height) +{ + elidedText->setFixedHeight(height); +} +//! [8] + + diff --git a/examples/widgets/elidedlabel/testwidget.h b/examples/widgets/elidedlabel/testwidget.h new file mode 100644 index 0000000000..ed4de95107 --- /dev/null +++ b/examples/widgets/elidedlabel/testwidget.h @@ -0,0 +1,36 @@ +#ifndef TESTWIDGET_H +#define TESTWIDGET_H + +#include +#include +#include +#include + +class ElidedLabel; + +//! [0] +class TestWidget : public QWidget +{ + Q_OBJECT + +public: + TestWidget(QWidget *parent = 0); + +protected: + void resizeEvent(QResizeEvent *event); + +private slots: + void switchText(); + void onWidthChanged(int width); + void onHeightChanged(int height); + +private: + int sampleIndex; + QStringList textSamples; + ElidedLabel *elidedText; + QSlider *heightSlider; + QSlider *widthSlider; +}; +//! [0] + +#endif // TESTWIDGET_H diff --git a/mkspecs/features/default_pre.prf b/mkspecs/features/default_pre.prf index adcdbb73e9..d451d29f7c 100644 --- a/mkspecs/features/default_pre.prf +++ b/mkspecs/features/default_pre.prf @@ -26,7 +26,11 @@ exists($$_PRO_FILE_PWD_/sync.profile) { message("Running syncqt for $$PRO_BASENAME in $$OUT_PWD") qtPrepareTool(QMAKE_SYNCQT, syncqt) - system("$$QMAKE_SYNCQT $$QTFWD -outdir $$OUT_PWD $$_PRO_FILE_PWD_") + system("$$QMAKE_SYNCQT $$QTFWD -outdir $$OUT_PWD $$_PRO_FILE_PWD_") { + # success! Nothing to do + } else { + error("Failed to run: $$QMAKE_SYNCQT $$QTFWD -outdir $$OUT_PWD $$_PRO_FILE_PWD_") + } unset(QTFWD) unset(PRO_BASENAME) } diff --git a/mkspecs/features/designer.prf b/mkspecs/features/designer.prf index 63a7e76a34..843a118a9a 100644 --- a/mkspecs/features/designer.prf +++ b/mkspecs/features/designer.prf @@ -1,7 +1,6 @@ -QT += xml -contains(QT_CONFIG, script): QT += script +QT += xml uilib +!isEmpty(QT.script.name): QT += script +!isEmpty(QT.designer.name): QT += designer qt:load(qt) plugin:DEFINES += QDESIGNER_EXPORT_WIDGETS - -qtAddLibrary(QtDesigner, true) diff --git a/mkspecs/features/qmltestcase.prf b/mkspecs/features/qmltestcase.prf index a3d66e659e..5e60185493 100644 --- a/mkspecs/features/qmltestcase.prf +++ b/mkspecs/features/qmltestcase.prf @@ -1,20 +1,6 @@ CONFIG += testcase -!symbian { - INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtQuickTest -} else { - load(data_caging_paths) - - INCLUDEPATH+=$$MW_LAYER_PUBLIC_EXPORT_PATH(QtQuickTest) -} - -QT += declarative - -win32:CONFIG(debug, debug|release) { - LIBS += -lQtQuickTest$${QT_LIBINFIX}d -} else { - LIBS += -lQtQuickTest$${QT_LIBINFIX} -} +QT += declarative qmltest # If the .pro file specified an IMPORTPATH, then add that to # the command-line when the test is run. diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index c611096147..3791c9565a 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -160,7 +160,7 @@ for(QTLIB, $$list($$lower($$unique(QT)))) { # add include paths for all .depends, since module/application might need f.ex. template specializations etc. QT_DEPENDS -= $$QT -for(QTLIB, $$list($$lower($$unique(QT_DEPENDS)))):INCLUDEPATH += $$INCLUDEPATH $$eval(QT.$${QTLIB}.includes) +for(QTLIB, $$list($$lower($$unique(QT_DEPENDS)))):INCLUDEPATH *= $$INCLUDEPATH $$eval(QT.$${QTLIB}.includes) !isEmpty(using_privates):!no_private_qt_headers_warning:if(!debug_and_release|!build_pass) { message("This project is using private headers and will therefore be tied to this specific Qt module build version.") diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf new file mode 100644 index 0000000000..c4eaab8147 --- /dev/null +++ b/mkspecs/features/qt_plugin.prf @@ -0,0 +1,41 @@ +TEMPLATE = lib +isEmpty(QT_MAJOR_VERSION) { + VERSION=5.0.0 +} else { + VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} +} +CONFIG += qt plugin + +win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release +TARGET = $$qtLibraryTarget($$TARGET) +contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols + +load(qt_targets) + +wince*:LIBS += $$QMAKE_LIBS_GUI + +symbian: { + TARGET.EPOCALLOWDLLDATA=1 + TARGET.CAPABILITY = All -Tcb + TARGET = $${TARGET}$${QT_LIBINFIX} + load(armcc_warnings) + + # Make partial upgrade SIS file for Qt plugin dll's + # Partial upgrade SIS file + vendorinfo = \ + "; Localised Vendor name" \ + "%{\"Nokia\"}" \ + " " \ + "; Unique Vendor name" \ + ":\"Nokia, Qt\"" \ + " " + isEmpty(QT_LIBINFIX): PARTIAL_UPGRADE_UID = 0x2001E61C + else: PARTIAL_UPGRADE_UID = 0xE001E61C + + pu_header = "; Partial upgrade package for testing $${TARGET} changes without reinstalling everything" \ + "$${LITERAL_HASH}{\"$${TARGET}\"}, ($$PARTIAL_UPGRADE_UID), $${QT_MAJOR_VERSION},$${QT_MINOR_VERSION},$${QT_PATCH_VERSION}, TYPE=PU" + partial_upgrade.pkg_prerules = pu_header vendorinfo + partial_upgrade.files = $$QMAKE_LIBDIR_QT/$${TARGET}.dll + partial_upgrade.path = c:/sys/bin + DEPLOYMENT += partial_upgrade +} diff --git a/qtbase.pro b/qtbase.pro index 375308a5cc..95f497fef4 100644 --- a/qtbase.pro +++ b/qtbase.pro @@ -10,26 +10,34 @@ cross_compile: CONFIG += nostrip module_qtbase_tests.subdir = tests module_qtbase_tests.target = module-qtbase-tests module_qtbase_tests.depends = module_qtbase_src -module_qtbase_tests.CONFIG = no_default_target no_default_install +module_qtbase_tests.CONFIG = no_default_install #process the projects -for(PROJECT, $$list($$lower($$unique(QT_BUILD_PARTS)))) { - isEqual(PROJECT, examples) { - SUBDIRS += examples - } else:isEqual(PROJECT, demos) { - SUBDIRS += demos - } else:isEqual(PROJECT, tests) { - module_qtbase_tests.CONFIG -= no_default_target - } else:isEqual(PROJECT, libs) { - include(src/src.pro) - } else:isEqual(PROJECT, qmake) { -# SUBDIRS += qmake - } else { - message(Unknown PROJECT: $$PROJECT) - } +PROJECTS=$$eval($$list($$lower($$unique(QT_BUILD_PARTS)))) +# note that the order matters for these blocks! +contains(PROJECTS, qmake) { + PROJECTS -= qmake + # nothing to be done +} +contains(PROJECTS, libs) { + PROJECTS -= libs + include(src/src.pro) +} +contains(PROJECTS, examples) { + PROJECTS -= examples + SUBDIRS += examples +} +contains(PROJECTS, demos) { + PROJECTS -= demos + SUBDIRS += demos +} +contains(PROJECTS, tests) { + PROJECTS -= tests + SUBDIRS += module_qtbase_tests +} +!isEmpty(PROJECTS) { + message(Unknown PROJECTS: $$PROJECTS) } - -SUBDIRS += module_qtbase_tests !symbian: confclean.depends += clean confclean.commands = diff --git a/src/corelib/concurrent/qtconcurrentcompilertest.h b/src/corelib/concurrent/qtconcurrentcompilertest.h index 884badbfbd..c139c7a8b2 100644 --- a/src/corelib/concurrent/qtconcurrentcompilertest.h +++ b/src/corelib/concurrent/qtconcurrentcompilertest.h @@ -57,6 +57,20 @@ QT_MODULE(Core) # define QT_TYPENAME typename #endif +namespace QtPrivate { + +template +class HasResultType { + typedef char Yes; + typedef void *No; + template static Yes test(int, const typename U::result_type * = 0); + template static No test(double); +public: + enum { Value = (sizeof(test(0)) == sizeof(Yes)) }; +}; + +} + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h index a79ad1c305..4bf2736e6c 100644 --- a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h +++ b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h @@ -195,17 +195,10 @@ QtConcurrent::ConstMemberFunctionWrapper createFunctionWrapper(T (C::*func return QtConcurrent::ConstMemberFunctionWrapper(func); } - -template -void *lazyResultType_helper(int, typename T::result_type * = 0); -template -char lazyResultType_helper(double); - -template (0)) != sizeof(void*)> +template ::Value> struct LazyResultType { typedef typename Functor::result_type Type; }; template -struct LazyResultType { typedef void Type; }; - +struct LazyResultType { typedef void Type; }; template struct ReduceResultType; diff --git a/src/corelib/concurrent/qtconcurrentrun.h b/src/corelib/concurrent/qtconcurrentrun.h index 8611fba361..ef51b2adcb 100644 --- a/src/corelib/concurrent/qtconcurrentrun.h +++ b/src/corelib/concurrent/qtconcurrentrun.h @@ -71,63 +71,114 @@ namespace QtConcurrent { template QFuture run(T (*functionPointer)()) { - return (new QT_TYPENAME SelectStoredFunctorCall0::type(functionPointer))->start(); + return (new StoredFunctorCall0(functionPointer))->start(); } template QFuture run(T (*functionPointer)(Param1), const Arg1 &arg1) { - return (new QT_TYPENAME SelectStoredFunctorCall1::type(functionPointer, arg1))->start(); + return (new StoredFunctorCall1(functionPointer, arg1))->start(); } template QFuture run(T (*functionPointer)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2) { - return (new QT_TYPENAME SelectStoredFunctorCall2::type(functionPointer, arg1, arg2))->start(); + return (new StoredFunctorCall2(functionPointer, arg1, arg2))->start(); } template QFuture run(T (*functionPointer)(Param1, Param2, Param3), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) { - return (new QT_TYPENAME SelectStoredFunctorCall3::type(functionPointer, arg1, arg2, arg3))->start(); + return (new StoredFunctorCall3(functionPointer, arg1, arg2, arg3))->start(); } template QFuture run(T (*functionPointer)(Param1, Param2, Param3, Param4), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) { - return (new QT_TYPENAME SelectStoredFunctorCall4::type(functionPointer, arg1, arg2, arg3, arg4))->start(); + return (new StoredFunctorCall4(functionPointer, arg1, arg2, arg3, arg4))->start(); } template QFuture run(T (*functionPointer)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) { - return (new QT_TYPENAME SelectStoredFunctorCall5::type(functionPointer, arg1, arg2, arg3, arg4, arg5))->start(); + return (new StoredFunctorCall5(functionPointer, arg1, arg2, arg3, arg4, arg5))->start(); } +#ifdef Q_COMPILER_DECLTYPE + +template +auto run(Functor functor) -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +{ + typedef decltype(functor()) result_type; + return (new StoredFunctorCall0(functor))->start(); +} + +template +auto run(Functor functor, const Arg1 &arg1) + -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +{ + typedef decltype(functor(arg1)) result_type; + return (new StoredFunctorCall1(functor, arg1))->start(); +} + +template +auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2) + -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +{ + typedef decltype(functor(arg1, arg2)) result_type; + return (new StoredFunctorCall2(functor, arg1, arg2))->start(); +} + +template +auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) + -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +{ + typedef decltype(functor(arg1, arg2, arg3)) result_type; + return (new StoredFunctorCall3(functor, arg1, arg2, arg3))->start(); +} + +template +auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) + -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +{ + typedef decltype(functor(arg1, arg2, arg3, arg4)) result_type; + return (new StoredFunctorCall4(functor, arg1, arg2, arg3, arg4))->start(); +} + +template +auto run(Functor functor, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) + -> typename QtPrivate::QEnableIf::Value, QFuture >::Type +{ + typedef decltype(functor(arg1, arg2, arg3, arg4, arg5)) result_type; + return (new StoredFunctorCall5(functor, arg1, arg2, arg3, arg4, arg5))->start(); +} + +#endif + template QFuture run(FunctionObject functionObject) { - return (new QT_TYPENAME SelectStoredFunctorCall0::type(functionObject))->start(); + return (new StoredFunctorCall0(functionObject))->start(); } template QFuture run(FunctionObject functionObject, const Arg1 &arg1) { - return (new QT_TYPENAME SelectStoredFunctorCall1::type(functionObject, arg1))->start(); + return (new StoredFunctorCall1(functionObject, arg1))->start(); } template QFuture run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2) { - return (new QT_TYPENAME SelectStoredFunctorCall2::type(functionObject, arg1, arg2))->start(); + return (new StoredFunctorCall2(functionObject, arg1, arg2))->start(); } template QFuture run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3) { - return (new QT_TYPENAME SelectStoredFunctorCall3::type(functionObject, arg1, arg2, arg3))->start(); + return (new StoredFunctorCall3(functionObject, arg1, arg2, arg3))->start(); } template QFuture run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4) { - return (new QT_TYPENAME SelectStoredFunctorCall4::type(functionObject, arg1, arg2, arg3, arg4))->start(); + return (new StoredFunctorCall4(functionObject, arg1, arg2, arg3, arg4))->start(); } template QFuture run(FunctionObject functionObject, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5) { - return (new QT_TYPENAME SelectStoredFunctorCall5::type(functionObject, arg1, arg2, arg3, arg4, arg5))->start(); + return (new StoredFunctorCall5(functionObject, arg1, arg2, arg3, arg4, arg5))->start(); } template diff --git a/src/corelib/concurrent/qtconcurrentstoredfunctioncall.h b/src/corelib/concurrent/qtconcurrentstoredfunctioncall.h index c61f9b8014..9beb0b9c35 100644 --- a/src/corelib/concurrent/qtconcurrentstoredfunctioncall.h +++ b/src/corelib/concurrent/qtconcurrentstoredfunctioncall.h @@ -66,23 +66,16 @@ struct StoredFunctorCall0: public RunFunctionTask }; -template -struct VoidStoredFunctorCall0: public RunFunctionTask +template +struct StoredFunctorCall0: public RunFunctionTask { - inline VoidStoredFunctorCall0(FunctionPointer _function) + inline StoredFunctorCall0(FunctionPointer _function) : function(_function) {} void runFunctor() { function(); } FunctionPointer function; }; -template -struct SelectStoredFunctorCall0 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorCall0 >::type type; -}; template struct StoredFunctorPointerCall0: public RunFunctionTask { @@ -276,23 +269,16 @@ struct StoredFunctorCall1: public RunFunctionTask Arg1 arg1; }; -template -struct VoidStoredFunctorCall1: public RunFunctionTask +template +struct StoredFunctorCall1: public RunFunctionTask { - inline VoidStoredFunctorCall1(FunctionPointer _function, const Arg1 &_arg1) + inline StoredFunctorCall1(FunctionPointer _function, const Arg1 &_arg1) : function(_function), arg1(_arg1) {} void runFunctor() { function(arg1); } FunctionPointer function; Arg1 arg1; }; -template -struct SelectStoredFunctorCall1 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorCall1 >::type type; -}; template struct StoredFunctorPointerCall1: public RunFunctionTask { @@ -486,23 +472,16 @@ struct StoredFunctorCall2: public RunFunctionTask Arg1 arg1; Arg2 arg2; }; -template -struct VoidStoredFunctorCall2: public RunFunctionTask +template +struct StoredFunctorCall2: public RunFunctionTask { - inline VoidStoredFunctorCall2(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2) + inline StoredFunctorCall2(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2) : function(_function), arg1(_arg1), arg2(_arg2) {} void runFunctor() { function(arg1, arg2); } FunctionPointer function; Arg1 arg1; Arg2 arg2; }; -template -struct SelectStoredFunctorCall2 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorCall2 >::type type; -}; template struct StoredFunctorPointerCall2: public RunFunctionTask { @@ -696,23 +675,16 @@ struct StoredFunctorCall3: public RunFunctionTask Arg1 arg1; Arg2 arg2; Arg3 arg3; }; -template -struct VoidStoredFunctorCall3: public RunFunctionTask +template +struct StoredFunctorCall3: public RunFunctionTask { - inline VoidStoredFunctorCall3(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) + inline StoredFunctorCall3(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3) : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3) {} void runFunctor() { function(arg1, arg2, arg3); } FunctionPointer function; Arg1 arg1; Arg2 arg2; Arg3 arg3; }; -template -struct SelectStoredFunctorCall3 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorCall3 >::type type; -}; template struct StoredFunctorPointerCall3: public RunFunctionTask { @@ -906,23 +878,16 @@ struct StoredFunctorCall4: public RunFunctionTask Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; }; -template -struct VoidStoredFunctorCall4: public RunFunctionTask +template +struct StoredFunctorCall4: public RunFunctionTask { - inline VoidStoredFunctorCall4(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) + inline StoredFunctorCall4(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4) : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4) {} void runFunctor() { function(arg1, arg2, arg3, arg4); } FunctionPointer function; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; }; -template -struct SelectStoredFunctorCall4 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorCall4 >::type type; -}; template struct StoredFunctorPointerCall4: public RunFunctionTask { @@ -1116,23 +1081,16 @@ struct StoredFunctorCall5: public RunFunctionTask Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; }; -template -struct VoidStoredFunctorCall5: public RunFunctionTask +template +struct StoredFunctorCall5: public RunFunctionTask { - inline VoidStoredFunctorCall5(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) + inline StoredFunctorCall5(FunctionPointer _function, const Arg1 &_arg1, const Arg2 &_arg2, const Arg3 &_arg3, const Arg4 &_arg4, const Arg5 &_arg5) : function(_function), arg1(_arg1), arg2(_arg2), arg3(_arg3), arg4(_arg4), arg5(_arg5) {} void runFunctor() { function(arg1, arg2, arg3, arg4, arg5); } FunctionPointer function; Arg1 arg1; Arg2 arg2; Arg3 arg3; Arg4 arg4; Arg5 arg5; }; -template -struct SelectStoredFunctorCall5 -{ - typedef typename SelectSpecialization::template - Type, - VoidStoredFunctorCall5 >::type type; -}; template struct StoredFunctorPointerCall5: public RunFunctionTask { @@ -1316,6 +1274,33 @@ struct SelectStoredConstMemberFunctionPointerCall5 Type, VoidStoredConstMemberFunctionPointerCall5 >::type type; }; + +template +class StoredFunctorCall : public RunFunctionTask +{ +public: + StoredFunctorCall(const Functor &f) : functor(f) { } + void runFunctor() + { + this->result = functor(); + } +private: + Functor functor; +}; +template +class StoredFunctorCall : public RunFunctionTask +{ +public: + StoredFunctorCall(const Functor &f) : functor(f) { } + void runFunctor() + { + functor(); + } +private: + Functor functor; +}; + + } //namespace QtConcurrent #endif // qdoc diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 4e3f4e312f..8a17af55f2 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -363,6 +363,11 @@ template inline void qToLittleEndian(T src, uchar *dest) #endif // Q_BYTE_ORDER == Q_BIG_ENDIAN +template <> inline quint8 qbswap(quint8 source) +{ + return source; +} + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index fda58336eb..79defc4277 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -425,14 +425,11 @@ namespace QT_NAMESPACE {} #if defined(Q_CC_MSVC) && _MSC_VER >= 1600 # define Q_COMPILER_RVALUE_REFS -# define Q_COMPILER_INITIALIZER_LISTS # define Q_COMPILER_AUTO_TYPE # define Q_COMPILER_LAMBDA -//# define Q_COMPILER_VARIADIC_TEMPLATES -//# define Q_COMPILER_CLASS_ENUM -//# define Q_COMPILER_DEFAULT_DELETE_MEMBERS -//# define Q_COMPILER_UNICODE_STRINGS -//# define Q_COMPILER_EXTERN_TEMPLATES +# define Q_COMPILER_DECLTYPE +// MSCV has std::initilizer_list, but do not support the braces initialization +//# define Q_COMPILER_INITIALIZER_LISTS # endif @@ -524,6 +521,7 @@ namespace QT_NAMESPACE {} # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 /* C++0x features supported in GCC 4.3: */ # define Q_COMPILER_RVALUE_REFS +# define Q_COMPILER_DECLTYPE # endif # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 /* C++0x features supported in GCC 4.4: */ @@ -791,6 +789,7 @@ namespace QT_NAMESPACE {} # if __INTEL_COMPILER >= 1100 # define Q_COMPILER_RVALUE_REFS # define Q_COMPILER_EXTERN_TEMPLATES +# define Q_COMPILER_DECLTYPE # elif __INTEL_COMPILER >= 1200 # define Q_COMPILER_VARIADIC_TEMPLATES # define Q_COMPILER_AUTO_TYPE @@ -2792,6 +2791,12 @@ QT_LICENSED_MODULE(Sensors) # define QT_NO_RAWFONT #endif +namespace QtPrivate { +//like std::enable_if +template struct QEnableIf; +template struct QEnableIf { typedef T Type; }; +} + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 9f59c6e8e9..09611e67f4 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1121,7 +1121,7 @@ \value WA_X11NetWmWindowTypeToolBar Adds _NET_WM_WINDOW_TYPE_TOOLBAR to the window's _NET_WM_WINDOW_TYPE X11 window property. See http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automaticaly sets this + has no effect on non-X11 platforms. \note Qt automatically sets this attribute for QToolBar. \value WA_X11NetWmWindowTypeMenu Adds _NET_WM_WINDOW_TYPE_MENU to the @@ -2593,7 +2593,7 @@ \value ImhFormattedNumbersOnly Only number input is allowed. This includes decimal point and minus sign. \value ImhUppercaseOnly Only upper case letter input is allowed. \value ImhLowercaseOnly Only lower case letter input is allowed. - \value ImhDialableCharactersOnly Only characters suitable for phone dialling are allowed. + \value ImhDialableCharactersOnly Only characters suitable for phone dialing are allowed. \value ImhEmailCharactersOnly Only characters suitable for email addresses are allowed. \value ImhUrlCharactersOnly Only characters suitable for URLs are allowed. diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index f67600d750..e411f8f643 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -24,6 +24,8 @@ HEADERS += \ io/qresource_p.h \ io/qresource_iterator_p.h \ io/qurl.h \ + io/qurltlds_p.h \ + io/qtldurl_p.h \ io/qsettings.h \ io/qsettings_p.h \ io/qfsfileengine.h \ @@ -41,6 +43,7 @@ SOURCES += \ io/qbuffer.cpp \ io/qdatastream.cpp \ io/qdataurl.cpp \ + io/qtldurl.cpp \ io/qdebug.cpp \ io/qdir.cpp \ io/qdiriterator.cpp \ diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp new file mode 100644 index 0000000000..7db4bbddd5 --- /dev/null +++ b/src/corelib/io/qtldurl.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore 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 "qplatformdefs.h" +#include "qurl.h" +#include "private/qurltlds_p.h" +#include "private/qtldurl_p.h" +#include "QtCore/qstringlist.h" + +QT_BEGIN_NAMESPACE + +static bool containsTLDEntry(const QString &entry) +{ + int index = qHash(entry) % tldCount; + int currentDomainIndex = tldIndices[index]; + while (currentDomainIndex < tldIndices[index+1]) { + QString currentEntry = QString::fromUtf8(tldData + currentDomainIndex); + if (currentEntry == entry) + return true; + currentDomainIndex += qstrlen(tldData + currentDomainIndex) + 1; // +1 for the ending \0 + } + return false; +} + +/*! + \internal + + Return the top-level-domain per Qt's copy of the Mozilla public suffix list of + \a domain. +*/ + +Q_CORE_EXPORT QString qTopLevelDomain(const QString &domain) +{ + QStringList sections = domain.toLower().split(QLatin1Char('.'), QString::SkipEmptyParts); + if (sections.isEmpty()) + return QString(); + + QString level, tld; + for (int j = sections.count() - 1; j >= 0; --j) { + level.prepend(QLatin1Char('.') + sections.at(j)); + if (qIsEffectiveTLD(level.right(level.size() - 1))) + tld = level; + } + return tld; +} + +/*! + \internal + + Return true if \a domain is a top-level-domain per Qt's copy of the Mozilla public suffix list. +*/ + +Q_CORE_EXPORT bool qIsEffectiveTLD(const QString &domain) +{ + // for domain 'foo.bar.com': + // 1. return if TLD table contains 'foo.bar.com' + if (containsTLDEntry(domain)) + return true; + + if (domain.contains(QLatin1Char('.'))) { + int count = domain.size() - domain.indexOf(QLatin1Char('.')); + QString wildCardDomain; + wildCardDomain.reserve(count + 1); + wildCardDomain.append(QLatin1Char('*')); + wildCardDomain.append(domain.right(count)); + // 2. if table contains '*.bar.com', + // test if table contains '!foo.bar.com' + if (containsTLDEntry(wildCardDomain)) { + QString exceptionDomain; + exceptionDomain.reserve(domain.size() + 1); + exceptionDomain.append(QLatin1Char('!')); + exceptionDomain.append(domain); + return (! containsTLDEntry(exceptionDomain)); + } + } + return false; +} + +QT_END_NAMESPACE diff --git a/src/corelib/io/qtldurl_p.h b/src/corelib/io/qtldurl_p.h new file mode 100644 index 0000000000..152ffa0f63 --- /dev/null +++ b/src/corelib/io/qtldurl_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore 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 QTLDURL_P_H +#define QTLDURL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qDecodeDataUrl. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtCore/qurl.h" +#include "QtCore/qstring.h" + +QT_BEGIN_NAMESPACE + +Q_CORE_EXPORT QString qTopLevelDomain(const QString &domain); +Q_CORE_EXPORT bool qIsEffectiveTLD(const QString &domain); + +QT_END_NAMESPACE + +#endif // QDATAURL_P_H diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 92ce5ab794..881365678f 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -192,7 +192,9 @@ #if defined QT3_SUPPORT #include "qfileinfo.h" #endif - +#ifndef QT_BOOTSTRAPPED +#include "qtldurl_p.h" +#endif #if defined(Q_OS_WINCE_WM) #pragma optimize("g", off) #endif @@ -5592,6 +5594,21 @@ bool QUrl::hasFragment() const return d->hasFragment; } +/*! + \since 4.8 + + Returns the TLD (Top-Level Domain) of the URL, (e.g. .co.uk, .net). + Note that the return value is prefixed with a '.' unless the + URL does not contain a valid TLD, in which case the function returns + an empty string. +*/ +#ifndef QT_BOOTSTRAPPED +QString QUrl::topLevelDomain() const +{ + return qTopLevelDomain(host()); +} +#endif + /*! Returns the result of the merge of this URL with \a relative. This URL is used as a base to convert \a relative to an absolute URL. diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 96b23d179d..d57a0c77df 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -181,6 +181,9 @@ public: void setEncodedFragment(const QByteArray &fragment); QByteArray encodedFragment() const; bool hasFragment() const; +#ifndef QT_BOOTSTRAPPED + QString topLevelDomain() const; +#endif QUrl resolved(const QUrl &relative) const; diff --git a/src/network/access/qnetworkcookiejartlds_p.h b/src/corelib/io/qurltlds_p.h similarity index 99% rename from src/network/access/qnetworkcookiejartlds_p.h rename to src/corelib/io/qurltlds_p.h index b06d881131..f4f525ced7 100644 --- a/src/network/access/qnetworkcookiejartlds_p.h +++ b/src/corelib/io/qurltlds_p.h @@ -38,15 +38,15 @@ // the terms of any one of the MPL, the GPL or the LGPL. // -#ifndef QNETWORKCOOKIEJARTLD_P_H -#define QNETWORKCOOKIEJARTLD_P_H +#ifndef QURLTLD_P_H +#define QURLTLD_P_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of the Network Access framework. This header file may change from +// of the Network Access and Core framework. This header file may change from // version to version without notice, or even be removed. // // We mean it. @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE // note to maintainer: // this file should be updated before each release -> // for instructions see the program at -// util/network/cookiejar-generateTLDs +// util/corelib/qurl-generateTLDs static const quint16 tldCount = 3949; static const quint16 tldIndices[] = { @@ -6478,4 +6478,4 @@ static const char tldData[] = { QT_END_NAMESPACE -#endif // QNETWORKCOOKIEJARTLD_P_H +#endif // QURLTLD_P_H diff --git a/src/network/access/qnetworkcookiejartlds_p.h.INFO b/src/corelib/io/qurltlds_p.h.INFO similarity index 62% rename from src/network/access/qnetworkcookiejartlds_p.h.INFO rename to src/corelib/io/qurltlds_p.h.INFO index 57a8d0e0cc..5781c2c678 100644 --- a/src/network/access/qnetworkcookiejartlds_p.h.INFO +++ b/src/corelib/io/qurltlds_p.h.INFO @@ -1,15 +1,15 @@ -The file qnetworkcookiejartlds_p.h is generated from the Public Suffix +The file qurltlds_p.h is generated from the Public Suffix List (see [1] and [2]), by the program residing at -util/network/cookiejar-generateTLDs in the Qt source tree. +util/corelib/qurl-generateTLDs in the Qt source tree. That program generates a character array and an index array from the list to provide fast lookups of elements within C++. -Those arrays in qnetworkcookiejartlds_p.h are derived from the Public +Those arrays in qurltlds_p.h are derived from the Public Suffix List ([2]), which was originally provided by Jo Hermans . -The file qnetworkcookiejartlds_p.h was last generated Friday, +The file qurltlds_p.h was last generated Friday, November 19th 15:24 2010. ---- diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 9cd353a7da..eb29e6eba8 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -42,9 +42,96 @@ #include "quuid.h" #include "qdatastream.h" +#include "qendian.h" QT_BEGIN_NAMESPACE +#ifndef QT_NO_QUUID_STRING +template +void _q_toHex(Char *&dst, Integral value) +{ + static const char digits[] = "0123456789abcdef"; + + value = qToBigEndian(value); + + const char* p = reinterpret_cast(&value); + + for (uint i = 0; i < sizeof(Integral); ++i, dst += 2) { + uint j = (p[i] >> 4) & 0xf; + dst[0] = Char(digits[j]); + j = p[i] & 0xf; + dst[1] = Char(digits[j]); + } +} + +template +bool _q_fromHex(const Char *&src, Integral &value) +{ + value = 0; + + for (uint i = 0; i < sizeof(Integral) * 2; ++i) { + int ch = *src++; + int tmp; + if (ch >= '0' && ch <= '9') + tmp = ch - '0'; + else if (ch >= 'a' && ch <= 'f') + tmp = ch - 'a' + 10; + else if (ch >= 'A' && ch <= 'F') + tmp = ch - 'A' + 10; + else + return false; + + value = value * 16 + tmp; + } + + return true; +} + +template +void _q_uuidToHex(Char *&dst, const uint &d1, const ushort &d2, const ushort &d3, const uchar (&d4)[8]) +{ + *dst++ = Char('{'); + _q_toHex(dst, d1); + *dst++ = Char('-'); + _q_toHex(dst, d2); + *dst++ = Char('-'); + _q_toHex(dst, d3); + *dst++ = Char('-'); + for (int i = 0; i < 2; i++) + _q_toHex(dst, d4[i]); + *dst++ = Char('-'); + for (int i = 2; i < 8; i++) + _q_toHex(dst, d4[i]); + *dst = Char('}'); +} + +template +bool _q_uuidFromHex(const Char *&src, uint &d1, ushort &d2, ushort &d3, uchar (&d4)[8]) +{ + if (*src == Char('{')) + src++; + if (!_q_fromHex(src, d1) + || *src++ != Char('-') + || !_q_fromHex(src, d2) + || *src++ != Char('-') + || !_q_fromHex(src, d3) + || *src++ != Char('-') + || !_q_fromHex(src, d4[0]) + || !_q_fromHex(src, d4[1]) + || *src++ != Char('-') + || !_q_fromHex(src, d4[2]) + || !_q_fromHex(src, d4[3]) + || !_q_fromHex(src, d4[4]) + || !_q_fromHex(src, d4[5]) + || !_q_fromHex(src, d4[6]) + || !_q_fromHex(src, d4[7])) { + return false; + } + + return true; +} +#endif + /*! \class QUuid \brief The QUuid class stores a Universally Unique Identifier (UUID). @@ -231,50 +318,22 @@ QT_BEGIN_NAMESPACE */ QUuid::QUuid(const QString &text) { - bool ok; - if (text.isEmpty()) { - *this = QUuid(); - return; - } - QString temp = text.toUpper(); - if (temp[0] != QLatin1Char('{')) - temp = QLatin1Char('{') + text; - if (text[(int)text.length()-1] != QLatin1Char('}')) - temp += QLatin1Char('}'); - - data1 = temp.mid(1, 8).toULongLong(&ok, 16); - if (!ok) { + if (text.length() < 36) { *this = QUuid(); return; } - data2 = temp.mid(10, 4).toUInt(&ok, 16); - if (!ok) { + const ushort *data = reinterpret_cast(text.unicode()); + + if (*data == '{' && text.length() < 37) { *this = QUuid(); return; } - data3 = temp.mid(15, 4).toUInt(&ok, 16); - if (!ok) { + + if (!_q_uuidFromHex(data, data1, data2, data3, data4)) { *this = QUuid(); return; } - data4[0] = temp.mid(20, 2).toUInt(&ok, 16); - if (!ok) { - *this = QUuid(); - return; - } - data4[1] = temp.mid(22, 2).toUInt(&ok, 16); - if (!ok) { - *this = QUuid(); - return; - } - for (int i = 2; i<8; i++) { - data4[i] = temp.mid(25 + (i-2)*2, 2).toUShort(&ok, 16); - if (!ok) { - *this = QUuid(); - return; - } - } } /*! @@ -282,10 +341,90 @@ QUuid::QUuid(const QString &text) */ QUuid::QUuid(const char *text) { - *this = QUuid(QString::fromLatin1(text)); + if (!text) { + *this = QUuid(); + return; + } + + if (!_q_uuidFromHex(text, data1, data2, data3, data4)) { + *this = QUuid(); + return; + } +} + +/*! + Creates a QUuid object from the QByteArray \a text, which must be + formatted as five hex fields separated by '-', e.g., + "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where 'x' is a hex + digit. The curly braces shown here are optional, but it is normal to + include them. If the conversion fails, a null UUID is created. See + toByteArray() for an explanation of how the five hex fields map to the + public data members in QUuid. + + \since 4.8 + + \sa toByteArray(), QUuid() +*/ +QUuid::QUuid(const QByteArray &text) +{ + if (text.length() < 36) { + *this = QUuid(); + return; + } + + const char *data = text.constData(); + + if (*data == '{' && text.length() < 37) { + *this = QUuid(); + return; + } + + if (!_q_uuidFromHex(data, data1, data2, data3, data4)) { + *this = QUuid(); + return; + } } #endif +/*! + Creates a QUuid object from the binary representation of the UUID, as + specified by RFC 4122 section 4.1.2. See toRfc4122() for a further + explanation of the order of bytes required. + + The byte array accepted is NOT a human readable format. + + If the conversion fails, a null UUID is created. + + \since 4.8 + + \sa toRfc4122(), QUuid() +*/ +QUuid QUuid::fromRfc4122(const QByteArray &bytes) +{ + if (bytes.isEmpty() || bytes.length() != 16) + return QUuid(); + + uint d1; + ushort d2, d3; + uchar d4[8]; + + const uchar *data = reinterpret_cast(bytes.constData()); + + d1 = qFromBigEndian(data); + data += sizeof(quint32); + d2 = qFromBigEndian(data); + data += sizeof(quint16); + d3 = qFromBigEndian(data); + data += sizeof(quint16); + + for (int i = 0; i < 8; ++i) { + d4[i] = *(data); + data++; + } + + return QUuid(d1, d2, d3, d4[0], d4[1], d4[2], d4[3], d4[4], d4[5], d4[6], d4[7]); +} + /*! \fn bool QUuid::operator==(const QUuid &other) const @@ -308,11 +447,6 @@ QUuid::QUuid(const char *text) \sa toString() */ -static QString uuidhex(uint data, int digits) -{ - return QString::number(data, 16).rightJustified(digits, QLatin1Char('0')); -} - /*! Returns the string representation of this QUuid. The string is formatted as five hex fields separated by '-' and enclosed in @@ -349,25 +483,114 @@ static QString uuidhex(uint data, int digits) */ QString QUuid::toString() const { - QString result; + QString result(38, Qt::Uninitialized); + ushort *data = (ushort *)result.unicode(); - QChar dash = QLatin1Char('-'); - result = QLatin1Char('{') + uuidhex(data1,8); - result += dash; - result += uuidhex(data2,4); - result += dash; - result += uuidhex(data3,4); - result += dash; - result += uuidhex(data4[0],2); - result += uuidhex(data4[1],2); - result += dash; - for (int i = 2; i < 8; i++) - result += uuidhex(data4[i],2); + _q_uuidToHex(data, data1, data2, data3, data4); - return result + QLatin1Char('}'); + return result; +} + +/*! + Returns the binary representation of this QUuid. The byte array is + formatted as five hex fields separated by '-' and enclosed in + curly braces, i.e., "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where + 'x' is a hex digit. From left to right, the five hex fields are + obtained from the four public data members in QUuid as follows: + + \table + \header + \o Field # + \o Source + + \row + \o 1 + \o data1 + + \row + \o 2 + \o data2 + + \row + \o 3 + \o data3 + + \row + \o 4 + \o data4[0] .. data4[1] + + \row + \o 5 + \o data4[2] .. data4[7] + + \endtable + + \since 4.8 +*/ +QByteArray QUuid::toByteArray() const +{ + QByteArray result(38, Qt::Uninitialized); + char *data = result.data(); + + _q_uuidToHex(data, data1, data2, data3, data4); + + return result; } #endif +/*! + Returns the binary representation of this QUuid. The byte array is in big + endian format, and formatted according to RFC 4122, section 4.1.2 - + "Layout and byte order". + + The order is as follows: + + \table + \header + \o Field # + \o Source + + \row + \o 1 + \o data1 + + \row + \o 2 + \o data2 + + \row + \o 3 + \o data3 + + \row + \o 4 + \o data4[0] .. data4[7] + + \endtable + + \since 4.8 +*/ +QByteArray QUuid::toRfc4122() const +{ + // we know how many bytes a UUID has, I hope :) + QByteArray bytes(16, Qt::Uninitialized); + uchar *data = reinterpret_cast(bytes.data()); + + qToBigEndian(data1, data); + data += sizeof(quint32); + qToBigEndian(data2, data); + data += sizeof(quint16); + qToBigEndian(data3, data); + data += sizeof(quint16); + + for (int i = 0; i < 8; ++i) { + *(data) = data4[i]; + data++; + } + + return bytes; +} + #ifndef QT_NO_DATASTREAM /*! \relates QUuid @@ -375,11 +598,30 @@ QString QUuid::toString() const */ QDataStream &operator<<(QDataStream &s, const QUuid &id) { - s << (quint32)id.data1; - s << (quint16)id.data2; - s << (quint16)id.data3; - for (int i = 0; i < 8; i++) - s << (quint8)id.data4[i]; + QByteArray bytes; + if (s.byteOrder() == QDataStream::BigEndian) { + bytes = id.toRfc4122(); + } else { + // we know how many bytes a UUID has, I hope :) + bytes = QByteArray(16, Qt::Uninitialized); + uchar *data = reinterpret_cast(bytes.data()); + + qToLittleEndian(id.data1, data); + data += sizeof(quint32); + qToLittleEndian(id.data2, data); + data += sizeof(quint16); + qToLittleEndian(id.data3, data); + data += sizeof(quint16); + + for (int i = 0; i < 8; ++i) { + *(data) = id.data4[i]; + data++; + } + } + + if (s.writeRawData(bytes.data(), 16) != 16) { + s.setStatus(QDataStream::WriteFailed); + } return s; } @@ -389,19 +631,30 @@ QDataStream &operator<<(QDataStream &s, const QUuid &id) */ QDataStream &operator>>(QDataStream &s, QUuid &id) { - quint32 u32; - quint16 u16; - quint8 u8; - s >> u32; - id.data1 = u32; - s >> u16; - id.data2 = u16; - s >> u16; - id.data3 = u16; - for (int i = 0; i < 8; i++) { - s >> u8; - id.data4[i] = u8; + QByteArray bytes(16, Qt::Uninitialized); + if (s.readRawData(bytes.data(), 16) != 16) { + s.setStatus(QDataStream::ReadPastEnd); + return s; } + + if (s.byteOrder() == QDataStream::BigEndian) { + id = QUuid::fromRfc4122(bytes); + } else { + const uchar *data = reinterpret_cast(bytes.constData()); + + id.data1 = qFromLittleEndian(data); + data += sizeof(quint32); + id.data2 = qFromLittleEndian(data); + data += sizeof(quint16); + id.data3 = qFromLittleEndian(data); + data += sizeof(quint16); + + for (int i = 0; i < 8; ++i) { + id.data4[i] = *(data); + data++; + } + } + return s; } #endif // QT_NO_DATASTREAM diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index f42ca91270..832d5bc5c6 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -108,8 +108,12 @@ struct Q_CORE_EXPORT QUuid QUuid(const QString &); QUuid(const char *); QString toString() const; - operator QString() const { return toString(); } + operator QString() const { return toString(); } // ### Qt5 remove + QUuid(const QByteArray &); + QByteArray toByteArray() const; #endif + QByteArray toRfc4122() const; + static QUuid fromRfc4122(const QByteArray &); bool isNull() const; bool operator==(const QUuid &orig) const diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index e6f041fe3c..4eb05d63b6 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -641,6 +641,8 @@ Q_OUTOFLINE_TEMPLATE QList QList::mid(int pos, int alength) const if (pos == 0 && alength == size()) return *this; QList cpy; + if (alength <= 0) + return cpy; cpy.reserve(alength); cpy.d->end = alength; QT_TRY { diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 192ddb41e0..ad8c6c9ab5 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -879,10 +879,10 @@ QStringList QFontDatabasePrivate::addTTFile(const QByteArray &file, const QByteA TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, ft_sfnt_os2); if (os2) { quint32 unicodeRange[4] = { - os2->ulUnicodeRange1, os2->ulUnicodeRange2, os2->ulUnicodeRange3, os2->ulUnicodeRange4 + static_cast(os2->ulUnicodeRange1), static_cast(os2->ulUnicodeRange2), static_cast(os2->ulUnicodeRange3), static_cast(os2->ulUnicodeRange4) }; quint32 codePageRange[2] = { - os2->ulCodePageRange1, os2->ulCodePageRange2 + static_cast(os2->ulCodePageRange1), static_cast(os2->ulCodePageRange2) }; writingSystems = qt_determine_writing_systems_from_truetype_bits(unicodeRange, codePageRange); diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 9c0feebbc8..dfe3e410f6 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2825,6 +2825,75 @@ QFixed QTextEngine::offsetInLigature(const QScriptItem *si, int pos, int max, in return 0; } +// Scan in logClusters[from..to-1] for glyph_pos +int QTextEngine::getClusterLength(unsigned short *logClusters, + const HB_CharAttributes *attributes, + int from, int to, int glyph_pos, int *start) +{ + int clusterLength = 0; + for (int i = from; i < to; i++) { + if (logClusters[i] == glyph_pos && attributes[i].charStop) { + if (*start < 0) + *start = i; + clusterLength++; + } + else if (clusterLength) + break; + } + return clusterLength; +} + +int QTextEngine::positionInLigature(const QScriptItem *si, int end, + QFixed x, QFixed edge, int glyph_pos, + bool cursorOnCharacter) +{ + unsigned short *logClusters = this->logClusters(si); + int clusterStart = -1; + int clusterLength = 0; + + if (si->analysis.script != QUnicodeTables::Common && + si->analysis.script != QUnicodeTables::Greek) { + if (glyph_pos == -1) + return si->position + end; + else { + int i; + for (i = 0; i < end; i++) + if (logClusters[i] == glyph_pos) + break; + return si->position + i; + } + } + + if (glyph_pos == -1 && end > 0) + glyph_pos = logClusters[end - 1]; + else { + if (x <= edge) + glyph_pos--; + } + + const HB_CharAttributes *attrs = attributes(); + clusterLength = getClusterLength(logClusters, attrs, 0, end, glyph_pos, &clusterStart); + + if (clusterLength) { + const QGlyphLayout &glyphs = shapedGlyphs(si); + QFixed glyphWidth = glyphs.effectiveAdvance(glyph_pos); + // the approximate width of each individual element of the ligature + QFixed perItemWidth = glyphWidth / clusterLength; + QFixed left = x > edge ? edge : edge - glyphWidth; + int n = ((x - left) / perItemWidth).floor().toInt(); + QFixed dist = x - left - n * perItemWidth; + int closestItem = dist > (perItemWidth / 2) ? n + 1 : n; + if (cursorOnCharacter && closestItem > 0) + closestItem--; + int pos = si->position + clusterStart + closestItem; + // Jump to the next charStop + while (!attrs[pos].charStop && pos < end) + pos++; + return pos; + } + return si->position + end; +} + int QTextEngine::previousLogicalPosition(int oldPos) const { const HB_CharAttributes *attrs = attributes(); diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index ef322bd6ee..21f36aee7f 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -620,6 +620,7 @@ public: QFixed leadingSpaceWidth(const QScriptLine &line); QFixed offsetInLigature(const QScriptItem *si, int pos, int max, int glyph_pos); + int positionInLigature(const QScriptItem *si, int end, QFixed x, QFixed edge, int glyph_pos, bool cursorOnCharacter); int previousLogicalPosition(int oldPos) const; int nextLogicalPosition(int oldPos) const; int lineNumberForTextPosition(int pos); @@ -642,6 +643,7 @@ private: void resolveAdditionalFormats() const; int endOfLine(int lineNum); int beginningOfLine(int lineNum); + int getClusterLength(unsigned short *logClusters, const HB_CharAttributes *attributes, int from, int to, int glyph_pos, int *start); }; class Q_GUI_EXPORT QStackTextEngine : public QTextEngine { diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index b9f29df1fe..a88b46625a 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2607,8 +2607,8 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const } else { bool rtl = eng->isRightToLeft(); bool visual = eng->visualCursorMovement(); + int end = qMin(lineEnd, si->position + l) - si->position; if (reverse) { - int end = qMin(lineEnd, si->position + l) - si->position; int glyph_end = end == l ? si->num_glyphs : logClusters[end]; int glyph_start = glyph_pos; if (visual && !rtl && !(lastLine && itm == (visualOrder[nItems - 1] + firstItem))) @@ -2624,7 +2624,7 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const for (int i = glyph_start; i <= glyph_end; i++) x += glyphs.effectiveAdvance(i); } - x += eng->offsetInLigature(si, pos, line.length, glyph_pos); + x += eng->offsetInLigature(si, pos, end, glyph_pos); } *cursorPos = pos + si->position; @@ -2739,6 +2739,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const } int glyph_pos = -1; + QFixed edge; // has to be inside run if (cpos == QTextLine::CursorOnCharacter) { if (si.analysis.bidiLevel % 2) { @@ -2749,6 +2750,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const if (pos < x) break; glyph_pos = gs; + edge = pos; break; } pos -= glyphs.effectiveAdvance(gs); @@ -2761,6 +2763,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const if (pos > x) break; glyph_pos = gs; + edge = pos; } pos += glyphs.effectiveAdvance(gs); ++gs; @@ -2774,6 +2777,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const while (gs <= ge) { if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) { glyph_pos = gs; + edge = pos; dist = qAbs(x-pos); } pos -= glyphs.effectiveAdvance(gs); @@ -2783,6 +2787,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const while (ge >= gs) { if (glyphs.attributes[ge].clusterStart && qAbs(x-pos) < dist) { glyph_pos = ge; + edge = pos; dist = qAbs(x-pos); } pos += glyphs.effectiveAdvance(ge); @@ -2794,6 +2799,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const while (gs <= ge) { if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) { glyph_pos = gs; + edge = pos; dist = qAbs(x-pos); } pos += glyphs.effectiveAdvance(gs); @@ -2805,6 +2811,7 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const pos += glyphs.effectiveAdvance(gs); if (glyphs.attributes[gs].clusterStart && qAbs(x-pos) < dist) { glyph_pos = gs; + edge = pos; dist = qAbs(x-pos); } ++gs; @@ -2821,16 +2828,13 @@ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const if (rtl && nchars > 0) return insertionPoints[lastLine ? nchars : nchars - 1]; } - return si.position + end; + return eng->positionInLigature(&si, end, x, pos, -1, + cpos == QTextLine::CursorOnCharacter); } } Q_ASSERT(glyph_pos != -1); - int j; - for (j = 0; j < eng->length(item); ++j) - if (logClusters[j] == glyph_pos) - break; -// qDebug("at pos %d (in run: %d)", si.position + j, j); - return si.position + j; + return eng->positionInLigature(&si, end, x, edge, glyph_pos, + cpos == QTextLine::CursorOnCharacter); } } // right of last item diff --git a/src/network/access/access.pri b/src/network/access/access.pri index 0f901b873d..3d5558d334 100644 --- a/src/network/access/access.pri +++ b/src/network/access/access.pri @@ -21,7 +21,6 @@ HEADERS += \ access/qnetworkcookie_p.h \ access/qnetworkcookiejar.h \ access/qnetworkcookiejar_p.h \ - access/qnetworkcookiejartlds_p.h \ access/qnetworkrequest.h \ access/qnetworkrequest_p.h \ access/qnetworkreply.h \ diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 33124fdd67..d950af4ee2 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -261,7 +261,17 @@ void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair) // set the host value = request.headerField("host"); if (value.isEmpty()) { - QByteArray host = QUrl::toAce(hostName); + QHostAddress add; + QByteArray host; + if (add.setAddress(hostName)) { + if (add.protocol() == QAbstractSocket::IPv6Protocol) + host = "[" + hostName.toAscii() + "]";//format the ipv6 in the standard way + else + host = hostName.toAscii(); + + } else { + host = QUrl::toAce(hostName); + } int port = request.url().port(); if (port != -1) { diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp index 291bdec0cf..a2fa689256 100644 --- a/src/network/access/qnetworkcookiejar.cpp +++ b/src/network/access/qnetworkcookiejar.cpp @@ -40,12 +40,12 @@ ****************************************************************************/ #include "qnetworkcookiejar.h" -#include "qnetworkcookiejartlds_p.h" #include "qnetworkcookiejar_p.h" #include "QtNetwork/qnetworkcookie.h" #include "QtCore/qurl.h" #include "QtCore/qdatetime.h" +#include "private/qtldurl_p.h" QT_BEGIN_NAMESPACE @@ -216,7 +216,7 @@ bool QNetworkCookieJar::setCookiesFromUrl(const QList &cookieLis // the check for effective TLDs makes the "embedded dot" rule from RFC 2109 section 4.3.2 // redundant; the "leading dot" rule has been relaxed anyway, see above // we remove the leading dot for this check - if (QNetworkCookieJarPrivate::isEffectiveTLD(domain.remove(0, 1))) + if (qIsEffectiveTLD(domain.remove(0, 1))) continue; // not accepted } @@ -304,43 +304,4 @@ QList QNetworkCookieJar::cookiesForUrl(const QUrl &url) const return result; } -bool QNetworkCookieJarPrivate::isEffectiveTLD(const QString &domain) -{ - // for domain 'foo.bar.com': - // 1. return if TLD table contains 'foo.bar.com' - if (containsTLDEntry(domain)) - return true; - - if (domain.contains(QLatin1Char('.'))) { - int count = domain.size() - domain.indexOf(QLatin1Char('.')); - QString wildCardDomain; - wildCardDomain.reserve(count + 1); - wildCardDomain.append(QLatin1Char('*')); - wildCardDomain.append(domain.right(count)); - // 2. if table contains '*.bar.com', - // test if table contains '!foo.bar.com' - if (containsTLDEntry(wildCardDomain)) { - QString exceptionDomain; - exceptionDomain.reserve(domain.size() + 1); - exceptionDomain.append(QLatin1Char('!')); - exceptionDomain.append(domain); - return (! containsTLDEntry(exceptionDomain)); - } - } - return false; -} - -bool QNetworkCookieJarPrivate::containsTLDEntry(const QString &entry) -{ - int index = qHash(entry) % tldCount; - int currentDomainIndex = tldIndices[index]; - while (currentDomainIndex < tldIndices[index+1]) { - QString currentEntry = QString::fromUtf8(tldData + currentDomainIndex); - if (currentEntry == entry) - return true; - currentDomainIndex += qstrlen(tldData + currentDomainIndex) + 1; // +1 for the ending \0 - } - return false; -} - QT_END_NAMESPACE diff --git a/src/network/access/qnetworkcookiejar_p.h b/src/network/access/qnetworkcookiejar_p.h index 912847b8f0..34858d9c92 100644 --- a/src/network/access/qnetworkcookiejar_p.h +++ b/src/network/access/qnetworkcookiejar_p.h @@ -63,9 +63,6 @@ class QNetworkCookieJarPrivate: public QObjectPrivate public: QList allCookies; - static bool Q_AUTOTEST_EXPORT isEffectiveTLD(const QString &domain); - static bool containsTLDEntry(const QString &entry); - Q_DECLARE_PUBLIC(QNetworkCookieJar) }; diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 338cf59c02..54cd898c67 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -488,7 +488,7 @@ void QNetworkConfigurationManagerPrivate::enablePolling() ++forcedPolling; if (forcedPolling == 1) - startPolling(); + QMetaObject::invokeMethod(this, "startPolling"); } void QNetworkConfigurationManagerPrivate::disablePolling() diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index 02e00b9a95..04cce202c5 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -107,7 +107,7 @@ private Q_SLOTS: void pollEngines(); private: - void startPolling(); + Q_INVOKABLE void startPolling(); QTimer *pollTimer; private: diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 5f5db17072..5c672ec227 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -149,6 +149,8 @@ bool QHttpSocketEngine::connectInternal() // Handshake isn't done. If unconnected, start connecting. if (d->state == None && d->socket->state() == QAbstractSocket::UnconnectedState) { setState(QAbstractSocket::ConnectingState); + //limit buffer in internal socket, data is buffered in the external socket under application control + d->socket->setReadBufferSize(65536); d->socket->connectToHost(d->proxy.hostName(), d->proxy.port()); } diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 575c0bc73e..ab757987f6 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1126,6 +1126,8 @@ bool QSocks5SocketEngine::connectInternal() if (d->socks5State == QSocks5SocketEnginePrivate::Uninitialized && d->socketState != QAbstractSocket::ConnectingState) { setState(QAbstractSocket::ConnectingState); + //limit buffer in internal socket, data is buffered in the external socket under application control + d->data->controlSocket->setReadBufferSize(65536); d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port()); return false; } diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 328c5c228c..76b7d41e46 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -127,7 +127,7 @@ QT_BEGIN_NAMESPACE // forward declaration -static QMap _q_mapFromOnelineName(char *name); +static QMap _q_mapFromX509Name(X509_NAME *name); /*! Constructs a QSslCertificate by reading \a format encoded data @@ -324,7 +324,7 @@ QString QSslCertificate::issuerInfo(SubjectInfo info) const // lazy init if (d->issuerInfo.isEmpty() && d->x509) d->issuerInfo = - _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_issuer_name(d->x509), 0, 0)); + _q_mapFromX509Name(q_X509_get_issuer_name(d->x509)); return d->issuerInfo.value(_q_SubjectInfoToString(info)); } @@ -341,7 +341,7 @@ QString QSslCertificate::issuerInfo(const QByteArray &tag) const // lazy init if (d->issuerInfo.isEmpty() && d->x509) d->issuerInfo = - _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_issuer_name(d->x509), 0, 0)); + _q_mapFromX509Name(q_X509_get_issuer_name(d->x509)); return d->issuerInfo.value(QString::fromLatin1(tag)); } @@ -360,7 +360,7 @@ QString QSslCertificate::subjectInfo(SubjectInfo info) const // lazy init if (d->subjectInfo.isEmpty() && d->x509) d->subjectInfo = - _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_subject_name(d->x509), 0, 0)); + _q_mapFromX509Name(q_X509_get_subject_name(d->x509)); return d->subjectInfo.value(_q_SubjectInfoToString(info)); } @@ -376,7 +376,7 @@ QString QSslCertificate::subjectInfo(const QByteArray &tag) const // lazy init if (d->subjectInfo.isEmpty() && d->x509) d->subjectInfo = - _q_mapFromOnelineName(q_X509_NAME_oneline(q_X509_get_subject_name(d->x509), 0, 0)); + _q_mapFromX509Name(q_X509_get_subject_name(d->x509)); return d->subjectInfo.value(QString::fromLatin1(tag)); } @@ -666,37 +666,17 @@ QByteArray QSslCertificatePrivate::QByteArray_from_X509(X509 *x509, QSsl::Encodi return BEGINCERTSTRING "\n" + tmp + ENDCERTSTRING "\n"; } -static QMap _q_mapFromOnelineName(char *name) +static QMap _q_mapFromX509Name(X509_NAME *name) { QMap info; - QString infoStr = QString::fromLocal8Bit(name); - q_CRYPTO_free(name); - - // ### The right-hand encoding seems to allow hex (Regulierungsbeh\xC8orde) - //entry.replace(QLatin1String("\\x"), QLatin1String("%")); - //entry = QUrl::fromPercentEncoding(entry.toLatin1()); - // ### See RFC-4630 for more details! - - QRegExp rx(QLatin1String("/([A-Za-z]+)=(.+)")); - - int pos = 0; - while ((pos = rx.indexIn(infoStr, pos)) != -1) { - const QString name = rx.cap(1); - - QString value = rx.cap(2); - const int valuePos = rx.pos(2); - - const int next = rx.indexIn(value); - if (next == -1) { - info.insert(name, value); - break; - } - - value = value.left(next); - info.insert(name, value); - pos = valuePos + value.length(); + for (int i = 0; i < q_X509_NAME_entry_count(name); ++i) { + X509_NAME_ENTRY *e = q_X509_NAME_get_entry(name, i); + const char *obj = q_OBJ_nid2sn(q_OBJ_obj2nid(q_X509_NAME_ENTRY_get_object(e))); + unsigned char *data = 0; + int size = q_ASN1_STRING_to_UTF8(&data, q_X509_NAME_ENTRY_get_data(e)); + info[QString::fromUtf8(obj)] = QString::fromUtf8((char*)data, size); + q_CRYPTO_free(data); } - return info; } diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index a730eb2a39..a4cc3c493d 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -101,6 +101,7 @@ DEFINEFUNC3(void *, ASN1_dup, i2d_of_void *a, a, d2i_of_void *b, b, char *c, c, DEFINEFUNC(long, ASN1_INTEGER_get, ASN1_INTEGER *a, a, return 0, return) DEFINEFUNC(unsigned char *, ASN1_STRING_data, ASN1_STRING *a, a, return 0, return) DEFINEFUNC(int, ASN1_STRING_length, ASN1_STRING *a, a, return 0, return) +DEFINEFUNC2(int, ASN1_STRING_to_UTF8, unsigned char **a, a, ASN1_STRING *b, b, return 0, return); DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return) DEFINEFUNC(int, BIO_free, BIO *a, a, return 0, return) DEFINEFUNC(BIO *, BIO_new, BIO_METHOD *a, a, return 0, return) @@ -248,7 +249,10 @@ DEFINEFUNC4(void *, X509_get_ext_d2i, X509 *a, a, int b, b, int *c, c, int *d, d DEFINEFUNC(X509_NAME *, X509_get_issuer_name, X509 *a, a, return 0, return) DEFINEFUNC(X509_NAME *, X509_get_subject_name, X509 *a, a, return 0, return) DEFINEFUNC(int, X509_verify_cert, X509_STORE_CTX *a, a, return -1, return) -DEFINEFUNC3(char *, X509_NAME_oneline, X509_NAME *a, a, char *b, b, int c, c, return 0, return) +DEFINEFUNC(int, X509_NAME_entry_count, X509_NAME *a, a, return 0, return) +DEFINEFUNC2(X509_NAME_ENTRY *, X509_NAME_get_entry, X509_NAME *a, a, int b, b, return 0, return) +DEFINEFUNC(ASN1_STRING *, X509_NAME_ENTRY_get_data, X509_NAME_ENTRY *a, a, return 0, return) +DEFINEFUNC(ASN1_OBJECT *, X509_NAME_ENTRY_get_object, X509_NAME_ENTRY *a, a, return 0, return) DEFINEFUNC(EVP_PKEY *, X509_PUBKEY_get, X509_PUBKEY *a, a, return 0, return) DEFINEFUNC(void, X509_STORE_free, X509_STORE *a, a, return, DUMMYARG) DEFINEFUNC(X509_STORE *, X509_STORE_new, DUMMYARG, DUMMYARG, return 0, return) @@ -518,6 +522,7 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(ASN1_INTEGER_get, 48, libs.second ) RESOLVEFUNC(ASN1_STRING_data, 71, libs.second ) RESOLVEFUNC(ASN1_STRING_length, 76, libs.second ) + RESOLVEFUNC(ASN1_STRING_to_UTF8, 86, libs.second ) RESOLVEFUNC(BIO_ctrl, 184, libs.second ) RESOLVEFUNC(BIO_free, 209, libs.second ) RESOLVEFUNC(BIO_new, 222, libs.second ) @@ -608,7 +613,10 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(SSLv23_server_method, 191, libs.first ) RESOLVEFUNC(TLSv1_server_method, 200, libs.first ) RESOLVEFUNC(SSL_CTX_load_verify_locations, 34, libs.first ) - RESOLVEFUNC(X509_NAME_oneline, 1830, libs.second ) + RESOLVEFUNC(X509_NAME_entry_count, 1821, libs.second ) + RESOLVEFUNC(X509_NAME_get_entry, 1823, libs.second ) + RESOLVEFUNC(X509_NAME_ENTRY_get_data, 1808, libs.second ) + RESOLVEFUNC(X509_NAME_ENTRY_get_object, 1809, libs.second ) RESOLVEFUNC(X509_PUBKEY_get, 1844, libs.second ) RESOLVEFUNC(X509_STORE_free, 1939, libs.second ) RESOLVEFUNC(X509_STORE_new, 1942, libs.second ) @@ -647,6 +655,7 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(ASN1_INTEGER_get) RESOLVEFUNC(ASN1_STRING_data) RESOLVEFUNC(ASN1_STRING_length) + RESOLVEFUNC(ASN1_STRING_to_UTF8) RESOLVEFUNC(BIO_ctrl) RESOLVEFUNC(BIO_free) RESOLVEFUNC(BIO_new) @@ -736,7 +745,10 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(SSLv3_server_method) RESOLVEFUNC(SSLv23_server_method) RESOLVEFUNC(TLSv1_server_method) - RESOLVEFUNC(X509_NAME_oneline) + RESOLVEFUNC(X509_NAME_entry_count) + RESOLVEFUNC(X509_NAME_get_entry) + RESOLVEFUNC(X509_NAME_ENTRY_get_data) + RESOLVEFUNC(X509_NAME_ENTRY_get_object) RESOLVEFUNC(X509_PUBKEY_get) RESOLVEFUNC(X509_STORE_free) RESOLVEFUNC(X509_STORE_new) diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index e20deb80a7..c0a3b4da6a 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -204,6 +204,7 @@ bool q_resolveOpenSslSymbols(); long q_ASN1_INTEGER_get(ASN1_INTEGER *a); unsigned char * q_ASN1_STRING_data(ASN1_STRING *a); int q_ASN1_STRING_length(ASN1_STRING *a); +int q_ASN1_STRING_to_UTF8(unsigned char **a, ASN1_STRING *b); long q_BIO_ctrl(BIO *a, int b, long c, void *d); int q_BIO_free(BIO *a); BIO *q_BIO_new(BIO_METHOD *a); @@ -360,7 +361,10 @@ void *q_X509_get_ext_d2i(X509 *a, int b, int *c, int *d); X509_NAME *q_X509_get_issuer_name(X509 *a); X509_NAME *q_X509_get_subject_name(X509 *a); int q_X509_verify_cert(X509_STORE_CTX *ctx); -char *q_X509_NAME_oneline(X509_NAME *a, char *b, int c); +int q_X509_NAME_entry_count(X509_NAME *a); +X509_NAME_ENTRY *q_X509_NAME_get_entry(X509_NAME *a,int b); +ASN1_STRING *q_X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *a); +ASN1_OBJECT *q_X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *a); EVP_PKEY *q_X509_PUBKEY_get(X509_PUBKEY *a); void q_X509_STORE_free(X509_STORE *store); X509_STORE *q_X509_STORE_new(); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index fd1269ef3e..dc07a6f77d 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1795,7 +1795,7 @@ static void convertFromGLImage(QImage &img, int w, int h, bool alpha_format, boo img = img.mirrored(); } -QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha) +Q_OPENGL_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha) { QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 0af8108f03..682c26255d 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE -extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool); +extern Q_OPENGL_EXPORT QImage qt_gl_read_framebuffer(const QSize&, bool, bool); #define QGL_FUNC_CONTEXT const QGLContext *ctx = d_ptr->fbo_guard.context(); #define QGL_FUNCP_CONTEXT const QGLContext *ctx = fbo_guard.context(); diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index 3afb3b1fae..45e7cdd875 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -113,7 +113,7 @@ extern void qgl_cleanup_glyph_cache(QGLContext *); void qgl_cleanup_glyph_cache(QGLContext *) {} #endif -extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool); +extern Q_OPENGL_EXPORT QImage qt_gl_read_framebuffer(const QSize&, bool, bool); QGLContext* QGLPBufferGLPaintDevice::context() const diff --git a/src/plugins/accessible/widgets/widgets.pro b/src/plugins/accessible/widgets/widgets.pro index 8fb42fbb03..6dd7e5022b 100644 --- a/src/plugins/accessible/widgets/widgets.pro +++ b/src/plugins/accessible/widgets/widgets.pro @@ -1,5 +1,5 @@ TARGET = qtaccessiblewidgets -include(../../qpluginbase.pri) +load(qt_plugin) include (../qaccessiblebase.pri) QT += core-private gui-private widgets-private diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro index f57a0c930b..25243f8e0a 100644 --- a/src/plugins/bearer/connman/connman.pro +++ b/src/plugins/bearer/connman/connman.pro @@ -1,5 +1,5 @@ TARGET = qconnmanbearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core network-private dbus diff --git a/src/plugins/bearer/corewlan/corewlan.pro b/src/plugins/bearer/corewlan/corewlan.pro index adc1625c3d..0d11b1e9d3 100644 --- a/src/plugins/bearer/corewlan/corewlan.pro +++ b/src/plugins/bearer/corewlan/corewlan.pro @@ -1,5 +1,5 @@ TARGET = qcorewlanbearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core-private network-private LIBS += -framework Foundation -framework SystemConfiguration diff --git a/src/plugins/bearer/generic/generic.pro b/src/plugins/bearer/generic/generic.pro index 94fefaf6c2..4f86c2a38c 100644 --- a/src/plugins/bearer/generic/generic.pro +++ b/src/plugins/bearer/generic/generic.pro @@ -1,5 +1,5 @@ TARGET = qgenericbearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core-private network-private diff --git a/src/plugins/bearer/icd/icd.pro b/src/plugins/bearer/icd/icd.pro index 4737045ae7..3f5753409d 100644 --- a/src/plugins/bearer/icd/icd.pro +++ b/src/plugins/bearer/icd/icd.pro @@ -1,5 +1,5 @@ TARGET = qicdbearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core network dbus diff --git a/src/plugins/bearer/nativewifi/nativewifi.pro b/src/plugins/bearer/nativewifi/nativewifi.pro index ba02f37d23..ec86cc0b93 100644 --- a/src/plugins/bearer/nativewifi/nativewifi.pro +++ b/src/plugins/bearer/nativewifi/nativewifi.pro @@ -1,5 +1,5 @@ TARGET = qnativewifibearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core-private network-private diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro index a9de1561fd..262f60a69c 100644 --- a/src/plugins/bearer/networkmanager/networkmanager.pro +++ b/src/plugins/bearer/networkmanager/networkmanager.pro @@ -1,5 +1,5 @@ TARGET = qnmbearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core network-private dbus diff --git a/src/plugins/bearer/nla/nla.pro b/src/plugins/bearer/nla/nla.pro index ecf958f559..76da098dbf 100644 --- a/src/plugins/bearer/nla/nla.pro +++ b/src/plugins/bearer/nla/nla.pro @@ -1,5 +1,5 @@ TARGET = qnlabearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core network diff --git a/src/plugins/bearer/symbian/symbian.pri b/src/plugins/bearer/symbian/symbian.pri index 5d2ae1a5cd..c4b3c6d09d 100644 --- a/src/plugins/bearer/symbian/symbian.pri +++ b/src/plugins/bearer/symbian/symbian.pri @@ -1,5 +1,5 @@ TARGET = qsymbianbearer -include(../../qpluginbase.pri) +load(qt_plugin) QT = core network diff --git a/src/plugins/codecs/cn/cn.pro b/src/plugins/codecs/cn/cn.pro index 51a2f41372..fc2e94b5a6 100644 --- a/src/plugins/codecs/cn/cn.pro +++ b/src/plugins/codecs/cn/cn.pro @@ -1,5 +1,5 @@ TARGET = qcncodecs -include(../../qpluginbase.pri) +load(qt_plugin) CONFIG += warn_on DESTDIR = $$QT.core.plugins/codecs diff --git a/src/plugins/codecs/jp/jp.pro b/src/plugins/codecs/jp/jp.pro index e6b7a4bb7f..834ca31ad6 100644 --- a/src/plugins/codecs/jp/jp.pro +++ b/src/plugins/codecs/jp/jp.pro @@ -1,5 +1,5 @@ TARGET = qjpcodecs -include(../../qpluginbase.pri) +load(qt_plugin) CONFIG += warn_on DESTDIR = $$QT.core.plugins/codecs diff --git a/src/plugins/codecs/kr/kr.pro b/src/plugins/codecs/kr/kr.pro index 14c162c6e8..f5aea6554f 100644 --- a/src/plugins/codecs/kr/kr.pro +++ b/src/plugins/codecs/kr/kr.pro @@ -1,5 +1,5 @@ TARGET = qkrcodecs -include(../../qpluginbase.pri) +load(qt_plugin) CONFIG += warn_on DESTDIR = $$QT.core.plugins/codecs diff --git a/src/plugins/codecs/tw/tw.pro b/src/plugins/codecs/tw/tw.pro index b0d5a2b68a..f76cba4dbc 100644 --- a/src/plugins/codecs/tw/tw.pro +++ b/src/plugins/codecs/tw/tw.pro @@ -1,5 +1,5 @@ TARGET = qtwcodecs -include(../../qpluginbase.pri) +load(qt_plugin) CONFIG += warn_on DESTDIR = $$QT.core.plugins/codecs diff --git a/src/plugins/generic/linuxinput/linuxinput.pro b/src/plugins/generic/linuxinput/linuxinput.pro index d4dc4bbbcb..a771ee9734 100644 --- a/src/plugins/generic/linuxinput/linuxinput.pro +++ b/src/plugins/generic/linuxinput/linuxinput.pro @@ -1,5 +1,5 @@ TARGET = qlinuxinputplugin -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/generic target.path = $$[QT_INSTALL_PLUGINS]/generic diff --git a/src/plugins/generic/tslib/tslib.pro b/src/plugins/generic/tslib/tslib.pro index 485152181c..d9726b6d3a 100644 --- a/src/plugins/generic/tslib/tslib.pro +++ b/src/plugins/generic/tslib/tslib.pro @@ -1,5 +1,5 @@ TARGET = qlinuxinputplugin -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/generic target.path = $$[QT_INSTALL_PLUGINS]/generic diff --git a/src/plugins/imageformats/gif/gif.pro b/src/plugins/imageformats/gif/gif.pro index 4b72cae6e4..b8d260e43c 100644 --- a/src/plugins/imageformats/gif/gif.pro +++ b/src/plugins/imageformats/gif/gif.pro @@ -1,5 +1,5 @@ TARGET = qgif -include(../../qpluginbase.pri) +load(qt_plugin) include(../../../gui/image/qgifhandler.pri) SOURCES += $$PWD/main.cpp diff --git a/src/plugins/imageformats/ico/ico.pro b/src/plugins/imageformats/ico/ico.pro index cef92cedc8..e0109c6a32 100644 --- a/src/plugins/imageformats/ico/ico.pro +++ b/src/plugins/imageformats/ico/ico.pro @@ -1,5 +1,5 @@ TARGET = qico -include(../../qpluginbase.pri) +load(qt_plugin) QTDIR_build:REQUIRES = "!contains(QT_CONFIG, no-ico)" diff --git a/src/plugins/imageformats/jpeg/jpeg.pro b/src/plugins/imageformats/jpeg/jpeg.pro index 1e6c24d061..aa489729a1 100644 --- a/src/plugins/imageformats/jpeg/jpeg.pro +++ b/src/plugins/imageformats/jpeg/jpeg.pro @@ -1,5 +1,5 @@ TARGET = qjpeg -include(../../qpluginbase.pri) +load(qt_plugin) QT += core-private diff --git a/src/plugins/imageformats/mng/mng.pro b/src/plugins/imageformats/mng/mng.pro index 01dc418c1b..72dc506cf9 100644 --- a/src/plugins/imageformats/mng/mng.pro +++ b/src/plugins/imageformats/mng/mng.pro @@ -1,5 +1,5 @@ TARGET = qmng -include(../../qpluginbase.pri) +load(qt_plugin) QTDIR_build:REQUIRES = "!contains(QT_CONFIG, no-mng)" diff --git a/src/plugins/imageformats/tiff/tiff.pro b/src/plugins/imageformats/tiff/tiff.pro index e4eb21b1e7..012c49ecf1 100644 --- a/src/plugins/imageformats/tiff/tiff.pro +++ b/src/plugins/imageformats/tiff/tiff.pro @@ -1,5 +1,5 @@ TARGET = qtiff -include(../../qpluginbase.pri) +load(qt_plugin) QTDIR_build:REQUIRES = "!contains(QT_CONFIG, no-tiff)" diff --git a/src/plugins/inputmethods/imsw-multi/imsw-multi.pro b/src/plugins/inputmethods/imsw-multi/imsw-multi.pro index e37212abee..c67be02ba4 100644 --- a/src/plugins/inputmethods/imsw-multi/imsw-multi.pro +++ b/src/plugins/inputmethods/imsw-multi/imsw-multi.pro @@ -1,5 +1,5 @@ TARGET = qimsw-multi -include(../../qpluginbase.pri) +load(qt_plugin) CONFIG += warn_on QT += widgets diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 5d751631a9..117dbe46d9 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -1,5 +1,5 @@ TARGET = qcocoa -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/platforms OBJECTIVE_SOURCES = main.mm \ diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro index 4a637463ef..f830177dcb 100644 --- a/src/plugins/platforms/directfb/directfb.pro +++ b/src/plugins/platforms/directfb/directfb.pro @@ -1,5 +1,5 @@ TARGET = qdirectfb -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/platforms isEmpty(DIRECTFB_LIBS) { diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro index 3692e38e1b..471cf63dd8 100644 --- a/src/plugins/platforms/eglfs/eglfs.pro +++ b/src/plugins/platforms/eglfs/eglfs.pro @@ -2,7 +2,7 @@ TARGET = qeglfs TEMPLATE = lib CONFIG += plugin -QT += opengl +QT += opengl core-private gui-private opengl-private DESTDIR = $$QT.gui.plugins/platforms diff --git a/src/plugins/platforms/externalplugin.pri b/src/plugins/platforms/externalplugin.pri index 54da4d957c..9b00acb4e9 100644 --- a/src/plugins/platforms/externalplugin.pri +++ b/src/plugins/platforms/externalplugin.pri @@ -26,4 +26,4 @@ QT_SOURCE_TREE = $$fromfile($$(QTDIR)/.qmake.cache,QT_SOURCE_TREE) QT_BUILD_TREE = $$fromfile($$(QTDIR)/.qmake.cache,QT_BUILD_TREE) -include($$QT_SOURCE_TREE/src/plugins/qpluginbase.pri) +load(qt_plugin) diff --git a/src/plugins/platforms/fb_base/fb_base.pro b/src/plugins/platforms/fb_base/fb_base.pro index 4445516cc7..4ebd53b407 100644 --- a/src/plugins/platforms/fb_base/fb_base.pro +++ b/src/plugins/platforms/fb_base/fb_base.pro @@ -6,7 +6,7 @@ #QT -= core gui TARGET = fb_base -#include(../../qpluginbase.pri) +#load(qt_plugin) DESTDIR = $$QT.gui.plugins/graphicssystems diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro index 4e4fe6ff4b..ce6814ecc1 100644 --- a/src/plugins/platforms/linuxfb/linuxfb.pro +++ b/src/plugins/platforms/linuxfb/linuxfb.pro @@ -1,5 +1,5 @@ TARGET = qlinuxfbgraphicssystem -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/platforms diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro index 5c8b55478a..d51b6b2ed0 100644 --- a/src/plugins/platforms/minimal/minimal.pro +++ b/src/plugins/platforms/minimal/minimal.pro @@ -1,6 +1,5 @@ TARGET = qminimal -include(../../qpluginbase.pri) -QT += gui-private core-private +load(qt_plugin) QT = core-private gui-private DESTDIR = $$QT.gui.plugins/platforms diff --git a/src/plugins/platforms/openkode/openkode.pro b/src/plugins/platforms/openkode/openkode.pro index a6e7d7665a..ad17a3bc78 100644 --- a/src/plugins/platforms/openkode/openkode.pro +++ b/src/plugins/platforms/openkode/openkode.pro @@ -1,5 +1,5 @@ TARGET = qopenkodeintegration -include(../../qpluginbase.pri) +load(qt_plugin) QT += opengl diff --git a/src/plugins/platforms/openvglite/openvglite.pro b/src/plugins/platforms/openvglite/openvglite.pro index 11e867d998..bb7efe9bf3 100644 --- a/src/plugins/platforms/openvglite/openvglite.pro +++ b/src/plugins/platforms/openvglite/openvglite.pro @@ -1,5 +1,5 @@ TARGET = qvglitegraphicssystem -include(../../qpluginbase.pri) +load(qt_plugin) QT += openvg diff --git a/src/plugins/platforms/qvfb/qvfb.pro b/src/plugins/platforms/qvfb/qvfb.pro index bc17525104..5db8533264 100644 --- a/src/plugins/platforms/qvfb/qvfb.pro +++ b/src/plugins/platforms/qvfb/qvfb.pro @@ -1,5 +1,5 @@ TARGET = qvfbintegration -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/platforms diff --git a/src/plugins/platforms/uikit/uikit.pro b/src/plugins/platforms/uikit/uikit.pro index 6f5947f2c0..45a48dc92a 100644 --- a/src/plugins/platforms/uikit/uikit.pro +++ b/src/plugins/platforms/uikit/uikit.pro @@ -1,5 +1,5 @@ TARGET = quikit -include(../../qpluginbase.pri) +load(qt_plugin) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms QT += opengl diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro index a7b8ca540a..85bffb0637 100644 --- a/src/plugins/platforms/vnc/vnc.pro +++ b/src/plugins/platforms/vnc/vnc.pro @@ -1,5 +1,5 @@ TARGET = qvncgraphicssystem -include(../../qpluginbase.pri) +load(qt_plugin) QT += network diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 2a71f3ee04..f1c9ccc18f 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -139,6 +139,11 @@ QWaylandDisplay::QWaylandDisplay(void) #ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration = QWaylandGLIntegration::createGLIntegration(this); #endif + +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT + mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this); +#endif + blockingReadEvents(); qRegisterMetaType("uint32_t"); @@ -147,10 +152,6 @@ QWaylandDisplay::QWaylandDisplay(void) mEglIntegration->initialize(); #endif -#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT - mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this); -#endif - connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests())); mFd = wl_display_get_fd(mDisplay, sourceUpdate, this); diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index e8919d7047..1232df6d52 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -68,6 +68,7 @@ QWaylandWindow::QWaylandWindow(QWindow *window) #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT mDisplay->windowManagerIntegration()->mapClientToProcess(qApp->applicationPid()); + mDisplay->windowManagerIntegration()->authenticateWithToken(); #endif mSurface = mDisplay->createSurface(this); diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index e49c73bfae..5bf751b6e9 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -1,5 +1,5 @@ TARGET = qwayland -include(../../qpluginbase.pri) +load(qt_plugin) QT+=gui-private core-private opengl-private diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h index ec776c5f87..73673aef6f 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h @@ -36,16 +36,37 @@ struct wl_client; struct wl_windowmanager; +struct wl_proxy; + +extern void +wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...); +extern struct wl_proxy * +wl_proxy_create(struct wl_proxy *factory, + const struct wl_interface *interface); +extern struct wl_proxy * +wl_proxy_create_for_id(struct wl_display *display, + const struct wl_interface *interface, uint32_t id); +extern void +wl_proxy_destroy(struct wl_proxy *proxy); + +extern int +wl_proxy_add_listener(struct wl_proxy *proxy, + void (**implementation)(void), void *data); + +extern void +wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data); + +extern void * +wl_proxy_get_user_data(struct wl_proxy *proxy); + extern const struct wl_interface wl_windowmanager_interface; -#define WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0 +#define wl_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0 +#define wl_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN 1 static inline struct wl_windowmanager * -wl_windowmanager_create(struct wl_display *display, uint32_t id, uint32_t /*version*/) +wl_windowmanager_create(struct wl_display *display, uint32_t id) { - // ### does not run without latest wayland. must be enabled later - //wl_display_bind(display, id, "wl_windowmanager", version); - return (struct wl_windowmanager *) wl_proxy_create_for_id(display, &wl_windowmanager_interface, id); } @@ -72,7 +93,14 @@ static inline void wl_windowmanager_map_client_to_process(struct wl_windowmanager *wl_windowmanager, uint32_t processid) { wl_proxy_marshal((struct wl_proxy *) wl_windowmanager, - WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid); + wl_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid); +} + +static inline void +wl_windowmanager_authenticate_with_token(struct wl_windowmanager *wl_windowmanager, const char *wl_authentication_token) +{ + wl_proxy_marshal((struct wl_proxy *) wl_windowmanager, + wl_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN, wl_authentication_token); } #ifdef __cplusplus diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp index bf8342308e..4236f395cb 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp @@ -68,12 +68,11 @@ struct wl_windowmanager *QWaylandWindowManagerIntegration::windowManager() const return mWaylandWindowManager; } -void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface, - uint32_t version, void *data) +void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data) { if (strcmp(interface, "wl_windowmanager") == 0) { QWaylandWindowManagerIntegration *integration = static_cast(data); - integration->mWaylandWindowManager = wl_windowmanager_create(display,id, version); + integration->mWaylandWindowManager = wl_windowmanager_create(display, id); } } @@ -83,3 +82,11 @@ void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId) wl_windowmanager_map_client_to_process(mWaylandWindowManager, (uint32_t) processId); } +void QWaylandWindowManagerIntegration::authenticateWithToken(const QByteArray &token) +{ + QByteArray authToken = token; + if (authToken.isEmpty()) + authToken = qgetenv("WL_AUTHENTICATION_TOKEN"); + if (mWaylandWindowManager) + wl_windowmanager_authenticate_with_token(mWaylandWindowManager, authToken.constData()); +} diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h index 01b814f22a..0e3781dbe2 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h @@ -56,6 +56,7 @@ public: void mapSurfaceToProcess(struct wl_surface *surface, long long processId); void mapClientToProcess(long long processId); + void authenticateWithToken(const QByteArray &token = QByteArray()); private: static void wlHandleListenerGlobal(wl_display *display, uint32_t id, diff --git a/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c b/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c index 48049d8571..0250801b1f 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c +++ b/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c @@ -26,7 +26,8 @@ #include "wayland-util.h" static const struct wl_message wl_windowmanager_requests[] = { - { "map_client_to_process", "u", NULL }, + { "map_client_to_process", "u" }, + { "authenticate_with_token", "s" }, }; WL_EXPORT const struct wl_interface wl_windowmanager_interface = { diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index 04db369f48..b78844a8d4 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -1,6 +1,6 @@ TARGET = xcb -include(../../qpluginbase.pri) +load(qt_plugin) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms QT += core-private gui-private diff --git a/src/plugins/platforms/xlib/xlib.pro b/src/plugins/platforms/xlib/xlib.pro index 902d379ee2..2cba5513d5 100644 --- a/src/plugins/platforms/xlib/xlib.pro +++ b/src/plugins/platforms/xlib/xlib.pro @@ -1,6 +1,6 @@ TARGET = qxlib -include(../../qpluginbase.pri) +load(qt_plugin) DESTDIR = $$QT.gui.plugins/platforms QT += core-private gui-private opengl-private diff --git a/src/plugins/qpluginbase.pri b/src/plugins/qpluginbase.pri index 2dd96bf7f2..b22a527761 100644 --- a/src/plugins/qpluginbase.pri +++ b/src/plugins/qpluginbase.pri @@ -1,41 +1 @@ -TEMPLATE = lib -isEmpty(QT_MAJOR_VERSION) { - VERSION=5.0.0 -} else { - VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} -} -CONFIG += qt plugin - -win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release -TARGET = $$qtLibraryTarget($$TARGET) -contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols - -include(../qt_targets.pri) - -wince*:LIBS += $$QMAKE_LIBS_GUI - -symbian: { - TARGET.EPOCALLOWDLLDATA=1 - TARGET.CAPABILITY = All -Tcb - TARGET = $${TARGET}$${QT_LIBINFIX} - load(armcc_warnings) - - # Make partial upgrade SIS file for Qt plugin dll's - # Partial upgrade SIS file - vendorinfo = \ - "; Localised Vendor name" \ - "%{\"Nokia\"}" \ - " " \ - "; Unique Vendor name" \ - ":\"Nokia, Qt\"" \ - " " - isEmpty(QT_LIBINFIX): PARTIAL_UPGRADE_UID = 0x2001E61C - else: PARTIAL_UPGRADE_UID = 0xE001E61C - - pu_header = "; Partial upgrade package for testing $${TARGET} changes without reinstalling everything" \ - "$${LITERAL_HASH}{\"$${TARGET}\"}, ($$PARTIAL_UPGRADE_UID), $${QT_MAJOR_VERSION},$${QT_MINOR_VERSION},$${QT_PATCH_VERSION}, TYPE=PU" - partial_upgrade.pkg_prerules = pu_header vendorinfo - partial_upgrade.files = $$QMAKE_LIBDIR_QT/$${TARGET}.dll - partial_upgrade.path = c:/sys/bin - DEPLOYMENT += partial_upgrade -} +load(qt_plugin) diff --git a/src/plugins/s60/s60pluginbase.pri b/src/plugins/s60/s60pluginbase.pri index 0cde7d2277..41d4b27db2 100644 --- a/src/plugins/s60/s60pluginbase.pri +++ b/src/plugins/s60/s60pluginbase.pri @@ -1,6 +1,6 @@ # Note: These version based 'plugins' are not an actual Qt plugins, # they are just regular runtime loaded libraries -include(../qpluginbase.pri) +load(qt_plugin) CONFIG -= plugin diff --git a/src/plugins/sqldrivers/qsqldriverbase.pri b/src/plugins/sqldrivers/qsqldriverbase.pri index 7399c659da..45638fcd4f 100644 --- a/src/plugins/sqldrivers/qsqldriverbase.pri +++ b/src/plugins/sqldrivers/qsqldriverbase.pri @@ -1,4 +1,4 @@ -include(../qpluginbase.pri) +load(qt_plugin) QT = core sql-private DESTDIR = $$QT.sql.plugins/sqldrivers diff --git a/src/testlib/qtestaccessible.h b/src/testlib/qtestaccessible.h index 9df54ce438..a58ed2ff69 100644 --- a/src/testlib/qtestaccessible.h +++ b/src/testlib/qtestaccessible.h @@ -49,8 +49,6 @@ #ifndef QT_NO_ACCESSIBILITY -#define QTEST_ACCESSIBILITY - #define QVERIFY_EVENT(object, child, event) \ QVERIFY(QTestAccessibility::verifyEvent(object, child, (int)event)) @@ -131,9 +129,9 @@ private: if (object) { QApplication* app = qobject_cast(object); if ( !app ) - qWarning("QTEST_ACCESSIBILITY: root Object is not a QApplication!"); + qWarning("%s: root Object is not a QApplication!", Q_FUNC_INFO); } else { - qWarning("QTEST_ACCESSIBILITY: root Object called with 0 pointer"); + qWarning("%s: root Object called with 0 pointer", Q_FUNC_INFO); } } diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index 16a87c8d7b..c4613e20ae 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -82,7 +82,7 @@ static inline QString moduleHeader(const QString &module, const QString &header) namespace CPP { WriteIncludes::WriteIncludes(Uic *uic) - : m_uic(uic), m_output(uic->output()), m_scriptsActivated(false) + : m_uic(uic), m_output(uic->output()), m_scriptsActivated(false), m_laidOut(false) { // When possible (no namespace) use the "QtModule/QClass" convention // and create a re-mapping of the old header "qclass.h" to it. Do not do this @@ -106,6 +106,7 @@ WriteIncludes::WriteIncludes(Uic *uic) void WriteIncludes::acceptUI(DomUI *node) { m_scriptsActivated = false; + m_laidOut = false; m_localIncludes.clear(); m_globalIncludes.clear(); m_knownClasses.clear(); @@ -144,6 +145,7 @@ void WriteIncludes::acceptWidget(DomWidget *node) void WriteIncludes::acceptLayout(DomLayout *node) { add(node->attributeClass()); + m_laidOut = true; TreeWalker::acceptLayout(node); } @@ -220,6 +222,9 @@ void WriteIncludes::add(const QString &className, bool determineHeader, const QS m_knownClasses.insert(className); + if (!m_laidOut && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBox"))) + add(QLatin1String("QLayout")); // spacing property of QToolBox) + if (className == QLatin1String("Line")) { // ### hmm, deprecate me! add(QLatin1String("QFrame")); return; diff --git a/src/tools/uic/cpp/cppwriteincludes.h b/src/tools/uic/cpp/cppwriteincludes.h index 39b1ddf897..e8215364b9 100644 --- a/src/tools/uic/cpp/cppwriteincludes.h +++ b/src/tools/uic/cpp/cppwriteincludes.h @@ -107,6 +107,7 @@ private: StringMap m_oldHeaderToNewHeader; bool m_scriptsActivated; + bool m_laidOut; }; } // namespace CPP diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 8660991b17..72da6db457 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1452,7 +1452,7 @@ void WriteInitialization::writeProperties(const QString &varName, case DomProperty::Url: { const DomUrl* u = p->elementUrl(); - propertyValue = QString::fromLatin1("QUrl(%1)") + propertyValue = QString::fromLatin1("QUrl(QString::fromUtf8(%1))") .arg(fixString(u->elementString()->text(), m_dindent)); break; } diff --git a/src/widgets/platforms/mac/qcocoasharedwindowmethods_mac_p.h b/src/widgets/platforms/mac/qcocoasharedwindowmethods_mac_p.h index e2539aaaf1..f5a93d98d2 100644 --- a/src/widgets/platforms/mac/qcocoasharedwindowmethods_mac_p.h +++ b/src/widgets/platforms/mac/qcocoasharedwindowmethods_mac_p.h @@ -199,19 +199,6 @@ QT_END_NAMESPACE [super setInitialFirstResponder:view]; } -- (void)setInitialFirstResponder:(NSView *)view -{ - // This method is called the first time the window is placed on screen and - // is the earliest point in time we can connect OpenGL contexts to NSViews. - QWidget *qwidget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; - if (qwidget) { - qt_event_request_window_change(qwidget); - qt_mac_send_posted_gl_updates(qwidget); - } - - [super setInitialFirstResponder:view]; -} - - (BOOL)makeFirstResponder:(NSResponder *)responder { // For some reason Cocoa wants to flip the first responder diff --git a/src/widgets/platforms/mac/qfontengine_coretext.mm b/src/widgets/platforms/mac/qfontengine_coretext.mm index 24bd750e80..737edc3a8c 100644 --- a/src/widgets/platforms/mac/qfontengine_coretext.mm +++ b/src/widgets/platforms/mac/qfontengine_coretext.mm @@ -100,7 +100,12 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const QCFString &name, const QCFType descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pixelSize); QCFType baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, &transform); - ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, &transform, symbolicTraits, symbolicTraits); + ctfont = NULL; + // There is a side effect in Core Text: if we apply 0 as symbolic traits to a font in normal weight, + // we will get the light version of that font (while the way supposed to work doesn't: + // setting kCTFontWeightTrait to some value between -1.0 to 0.0 has no effect on font selection) + if (fontDef.weight != QFont::Normal || symbolicTraits) + ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, &transform, symbolicTraits, symbolicTraits); // CTFontCreateCopyWithSymbolicTraits returns NULL if we ask for a trait that does // not exist for the given font. (for example italic) diff --git a/src/widgets/platforms/mac/qpixmap_mac.cpp b/src/widgets/platforms/mac/qpixmap_mac.cpp index 7e31f5b80b..cb3016177d 100644 --- a/src/widgets/platforms/mac/qpixmap_mac.cpp +++ b/src/widgets/platforms/mac/qpixmap_mac.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -73,12 +74,18 @@ static int qt_pixmap_serial = 0; Q_GUI_EXPORT quint32 *qt_mac_pixmap_get_base(const QPixmap *pix) { - return static_cast(pix->data.data())->pixels; + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) + return reinterpret_cast(static_cast(pix->data.data())->buffer()->bits()); + else + return static_cast(pix->data.data())->pixels; } Q_GUI_EXPORT int qt_mac_pixmap_get_bytes_per_line(const QPixmap *pix) { - return static_cast(pix->data.data())->bytesPerRow; + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) + return static_cast(pix->data.data())->buffer()->bytesPerLine(); + else + return static_cast(pix->data.data())->bytesPerRow; } void qt_mac_cgimage_data_free(void *info, const void *memoryToFree, size_t) diff --git a/src/widgets/platforms/mac/qwidget_mac.mm b/src/widgets/platforms/mac/qwidget_mac.mm index 9a873f32ac..3a025e9237 100644 --- a/src/widgets/platforms/mac/qwidget_mac.mm +++ b/src/widgets/platforms/mac/qwidget_mac.mm @@ -4541,6 +4541,11 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM QPoint oldp = q->pos(); QSize olds = q->size(); + // Apply size restrictions, applicable for Windows & Widgets. + if (QWExtra *extra = extraData()) { + w = qBound(extra->minw, w, extra->maxw); + h = qBound(extra->minh, h, extra->maxh); + } const bool isResize = (olds != QSize(w, h)); if (!realWindow && !isResize && QPoint(x, y) == oldp) @@ -4550,13 +4555,6 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM data.window_state = data.window_state & ~Qt::WindowMaximized; const bool visible = q->isVisible(); - // Apply size restrictions, applicable for Windows & Widgets. - if (QWExtra *extra = extraData()) { - w = qMin(w, extra->maxw); - h = qMin(h, extra->maxh); - w = qMax(w, extra->minw); - h = qMax(h, extra->minh); - } data.crect = QRect(x, y, w, h); if (realWindow) { diff --git a/src/widgets/platforms/x11/qfontdatabase_x11.cpp b/src/widgets/platforms/x11/qfontdatabase_x11.cpp index 8a13d91fbb..a5fdcb5216 100644 --- a/src/widgets/platforms/x11/qfontdatabase_x11.cpp +++ b/src/widgets/platforms/x11/qfontdatabase_x11.cpp @@ -1996,6 +1996,11 @@ void QFontDatabase::load(const QFontPrivate *d, int script) QFontCache::instance()->insertEngine(key, fe); } +// Needed for fontconfig version < 2.2.97 +#ifndef FC_FAMILYLANG +#define FC_FAMILYLANG "familylang" +#endif + static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) { #if defined(QT_NO_FONTCONFIG) diff --git a/src/widgets/platforms/x11/qfontengine_x11.cpp b/src/widgets/platforms/x11/qfontengine_x11.cpp index 099704894c..e3bfa5df46 100644 --- a/src/widgets/platforms/x11/qfontengine_x11.cpp +++ b/src/widgets/platforms/x11/qfontengine_x11.cpp @@ -1205,7 +1205,9 @@ QFontEngine *QFontEngineX11FT::cloneWithSize(qreal pixelSize) const delete fe; return 0; } else { +#ifndef QT_NO_XRENDER fe->xglyph_format = xglyph_format; +#endif return fe; } } diff --git a/src/widgets/to_be_moved/qlinecontrol.cpp b/src/widgets/to_be_moved/qlinecontrol.cpp index ee7d7fb126..bf36033c08 100644 --- a/src/widgets/to_be_moved/qlinecontrol.cpp +++ b/src/widgets/to_be_moved/qlinecontrol.cpp @@ -435,6 +435,8 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) c += event->commitString().length() - qMin(-event->replacementStart(), event->replacementLength()); m_cursor += event->replacementStart(); + if (m_cursor < 0) + m_cursor = 0; // insert commit string if (event->replacementLength()) { @@ -447,7 +449,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) cursorPositionChanged = true; } - m_cursor = qMin(c, m_text.length()); + m_cursor = qBound(0, c, m_text.length()); for (int i = 0; i < event->attributes().size(); ++i) { const QInputMethodEvent::Attribute &a = event->attributes().at(i); diff --git a/src/widgets/to_be_moved/qtextcontrol.cpp b/src/widgets/to_be_moved/qtextcontrol.cpp index 149c29213e..ab294b9e0d 100644 --- a/src/widgets/to_be_moved/qtextcontrol.cpp +++ b/src/widgets/to_be_moved/qtextcontrol.cpp @@ -677,7 +677,7 @@ void QTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, qrea const qreal wordEndX = line.cursorToX(curs.position() - blockPos) + blockCoordinates.x(); - if (mouseXPosition < wordStartX || mouseXPosition > wordEndX) + if (!wordSelectionEnabled && (mouseXPosition < wordStartX || mouseXPosition > wordEndX)) return; // keep the already selected word even when moving to the left @@ -1579,8 +1579,10 @@ void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, con emit q->cursorPositionChanged(); _q_updateCurrentCharFormatAndSelection(); } else { - if (cursor.position() != oldCursorPos) + if (cursor.position() != oldCursorPos) { emit q->cursorPositionChanged(); + emit q->microFocusChanged(); + } selectionChanged(); } repaintOldAndNewSelection(oldSelection); diff --git a/tests/auto/macgui/macgui.pro b/tests/auto/macgui/macgui.pro index 0ed2350a48..7e40d81808 100644 --- a/tests/auto/macgui/macgui.pro +++ b/tests/auto/macgui/macgui.pro @@ -7,5 +7,7 @@ INCLUDEPATH += . SOURCES += tst_macgui.cpp guitest.cpp HEADERS += guitest.h +QT = core-private gui-private + requires(mac) diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 6c0e2611c0..03b2d79bba 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -947,21 +947,16 @@ void tst_QAccessibility::doAction() void tst_QAccessibility::applicationTest() { -#ifdef QTEST_ACCESSIBILITY QLatin1String name = QLatin1String("My Name"); qApp->setApplicationName(name); QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(qApp); QCOMPARE(interface->text(QAccessible::Name, 0), name); QCOMPARE(interface->role(0), QAccessible::Application); delete interface; -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::mainWindowTest() { -#ifdef QTEST_ACCESSIBILITY QMainWindow mw; mw.resize(300, 200); mw.show(); // triggers layout @@ -974,10 +969,6 @@ void tst_QAccessibility::mainWindowTest() QCOMPARE(interface->text(QAccessible::Name, 0), name); QCOMPARE(interface->role(0), QAccessible::Window); delete interface; - -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } class CounterButton : public QPushButton { @@ -1295,7 +1286,6 @@ void tst_QAccessibility::tabTest() void tst_QAccessibility::tabWidgetTest() { -#ifdef QTEST_ACCESSIBILITY QTabWidget *tabWidget = new QTabWidget(); tabWidget->show(); @@ -1381,9 +1371,6 @@ void tst_QAccessibility::tabWidgetTest() delete interface; delete tabWidget; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::menuTest() diff --git a/tests/auto/qcompleter/qcompleter.pro b/tests/auto/qcompleter/qcompleter.pro index d23e1eb366..cde64ec672 100644 --- a/tests/auto/qcompleter/qcompleter.pro +++ b/tests/auto/qcompleter/qcompleter.pro @@ -1,6 +1,3 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Apr 26 13:53:24 2006 -###################################################################### load(qttest_p4) TEMPLATE = app TARGET = tst_qcompleter @@ -8,10 +5,5 @@ QT += widgets DEPENDPATH += . INCLUDEPATH += . .. -CONFIG += console qtestlib - # Input SOURCES += tst_qcompleter.cpp - - - diff --git a/tests/auto/qerrormessage/qerrormessage.pro b/tests/auto/qerrormessage/qerrormessage.pro index 4ac8466127..363d085cbf 100644 --- a/tests/auto/qerrormessage/qerrormessage.pro +++ b/tests/auto/qerrormessage/qerrormessage.pro @@ -1,15 +1,10 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Apr 26 13:53:24 2006 -###################################################################### load(qttest_p4) TEMPLATE = app TARGET = tst_qerrormessage DEPENDPATH += . INCLUDEPATH += . + QT += widgets -CONFIG += console qtestlib + # Input SOURCES += tst_qerrormessage.cpp - - - diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp index 74b71ad455..93c08cdc6b 100644 --- a/tests/auto/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp @@ -316,16 +316,16 @@ void tst_QHostInfo::lookupIPv6_data() QTest::addColumn("addresses"); QTest::addColumn("err"); - QTest::newRow("ipv6-net") << "www.ipv6-net.org" << "62.93.217.177 2001:618:1401:0:0:0:0:4" << int(QHostInfo::NoError); - QTest::newRow("ipv6-test") << "ipv6-test.dev.troll.no" << "2001:638:a00:2:0:0:0:2" << int(QHostInfo::NoError); - QTest::newRow("dns6-test") << "dns6-test-dev.troll.no" << "2001:470:1f01:115:0:0:0:10" << int(QHostInfo::NoError); - QTest::newRow("multi-dns6") << "multi-dns6-test-dev.troll.no" << "2001:470:1f01:115:0:0:0:11 2001:470:1f01:115:0:0:0:12" << int(QHostInfo::NoError); - QTest::newRow("dns46-test") << "dns46-test-dev.troll.no" << "10.3.4.90 2001:470:1f01:115:0:0:0:13" << int(QHostInfo::NoError); + QTest::newRow("ipv6-net") << "www.ipv6-net.org" << "62.93.217.177 2001:618:1401::4" << int(QHostInfo::NoError); + QTest::newRow("ipv6-test") << "ipv6-test.dev.troll.no" << "2001:638:a00:2::2" << int(QHostInfo::NoError); + QTest::newRow("dns6-test") << "dns6-test-dev.troll.no" << "2001:470:1f01:115::10" << int(QHostInfo::NoError); + QTest::newRow("multi-dns6") << "multi-dns6-test-dev.troll.no" << "2001:470:1f01:115::11 2001:470:1f01:115::12" << int(QHostInfo::NoError); + QTest::newRow("dns46-test") << "dns46-test-dev.troll.no" << "10.3.4.90 2001:470:1f01:115::13" << int(QHostInfo::NoError); // avoid using real IPv6 addresses here because this will do a DNS query // real addresses are between 2000:: and 3fff:ffff:ffff:ffff:ffff:ffff:ffff QTest::newRow("literal_ip6") << "f001:6b0:1:ea:202:a5ff:fecd:13a6" << "f001:6b0:1:ea:202:a5ff:fecd:13a6" << int(QHostInfo::NoError); - QTest::newRow("literal_shortip6") << "f001:618:1401::4" << "f001:618:1401:0:0:0:0:4" << int(QHostInfo::NoError); + QTest::newRow("literal_shortip6") << "f001:618:1401::4" << "f001:618:1401::4" << int(QHostInfo::NoError); } void tst_QHostInfo::lookupIPv6() diff --git a/tests/auto/qlist/tst_qlist.cpp b/tests/auto/qlist/tst_qlist.cpp index 496f3d9170..3901b6ffe8 100644 --- a/tests/auto/qlist/tst_qlist.cpp +++ b/tests/auto/qlist/tst_qlist.cpp @@ -200,6 +200,9 @@ void tst_QList::mid() const QCOMPARE(list.mid(3, 3), QList() << "bak" << "buck" << "hello"); + + QList list1; + QCOMPARE(list1.mid(1, 1).length(), 0); } void tst_QList::at() const diff --git a/tests/auto/qlocalsocket/lackey/lackey.pro b/tests/auto/qlocalsocket/lackey/lackey.pro index 6af58b122a..2573222c8b 100644 --- a/tests/auto/qlocalsocket/lackey/lackey.pro +++ b/tests/auto/qlocalsocket/lackey/lackey.pro @@ -1,10 +1,6 @@ #include(../src/src.pri) -QT = core script network - -requires(contains(QT_CONFIG,script)) - -CONFIG += qtestlib +QT = core script network testlib DESTDIR = ./ diff --git a/tests/auto/qmessagebox/qmessagebox.pro b/tests/auto/qmessagebox/qmessagebox.pro index cbec1db9b5..bc1402e615 100644 --- a/tests/auto/qmessagebox/qmessagebox.pro +++ b/tests/auto/qmessagebox/qmessagebox.pro @@ -1,6 +1,3 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Apr 26 13:53:24 2006 -###################################################################### load(qttest_p4) TEMPLATE = app TARGET = tst_qmessagebox @@ -8,7 +5,6 @@ QT += widgets DEPENDPATH += . INCLUDEPATH += . -CONFIG += console qtestlib # Input SOURCES += tst_qmessagebox.cpp diff --git a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index 2b11219aa4..d29ef77347 100644 --- a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp +++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -357,7 +357,7 @@ void tst_QNetworkConfigurationManager::usedInThread() connect(&thread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); thread.start(); QTestEventLoop::instance().enterLoop(100); //QTRY_VERIFY could take ~90 seconds to time out in the thread - QVERIFY(thread.isFinished()); + QVERIFY(!QTestEventLoop::instance().timeout()); qDebug() << "prescan:" << thread.preScanConfigs.count(); qDebug() << "postscan:" << thread.configs.count(); @@ -368,7 +368,9 @@ void tst_QNetworkConfigurationManager::usedInThread() QTRY_VERIFY(spy.count() == 1); //wait for scan to complete QList configs = manager.allConfigurations(); QCOMPARE(thread.configs, configs); - QCOMPARE(thread.preScanConfigs, preScanConfigs); + //Don't compare pre scan configs, because these may be cached and therefore give different results + //which makes the test unstable. The post scan results should have all configurations every time + //QCOMPARE(thread.preScanConfigs, preScanConfigs); #endif } diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index d59a5105ae..1b4256bb00 100644 --- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -42,7 +42,7 @@ #include #include -#include "private/qnetworkcookiejar_p.h" +#include "private/qtldurl_p.h" class tst_QNetworkCookieJar: public QObject { @@ -438,7 +438,7 @@ void tst_QNetworkCookieJar::effectiveTLDs() #endif QFETCH(QString, domain); QFETCH(bool, isTLD); - QCOMPARE(QNetworkCookieJarPrivate::isEffectiveTLD(domain), isTLD); + QCOMPARE(qIsEffectiveTLD(domain), isTLD); } QTEST_MAIN(tst_QNetworkCookieJar) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 4f5bd193c5..67b6e5c5b4 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -457,9 +457,9 @@ public: : client(0), dataToTransmit(data), doClose(true), doSsl(ssl), ipv6(useipv6), multiple(false), totalConnections(0) { - if( useipv6 ){ + if (useipv6) { listen(QHostAddress::AnyIPv6); - }else{ + } else { listen(); } if (thread) { @@ -2338,8 +2338,9 @@ void tst_QNetworkReply::connectToIPv6Address_data() QTest::addColumn("url"); QTest::addColumn("error"); QTest::addColumn("dataToSend"); - QTest::addColumn("serverVerifyData"); - QTest::newRow("localhost") << QUrl(QByteArray("http://[::1]")) << QNetworkReply::NoError<< QByteArray("localhost") << QByteArray("\r\nHost: [::1]\r\n"); + QTest::addColumn("hostfield"); + QTest::newRow("localhost") << QUrl(QByteArray("http://[::1]")) << QNetworkReply::NoError<< QByteArray("localhost") << QByteArray("[::1]"); + //QTest::newRow("ipv4localhost") << QUrl(QByteArray("http://127.0.0.1")) << QNetworkReply::NoError<< QByteArray("ipv4localhost") << QByteArray("127.0.0.1"); //to add more test data here } @@ -2348,7 +2349,7 @@ void tst_QNetworkReply::connectToIPv6Address() QFETCH(QUrl, url); QFETCH(QNetworkReply::NetworkError, error); QFETCH(QByteArray, dataToSend); - QFETCH(QByteArray, serverVerifyData); + QFETCH(QByteArray, hostfield); QByteArray httpResponse = QByteArray("HTTP/1.0 200 OK\r\nContent-Length: "); httpResponse += QByteArray::number(dataToSend.size()); @@ -2366,10 +2367,9 @@ void tst_QNetworkReply::connectToIPv6Address() QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); QByteArray content = reply->readAll(); - if( !serverVerifyData.isEmpty()){ - //qDebug() << server.receivedData; - //QVERIFY(server.receivedData.contains(serverVerifyData)); //got a bug here - } + //qDebug() << server.receivedData; + QByteArray hostinfo = "\r\nHost: " + hostfield + ":" + QByteArray::number(server.serverPort()) + "\r\n"; + QVERIFY(server.receivedData.contains(hostinfo)); QVERIFY(content == dataToSend); QCOMPARE(reply->url(), request.url()); QVERIFY(reply->error() == error); diff --git a/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem b/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem new file mode 100644 index 0000000000..e1b731d69b --- /dev/null +++ b/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIICkTCCAfqgAwIBAgIJAL1nF+PLAF2KMA0GCSqGSIb3DQEBBQUAMGkxKzApBgNV +BAoMIkjElcSCxrLDvyDKjeG6v8qI4bq34bi7IFLDqWPDtnJkxZ0xFTATBgNVBAsM +DOOIp0HjiYHvvatCQzEWMBQGA1UEAwwNSm9obm55IEd1aXRhcjELMAkGA1UEBhMC +Tk8wHhcNMTEwNTA1MDgxMzEwWhcNMTEwNjA0MDgxMzEwWjBpMSswKQYDVQQKDCJI +xJXEgsayw78gyo3hur/KiOG6t+G4uyBSw6ljw7ZyZMWdMRUwEwYDVQQLDAzjiKdB +44mB772rQkMxFjAUBgNVBAMMDUpvaG5ueSBHdWl0YXIxCzAJBgNVBAYTAk5PMIGf +MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2zSxS17I6596dJE/VAmGz+06D9S8n +3C0hnIGNVu+LwbgDJTvOw0SzNj4UP72UGgd3UI1KLBg5XWIsRNmE3COJMMh6syjI +L1Ept+tVXxGL6n4gl+0nZ7dkUyxJmeFtigYrL+qCH1yd5rmf3sC3jO4IosuAiG66 +IDkJEVo64NT8ZQIDAQABo0EwPzA9BgNVHREENjA0gQ9hcm5lQGZvb2Jhci5vcmeC +Dnd3dy5mb29iYXIub3JngRFiamFybmVAZm9vYmFyLm9yZzANBgkqhkiG9w0BAQUF +AAOBgQAqVhbC0/EUFdnKlYV3PrknwGX1dPEPGJuIQHa0KpoicvNiOhs1HxBDYbzc +F6wcAMEynq4YwGKhcQLZOs2mo0LreAjA9rU/yBnqrnUW/4gxtUUvmJKK+62IjfLp +eO1L+1NcEMJiaZf8fip4VXhXdOYUhgE8WUZ1UJRC6w3T/yAgcQ== +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem.san b/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem.san new file mode 100644 index 0000000000..f46a637da4 --- /dev/null +++ b/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem.san @@ -0,0 +1,5 @@ +[subj_alt_name] +subjectAltName=\ + email:arne@foobar.org,\ + DNS:www.foobar.org,\ + email:bjarne@foobar.org diff --git a/tests/auto/qsslcertificate/certificates/gencertificates.sh b/tests/auto/qsslcertificate/certificates/gencertificates.sh index 9f873d9c1b..0bac191326 100755 --- a/tests/auto/qsslcertificate/certificates/gencertificates.sh +++ b/tests/auto/qsslcertificate/certificates/gencertificates.sh @@ -90,5 +90,15 @@ openssl req -x509 -in req-san.pem -out $outname -key rsa-pri-1024.pem \ -config san.cnf -extensions subj_alt_name /bin/cp san.cnf $outname.san +#--- Non-ASCII Subject --------------------------------------------------------------------- +echo -e "\n generating self signed root cert. with Subject containing UTF-8 characters ..." +outname=cert-ss-san-utf8.pem +#subject="/O=HĕĂƲÿ ʍếʈặḻ Récördŝ/OU=㈧A㉁ォBC/CN=Johnny Guitar/C=NO" +subject=$'/O=H\xc4\x95\xc4\x82\xc6\xb2\xc3\xbf \xca\x8d\xe1\xba\xbf\xca\x88\xe1\xba\xb7\xe1\xb8\xbb R\xc3\xa9c\xc3\xb6rd\xc5\x9d/OU=\xe3\x88\xa7A\xe3\x89\x81\xef\xbd\xabBC/CN=Johnny Guitar/C=NO' +openssl req -out req-san.pem -new -key rsa-pri-1024.pem -utf8 -subj "$subject" +openssl req -x509 -in req-san.pem -out $outname -key rsa-pri-1024.pem \ + -config san.cnf -extensions subj_alt_name -nameopt multiline,utf8,-esc_msb +/bin/cp san.cnf $outname.san + echo -e "\n cleaning up ..." /bin/rm rsa-pri-1024.pem rsa-pub-1024.* req*.pem diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index c38147d417..9276685928 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -96,6 +96,7 @@ private slots: void digest_data(); void digest(); void alternateSubjectNames_data(); + void utf8SubjectNames(); void alternateSubjectNames(); void publicKey_data(); void publicKey(); @@ -407,6 +408,27 @@ void tst_QSslCertificate::alternateSubjectNames() } } +void tst_QSslCertificate::utf8SubjectNames() +{ + QSslCertificate cert = QSslCertificate::fromPath("certificates/cert-ss-san-utf8.pem", QSsl::Pem, + QRegExp::FixedString).first(); + QVERIFY(!cert.isNull()); + + // O is "Heavy Metal Records" with heavy use of "decorations" like accents, umlauts etc., + // OU uses arabian / asian script letters near codepoint 64K. + // strings split where the compiler would otherwise find three-digit hex numbers + static const char *o = "H\xc4\x95\xc4\x82\xc6\xb2\xc3\xbf \xca\x8d\xe1\xba\xbf\xca\x88\xe1\xba" + "\xb7\xe1\xb8\xbb R\xc3\xa9" "c" "\xc3\xb6rd\xc5\x9d"; + static const char *ou = "\xe3\x88\xa7" "A" "\xe3\x89\x81\xef\xbd\xab" "BC"; + + // the following two tests should help find "\x"-literal encoding bugs in the test itself + QCOMPARE(cert.subjectInfo("O").length(), QString::fromUtf8(o).length()); + QCOMPARE (cert.subjectInfo("O").toUtf8().toHex(), QByteArray(o).toHex()); + + QCOMPARE(cert.subjectInfo("O"), QString::fromUtf8(o)); + QCOMPARE(cert.subjectInfo("OU"), QString::fromUtf8(ou)); +} + void tst_QSslCertificate::publicKey_data() { QTest::addColumn("certFilePath"); @@ -519,13 +541,13 @@ void tst_QSslCertificate::fromPath_data() QTest::newRow("\"certificates/*\" fixed der") << QString("certificates/*") << int(QRegExp::FixedString) << false << 0; QTest::newRow("\"certificates/*\" regexp pem") << QString("certificates/*") << int(QRegExp::RegExp) << true << 0; QTest::newRow("\"certificates/*\" regexp der") << QString("certificates/*") << int(QRegExp::RegExp) << false << 0; - QTest::newRow("\"certificates/*\" wildcard pem") << QString("certificates/*") << int(QRegExp::Wildcard) << true << 4; + QTest::newRow("\"certificates/*\" wildcard pem") << QString("certificates/*") << int(QRegExp::Wildcard) << true << 5; QTest::newRow("\"certificates/*\" wildcard der") << QString("certificates/*") << int(QRegExp::Wildcard) << false << 0; QTest::newRow("\"c*/c*.pem\" fixed pem") << QString("c*/c*.pem") << int(QRegExp::FixedString) << true << 0; QTest::newRow("\"c*/c*.pem\" fixed der") << QString("c*/c*.pem") << int(QRegExp::FixedString) << false << 0; QTest::newRow("\"c*/c*.pem\" regexp pem") << QString("c*/c*.pem") << int(QRegExp::RegExp) << true << 0; QTest::newRow("\"c*/c*.pem\" regexp der") << QString("c*/c*.pem") << int(QRegExp::RegExp) << false << 0; - QTest::newRow("\"c*/c*.pem\" wildcard pem") << QString("c*/c*.pem") << int(QRegExp::Wildcard) << true << 4; + QTest::newRow("\"c*/c*.pem\" wildcard pem") << QString("c*/c*.pem") << int(QRegExp::Wildcard) << true << 5; QTest::newRow("\"c*/c*.pem\" wildcard der") << QString("c*/c*.pem") << int(QRegExp::Wildcard) << false << 0; QTest::newRow("\"d*/c*.pem\" fixed pem") << QString("d*/c*.pem") << int(QRegExp::FixedString) << true << 0; QTest::newRow("\"d*/c*.pem\" fixed der") << QString("d*/c*.pem") << int(QRegExp::FixedString) << false << 0; @@ -535,7 +557,7 @@ void tst_QSslCertificate::fromPath_data() QTest::newRow("\"d*/c*.pem\" wildcard der") << QString("d*/c*.pem") << int(QRegExp::Wildcard) << false << 0; QTest::newRow("\"c.*/c.*.pem\" fixed pem") << QString("c.*/c.*.pem") << int(QRegExp::FixedString) << true << 0; QTest::newRow("\"c.*/c.*.pem\" fixed der") << QString("c.*/c.*.pem") << int(QRegExp::FixedString) << false << 0; - QTest::newRow("\"c.*/c.*.pem\" regexp pem") << QString("c.*/c.*.pem") << int(QRegExp::RegExp) << true << 4; + QTest::newRow("\"c.*/c.*.pem\" regexp pem") << QString("c.*/c.*.pem") << int(QRegExp::RegExp) << true << 5; QTest::newRow("\"c.*/c.*.pem\" regexp der") << QString("c.*/c.*.pem") << int(QRegExp::RegExp) << false << 0; QTest::newRow("\"c.*/c.*.pem\" wildcard pem") << QString("c.*/c.*.pem") << int(QRegExp::Wildcard) << true << 0; QTest::newRow("\"c.*/c.*.pem\" wildcard der") << QString("c.*/c.*.pem") << int(QRegExp::Wildcard) << false << 0; @@ -546,7 +568,7 @@ void tst_QSslCertificate::fromPath_data() QTest::newRow("\"d.*/c.*.pem\" wildcard pem") << QString("d.*/c.*.pem") << int(QRegExp::Wildcard) << true << 0; QTest::newRow("\"d.*/c.*.pem\" wildcard der") << QString("d.*/c.*.pem") << int(QRegExp::Wildcard) << false << 0; #ifdef Q_OS_LINUX - QTest::newRow("absolute path wildcard pem") << QString(QDir::currentPath() + "/certificates/*.pem") << int(QRegExp::Wildcard) << true << 4; + QTest::newRow("absolute path wildcard pem") << QString(QDir::currentPath() + "/certificates/*.pem") << int(QRegExp::Wildcard) << true << 5; #endif QTest::newRow("trailing-whitespace") << QString("more-certificates/trailing-whitespace.pem") << int(QRegExp::FixedString) << true << 1; @@ -769,7 +791,7 @@ void tst_QSslCertificate::nulInCN() QString cn = cert.subjectInfo(QSslCertificate::CommonName); QVERIFY(cn != "www.bank.com"); - static const char realCN[] = "www.bank.com\\x00.badguy.com"; + static const char realCN[] = "www.bank.com\0.badguy.com"; QCOMPARE(cn, QString::fromLatin1(realCN, sizeof realCN - 1)); } diff --git a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp index 74ffff2db7..74a254cbf4 100644 --- a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -146,6 +146,15 @@ void tst_QtConcurrentMap::map() QCOMPARE(numberList, QList() << 2 << 4 << 6); QtConcurrent::map(numberList.begin(), numberList.end(), &Number::multiplyBy2).waitForFinished(); QCOMPARE(numberList, QList() << 4 << 8 << 12); + +#ifdef Q_COMPILER_LAMBDA + // lambda + QtConcurrent::map(list, [](int &x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList() << 128 << 256 << 384); + QtConcurrent::map(list.begin(), list.end(), [](int &x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList() << 256 << 512 << 768); +#endif + } // functors don't take arguments by reference, making these no-ops @@ -170,6 +179,14 @@ void tst_QtConcurrentMap::map() QCOMPARE(list, QList() << 1 << 2 << 3); QtConcurrent::map(list.begin(), list.end(), multiplyBy2Immutable).waitForFinished(); QCOMPARE(list, QList() << 1 << 2 << 3); + +#ifdef Q_COMPILER_LAMBDA + // lambda + QtConcurrent::map(list, [](int x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList() << 1 << 2 << 3); + QtConcurrent::map(list.begin(), list.end(), [](int x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList() << 1 << 2 << 3); +#endif } // Linked lists and forward iterators @@ -2303,6 +2320,10 @@ void tst_QtConcurrentMap::stlContainers() { #ifdef QT_NO_STL QSKIP("Qt compiled without STL support", SkipAll); +#elif defined(Q_COMPILER_RVALUE_REFS) + //mapped uses &Container::push_back, but in c++0x, std::vector has two overload of it + // meaning it is not possible to take the address of that function anymore. + QSKIP("mapped do not work with c++0x stl vector", SkipAll); #else std::vector vector; vector.push_back(1); diff --git a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp index e4e9479a13..cacb09aae1 100644 --- a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -67,6 +67,8 @@ private slots: #if 0 void createFunctor(); #endif + void functor(); + void lambda(); }; #if 0 @@ -444,6 +446,71 @@ void tst_QtConcurrentRun::createFunctor() } #endif +struct Functor { + int operator()() { return 42; } + double operator()(double a, double b) { return a/b; } + int operator()(int a, int b) { return a/b; } + void operator()(int) { } + void operator()(int, int, int) { } + void operator()(int, int, int, int) { } + void operator()(int, int, int, int, int) { } + void operator()(int, int, int, int, int, int) { } +}; + +void tst_QtConcurrentRun::functor() +{ + //this test functor without result_type, decltype need to be supported by the compiler +#ifndef Q_COMPILER_DECLTYPE + QSKIP("Compiler do not suport decltype", SkipAll); +#else + Functor f; + { + QFuture fut = QtConcurrent::run(f); + QCOMPARE(fut.result(), 42); + } + { + QFuture fut = QtConcurrent::run(f, 8.5, 1.8); + QCOMPARE(fut.result(), (8.5/1.8)); + } + { + QFuture fut = QtConcurrent::run(f, 19, 3); + QCOMPARE(fut.result(), int(19/3)); + } + { + QtConcurrent::run(f, 1).waitForFinished(); + QtConcurrent::run(f, 1,2).waitForFinished(); + QtConcurrent::run(f, 1,2,3).waitForFinished(); + QtConcurrent::run(f, 1,2,3,4).waitForFinished(); + QtConcurrent::run(f, 1,2,3,4,5).waitForFinished(); + } +#endif +} + + +void tst_QtConcurrentRun::lambda() +{ +#ifndef Q_COMPILER_LAMBDA + QSKIP("Compiler do not suport lambda", SkipAll); +#else + + QCOMPARE(QtConcurrent::run([](){ return 45; }).result(), 45); + QCOMPARE(QtConcurrent::run([](int a){ return a+15; }, 12).result(), 12+15); + QCOMPARE(QtConcurrent::run([](int a, double b){ return a + b; }, 12, 15).result(), double(12+15)); + QCOMPARE(QtConcurrent::run([](int a , int, int, int, int b){ return a + b; }, 1, 2, 3, 4, 5).result(), 1 + 5); + +#ifdef Q_COMPILER_INITIALIZER_LISTS + { + QString str { "Hello World Foo" }; + QFuture f1 = QtConcurrent::run([&](){ return str.split(' '); }); + auto r = f1.result(); + QCOMPARE(r, QStringList({"Hello", "World", "Foo"})); + } +#endif + +#endif +} + + #include "tst_qtconcurrentrun.moc" #else diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index b6adc2b8a0..2414ab3e37 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -127,6 +127,8 @@ private slots: void textWithSurrogates_qtbug15679(); void textWidthWithStackedTextEngine(); void textWidthWithLineSeparator(); + void cursorInLigatureWithMultipleLines(); + void xToCursorForLigatures(); private: QFont testFont; @@ -1460,5 +1462,45 @@ void tst_QTextLayout::textWidthWithLineSeparator() QCOMPARE(line1.naturalTextWidth(), line2.naturalTextWidth()); } +void tst_QTextLayout::cursorInLigatureWithMultipleLines() +{ +#if !defined(Q_WS_MAC) + QSKIP("This test can not be run on Mac", SkipAll); +#endif + QTextLayout layout("first line finish", QFont("Times", 20)); + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(70); + line = layout.createLine(); + layout.endLayout(); + + // The second line will be "finish", with "fi" as a ligature + QVERIFY(line.cursorToX(0) != line.cursorToX(1)); +} + +void tst_QTextLayout::xToCursorForLigatures() +{ +#if !defined(Q_WS_MAC) + QSKIP("This test can not be run on Mac", SkipAll); +#endif + QTextLayout layout("fi", QFont("Times", 20)); + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + QVERIFY(line.xToCursor(0) != line.xToCursor(line.naturalTextWidth() / 2)); + + // U+0061 U+0308 + QTextLayout layout2(QString::fromUtf8("\x61\xCC\x88"), QFont("Times", 20)); + + layout2.beginLayout(); + line = layout2.createLine(); + layout2.endLayout(); + + qreal width = line.naturalTextWidth(); + QVERIFY(line.xToCursor(0) == line.xToCursor(width / 2) || + line.xToCursor(width) == line.xToCursor(width / 2)); +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" diff --git a/tests/auto/qtipc/lackey/lackey.pro b/tests/auto/qtipc/lackey/lackey.pro index 2fa364c4c9..91659d701e 100644 --- a/tests/auto/qtipc/lackey/lackey.pro +++ b/tests/auto/qtipc/lackey/lackey.pro @@ -1,17 +1,12 @@ include(../qsharedmemory/src/src.pri) -QT = core script -QT += core-private - -CONFIG += qtestlib +QT = core-private script testlib DESTDIR = ./ win32: CONFIG += console mac:CONFIG -= app_bundle -requires(contains(QT_CONFIG,script)) - DEFINES += QSHAREDMEMORY_DEBUG DEFINES += QSYSTEMSEMAPHORE_DEBUG diff --git a/tests/auto/qurl/qurl.pro b/tests/auto/qurl/qurl.pro index a5c39a5a98..a43a57e002 100644 --- a/tests/auto/qurl/qurl.pro +++ b/tests/auto/qurl/qurl.pro @@ -1,5 +1,5 @@ load(qttest_p4) SOURCES += tst_qurl.cpp -QT = core +QT = core core-private symbian: TARGET.CAPABILITY = NetworkServices CONFIG += parallel_test diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 30f1a10717..4aa7185c17 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -49,6 +49,7 @@ #include #include #include +#include "private/qtldurl_p.h" // For testsuites #define IDNA_ACE_PREFIX "xn--" @@ -88,6 +89,8 @@ public slots: void init(); void cleanup(); private slots: + void effectiveTLDs_data(); + void effectiveTLDs(); void getSetCheck(); void constructing(); void assignment(); @@ -3994,5 +3997,28 @@ void tst_QUrl::taskQTBUG_8701() QCOMPARE(foo_uni_bar, QUrl(foo_uni_bar, QUrl::StrictMode).toString()); } +void tst_QUrl::effectiveTLDs_data() +{ + QTest::addColumn("domain"); + QTest::addColumn("TLD"); + + QTest::newRow("yes0") << QUrl::fromEncoded("http://test.co.uk") << ".co.uk"; + QTest::newRow("yes1") << QUrl::fromEncoded("http://test.com") << ".com"; + QTest::newRow("yes2") << QUrl::fromEncoded("http://www.test.de") << ".de"; + QTest::newRow("yes3") << QUrl::fromEncoded("http://test.ulm.museum") << ".ulm.museum"; + QTest::newRow("yes4") << QUrl::fromEncoded("http://www.com.krodsherad.no") << ".krodsherad.no"; + QTest::newRow("yes5") << QUrl::fromEncoded("http://www.co.uk.1.bg") << ".1.bg"; + QTest::newRow("yes6") << QUrl::fromEncoded("http://www.com.com.cn") << ".com.cn"; + QTest::newRow("yes7") << QUrl::fromEncoded("http://www.test.org.ws") << ".org.ws"; + QTest::newRow("yes9") << QUrl::fromEncoded("http://www.com.co.uk.wallonie.museum") << ".wallonie.museum"; +} + +void tst_QUrl::effectiveTLDs() +{ + QFETCH(QUrl, domain); + QFETCH(QString, TLD); + QCOMPARE(domain.topLevelDomain(), TLD); +} + QTEST_MAIN(tst_QUrl) #include "tst_qurl.moc" diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp index 6333e837d5..4948312fd4 100644 --- a/tests/auto/quuid/tst_quuid.cpp +++ b/tests/auto/quuid/tst_quuid.cpp @@ -60,7 +60,14 @@ public: tst_QUuid(); private slots: + void fromChar(); void toString(); + void fromString(); + void toByteArray(); + void fromByteArray(); + void toRfc4122(); + void fromRfc4122(); + void check_QDataStream(); void isNull(); void equal(); void notEqual(); @@ -83,16 +90,106 @@ public: tst_QUuid::tst_QUuid() { - uuidA = "{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"; - uuidB = "{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"; + //"{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"; + uuidA = QUuid(0xfc69b59e, 0xcc34 ,0x4436 ,0xa4 ,0x3c ,0xee ,0x95 ,0xd1 ,0x28 ,0xb8 ,0xc5); + + //"{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"; + uuidB = QUuid(0x1ab6e93a ,0xb1cb ,0x4a87 ,0xba ,0x47 ,0xec ,0x7e ,0x99 ,0x03 ,0x9a ,0x7b); } +void tst_QUuid::fromChar() +{ + QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5")); + QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5")); + QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c")); + QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34")); + QCOMPARE(QUuid(), QUuid("fc69b59e-cc34-")); + QCOMPARE(QUuid(), QUuid("fc69b59e-cc34")); + QCOMPARE(QUuid(), QUuid("cc34")); + QCOMPARE(QUuid(), QUuid(NULL)); + + QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); +} void tst_QUuid::toString() { QCOMPARE(uuidA.toString(), QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + + QCOMPARE(uuidB.toString(), QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")); } +void tst_QUuid::fromString() +{ + QCOMPARE(uuidA, QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); + QCOMPARE(uuidA, QUuid(QString("fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); + QCOMPARE(uuidA, QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); + QCOMPARE(uuidA, QUuid(QString("fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); + QCOMPARE(QUuid(), QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c"))); + + QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); +} + +void tst_QUuid::toByteArray() +{ + QCOMPARE(uuidA.toByteArray(), QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + + QCOMPARE(uuidB.toByteArray(), QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")); +} + +void tst_QUuid::fromByteArray() +{ + QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); + QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); + QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); + QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); + QCOMPARE(QUuid(), QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c"))); + + QCOMPARE(uuidB, QUuid(QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); +} + +void tst_QUuid::toRfc4122() +{ + QCOMPARE(uuidA.toRfc4122(), QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5")); + + QCOMPARE(uuidB.toRfc4122(), QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b")); +} + +void tst_QUuid::fromRfc4122() +{ + QCOMPARE(uuidA, QUuid::fromRfc4122(QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5"))); + + QCOMPARE(uuidB, QUuid::fromRfc4122(QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b"))); +} + +void tst_QUuid::check_QDataStream() +{ + QUuid tmp; + QByteArray ar; + { + QDataStream out(&ar,QIODevice::WriteOnly); + out.setByteOrder(QDataStream::BigEndian); + out << uuidA; + } + { + QDataStream in(&ar,QIODevice::ReadOnly); + in.setByteOrder(QDataStream::BigEndian); + in >> tmp; + QCOMPARE(uuidA, tmp); + } + { + QDataStream out(&ar,QIODevice::WriteOnly); + out.setByteOrder(QDataStream::LittleEndian); + out << uuidA; + } + { + QDataStream in(&ar,QIODevice::ReadOnly); + in.setByteOrder(QDataStream::LittleEndian); + in >> tmp; + QCOMPARE(uuidA, tmp); + } +} void tst_QUuid::isNull() { diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 1d3591d757..a795e89762 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include #include @@ -399,6 +400,7 @@ private slots: void taskQTBUG_11373(); #endif // QT_MAC_USE_COCOA #endif + void taskQTBUG_17333_ResizeInfiniteRecursion(); void nativeChildFocus(); @@ -10217,6 +10219,18 @@ void tst_QWidget::taskQTBUG_11373() #endif // QT_MAC_USE_COCOA #endif +void tst_QWidget::taskQTBUG_17333_ResizeInfiniteRecursion() +{ + QTableView tb; + const char *s = "border: 1px solid;"; + tb.setStyleSheet(s); + tb.show(); + + QTest::qWaitForWindowShown(&tb); + tb.setGeometry(QRect(100, 100, 0, 100)); + // No crash, it works. +} + void tst_QWidget::nativeChildFocus() { QWidget w; diff --git a/tests/auto/uic/uic.pro b/tests/auto/uic/uic.pro index 355cb56cea..0045015457 100644 --- a/tests/auto/uic/uic.pro +++ b/tests/auto/uic/uic.pro @@ -1,6 +1,5 @@ load(qttest_p4) -CONFIG += qtestlib SOURCES += tst_uic.cpp TARGET = tst_uic diff --git a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp index dbec65ca42..a035cf3627 100644 --- a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp @@ -53,6 +53,18 @@ public: private slots: void createUuid(); + void fromChar(); + void toString(); + void fromString(); + void toByteArray(); + void fromByteArray(); + void toRfc4122(); + void fromRfc4122(); + void toDataStream(); + void fromDataStream(); + void isNull(); + void operatorLess(); + void operatorMore(); }; void tst_bench_QUuid::createUuid() @@ -62,5 +74,118 @@ void tst_bench_QUuid::createUuid() } } +void tst_bench_QUuid::fromChar() +{ + QBENCHMARK { + QUuid uuid("{67C8770B-44F1-410A-AB9A-F9B5446F13EE}"); + } +} + +void tst_bench_QUuid::toString() +{ + QUuid uuid = QUuid::createUuid(); + QBENCHMARK { + uuid.toString(); + } +} + +void tst_bench_QUuid::fromString() +{ + QString string = "{67C8770B-44F1-410A-AB9A-F9B5446F13EE}"; + QBENCHMARK { + QUuid uuid(string); + } +} + +void tst_bench_QUuid::toByteArray() +{ + QUuid uuid = QUuid::createUuid(); + QBENCHMARK { + uuid.toByteArray(); + } +} + +void tst_bench_QUuid::fromByteArray() +{ + QByteArray string = "{67C8770B-44F1-410A-AB9A-F9B5446F13EE}"; + QBENCHMARK { + QUuid uuid(string); + } +} + +void tst_bench_QUuid::toRfc4122() +{ + QUuid uuid = QUuid::createUuid(); + QBENCHMARK { + uuid.toRfc4122(); + } +} + +void tst_bench_QUuid::fromRfc4122() +{ + QByteArray string = QByteArray::fromHex("67C8770B44F1410AAB9AF9B5446F13EE"); + QBENCHMARK { + QUuid uuid = QUuid::fromRfc4122(string); + } +} + +void tst_bench_QUuid::toDataStream() +{ + QUuid uuid1, uuid2; + uuid1 = QUuid::createUuid(); + QByteArray ar; + { + QDataStream out(&ar,QIODevice::WriteOnly); + QBENCHMARK { + out << uuid1; + } + } +} + +void tst_bench_QUuid::fromDataStream() +{ + QUuid uuid1, uuid2; + uuid1 = QUuid::createUuid(); + QByteArray ar; + { + QDataStream out(&ar,QIODevice::WriteOnly); + out << uuid1; + } + { + QDataStream in(&ar,QIODevice::ReadOnly); + QBENCHMARK { + in >> uuid2; + } + } +} + +void tst_bench_QUuid::isNull() +{ + QUuid uuid = QUuid(); + QBENCHMARK { + uuid.isNull(); + } +} + +void tst_bench_QUuid::operatorLess() +{ + QUuid uuid1, uuid2; + uuid1 = QUuid::createUuid(); + uuid2 = QUuid::createUuid(); + QBENCHMARK { + uuid1 < uuid2; + } +} + +void tst_bench_QUuid::operatorMore() +{ + QUuid uuid1, uuid2; + uuid1 = QUuid::createUuid(); + uuid2 = QUuid::createUuid(); + QBENCHMARK { + uuid1 > uuid2; + } +} + QTEST_MAIN(tst_bench_QUuid); #include "tst_quuid.moc" diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp index d62cdac9bb..95aaad3a25 100644 --- a/tests/benchmarks/corelib/tools/qstring/main.cpp +++ b/tests/benchmarks/corelib/tools/qstring/main.cpp @@ -53,6 +53,11 @@ #include #endif +// MAP_ANON is deprecated on Linux, and MAP_ANONYMOUS is not present on Mac +#ifndef MAP_ANONYMOUS +# define MAP_ANONYMOUS MAP_ANON +#endif + #include #include "data.h" @@ -772,7 +777,7 @@ static void __attribute__((noinline)) equals2_selftest() void *page1, *page3; ushort *page2; page1 = mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - page2 = (ushort *)mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0); + page2 = (ushort *)mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); page3 = mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); Q_ASSERT(quintptr(page2) == quintptr(page1) + pagesize || quintptr(page2) == quintptr(page1) - pagesize); @@ -1329,7 +1334,7 @@ void tst_QString::ucstrncmp() const void *page1, *page3; ushort *page2; page1 = mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - page2 = (ushort *)mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0); + page2 = (ushort *)mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); page3 = mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); Q_ASSERT(quintptr(page2) == quintptr(page1) + pagesize || quintptr(page2) == quintptr(page1) - pagesize); diff --git a/util/network/cookiejar-generateTLDs/main.cpp b/util/corelib/qurl-generateTLDs/main.cpp similarity index 97% rename from util/network/cookiejar-generateTLDs/main.cpp rename to util/corelib/qurl-generateTLDs/main.cpp index b369ecee88..861546ce9e 100644 --- a/util/network/cookiejar-generateTLDs/main.cpp +++ b/util/corelib/qurl-generateTLDs/main.cpp @@ -77,7 +77,7 @@ int main(int argc, char **argv) { printf(" wget http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1 -O effective_tld_names.dat\n"); printf(" grep '^[^\\/\\/]' effective_tld_names.dat > effective_tld_names.dat.trimmed\n"); printf(" %s effective_tld_names.dat.trimmed effective_tld_names.dat.qt\n\n", argv[0]); - printf("Now copy the data from effective_tld_names.dat.qt to the file src/network/access/qnetworkcookiejartlds_p.h in your Qt repo\n\n"); + printf("Now copy the data from effective_tld_names.dat.qt to the file src/corelib/io/qurltlds_p.h in your Qt repo\n\n"); exit(1); } QFile file(argv[1]); @@ -156,6 +156,6 @@ int main(int argc, char **argv) { outFile.write(outDataBufferBA); outFile.write("};\n"); outFile.close(); - printf("data generated to %s . Now copy the data from this file to src/network/access/qnetworkcookiejartlds_p.h in your Qt repo\n", argv[2]); + printf("data generated to %s . Now copy the data from this file to src/corelib/io/qurltlds_p.h in your Qt repo\n", argv[2]); exit(0); } diff --git a/util/network/cookiejar-generateTLDs/cookiejar-generateTLDs.pro b/util/corelib/qurl-generateTLDs/qurl-generateTLDs.pro similarity index 100% rename from util/network/cookiejar-generateTLDs/cookiejar-generateTLDs.pro rename to util/corelib/qurl-generateTLDs/qurl-generateTLDs.pro diff --git a/util/lexgen/tests/tests.pro b/util/lexgen/tests/tests.pro index eb04439a13..1a1e51d8c9 100644 --- a/util/lexgen/tests/tests.pro +++ b/util/lexgen/tests/tests.pro @@ -1,6 +1,5 @@ -CONFIG += qtestlib SOURCES += tst_lexgen.cpp TARGET = tst_lexgen include(../lexgen.pri) -QT = core +QT = core testlib DEFINES += SRCDIR=\\\"$$PWD\\\"