Commit Graph

39849 Commits

Author SHA1 Message Date
Qt Forward Merge Bot
e56d3b03ed Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	src/corelib/tools/qlocale_data_p.h
        (Regenerated by running the scripts in util/local_database/)
	src/gui/opengl/qopengltextureuploader.cpp

Done-With: Edward Welbourne <edward.welbourne@qt.io>
Done-With: Allan Sandfeld Jensen <allan.jensen@qt.io>
Change-Id: I12df7f066ed0a25eb109f61c4b8d8dea63b683e2
2019-05-09 13:06:11 +00:00
Laszlo Agocs
64a2dc3962 Add missing backslash to kmsconvenience.pro
Change-Id: I3519447af657bdbb7304aca272de416104dca0f9
Fixes: QTBUG-75730
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-05-09 12:55:06 +00:00
Joerg Bornemann
a12b6e7bf6 Fix CMake file generation for debug libs on macOS
CMAKE_QT_STEM already contains the _debug suffix.
Do not add it again.

This amends commit bb8a3dfc.

Fixes: QTBUG-75520
Change-Id: I6c311f0913ea83fcf299a21a0ee1f28c3861371f
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2019-05-09 07:50:32 +00:00
Edward Welbourne
17c44479aa Update CLDR version in attribution
This is a follow-up to 43abe86e.

Change-Id: I2442304c9c79bcb1932fb173b8d993a242d79f4b
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2019-05-09 07:40:06 +00:00
Eirik Aavitsland
3d8ed3ba96 Fix: style sheet styling of background of triangular QTabWidget tabs
The triangular tab shape is not reproducible with setting style border
options, so it should be painted with the usual code path, also when a
custom background has been set.

Fixes: QTBUG-72096
Change-Id: I7bc1c0579386b8ea7266ce6456534c2519d9addf
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2019-05-09 06:47:30 +00:00
Friedemann Kleint
fa890c4686 Windows QPA: Improve debug messages
Include screen and MINMAXINFO values in the message about not being able to
set the geometry.

Suppress output of some window finding functions unless verbose.

Change-Id: Iaaae59ecb302438b3444735067d018c77d2af162
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2019-05-09 06:13:27 +00:00
Martin Storsjö
827b7afba7 ANGLE: Backport fix for compilation on mingw/64bit with clang
This backports the following upstream fix from angle:
63cc351fba

Change-Id: Id80dba62c69f3505eb836f758367b4bf054b1fd5
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2019-05-08 21:21:41 +00:00
Sergio Martins
9444416a46 Define Q_OS_WINDOWS, make it an alias to Q_OS_WIN
As seen in several occasions, both in user code and in Qt proper,
people make these mistakes. What makes it harder to spot is that it doesn't
look like a typo, and feels natural (natural as Q_OS_LINUX instead of Q_OS_LIN feels).

There's been a P1 in qtdeclarative/ and currently there's a Q_OS_WINDOWS usage
in qtwebengine.

This is a recurring problem, no matter how much people test and review
these errors will happen, so the alias is justified.

Change-Id: If6943b52e17f0c8b238c36bb1f7834802123f12a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-05-08 17:22:01 +00:00
Konstantin Shegunov
c6bee8e4b2 Fix integer overflows in QDeadlineTimer
If the deadline is far in the future, the conversions to nanoseconds
or internal arithmetic may overflow and give an invalid object, thus
the deadline may end up in the past. Added a test to the testlib
selftest for sleep.

[ChangeLog][QtCore][QDeadlineTimer] Fixed integer overflows
leading to immediate timeouts.

Task-number: QTBUG-69750
Change-Id: I9814eccdf9f9b3add9ca66ec3e27e10cd5ad54a8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-05-08 17:19:44 +00:00
Joerg Bornemann
2a79af6b5c Doc: Document the c++2a CONFIG value
Change-Id: Ia4d84ac141b6fb27b244dfb8272b8039e337a9e4
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2019-05-08 13:42:28 +00:00
Mårten Nordheim
8adcfa8b24 WinRT: Fix crash in native socket engine during close
Make sure "this" still exists when we're done sending the
readNotification.

The crash manifested itself when connecting to certain websites as they
would reply with status 403, then close the connection. On our end we
would then handle this "remote host closed" followed by handling the
data we received. The http code handles the data successfully and sees
we are done and there is nothing more to do, so it closes the
connection. Which leads to closing QAbstractSocket, which closes
native socket again and then deletes it.

Fixes: QTBUG-75620
Change-Id: I233c67f359aa8234f1a2c4ea9463108b08c9165f
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2019-05-08 13:26:03 +00:00
Friedemann Kleint
a1516c3b93 Windows: Add debug output for message WM_DPICHANGED
Add it to the name lookup and add verbose formatting
to the debug operator.

Task-number: QTBUG-73014
Change-Id: I31ee31bc28ef563fdbc0adedcea03546ced5faad
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2019-05-08 13:25:59 +00:00
Christian Ehrlicher
69f6cab0af Doc: replace even more null/0/nullptr with \nullptr macro
Try to replace all wordings like '.. to 0' with '.. to \nullptr'. Also
checked for 'null pointer' and similar.

Change-Id: I73341f59ba51e0798e816a8b1a532c7c7374b74a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2019-05-08 12:48:32 +00:00
Dmitry Kazakov
a5725561da Fetch stylus button remapping from WinTab driver
The user can remap the stylus buttons using tablet driver settings.
This information is available to the application via CSR_SYSBTNMAP
WinTab feature. We should fetch this information every time the
stylus gets into proximity, because the user can change these settings
on the fly.

Change-Id: Idc839905c3485179d782814f78fa862fd4a99127
Reviewed-by: Andre de la Rocha <andre.rocha@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2019-05-08 12:42:32 +00:00
Eirik Aavitsland
95fa35fc72 Fix possible endless loop when stroking curves
The bezier shifting algorithm compared coordinates exactly, and so
could end up in an endless loop when values were at the edge of the
number resolution. Fix by using fuzzy comparison instead.

Fixes: QTBUG-75522
Change-Id: I61346edbd87389f66965a906ac337fc1f5300e5c
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2019-05-08 12:34:19 +00:00
Tor Arne Vestbø
19d13f8b2d macOS: Deliver and handle screen change unconditionally
We can't rely on the previous screen and current screen to accurately
reflect whether or not the window has been moved from one screen to
another, or if the window just stayed on the same screen but the screen
was reconfigured by macOS. The reasons for this are many-fold, but
include factors such as Qt using the screen of the top level window
to resolve the screen of the child windows, and AppKit delivering
screen change events in an order that makes things harder to track.

The result is that we need to always send screen change events, for
all windows, including child windows, and we also need to restart the
display link by re-requesting an update request if needed, so that
child windows that are running animations will continue to animate
on the new screen.

Change-Id: I0b87849c41323e92c08f5115842be067fa8f8490
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2019-05-08 12:24:19 +00:00
Tor Arne Vestbø
9054950b7c macOS: Always respond to cursorUpdate by applying custom cursor if set
Calling super will push the default arrow cursor, so we should only
do that if our own cursor has been unset.

Change-Id: I71d8934e7eab2b15e150730e2282e7063ada305a
Fixes: QTBUG-75552
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2019-05-08 12:23:47 +00:00
Vova Mshanetskiy
8ea3300a08 QAndroidInputContext: Fix getTextBefore/AfterCursor() in mid. of preedit
getTextBeforeCursor() and getTextAfterCursor() were not properly
handling the case when the cursor is in the middle of preedit string
(just as TODO comments inside these functions were saying). This was
causing problems with Gboard when the user focuses a text editor by
tapping in the middle of a word.

Fixes: QTBUG-58063
Change-Id: I4a580a74d79965816557bfb342337975348d1c45
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2019-05-08 14:52:31 +03:00
Vova Mshanetskiy
d0741f4267 QAndroidInputContext: Fix most "Input method out of sync" warnings
According to Android docs start == end in a call to setComposingRegion()
means finish composing. But this case was not being handled properly:
m_composingText was being assigned an empty string, but
m_composingTextStart was being assigned the value of start, which is
never -1.

There is one other possible cause of "Input method out of sync"
warnings, but it is tightly coupled with another bug, so it will be
fixed by a separate commit.

Change-Id: Ie475df84f330453ce4fc623e8b631b435d7d0042
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2019-05-13 14:52:47 +03:00
Frederik Gladhorn
73ca3dbf49 Windows Accessibility: window should be focusable
Fixes: QTBUG-75001
Change-Id: Iac67b9bba70317f8d28ac2d355d584417d1ffebf
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2019-05-21 09:26:10 +00:00
Massimiliano Gubinelli
a4bd4565cc Emit QMenu::aboutToShow() before platform specific code
Send the aboutToShow() signal to QMenu before synchronising the
widgets for the menu items. This fixes a bug where if new
QWidgetActions are added to the menu from a slot triggered by the menu's
aboutToShow() signal, then such new actions do not shows up correctly on
Mac. Other platforms are not affected by the change.

Fixes: QTBUG-75826
Change-Id: Ic245d3fbc7ddde6944cca6cdb8e8951380c846ec
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2019-05-16 12:33:45 +00:00
Laszlo Agocs
1f04b09446 eglfs/openwfd: do not purge QSurfaceFormat fields
Change-Id: I6c1d83624838362f6a3daa6c2b309fb518a25d4b
Fixes: QTBUG-75673
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-05-08 15:51:19 +02:00
Frederik Gladhorn
516ab2a595 Windows Accessibility: Add UI Automation Window provider
This allows closing, minimizing and maximizing the window.

Fixes: QTBUG-74999
Change-Id: I8b3ad806a1767586c8cf7e5a1848fc0e525621cd
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2019-05-20 13:21:02 +00:00
Tor Arne Vestbø
5e743adc20 Don't try to retranslate strings for native color dialogs
If the native color dialog is in use we haven't created any of the
widgets and will crash when trying to update them.

Change-Id: I6c43cc47359110c3b9db7cacb62581446cc6f7a3
Fixes: QTBUG-75858
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2019-05-16 14:51:42 +02:00
Tor Arne Vestbø
387691498a macOS: Generate UTF-16 clipboard content without BOM
Qt on macOS has traditionally not included a BOM in the UTF-16 data,
but due to iOS requiring it it was changed in 4e196159. This had the
unfortunate side effect of breaking macOS applications that were not
prepared for the BOM, even if the public.utf16-plain-text UTI can have
an optional BOM, most notably Microsoft Excel. It also resulted in the
public.utf8-plain-text having a BOM, as that's automatically generated
by macOS based on the UTF-16 content we give it. Having a BOM in UTF-8
is technically fine, but not required, and recommended against.

The fact that iOS requires a BOM is a bit dubious, and most likely a
result of applications or system frameworks decoding the data using
NSUTF16StringEncoding, which assumes big-ending byte ordering if there
is no BOM, as opposed to public.utf16-plain-text which assumes native
byte ordering. Since we can't fix iOS our best bet is to include a BOM.

For macOS though, we revert back to the old behavior of not including
a BOM, since that seems to surprise macOS frameworks and applications
the least, even if having a BOM in public.utf16-plain-text should be
fully supported.

Longer term we should look at what kind of UTIs we generate. Most apps
on macOS do not generate public.utf16-plain-text, but instead generate
public.utf16-external-plain-text, which differs from the former in that
it assumes big-endian byte-ordering when there's no BOM. On iOS apps
seem to generate public.utf8-plain-text, and do not generate any UTF-16
UTIs. Moving Qt over to these UTIs would fix the problem as well, but
is a larger change that needs more research.

Change-Id: I4769c8b7d09daef7e3012e99cacc3237f7b0fc1a
Fixes: QTBUG-61562
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2019-05-20 13:31:34 +00:00
Friedemann Kleint
299675e665 tst_QMdiSubWindow::setSystemMenu(): Pass in High DPI/multi-screen setups
The window tends to grow to span screens in multi-screen setups; force it to
be on the primary screen by showing it maximized in that case.

Change-Id: I984ba7a4cd4abd1f862c59c8dca0e2275f44c724
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-05-20 10:51:46 +02:00
Friedemann Kleint
18b336990f Brush up tst_QMdiSubWindow
- Use nullptr
- Use range-based for
- Use correct static invocation
- Set a title on shown windows to make it possible to identify
  slow tests
- Fix the class declarations, use override, member initializations
- Use Qt 5 connection syntax where possible
- Ensure top level widget list is empty after each test, delete left-over
  menu bars and disable menu animations

Change-Id: Ieeb943ea669cd139f1835088b816802e777a9676
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2019-05-20 10:51:46 +02:00
Morten Johan Sørvig
4c9758f1af QHighDpi: Simplify top-level window handling code
Introduce origin(QWindow *), which returns the point
around which coordinates should be scaled: the screen
origin for top-level windows, and (0, 0) for child windows.

The code paths for top-level and child windows can
then be combined.

Change-Id: I6b9cdbd9e7c2d9406e9137e325c4eb5c79e3ac9a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2019-05-14 19:31:16 +02:00
Andre de la Rocha
8be17f1fd5 Windows QPA: Fix QWheelEvent::buttons() after click on title bar
When the left or right mouse buttons are pressed over the window title
bar a WM_NCLBUTTONDOWN/WM_NCRBUTTONDOWN message is received. But when the
button is released, no corresponding UP message is received, but only
a WM_NCMOUSEMOVE or WM_MOUSEMOVE. This makes the internal mouse button
state stored in QGuiApplication get out of sync with the actual state,
resulting in an incorrect button state being used in QWheelEvent.
This patch detects the button release condition and generates the missing
release event.

Change-Id: I6dd9f8580bd6ba772522574f9a08298e49c43e61
Fixes: QTBUG-75678
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2019-05-18 03:15:06 +00:00
Oliver Wolff
a96a33d993 qtmain_winrt: Avoid nullptrs in str*cmp which cause crashes
When bringing an application back to foreground, args may contain NULL.
These nullptrs should not cause application crashes.

Fixes: QTBUG-75843
Change-Id: I642e3c359216e7706bcb13508399999a51a4fc2d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2019-05-17 09:26:33 +00:00
Kai Koehne
b7aea2bcd3 Qt Widgets: Document CMake macros
Task-number: QTBUG-72159
Change-Id: Ib9fdf852583964cf07c4d26e0a6c74f0058e29f1
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2019-05-16 13:24:25 +00:00
Kai Koehne
57b4f6d56e Qt Core: Document CMake macros
Document public macros in Qt5CoreMacros.cmake. This will replace
the list in the current CMake Manual.

Task-number: QTBUG-72159
Change-Id: I377412fe0c1d0a9b232162bbab88ac830d2cac80
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2019-05-16 13:24:08 +00:00
Friedemann Kleint
b88be04519 Make tst_qwidget_window pass on High-DPI screens (Windows)
Use a fuzz check (cf 6309062722) and a minimum
size similar to tst_qwidget to make the test pass on large monitors with or
without active scaling.

Change-Id: I5a9e28e38e1d007057894c349c94f0e6fe12009c
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2019-05-16 12:56:33 +00:00
Friedemann Kleint
e72e5aa83a Brush up tst_QWidget
- Use nullptr
- Fix C-style casts
- Fix redundant bool expressions
- Fix else after return
- Remove unnecessary casts to int from registered enums
- Fix most signedness-related warnings
- Use range-based for
- Use correct static invocation
- Set a title on shown windows to make it possible to identify
  slow tests
- Fix the class declarations, use override, member initializations
- Use Qt 5 connection syntax
- Remove unused variables
- Streamline code in some cases

Change-Id: I1350b382b0b7d0f3198039fdc78892cfa1dd498d
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2019-05-16 06:24:27 +00:00
Friedemann Kleint
909f793de1 Brush up tst_QWindow
- Use nullptr
- Fix C-style casts
- Remove unnecessary casts to int from registered enums
- Fix most signedness-related warnings
- Use range-based for
- Use correct static invocation
- Set a title on shown windows to make it possible to identify
  slow tests
- Fix the class declarations, use override, member initializations
- Streamline code in some cases

Change-Id: I4c9b99126cff02136def0e03accdf1129fe6d72b
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-05-15 19:57:06 +00:00
Friedemann Kleint
ef3b585ddf Brush up tst_QApplication
- Use nullptr
- Fix C-style casts
- Use range-based for
- Use correct static invocation
- Set a title on shown windows to make it possible to identify
  slow tests
- Fix the class declarations, use override, member initializations
- Use Qt 5 connection syntax; use lambdas where applicable
  to remove helper slots
- Streamline code in some cases
- Replace helper function to convert touch points by the one in
  QWindowSystemInterfacePrivate
- Use a logging category for the debug outpt, silencing some output

Change-Id: Ia46c7ad7c08f3afc8e5869ea99b66e406de97781
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-05-15 19:56:50 +00:00
Friedemann Kleint
07071a23c3 uic/Python: Fix tab stop/Z-Order and buddy handling
The code compared the attribute names of the properties against the
m_registeredWidgets hash which contained the qualified names
(self.widget) and thus reported errors without actually generating
anything.

Replace the m_registeredWidgets hash by a lookup of the attribute name
in the m_widgets hash and add a function widgetVariableName()
returning the qualified variable name for an attribute name and use
that for the checks.

Remove unused m_registeredActions hash and rename some variables to
make it clearer.

Task-number: PYSIDE-797
Change-Id: Id31d95c1141d21c51eb85bcd8f8fc63486eb36a5
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2019-05-08 10:19:22 +02:00
Friedemann Kleint
f48aa008e9 Windows QPA: Fix RTL window title bars
Add a platform option to the plugin (-platform windows:reverse) that
enables reverse mode. It sets WS_EX_LAYOUTRTL on RTL windows, forces normal
orientation on all HDCs created for the window, fixes
ClientToScreen()/ScreenToClient() accordingly and transforms mouse events.

[ChangeLog][Platform Specific Changes][Windows] It is now possible
to enable RTL mode by passing the option -platform windows:reverse.

Fixes: QTBUG-28463
Change-Id: I4d70818b2fd315d4e8d5627eab11ae912c6e77be
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2019-05-22 14:23:33 +02:00
Marc Mutz
26a0db4b44 Long live Qt::SplitBehavior!
The is a copy of the QString::SplitBehavior enum, but scoped
in the Qt namespace instead of inside QString, where it creates
problems using it elsewhere (QStringView, in particular).

Overload all QString{,Ref} functions taking QString::SplitBehavior
with Qt::SplitBehavior.

Make Qt::SplitBehavior a QFlags for easier future extensions (e.g.
a hint to use Boyer-Moore searching).

Added tests in QStringApiSymmetry.

[ChangeLog][QtCore] Added new Qt::SplitBehavior.

[ChangeLog][QtCore][QString/QStringRef] The split functions now
optionally take Qt::SplitBehavior.

Change-Id: I43a1f8d6b22f09af3709a0b4fb46fca61f9d1d1f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-05-21 17:50:26 +02:00
Marc Mutz
cea46aa362 QGestureManager: don't abuse a QMap for a set
The filterEvents() implementations used a QMap<GestureType, int> for
tracking whether a given type was already seen. The mapped_type was
completely unused.

Since the expected number of gesture types is very low, go directly to
QVarLengthArray, not QSet, as the reduced number of allocation will
dwarf the low overhead of O(N) search vs. O(1) for QSet or O(logN) for
QMap.

Change-Id: I98b6af69f11cca753e3c7c4fbb58e8f2e935e0d5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2019-05-21 09:15:15 +02:00
Marc Mutz
f7ae47ad07 QEvdevTouchScreenData: use a mutex locker instead of manual lock/unlock()
Extra difficulty: the lock is conditional. Not a problem with std::unique_lock, which is movable.

Change-Id: Ib5515838ccb10100d5aa31163ab7f171591c04c4
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2019-05-21 09:07:38 +02:00
Marc Mutz
9d0649d338 QStandardDirs: fix quadratic loop
Instead of a bad copy of remove_if, with quadratic complexity, use
an ok copy of copy_if, with linear complexity.

Port to QStringRef as a drive-by.

Change-Id: I47fde73b33305385835b0012f6d332e973470789
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2019-05-21 08:58:16 +02:00
Marc Mutz
94fbea2f30 QFileSystemWatcher: fix quadratic loop by porting away from QMutableListIterator
QMutableListIterator::remove() is linear, so called in a loop, the
loop potentially becomes quadratic.

Fix by porting to std::remove_if. In this case, since the old code
unconditionally detached, anyway, we use remove_copy_if to build a new
list. That's still more efficient than the old code, even if nothing
is removed. It also prepares the code for when Java-style iterators
will be deprecated.

Since the same code appears in two different functions, do an Extract
Method into a file-static function.

Lastly, restore NRVO for most compilers by returning the same object
from all return statements of the function.

Change-Id: I6909c6483d8f7acfd1bf381828f020038b04e431
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2019-05-21 08:57:49 +02:00
Marc Mutz
1065777a2a QtGui: get rid of the last Java-style iterator
Trivial.

Java-style iterators are going to be deprecated.

Change-Id: Ie94658be988cc095fb3b05d0d4ef6e7e3bf9a2af
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2019-05-21 08:57:42 +02:00
Marc Mutz
b03385f9cf QFileSystemWatcherEngines: port some Java-style iterators to ranged-for
Java-style iterators are scheduled to be deprecated.

The general pattern used in the patch is that instead of copying an
input list, then iterating over the copy with some calls to
it.remove() (which leads to quadratic-complexity loops), we simply
copy conditionally (a la remove_copy_if instead of remove_if).

To make clearer what's going on, rename the outgoing list to
'unhandled'.

To avoid having to touch too much of the loops' structure, which
sometimes is quite convoluted, use qScopeGuard to do the append to
'unhandled', unless the original code removed the element.

Saves a surprising almost 5KiB in text size on GCC 9.1 optimized
AMD64 Linux builds.

Change-Id: Ifd861de9aa48d66b420858606998dd08a8401e03
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2019-05-21 21:57:20 +02:00
Marc Mutz
4e026a2076 QQnxIntegration: replace a Java-style iterator with an STL-style loop
Java-style iterators are going to be deprecated.

Change-Id: Ia55070608d3826bd84ed5d56a593c1c4918a6063
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2019-05-21 08:56:28 +02:00
Marc Mutz
88978a5b03 Add private qt_make_unique as a drop-in for C++14 std::make_unique
The original is much more subtle, so don't try to be a 100%
replacement. Most users will be able to use std::make_unique these
days. This is just a minimal implementation to enable using the
functionality in the implementation of Qt libraries. In particular,
it does not attempt to deal with arrays.

It is therefore not proposed as public API. It is placed in a new
private header, since the only header in QtCore that already
includes <memory> is sharedpointer_impl.h, and that did not seem
to be a good place to add it. It is probably too much of a
compilation-time drain to add <memory> to qglobal.h...

Change-Id: Ie206ef7ae9beb36c63aef4ec46dbde6c73e0d9f5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-05-21 20:17:21 +00:00
Giuseppe D'Angelo
8845caa057 QCharRef/QByteRef: warn when triggering the resizing operator= behavior
The whole reason of QCharRef/QByteRef existence is to have a magic
operator=. This operator= delays the actual detach up to
the moment something is written into the Ref, thus avoiding
spurious detaches to the underlying string/byte array.

operator= has also an extra feature, it allows this code to
succeed:

  QString s("abc");
  s[10] = 'z';
  assert(s == "abc      z");

This last behavior is *extremely* surprising.

The problem with all of this is that this extra convenience is
outweighted by the massive pessimization in the codegen for
operator[]; by the maintenance burden (QChar APIs need to be
mirrored in QCharRef, etc.), and, for the automatic resize, by the
fact that it's an super-niche use case.

Cherry on top, std::basic_string does not do that, and no Qt or std
container does that. In other words: any other container-like class
exhibits UB for out of bounds access.

We can't just go and change behavior, though. This is something
coming all the way back from Qt 2 (maybe even Qt 1), which means we
can't deprecate it at short notice.

This patch simply adds a warning in debug builds in case the special
resizing behavior is triggered. While at it, removes some code
duplication in QByteRef.

[ChangeLog][QtCore][QString] The behavior of operator[] to allow
implicit resizing of the string has been deprecated, and will be
removed in a future version of Qt.

[ChangeLog][QtCore][QByteArray] The behavior of operator[] to allow
implicit detaching and resizing of the byte array has been
deprecated, and will be removed in a future version of Qt.

Change-Id: I3b5c5191167f12a606bcf6e513e6f304b220d675
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2019-05-19 14:24:52 +02:00
Giuseppe D'Angelo
c7167509ac QPainterPath: convert manual memory management to std::unique_ptr
And default the destructor, now that it's empty.

Change-Id: I868d4fa04f8e82bc35f2364073d07fa47659b89c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2019-05-14 20:07:49 +02:00
Giuseppe D'Angelo
0060ff6749 QPainterPathPrivate: code tidies
* Honor the RO3, doing copies of the members where it belongs
(and not in its subclass), and properly handling the refcounting
by disabling the copy assignment

* Clean up construction of QPainterPathData by using ctor-init-lists,
getting rid of a warning because the base class copy constructor
wasn't being called by the subclass' copy constructor.

* Mark everything for cleanup in Qt 6.

Change-Id: I143a322dc816e2e12b454a9e5ffe63f1a86009a5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-05-14 19:36:03 +02:00