summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* tst_QGraphicsItem: Fix UB (invalid cast/member call) in prepareGeometryChange()Marc Mutz2016-09-221-5/+8
| | | | | | | | | | | | | | | | | | | | | Found by UBSan: tst_qgraphicsitem.cpp:5066:29: runtime error: downcast of address 0x2afcb006c7f0 which does not point to an object of type 'GeometryChanger' 0x2afcb006c7f0: note: object is of type 'QGraphicsRectItem' 00 00 00 00 d8 64 ca 98 fc 2a 00 00 40 a9 0b b0 fc 2a 00 00 75 65 29 00 00 00 00 00 35 00 00 00 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QGraphicsRectItem' #0 0x4c5f1c in tst_QGraphicsItem::prepareGeometryChange() tst_qgraphicsitem.cpp:5066 Fix by actually instantiating a GeometryChanger, which incidentally is the pattern used by paint() a few lines below, too. While at it, allocate the item on the stack (as is done in paint()) and create a local QRectF variable to avoid repeating the same magic numbers over and over again. Change-Id: If5a3d56511000a17703d78d7dd1f0ea072b8bc11 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add missing test for QReguarExpression for QTextDocument::findMultipleSamuel Gaist2016-09-201-0/+18
| | | | | Change-Id: Ia9b3eb21a178da4ae2844dba37b7e1cc669d6b50 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* multiwindow: Base vsync debug output on actual surface formatTor Arne Vestbø2016-09-191-12/+18
| | | | | | | | Allows us to detect cases where the requested vsync combination was not possible to fulfill. Change-Id: Ie8f3665129f7a1ab7fcefb94b2298d54520b753a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* multiwindow: Replace per window fps timers with unified approachTor Arne Vestbø2016-09-191-18/+46
| | | | | | | | | | The FPS is now calculated and output on the command line in a single place. The animated fps counter has been replaced with a vertical line which should make it easier to observe tearing issues when vsync is disabled. Change-Id: Id356fc1958c048d85aba48edfed59124454038d4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* multiwindow: Call update() after swapTor Arne Vestbø2016-09-191-2/+2
| | | | | Change-Id: Ic2c26339bce9fe92b2ccc730c72f53ce94397b78 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* multiwindow: React to mouse press to allow debugging UI responsivenessTor Arne Vestbø2016-09-191-33/+20
| | | | | | | | The animated FPS counter should be enough to observe smooth animations, so we use the color of the window to visualize frame latency. Change-Id: I1171a1c4bdc261ca8655771290c6735357821781 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* multiwindow: Use showNormal() instead of show() to ensure normal geometryTor Arne Vestbø2016-09-191-1/+1
| | | | | Change-Id: Ice607f536a620da5a70f2ba066f4983bb78c6288 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QtWidgets: Fix enter/leave events on popup menusBłażej Szczygieł2016-09-151-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If the sloppy menu popups - send the leave event to the last active menu (except Cocoa), because only currect active menu gets enter/leave events (currently Cocoa is an exception). Check that the menu really has a mouse before hiding the sloppy menu - don't rely on enter events. This patch removes some unnecessary synthetic mouse enter/leave events from QMenu which causes event duplications with different mouse cursor position. Refactor sloppy menu timer handling - start or restart timers on mouse move events. Enter/leave events are not reliable. Fixes: - better enter/leave events handling for native widget actions, - reduce duplicated enter/leave events for menu actions, - better handle torn off sloppy menus. Partially reverts: 0ed68f3f58c63bd1496cb268bd83881da180051f Amends: 57ecd5aeeb1f609206933be66b92fcdf703703d7 Task-number: QTBUG-53068 Change-Id: I7ad56ac1619db124915d373fab82d0512d44c90e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QLatin1String: Fix UB (nullptr passed) in relational operatorsMarc Mutz2016-09-151-0/+57
| | | | | | | | | | | | | | | | | | Found by UBSan: qstring.h:1160:44: runtime error: null pointer passed as argument 1, which is declared to never be null qstring.h:1160:44: runtime error: null pointer passed as argument 2, which is declared to never be null Fix by avoiding the memcmp() calls if there's a chance that they might be called with nullptr. While at it, also implement !=, >, <=, >= in terms of ==, <, and add a test, because this particular UB was not fingered by any of the QtCore test cases, but by a Qt3D one. Change-Id: I413792dcc8431ef14f0c79f26e89a3e9fab69465 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Never return char variants when reading prepared MySQL statementsMilian Wolff2016-09-121-14/+31
| | | | | | | | | | | | | | | | | | | | | | | | This has undesired effects when converting a QSqlRecord to JSON. A char(0) e.g. has special semantics that are undesired when reading a Tinyint column. I don't think that returning bool for the special case of a Tinyint(1) is required. This also did not happen before, and is also not happening when not using a prepared statement. Instead, a plain int/uint QVariant is returned. This patch extends tst_QSqlQuery::integralTypesMysql to also cover reading and writing booleans from/to a MySQL table column of type Tinyint(1). Additionally, the reading is now also done with a prepared statement and we also check the raw variant value. The broken behavior fixed by this patch was introduced by me in commit 194403a3483b7317cc9511bc8b2ab307775643c5. Change-Id: I028a3abd83fdd2b42d98d478950d205e5b6bbeb5 Task-number: QTBUG-53397 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* QtWidgets: Send show/hide event to children on restore/minimizeBłażej Szczygieł2016-09-121-5/+43
| | | | | | | | | | | | | | | | | | | | | Child widgets should get the show/hide event when the TLW changes its state, because child widgets are also visible or invisible. This restores the Qt4 behavior (fixes the Qt4->Qt5 regression). Restoring/minimizing the TLW now sends the spontaneous show/hide event. Show events are now handled also in the expose event handler in the QWidgetWindow class, because the show event must occur before the expose event to avoid possible flicker e.g. the OpenGL content. This can happen e.g. on XCB platform. If the "WindowStateChange" event occur before the expose event (e.g. Windows platform) then the code in expose event handler will be ignored to prevent event duplications. Added autotest. Task-number: QTBUG-50589 Change-Id: Ie9a9329b1f29bff876de28d5948d0d5fb6bc1f05 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* qcompilerdetection.h: retract Q_COMPILER_DEFAULT_MEMBERS for MSVC < 2015Marc Mutz2016-09-031-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Earlier versions of the compiler cannot default move special member functions, even though we also define Q_COMPILER_RVALUE_REFS for them. Fix by retracting the less-often-used of the two compiler feature defines. Q_COMPILER_DEFAULT_MEMBERS is not used outside QtBase in neither 5.6 nor 5.7 (5.8 is not released at this time, so wasn't considered). The same is true of the dependent macros Q_COMPILER_DEFAULT_DELETE_MEMBERS and Q_DECL_EQ_DEFAULT. In QtBase, the three uses are: 1. in QAtomic*, where the user also requires Q_COMPILER_CONSTEXPR, which is not defined for any MSVC at this time, 2. for QEnableSharedFromThis, which is a class template with an alternative {} implementa- tion of the default constructor, and uncon- ditional user-defined copy special member functions. 3. The test of the corresponding functionality in tst_compiler, which this commit amends. That means that neither of these two only uses of the macro in Qt libraries are affected by the change. The reason we do this change, then, is that in the future, we want to be able to more easily restore move special member functions for classes for which they are suppressed due to user-defined dtors or copy special member functions. Change-Id: I6f88cad66d6b87a758231f16355c3bddae697b86 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qstrncpy: don't call strncpy_s with invalid parametersMarc Mutz2016-09-031-3/+11
| | | | | | | | | | | | | | | According to https://msdn.microsoft.com/en-us/library/5dae5d43.aspx, strncpy_s' second argument must not be 0: > If strDest or strSource is NULL, *or numberOfElements is 0*, the > invalid parameter handler is invoked. Move the existing check for len > 0 up to protect the strncpy_s call, too. Change-Id: I70d339ea60d4b76f3038b2e4e4756f6590a9bd31 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* uic: generate translate calls with Q_NULLPTR instead of 0Dyami Caliri2016-09-03102-985/+985
| | | | | | | | | uic should use Q_NULLPTR instead of 0 as the default disambiguation context. Task-number: QTBUG-45291 Change-Id: I889182c7fe1c4be3336f3cd645aa60838863c633 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Major re-write of generate_expected_output.pyEdward Welbourne2016-08-291-82/+178
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Restructured, separated the canonicalising of output lines out (into an object that prepares the necessary regexes and replacements) suppress more, changed the path-stripping to strip qtbase's parent rather than os.getcwd() and took account of shadow builds (so both source tree and build tree provide prefixes we want to strip from paths). Also cope with $PWD potentially having symlinks in it, where os.getcwd() is canonical. It's possible some output might name files elsewhere in the source tree; these won't be filtered by the prior cwd prefix removal; and, in any case, the problem with cwd is only that the ancestry of qtbase is apt to vary; paths relative to there should be consistent between test runs. This change shall lead to a one-off rewrite of all expected_* files; but it should now catch all paths. By stripping both build root and source root (when different) it also avoids differences for those doing out-of-source ("shadow") builds. In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my build root's path) got represented by a character entity, confounding the replacement; so also do replacement that catches this. We may discover other character entity subsitutions needed along with this. Now filtering line numbers and timing information, including benchmark results; these numbers all get replaced with 0 to avoid noisy diffs. Also purging dangling hspace, to placate sanity-bot. The module can now be imported - the code it runs is packaged as a main() function that a __name__ == '__main__' stanza runs - and all data is localised to where it's needed, rather than held in globals. Tidied up and organized the existing regexes. There are doc-strings; there is a short usage comment. Data is localised rather than global and modern pythonic idioms get used where apt. Regexes are compiled once instead of repeatedly. An object looks after the list of patterns to apply and its construction handles all anticipated problems. Failures are mediated by an exception. The output file now gets written once, instead of twice (once before editing, then over-write to edit), and Popen uses text mode, so that write can do the same. Its command is delivered as an array, avoiding the need to invoke a shell. Instead of relying on qmake being in our path (which might give us a bogus QT_VERSION if the one in path doesn't match our build tree), use the relative path to qmake - we rely on being run in a specific directory in the build tree, after all. Escape dots in the version properly, so that 51730 doesn't get mistaken for 5.7.0 (for example), and moved this check later in the sequence (matching a smaller target makes it more likely to falsely match). Overtly check we are in the right directory and tell the user what we actually need, if run from the wrong place. Simplify handling of the unsupported use-case for MS-Windows (but note what would be needed for it). Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* QTextDocument: fix string backward searchSamuel Gaist2016-08-281-0/+2
| | | | | | | | | [ChangeLog][QtGui][QTextDocument] Fixed a bug that would return a wrong position when searching backward from the end of the document. Task-number: QTBUG-48182 Change-Id: I6e88f808a50cb840f61e7bc579e2a28c5300089d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QAbstractSpinBox: Clear 'cleared' flag on receiving a keypressFriedemann Kleint2016-08-251-0/+29
| | | | | | | | | Prevent QAbstractSpinBoxPrivate::interpret() from bailing out in focus changes after text has been entered. Task-number: QTBUG-55249 Change-Id: I250b3c50f7db5de2e9356038df20f18ee059df11 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* multiwindow: Make it easier to test 1-N windowsTor Arne Vestbø2016-08-241-27/+33
| | | | | | | | | Changes the --extrawindows option to --numwindows with a default of 3, and layouts all windows in rows and columns so that they are all exposed at startup. Change-Id: I5e8d63a14b778bcddc2fee3bf7e78d6664532b5b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* multiwindow: Use QCommandLineParser instead of parsing manuallyTor Arne Vestbø2016-08-241-24/+35
| | | | | Change-Id: I9d9e3ede6c8cce3aa1b42d0e98a0a5b19fefc73c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QMimeType: use default locale rather than system localeDavid Faure2016-08-242-0/+17
| | | | | | | | | | | | | This makes it possible for the application to control which language is used by QMimeType::comment() [ChangeLog][QtCore][QMimeType] QMimeType::comment() now uses the default locale rather than system locale, so that applications can control which language is being used. Task-number: QTBUG-50776 Change-Id: I82623b7c488035a4164fadaf37ebcc79a9fd6173 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* multiwindow: Base fps on number of frames swapped, not timing of last frameTor Arne Vestbø2016-08-241-9/+21
| | | | | Change-Id: I582e4f35b2702ac3792c5641fa10f74a79351bed Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix crash in dumpConfigurationMaurice Kalinowski2016-08-231-5/+7
| | | | | | | | Some qpa backends do not provide a QPlatformNativeInterface. Hence, check whether return value is valid. Change-Id: Iab46bc59a151aa244fcfebf58edb37496369db89 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Fix problem with exception reporting in QFuture::waitForResult()Christian Strømme2016-08-231-0/+37
| | | | | | | | | | This fixes a problem that occurs when a task, that is run synchronously, throws an exception. If that happened, then the exception would not be re-thrown, because of an early return. Task-number: QTBUG-54831 Change-Id: Ic70c5b810ec6adce6e62bfd6832ba9f170b13a7f Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* Cocoa Menus: Introducing Menurama manual testGabriel de Dietrich2016-08-197-0/+658
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This manual test pretends to be a modest safeguard against QMenu related regressions on macOS. It takes a slightly different approach than the existing menus manual test, tracking observed regressions instead of providing extensive coverage (though this may change in the future). These regressions are listed as task numbers below, most of them arising from the now infamous change, 09acf326dbc6b7b6 QCocoaMenu: Decouple NSMenuItem from NSMenu So, from now on, please run this and the menus manual tests and look for regressions every time you make a change regarding QCocoaMenu and related. And, if you're fixing a regression, add the regression example to the Menurama manual test. Task-number: QTBUG-52931 Task-number: QTBUG-53085 Task-number: QTBUG-53251 Task-number: QTBUG-54633 Task-number: QTBUG-54637 Task-number: QTBUG-54698 Task-number: QTBUG-55121 Change-Id: I276e916dcdf00f1a44faf64d87050bc3a037a3b5 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Remove unneeded dependency on Qt widgetsEirik Aavitsland2016-08-151-1/+1
| | | | | | | | | Widgets module is no longer required. Removing it allows this test to be run with a qtbase configured with -no-widgets, which saves compilation time. Change-Id: Id99d3f25cd7b227aa81e1cf1ac7b6fd5227ac4c4 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Doc: Change instances of '(Mac) OS X' to 'macOS'Topi Reinio2016-08-121-1/+1
| | | | | | | | | | | | | | | As of version 10.12 (Sierra), the name of Apple's desktop operating system will be macOS. Change the occurrences where the Mac platform is discussed to use a macro \macos, which expands to 'macOS'. This helps with adapting to future renaming. Update the instructions on mac-specific Q_OS_* macro usage. Add a \target for the old 'Qt for OS X' topic to keep links working for other documentation modules that try to link with the old name. Change-Id: Id33fb0cd985df702a4ae4efb4c5fd428e77d9b85 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* tst_QStringListModel: don't leak memory when tests failMarc Mutz2016-08-121-20/+14
| | | | | | | Simply allocate objects on the stack instead of the heap. Change-Id: Ic047d78e49668878821cce1c8ab599a8551b6476 Reviewed-by: David Faure <david.faure@kdab.com>
* QStringListModel: fix dataChanged's roles parameterMarc Mutz2016-08-122-2/+53
| | | | | | | | | | | | | In QStringListModel, the display and the edit roles are synonyms, so when one is changed, the other changes with it. However, in setData() we only emitted a vector with just the role that was passed in by the user. Fix by always passing both roles, regardless of which one was used to set the data. Change-Id: I498e7cb33796fae266901817b01ad85d861d4bb4 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* tst_QSslSocket::setLocalCertificateChain(): fix resource leak when test failMarc Mutz2016-08-111-3/+2
| | | | | | | | | The deleteLater() call wasn't reliably reached when tests fail, so use a QScopedPointer with QScopedPointerDeleteLater deleter. Change-Id: Ica73bc73c2a0ac1e9b77e4804f2aedcad9b662a0 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> Reviewed-by: Richard J. Moore <rich@kde.org>
* Remove ~tst_QImageWriterMarc Mutz2016-08-111-11/+0
| | | | | | | | | | The test no longer writes to SRCDIR, so don't try to remove generated files from there, either. Amends bb5570082ecbb1494fd39a971f722cc159bf213a. Change-Id: I1d5df88b1865f3dbd914ec71147de61e173f2f4e Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* Fix memory leak in tst_qgraphicsproxywidgetJędrzej Nowacki2016-08-101-1/+2
| | | | | | | | QStyle was created but never removed Change-Id: I55011377afd475af28e4ce2cf657e435dd37c96a Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* Always generate size hint for spacer itemsJarek Kobus2016-08-082-3/+3
| | | | | | Task-number: QTBUG-55008 Change-Id: I53c86b64aa3c0a3e5f80551baefe775c2d4b1e90 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* tst_QString: unit test for broken toLocal8bit() error-handlingEdward Welbourne2016-08-051-0/+62
| | | | | | | | | | We can't (at present) actually exercise the failure in QWindowsLocalCodec::convertFromUnicode() that prompted us to consider the possible failure here, but we should at least test for it. Change-Id: I5066c88d7b4caeb48aebc6b79c355fa49e1c581c Reviewed-by: Frederic Marchal <frederic.marchal@wowtechnology.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix tst_QProcess::closeWriteChannel() under WindowsAlex Trotsenko2016-08-051-6/+9
| | | | | | | | | | | | Sometimes, this test fails in CI due to notifications arriving asynchronously from the OS. This happens inside closeWriteChannel() call, where we are flushing the write buffer and I/O completion on the read pipe could occur there as well. So, take this into account before waiting for the new incoming data. Also, improve the checks on successful reading and writing. Change-Id: Iabe875fc346eb4420c72d03208d22ea861a570c6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Improve performance of QColor::name, now more than 4 times fasterDavid Faure2016-08-054-0/+77
| | | | | | | | | | | | | | Before: HexRgb: 0.00230 ms per iteration, HexArgb: 0.00290 ms per iteration After: HexRgb: 0.00051 ms per iteration, HexArgb: 0.00061 ms per iteration This showed up as a relevant optimization when profiling KIconLoader which uses QColor::name() as part of the key -- thanks to Mark Gaiser for the investigation and first suggestion of a solution. I have also seen customer code writing a replacement for QColor::name() because it was too slow to be used as a hash key. Change-Id: I009ccdd712ea0d869d466e2c9894e0cea58f0e68 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QNativeSocketEngine::option(): return a correct value on invalid callAlex Trotsenko2016-08-051-0/+1
| | | | | | | | Instead of 'true', it should be '-1'. Change-Id: I5e8f99153da68d34b37477ef4cedbc447fba347f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QString: fix append(const QStringRef &str)Anton Kudryavtsev2016-08-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | Use QStringRef::isNull instead of QStringRef::string() for validation. Non-NULL str.string() may yet leave us with a useless str.unicode(), which is the actual problem here; whereas !str.isNull() does really confirm that str.unicode() is sensible. Such test prevents situation like: const QString a; QString b; b.append(a); // b.isNull() == true b.append(QStringRef(&a)); // b.isNull() == false Auto test updated: create QStringRef from QString directly, without any condition. Change-Id: I082cd58ef656d8a53e3c1223aca01feea82fffb9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QLocalSocket/Tcp: open device before making a connectionAlex Trotsenko2016-08-041-0/+1
| | | | | | | | | | | | According to QLocalSocket's documentation, connectToServer() must initiate a connection attempt after opening the device. Otherwise, if a connection succeeds immediately, connected() signal will be emitted on closed device. So, this patch ensures that TCP-based implementation behaves correctly. Change-Id: I4cc9474815e091a1491a429a6dc17f9cf0154f58 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Don't call virtual functions with data from an old modelBogDan Vatra2016-08-041-2/+41
| | | | | | Change-Id: I4f1ec56ce722110042f72761bbc2976e580b7149 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Fixed Bug in QVariant comparison when containing QStringListsClemens Sielaff2016-08-031-0/+55
| | | | | | | | | | | | | | | | | As it were, QStringLists were not handled explicitly when comparing QVariants. If both QStringLists contained only a single entry, they were treated as QStrings - if both QStringLists were empty, there were equal (correctly so) - but if one of the QStringLists had more than one entry, the compare function fell through to returning always 1. As discussed here: https://stackoverflow.com/a/38492467/3444217 Added rich comparison tests for all non-numerical, non-recursive QVariants that support them (except QModelIndex and QPersistentModelIndex) Task-number: QTBUG-54893 Change-Id: Icc5480d9ba056ee5efe83da566c5829caa1509d7 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* tst_QTreeView: Fix UB (invalid downcast, member call)Marc Mutz2016-08-011-70/+27
| | | | | | | | | | | | | As reported by UBSan: tst_qtreeview.cpp:2187:36: runtime error: downcast of address 0x7ffc15749f20 which does not point to an object of type 'PublicView' 0x7ffc15749f20: note: object is of type 'QTreeView' Fix by making the test a friend of QTreeView (and, for Clang, of QAbstractItemView) instead. Change-Id: I5b748696ab441a91058f4d45a18bd5ed75a6e560 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* tst_QAbstractItemView: Fix UB (invalid downcast, member call)Marc Mutz2016-08-011-178/+76
| | | | | | | | | | | | | | | | | | As reported by UBSan: tst_qabstractitemview.cpp:336:23: runtime error: member call on address 0x7ffe6fe96e10 which does not point to an object of type 'TestView' 0x7ffe6fe96e10: note: object is of type 'QListView' tst_qabstractitemview.cpp:337:5: runtime error: member call on address 0x7ffe6fe96e10 which does not point to an object of type 'TestView' 0x7ffe6fe96e10: note: object is of type 'QListView' tst_qabstractitemview.cpp:338:23: runtime error: member call on address 0x7ffe6fe96e10 which does not point to an object of type 'TestView' 0x7ffe6fe96e10: note: object is of type 'QListView' [etc ...] Fix by making the test a friend of QAbstractItemView instead. Change-Id: I1a08977042296eb34e9dbdb5c0595662dbd2e5ef Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QSortFilterProxyModel: Don't forward the hint from source's layoutChanged signalOlivier Goffart2016-08-011-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | We can't forward a VerticalSortHint or HorizontalSortHint hint, because we might be filtering extra items. The documentation of QAbstractItemModel::LayoutChangeHint states: Note that VerticalSortHint and HorizontalSortHint carry the meaning that items are being moved within the same parent, not moved to a different parent in the model, and not filtered out or in. And some of the views rely on this assumption (QQmlDelegateModel for example) What happens in the test is the following: - 'model' emit the dataChanged signal when its data is changed. - 'proxi1' QSortFilterProxyModelPrivate::_q_sourceDataChanged does not forward the dataChanged signal imediatly, it will instead first re-sort the model and call layoutAboutToBeChanged / layouChanged with the VerticalSortHint - 'proxy2' would forward the layoutAboutToBeChanged with the hint, but in QSortFilterProxyModelPrivate::_q_sourceLayoutChanged, it will redo the mapping which will cause the changed data to be filtered. So proxy2 can't forward the VerticalSortHint as it removed rows in the process. Change-Id: I20b6983e9d18bf7509fe6144c74f37d24e4a18c2 Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com> Reviewed-by: David Faure <david.faure@kdab.com>
* Fix UB (invalid enum value) in tst_QTreeViewMarc Mutz2016-07-311-30/+32
| | | | | | | | | | | | As reported by UBSan: tst_qtreeview.cpp:663:5: runtime error: load of value 4294967295, which is not a valid value for type 'DragDropMode' Instead of abusing -1 to indicate to not set the dragDropMode, use a separate boolean field in tha data. Change-Id: I13e7539c858f3b2462d57d660062ef3cb7aec61b Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QUrl: fix resolved() for data URLsDavid Faure2016-07-291-7/+9
| | | | | | | | | | | | | | They look relative because the path doesn't start with a '/' but they have a scheme so they shouldn't be combined as if it was one absolute and one relative URL. [ChangeLog][QtCore][QUrl] QUrl::resolved() no longer treats a URL with a scheme as a relative URL if it matches this URL's scheme. This special casing was incompatible with RFC 3986 and broke resolving data: URLs, for instance. Change-Id: I3758d3a2141cea7c6d13514243eb8dee5d510dd0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix for race condition in signal activationDenis Kormalev2016-07-291-0/+175
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was a race condition between QObject::disconnect() and QMetaObject::activate() which can occur if there are multiple BlockingQueued connections to one signal from different threads and they connect/disconnect their connections often. What can happen in this case is: T1 is in activate() method and T2 is in disconnect() method T1 T2 locks sender mutex selects next connection unlocks sender mutex locks sender mutex sets isSlotObject to false creates QMetaCallEvent derefs connection posts event Two things can happen here: 1. Connection can still be valid, but it will have isSlotObject==false and callFunction will be used instead of slotObj 2. Connection can already be invalid To fix it mutex unlock should be moved after QMetaCallEvent creation. Also there is another case, when we don't disconnect but delete the receiver object. In this case it can already be invalid during postEvent, so we need to move mutex unlock after postEvent. Change-Id: I8103798324140ee11de5b4e10906562ba878ff8b Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Item delegates: show localized detailed tooltips and "What's this?" textsAlexander Volkov2016-07-282-1/+63
| | | | | | | | | | | | | Extract the common part from QItemDelegate and QStyledItemDelegate which uses QLocale to convert a value for Qt::DisplayRole to a string. Use this code to get the text for tooltips and "What's this?". [ChangeLog][QtWidgets][QAbstractItemDelegate] Show localized detailed tooltips and "What's this?" texts. Task-number: QTBUG-16469 Change-Id: I8618763d45b8cfddafc2f263d658ba256be60a15 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QVector: fix crash on reserve(0)David Faure2016-07-281-0/+22
| | | | | | | | | | It crashed when d was equal to Data::unsharableEmpty(). Task-number: QTBUG-51758 Change-Id: If9f2a7d11892507135f4dc0aeef909f59b7478fc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* Backwards compatibility fix: No default colormap for Mono QImagesEirik Aavitsland2016-07-271-2/+36
| | | | | | | | | | | | | | | | | This is a partial revert of a4e2f2e687ca7aec88ecf82f72d42ac61e17a5b9. That fix tried to avoid the risk of a crash in pixel() by ensuring Mono QImages created with external data also got a default color table. However, that broke usable behavior in existing code that was painting in Mono QImages using color0/color1. This commit reverts to the old behavior, and instead expands on the checking in pixel() so that lacking color table is handled gracefully for all indexed formats. Task-number: QTBUG-54827 Change-Id: I9164198bed9d20c4b12cdba40a31c141bef3128d Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix QTemporaryDir to handle Unicode characters on WindowsFriedemann Kleint2016-07-202-0/+82
| | | | | | | | | | | | | | | | | | For platforms not providing mkdtemp(), QTemporaryDir relied on an implementation of q_mkdtemp() operating on char *, converting back and forth using QFile::encodeName()/decodeName() when passing the name to QFileSystemEngine. This caused failures on Windows (which uses "System"/Latin1 encoding) for names containing characters outside the Latin1 space. Reimplement q_mkdtemp() to operate on QString, which avoids the conversions altogether and also enables the use of larger character spaces for the pattern. Add tests. Task-number: QTBUG-54810 Change-Id: Ie4323ad73b5beb8a1b8ab81425f73d03c626d58a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>