GTK syle: initialize all members of GdkColor

Coverity rightfully complains that we're copying a struct with an
uninitialized member, triggering undefined behavior.

Change-Id: I7635b859eb11e5eb9b825df8e23b453116059892
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
XCB: fix a memory leak

An early return caused a leak of a new'd allocated object.

Change-Id: I9fbc37238dd49066d24363a2e8ee8bf35b155301
Reviewed-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
XCB: fix a possible array overflow leading to a crash

The QClipboard::Mode returned from modeForAtom should be checked
everywhere because values greater than Selection (i.e. FindBuffer)
aren't supported on X and should mean error conditions.

The lack of such a check did an out-of-bounds array access, which
could lead to a crash.

Change-Id: I70f70b5f713ab2f892e258d4df2f7afeb434f0c1
Reviewed-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Gatis Paeglis <gatis.paeglis@digia.com>
QRegion: fix a memory leak

An early return in case of errors leaked memory tracked in a variable
in scope.

Change-Id: I68cd77890608caff54df7476d38850e5541ce76e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
QObject: fix a memory leak in moveToThread

For some reason it seems to be supported to call moveToThread(0).
That call will allocate a new QThreadData for the object. However,
if we then detect that we're calling moveToThread from a thread
which is not the one the QObject has affinity with,
we error out leaking that QThreadData object.

Change-Id: I0fe6625a2a9887535e457f3897b514d2a03d1480
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
QTransform: initialize the d member

Although never used, the d member triggers all sorts of warnings
when copying a QTransform around because it's technically
undefined behavior (reading from an uninitialized variable).

Change-Id: If06b6bea6f0ec0623c38ba330d46958b373cdc65
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Prevent a Coverity warning about a dangerous code path

Coverity warns that we may access the gray array without initializing
it. The array is initialized if d (the source image depth) is 8.

However, when doing ordered dithering, we don't check that depth
any more and just use the array. There are instead checks in place
for the other dither modes; the one for ordered has been commented
out before public history.

So, for the love of kittens, put the check back.

Change-Id: I1cc5ced8edbb626777e54e9f4e58f152c6b28ddc
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
QFile: fix undefined behavior when closing a buffered file

C11 §7.21.3.4 [Files] says that

    The value of a pointer to a FILE object is indeterminate
    after the associated file is closed

POSIX.1-2013 reinforces by saying that

    After the call to fclose(), any use of stream results
    in undefined behavior.

This means we can't call fclose() again on a FILE *,
even if fclose() returned EOF and set errno to EINTR.

Change-Id: I282f4ff926e3c134729defa290c80d42431e97ce
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Refactor some loops over EINTR

QT_CLOSE is #defined to be qt_safe_close which already performs
the EINTR loop. So there's no need of doing other loops
(either by hand or by the EINTR_LOOP macro).

Change-Id: Icca256124def5ab5d79c2ba101c6f889c85d19da
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Document that default-constructed QFuture are canceled

Task-number: QTBUG-40680
Change-Id: Idee9ff75c89c8349be779b90ee9c34a899d92c0c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Reviewed-by: Martin Smith <martin.smith@digia.com>
QSettings: Don't chop off trailing tabs that were actually part of a value.

This was done wrong when using the ini format.

Task-number:  QTBUG-22461
Change-Id: Ib9390460bce6138659cceac7e3cd25339ba5e9bb
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Cocoa: Properly remove content view from its superview in setNSWindow()

-[NSWindow setContentView:] doesn't make assupmtions about where that
view comes from, and just attaches it to the window. We need to make
sure we detach it from its previous window by calling -[NSView
removeFromSuperview], or the previous NSWindow may keep references to
the view. This can be an  issue if the view is deleted right after.

Task-number: QTBUG-39628
Change-Id: I152dedcb64ac044d8ca290c9996b388809e2477b
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Fix compilation on OS X with macx-clang-32

Task-number: QTBUG-27335
Change-Id: I1703aee2d90e02b1a6ed386715bebddf6dedb9f5
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>