summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/syncqt6
-rw-r--r--config.tests/mac/crc/main.cpp4
-rwxr-xr-xconfigure2
-rw-r--r--src/corelib/codecs/qtextcodec.h2
-rw-r--r--src/corelib/io/qfsfileengine.cpp2
-rw-r--r--src/corelib/io/qprocess.cpp3
-rw-r--r--src/corelib/kernel/qcore_unix.cpp5
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp13
-rw-r--r--src/dbus/qdbusargument_p.h2
-rw-r--r--src/dbus/qdbusconnection_p.h2
-rw-r--r--src/dbus/qdbusconnectioninterface.cpp2
-rw-r--r--src/dbus/qdbuserror.cpp2
-rw-r--r--src/dbus/qdbusintegrator_p.h2
-rw-r--r--src/dbus/qdbusinterface.cpp2
-rw-r--r--src/dbus/qdbusinterface_p.h4
-rw-r--r--src/dbus/qdbusinternalfilters.cpp2
-rw-r--r--src/dbus/qdbusmessage.cpp2
-rw-r--r--src/dbus/qdbusmetatype.cpp2
-rw-r--r--src/dbus/qdbusutil.cpp2
-rw-r--r--src/dbus/qdbusxmlparser_p.h2
-rw-r--r--src/gui/dialogs/dialogs.pri18
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp24
-rw-r--r--src/gui/kernel/qapplication.cpp10
-rw-r--r--src/gui/kernel/qwidget_mac.mm112
-rw-r--r--src/gui/styles/qgtkstyle.cpp16
-rw-r--r--src/gui/styles/qgtkstyle_p.cpp2
-rw-r--r--src/gui/styles/qgtkstyle_p.h2
-rw-r--r--src/gui/util/qsystemtrayicon.cpp3
-rw-r--r--src/gui/util/qsystemtrayicon_mac.mm28
-rw-r--r--src/network/access/qnetworkrequest.cpp3
-rw-r--r--src/qt_install.pri6
-rw-r--r--tests/auto/auto.pro1
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp2
-rw-r--r--tests/auto/qprocessenvironment/qprocessenvironment.pro5
-rw-r--r--tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp265
-rw-r--r--tests/auto/qsharedpointer/tst_qsharedpointer.cpp10
-rw-r--r--tests/auto/qtouchevent/tst_qtouchevent.cpp250
-rw-r--r--tests/manual/qwidget_zorder/main.cpp118
-rw-r--r--tests/manual/qwidget_zorder/qwidget_zorder.pro6
39 files changed, 847 insertions, 97 deletions
diff --git a/bin/syncqt b/bin/syncqt
index a14a82d..629e124 100755
--- a/bin/syncqt
+++ b/bin/syncqt
@@ -666,6 +666,7 @@ foreach (@modules_to_sync) {
#information used after the syncing
my $pri_install_classes = "";
my $pri_install_files = "";
+ my $pri_install_pfiles = "";
my $libcapitals = $lib;
$libcapitals =~ y/a-z/A-Z/;
@@ -834,6 +835,10 @@ foreach (@modules_to_sync) {
$pri_install_files.= "$pri_install_iheader ";;
}
}
+ else {
+ my $pri_install_iheader = fixPaths($iheader, $current_dir);
+ $pri_install_pfiles.= "$pri_install_iheader ";;
+ }
}
print "header created for $iheader ($header_copies)\n" if($header_copies > 0);
}
@@ -878,6 +883,7 @@ foreach (@modules_to_sync) {
my $headers_pri_contents = "";
$headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n";
$headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n";
+ $headers_pri_contents .= "SYNCQT.PRIVATE_HEADER_FILES = $pri_install_pfiles\n";
my $headers_pri_file = "$out_basedir/include/$lib/headers.pri";
if(-e "$headers_pri_file") {
open HEADERS_PRI_FILE, "<$headers_pri_file";
diff --git a/config.tests/mac/crc/main.cpp b/config.tests/mac/crc/main.cpp
index 894f88b..700a4cd 100644
--- a/config.tests/mac/crc/main.cpp
+++ b/config.tests/mac/crc/main.cpp
@@ -71,7 +71,7 @@ private:
for(int iCodes = 0; iCodes <= 0xFF; iCodes++) {
ulTable[iCodes] = Reflect(iCodes, 8) << 24;
for(int iPos = 0; iPos < 8; iPos++) {
- ulTable[iCodes] = (ulTable[iCodes] << 1)
+ ulTable[iCodes] = ((ulTable[iCodes] << 1) & 0xffffffff)
^ ((ulTable[iCodes] & (1 << 31)) ? ulPolynomial : 0);
}
@@ -84,7 +84,7 @@ private:
// Swap bit 0 for bit 7, bit 1 For bit 6, etc....
for(int iPos = 1; iPos < (cChar + 1); iPos++) {
if(ulReflect & 1) {
- ulValue |= (1 << (cChar - iPos));
+ ulValue |= (1ul << (cChar - iPos));
}
ulReflect >>= 1;
}
diff --git a/configure b/configure
index 6dc3898..486dc0c 100755
--- a/configure
+++ b/configure
@@ -131,7 +131,7 @@ compilerSupportsFlag()
cat >conftest.cpp <<EOF
int main() { return 0; }
EOF
- "$TEST_COMPILER" "$@" -o /dev/null conftest.cpp
+ "$TEST_COMPILER" "$@" -o conftest.o conftest.cpp
ret=$?
rm -f conftest.cpp conftest.o
return $ret
diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h
index f831700..6170272 100644
--- a/src/corelib/codecs/qtextcodec.h
+++ b/src/corelib/codecs/qtextcodec.h
@@ -161,7 +161,7 @@ public:
QByteArray fromUnicode(const QString& str);
QByteArray fromUnicode(const QChar *uc, int len);
#ifdef QT3_SUPPORT
- QByteArray fromUnicode(const QString& uc, int& lenInOut);
+ QT3_SUPPORT QByteArray fromUnicode(const QString& uc, int& lenInOut);
#endif
bool hasFailure() const;
private:
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 37b0ea1..e4c4e3f 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -144,7 +144,7 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path)
return path;
#endif
// Mac OS X 10.5.x doesn't support the realpath(X,0) extenstion we use here.
-#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) || defined(Q_OS_SYMBIAN)
+#if defined(Q_OS_LINIX) || defined(Q_OS_SYMBIAN)
char *ret = realpath(path.toLocal8Bit().constData(), (char*)0);
if (ret) {
QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret));
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 37161bc..c78af3c 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -275,7 +275,7 @@ QProcessEnvironment &QProcessEnvironment::operator=(const QProcessEnvironment &o
*/
bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const
{
- return d->hash == other.d->hash;
+ return d == other.d || (d && other.d && d->hash == other.d->hash);
}
/*!
@@ -334,6 +334,7 @@ bool QProcessEnvironment::contains(const QString &name) const
*/
void QProcessEnvironment::insert(const QString &name, const QString &value)
{
+ // d detaches from null
d->hash.insert(prepareName(name), prepareValue(value));
}
diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp
index 5885591..d0dc7be 100644
--- a/src/corelib/kernel/qcore_unix.cpp
+++ b/src/corelib/kernel/qcore_unix.cpp
@@ -129,7 +129,7 @@ static inline bool time_update(struct timeval *tv, const struct timeval &start,
// clock source is monotonic, so we can recalculate how much timeout is left
struct timeval now = qt_gettime();
*tv = timeout + start - now;
- return true;
+ return tv->tv_sec >= 0;
}
int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
@@ -154,7 +154,8 @@ int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
// recalculate the timeout
if (!time_update(&timeout, start, *orig_timeout)) {
- // clock reset, fake timeout error
+ // timeout during update
+ // or clock reset, fake timeout error
return 0;
}
}
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index c6eef5e..c305341 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -509,7 +509,11 @@ LRESULT CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp)
}
}
}
+#ifdef Q_OS_WINCE
+ return 0;
+#else
return CallNextHookEx(0, code, wp, lp);
+#endif
}
static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatcher)
@@ -636,11 +640,13 @@ void QEventDispatcherWin32::createInternalHwnd()
return;
d->internalHwnd = qt_create_internal_window(this);
+#ifndef Q_OS_WINCE
// setup GetMessage hook needed to drive our posted events
d->getMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) qt_GetMessageHook, NULL, GetCurrentThreadId());
if (!d->getMessageHook) {
qFatal("Qt: INTERNALL ERROR: failed to install GetMessage hook");
}
+#endif
// register all socket notifiers
QList<int> sockets = (d->sn_read.keys().toSet()
@@ -731,6 +737,11 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
}
}
if (haveMessage) {
+#ifdef Q_OS_WINCE
+ // WinCE doesn't support hooks at all, so we have to call this by hand :(
+ (void) qt_GetMessageHook(0, PM_REMOVE, (LPARAM) &msg);
+#endif
+
if (d->internalHwnd == msg.hwnd && msg.message == WM_QT_SENDPOSTEDEVENTS) {
if (seenWM_QT_SENDPOSTEDEVENTS) {
needWM_QT_SENDPOSTEDEVENTS = true;
@@ -1065,9 +1076,11 @@ void QEventDispatcherWin32::closingDown()
d->timerVec.clear();
d->timerDict.clear();
+#ifndef Q_OS_WINCE
if (d->getMessageHook)
UnhookWindowsHookEx(d->getMessageHook);
d->getMessageHook = 0;
+#endif
}
bool QEventDispatcherWin32::event(QEvent *e)
diff --git a/src/dbus/qdbusargument_p.h b/src/dbus/qdbusargument_p.h
index 47c5e62..17302b4 100644
--- a/src/dbus/qdbusargument_p.h
+++ b/src/dbus/qdbusargument_p.h
@@ -54,7 +54,7 @@
//
#include <qdbusargument.h>
-#include <qdbus_symbols_p.h>
+#include "qdbus_symbols_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h
index b65e101..d6f7598 100644
--- a/src/dbus/qdbusconnection_p.h
+++ b/src/dbus/qdbusconnection_p.h
@@ -67,7 +67,7 @@
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qvector.h>
-#include <qdbus_symbols_p.h>
+#include "qdbus_symbols_p.h"
#include <qdbusmessage.h>
diff --git a/src/dbus/qdbusconnectioninterface.cpp b/src/dbus/qdbusconnectioninterface.cpp
index 0f9a67f..ec61859 100644
--- a/src/dbus/qdbusconnectioninterface.cpp
+++ b/src/dbus/qdbusconnectioninterface.cpp
@@ -49,7 +49,7 @@
#include <QtCore/QVariant>
#include <QtCore/QDebug>
-#include <qdbus_symbols_p.h> // for the DBUS_* constants
+#include "qdbus_symbols_p.h" // for the DBUS_* constants
QT_BEGIN_NAMESPACE
diff --git a/src/dbus/qdbuserror.cpp b/src/dbus/qdbuserror.cpp
index 5c2fa2b..a48b878 100644
--- a/src/dbus/qdbuserror.cpp
+++ b/src/dbus/qdbuserror.cpp
@@ -44,7 +44,7 @@
#include <qdebug.h>
#include <qvarlengtharray.h>
-#include <qdbus_symbols_p.h>
+#include "qdbus_symbols_p.h"
#include "qdbusmessage.h"
#include "qdbusmessage_p.h"
diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h
index 5b18aca..85c6cb2 100644
--- a/src/dbus/qdbusintegrator_p.h
+++ b/src/dbus/qdbusintegrator_p.h
@@ -54,7 +54,7 @@
#ifndef QDBUSINTEGRATOR_P_H
#define QDBUSINTEGRATOR_P_H
-#include <qdbus_symbols_p.h>
+#include "qdbus_symbols_p.h"
#include "qcoreevent.h"
#include "qeventloop.h"
diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp
index d0a693f..c05e6a9 100644
--- a/src/dbus/qdbusinterface.cpp
+++ b/src/dbus/qdbusinterface.cpp
@@ -41,7 +41,7 @@
#include "qdbusinterface.h"
-#include <qdbus_symbols_p.h>
+#include "qdbus_symbols_p.h"
#include <QtCore/qpointer.h>
#include <QtCore/qstringlist.h>
diff --git a/src/dbus/qdbusinterface_p.h b/src/dbus/qdbusinterface_p.h
index 3d11af1..a601608 100644
--- a/src/dbus/qdbusinterface_p.h
+++ b/src/dbus/qdbusinterface_p.h
@@ -54,8 +54,8 @@
#ifndef QDBUSINTERFACEPRIVATE_H
#define QDBUSINTERFACEPRIVATE_H
-#include <qdbusabstractinterface_p.h>
-#include <qdbusmetaobject_p.h>
+#include "qdbusabstractinterface_p.h"
+#include "qdbusmetaobject_p.h"
#include <qdbusinterface.h>
QT_BEGIN_NAMESPACE
diff --git a/src/dbus/qdbusinternalfilters.cpp b/src/dbus/qdbusinternalfilters.cpp
index acd04d3..37110c5 100644
--- a/src/dbus/qdbusinternalfilters.cpp
+++ b/src/dbus/qdbusinternalfilters.cpp
@@ -41,7 +41,7 @@
#include "qdbusconnection_p.h"
-#include <qdbus_symbols_p.h>
+#include "qdbus_symbols_p.h"
#include <QtCore/qcoreapplication.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/qstringlist.h>
diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp
index 4f1950b..a37ba1f 100644
--- a/src/dbus/qdbusmessage.cpp
+++ b/src/dbus/qdbusmessage.cpp
@@ -44,7 +44,7 @@
#include <qdebug.h>
#include <qstringlist.h>
-#include <qdbus_symbols_p.h>
+#include "qdbus_symbols_p.h"
#include "qdbusargument_p.h"
#include "qdbuserror.h"
diff --git a/src/dbus/qdbusmetatype.cpp b/src/dbus/qdbusmetatype.cpp
index 237aea3..afa3bbf 100644
--- a/src/dbus/qdbusmetatype.cpp
+++ b/src/dbus/qdbusmetatype.cpp
@@ -42,7 +42,7 @@
#include "qdbusmetatype.h"
#include <string.h>
-#include <qdbus_symbols_p.h>
+#include "qdbus_symbols_p.h"
#include <qbytearray.h>
#include <qglobal.h>
diff --git a/src/dbus/qdbusutil.cpp b/src/dbus/qdbusutil.cpp
index bf5a739..01b1dbd 100644
--- a/src/dbus/qdbusutil.cpp
+++ b/src/dbus/qdbusutil.cpp
@@ -41,7 +41,7 @@
#include "qdbusutil_p.h"
-#include <qdbus_symbols_p.h>
+#include "qdbus_symbols_p.h"
#include <QtCore/qstringlist.h>
diff --git a/src/dbus/qdbusxmlparser_p.h b/src/dbus/qdbusxmlparser_p.h
index 3dbae1b..1a0523b 100644
--- a/src/dbus/qdbusxmlparser_p.h
+++ b/src/dbus/qdbusxmlparser_p.h
@@ -56,7 +56,7 @@
#include <QtCore/qmap.h>
#include <QtXml/qdom.h>
#include <qdbusmacros.h>
-#include <qdbusintrospection_p.h>
+#include "qdbusintrospection_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/gui/dialogs/dialogs.pri b/src/gui/dialogs/dialogs.pri
index b9fad41..63f64a2 100644
--- a/src/gui/dialogs/dialogs.pri
+++ b/src/gui/dialogs/dialogs.pri
@@ -28,13 +28,27 @@ HEADERS += \
dialogs/qprintpreviewdialog.h
!embedded:mac {
- OBJECTIVE_SOURCES += dialogs/qcolordialog_mac.mm \
- dialogs/qfiledialog_mac.mm \
+ OBJECTIVE_SOURCES += dialogs/qfiledialog_mac.mm \
dialogs/qfontdialog_mac.mm \
dialogs/qnspanelproxy_mac.mm \
dialogs/qpagesetupdialog_mac.mm \
dialogs/qprintdialog_mac.mm
+
+# Compile qcolordialog_mac.mm with exception support, disregarding the -no-exceptions
+# configure option. (qcolordialog_mac needs to catch exceptions thrown by cocoa)
+ EXCEPTION_SOURCES = dialogs/qcolordialog_mac.mm
+ exceptions_compiler.commands = $$QMAKE_CXX -c
+ exceptions_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
+ exceptions_compiler.commands += -fexceptions
+ exceptions_compiler.dependency_type = TYPE_C
+ exceptions_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
+ exceptions_compiler.input = EXCEPTION_SOURCES
+ exceptions_compiler.variable_out = OBJECTS
+ exceptions_compiler.name = compiling[exceptopns] ${QMAKE_FILE_IN}
+ silent:exceptions_compiler.commands = @echo compiling[exceptopns] ${QMAKE_FILE_IN} && $$exceptions_compiler.commands
+ QMAKE_EXTRA_COMPILERS += exceptions_compiler
}
+
win32 {
HEADERS += dialogs/qwizard_win_p.h
SOURCES += dialogs/qdialogsbinarycompat_win.cpp \
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 2af90b8..6176f2d 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -614,6 +614,19 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
if (item == lastActivePanel)
lastActivePanel = 0;
+ // Cancel active touches
+ {
+ QMap<int, QGraphicsItem *>::iterator it = itemForTouchPointId.begin();
+ while (it != itemForTouchPointId.end()) {
+ if (it.value() == item) {
+ sceneCurrentTouchPoints.remove(it.key());
+ it = itemForTouchPointId.erase(it);
+ } else {
+ ++it;
+ }
+ }
+ }
+
// Disable selectionChanged() for individual items
++selectionChanging;
int oldSelectedItemsSize = selectedItems.size();
@@ -5680,17 +5693,22 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
touchEvent->setAccepted(acceptTouchEvents);
res = acceptTouchEvents && sendEvent(item, touchEvent);
eventAccepted = touchEvent->isAccepted();
- item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted);
+ if (itemForTouchPointId.value(touchEvent->touchPoints().first().id()) == 0) {
+ // item was deleted
+ item = 0;
+ } else {
+ item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted);
+ }
touchEvent->spont = false;
if (res && eventAccepted) {
// the first item to accept the TouchBegin gets an implicit grab.
for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);
- itemForTouchPointId[touchPoint.id()] = item;
+ itemForTouchPointId[touchPoint.id()] = item; // can be zero
}
break;
}
- if (item->isPanel())
+ if (item && item->isPanel())
break;
}
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 9f4cd0c..8c63968 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -4092,9 +4092,15 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents);
touchEvent->setWidget(widget);
touchEvent->setAccepted(acceptTouchEvents);
+ QWeakPointer<QWidget> p = widget;
res = acceptTouchEvents && d->notify_helper(widget, touchEvent);
eventAccepted = touchEvent->isAccepted();
- widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted);
+ if (p.isNull()) {
+ // widget was deleted
+ widget = 0;
+ } else {
+ widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted);
+ }
touchEvent->spont = false;
if (res && eventAccepted) {
// the first widget to accept the TouchBegin gets an implicit grab.
@@ -4103,7 +4109,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
d->widgetForTouchPointId[touchPoint.id()] = widget;
}
break;
- } else if (widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) {
+ } else if (p.isNull() || widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) {
break;
}
QPoint offset = widget->pos();
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 1907cca..7dc4d85 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -3654,6 +3654,16 @@ void QWidgetPrivate::setFocus_sys()
}
}
+NSComparisonResult compareViews2Raise(id view1, id view2, void *context)
+{
+ id topView = reinterpret_cast<id>(context);
+ if (view1 == topView)
+ return NSOrderedDescending;
+ if (view2 == topView)
+ return NSOrderedAscending;
+ return NSOrderedSame;
+}
+
void QWidgetPrivate::raise_sys()
{
Q_Q(QWidget);
@@ -3661,7 +3671,6 @@ void QWidgetPrivate::raise_sys()
return;
#if QT_MAC_USE_COCOA
- QMacCocoaAutoReleasePool pool;
if (isRealWindow()) {
// Calling orderFront shows the window on Cocoa too.
if (!q->testAttribute(Qt::WA_DontShowOnScreen) && q->isVisible()) {
@@ -3673,16 +3682,9 @@ void QWidgetPrivate::raise_sys()
SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly);
}
} else {
- // Cocoa doesn't really have an idea of Z-ordering, but you can
- // fake it by changing the order of it. But beware, removing an
- // NSView will also remove it as the first responder. So we re-set
- // the first responder just in case:
NSView *view = qt_mac_nativeview_for(q);
NSView *parentView = [view superview];
- NSResponder *firstResponder = [[view window] firstResponder];
- [view removeFromSuperview];
- [parentView addSubview:view];
- [[view window] makeFirstResponder:firstResponder];
+ [parentView sortSubviewsUsingFunction:compareViews2Raise context:reinterpret_cast<void *>(view)];
}
#else
if(q->isWindow()) {
@@ -3700,47 +3702,29 @@ void QWidgetPrivate::raise_sys()
#endif
}
+NSComparisonResult compareViews2Lower(id view1, id view2, void *context)
+{
+ id topView = reinterpret_cast<id>(context);
+ if (view1 == topView)
+ return NSOrderedAscending;
+ if (view2 == topView)
+ return NSOrderedDescending;
+ return NSOrderedSame;
+}
+
void QWidgetPrivate::lower_sys()
{
Q_Q(QWidget);
if((q->windowType() == Qt::Desktop))
return;
#ifdef QT_MAC_USE_COCOA
- QMacCocoaAutoReleasePool pool;
if (isRealWindow()) {
OSWindowRef window = qt_mac_window_for(q);
[window orderBack:window];
} else {
- // Cocoa doesn't really have an idea of Z-ordering, but you can
- // fake it by changing the order of it. In this case
- // we put the item at the beginning of the list, but that means
- // we must re-insert everything since we cannot modify the list directly.
- NSView *myview = qt_mac_nativeview_for(q);
- NSView *parentView = [myview superview];
- NSArray *tmpViews = [parentView subviews];
- NSMutableArray *subviews = [[NSMutableArray alloc] initWithCapacity:[tmpViews count]];
- [subviews addObjectsFromArray:tmpViews];
- NSResponder *firstResponder = [[myview window] firstResponder];
- // Implicit assumption that myViewIndex is included in subviews, that's why I'm not checking
- // myViewIndex.
- NSUInteger index = 0;
- NSUInteger myViewIndex = 0;
- bool foundMyView = false;
- for (NSView *subview in subviews) {
- [subview removeFromSuperview];
- if (subview == myview) {
- foundMyView = true;
- myViewIndex = index;
- }
- ++index;
- }
- [parentView addSubview:myview];
- if (foundMyView)
- [subviews removeObjectAtIndex:myViewIndex];
- for (NSView *subview in subviews)
- [parentView addSubview:subview];
- [subviews release];
- [[myview window] makeFirstResponder:firstResponder];
+ NSView *view = qt_mac_nativeview_for(q);
+ NSView *parentView = [view superview];
+ [parentView sortSubviewsUsingFunction:compareViews2Lower context:reinterpret_cast<void *>(view)];
}
#else
if(q->isWindow()) {
@@ -3753,6 +3737,16 @@ void QWidgetPrivate::lower_sys()
#endif
}
+NSComparisonResult compareViews2StackUnder(id view1, id view2, void *context)
+{
+ const QHash<NSView *, int> &viewOrder = *reinterpret_cast<QHash<NSView *, int> *>(context);
+ if (viewOrder[view1] < viewOrder[view2])
+ return NSOrderedAscending;
+ if (viewOrder[view1] > viewOrder[view2])
+ return NSOrderedDescending;
+ return NSOrderedSame;
+}
+
void QWidgetPrivate::stackUnder_sys(QWidget *w)
{
// stackUnder
@@ -3761,37 +3755,23 @@ void QWidgetPrivate::stackUnder_sys(QWidget *w)
return;
#ifdef QT_MAC_USE_COCOA
// Do the same trick as lower_sys() and put this widget before the widget passed in.
- QMacCocoaAutoReleasePool pool;
- NSView *myview = qt_mac_nativeview_for(q);
+ NSView *myView = qt_mac_nativeview_for(q);
NSView *wView = qt_mac_nativeview_for(w);
- NSView *parentView = [myview superview];
- NSArray *tmpViews = [parentView subviews];
- NSMutableArray *subviews = [[NSMutableArray alloc] initWithCapacity:[tmpViews count]];
- [subviews addObjectsFromArray:tmpViews];
- // Implicit assumption that myViewIndex and wViewIndex is included in subviews,
- // that's why I'm not checking myViewIndex.
- NSUInteger index = 0;
- NSUInteger myViewIndex = 0;
- NSUInteger wViewIndex = 0;
- for (NSView *subview in subviews) {
- [subview removeFromSuperview];
- if (subview == myview)
- myViewIndex = index;
- else if (subview == wView)
- wViewIndex = index;
- ++index;
- }
- index = 0;
+ QHash<NSView *, int> viewOrder;
+ NSView *parentView = [myView superview];
+ NSArray *subviews = [parentView subviews];
+ NSUInteger index = 1;
+ // make a hash of view->zorderindex and make sure z-value is always odd,
+ // so that when we modify the order we create a new (even) z-value which
+ // will not interfere with others.
for (NSView *subview in subviews) {
- if (index == myViewIndex)
- continue;
- if (index == wViewIndex)
- [parentView addSubview:myview];
- [parentView addSubview:subview];
+ viewOrder.insert(subview, index * 2);
++index;
}
- [subviews release];
+ viewOrder[myView] = viewOrder[wView] - 1;
+
+ [parentView sortSubviewsUsingFunction:compareViews2StackUnder context:reinterpret_cast<void *>(&viewOrder)];
#else
QWidget *p = q->parentWidget();
if(!p || p != w->parentWidget())
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index afa3325..e10bb41 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -3375,12 +3375,28 @@ QIcon QGtkStyle::standardIconImplementation(StandardPixmap standardIcon,
/*! \reimp */
QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
{
+ Q_D(const QGtkStyle);
+
QRect r = QCleanlooksStyle::subElementRect(element, option, widget);
switch (element) {
case SE_ProgressBarLabel:
case SE_ProgressBarContents:
case SE_ProgressBarGroove:
return option->rect;
+ case SE_PushButtonContents:
+ if (!d->gtk_check_version(2, 10, 0)) {
+ GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
+ GtkBorder *border = 0;
+ d->gtk_widget_style_get(gtkButton, "inner-border", &border, NULL);
+ if (border) {
+ r = option->rect.adjusted(border->left, border->top, -border->right, -border->bottom);
+ d->gtk_border_free(border);
+ } else {
+ r = option->rect.adjusted(1, 1, -1, -1);
+ }
+ r = visualRect(option->direction, option->rect, r);
+ }
+ break;
default:
break;
}
diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp
index 22dfc62..a644a5b 100644
--- a/src/gui/styles/qgtkstyle_p.cpp
+++ b/src/gui/styles/qgtkstyle_p.cpp
@@ -158,6 +158,7 @@ Ptr_gtk_window_get_type QGtkStylePrivate::gtk_window_get_type = 0;
Ptr_gtk_widget_get_type QGtkStylePrivate::gtk_widget_get_type = 0;
Ptr_gtk_rc_get_style_by_paths QGtkStylePrivate::gtk_rc_get_style_by_paths = 0;
Ptr_gtk_check_version QGtkStylePrivate::gtk_check_version = 0;
+Ptr_gtk_border_free QGtkStylePrivate::gtk_border_free = 0;
Ptr_pango_font_description_get_size QGtkStylePrivate::pango_font_description_get_size = 0;
Ptr_pango_font_description_get_weight QGtkStylePrivate::pango_font_description_get_weight = 0;
@@ -416,6 +417,7 @@ void QGtkStylePrivate::resolveGtk() const
gtk_widget_get_type =(Ptr_gtk_widget_get_type)libgtk.resolve("gtk_widget_get_type");
gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths");
gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version");
+ gtk_border_free =(Ptr_gtk_border_free)libgtk.resolve("gtk_border_free");
pango_font_description_get_size = (Ptr_pango_font_description_get_size)libgtk.resolve("pango_font_description_get_size");
pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight");
pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");
diff --git a/src/gui/styles/qgtkstyle_p.h b/src/gui/styles/qgtkstyle_p.h
index f6ab8a3..c27308f 100644
--- a/src/gui/styles/qgtkstyle_p.h
+++ b/src/gui/styles/qgtkstyle_p.h
@@ -176,6 +176,7 @@ typedef GtkWidget* (*Ptr_gtk_file_chooser_dialog_new)(const gchar *title,
typedef void (*Ptr_gtk_file_chooser_set_current_name) (GtkFileChooser *, const gchar *);
typedef gboolean (*Ptr_gtk_file_chooser_set_filename) (GtkFileChooser *chooser, const gchar *name);
typedef gint (*Ptr_gtk_dialog_run) (GtkDialog*);
+typedef void (*Ptr_gtk_border_free)(GtkBorder *);
typedef guchar* (*Ptr_gdk_pixbuf_get_pixels) (const GdkPixbuf *pixbuf);
typedef int (*Ptr_gdk_pixbuf_get_width) (const GdkPixbuf *pixbuf);
@@ -371,6 +372,7 @@ public:
static Ptr_gtk_widget_get_type gtk_widget_get_type;
static Ptr_gtk_rc_get_style_by_paths gtk_rc_get_style_by_paths;
static Ptr_gtk_check_version gtk_check_version;
+ static Ptr_gtk_border_free gtk_border_free;
static Ptr_pango_font_description_get_size pango_font_description_get_size;
static Ptr_pango_font_description_get_weight pango_font_description_get_weight;
diff --git a/src/gui/util/qsystemtrayicon.cpp b/src/gui/util/qsystemtrayicon.cpp
index c6ea00f..6f2b501 100644
--- a/src/gui/util/qsystemtrayicon.cpp
+++ b/src/gui/util/qsystemtrayicon.cpp
@@ -380,6 +380,9 @@ bool QSystemTrayIcon::supportsMessages()
On Windows, the \a millisecondsTimeoutHint is usually ignored by the system
when the application has focus.
+ On Mac OS X, the Growl notification system must be installed for this function to
+ display messages.
+
\sa show() supportsMessages()
*/
void QSystemTrayIcon::showMessage(const QString& title, const QString& msg,
diff --git a/src/gui/util/qsystemtrayicon_mac.mm b/src/gui/util/qsystemtrayicon_mac.mm
index b74ca85..93295a7 100644
--- a/src/gui/util/qsystemtrayicon_mac.mm
+++ b/src/gui/util/qsystemtrayicon_mac.mm
@@ -314,8 +314,22 @@ QT_END_NAMESPACE
{
Q_UNUSED(notification);
down = NO;
+
+ if( ![self icon]->icon().isNull() ) {
+#ifndef QT_MAC_USE_COCOA
+ const short scale = GetMBarHeight()-4;
+#else
+ CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
+ const short scale = hgt - 4;
+#endif
+ NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale))));
+ [self setImage: nsimage];
+ [nsimage release];
+ }
+
if([self icon]->contextMenu())
[self icon]->contextMenu()->hide();
+
[self setNeedsDisplay:YES];
}
@@ -327,6 +341,20 @@ QT_END_NAMESPACE
[self icon]->contextMenu()->hide();
[self setNeedsDisplay:YES];
+#ifndef QT_MAC_USE_COCOA
+ const short scale = GetMBarHeight()-4;
+#else
+ CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
+ const short scale = hgt - 4;
+#endif
+
+ if( down && ![self icon]->icon().isNull() ) {
+ NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale), QIcon::Selected)));
+ [self setImage: nsaltimage];
+ [nsaltimage release];
+ }
+
+
if (down)
[parent triggerSelector:self];
else if ((clickCount%2))
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index c91c608..923f2e3 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -49,6 +49,9 @@
#include "QtCore/qdatetime.h"
#include <ctype.h>
+#ifndef QT_NO_DATESTRING
+# include <stdio.h>
+#endif
QT_BEGIN_NAMESPACE
diff --git a/src/qt_install.pri b/src/qt_install.pri
index ebeac8d..5b29942 100644
--- a/src/qt_install.pri
+++ b/src/qt_install.pri
@@ -30,6 +30,12 @@ qt_install_headers {
targ_headers.files = $$INSTALL_HEADERS
targ_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET
INSTALLS += targ_headers
+
+ contains(QT_CONFIG,private_tests) {
+ private_headers.files = $$SYNCQT.PRIVATE_HEADER_FILES
+ private_headers.path = $$[QT_INSTALL_HEADERS]/$$TARGET/private
+ INSTALLS += private_headers
+ }
}
embedded:equals(TARGET, QtGui) {
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 92d29ae..5041812 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -256,6 +256,7 @@ SUBDIRS += \
qprinter \
qprinterinfo \
qprocess \
+ qprocessenvironment \
qprogressbar \
qprogressdialog \
qpropertyanimation \
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index cd58fd6..1445f5b 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -513,9 +513,11 @@ void tst_QFileInfo::canonicalFilePath()
QFileInfo info("/tmp/../../../../../../../../../../../../../../../../../");
info.canonicalFilePath();
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
// This used to crash on Mac
QFileInfo dontCrash(QLatin1String("/"));
QCOMPARE(dontCrash.canonicalFilePath(), QLatin1String("/"));
+#endif
#ifndef Q_OS_WIN
// test symlinks
diff --git a/tests/auto/qprocessenvironment/qprocessenvironment.pro b/tests/auto/qprocessenvironment/qprocessenvironment.pro
new file mode 100644
index 0000000..398facc
--- /dev/null
+++ b/tests/auto/qprocessenvironment/qprocessenvironment.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+
+QT = core
+
+SOURCES += tst_qprocessenvironment.cpp
diff --git a/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp
new file mode 100644
index 0000000..1cde33c
--- /dev/null
+++ b/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp
@@ -0,0 +1,265 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest>
+#include <QObject>
+#include <QProcessEnvironment>
+
+// Note:
+// in cross-platform tests, ALWAYS use UPPERCASE variable names
+// That's because on Windows, the variables are uppercased
+
+class tst_QProcessEnvironment: public QObject
+{
+ Q_OBJECT
+private slots:
+ void operator_eq();
+ void clearAndIsEmpty();
+ void insert();
+ void emptyNull();
+ void toStringList();
+
+ void caseSensitivity();
+ void systemEnvironment();
+ void putenv();
+};
+
+void tst_QProcessEnvironment::operator_eq()
+{
+ QProcessEnvironment e1;
+ QVERIFY(e1 == e1);
+ e1.clear();
+ QVERIFY(e1 == e1);
+
+ e1 = QProcessEnvironment();
+ QProcessEnvironment e2;
+ QVERIFY(e1 == e2);
+
+ e1.clear();
+ QVERIFY(e1 != e2);
+
+ e2.clear();
+
+ QVERIFY(e1 == e2);
+}
+
+void tst_QProcessEnvironment::clearAndIsEmpty()
+{
+ QProcessEnvironment e;
+ e.insert("FOO", "bar");
+ QVERIFY(!e.isEmpty());
+ e.clear();
+ QVERIFY(e.isEmpty());
+}
+
+void tst_QProcessEnvironment::insert()
+{
+ QProcessEnvironment e;
+ e.insert("FOO", "bar");
+ QVERIFY(!e.isEmpty());
+ QVERIFY(e.contains("FOO"));
+ QCOMPARE(e.value("FOO"), QString("bar"));
+
+ e.remove("FOO");
+ QVERIFY(!e.contains("FOO"));
+ QVERIFY(e.value("FOO").isNull());
+
+ e.clear();
+ QVERIFY(!e.contains("FOO"));
+}
+
+void tst_QProcessEnvironment::emptyNull()
+{
+ QProcessEnvironment e;
+
+ e.insert("FOO", "");
+ QVERIFY(e.contains("FOO"));
+ QVERIFY(e.value("FOO").isEmpty());
+ QVERIFY(!e.value("FOO").isNull());
+
+ e.insert("FOO", QString());
+ QVERIFY(e.contains("FOO"));
+ QVERIFY(e.value("FOO").isEmpty());
+ // don't test if it's NULL, since we shall not make a guarantee
+
+ e.remove("FOO");
+ QVERIFY(!e.contains("FOO"));
+}
+
+void tst_QProcessEnvironment::toStringList()
+{
+ QProcessEnvironment e;
+ QVERIFY(e.isEmpty());
+ QVERIFY(e.toStringList().isEmpty());
+
+ e.insert("FOO", "bar");
+ QStringList result = e.toStringList();
+ QVERIFY(!result.isEmpty());
+ QCOMPARE(result.length(), 1);
+ QCOMPARE(result.at(0), QString("FOO=bar"));
+
+ e.clear();
+ e.insert("BAZ", "");
+ result = e.toStringList();
+ QCOMPARE(result.at(0), QString("BAZ="));
+
+ e.insert("FOO", "bar");
+ e.insert("A", "bc");
+ e.insert("HELLO", "World");
+ result = e.toStringList();
+ QCOMPARE(result.length(), 4);
+
+ // order is not specified, so use contains()
+ QVERIFY(result.contains("FOO=bar"));
+ QVERIFY(result.contains("BAZ="));
+ QVERIFY(result.contains("A=bc"));
+ QVERIFY(result.contains("HELLO=World"));
+}
+
+void tst_QProcessEnvironment::caseSensitivity()
+{
+ QProcessEnvironment e;
+ e.insert("foo", "bar");
+
+#ifdef Q_OS_WIN
+ // on Windows, it's uppercased
+ QVERIFY(e.contains("foo"));
+ QVERIFY(e.contains("FOO"));
+ QVERIFY(e.contains("FoO"));
+
+ QCOMPARE(e.value("foo"), QString("bar"));
+ QCOMPARE(e.value("FOO"), QString("bar"));
+ QCOMPARE(e.value("FoO"), QString("bar"));
+
+ QStringList list = e.toStringList();
+ QCOMPARE(list.at(0), QString("FOO=bar"));
+#else
+ // otherwise, it's case sensitive
+ QVERIFY(e.contains("foo"));
+ QVERIFY(!e.contains("FOO"));
+
+ e.insert("FOO", "baz");
+ QVERIFY(e.contains("FOO"));
+ QCOMPARE(e.value("FOO"), QString("baz"));
+ QCOMPARE(e.value("foo"), QString("bar"));
+
+ QStringList list = e.toStringList();
+ QVERIFY(list.contains("foo=bar"));
+ QVERIFY(list.contains("FOO=baz"));
+#endif
+}
+
+void tst_QProcessEnvironment::systemEnvironment()
+{
+ static const char envname[] = "THIS_ENVIRONMENT_VARIABLE_HOPEFULLY_DOESNT_EXIST";
+ QByteArray path = qgetenv("PATH");
+ QByteArray nonexistant = qgetenv(envname);
+ QProcessEnvironment system = QProcessEnvironment::systemEnvironment();
+
+ QVERIFY(nonexistant.isNull());
+
+#ifdef Q_WS_WINCE
+ // Windows CE has no environment
+ QVERIFY(path.isEmpty());
+ QVERIFY(!system.contains("PATH"));
+ QVERIFY(system.isEmpty());
+#else
+ // all other system have environments
+ if (path.isEmpty())
+ QFAIL("Could not find the PATH environment variable -- please correct the test environment");
+
+ QVERIFY(system.contains("PATH"));
+ QCOMPARE(system.value("PATH"), QString::fromLocal8Bit(path));
+
+ QVERIFY(!system.contains(envname));
+
+# ifdef Q_OS_WIN
+ // check case-insensitive too
+ QVERIFY(system.contains("path"));
+ QCOMPARE(system.value("path"), QString::fromLocal8Bit(path));
+
+ QVERIFY(!system.contains(QString(envname).toLower()));
+# endif
+#endif
+}
+
+void tst_QProcessEnvironment::putenv()
+{
+#ifdef Q_WS_WINCE
+ QSKIP("Windows CE has no environment", SkipAll);
+#else
+ static const char envname[] = "WE_RE_SETTING_THIS_ENVIRONMENT_VARIABLE";
+ static bool testRan = false;
+
+ if (testRan)
+ QFAIL("You cannot run this test more than once, since we modify the environment");
+ testRan = true;
+
+ QByteArray valBefore = qgetenv(envname);
+ if (!valBefore.isNull())
+ QFAIL("The environment variable we set in the environment is already set! -- please correct the test environment");
+ QProcessEnvironment eBefore = QProcessEnvironment::systemEnvironment();
+
+ qputenv(envname, "Hello, World");
+ QByteArray valAfter = qgetenv(envname);
+ if (valAfter != "Hello, World")
+ QSKIP("Could not test: qputenv did not do its job", SkipAll);
+
+ QProcessEnvironment eAfter = QProcessEnvironment::systemEnvironment();
+
+ QVERIFY(!eBefore.contains(envname));
+ QVERIFY(eAfter.contains(envname));
+ QCOMPARE(eAfter.value(envname), QString("Hello, World"));
+
+# ifdef Q_OS_WIN
+ // check case-insensitive too
+ QString lower = envname;
+ lower = lower.toLower();
+ QVERIFY(!eBefore.contains(lower));
+ QVERIFY(eAfter.contains(lower));
+ QCOMPARE(eAfter.value(lower), QString("Hello, World"));
+# endif
+#endif
+}
+
+QTEST_MAIN(tst_QProcessEnvironment)
+
+#include "tst_qprocessenvironment.moc"
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index ed9206c..0cb08f9 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -73,6 +73,7 @@ private slots:
void forwardDeclaration2();
void memoryManagement();
void downCast();
+ void functionCallDownCast();
void upCast();
void qobjectWeakManagement();
void noSharedPointerFromWeakQObject();
@@ -503,6 +504,15 @@ void tst_QSharedPointer::downCast()
QCOMPARE(DerivedData::derivedDestructorCounter, destructorCount + 1);
}
+void functionDataByValue(QSharedPointer<Data> p) { Q_UNUSED(p); };
+void functionDataByRef(const QSharedPointer<Data> &p) { Q_UNUSED(p); };
+void tst_QSharedPointer::functionCallDownCast()
+{
+ QSharedPointer<DerivedData> p(new DerivedData());
+ functionDataByValue(p);
+ functionDataByRef(p);
+}
+
void tst_QSharedPointer::upCast()
{
QSharedPointer<Data> baseptr = QSharedPointer<Data>(new DerivedData);
diff --git a/tests/auto/qtouchevent/tst_qtouchevent.cpp b/tests/auto/qtouchevent/tst_qtouchevent.cpp
index f95a5c6..da8721c 100644
--- a/tests/auto/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/qtouchevent/tst_qtouchevent.cpp
@@ -48,6 +48,7 @@ public:
QList<QTouchEvent::TouchPoint> touchBeginPoints, touchUpdatePoints, touchEndPoints;
bool seenTouchBegin, seenTouchUpdate, seenTouchEnd;
bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd;
+ bool deleteInTouchBegin, deleteInTouchUpdate, deleteInTouchEnd;
tst_QTouchEventWidget()
: QWidget()
@@ -62,6 +63,7 @@ public:
touchEndPoints.clear();
seenTouchBegin = seenTouchUpdate = seenTouchEnd = false;
acceptTouchBegin = acceptTouchUpdate = acceptTouchEnd = true;
+ deleteInTouchBegin = deleteInTouchUpdate = deleteInTouchEnd = false;
}
bool event(QEvent *event)
@@ -74,6 +76,8 @@ public:
seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd;
touchBeginPoints = static_cast<QTouchEvent *>(event)->touchPoints();
event->setAccepted(acceptTouchBegin);
+ if (deleteInTouchBegin)
+ delete this;
break;
case QEvent::TouchUpdate:
if (!seenTouchBegin) qWarning("TouchUpdate: have not seen TouchBegin");
@@ -81,6 +85,8 @@ public:
seenTouchUpdate = seenTouchBegin && !seenTouchEnd;
touchUpdatePoints = static_cast<QTouchEvent *>(event)->touchPoints();
event->setAccepted(acceptTouchUpdate);
+ if (deleteInTouchUpdate)
+ delete this;
break;
case QEvent::TouchEnd:
if (!seenTouchBegin) qWarning("TouchEnd: have not seen TouchBegin");
@@ -88,6 +94,8 @@ public:
seenTouchEnd = seenTouchBegin && !seenTouchEnd;
touchEndPoints = static_cast<QTouchEvent *>(event)->touchPoints();
event->setAccepted(acceptTouchEnd);
+ if (deleteInTouchEnd)
+ delete this;
break;
default:
return QWidget::event(event);
@@ -102,13 +110,21 @@ public:
QList<QTouchEvent::TouchPoint> touchBeginPoints, touchUpdatePoints, touchEndPoints;
bool seenTouchBegin, seenTouchUpdate, seenTouchEnd;
bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd;
+ bool deleteInTouchBegin, deleteInTouchUpdate, deleteInTouchEnd;
+ tst_QTouchEventGraphicsItem **weakpointer;
tst_QTouchEventGraphicsItem()
- : QGraphicsItem()
+ : QGraphicsItem(), weakpointer(0)
{
reset();
}
+ ~tst_QTouchEventGraphicsItem()
+ {
+ if (weakpointer)
+ *weakpointer = 0;
+ }
+
void reset()
{
touchBeginPoints.clear();
@@ -116,6 +132,7 @@ public:
touchEndPoints.clear();
seenTouchBegin = seenTouchUpdate = seenTouchEnd = false;
acceptTouchBegin = acceptTouchUpdate = acceptTouchEnd = true;
+ deleteInTouchBegin = deleteInTouchUpdate = deleteInTouchEnd = false;
}
QRectF boundingRect() const { return QRectF(0, 0, 10, 10); }
@@ -131,6 +148,8 @@ public:
seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd;
touchBeginPoints = static_cast<QTouchEvent *>(event)->touchPoints();
event->setAccepted(acceptTouchBegin);
+ if (deleteInTouchBegin)
+ delete this;
break;
case QEvent::TouchUpdate:
if (!seenTouchBegin) qWarning("TouchUpdate: have not seen TouchBegin");
@@ -138,6 +157,8 @@ public:
seenTouchUpdate = seenTouchBegin && !seenTouchEnd;
touchUpdatePoints = static_cast<QTouchEvent *>(event)->touchPoints();
event->setAccepted(acceptTouchUpdate);
+ if (deleteInTouchUpdate)
+ delete this;
break;
case QEvent::TouchEnd:
if (!seenTouchBegin) qWarning("TouchEnd: have not seen TouchBegin");
@@ -145,6 +166,8 @@ public:
seenTouchEnd = seenTouchBegin && !seenTouchEnd;
touchEndPoints = static_cast<QTouchEvent *>(event)->touchPoints();
event->setAccepted(acceptTouchEnd);
+ if (deleteInTouchEnd)
+ delete this;
break;
default:
return QGraphicsItem::sceneEvent(event);
@@ -168,6 +191,8 @@ private slots:
void basicRawEventTranslation();
void multiPointRawEventTranslationOnTouchScreen();
void multiPointRawEventTranslationOnTouchPad();
+ void deleteInEventHandler();
+ void deleteInRawEventTranslation();
};
void tst_QTouchEvent::touchDisabledByDefault()
@@ -496,7 +521,7 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate()
res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent);
QVERIFY(res);
// the scene accepts the event, since it found an item to send the event to
- QVERIFY(touchUpdateEvent.isAccepted());
+ QVERIFY(!touchUpdateEvent.isAccepted());
QVERIFY(child.seenTouchUpdate);
QVERIFY(!root.seenTouchUpdate);
@@ -510,7 +535,7 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate()
res = QApplication::sendEvent(view.viewport(), &touchEndEvent);
QVERIFY(res);
// the scene accepts the event, since it found an item to send the event to
- QVERIFY(touchEndEvent.isAccepted());
+ QVERIFY(!touchEndEvent.isAccepted());
QVERIFY(child.seenTouchEnd);
QVERIFY(!root.seenTouchEnd);
}
@@ -1059,6 +1084,225 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
}
}
+void tst_QTouchEvent::deleteInEventHandler()
+{
+ // QWidget
+ {
+ QWidget window;
+ tst_QTouchEventWidget *child1, *child2, *child3;
+ child1 = new tst_QTouchEventWidget;
+ child2 = new tst_QTouchEventWidget;
+ child3 = new tst_QTouchEventWidget;
+ child1->setParent(&window);
+ child2->setParent(&window);
+ child3->setParent(&window);
+ child1->setAttribute(Qt::WA_AcceptTouchEvents);
+ child2->setAttribute(Qt::WA_AcceptTouchEvents);
+ child3->setAttribute(Qt::WA_AcceptTouchEvents);
+ child1->deleteInTouchBegin = true;
+ child2->deleteInTouchUpdate = true;
+ child3->deleteInTouchEnd = true;
+
+ QList<QTouchEvent::TouchPoint> touchPoints;
+ touchPoints.append(QTouchEvent::TouchPoint(0));
+ QTouchEvent touchBeginEvent(QEvent::TouchBegin,
+ QTouchEvent::TouchScreen,
+ Qt::NoModifier,
+ Qt::TouchPointPressed,
+ touchPoints);
+ QTouchEvent touchUpdateEvent(QEvent::TouchUpdate,
+ QTouchEvent::TouchScreen,
+ Qt::NoModifier,
+ Qt::TouchPointStationary,
+ touchPoints);
+ QTouchEvent touchEndEvent(QEvent::TouchEnd,
+ QTouchEvent::TouchScreen,
+ Qt::NoModifier,
+ Qt::TouchPointReleased,
+ touchPoints);
+ QWeakPointer<QWidget> p;
+ bool res;
+
+ touchBeginEvent.ignore();
+ p = child1;
+ res = QApplication::sendEvent(child1, &touchBeginEvent);
+ // event is handled, but widget should be deleted
+ QVERIFY(res && touchBeginEvent.isAccepted() && p.isNull());
+
+ touchBeginEvent.ignore();
+ p = child2;
+ res = QApplication::sendEvent(child2, &touchBeginEvent);
+ QVERIFY(res && touchBeginEvent.isAccepted() && !p.isNull());
+ touchUpdateEvent.ignore();
+ res = QApplication::sendEvent(child2, &touchUpdateEvent);
+ QVERIFY(res && touchUpdateEvent.isAccepted() && p.isNull());
+
+ touchBeginEvent.ignore();
+ p = child3;
+ res = QApplication::sendEvent(child3, &touchBeginEvent);
+ QVERIFY(res && touchBeginEvent.isAccepted() && !p.isNull());
+ touchUpdateEvent.ignore();
+ res = QApplication::sendEvent(child3, &touchUpdateEvent);
+ QVERIFY(res && touchUpdateEvent.isAccepted() && !p.isNull());
+ touchEndEvent.ignore();
+ res = QApplication::sendEvent(child3, &touchEndEvent);
+ QVERIFY(res && touchEndEvent.isAccepted() && p.isNull());
+ }
+
+ // QGraphicsView
+ {
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ tst_QTouchEventGraphicsItem *root, *child1, *child2, *child3;
+ root = new tst_QTouchEventGraphicsItem;
+ child1 = new tst_QTouchEventGraphicsItem;
+ child2 = new tst_QTouchEventGraphicsItem;
+ child3 = new tst_QTouchEventGraphicsItem;
+ child1->setParentItem(root);
+ child2->setParentItem(root);
+ child3->setParentItem(root);
+ child1->setZValue(1.);
+ child2->setZValue(0.);
+ child3->setZValue(-1.);
+ child1->setAcceptTouchEvents(true);
+ child2->setAcceptTouchEvents(true);
+ child3->setAcceptTouchEvents(true);
+ child1->deleteInTouchBegin = true;
+ child2->deleteInTouchUpdate = true;
+ child3->deleteInTouchEnd = true;
+
+ scene.addItem(root);
+ view.resize(200, 200);
+ view.fitInView(scene.sceneRect());
+
+ QTouchEvent::TouchPoint touchPoint(0);
+ touchPoint.setState(Qt::TouchPointPressed);
+ touchPoint.setPos(view.mapFromScene(child1->mapToScene(child1->boundingRect().center())));
+ touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint()));
+ touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint()));
+ QList<QTouchEvent::TouchPoint> touchPoints;
+ touchPoints.append(touchPoint);
+ QTouchEvent touchBeginEvent(QEvent::TouchBegin,
+ QTouchEvent::TouchScreen,
+ Qt::NoModifier,
+ Qt::TouchPointPressed,
+ touchPoints);
+ touchPoints[0].setState(Qt::TouchPointMoved);
+ QTouchEvent touchUpdateEvent(QEvent::TouchUpdate,
+ QTouchEvent::TouchScreen,
+ Qt::NoModifier,
+ Qt::TouchPointMoved,
+ touchPoints);
+ touchPoints[0].setState(Qt::TouchPointReleased);
+ QTouchEvent touchEndEvent(QEvent::TouchEnd,
+ QTouchEvent::TouchScreen,
+ Qt::NoModifier,
+ Qt::TouchPointReleased,
+ touchPoints);
+ bool res;
+
+ child1->weakpointer = &child1;
+ touchBeginEvent.ignore();
+ res = QApplication::sendEvent(view.viewport(), &touchBeginEvent);
+ QVERIFY(res && touchBeginEvent.isAccepted() && !child1);
+ touchUpdateEvent.ignore();
+ res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent);
+ QVERIFY(res && touchUpdateEvent.isAccepted() && !child1);
+ touchEndEvent.ignore();
+ res = QApplication::sendEvent(view.viewport(), &touchEndEvent);
+ QVERIFY(res && touchUpdateEvent.isAccepted() && !child1);
+
+ child2->weakpointer = &child2;
+ touchBeginEvent.ignore();
+ res = QApplication::sendEvent(view.viewport(), &touchBeginEvent);
+ QVERIFY(res && touchBeginEvent.isAccepted() && child2);
+ touchUpdateEvent.ignore();
+ res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent);
+ QVERIFY(res && !touchUpdateEvent.isAccepted() && !child2);
+ touchEndEvent.ignore();
+ res = QApplication::sendEvent(view.viewport(), &touchEndEvent);
+ QVERIFY(res && !touchUpdateEvent.isAccepted() && !child2);
+
+ child3->weakpointer = &child3;
+ res = QApplication::sendEvent(view.viewport(), &touchBeginEvent);
+ QVERIFY(res && touchBeginEvent.isAccepted() && child3);
+ res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent);
+ QVERIFY(res && !touchUpdateEvent.isAccepted() && child3);
+ res = QApplication::sendEvent(view.viewport(), &touchEndEvent);
+ QVERIFY(res && !touchEndEvent.isAccepted() && !child3);
+
+ delete root;
+ }
+}
+
+void tst_QTouchEvent::deleteInRawEventTranslation()
+{
+ tst_QTouchEventWidget touchWidget;
+ touchWidget.setAttribute(Qt::WA_AcceptTouchEvents);
+ touchWidget.setGeometry(100, 100, 300, 300);
+
+ tst_QTouchEventWidget *leftWidget = new tst_QTouchEventWidget;
+ leftWidget->setParent(&touchWidget);
+ leftWidget->setAttribute(Qt::WA_AcceptTouchEvents);
+ leftWidget->setGeometry(0, 100, 100, 100);
+ leftWidget->deleteInTouchBegin = true;
+ leftWidget->show();
+
+ tst_QTouchEventWidget *centerWidget = new tst_QTouchEventWidget;
+ centerWidget->setParent(&touchWidget);
+ centerWidget->setAttribute(Qt::WA_AcceptTouchEvents);
+ centerWidget->setGeometry(100, 100, 100, 100);
+ centerWidget->deleteInTouchUpdate = true;
+ centerWidget->show();
+
+ tst_QTouchEventWidget *rightWidget = new tst_QTouchEventWidget;
+ rightWidget->setParent(&touchWidget);
+ rightWidget->setAttribute(Qt::WA_AcceptTouchEvents);
+ rightWidget->setGeometry(200, 100, 100, 100);
+ rightWidget->deleteInTouchEnd = true;
+ rightWidget->show();
+
+ QPointF leftPos = leftWidget->rect().center();
+ QPointF centerPos = centerWidget->rect().center();
+ QPointF rightPos = rightWidget->rect().center();
+ QPointF leftScreenPos = leftWidget->mapToGlobal(leftPos.toPoint());
+ QPointF centerScreenPos = centerWidget->mapToGlobal(centerPos.toPoint());
+ QPointF rightScreenPos = rightWidget->mapToGlobal(rightPos.toPoint());
+ QRectF screenGeometry = qApp->desktop()->screenGeometry(&touchWidget);
+
+ QWeakPointer<QWidget> pl = leftWidget, pc = centerWidget, pr = rightWidget;
+
+ QList<QTouchEvent::TouchPoint> rawTouchPoints;
+ rawTouchPoints.append(QTouchEvent::TouchPoint(0));
+ rawTouchPoints.append(QTouchEvent::TouchPoint(1));
+ rawTouchPoints.append(QTouchEvent::TouchPoint(2));
+ rawTouchPoints[0].setState(Qt::TouchPointPressed);
+ rawTouchPoints[0].setScreenPos(leftScreenPos);
+ rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry));
+ rawTouchPoints[1].setState(Qt::TouchPointPressed);
+ rawTouchPoints[1].setScreenPos(centerScreenPos);
+ rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry));
+ rawTouchPoints[2].setState(Qt::TouchPointPressed);
+ rawTouchPoints[2].setScreenPos(rightScreenPos);
+ rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].pos(), screenGeometry));
+
+ // generate begin events on all widgets, the left widget should die
+ qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints);
+ QVERIFY(pl.isNull() && !pc.isNull() && !pr.isNull());
+
+ // generate update events on all widget, the center widget should die
+ rawTouchPoints[0].setState(Qt::TouchPointMoved);
+ rawTouchPoints[1].setState(Qt::TouchPointMoved);
+ rawTouchPoints[2].setState(Qt::TouchPointMoved);
+ qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints);
+
+ // generate end events on all widget, the right widget should die
+ rawTouchPoints[0].setState(Qt::TouchPointReleased);
+ rawTouchPoints[1].setState(Qt::TouchPointReleased);
+ rawTouchPoints[2].setState(Qt::TouchPointReleased);
+ qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints);
+}
+
QTEST_MAIN(tst_QTouchEvent)
#include "tst_qtouchevent.moc"
diff --git a/tests/manual/qwidget_zorder/main.cpp b/tests/manual/qwidget_zorder/main.cpp
new file mode 100644
index 0000000..fe8e0a2
--- /dev/null
+++ b/tests/manual/qwidget_zorder/main.cpp
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+class Widget : public QWidget
+{
+ Q_OBJECT
+public:
+ Widget()
+ {
+ QWidget *stackWidget = new QWidget;
+ stackWidget->setFixedSize(400, 300);
+ button = new QPushButton("pushbutton", stackWidget);
+ plainTextEdit = new QPlainTextEdit(stackWidget);
+ plainTextEdit->setWordWrapMode(QTextOption::NoWrap);
+ QString s = "foo bar bar foo foo bar bar foo";
+ for (int i = 0; i < 10; ++i) {
+ plainTextEdit->appendPlainText(s);
+ s.remove(1, 2);
+ }
+ calendar = new QCalendarWidget(stackWidget);
+ button->move(10, 10);
+ button->resize(100, 100);
+ plainTextEdit->move(30, 70);
+ plainTextEdit->resize(100, 100);
+ calendar->move(80, 40);
+
+ QWidget *buttonOps = new QWidget;
+ QVBoxLayout *l = new QVBoxLayout(buttonOps);
+ QPushButton *lower = new QPushButton("button: lower");
+ connect(lower, SIGNAL(clicked()), button, SLOT(lower()));
+ l->addWidget(lower);
+ QPushButton *raise = new QPushButton("button: raise");
+ connect(raise, SIGNAL(clicked()), button, SLOT(raise()));
+ l->addWidget(raise);
+
+ lower = new QPushButton("calendar: lower");
+ connect(lower, SIGNAL(clicked()), calendar, SLOT(lower()));
+ l->addWidget(lower);
+ raise = new QPushButton("calendar: raise");
+ connect(raise, SIGNAL(clicked()), calendar, SLOT(raise()));
+ l->addWidget(raise);
+ QPushButton *stackUnder = new QPushButton("calendar: stack under textedit");
+ connect(stackUnder, SIGNAL(clicked()), this, SLOT(stackCalendarUnderTextEdit()));
+ l->addWidget(stackUnder);
+
+ lower = new QPushButton("lower textedit");
+ connect(lower, SIGNAL(clicked()), plainTextEdit, SLOT(lower()));
+ l->addWidget(lower);
+ raise = new QPushButton("raise textedit");
+ connect(raise, SIGNAL(clicked()), plainTextEdit, SLOT(raise()));
+ l->addWidget(raise);
+
+ QHBoxLayout *mainLayout = new QHBoxLayout(this);
+ mainLayout->addWidget(buttonOps);
+ mainLayout->addWidget(stackWidget);
+ }
+
+private Q_SLOTS:
+ void stackCalendarUnderTextEdit()
+ {
+ calendar->stackUnder(plainTextEdit);
+ }
+
+private:
+ QPushButton *button;
+ QPlainTextEdit *plainTextEdit;
+ QCalendarWidget *calendar;
+};
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ Widget w;
+ w.show();
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/qwidget_zorder/qwidget_zorder.pro b/tests/manual/qwidget_zorder/qwidget_zorder.pro
new file mode 100644
index 0000000..5526f91
--- /dev/null
+++ b/tests/manual/qwidget_zorder/qwidget_zorder.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp