diff --git a/doc/src/images/standarddialogs-example.png b/doc/src/images/standarddialogs-example.png index b6b8a076db..f584ebb27d 100644 Binary files a/doc/src/images/standarddialogs-example.png and b/doc/src/images/standarddialogs-example.png differ diff --git a/examples/widgets/doc/images/basiclayouts-example.png b/examples/widgets/doc/images/basiclayouts-example.png index 4a1c45dd80..d19afdb069 100644 Binary files a/examples/widgets/doc/images/basiclayouts-example.png and b/examples/widgets/doc/images/basiclayouts-example.png differ diff --git a/src/corelib/doc/snippets/code/src_corelib_concurrent_qthreadpool.cpp b/src/corelib/doc/snippets/code/src_corelib_concurrent_qthreadpool.cpp index ba31972aa1..8490942048 100644 --- a/src/corelib/doc/snippets/code/src_corelib_concurrent_qthreadpool.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_concurrent_qthreadpool.cpp @@ -51,7 +51,7 @@ //! [0] class HelloWorldTask : public QRunnable { - void run() + void run() override { qDebug() << "Hello world from thread" << QThread::currentThread(); } diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qabstractfileengine.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qabstractfileengine.cpp index 055812ea60..ae2f305313 100644 --- a/src/corelib/doc/snippets/code/src_corelib_io_qabstractfileengine.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_io_qabstractfileengine.cpp @@ -52,7 +52,7 @@ class ZipEngineHandler : public QAbstractFileEngineHandler { public: - QAbstractFileEngine *create(const QString &fileName) const; + QAbstractFileEngine *create(const QString &fileName) const override; }; QAbstractFileEngine *ZipEngineHandler::create(const QString &fileName) const @@ -105,12 +105,12 @@ public: entries << "entry1" << "entry2" << "entry3"; } - bool hasNext() const + bool hasNext() const override { return index < entries.size() - 1; } - QString next() + QString next() override { if (!hasNext()) return QString(); @@ -118,7 +118,7 @@ public: return currentFilePath(); } - QString currentFileName() + QString currentFileName() override { return entries.at(index); } diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qprocess.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qprocess.cpp index 2e94666970..8a2825cd10 100644 --- a/src/corelib/doc/snippets/code/src_corelib_io_qprocess.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_io_qprocess.cpp @@ -94,7 +94,7 @@ class SandboxProcess : public QProcess { ... protected: - void setupChildProcess(); + void setupChildProcess() override; ... }; diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp index 3379d0bc1a..2e055ec439 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp @@ -120,7 +120,7 @@ public: ... - QVariant data(const QModelIndex &index, int role) + QVariant data(const QModelIndex &index, int role) override { if (role != Qt::BackgroundRole) return QSortFilterProxyModel::data(index, role); diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp index c12ed147db..6451f46b36 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp @@ -101,7 +101,7 @@ public: MainWindow(); protected: - bool eventFilter(QObject *obj, QEvent *ev); + bool eventFilter(QObject *obj, QEvent *ev) override; private: QTextEdit *textEdit; @@ -147,7 +147,7 @@ public: MyObject(QObject *parent = 0); protected: - void timerEvent(QTimerEvent *event); + void timerEvent(QTimerEvent *event) override; }; MyObject::MyObject(QObject *parent) @@ -215,7 +215,7 @@ class KeyPressEater : public QObject ... protected: - bool eventFilter(QObject *obj, QEvent *event); + bool eventFilter(QObject *obj, QEvent *event) override; }; bool KeyPressEater::eventFilter(QObject *obj, QEvent *event) @@ -508,7 +508,7 @@ public: MyClass(QWidget *parent = 0); ~MyClass(); - bool event(QEvent* ev) + bool event(QEvent* ev) override { if (ev->type() == QEvent::PolishRequest) { // overwrite handling of PolishRequest if any diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qexception.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qexception.cpp index eaf3a156cf..723c1630f6 100644 --- a/src/corelib/doc/snippets/code/src_corelib_thread_qexception.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_thread_qexception.cpp @@ -53,8 +53,8 @@ class MyException : public QException { public: - void raise() const { throw *this; } - MyException *clone() const { return new MyException(*this); } + void raise() const override { throw *this; } + MyException *clone() const override { return new MyException(*this); } }; //! [0] diff --git a/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp b/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp index 65ee9260b2..d89e28836f 100644 --- a/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp +++ b/src/corelib/doc/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp @@ -58,7 +58,7 @@ class DateFormatProxyModel : public QIdentityProxyModel m_formatString = formatString; } - QVariant data(const QModelIndex &index, int role) const + QVariant data(const QModelIndex &index, int role) const override { if (role != Qt::DisplayRole) return QIdentityProxyModel::data(index, role); diff --git a/src/corelib/doc/snippets/eventfilters/filterobject.h b/src/corelib/doc/snippets/eventfilters/filterobject.h index 08b7c67192..354aa4ff5c 100644 --- a/src/corelib/doc/snippets/eventfilters/filterobject.h +++ b/src/corelib/doc/snippets/eventfilters/filterobject.h @@ -59,7 +59,7 @@ class FilterObject : public QObject public: FilterObject(QObject *parent = 0); - bool eventFilter(QObject *object, QEvent *event); + bool eventFilter(QObject *object, QEvent *event) override; void setFilteredObject(QObject *object); private: diff --git a/src/corelib/doc/snippets/events/events.cpp b/src/corelib/doc/snippets/events/events.cpp index 9606b0c2ee..969b0047f0 100644 --- a/src/corelib/doc/snippets/events/events.cpp +++ b/src/corelib/doc/snippets/events/events.cpp @@ -54,7 +54,7 @@ class MyCheckBox : public QCheckBox { public: - void mousePressEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event) override; }; //! [0] @@ -72,7 +72,7 @@ void MyCheckBox::mousePressEvent(QMouseEvent *event) class MyWidget : public QWidget { public: - bool event(QEvent *event); + bool event(QEvent *event) override; }; static const int MyCustomEventType = 1099; diff --git a/src/corelib/doc/snippets/settings/settings.cpp b/src/corelib/doc/snippets/settings/settings.cpp index 28b72acd6a..49312b9cfc 100644 --- a/src/corelib/doc/snippets/settings/settings.cpp +++ b/src/corelib/doc/snippets/settings/settings.cpp @@ -143,7 +143,7 @@ public: void readSettings(); protected: - void closeEvent(QCloseEvent *event); + void closeEvent(QCloseEvent *event) override; }; //! [16] diff --git a/src/corelib/doc/snippets/statemachine/eventtest.cpp b/src/corelib/doc/snippets/statemachine/eventtest.cpp index cecf26f2e7..d7d4ce0d21 100644 --- a/src/corelib/doc/snippets/statemachine/eventtest.cpp +++ b/src/corelib/doc/snippets/statemachine/eventtest.cpp @@ -58,7 +58,7 @@ public: protected: //![0] - bool eventTest(QEvent *event) + bool eventTest(QEvent *event) override { if (event->type() == QEvent::Wrapped) { QEvent *wrappedEvent = static_cast(event)->event(); @@ -71,7 +71,7 @@ protected: } //![0] - void onTransition(QEvent *event) + void onTransition(QEvent *event) override { } diff --git a/src/corelib/doc/snippets/statemachine/main4.cpp b/src/corelib/doc/snippets/statemachine/main4.cpp index 5786fa3c17..e21656b91c 100644 --- a/src/corelib/doc/snippets/statemachine/main4.cpp +++ b/src/corelib/doc/snippets/statemachine/main4.cpp @@ -72,7 +72,7 @@ public: : m_value(value) {} protected: - virtual bool eventTest(QEvent *e) + bool eventTest(QEvent *e) override { if (e->type() != QEvent::Type(QEvent::User+1)) // StringEvent return false; @@ -80,7 +80,7 @@ protected: return (m_value == se->value); } - virtual void onTransition(QEvent *) {} + void onTransition(QEvent *) override {} private: QString m_value; diff --git a/src/corelib/io/qurl_p.h b/src/corelib/io/qurl_p.h index cb88cac35e..1b9237e58a 100644 --- a/src/corelib/io/qurl_p.h +++ b/src/corelib/io/qurl_p.h @@ -65,7 +65,7 @@ extern Q_AUTOTEST_EXPORT int qt_urlRecode(QString &appendTo, const QChar *begin, enum AceLeadingDot { AllowLeadingDot, ForbidLeadingDot }; enum AceOperation { ToAceOnly, NormalizeAce }; extern QString qt_ACE_do(const QString &domain, AceOperation op, AceLeadingDot dot); -extern Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from); +extern Q_AUTOTEST_EXPORT bool qt_nameprep(QString *source, int from); extern Q_AUTOTEST_EXPORT bool qt_check_std3rules(const QChar *uc, int len); extern Q_AUTOTEST_EXPORT void qt_punycodeEncoder(const QChar *s, int ucLength, QString *output); extern Q_AUTOTEST_EXPORT QString qt_punycodeDecoder(const QString &pc); diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index 2f8bd91f6e..2305e66407 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -2021,7 +2021,7 @@ static bool isBidirectionalL(uint uc) return false; } -Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from) +Q_AUTOTEST_EXPORT bool qt_nameprep(QString *source, int from) { QChar *src = source->data(); // causes a detach, so we're sure the only one using it QChar *out = src + from; @@ -2036,7 +2036,7 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from) } } if (out == e) - return; // everything was mapped easily (lowercased, actually) + return true; // everything was mapped easily (lowercased, actually) int firstNonAscii = out - src; // Characters unassigned in Unicode 3.2 are not allowed in "stored string" scheme @@ -2059,7 +2059,7 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from) QChar::UnicodeVersion version = QChar::unicodeVersion(uc); if (version == QChar::Unicode_Unassigned || version > QChar::Unicode_3_2) { source->resize(from); // not allowed, clear the label - return; + return false; } } if (!isMappedToNothing(uc)) { @@ -2086,7 +2086,7 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from) // Strip prohibited output if (containsProhibitedOuptut(source, firstNonAscii)) { source->resize(from); - return; + return false; } // Check for valid bidirectional characters @@ -2110,9 +2110,13 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from) } if (containsRandALCat) { if (containsLCat || (!isBidirectionalRorAL(src[from].unicode()) - || !isBidirectionalRorAL(e[-1].unicode()))) + || !isBidirectionalRorAL(e[-1].unicode()))) { source->resize(from); // not allowed, clear the label + return false; + } } + + return true; } static const QChar *qt_find_nonstd3(const QChar *uc, int len, Qt::CaseSensitivity cs) @@ -2553,7 +2557,8 @@ QString qt_ACE_do(const QString &domain, AceOperation op, AceLeadingDot dot) } else { // Punycode encoding and decoding cannot be done in-place // That means we need one or two temporaries - qt_nameprep(&result, prevLen); + if (!qt_nameprep(&result, prevLen)) + return QString(); // failed labelLength = result.length() - prevLen; int toReserve = labelLength + 4 + 6; // "xn--" plus some extra bytes aceForm.resize(0); diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index b658d8afcf..0146e22fa3 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -651,6 +651,7 @@ Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW // So it's an acceptable compromise. #if defined(__AVX__) || defined(__SSE4_2__) || defined(__POPCNT__) #define QALGORITHMS_USE_BUILTIN_POPCOUNT +#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW { return __popcnt(v); @@ -663,13 +664,15 @@ Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW { return __popcnt16(v); } -#if Q_PROCESSOR_WORDSIZE == 8 -#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW { +#if Q_PROCESSOR_WORDSIZE == 8 return __popcnt64(v); -} +#else + return __popcnt(quint32(v)) + __popcnt(quint32(v >> 32)); #endif // MSVC 64bit +} + #endif // __AVX__ || __SSE4_2__ || __POPCNT__ #endif // MSVC diff --git a/src/gui/doc/snippets/draganddrop/dragwidget.h b/src/gui/doc/snippets/draganddrop/dragwidget.h index 424c0b334b..709f9338bf 100644 --- a/src/gui/doc/snippets/draganddrop/dragwidget.h +++ b/src/gui/doc/snippets/draganddrop/dragwidget.h @@ -74,10 +74,10 @@ signals: void mimeTypes(const QStringList &types); protected: - void dragEnterEvent(QDragEnterEvent *event); - void dropEvent(QDropEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); + void dragEnterEvent(QDragEnterEvent *event) override; + void dropEvent(QDropEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; private: QByteArray data; diff --git a/src/gui/doc/snippets/dragging/mainwindow.h b/src/gui/doc/snippets/dragging/mainwindow.h index 5e796d530f..8a8e43b223 100644 --- a/src/gui/doc/snippets/dragging/mainwindow.h +++ b/src/gui/doc/snippets/dragging/mainwindow.h @@ -68,7 +68,7 @@ public: MainWindow(QWidget *parent = 0); protected: - void mousePressEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event) override; private: QLabel *iconLabel; diff --git a/src/gui/doc/snippets/dropevents/window.h b/src/gui/doc/snippets/dropevents/window.h index 17c323b952..6ac35181ed 100644 --- a/src/gui/doc/snippets/dropevents/window.h +++ b/src/gui/doc/snippets/dropevents/window.h @@ -67,8 +67,8 @@ public: Window(QWidget *parent = 0); protected: - void dragEnterEvent(QDragEnterEvent *event); - void dropEvent(QDropEvent *event); + void dragEnterEvent(QDragEnterEvent *event) override; + void dropEvent(QDropEvent *event) override; private: QComboBox *mimeTypeCombo; diff --git a/src/gui/doc/snippets/droprectangle/window.h b/src/gui/doc/snippets/droprectangle/window.h index 683e5cb813..5a9ef75d3b 100644 --- a/src/gui/doc/snippets/droprectangle/window.h +++ b/src/gui/doc/snippets/droprectangle/window.h @@ -67,8 +67,8 @@ public: Window(QWidget *parent = 0); protected: - void dragMoveEvent(QDragMoveEvent *event); - void dropEvent(QDropEvent *event); + void dragMoveEvent(QDragMoveEvent *event) override; + void dropEvent(QDropEvent *event) override; private: QComboBox *mimeTypeCombo; diff --git a/src/gui/doc/snippets/matrix/matrix.cpp b/src/gui/doc/snippets/matrix/matrix.cpp index ec9e130a29..115dc3d508 100644 --- a/src/gui/doc/snippets/matrix/matrix.cpp +++ b/src/gui/doc/snippets/matrix/matrix.cpp @@ -53,7 +53,7 @@ class SimpleTransformation : public QWidget { - void paintEvent(QPaintEvent *); + void paintEvent(QPaintEvent *) override; }; //! [0] @@ -73,7 +73,7 @@ void SimpleTransformation::paintEvent(QPaintEvent *) class CombinedTransformation : public QWidget { - void paintEvent(QPaintEvent *); + void paintEvent(QPaintEvent *) override; }; //! [1] @@ -97,7 +97,7 @@ void CombinedTransformation::paintEvent(QPaintEvent *) class BasicOperations : public QWidget { - void paintEvent(QPaintEvent *); + void paintEvent(QPaintEvent *) override; }; //! [2] diff --git a/src/gui/doc/snippets/plaintextlayout/window.h b/src/gui/doc/snippets/plaintextlayout/window.h index 0068a37482..8552ecd4ba 100644 --- a/src/gui/doc/snippets/plaintextlayout/window.h +++ b/src/gui/doc/snippets/plaintextlayout/window.h @@ -61,7 +61,7 @@ public: Window(QWidget *parent = 0); protected: - void paintEvent(QPaintEvent *event); + void paintEvent(QPaintEvent *event) override; private: QFont font; diff --git a/src/gui/doc/snippets/qfileopenevent/main.cpp b/src/gui/doc/snippets/qfileopenevent/main.cpp index 3e707f2ddf..f18e763bbc 100644 --- a/src/gui/doc/snippets/qfileopenevent/main.cpp +++ b/src/gui/doc/snippets/qfileopenevent/main.cpp @@ -61,7 +61,7 @@ public: { } - bool event(QEvent *event) + bool event(QEvent *event) override { if (event->type() == QEvent::FileOpen) { QFileOpenEvent *openEvent = static_cast(event); diff --git a/src/gui/doc/snippets/separations/finalwidget.h b/src/gui/doc/snippets/separations/finalwidget.h index 0301f68fe9..886a5dfaf3 100644 --- a/src/gui/doc/snippets/separations/finalwidget.h +++ b/src/gui/doc/snippets/separations/finalwidget.h @@ -71,8 +71,8 @@ public: const QPixmap *pixmap() const; protected: - void mouseMoveEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; private: void createImage(); diff --git a/src/gui/doc/snippets/textdocument-imagedrop/textedit.h b/src/gui/doc/snippets/textdocument-imagedrop/textedit.h index 9f73bceeaf..3f570884ba 100644 --- a/src/gui/doc/snippets/textdocument-imagedrop/textedit.h +++ b/src/gui/doc/snippets/textdocument-imagedrop/textedit.h @@ -59,8 +59,8 @@ class TextEdit : public QTextEdit public: TextEdit(QWidget *parent=0); - bool canInsertFromMimeData( const QMimeData *source ) const; - void insertFromMimeData( const QMimeData *source ); + bool canInsertFromMimeData( const QMimeData *source ) const override; + void insertFromMimeData( const QMimeData *source ) override; }; #endif diff --git a/src/gui/doc/snippets/transform/main.cpp b/src/gui/doc/snippets/transform/main.cpp index e096eee7fc..e30a3b63bf 100644 --- a/src/gui/doc/snippets/transform/main.cpp +++ b/src/gui/doc/snippets/transform/main.cpp @@ -53,7 +53,7 @@ class SimpleTransformation : public QWidget { - void paintEvent(QPaintEvent *); + void paintEvent(QPaintEvent *) override; }; //! [0] @@ -73,7 +73,7 @@ void SimpleTransformation::paintEvent(QPaintEvent *) class CombinedTransformation : public QWidget { - void paintEvent(QPaintEvent *); + void paintEvent(QPaintEvent *) override; }; //! [1] @@ -97,7 +97,7 @@ void CombinedTransformation::paintEvent(QPaintEvent *) class BasicOperations : public QWidget { - void paintEvent(QPaintEvent *); + void paintEvent(QPaintEvent *) override; }; //! [2] diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 400888cc21..6486a447ee 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -55,12 +55,16 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_DEBUG #define QT_RESET_GLERROR() \ { \ - while (QOpenGLContext::currentContext()->functions()->glGetError() != GL_NO_ERROR) {} \ + while (true) {\ + GLenum error = QOpenGLContext::currentContext()->functions()->glGetError(); \ + if (error == GL_NO_ERROR || error == GL_CONTEXT_LOST) \ + break; \ + } \ } #define QT_CHECK_GLERROR() \ { \ GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); \ - if (err != GL_NO_ERROR) { \ + if (err != GL_NO_ERROR && err != GL_CONTEXT_LOST) { \ qDebug("[%s line %d] OpenGL Error: %d", \ __FILE__, __LINE__, (int)err); \ } \ @@ -134,6 +138,10 @@ QT_BEGIN_NAMESPACE #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #endif +#ifndef GL_CONTEXT_LOST +#define GL_CONTEXT_LOST 0x0507 +#endif + /*! @@ -1327,8 +1335,11 @@ static QImage qt_gl_read_framebuffer(const QSize &size, GLenum internal_format, { QOpenGLContext *ctx = QOpenGLContext::currentContext(); QOpenGLFunctions *funcs = ctx->functions(); - while (funcs->glGetError()); - + while (true) { + GLenum error = funcs->glGetError(); + if (error == GL_NO_ERROR || error == GL_CONTEXT_LOST) + break; + } switch (internal_format) { case GL_RGB: case GL_RGB8: diff --git a/src/opengl/doc/snippets/code/src_opengl_qgl.cpp b/src/opengl/doc/snippets/code/src_opengl_qgl.cpp index 839d941a1c..a73ee2cdc5 100644 --- a/src/opengl/doc/snippets/code/src_opengl_qgl.cpp +++ b/src/opengl/doc/snippets/code/src_opengl_qgl.cpp @@ -146,7 +146,7 @@ public: protected: - void initializeGL() + void initializeGL() override { // Set up the rendering context, define display lists etc.: ... @@ -155,7 +155,7 @@ protected: ... } - void resizeGL(int w, int h) + void resizeGL(int w, int h) override { // setup viewport, projection etc.: glViewport(0, 0, (GLint)w, (GLint)h); @@ -164,7 +164,7 @@ protected: ... } - void paintGL() + void paintGL() override { // draw the scene: ... diff --git a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp index d0f9a367c5..a27feb1505 100644 --- a/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp +++ b/src/sql/doc/snippets/sqldatabase/sqldatabase.cpp @@ -273,7 +273,7 @@ void QSqlQueryModel_snippets() class MyModel : public QSqlQueryModel { public: - QVariant data(const QModelIndex &item, int role) const; + QVariant data(const QModelIndex &item, int role) const override; int m_specialColumnNo; }; @@ -526,15 +526,15 @@ public: ~XyzResult() {} protected: - QVariant data(int /* index */) { return QVariant(); } - bool isNull(int /* index */) { return false; } - bool reset(const QString & /* query */) { return false; } - bool fetch(int /* index */) { return false; } - bool fetchFirst() { return false; } - bool fetchLast() { return false; } - int size() { return 0; } - int numRowsAffected() { return 0; } - QSqlRecord record() const { return QSqlRecord(); } + QVariant data(int /* index */) override { return QVariant(); } + bool isNull(int /* index */) override { return false; } + bool reset(const QString & /* query */) override { return false; } + bool fetch(int /* index */) override { return false; } + bool fetchFirst() override { return false; } + bool fetchLast() override { return false; } + int size() override { return 0; } + int numRowsAffected() override { return 0; } + QSqlRecord record() const override { return QSqlRecord(); } }; //! [47] @@ -545,13 +545,13 @@ public: XyzDriver() {} ~XyzDriver() {} - bool hasFeature(DriverFeature /* feature */) const { return false; } + bool hasFeature(DriverFeature /* feature */) const override { return false; } bool open(const QString & /* db */, const QString & /* user */, const QString & /* password */, const QString & /* host */, - int /* port */, const QString & /* options */) + int /* port */, const QString & /* options */) override { return false; } void close() {} - QSqlResult *createResult() const { return new XyzResult(this); } + QSqlResult *createResult() const override { return new XyzResult(this); } }; //! [48] diff --git a/src/widgets/doc/snippets/code/doc_gui_widgets_qopenglwidget.cpp b/src/widgets/doc/snippets/code/doc_gui_widgets_qopenglwidget.cpp index 4a3816ae72..633a413b4f 100644 --- a/src/widgets/doc/snippets/code/doc_gui_widgets_qopenglwidget.cpp +++ b/src/widgets/doc/snippets/code/doc_gui_widgets_qopenglwidget.cpp @@ -55,7 +55,7 @@ public: MyGLWidget(QWidget *parent) : QOpenGLWidget(parent) { } protected: - void initializeGL() + void initializeGL() override { // Set up the rendering context, load shaders and other resources, etc.: QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); @@ -63,7 +63,7 @@ protected: ... } - void resizeGL(int w, int h) + void resizeGL(int w, int h) override { // Update projection matrix and other size related settings: m_projection.setToIdentity(); @@ -71,7 +71,7 @@ protected: ... } - void paintGL() + void paintGL() override { // Draw the scene: QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); @@ -86,7 +86,7 @@ protected: class MyGLWidget : public QOpenGLWidget, protected QOpenGLFunctions { ... - void initializeGL() + void initializeGL() override { initializeOpenGLFunctions(); glClearColor(...); @@ -108,7 +108,7 @@ widget->setFormat(format); // must be called before the widget or its parent win //! [3] ... - void paintGL() + void paintGL() override { QOpenGLFunctions_3_2_Core *f = QOpenGLContext::currentContext()->versionFunctions(); ... diff --git a/src/widgets/doc/snippets/code/doc_src_layout.cpp b/src/widgets/doc/snippets/code/doc_src_layout.cpp index 42f5611bde..5e9a740244 100644 --- a/src/widgets/doc/snippets/code/doc_src_layout.cpp +++ b/src/widgets/doc/snippets/code/doc_src_layout.cpp @@ -63,13 +63,13 @@ public: CardLayout(int dist): QLayout(dist) {} ~CardLayout(); - void addItem(QLayoutItem *item); - QSize sizeHint() const; - QSize minimumSize() const; - int count() const; - QLayoutItem *itemAt(int) const; - QLayoutItem *takeAt(int); - void setGeometry(const QRect &rect); + void addItem(QLayoutItem *item) override; + QSize sizeHint() const override; + QSize minimumSize() const override; + int count() const override; + QLayoutItem *itemAt(int) const override; + QLayoutItem *takeAt(int) override; + void setGeometry(const QRect &rect) override; private: QList list; diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp index 7511c83b3c..8d8c63db9e 100644 --- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp +++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp @@ -52,7 +52,7 @@ class SimpleItem : public QGraphicsItem { public: - QRectF boundingRect() const + QRectF boundingRect() const override { qreal penWidth = 1; return QRectF(-10 - penWidth / 2, -10 - penWidth / 2, @@ -60,7 +60,7 @@ public: } void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget) + QWidget *widget) override { painter->drawRoundedRect(-10, -10, 20, 20, 5, 5); } @@ -74,7 +74,7 @@ class CustomItem : public QGraphicsItem public: enum { Type = UserType + 1 }; - int type() const + int type() const override { // Enable the use of qgraphicsitem_cast with this item. return Type; @@ -260,7 +260,7 @@ class QGraphicsPathItem : public QAbstractGraphicsShapeItem { public: enum { Type = 2 }; - int type() const { return Type; } + int type() const override { return Type; } ... }; //! [18] diff --git a/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp b/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp index 33d5fab321..3169d1c193 100644 --- a/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp +++ b/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp @@ -54,7 +54,7 @@ class MyProxyStyle : public QProxyStyle public: int styleHint(StyleHint hint, const QStyleOption *option = 0, - const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const + const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const override { if (hint == QStyle::SH_UnderlineShortcut) return 1; @@ -73,7 +73,7 @@ class MyProxyStyle : public QProxyStyle { public: int styleHint(StyleHint hint, const QStyleOption *option = 0, - const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const + const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const override { if (hint == QStyle::SH_UnderlineShortcut) return 0; diff --git a/src/widgets/doc/snippets/code/src_gui_util_qundostack.cpp b/src/widgets/doc/snippets/code/src_gui_util_qundostack.cpp index e191c74287..8f59fe9cb3 100644 --- a/src/widgets/doc/snippets/code/src_gui_util_qundostack.cpp +++ b/src/widgets/doc/snippets/code/src_gui_util_qundostack.cpp @@ -54,9 +54,9 @@ class AppendText : public QUndoCommand public: AppendText(QString *doc, const QString &text) : m_document(doc), m_text(text) { setText("append text"); } - virtual void undo() + void undo() override { m_document->chop(m_text.length()); } - virtual void redo() + void redo() override { m_document->append(m_text); } private: QString *m_document; diff --git a/src/widgets/doc/snippets/customstyle/customstyle.h b/src/widgets/doc/snippets/customstyle/customstyle.h index addb1dfb6e..be9edf0bf4 100644 --- a/src/widgets/doc/snippets/customstyle/customstyle.h +++ b/src/widgets/doc/snippets/customstyle/customstyle.h @@ -63,7 +63,7 @@ public: ~CustomStyle() {} void drawPrimitive(PrimitiveElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget) const; + QPainter *painter, const QWidget *widget) const override; }; //! [0] diff --git a/src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp b/src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp index b3ace9ce46..96e6bd650c 100644 --- a/src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp +++ b/src/widgets/doc/snippets/graphicssceneadditemsnippet.cpp @@ -58,7 +58,7 @@ public: void drawItems(QPainter *painter, int numItems, QGraphicsItem *items[], const QStyleOptionGraphicsItem options[], - QWidget *widget = 0); + QWidget *widget = 0) override; }; //! [0] diff --git a/src/widgets/doc/snippets/myscrollarea.cpp b/src/widgets/doc/snippets/myscrollarea.cpp index 477b041fe1..dbf8da1603 100644 --- a/src/widgets/doc/snippets/myscrollarea.cpp +++ b/src/widgets/doc/snippets/myscrollarea.cpp @@ -57,8 +57,8 @@ public: void setWidget(QWidget *w); protected: - void scrollContentsBy(int dx, int dy); - void resizeEvent(QResizeEvent *event); + void scrollContentsBy(int dx, int dy) override; + void resizeEvent(QResizeEvent *event) override; private: void updateWidgetPosition(); diff --git a/src/widgets/doc/snippets/qlistview-dnd/model.h b/src/widgets/doc/snippets/qlistview-dnd/model.h index 7635d2f21a..3d418dca14 100644 --- a/src/widgets/doc/snippets/qlistview-dnd/model.h +++ b/src/widgets/doc/snippets/qlistview-dnd/model.h @@ -61,15 +61,15 @@ class DragDropListModel : public QStringListModel public: DragDropListModel(const QStringList &strings, QObject *parent = 0); - Qt::ItemFlags flags(const QModelIndex &index) const; + Qt::ItemFlags flags(const QModelIndex &index) const override; bool canDropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent); + int row, int column, const QModelIndex &parent) override; bool dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent); - QMimeData *mimeData(const QModelIndexList &indexes) const; - QStringList mimeTypes() const; - Qt::DropActions supportedDropActions() const; + int row, int column, const QModelIndex &parent) override; + QMimeData *mimeData(const QModelIndexList &indexes) const override; + QStringList mimeTypes() const override; + Qt::DropActions supportedDropActions() const override; }; #endif diff --git a/src/widgets/doc/snippets/qstyleoption/main.cpp b/src/widgets/doc/snippets/qstyleoption/main.cpp index 659a5f945b..529f88f1d9 100644 --- a/src/widgets/doc/snippets/qstyleoption/main.cpp +++ b/src/widgets/doc/snippets/qstyleoption/main.cpp @@ -56,7 +56,7 @@ class MyPushButton : public QPushButton public: MyPushButton(QWidget *parent = 0); - void paintEvent(QPaintEvent *); + void paintEvent(QPaintEvent *) override; }; MyPushButton::MyPushButton(QWidget *parent) @@ -87,7 +87,7 @@ class MyStyle : public QStyle public: void drawPrimitive(PrimitiveElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget); + QPainter *painter, const QWidget *widget) override; }; //! [4] diff --git a/src/widgets/doc/snippets/qstyleplugin/main.cpp b/src/widgets/doc/snippets/qstyleplugin/main.cpp index 2cc7040e93..1c61581572 100644 --- a/src/widgets/doc/snippets/qstyleplugin/main.cpp +++ b/src/widgets/doc/snippets/qstyleplugin/main.cpp @@ -59,7 +59,7 @@ class MyStylePlugin : public QStylePlugin public: MyStylePlugin(QObject *parent = 0); - QStyle *create(const QString &key); + QStyle *create(const QString &key) override; }; //! [0] diff --git a/src/widgets/doc/snippets/splitterhandle/splitter.h b/src/widgets/doc/snippets/splitterhandle/splitter.h index 49ef20a620..8df7bc14a2 100644 --- a/src/widgets/doc/snippets/splitterhandle/splitter.h +++ b/src/widgets/doc/snippets/splitterhandle/splitter.h @@ -64,7 +64,7 @@ public: Splitter(Qt::Orientation orientation, QWidget *parent = 0); protected: - QSplitterHandle *createHandle(); + QSplitterHandle *createHandle() override; }; //! [0] @@ -74,7 +74,7 @@ public: SplitterHandle(Qt::Orientation orientation, QSplitter *parent); protected: - void paintEvent(QPaintEvent *event); + void paintEvent(QPaintEvent *event) override; private: QLinearGradient gradient; diff --git a/src/widgets/doc/snippets/styles/styles.cpp b/src/widgets/doc/snippets/styles/styles.cpp index 116c807f39..77fde0693d 100644 --- a/src/widgets/doc/snippets/styles/styles.cpp +++ b/src/widgets/doc/snippets/styles/styles.cpp @@ -55,7 +55,7 @@ class MyWidget : public QWidget { protected: - void paintEvent(QPaintEvent *event); + void paintEvent(QPaintEvent *event) override; void paintEvent2(QPaintEvent *event); }; diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 7615ad4586..1aa8984b70 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -2067,6 +2067,21 @@ void tst_QUrl::isValid() qPrintable(url.errorString())); } + { + QUrl url = QUrl::fromEncoded("foo://%f0%9f%93%99.example.la/g"); + QVERIFY(!url.isValid()); + QVERIFY(url.toString().isEmpty()); + QCOMPARE(url.path(), QString("/g")); + url.setHost("%f0%9f%93%99.example.la/"); + QVERIFY(!url.isValid()); + QVERIFY(url.toString().isEmpty()); + url.setHost("\xf0\x9f\x93\x99.example.la/"); + QVERIFY(!url.isValid()); + QVERIFY(url.toString().isEmpty()); + QVERIFY2(url.errorString().contains("Invalid hostname"), + qPrintable(url.errorString())); + } + { QUrl url("http://example.com"); QVERIFY(url.isValid()); @@ -2798,7 +2813,9 @@ void tst_QUrl::hosts() { QFETCH(QString, url); - QTEST(QUrl(url).host(), "host"); + QUrl u(url); + QTEST(u.host(), "host"); + QVERIFY(u.isEmpty() || u.isValid()); } void tst_QUrl::hostFlags_data()