Merge "Merge remote-tracking branch 'origin/5.3' into 5.4" into refs/staging/5.4

This commit is contained in:
Gabriel de Dietrich 2014-10-01 16:21:12 +02:00 committed by The Qt Project
commit 8ee9774e67
30 changed files with 221 additions and 67 deletions

View File

@ -160,15 +160,9 @@ QFSFileEngine::~QFSFileEngine()
Q_D(QFSFileEngine); Q_D(QFSFileEngine);
if (d->closeFileHandle) { if (d->closeFileHandle) {
if (d->fh) { if (d->fh) {
int ret; fclose(d->fh);
do {
ret = fclose(d->fh);
} while (ret == EOF && errno == EINTR);
} else if (d->fd != -1) { } else if (d->fd != -1) {
int ret; QT_CLOSE(d->fd);
do {
ret = QT_CLOSE(d->fd);
} while (ret == -1 && errno == EINTR);
} }
} }
d->unmapAll(); d->unmapAll();
@ -365,15 +359,14 @@ bool QFSFileEnginePrivate::closeFdFh()
// Close the file if we created the handle. // Close the file if we created the handle.
if (closeFileHandle) { if (closeFileHandle) {
int ret; int ret;
do {
if (fh) { if (fh) {
// Close buffered file. // Close buffered file.
ret = fclose(fh) != 0 ? -1 : 0; ret = fclose(fh);
} else { } else {
// Close unbuffered file. // Close unbuffered file.
ret = QT_CLOSE(fd); ret = QT_CLOSE(fd);
} }
} while (ret == -1 && errno == EINTR);
// We must reset these guys regardless; calling close again after a // We must reset these guys regardless; calling close again after a
// failed close causes crashes on some systems. // failed close causes crashes on some systems.

View File

@ -672,11 +672,11 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result,
} }
} }
inline static void iniChopTrailingSpaces(QString &str) inline static void iniChopTrailingSpaces(QString &str, int limit)
{ {
int n = str.size() - 1; int n = str.size() - 1;
QChar ch; QChar ch;
while (n >= 0 && ((ch = str.at(n)) == QLatin1Char(' ') || ch == QLatin1Char('\t'))) while (n >= limit && ((ch = str.at(n)) == QLatin1Char(' ') || ch == QLatin1Char('\t')))
str.truncate(n--); str.truncate(n--);
} }
@ -734,6 +734,7 @@ StSkipSpaces:
// fallthrough // fallthrough
StNormal: StNormal:
int chopLimit = stringResult.length();
while (i < to) { while (i < to) {
switch (str.at(i)) { switch (str.at(i)) {
case '\\': case '\\':
@ -771,6 +772,7 @@ StNormal:
} else { } else {
// the character is skipped // the character is skipped
} }
chopLimit = stringResult.length();
break; break;
case '"': case '"':
++i; ++i;
@ -782,7 +784,7 @@ StNormal:
case ',': case ',':
if (!inQuotedString) { if (!inQuotedString) {
if (!currentValueIsQuoted) if (!currentValueIsQuoted)
iniChopTrailingSpaces(stringResult); iniChopTrailingSpaces(stringResult, chopLimit);
if (!isStringList) { if (!isStringList) {
isStringList = true; isStringList = true;
stringListResult.clear(); stringListResult.clear();
@ -822,6 +824,8 @@ StNormal:
} }
} }
} }
if (!currentValueIsQuoted)
iniChopTrailingSpaces(stringResult, chopLimit);
goto end; goto end;
StHexEscape: StHexEscape:
@ -861,8 +865,6 @@ StOctEscape:
} }
end: end:
if (!currentValueIsQuoted)
iniChopTrailingSpaces(stringResult);
if (isStringList) if (isStringList)
stringListResult.append(stringResult); stringListResult.append(stringResult);
return isStringList; return isStringList;

View File

@ -1465,14 +1465,14 @@ void QObject::moveToThread(QThread *targetThread)
} }
QThreadData *currentData = QThreadData::current(); QThreadData *currentData = QThreadData::current();
QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : new QThreadData(0); QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : Q_NULLPTR;
if (d->threadData->thread == 0 && currentData == targetData) { if (d->threadData->thread == 0 && currentData == targetData) {
// one exception to the rule: we allow moving objects with no thread affinity to the current thread // one exception to the rule: we allow moving objects with no thread affinity to the current thread
currentData = d->threadData; currentData = d->threadData;
} else if (d->threadData != currentData) { } else if (d->threadData != currentData) {
qWarning("QObject::moveToThread: Current thread (%p) is not the object's thread (%p).\n" qWarning("QObject::moveToThread: Current thread (%p) is not the object's thread (%p).\n"
"Cannot move to target thread (%p)\n", "Cannot move to target thread (%p)\n",
currentData->thread, d->threadData->thread, targetData->thread); currentData->thread, d->threadData->thread, targetData ? targetData->thread : Q_NULLPTR);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
qWarning("On Mac OS X, you might be loading two sets of Qt binaries into the same process. " qWarning("On Mac OS X, you might be loading two sets of Qt binaries into the same process. "
@ -1486,6 +1486,9 @@ void QObject::moveToThread(QThread *targetThread)
// prepare to move // prepare to move
d->moveToThread_helper(); d->moveToThread_helper();
if (!targetData)
targetData = new QThreadData(0);
QOrderedMutexLocker locker(&currentData->postEventList.mutex, QOrderedMutexLocker locker(&currentData->postEventList.mutex,
&targetData->postEventList.mutex); &targetData->postEventList.mutex);

View File

@ -89,7 +89,7 @@
/*! \fn QFuture::QFuture() /*! \fn QFuture::QFuture()
Constructs an empty future. Constructs an empty, canceled future.
*/ */
/*! \fn QFuture::QFuture(const QFuture &other) /*! \fn QFuture::QFuture(const QFuture &other)

View File

@ -1354,8 +1354,7 @@ void dither_to_Mono(QImageData *dst, const QImageData *src,
dst_data += dst_bpl; dst_data += dst_bpl;
src_data += src_bpl; src_data += src_bpl;
} }
} else } else if (d == 8) {
/* (d == 8) */ {
for (int i=0; i<h; i++) { for (int i=0; i<h; i++) {
const uchar *p = src_data; const uchar *p = src_data;
const uchar *end = p + w; const uchar *end = p + w;

View File

@ -3558,8 +3558,10 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule)
return region; return region;
} }
if (!(pETEs = static_cast<EdgeTableEntry *>(malloc(sizeof(EdgeTableEntry) * Count)))) if (!(pETEs = static_cast<EdgeTableEntry *>(malloc(sizeof(EdgeTableEntry) * Count)))) {
delete region;
return 0; return 0;
}
region->vectorize(); region->vectorize();

View File

@ -250,6 +250,7 @@ QTransform::QTransform()
, m_13(0), m_23(0), m_33(1) , m_13(0), m_23(0), m_33(1)
, m_type(TxNone) , m_type(TxNone)
, m_dirty(TxNone) , m_dirty(TxNone)
, d(Q_NULLPTR)
{ {
} }
@ -268,6 +269,7 @@ QTransform::QTransform(qreal h11, qreal h12, qreal h13,
, m_13(h13), m_23(h23), m_33(h33) , m_13(h13), m_23(h23), m_33(h33)
, m_type(TxNone) , m_type(TxNone)
, m_dirty(TxProject) , m_dirty(TxProject)
, d(Q_NULLPTR)
{ {
} }
@ -284,6 +286,7 @@ QTransform::QTransform(qreal h11, qreal h12, qreal h21,
, m_13(0), m_23(0), m_33(1) , m_13(0), m_23(0), m_33(1)
, m_type(TxNone) , m_type(TxNone)
, m_dirty(TxShear) , m_dirty(TxShear)
, d(Q_NULLPTR)
{ {
} }
@ -299,6 +302,7 @@ QTransform::QTransform(const QMatrix &mtx)
m_13(0), m_23(0), m_33(1) m_13(0), m_23(0), m_33(1)
, m_type(TxNone) , m_type(TxNone)
, m_dirty(TxShear) , m_dirty(TxShear)
, d(Q_NULLPTR)
{ {
} }

View File

@ -154,12 +154,18 @@ private:
: affine(h11, h12, h21, h22, h31, h32, true) : affine(h11, h12, h21, h22, h31, h32, true)
, m_13(h13), m_23(h23), m_33(h33) , m_13(h13), m_23(h23), m_33(h33)
, m_type(TxNone) , m_type(TxNone)
, m_dirty(TxProject) {} , m_dirty(TxProject)
, d(Q_NULLPTR)
{
}
inline QTransform(bool) inline QTransform(bool)
: affine(true) : affine(true)
, m_13(0), m_23(0), m_33(1) , m_13(0), m_23(0), m_33(1)
, m_type(TxNone) , m_type(TxNone)
, m_dirty(TxNone) {} , m_dirty(TxNone)
, d(Q_NULLPTR)
{
}
inline TransformationType inline_type() const; inline TransformationType inline_type() const;
QMatrix affine; QMatrix affine;
qreal m_13; qreal m_13;

View File

@ -2519,6 +2519,7 @@ bool QTextEngine::atWordSeparator(int position) const
case '`': case '`':
case '~': case '~':
case '|': case '|':
case '\\':
return true; return true;
default: default:
break; break;

View File

@ -44,7 +44,6 @@ QT_BEGIN_NAMESPACE
QNetworkAccessCacheBackend::QNetworkAccessCacheBackend() QNetworkAccessCacheBackend::QNetworkAccessCacheBackend()
: QNetworkAccessBackend() : QNetworkAccessBackend()
, device(0)
{ {
} }
@ -117,11 +116,6 @@ bool QNetworkAccessCacheBackend::sendCacheContents()
void QNetworkAccessCacheBackend::closeDownstreamChannel() void QNetworkAccessCacheBackend::closeDownstreamChannel()
{ {
if (operation() == QNetworkAccessManager::GetOperation) {
device->close();
delete device;
device = 0;
}
} }
void QNetworkAccessCacheBackend::closeUpstreamChannel() void QNetworkAccessCacheBackend::closeUpstreamChannel()

View File

@ -67,7 +67,6 @@ public:
private: private:
bool sendCacheContents(); bool sendCacheContents();
QIODevice *device;
}; };

View File

@ -424,6 +424,7 @@ QNetworkReplyHttpImplPrivate::QNetworkReplyHttpImplPrivate()
, synchronous(false) , synchronous(false)
, state(Idle) , state(Idle)
, statusCode(0) , statusCode(0)
, uploadDeviceChoking(false)
, outgoingData(0) , outgoingData(0)
, bytesUploaded(-1) , bytesUploaded(-1)
, cacheLoadDevice(0) , cacheLoadDevice(0)
@ -1285,9 +1286,12 @@ void QNetworkReplyHttpImplPrivate::wantUploadDataSlot(qint64 maxSize)
char *data = const_cast<char*>(uploadByteDevice->readPointer(maxSize, currentUploadDataLength)); char *data = const_cast<char*>(uploadByteDevice->readPointer(maxSize, currentUploadDataLength));
if (currentUploadDataLength == 0) { if (currentUploadDataLength == 0) {
uploadDeviceChoking = true;
// No bytes from upload byte device. There will be bytes later, it will emit readyRead() // No bytes from upload byte device. There will be bytes later, it will emit readyRead()
// and our uploadByteDeviceReadyReadSlot() is called. // and our uploadByteDeviceReadyReadSlot() is called.
return; return;
} else {
uploadDeviceChoking = false;
} }
// Let's make a copy of this data // Let's make a copy of this data
@ -1300,7 +1304,12 @@ void QNetworkReplyHttpImplPrivate::wantUploadDataSlot(qint64 maxSize)
void QNetworkReplyHttpImplPrivate::uploadByteDeviceReadyReadSlot() void QNetworkReplyHttpImplPrivate::uploadByteDeviceReadyReadSlot()
{ {
// Start the flow between this thread and the HTTP thread again by triggering a upload. // Start the flow between this thread and the HTTP thread again by triggering a upload.
wantUploadDataSlot(1024); // However only do this when we were choking before, else the state in
// QNonContiguousByteDeviceThreadForwardImpl gets messed up.
if (uploadDeviceChoking) {
uploadDeviceChoking = false;
wantUploadDataSlot(1024);
}
} }

View File

@ -194,6 +194,7 @@ public:
// upload // upload
QNonContiguousByteDevice* createUploadByteDevice(); QNonContiguousByteDevice* createUploadByteDevice();
QSharedPointer<QNonContiguousByteDevice> uploadByteDevice; QSharedPointer<QNonContiguousByteDevice> uploadByteDevice;
bool uploadDeviceChoking; // if we couldn't readPointer() any data at the moment
QIODevice *outgoingData; QIODevice *outgoingData;
QSharedPointer<QRingBuffer> outgoingDataBuffer; QSharedPointer<QRingBuffer> outgoingDataBuffer;
void emitReplyUploadProgress(qint64 bytesSent, qint64 bytesTotal); // dup? void emitReplyUploadProgress(qint64 bytesSent, qint64 bytesTotal); // dup?

View File

@ -139,13 +139,13 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM; int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM;
int socket = qt_safe_socket(protocol, type, 0); int socket = qt_safe_socket(protocol, type, 0);
if (socket <= 0 && socketProtocol == QAbstractSocket::AnyIPProtocol && errno == EAFNOSUPPORT) { if (socket < 0 && socketProtocol == QAbstractSocket::AnyIPProtocol && errno == EAFNOSUPPORT) {
protocol = AF_INET; protocol = AF_INET;
socket = qt_safe_socket(protocol, type, 0); socket = qt_safe_socket(protocol, type, 0);
socketProtocol = QAbstractSocket::IPv4Protocol; socketProtocol = QAbstractSocket::IPv4Protocol;
} }
if (socket <= 0) { if (socket < 0) {
int ecopy = errno; int ecopy = errno;
switch (ecopy) { switch (ecopy) {
case EPROTONOSUPPORT: case EPROTONOSUPPORT:

View File

@ -703,9 +703,8 @@ bool QCocoaFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit
void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate() void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate()
{ {
if (mDelegate)
return;
QCocoaAutoReleasePool pool; QCocoaAutoReleasePool pool;
const SharedPointerFileDialogOptions &opts = options(); const SharedPointerFileDialogOptions &opts = options();
const QList<QUrl> selectedFiles = opts->initiallySelectedFiles(); const QList<QUrl> selectedFiles = opts->initiallySelectedFiles();
const QUrl directory = mDir.isEmpty() ? opts->initialDirectory() : mDir; const QUrl directory = mDir.isEmpty() ? opts->initialDirectory() : mDir;
@ -717,6 +716,7 @@ void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate()
options:opts options:opts
helper:this]; helper:this];
[static_cast<QNSOpenSavePanelDelegate *>(mDelegate) release];
mDelegate = delegate; mDelegate = delegate;
} }

View File

@ -82,6 +82,32 @@ static bool isMouseEvent(NSEvent *ev)
} }
} }
static void selectNextKeyWindow(NSWindow *currentKeyWindow)
{
if (!currentKeyWindow)
return;
const QCocoaAutoReleasePool pool;
if ([[NSApplication sharedApplication] keyWindow] != currentKeyWindow)
return;//currentKeyWindow is not a key window actually.
NSArray *const windows = [[NSApplication sharedApplication] windows];
bool startLookup = false;
for (NSWindow *candidate in [windows reverseObjectEnumerator]) {
if (!startLookup) {
if (candidate == currentKeyWindow)
startLookup = true;
} else {
if ([candidate isVisible] && [candidate canBecomeKeyWindow]) {
[candidate makeKeyWindow];
break;
}
}
}
}
@interface NSWindow (CocoaWindowCategory) @interface NSWindow (CocoaWindowCategory)
- (NSRect) legacyConvertRectFromScreen:(NSRect) rect; - (NSRect) legacyConvertRectFromScreen:(NSRect) rect;
@end @end
@ -592,6 +618,9 @@ void QCocoaWindow::hide(bool becauseOfAncestor)
foreach (QCocoaWindow *childWindow, m_childWindows) foreach (QCocoaWindow *childWindow, m_childWindows)
childWindow->hide(true); childWindow->hide(true);
if (window()->transientParent() && m_nsWindow == [[NSApplication sharedApplication] keyWindow])
selectNextKeyWindow(m_nsWindow); // Otherwise, Cocoa can do it wrong.
[m_nsWindow orderOut:nil]; [m_nsWindow orderOut:nil];
} }
@ -1456,7 +1485,11 @@ void QCocoaWindow::setNSWindow(QCocoaNSWindow *window)
{ {
if (window.contentView != m_contentView) { if (window.contentView != m_contentView) {
[m_contentView setPostsFrameChangedNotifications: NO]; [m_contentView setPostsFrameChangedNotifications: NO];
[m_contentView retain];
if (m_contentView.superview) // m_contentView comes from another NSWindow
[m_contentView removeFromSuperview];
[window setContentView:m_contentView]; [window setContentView:m_contentView];
[m_contentView release];
[m_contentView setPostsFrameChangedNotifications: YES]; [m_contentView setPostsFrameChangedNotifications: YES];
} }
} }

View File

@ -594,6 +594,8 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
CGImageRelease(subMask); CGImageRelease(subMask);
[self invalidateWindowShadowIfNeeded]; [self invalidateWindowShadowIfNeeded];
m_backingStore = 0;
} }
- (BOOL) isFlipped - (BOOL) isFlipped

View File

@ -731,6 +731,9 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req)
void QXcbClipboard::handleXFixesSelectionRequest(xcb_xfixes_selection_notify_event_t *event) void QXcbClipboard::handleXFixesSelectionRequest(xcb_xfixes_selection_notify_event_t *event)
{ {
QClipboard::Mode mode = modeForAtom(event->selection); QClipboard::Mode mode = modeForAtom(event->selection);
if (mode > QClipboard::Selection)
return;
// here we care only about the xfixes events that come from non Qt processes // here we care only about the xfixes events that come from non Qt processes
if (event->owner != XCB_NONE && event->owner != owner()) { if (event->owner != XCB_NONE && event->owner != owner()) {
if (!m_xClipboard[mode]) { if (!m_xClipboard[mode]) {

View File

@ -361,8 +361,10 @@ XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
QTouchDevice::Capabilities caps = 0; QTouchDevice::Capabilities caps = 0;
dev = new XInput2TouchDeviceData; dev = new XInput2TouchDeviceData;
dev->xiDeviceInfo = XIQueryDevice(static_cast<Display *>(m_xlib_display), id, &nrDevices); dev->xiDeviceInfo = XIQueryDevice(static_cast<Display *>(m_xlib_display), id, &nrDevices);
if (nrDevices <= 0) if (nrDevices <= 0) {
delete dev;
return 0; return 0;
}
int type = -1; int type = -1;
int maxTouchPoints = 1; int maxTouchPoints = 1;
bool hasRelativeCoords = false; bool hasRelativeCoords = false;

View File

@ -848,8 +848,10 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
baseLayout, latchedLayout, lockedLayout); baseLayout, latchedLayout, lockedLayout);
xkb_keysym_t sym = xkb_state_key_get_one_sym(kb_state, event->nativeScanCode()); xkb_keysym_t sym = xkb_state_key_get_one_sym(kb_state, event->nativeScanCode());
if (sym == XKB_KEY_NoSymbol) if (sym == XKB_KEY_NoSymbol) {
xkb_state_unref(kb_state);
return QList<int>(); return QList<int>();
}
QList<int> result; QList<int> result;
int baseQtKey = keysymToQtKey(sym, modifiers, lookupString(kb_state, event->nativeScanCode())); int baseQtKey = keysymToQtKey(sym, modifiers, lookupString(kb_state, event->nativeScanCode()));

View File

@ -211,6 +211,7 @@ bool Uic::write(QIODevice *in)
#ifdef QT_UIC_JAVA_GENERATOR #ifdef QT_UIC_JAVA_GENERATOR
if (language.toLower() != QLatin1String("jambi")) { if (language.toLower() != QLatin1String("jambi")) {
fprintf(stderr, "uic: File is not a 'jambi' form\n"); fprintf(stderr, "uic: File is not a 'jambi' form\n");
delete ui;
return false; return false;
} }
rtn = jwrite (ui); rtn = jwrite (ui);
@ -221,6 +222,7 @@ bool Uic::write(QIODevice *in)
#ifdef QT_UIC_CPP_GENERATOR #ifdef QT_UIC_CPP_GENERATOR
if (!language.isEmpty() && language.toLower() != QLatin1String("c++")) { if (!language.isEmpty() && language.toLower() != QLatin1String("c++")) {
fprintf(stderr, "uic: File is not a 'c++' ui file, language=%s\n", qPrintable(language)); fprintf(stderr, "uic: File is not a 'c++' ui file, language=%s\n", qPrintable(language));
delete ui;
return false; return false;
} }

View File

@ -1002,6 +1002,9 @@ void QTreeModel::timerEvent(QTimerEvent *ev)
\since 4.2 \since 4.2
Hides the item if \a hide is true, otherwise shows the item. Hides the item if \a hide is true, otherwise shows the item.
\note A call to this function has no effect if the item is not currently in a view. In particular,
calling \c setHidden(true) on an item and only then adding it to a view will result in
a visible item.
\sa isHidden() \sa isHidden()
*/ */

View File

@ -271,7 +271,7 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge
// (and reaches this point), then the menu item itself has been disabled. // (and reaches this point), then the menu item itself has been disabled.
// This occurs at the QPA level on Mac, were we disable all the Cocoa menus // This occurs at the QPA level on Mac, were we disable all the Cocoa menus
// when showing a modal window. // when showing a modal window.
if (a->shortcut().count() <= 1) if (a->shortcut().count() < 1 || (a->shortcut().count() == 1 && (a->shortcut()[0] & Qt::MODIFIER_MASK) != 0))
continue; continue;
#endif #endif
QAction *a = menu->menuAction(); QAction *a = menu->menuAction();

View File

@ -10528,6 +10528,22 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) { if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) {
if (extra && extra->hasWindowContainer) if (extra && extra->hasWindowContainer)
QWindowContainer::toplevelAboutToBeDestroyed(q); QWindowContainer::toplevelAboutToBeDestroyed(q);
QWindow *newParentWindow = newparent->windowHandle();
if (!newParentWindow)
if (QWidget *npw = newparent->nativeParentWidget())
newParentWindow = npw->windowHandle();
Q_FOREACH (QObject *child, q->windowHandle()->children()) {
QWindow *childWindow = qobject_cast<QWindow *>(child);
if (!childWindow)
continue;
QWidgetWindow *childWW = qobject_cast<QWidgetWindow *>(childWindow);
QWidget *childWidget = childWW ? childWW->widget() : 0;
if (!childWW || (childWidget && childWidget->testAttribute(Qt::WA_NativeWindow)))
childWindow->setParent(newParentWindow);
}
q->destroy(); q->destroy();
} }

View File

@ -289,6 +289,7 @@ static QColor mergedColors(const QColor &colorA, const QColor &colorB, int facto
static GdkColor fromQColor(const QColor &color) static GdkColor fromQColor(const QColor &color)
{ {
GdkColor retval; GdkColor retval;
retval.pixel = 0;
retval.red = color.red() * 255; retval.red = color.red() * 255;
retval.green = color.green() * 255; retval.green = color.green() * 255;
retval.blue = color.blue() * 255; retval.blue = color.blue() * 255;

View File

@ -1749,11 +1749,13 @@ ThemeDrawState QMacStylePrivate::getDrawState(QStyle::State flags)
return tds; return tds;
} }
NSView *QMacStylePrivate::buttonOfKind(ThemeButtonKind kind) const NSView *QMacStylePrivate::buttonOfKind(ThemeButtonKind kind, QPoint *offset) const
{ {
NSView *bv = buttons[kind]; NSView *bv = buttons[kind];
if (!bv) { if (!bv) {
if (kind == kThemePopupButton) if (kind == kThemePopupButton
|| kind == kThemePopupButtonSmall
|| kind == kThemePopupButtonMini)
bv = [[NSPopUpButton alloc] init]; bv = [[NSPopUpButton alloc] init];
else if (kind == kThemeComboBox) else if (kind == kThemeComboBox)
bv = [[NSComboBox alloc] init]; bv = [[NSComboBox alloc] init];
@ -1793,25 +1795,61 @@ NSView *QMacStylePrivate::buttonOfKind(ThemeButtonKind kind) const
break; break;
} }
// if (kind == kThemePushButtonSmall
// || kind == kThemePopupButtonSmall
// || kind == kThemeCheckBoxSmall
// || kind == kThemeRadioButtonSmall)
// bc.controlSize = NSSmallControlSize;
// else if (kind == kThemePushButtonMini
// || kind == kThemePopupButtonMini
// || kind == kThemeCheckBoxMini
// || kind == kThemeRadioButtonMini)
// bc.controlSize = NSMiniControlSize;
if ([bv isKindOfClass:[NSButton class]]) { if ([bv isKindOfClass:[NSButton class]]) {
NSButton *bc = (NSButton *)bv; NSButton *bc = (NSButton *)bv;
bc.title = nil; bc.title = nil;
NSCell *bcell = bc.cell;
switch (kind) {
case kThemePushButtonSmall:
case kThemePopupButtonSmall:
case kThemeCheckBoxSmall:
case kThemeRadioButtonSmall:
bcell.controlSize = NSSmallControlSize;
break;
case kThemePushButtonMini:
case kThemePopupButtonMini:
case kThemeCheckBoxMini:
case kThemeRadioButtonMini:
bcell.controlSize = NSMiniControlSize;
break;
default:
break;
}
} }
const_cast<QMacStylePrivate *>(this)->buttons.insert(kind, bv); const_cast<QMacStylePrivate *>(this)->buttons.insert(kind, bv);
} }
if (offset) {
switch (kind) {
case kThemeRadioButton:
offset->setY(2);
break;
case kThemeRadioButtonSmall:
*offset = QPoint(-1, 2);
break;
case kThemeRadioButtonMini:
offset->setY(2);
break;
case kThemePopupButtonSmall:
case kThemeCheckBox:
offset->setY(1);
break;
case kThemeCheckBoxSmall:
offset->setX(-1);
break;
case kThemeCheckBoxMini:
*offset = QPoint(7, 5);
break;
case kThemePopupButtonMini:
*offset = QPoint(2, -1);
break;
default:
break;
}
}
return bv; return bv;
} }
@ -1827,8 +1865,8 @@ void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRect &qtRect, QPain
CGRect rect = CGRectMake(qtRect.x() + 1, qtRect.y(), qtRect.width(), qtRect.height()); CGRect rect = CGRectMake(qtRect.x() + 1, qtRect.y(), qtRect.width(), qtRect.height());
[backingStoreNSView addSubview:view]; [backingStoreNSView addSubview:view];
view.frame = rect; view.frame = NSRectFromCGRect(rect);
[view drawRect:rect]; [view drawRect:NSRectFromCGRect(rect)];
[view removeFromSuperviewWithoutNeedingDisplay]; [view removeFromSuperviewWithoutNeedingDisplay];
[NSGraphicsContext restoreGraphicsState]; [NSGraphicsContext restoreGraphicsState];
@ -1928,14 +1966,20 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD
} }
pm = QPixmap::fromImage(image); pm = QPixmap::fromImage(image);
} else if ((usingYosemiteOrLater && combo && !editableCombo) || button) { } else if ((usingYosemiteOrLater && combo && !editableCombo) || button) {
NSButton *bc = (NSButton *)buttonOfKind(bdi->kind); QPoint offset;
NSButton *bc = (NSButton *)buttonOfKind(bdi->kind, &offset);
[bc highlight:pressed]; [bc highlight:pressed];
bc.enabled = bdi->state != kThemeStateUnavailable && bdi->state != kThemeStateUnavailableInactive; bc.enabled = bdi->state != kThemeStateUnavailable && bdi->state != kThemeStateUnavailableInactive;
bc.allowsMixedState = YES;
bc.state = bdi->value == kThemeButtonOn ? NSOnState : bc.state = bdi->value == kThemeButtonOn ? NSOnState :
bdi->value == kThemeButtonMixed ? NSMixedState : NSOffState; bdi->value == kThemeButtonMixed ? NSMixedState : NSOffState;
p->translate(0, 1); // The view frame may differ from what we pass to HITheme
drawNSViewInRect(bc, opt->rect, p); QRect rect = opt->rect;
p->translate(0, -1); if (bdi->kind == kThemePopupButtonMini)
rect.adjust(0, 0, -5, 0);
p->translate(offset);
drawNSViewInRect(bc, rect, p);
p->translate(-offset);
return; return;
} else if (usingYosemiteOrLater && editableCombo) { } else if (usingYosemiteOrLater && editableCombo) {
QImage image = activePixmap.toImage(); QImage image = activePixmap.toImage();
@ -3821,9 +3865,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
NSBezierPath *pushButtonFocusRingPath; NSBezierPath *pushButtonFocusRingPath;
if (bdi.kind == kThemeBevelButton) if (bdi.kind == kThemeBevelButton)
pushButtonFocusRingPath = [NSBezierPath bezierPathWithRect:focusRect]; pushButtonFocusRingPath = [NSBezierPath bezierPathWithRect:NSRectFromCGRect(focusRect)];
else else
pushButtonFocusRingPath = [NSBezierPath bezierPathWithRoundedRect:focusRect xRadius:4 yRadius:4]; pushButtonFocusRingPath = [NSBezierPath bezierPathWithRoundedRect:NSRectFromCGRect(focusRect) xRadius:4 yRadius:4];
qt_drawFocusRingOnPath(cg, pushButtonFocusRingPath); qt_drawFocusRingOnPath(cg, pushButtonFocusRingPath);
} }

View File

@ -187,7 +187,7 @@ public:
void setAutoDefaultButton(QObject *button) const; void setAutoDefaultButton(QObject *button) const;
NSView *buttonOfKind(ThemeButtonKind kind) const; NSView *buttonOfKind(ThemeButtonKind kind, QPoint *offset) const;
void drawNSViewInRect(NSView *view, const QRect &rect, QPainter *p) const; void drawNSViewInRect(NSView *view, const QRect &rect, QPainter *p) const;
void resolveCurrentNSView(QWindow *window); void resolveCurrentNSView(QWindow *window);

View File

@ -120,6 +120,7 @@ private slots:
void testEmptyData(); void testEmptyData();
void testResourceFiles(); void testResourceFiles();
void testRegistryShortRootNames(); void testRegistryShortRootNames();
void trailingWhitespace();
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
void fileName(); void fileName();
#endif #endif
@ -2053,6 +2054,23 @@ void tst_QSettings::testRegistryShortRootNames()
#endif #endif
} }
void tst_QSettings::trailingWhitespace()
{
{
QSettings s("tst_QSettings_trailingWhitespace");
s.setValue("trailingSpace", "x ");
s.setValue("trailingTab", "x\t");
s.setValue("trailingNewline", "x\n");
}
{
QSettings s("tst_QSettings_trailingWhitespace");
QCOMPARE(s.value("trailingSpace").toString(), QLatin1String("x "));
QCOMPARE(s.value("trailingTab").toString(), QLatin1String("x\t"));
QCOMPARE(s.value("trailingNewline").toString(), QLatin1String("x\n"));
s.clear();
}
}
void tst_QSettings::fromFile_data() void tst_QSettings::fromFile_data()
{ {
populateWithFormats(); populateWithFormats();

View File

@ -34,6 +34,7 @@
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#ifndef QT_NO_BEARERMANAGEMENT #ifndef QT_NO_BEARERMANAGEMENT
#include <QtNetwork/QNetworkConfigurationManager> #include <QtNetwork/QNetworkConfigurationManager>
#endif #endif
@ -53,6 +54,7 @@ public:
private slots: private slots:
void networkAccessible(); void networkAccessible();
void alwaysCacheRequest();
}; };
tst_QNetworkAccessManager::tst_QNetworkAccessManager() tst_QNetworkAccessManager::tst_QNetworkAccessManager()
@ -118,5 +120,16 @@ void tst_QNetworkAccessManager::networkAccessible()
#endif #endif
} }
void tst_QNetworkAccessManager::alwaysCacheRequest()
{
QNetworkAccessManager manager;
QNetworkRequest req;
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache);
QNetworkReply *reply = manager.get(req);
reply->close();
delete reply;
}
QTEST_MAIN(tst_QNetworkAccessManager) QTEST_MAIN(tst_QNetworkAccessManager)
#include "tst_qnetworkaccessmanager.moc" #include "tst_qnetworkaccessmanager.moc"

View File

@ -7875,6 +7875,8 @@ protected slots:
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
bandwidthQuota = 8*1024; // fill quota bandwidthQuota = 8*1024; // fill quota
emit readyRead(); emit readyRead();
// Emitting readyRead() several times triggers a bug ("QIODevice::read: Called with maxSize < 0") we fix with this commit
emit readyRead();
} }
}; };