summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Change representation of string data in the meta objectLars Knoll2019-12-085-36/+36
| | | | | | | | | | | | | Don't store our string data as QByteArrayLiterals anymore, but revert back to simply storing them as an array of char* and offsets into that array. This is required to be able to inline size and begin into QByteArray itself. Once that change is done, we can then avoid creating copies of the string data again. Change-Id: I362a54581caefdb1b3da4a7ab922d37e2e63dc02 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Inline the size and data pointer members in QStringThiago Macieira2019-12-085-292/+304
| | | | | | | | | | | | | | | | | I'd have preferred to use QArrayDataPointer<ushort> for QString, but that option wasn't the best one. QArrayDataPointer try to do some operations using QArrayDataOps and that would expand to unnecessary code. What's more, the existing code expected to be able to modify and access the d pointer. Instead, this commit introduces QStringPrivate (named differently from QStringData to catch potential users), which contains the three members. This POD class is also used in QJsonValue to store the "inlined" QString. QHashedString in qtdeclarative will need a similar solution. Change-Id: I33f072158e6e2cd031d4d2ffc81f4a8dbaf4e616 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Inline the size and begin pointer in QVectorThiago Macieira2019-12-087-642/+433
| | | | | | | | | | | Add QGenericArray to simplify operations. This class can be shared by other tool classes. If there is nothing else to share it, we can move the code onto qvector.h. The one candidate is QList. All tests pass and valgrind is good. Change-Id: Ieaa80709caf5f50520aa97312ab726396f5475eb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix potential out of bounds write in the JSON writerLars Knoll2019-12-081-1/+2
| | | | | | | | | If a small string (1 or 2 chars) would require a JSON escape sequence when writing out the string, the code could write out of bounds of the byte array. Fix that by always allocating at least 16 bytes of space. Change-Id: I4d023e7ed837b25b0a5dcf6cfaaf94aa55695b9f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of the operator[](uint) overloadsLars Knoll2019-12-084-35/+0
| | | | | | | | Those make no sense and where probably only there to workaround bugs in some old compilers. Change-Id: I5b196cc5306ac1c6307257b70179278d82d383c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Various cleanups in qarraydataops and qarraydatapointerThiago Macieira2019-12-082-87/+304
| | | | | | | | Various cleanups. Add copyAppend overload for forward iterators and a insert overload for inserting n elements. Change-Id: Ic41cd20818b8307e957948d04ef6379368defa55 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Start moving QArrayData's size and data pointer to the main classThiago Macieira2019-12-087-117/+194
| | | | | | | | | | | | | This requires that the allocation functions return two pointers: the d pointer and the pointer to the actual data. Ported QArrayDataPointer & SimpleVector to the inlined size & data. For now, the size and offset members are not yet removed from QArrayData, to let QVector, QByteArray and QString compile unmodified. Change-Id: I8489300976723d75b8fd5831427b1e2bba486196 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add QArrayDataOps::moveAppend()Thiago Macieira2019-12-081-0/+56
| | | | | | | Same as copyAppend() but calls the move constructor Change-Id: I7de033f80b0e4431b7f1ffff13f9399e39b5fee4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add the QArrayDataOps::parameter_type typedefThiago Macieira2019-12-081-2/+6
| | | | | | | | | It's a typedef meant to replace the "const T &" parameters (hence the name). But it's actually just a T for POD types, so we don't create references to them. Change-Id: I10c746d5e852c957ec84319712597478c4dc872c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Stop using the reference counter to store data stateThiago Macieira2019-12-086-21/+29
| | | | | | | | | | | Instead of using the reference count to store whether the data is sharable and whether the header is immutable, move the settings to the flags member. This allows us to save one comparison per deref() or needsDetach(). It also allows for the possibility of mutable data pointed to by a static header. Change-Id: Ie678a2ff2bb9bce73497cb6138b431c465b0f3bb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add reference-count manipulation functions to QArrayData and hide refThiago Macieira2019-12-0812-63/+83
| | | | | | | | The next change will stop using some values in the reference counter as settings from the data. Change-Id: I94df1fe643896373fac2f000fff55bc7708fc807 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Introduce the Mutable flag and move QArrayDataPointer::needsDetachThiago Macieira2019-12-088-37/+48
| | | | | | | | | | | | | | | | | | The Mutable flag now contains the information on whether the data this QArrayData points to is mutable. This decouples the mutability / immutability setting from the allocation and from the type of data, opening the way for mutable raw or foreign data. There are still plenty of places in the source code that check the size of the allocation when it actually wants d->isMutable(). Fixing this will require reviewing all the code, so is left for later. The needsDetach() function is moved to QArrayData and de-constified. It returns true when a reallocation is necessary if the data is to be modified. Change-Id: I17e2bc5a3f6ef1f3eba8a205acd9852b95524f57 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make the AllocOptions flag to QVector::reallocData mandatoryThiago Macieira2019-12-081-8/+12
| | | | | | | This forces us to calculate the reallocation flags properly. Change-Id: I3486b193ad6732df666fc9ddad96831c9fbe068c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix a use-after-free problem in QByteArray::replaceLars Knoll2019-12-071-3/+3
| | | | | | | | | | if the string pointed to by after is part of the QByteArray, we were trying to protect against a use-after-free by copying after. Unfortunately, it was not used later on in the code instead of the original after. Change-Id: I2f2263e4bb1855e802bba2fc08db34762c66887a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove unused private methodLars Knoll2019-12-071-102/+0
| | | | | Change-Id: I3502c3c0451e7829fff0159a5d0891df34d04fe7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Introduce flags to indicate the QArrayData typeThiago Macieira2019-12-077-58/+79
| | | | | | | | | | | | | | | | | These flags allow us to determine what type of data QArrayData is carrying. There are currently only two supported types: - raw data type: constructed via fromRawData or static data - allocated data type: regular data done via heap allocation The QArrayData object is usually allocated on the heap, unless its own reference count is -1 (indicating static const QArrayData). Such object should have a type of RawDataType, since we can't call free(). Add GrowsBackward for completeness as well as the StaticDataFlags default for static data. Change-Id: Icc915a468a2acf2eae91a94e82451f852d382c92 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Introduce QArrayData::allocatedCapacity() and use it instead of d->allocThiago Macieira2019-12-078-68/+79
| | | | | | | | | | | | | | | | In almost all cases, use d->allocatedCapacity() or d->constAllocatedCapacity() instead of d->alloc, since they do the same thing (right now). In the future, the functions will be changed. There is a separate const version because most const code should not need to know the allocation size -- only mutating code should need to know that There are a few cases where d->alloc was replaced with a better alternative, like d->size. The one case that remains in the code will be replaced by a different test when it's available. Change-Id: I48135469db4caf150f82df93fff42d2309b23719 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace QArrayData::capacityReserved with a full flags fieldThiago Macieira2019-12-077-36/+19
| | | | | | | | | | | | | Instead of stealing one bit from the alloc field, let's use a full 32-bit for the flags. The first flag to be in the field is the CapacityReserved (even though the allocate() function will store some others there, not relevant for now). This is done in preparation for the need for more flags necessary anyway. Change-Id: I4c997d14743495e0d4558a6fb0a6042eb3d4975d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rename QArrayData::AllocateOptions enum and update some flagsThiago Macieira2019-12-077-39/+41
| | | | | | | | | | | | | | | | Rename to QArrayData::ArrayOptions in preparation for these flags being in the array itself, instead of used just for allocating new ones. For that reason, rename QArrayData::Default to DefaultAllocationFlags. And introduce QArray::DefaultRawFlags to mean the flags needed for creating a raw (static) QArrayData. Also rename QArrayData::Grow to GrowsForward, so we may add GrowsBackward in the future. Change-Id: I536d9b34124f775d53cf810f62d6b0eaada8daef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add QArrayData::sharedNullData()Thiago Macieira2019-12-071-0/+12
| | | | | | | | | | | | | Just to simplify a few operations, like detecting when a QChar* or char* coming from a QString or QByteArray, respectively, were null data. While you're not supposed to dereference the pointer returned by QVector::data() unless you know that the array is non-empty, that is permitted for QString and QByteArray. That is, QString().constData() must return a valid pointer to a null QChar. Change-Id: I80b4b62f203dc841e5c99c20c51d92ca576e4bfe Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Tell the compiler that QArrayData::allocate allocates memoryThiago Macieira2019-12-071-1/+5
| | | | | | | | | | ICC, GCC and Clang support __attribute__((malloc)) that tells them that the function returns newly allocated memory which doesn't alias anything else. Though technically we may return memory that has already been used (the shared null or such), that should not be a problem. Change-Id: Id3d5c7bf4d4c45069621ffff13f7f81f8b08ea3d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Tell the compiler that QArrayData returns aligned pointersThiago Macieira2019-12-071-4/+11
| | | | | | | | | | | GCC 4.9 and later support the __attribute__((alloc_align)) attributes that indicate the alignment of the data. To make it work on GCC since 4.7 and Clang as of 3.6, we instead use __builtin_assume_aligned(). I don't know which version of ICC first implemented this, but ICC 15 does and it also reports itself as GCC 4.9. Change-Id: I58bd914b9bdd0ed3349ba56fa78220ab06114852 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use Q_NAMESPACE for the Qt namespace, and remove the old moc hack to support itOlivier Goffart2019-12-066-312/+325
| | | | | | | | | | Since I can't #include qobjectdefs from qnamespace because of circular dependency, move the Qt macro in the qtmetamacros.h header. Deprecate QObject::staticQtMetaObject since now one can just use Qt::staticMetaObject Change-Id: I11982aa17c2afa2067486b113f8052672f3695eb Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make setModel() virtualAndrew Patterson2019-12-061-1/+1
| | | | | | | Task-number: QTBUG-74255 Change-Id: I354e547dd75019a964f4b8e4f087a72e610816f3 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-12-0511-57/+51
|\ | | | | | | Change-Id: I9d63a4c4b229a831b5369f6ec74ac97ba6d6556a
| * Document that toggleViewAction can't be used to toggle the dock widgetVolker Hilsheimer2019-12-041-2/+5
| | | | | | | | | | | | | | | | | | | | | | ...from code. This is by design; the action is updated when the dock widget changes, not the other way around (which would easily result in infinite loops). Change-Id: I9e71784d239a9cbb6c8efaeaa3e3adc6dc590f65 Fixes: QTBUG-80022 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
| * Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-12-0410-55/+46
| |\ | | | | | | | | | Change-Id: Ia70e81943ef097941339f9ef9ace28592a2eb740
| | * QMacTimeZonePrivate: use .member rather than [- member] notationEdward Welbourne2019-12-031-12/+11
| | | | | | | | | | | | | | | | | | | | | | | | Apparently this is our preferred style for Objective C member references. Change-Id: I8b2bbaabadbea2cfa74f209372e77cee79e3c895 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
| | * Make QMacTimeZonePrivate default constructor more efficientEdward Welbourne2019-12-031-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Inline systemTimeZoneId() in it to save the need for init(). We thus save the lookup by name for a time-zone object, when that object is what we took the name from anyway. Do some minor tidy-up in the other constructors and add an assert to systemTimeZoneId() to match the new one in the default constructor. Change-Id: Ib70acf31bdb4a4fa1306eebd1fd5f00ad6b89bcc Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
| | * Fix assert in QTextDocument CSS parser on "border-width: 1pt"David Faure2019-12-033-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code was assuming that if the parsing of the value worked, then it must be a list of 4 variants. But in this case it's just a single length. This came from <td> using 4 values for border-width while other elements use a single value. But the storage is shared. So the fix is to use 4 values everywhere. When reading 4 and there's only one, it gets duplicated, so the caller can just use the first one in that case. Task-number: QTBUG-80496 Change-Id: I682244b6e3781c4d673a62d5e6511dac263c58e8 Reviewed-by: Nils Jeisecke <nils.jeisecke@saltation.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
| | * QMacStyle: correct placement of edit field in comboboxVolker Hilsheimer2019-12-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | The dark edit field is now centered within the frame around it, with a thin border on all sides, including between input field and button. Change-Id: I27e853289e9048c21fdc81e45fadacba9665b49e Fixes: QTBUG-63454 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
| | * Prevent emscripten_webgl_destroy_context from removing event handlersMorten Johan Sørvig2019-12-031-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The JavaScript implementation of that function has the following code: if (typeof JSEvents === 'object') JSEvents.removeAllHandlersOnTarget(GL.contexts[contextHandle].GLctx.canvas); // Release all // JS event handlers on the DOM element that the GL context is associated with since the context // is now deleted. This breaks mouse/keyboard events, etc. Disable this logic by temporarily setting the JSEvents object to undefined, for the duration of the emscripten_webgl_destroy_context call. Fixes: QTBUG-74850 Change-Id: Ied3177b0ca6e63e8ea07143bf7d6a850b0bce35a Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
| | * Fix depth in renderText()Laszlo Agocs2019-12-031-1/+1
| | | | | | | | | | | | | | | | | | Fixes: QTBUG-31156 Change-Id: I3cbb3f9c5dfbcb182dbe283b0bf0f05a031970a5 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
| | * Relocate a comment that had become detached from its codeEdward Welbourne2019-12-031-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | Two little tool functions had come between it and the function it actually describes. Change-Id: Ib49d1623833275ea79c7916fece29aed9503aa40 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
| | * Fix serializing QUuid with QDataStream with Qt 4 stream versionsJoni Poikelin2019-12-031-2/+2
| | | | | | | | | | | | | | | | | | | | | Fixes: QTBUG-76103 Change-Id: Iac92c33539940f5f67d014db5240c6dc14bfb772 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
| | * rhi: Remove unused compat functionsLaszlo Agocs2019-12-031-20/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | These were kept around to keep Qt Quick compiling, but the migration there has been done a long time ago. Remove these leftovers now. Change-Id: Ibd47381b410b11b5475a85c7ed3cb05c22f7adbb Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* | | Remove QVariant::operator< and related operatorOlivier Goffart2019-12-042-128/+0
| | | | | | | | | | | | | | | | | | | | | The operator does not have a total order Change-Id: Ifd263c3495aca08c8ccceb9949596c308a76a6c1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-12-0447-255/+519
|\| | | | | | | | | | | Change-Id: I4134c0c6b6c9911950f58b3b5c86e789d28a185b
| * | QMdiArea: on macOS using tabs, render document icons next to the textVolker Hilsheimer2019-12-033-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is closer to what titles of documents look like in macOS apps, even though MDI is not a well-defined concept on this platform. To implement this, the QCommonStylePrivate::tabLayout method had to be made virtual, as it is called by the QCommonStyle class. It was already reimplemented in QMacStylePrivate, but didn't get called in all cases. Now that it is called as an override, adjust the icon placement to include the padding so that we get identical results to 5.13 for normal tab widgets. Change-Id: I7a63f6d76891146ca713259096a7737a86584d81 Fixes: QTBUG-63445 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
| * | CMake: Use lower-case macro/function namesKai Koehne2019-12-033-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CMake is case-insensitive for macro and function names. Still, it is "strongly recommended to stay with the case chosen in the function definition." So let's make the function and macro definition lower-case, like we also recommend in the documentation. Change-Id: I1f64b18716f034cb696d2e19a2b380aaadd6cd07 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
| * | CMake: Remove conditions for CMake < 3.1Kai Koehne2019-12-031-45/+40
| | | | | | | | | | | | | | | | | | | | | We don't support anything older than CMake 3.1 Change-Id: I5425a2fddfe5416a6a127a81da669fb37ac4d81c Reviewed-by: Liang Qi <liang.qi@qt.io>
| * | Merge remote-tracking branch 'origin/5.14' into 5.15Ulf Hermann2019-12-0335-180/+240
| |\| | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/serialization/qcborvalue.cpp Change-Id: I675a3029955c96e81a33ed9d98b72b55b6784b52
| | * iOS: Guard against request for textInputView without focus windowTor Arne Vestbø2019-12-031-2/+6
| | | | | | | | | | | | | | | | | | Change-Id: I7b8df07fffef1cc948f6720685234540a20ccc81 Fixes: QTBUG-79316 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
| | * macOS: Don't tweak NSApp presentationOptions on startupTor Arne Vestbø2019-12-031-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AppKit will initialize NSScreens nowadays, so we don't need to manually trigger it. Task-number: QTBUG-80193 Change-Id: Ic0251a1b978b9d4ff53f20e67902787cf529fa87 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
| | * RHI/Vulkan: Fix buildFriedemann Kleint2019-12-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add missing include, fixing: rhi\qrhivulkan.cpp(6273): error C2027: use of undefined type 'QWindow' Amends 0f812db558df072a411ade3305b796d54bccd996. Change-Id: Ide61b713e958877f18a45a89b36a4e1330f75821 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
| | * rhi: vulkan: Remove unused includeLaszlo Agocs2019-11-291-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | QVulkanWindow support has long been removed from the Vulkan backend. The include is a leftover from those times. Change-Id: Ie68ac3611b24310f2b6111a72dd0679adafdc74d Reviewed-by: Johan Helsing <johan.helsing@qt.io>
| | * macOS Accessibility: Fix role for comboboxesPeter Varga2019-11-291-1/+1
| | | | | | | | | | | | | | | | | | | | | Otherwise combobox with editable text field won't work. Change-Id: I135c3a63cf8fba66d724e140a5a63828853e154e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
| | * QTreeView: Reset the pressed index if the decoration was pressed onAndy Shaw2019-11-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to reset the pressed index when the decoration was pressed on otherwise if the mouse ends up over an already selected item that was previously clicked on. This prevents it from thinking that the mouse has been released on this item right after pressing on it. Fixes: QTBUG-59067 Change-Id: Iab372ae20db3682ab0812661f86533079ba4083c Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
| | * wasm: Disable TextureSwizzleFredrik Orderud2019-11-281-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The WebGL 2.0 specification explicitly does not support texture swizzles. Therefore, disabling it when targeting WASM. This fixes "WebGL: INVALID_ENUM: texParameter: invalid parameter name" when running in Chrome or Firefox. Change-Id: Ic7e22e0f623095245274924095cb63fd0ff7e8c2 Reference: https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.19 Fixes: QTBUG-80287 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
| | * Silence intel compiler warning about float comparisonOlivier Goffart2019-11-289-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Add the equivalent intel warning macro in public header where there was already the macro for -Wfloat-equal Change-Id: I8f20400f0b95c8f3857fa7a0a33464c8c34d5c0e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>