summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-04-21 14:32:54 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-04-21 14:32:54 (GMT)
commit0ed389f6d1bedb4caffde70f22efae91d70c4a90 (patch)
treee88b8ee3f9f07917b284af117b7a415a81da6040
parentc74dac2a0ef5d1b428c4da4e48fab05f9886233a (diff)
parentad0c6b17cde4a3ce0041d1a54b96ccb5a6792520 (diff)
downloadQt-0ed389f6d1bedb4caffde70f22efae91d70c4a90.zip
Qt-0ed389f6d1bedb4caffde70f22efae91d70c4a90.tar.gz
Qt-0ed389f6d1bedb4caffde70f22efae91d70c4a90.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: (22 commits) Fixes wrong QGraphicsView's viewport cursor reset. Optimize ~QObject Document that QFileSystemWatcher needs to be destroyed before ~QCoreApp Build fix for mingw Fixes keyboard shortcuts for QGraphicsTextItem. Optimize QMetaObject::activate Benchmark emission of signal connected to nothing Micro optimisations in QMutexLocker Fixed assert failure when trying to load invalid SVG file. Added QIcon::name() QDialog: user-moved dialog would not show on the same place after hide Fixed image drawing inconsistencies when drawing 1x1 images/subrects. Fixed pixel-bleeding when stretching subrected pixmaps. Fixed a crash when declaring an animation with Q_GLOBAL_STATIC Add a test to QListView to check initialisation of style option index, similar to QTreeView test. Odf export: Remove double namespace in tab-stops and fix table padding Mac: Fix off-by-one in vertical position for elided and non-elided text QX11GL: Fix bug with pixmaps drawn on multiple top-levels Use QGLContextPrivate to track attribarray enabled state. Don't crash when calling drawPixmapFragements with a null pixmap ...
-rw-r--r--src/corelib/animation/qabstractanimation.cpp77
-rw-r--r--src/corelib/animation/qabstractanimation_p.h11
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp5
-rw-r--r--src/corelib/kernel/qobject.cpp53
-rw-r--r--src/corelib/kernel/qobject_p.h28
-rw-r--r--src/corelib/thread/qmutex.h18
-rw-r--r--src/gui/dialogs/qdialog.cpp14
-rw-r--r--src/gui/dialogs/qdialog.h2
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp3
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp12
-rw-r--r--src/gui/image/qicon.cpp19
-rw-r--r--src/gui/image/qicon.h2
-rw-r--r--src/gui/image/qiconengine.cpp20
-rw-r--r--src/gui/image/qiconengine.h5
-rw-r--r--src/gui/image/qiconloader.cpp6
-rw-r--r--src/gui/kernel/qwidget.cpp6
-rw-r--r--src/gui/painting/qdrawhelper.cpp21
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp2
-rw-r--r--src/gui/painting/qpaintengineex.cpp3
-rw-r--r--src/gui/painting/qpainterpath.cpp2
-rw-r--r--src/gui/styles/qcommonstyle.cpp2
-rw-r--r--src/gui/text/qtextodfwriter.cpp12
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp6
-rw-r--r--src/opengl/qglextensions.cpp11
-rw-r--r--src/opengl/qpixmapdata_x11gl_egl.cpp19
-rw-r--r--src/src.pro2
-rw-r--r--src/svg/qsvghandler.cpp9
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp38
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp28
-rw-r--r--tests/auto/qicon/tst_qicon.cpp23
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp31
-rw-r--r--tests/benchmarks/corelib/kernel/qobject/main.cpp9
-rw-r--r--tests/benchmarks/corelib/kernel/qobject/object.cpp3
-rw-r--r--tests/benchmarks/corelib/kernel/qobject/object.h1
34 files changed, 372 insertions, 131 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 82b3003..01570ad 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -173,11 +173,12 @@ QUnifiedTimer::QUnifiedTimer() :
time.invalidate();
}
-QUnifiedTimer *QUnifiedTimer::instance()
+
+QUnifiedTimer *QUnifiedTimer::instance(bool create)
{
QUnifiedTimer *inst;
#ifndef QT_NO_THREAD
- if (!unifiedTimer()->hasLocalData()) {
+ if (create && !unifiedTimer()->hasLocalData()) {
inst = new QUnifiedTimer;
unifiedTimer()->setLocalData(inst);
} else {
@@ -190,10 +191,16 @@ QUnifiedTimer *QUnifiedTimer::instance()
return inst;
}
+QUnifiedTimer *QUnifiedTimer::instance()
+{
+ return instance(true);
+}
+
void QUnifiedTimer::ensureTimerUpdate()
{
- if (isPauseTimerActive)
- updateAnimationsTime();
+ QUnifiedTimer *inst = QUnifiedTimer::instance(false);
+ if (inst && inst->isPauseTimerActive)
+ inst->updateAnimationsTime();
}
void QUnifiedTimer::updateAnimationsTime()
@@ -219,6 +226,13 @@ void QUnifiedTimer::updateAnimationsTime()
}
}
+void QUnifiedTimer::updateAnimationTimer()
+{
+ QUnifiedTimer *inst = QUnifiedTimer::instance(false);
+ if (inst)
+ inst->restartAnimationTimer();
+}
+
void QUnifiedTimer::restartAnimationTimer()
{
if (runningLeafAnimations == 0 && !runningPauseAnimations.isEmpty()) {
@@ -269,34 +283,41 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event)
void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation, bool isTopLevel)
{
- registerRunningAnimation(animation);
+ QUnifiedTimer *inst = instance(true); //we create the instance if needed
+ inst->registerRunningAnimation(animation);
if (isTopLevel) {
Q_ASSERT(!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer);
QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = true;
- animationsToStart << animation;
- if (!startStopAnimationTimer.isActive())
- startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this);
+ inst->animationsToStart << animation;
+ if (!inst->startStopAnimationTimer.isActive())
+ inst->startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, inst);
}
}
void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation)
{
- unregisterRunningAnimation(animation);
+ QUnifiedTimer *inst = QUnifiedTimer::instance(false);
+ if (inst) {
+ //at this point the unified timer should have been created
+ //but it might also have been already destroyed in case the application is shutting down
- if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer)
- return;
+ inst->unregisterRunningAnimation(animation);
- int idx = animations.indexOf(animation);
- if (idx != -1) {
- animations.removeAt(idx);
- // this is needed if we unregister an animation while its running
- if (idx <= currentAnimationIdx)
- --currentAnimationIdx;
+ if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer)
+ return;
- if (animations.isEmpty() && !startStopAnimationTimer.isActive())
- startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this);
- } else {
- animationsToStart.removeOne(animation);
+ int idx = inst->animations.indexOf(animation);
+ if (idx != -1) {
+ inst->animations.removeAt(idx);
+ // this is needed if we unregister an animation while its running
+ if (idx <= inst->currentAnimationIdx)
+ --inst->currentAnimationIdx;
+
+ if (inst->animations.isEmpty() && !inst->startStopAnimationTimer.isActive())
+ inst->startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, inst);
+ } else {
+ inst->animationsToStart.removeOne(animation);
+ }
}
QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = false;
}
@@ -371,11 +392,11 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped;
if (oldState == QAbstractAnimation::Running) {
if (newState == QAbstractAnimation::Paused && hasRegisteredTimer)
- QUnifiedTimer::instance()->ensureTimerUpdate();
+ QUnifiedTimer::ensureTimerUpdate();
//the animation, is not running any more
- QUnifiedTimer::instance()->unregisterAnimation(q);
+ QUnifiedTimer::unregisterAnimation(q);
} else if (newState == QAbstractAnimation::Running) {
- QUnifiedTimer::instance()->registerAnimation(q, isTopLevel);
+ QUnifiedTimer::registerAnimation(q, isTopLevel);
}
q->updateState(newState, oldState);
@@ -397,7 +418,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
if (oldState == QAbstractAnimation::Stopped) {
if (isTopLevel) {
// currentTime needs to be updated if pauseTimer is active
- QUnifiedTimer::instance()->ensureTimerUpdate();
+ QUnifiedTimer::ensureTimerUpdate();
q->setCurrentTime(totalCurrentTime);
}
}
@@ -456,7 +477,7 @@ QAbstractAnimation::~QAbstractAnimation()
d->state = Stopped;
emit stateChanged(oldState, d->state);
if (oldState == QAbstractAnimation::Running)
- QUnifiedTimer::instance()->unregisterAnimation(this);
+ QUnifiedTimer::unregisterAnimation(this);
}
}
@@ -555,14 +576,14 @@ void QAbstractAnimation::setDirection(Direction direction)
// the commands order below is important: first we need to setCurrentTime with the old direction,
// then update the direction on this and all children and finally restart the pauseTimer if needed
if (d->hasRegisteredTimer)
- QUnifiedTimer::instance()->ensureTimerUpdate();
+ QUnifiedTimer::ensureTimerUpdate();
d->direction = direction;
updateDirection(direction);
if (d->hasRegisteredTimer)
// needed to update the timer interval in case of a pause animation
- QUnifiedTimer::instance()->restartAnimationTimer();
+ QUnifiedTimer::updateAnimationTimer();
emit directionChanged(direction);
}
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index 2282cdb..fcfe824 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -124,9 +124,10 @@ private:
public:
//XXX this is needed by dui
static Q_CORE_EXPORT QUnifiedTimer *instance();
+ static QUnifiedTimer *instance(bool create);
- void registerAnimation(QAbstractAnimation *animation, bool isTopLevel);
- void unregisterAnimation(QAbstractAnimation *animation);
+ static void registerAnimation(QAbstractAnimation *animation, bool isTopLevel);
+ static void unregisterAnimation(QAbstractAnimation *animation);
//defines the timing interval. Default is DEFAULT_TIMER_INTERVAL
void setTimingInterval(int interval)
@@ -151,13 +152,13 @@ public:
this is used for updating the currentTime of all animations in case the pause
timer is active or, otherwise, only of the animation passed as parameter.
*/
- void ensureTimerUpdate();
+ static void ensureTimerUpdate();
/*
this will evaluate the need of restarting the pause timer in case there is still
some pause animations running.
*/
- void restartAnimationTimer();
+ static void updateAnimationTimer();
protected:
void timerEvent(QTimerEvent *);
@@ -187,6 +188,8 @@ private:
void registerRunningAnimation(QAbstractAnimation *animation);
void unregisterRunningAnimation(QAbstractAnimation *animation);
+ void restartAnimationTimer();
+
void updateAnimationsTime();
int closestPauseAnimationTimeToFinish();
};
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index 00af3fd..18c3c9f 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -426,6 +426,11 @@ QFileSystemWatcher::QFileSystemWatcher(const QStringList &paths, QObject *parent
/*!
Destroys the file system watcher.
+
+ \note To avoid deadlocks on shutdown, all instances of QFileSystemWatcher
+ need to be destroyed before QCoreApplication. Note that passing
+ QCoreApplication::instance() as the parent object when creating
+ QFileSystemWatcher is not sufficient.
*/
QFileSystemWatcher::~QFileSystemWatcher()
{
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index c13d829..6a6db51 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -101,7 +101,7 @@ static QBasicAtomicInt objectCount = Q_BASIC_ATOMIC_INITIALIZER(0);
/** \internal
* mutex to be locked when accessing the connectionlists or the senders list
*/
-static QMutex *signalSlotLock(const QObject *o)
+static inline QMutex *signalSlotLock(const QObject *o)
{
if (!signalSlotMutexes) {
QMutexPool *mp = new QMutexPool;
@@ -393,27 +393,6 @@ void QObjectPrivate::cleanConnectionLists()
}
}
-QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver,
- Sender *sender)
-{
- Sender *previousSender = receiver->d_func()->currentSender;
- receiver->d_func()->currentSender = sender;
- return previousSender;
-}
-
-void QObjectPrivate::resetCurrentSender(QObject *receiver,
- Sender *currentSender,
- Sender *previousSender)
-{
- // ref is set to zero when this object is deleted during the metacall
- if (currentSender->ref == 1)
- receiver->d_func()->currentSender = previousSender;
- // if we've recursed, we need to tell the caller about the objects deletion
- if (previousSender)
- previousSender->ref = currentSender->ref;
-}
-
-
typedef QMultiHash<QObject *, QObject **> GuardHash;
Q_GLOBAL_STATIC(GuardHash, guardHash)
Q_GLOBAL_STATIC(QMutex, guardHashLock)
@@ -880,19 +859,14 @@ QObject::~QObject()
if (d->declarativeData)
QAbstractDeclarativeData::destroyed(d->declarativeData, this);
- {
- QMutex *signalSlotMutex = 0;
- QT_TRY {
- signalSlotMutex = signalSlotLock(this);
- } QT_CATCH(const std::bad_alloc &) {
- // out of memory - swallow to prevent a crash
- }
- QMutexLocker locker(signalSlotMutex);
+ // set ref to zero to indicate that this object has been deleted
+ if (d->currentSender != 0)
+ d->currentSender->ref = 0;
+ d->currentSender = 0;
- // set ref to zero to indicate that this object has been deleted
- if (d->currentSender != 0)
- d->currentSender->ref = 0;
- d->currentSender = 0;
+ if (d->connectionLists || d->senders) {
+ QMutex *signalSlotMutex = signalSlotLock(this);
+ QMutexLocker locker(signalSlotMutex);
// disconnect all receivers
if (d->connectionLists) {
@@ -910,7 +884,7 @@ QObject::~QObject()
}
QMutex *m = signalSlotLock(c->receiver);
- bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m);
+ bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m);
if (c->receiver) {
*c->prev = c->next;
@@ -938,7 +912,7 @@ QObject::~QObject()
QObject *sender = node->sender;
QMutex *m = signalSlotLock(sender);
node->prev = &node;
- bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m);
+ bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m);
//the node has maybe been removed while the mutex was unlocked in relock?
if (!node || node->sender != sender) {
m->unlock();
@@ -972,7 +946,8 @@ QObject::~QObject()
qt_removeObject(this);
- QCoreApplication::removePostedEvents(this);
+ if (d->postedEvents)
+ QCoreApplication::removePostedEvents(this, 0);
if (d->parent) // remove it from parent object
d->setParent_helper(0);
@@ -3231,9 +3206,9 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
argv ? argv : empty_argv);
}
- QMutexLocker locker(signalSlotLock(sender));
QThreadData *currentThreadData = QThreadData::current();
+ QMutexLocker locker(signalSlotLock(sender));
QObjectConnectionListVector *connectionLists = sender->d_func()->connectionLists;
if (!connectionLists) {
locker.unlock();
@@ -3329,7 +3304,7 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
if (connectionLists->orphaned) {
if (!connectionLists->inUse)
delete connectionLists;
- } else {
+ } else if (connectionLists->dirty) {
sender->d_func()->cleanConnectionLists();
}
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 341b3e9..4800e6a 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -156,9 +156,9 @@ public:
void removePendingChildInsertedEvents(QObject *child);
#endif
- static Sender *setCurrentSender(QObject *receiver,
+ static inline Sender *setCurrentSender(QObject *receiver,
Sender *sender);
- static void resetCurrentSender(QObject *receiver,
+ static inline void resetCurrentSender(QObject *receiver,
Sender *currentSender,
Sender *previousSender);
static int *setDeleteWatch(QObjectPrivate *d, int *newWatch);
@@ -215,9 +215,29 @@ public:
inline bool QObjectPrivate::isSignalConnected(uint signal_index) const
{
return signal_index >= sizeof(connectedSignals) * 8
+ || (connectedSignals[signal_index >> 5] & (1 << (signal_index & 0x1f))
|| qt_signal_spy_callback_set.signal_begin_callback
- || qt_signal_spy_callback_set.signal_end_callback
- || (connectedSignals[signal_index >> 5] & (1 << (signal_index & 0x1f)));
+ || qt_signal_spy_callback_set.signal_end_callback);
+}
+
+inline QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver,
+ Sender *sender)
+{
+ Sender *previousSender = receiver->d_func()->currentSender;
+ receiver->d_func()->currentSender = sender;
+ return previousSender;
+}
+
+inline void QObjectPrivate::resetCurrentSender(QObject *receiver,
+ Sender *currentSender,
+ Sender *previousSender)
+{
+ // ref is set to zero when this object is deleted during the metacall
+ if (currentSender->ref == 1)
+ receiver->d_func()->currentSender = previousSender;
+ // if we've recursed, we need to tell the caller about the objects deletion
+ if (previousSender)
+ previousSender->ref = currentSender->ref;
}
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 677412e..509f300 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -95,21 +95,23 @@ class Q_CORE_EXPORT QMutexLocker
{
public:
inline explicit QMutexLocker(QMutex *m)
- : val(reinterpret_cast<quintptr>(m))
{
- Q_ASSERT_X((val & quintptr(1u)) == quintptr(0),
+ Q_ASSERT_X((reinterpret_cast<quintptr>(m) & quintptr(1u)) == quintptr(0),
"QMutexLocker", "QMutex pointer is misaligned");
- relock();
+ if (m) {
+ m->lock();
+ val = reinterpret_cast<quintptr>(m) | quintptr(1u);
+ } else {
+ val = 0;
+ }
}
inline ~QMutexLocker() { unlock(); }
inline void unlock()
{
- if (val) {
- if ((val & quintptr(1u)) == quintptr(1u)) {
- val &= ~quintptr(1u);
- mutex()->unlock();
- }
+ if ((val & quintptr(1u)) == quintptr(1u)) {
+ val &= ~quintptr(1u);
+ mutex()->unlock();
}
}
diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp
index a6bd78a..e4f45ba 100644
--- a/src/gui/dialogs/qdialog.cpp
+++ b/src/gui/dialogs/qdialog.cpp
@@ -393,7 +393,6 @@ void QDialogPrivate::resetModalitySetByOpen()
resetModalityTo = -1;
}
-#if defined(Q_WS_WINCE) || defined(Q_WS_S60)
#ifdef Q_WS_WINCE_WM
void QDialogPrivate::_q_doneAction()
{
@@ -408,12 +407,12 @@ void QDialogPrivate::_q_doneAction()
bool QDialog::event(QEvent *e)
{
bool result = QWidget::event(e);
-#ifdef Q_WS_WINCE
+#if defined(Q_WS_WINCE)
if (e->type() == QEvent::OkRequest) {
accept();
result = true;
- }
-#else
+ } else
+#elif defined(Q_WS_S60)
if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize )) {
if (!testAttribute(Qt::WA_Moved)) {
Qt::WindowStates state = windowState();
@@ -422,11 +421,14 @@ bool QDialog::event(QEvent *e)
if (state != windowState())
setWindowState(state);
}
- }
+ } else
#endif
+ if (e->type() == QEvent::Move) {
+ setAttribute(Qt::WA_Moved, true); // as explicit as the user wants it to be
+ }
+
return result;
}
-#endif
/*!
Returns the modal dialog's result code, \c Accepted or \c Rejected.
diff --git a/src/gui/dialogs/qdialog.h b/src/gui/dialogs/qdialog.h
index 777256a..7ab0cb6 100644
--- a/src/gui/dialogs/qdialog.h
+++ b/src/gui/dialogs/qdialog.h
@@ -107,9 +107,7 @@ public Q_SLOTS:
protected:
QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = 0);
-#if defined(Q_WS_WINCE) || defined(Q_WS_S60)
bool event(QEvent *e);
-#endif
void keyPressEvent(QKeyEvent *);
void closeEvent(QCloseEvent *);
void showEvent(QShowEvent *);
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 9759b39..20ea262 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -10086,6 +10086,9 @@ bool QGraphicsTextItem::sceneEvent(QEvent *event)
#endif //QT_NO_IM
}
break;
+ case QEvent::ShortcutOverride:
+ dd->sendControlEvent(event);
+ return true;
default:
break;
}
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index a767987..114de85 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -733,11 +733,13 @@ void QGraphicsViewPrivate::_q_unsetViewportCursor()
}
// Restore the original viewport cursor.
- hasStoredOriginalCursor = false;
- if (dragMode == QGraphicsView::ScrollHandDrag)
- viewport->setCursor(Qt::OpenHandCursor);
- else
- viewport->setCursor(originalCursor);
+ if (hasStoredOriginalCursor) {
+ hasStoredOriginalCursor = false;
+ if (dragMode == QGraphicsView::ScrollHandDrag)
+ viewport->setCursor(Qt::OpenHandCursor);
+ else
+ viewport->setCursor(originalCursor);
+ }
}
#endif
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index fad51f4..bc52e99 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -879,6 +879,25 @@ QList<QSize> QIcon::availableSizes(Mode mode, State state) const
}
/*!
+ \since 4.7
+
+ Returns the name used to create the icon, if available.
+
+ Depending on the way the icon was created, it may have an associated
+ name. This is the case for icons created with fromTheme() or icons
+ using a QIconEngine which supports the QIconEngineV2::IconNameHook.
+
+ \sa fromTheme(), QIconEngine
+*/
+QString QIcon::name() const
+{
+ if (!d || !d->engine || d->engine_version < 2)
+ return QString();
+ QIconEngineV2 *engine = static_cast<QIconEngineV2*>(d->engine);
+ return engine->iconName();
+}
+
+/*!
\since 4.6
Sets the search paths for icon themes to \a paths.
diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h
index 2812703..faef07b 100644
--- a/src/gui/image/qicon.h
+++ b/src/gui/image/qicon.h
@@ -81,6 +81,8 @@ public:
QSize actualSize(const QSize &size, Mode mode = Normal, State state = Off) const;
+ QString name() const;
+
void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const;
inline void paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const
{ paint(painter, QRect(x, y, w, h), alignment, mode, state); }
diff --git a/src/gui/image/qiconengine.cpp b/src/gui/image/qiconengine.cpp
index 4c7c728..050d48d 100644
--- a/src/gui/image/qiconengine.cpp
+++ b/src/gui/image/qiconengine.cpp
@@ -183,6 +183,10 @@ void QIconEngine::addFile(const QString &/*fileName*/, const QSize &/*size*/, QI
that should be filled with icon sizes. Engines that work in terms
of a scalable, vectorial format normally return an empty list.
+ \value IconNameHook Allows to query the name used to create the
+ icon, for example when instantiating an icon using
+ QIcon::fromTheme().
+
\sa virtual_hook()
*/
@@ -301,4 +305,20 @@ QList<QSize> QIconEngineV2::availableSizes(QIcon::Mode mode, QIcon::State state)
return arg.sizes;
}
+/*!
+ \since 4.7
+
+ Returns the name used to create the engine, if available.
+
+ \note This is a helper method and the actual work is done by
+ virtual_hook() method, hence this method depends on icon engine support
+ and may not work with all icon engines.
+ */
+QString QIconEngineV2::iconName()
+{
+ QString name;
+ virtual_hook(QIconEngineV2::IconNameHook, reinterpret_cast<void*>(&name));
+ return name;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qiconengine.h b/src/gui/image/qiconengine.h
index 1f9266b..6d8b6ad 100644
--- a/src/gui/image/qiconengine.h
+++ b/src/gui/image/qiconengine.h
@@ -80,7 +80,7 @@ public:
virtual void virtual_hook(int id, void *data);
public:
- enum IconEngineHook { AvailableSizesHook = 1 };
+ enum IconEngineHook { AvailableSizesHook = 1, IconNameHook };
struct AvailableSizesArgument
{
@@ -92,6 +92,9 @@ public:
// ### Qt 5: make this function const and virtual.
QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal,
QIcon::State state = QIcon::Off);
+
+ // ### Qt 5: make this function const and virtual.
+ QString iconName();
};
QT_END_NAMESPACE
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 72ec2e8..a515ef8 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -554,6 +554,12 @@ void QIconLoaderEngine::virtual_hook(int id, void *data)
}
}
break;
+ case QIconEngineV2::IconNameHook:
+ {
+ QString &name = *reinterpret_cast<QString*>(data);
+ name = m_iconName;
+ }
+ break;
default:
QIconEngineV2::virtual_hook(id, data);
}
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 10fa4b9..046bc7f 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -7307,9 +7307,9 @@ void QWidgetPrivate::show_helper()
setVisible(false).
- \note If you are working with QDialog or its subclasses and you invoke
- the show() function after this function, the dialog will be displayed in
- its original position.
+ \note Since Qt 4.7, when calling hide() and then show() on QDialog
+ derived widgets will show on the previous (as in "Where the user moved it to")
+ position.
\sa hideEvent(), isHidden(), show(), setVisible(), isVisible(), close()
*/
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index b440fce..bfa1136 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -674,6 +674,11 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *
int image_width = data->texture.width;
int image_height = data->texture.height;
+ int image_x1 = data->texture.x1;
+ int image_y1 = data->texture.y1;
+ int image_x2 = data->texture.x2;
+ int image_y2 = data->texture.y2;
+
const qreal cx = x + 0.5;
const qreal cy = y + 0.5;
@@ -708,17 +713,17 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *
y2 = y1 + 1;
y2 %= image_height;
} else {
- if (x1 < 0) {
- x2 = x1 = 0;
- } else if (x1 >= image_width - 1) {
- x2 = x1 = image_width - 1;
+ if (x1 < image_x1) {
+ x2 = x1 = image_x1;
+ } else if (x1 >= image_x2 - 1) {
+ x2 = x1 = image_x2 - 1;
} else {
x2 = x1 + 1;
}
- if (y1 < 0) {
- y2 = y1 = 0;
- } else if (y1 >= image_height - 1) {
- y2 = y1 = image_height - 1;
+ if (y1 < image_y1) {
+ y2 = y1 = image_y1;
+ } else if (y1 >= image_y2 - 1) {
+ y2 = y1 = image_y2 - 1;
} else {
y2 = y1 + 1;
}
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 8f14583..9148ac2 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -2552,7 +2552,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
int sr_t = qFloor(sr.top());
int sr_b = qCeil(sr.bottom()) - 1;
- if (!s->flags.antialiased && sr_l == sr_r && sr_t == sr_b) {
+ if (s->matrix.type() <= QTransform::TxScale && !s->flags.antialiased && sr_l == sr_r && sr_t == sr_b) {
// as fillRect will apply the aliased coordinate delta we need to
// subtract it here as we don't use it for image drawing
QTransform old = s->matrix;
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 9366513..a78cafb 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -974,6 +974,9 @@ void QPaintEngineEx::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, con
void QPaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount,
const QPixmap &pixmap, QPainter::PixmapFragmentHints /*hints*/)
{
+ if (pixmap.isNull())
+ return;
+
qreal oldOpacity = state()->opacity;
QTransform oldTransform = state()->matrix;
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index f78de34..965b84c 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -1914,7 +1914,7 @@ static bool qt_painterpath_check_crossing(const QPainterPath *path, const QRectF
case QPainterPath::MoveToElement:
if (i > 0
- && qFuzzyCompare(last_pt.x(), last_start.y())
+ && qFuzzyCompare(last_pt.x(), last_start.x())
&& qFuzzyCompare(last_pt.y(), last_start.y())
&& qt_painterpath_isect_line_rect(last_pt.x(), last_pt.y(),
last_start.x(), last_start.y(), rect))
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index b0e2d37..8036728 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -981,7 +981,7 @@ void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewIt
qreal y = position.y() + line.y() + line.ascent();
p->save();
p->setFont(option->font);
- p->drawText(int(x), int(y), elidedText);
+ p->drawText(QPointF(x, y), elidedText);
p->restore();
break;
}
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index d369bff0..7992de5 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -493,10 +493,10 @@ void QTextOdfWriter::writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat
format.nonBreakableLines() ? QString::fromLatin1("true") : QString::fromLatin1("false"));
if (format.hasProperty(QTextFormat::TabPositions)) {
QList<QTextOption::Tab> tabs = format.tabPositions();
- writer.writeStartElement(styleNS, QString::fromLatin1("style-tab-stops"));
+ writer.writeStartElement(styleNS, QString::fromLatin1("tab-stops"));
QList<QTextOption::Tab>::Iterator iterator = tabs.begin();
while(iterator != tabs.end()) {
- writer.writeEmptyElement(styleNS, QString::fromLatin1("style-tab-stop"));
+ writer.writeEmptyElement(styleNS, QString::fromLatin1("tab-stop"));
writer.writeAttribute(styleNS, QString::fromLatin1("position"), pixelToPoint(iterator->position) );
QString type;
switch(iterator->type) {
@@ -511,7 +511,7 @@ void QTextOdfWriter::writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat
++iterator;
}
- writer.writeEndElement(); // style-tab-stops
+ writer.writeEndElement(); // tab-stops
}
writer.writeEndElement(); // paragraph-properties
@@ -698,11 +698,11 @@ void QTextOdfWriter::writeTableCellFormat(QXmlStreamWriter &writer, QTextTableCe
if (padding > 0)
writer.writeAttribute(foNS, QString::fromLatin1("padding-top"), pixelToPoint(padding));
if (format.bottomPadding() > 0)
- writer.writeAttribute(foNS, QString::fromLatin1("padding-top"), pixelToPoint(format.bottomPadding()));
+ writer.writeAttribute(foNS, QString::fromLatin1("padding-bottom"), pixelToPoint(format.bottomPadding()));
if (format.leftPadding() > 0)
- writer.writeAttribute(foNS, QString::fromLatin1("padding-top"), pixelToPoint(format.leftPadding()));
+ writer.writeAttribute(foNS, QString::fromLatin1("padding-left"), pixelToPoint(format.leftPadding()));
if (format.rightPadding() > 0)
- writer.writeAttribute(foNS, QString::fromLatin1("padding-top"), pixelToPoint(format.rightPadding()));
+ writer.writeAttribute(foNS, QString::fromLatin1("padding-right"), pixelToPoint(format.rightPadding()));
}
if (format.hasProperty(QTextFormat::TextVerticalAlignment)) {
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index c89d34f..955a129 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -573,9 +573,9 @@ void QGL2PaintEngineExPrivate::resetGLState()
glStencilMask(0xff);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glStencilFunc(GL_ALWAYS, 0, 0xff);
- glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
- glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
- glDisableVertexAttribArray(QT_OPACITY_ATTR);
+ ctx->d_func()->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, false);
+ ctx->d_func()->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, false);
+ ctx->d_func()->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false);
#ifndef QT_OPENGL_ES_2
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // color may have been changed by glVertexAttrib()
#endif
diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp
index ef3c4cd..8e2bbd4 100644
--- a/src/opengl/qglextensions.cpp
+++ b/src/opengl/qglextensions.cpp
@@ -235,11 +235,6 @@ bool qt_resolve_eglimage_gl_extensions(QGLContext *ctx)
bool qt_resolve_glsl_extensions(QGLContext *ctx)
{
- // Geometry shaders are optional...
- glProgramParameteriEXT = (_glProgramParameteriEXT) ctx->getProcAddress(QLatin1String("glProgramParameteriEXT"));
- glFramebufferTextureEXT = (_glFramebufferTextureEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureEXT"));
- glFramebufferTextureLayerEXT = (_glFramebufferTextureLayerEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureLayerEXT"));
- glFramebufferTextureFaceEXT = (_glFramebufferTextureFaceEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureFaceEXT"));
#if defined(QT_OPENGL_ES_2)
// The GLSL shader functions are always present in OpenGL/ES 2.0.
@@ -254,6 +249,12 @@ bool qt_resolve_glsl_extensions(QGLContext *ctx)
if (glCreateShader)
return true;
+ // Geometry shaders are optional...
+ glProgramParameteriEXT = (_glProgramParameteriEXT) ctx->getProcAddress(QLatin1String("glProgramParameteriEXT"));
+ glFramebufferTextureEXT = (_glFramebufferTextureEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureEXT"));
+ glFramebufferTextureLayerEXT = (_glFramebufferTextureLayerEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureLayerEXT"));
+ glFramebufferTextureFaceEXT = (_glFramebufferTextureFaceEXT) ctx->getProcAddress(QLatin1String("glFramebufferTextureFaceEXT"));
+
glCreateShader = (_glCreateShader) ctx->getProcAddress(QLatin1String("glCreateShader"));
if (glCreateShader) {
glShaderSource = (_glShaderSource) ctx->getProcAddress(QLatin1String("glShaderSource"));
diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp
index 3ab385a..4d726b6 100644
--- a/src/opengl/qpixmapdata_x11gl_egl.cpp
+++ b/src/opengl/qpixmapdata_x11gl_egl.cpp
@@ -66,7 +66,8 @@ QT_BEGIN_NAMESPACE
// different contexts:
Q_GLOBAL_STATIC(QEglContext, qt_x11gl_rgbContext);
-Q_GLOBAL_STATIC(QEglContext, qt_x11gl_argbContext)
+Q_GLOBAL_STATIC(QEglContext, qt_x11gl_argbContext);
+Q_GLOBAL_STATIC_WITH_ARGS(QGLContext, qt_x11gl_fake_shared_context, (QX11GLPixmapData::glFormat()));
QEglContext* QX11GLPixmapData::rgbContext = 0;
QEglContext* QX11GLPixmapData::argbContext = 0;
@@ -112,7 +113,13 @@ bool QX11GLPixmapData::hasX11GLPixmaps()
if (!argbContext) {
argbContext = qt_x11gl_argbContext();
argbContext->setConfig(argbConfig);
- argbContext->createContext();
+ bool success = argbContext->createContext(rgbContext);
+ if (!success) {
+ qWarning("QX11GLPixmapData - RGB & ARGB contexts aren't shared");
+ success = argbContext->createContext();
+ if (!success)
+ argbContext = rgbContext; // Might work, worth a shot at least.
+ }
}
if (!argbContext->isValid())
@@ -258,6 +265,14 @@ QPaintEngine* QX11GLPixmapData::paintEngine() const
ctx = new QGLContext(glFormat());
Q_ASSERT(ctx->d_func()->eglContext == 0);
ctx->d_func()->eglContext = hasAlphaChannel() ? argbContext : rgbContext;
+
+ // While we use a seperate QGLContext for each pixmap, the underlying QEglContext is
+ // the same. So we must use a "fake" QGLContext and fool the texture cache into thinking
+ // each pixmap's QGLContext is sharing with this central one. The only place this is
+ // going to fail is where we the underlying EGL RGB and ARGB contexts aren't sharing.
+ ctx->d_func()->sharing = true;
+ QGLContextGroup::addShare(ctx, qt_x11gl_fake_shared_context());
+
// Update the glFormat for the QGLContext:
qt_glformat_from_eglconfig(ctx->d_func()->glFormat, ctx->d_func()->eglContext->config());
}
diff --git a/src/src.pro b/src/src.pro
index c74b0ca..1c76d18 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -5,12 +5,12 @@ unset(SRC_SUBDIRS)
win32:SRC_SUBDIRS += src_winmain
symbian:SRC_SUBDIRS += src_s60main
SRC_SUBDIRS += src_corelib src_xml src_network src_sql src_testlib
-win32:SRC_SUBDIRS += src_activeqt
!symbian:contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus
!contains(QT_CONFIG, no-gui): SRC_SUBDIRS += src_gui
!wince*:!symbian:!vxworks:contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_qt3support
!wince*:!symbian-abld:!symbian-sbsv2:include(tools/tools.pro)
+win32:SRC_SUBDIRS += src_activeqt
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2): SRC_SUBDIRS += src_opengl
contains(QT_CONFIG, openvg): SRC_SUBDIRS += src_openvg
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index 038aeb4..b6e771f 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -3525,7 +3525,11 @@ void QSvgHandler::parse()
// namespaceUri is empty. The only possible strategy at
// this point is to do what everyone else seems to do and
// ignore the reported namespaceUri completely.
- startElement(xml->name().toString(), xml->attributes());
+ if (!startElement(xml->name().toString(), xml->attributes())) {
+ delete m_doc;
+ m_doc = 0;
+ return;
+ }
break;
case QXmlStreamReader::EndElement:
endElement(xml->name());
@@ -3570,6 +3574,9 @@ bool QSvgHandler::startElement(const QString &localName,
m_whitespaceMode.push(QSvgText::Default);
}
+ if (!m_doc && localName != QLatin1String("svg"))
+ return false;
+
if (FactoryMethod method = findGroupFactory(localName)) {
//group
node = method(m_doc ? m_nodes.top() : 0, attributes, this);
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 03ce45a..e2f7f18 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -62,6 +62,7 @@
#include <QVBoxLayout>
#include <QGraphicsEffect>
#include <QInputContext>
+#include <QPushButton>
#include "../../shared/util.h"
@@ -426,6 +427,7 @@ private slots:
void itemIsInFront();
void scenePosChange();
void updateMicroFocus();
+ void textItem_shortcuts();
// task specific tests below me
void task141694_textItemEnsureVisible();
@@ -10060,6 +10062,42 @@ void tst_QGraphicsItem::updateMicroFocus()
QTRY_COMPARE(ic2.nbUpdates, 0);
}
+void tst_QGraphicsItem::textItem_shortcuts()
+{
+ QWidget w;
+ QVBoxLayout l;
+ w.setLayout(&l);
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ l.addWidget(&view);
+ QPushButton b("Push Me");
+ l.addWidget(&b);
+
+ QGraphicsTextItem *item = scene.addText("Troll Text");
+ item->setFlag(QGraphicsItem::ItemIsFocusable);
+ item->setTextInteractionFlags(Qt::TextEditorInteraction);
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+
+ item->setFocus();
+ QTRY_VERIFY(item->hasFocus());
+ QVERIFY(item->textCursor().selectedText().isEmpty());
+
+ // Shortcut should work (select all)
+ QTest::keyClick(&view, Qt::Key_A, Qt::ControlModifier);
+ QTRY_COMPARE(item->textCursor().selectedText(), item->toPlainText());
+ QTextCursor tc = item->textCursor();
+ tc.clearSelection();
+ item->setTextCursor(tc);
+ QVERIFY(item->textCursor().selectedText().isEmpty());
+
+ // Shortcut should also work if the text item has the focus and another widget
+ // has the same shortcut.
+ b.setShortcut(QKeySequence("CTRL+A"));
+ QTest::keyClick(&view, Qt::Key_A, Qt::ControlModifier);
+ QTRY_COMPARE(item->textCursor().selectedText(), item->toPlainText());
+}
+
void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
{
struct Item : public QGraphicsTextItem
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 1c19fab..5e889f4 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -239,6 +239,7 @@ private slots:
void QTBUG_4151_clipAndIgnore_data();
void QTBUG_4151_clipAndIgnore();
void QTBUG_5859_exposedRect();
+ void QTBUG_7438_cursor();
};
void tst_QGraphicsView::initTestCase()
@@ -4063,5 +4064,32 @@ void tst_QGraphicsView::QTBUG_5859_exposedRect()
QCOMPARE(item.lastExposedRect, scene.lastBackgroundExposedRect);
}
+void tst_QGraphicsView::QTBUG_7438_cursor()
+{
+#ifndef QT_NO_CURSOR
+#if defined(Q_OS_WINCE)
+ QSKIP("Qt/CE does not have regular cursor support", SkipAll);
+#endif
+ QGraphicsScene scene;
+ QGraphicsItem *item = scene.addRect(QRectF(-10, -10, 20, 20));
+ item->setFlag(QGraphicsItem::ItemIsMovable);
+
+ QGraphicsView view(&scene);
+ view.setFixedSize(400, 400);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QCOMPARE(view.viewport()->cursor().shape(), QCursor().shape());
+ view.viewport()->setCursor(Qt::PointingHandCursor);
+ QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor);
+ sendMouseMove(view.viewport(), view.mapFromScene(0, 0));
+ QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor);
+ sendMousePress(view.viewport(), view.mapFromScene(0, 0));
+ QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor);
+ sendMouseRelease(view.viewport(), view.mapFromScene(0, 0));
+ QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor);
+#endif
+}
+
QTEST_MAIN(tst_QGraphicsView)
#include "tst_qgraphicsview.moc"
diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp
index fae9cc0..e68664c 100644
--- a/tests/auto/qicon/tst_qicon.cpp
+++ b/tests/auto/qicon/tst_qicon.cpp
@@ -76,6 +76,7 @@ private slots:
void svg();
void addFile();
void availableSizes();
+ void name();
void streamAvailableSizes_data();
void streamAvailableSizes();
void fromTheme();
@@ -550,6 +551,28 @@ void tst_QIcon::availableSizes()
}
}
+void tst_QIcon::name()
+{
+ {
+ // No name if icon does not come from a theme
+ QIcon icon(":/image.png");
+ QString name = icon.name();
+ QVERIFY(name.isEmpty());
+ }
+
+ {
+ // Getting the name of an icon coming from a theme should work
+ QString searchPath = QLatin1String(":/icons");
+ QIcon::setThemeSearchPaths(QStringList() << searchPath);
+ QString themeName("testtheme");
+ QIcon::setThemeName(themeName);
+
+ QIcon icon = QIcon::fromTheme("appointment-new");
+ QString name = icon.name();
+ QCOMPARE(name, QLatin1String("appointment-new"));
+ }
+}
+
void tst_QIcon::streamAvailableSizes_data()
{
QTest::addColumn<QIcon>("icon");
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index f5c32cd..330f803 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -124,6 +124,7 @@ private slots:
void taskQTBUG_2678_spacingAndWrappedText();
void taskQTBUG_5877_skippingItemInPageDownUp();
void taskQTBUG_9455_wrongScrollbarRanges();
+ void styleOptionViewItem();
};
// Testing get/set functions
@@ -1971,5 +1972,35 @@ void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges()
QCOMPARE(w.verticalScrollBar()->maximum(), w.contentsSize().height() - w.viewport()->geometry().height());
}
+void tst_QListView::styleOptionViewItem()
+{
+ class MyDelegate : public QStyledItemDelegate
+ {
+ public:
+ void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
+ {
+ QVERIFY(qstyleoption_cast<const QStyleOptionViewItemV4 *>(&option));
+ QStyleOptionViewItemV4 opt(option);
+ initStyleOption(&opt, index);
+
+ QCOMPARE(opt.index, index);
+
+ QStyledItemDelegate::paint(painter, option, index);
+ }
+ };
+
+ QListView view;
+ QStandardItemModel model;
+ view.setModel(&model);
+ MyDelegate delegate;
+ view.setItemDelegate(&delegate);
+ model.appendRow(QList<QStandardItem*>()
+ << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") );
+
+ // Run test
+ view.showMaximized();
+ QApplication::processEvents();
+}
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"
diff --git a/tests/benchmarks/corelib/kernel/qobject/main.cpp b/tests/benchmarks/corelib/kernel/qobject/main.cpp
index 7f24ebd..8d05fcd 100644
--- a/tests/benchmarks/corelib/kernel/qobject/main.cpp
+++ b/tests/benchmarks/corelib/kernel/qobject/main.cpp
@@ -69,6 +69,7 @@ void QObjectBenchmark::signal_slot_benchmark_data()
QTest::newRow("simple function") << 0;
QTest::newRow("single signal/slot") << 1;
QTest::newRow("multi signal/slot") << 2;
+ QTest::newRow("unconnected signal") << 3;
}
void QObjectBenchmark::signal_slot_benchmark()
@@ -110,9 +111,13 @@ void QObjectBenchmark::signal_slot_benchmark()
QBENCHMARK {
singleObject.emitSignal0();
}
- } else {
+ } else if (type == 2) {
QBENCHMARK {
- multiObject.emitSignal0();
+ multiObject.emitSignal0();
+ }
+ } else if (type == 3) {
+ QBENCHMARK {
+ singleObject.emitSignal1();
}
}
}
diff --git a/tests/benchmarks/corelib/kernel/qobject/object.cpp b/tests/benchmarks/corelib/kernel/qobject/object.cpp
index d775a32..3920e97 100644
--- a/tests/benchmarks/corelib/kernel/qobject/object.cpp
+++ b/tests/benchmarks/corelib/kernel/qobject/object.cpp
@@ -42,6 +42,9 @@
void Object::emitSignal0()
{ emit signal0(); }
+void Object::emitSignal1()
+{ emit signal1(); }
+
void Object::slot0()
{ }
diff --git a/tests/benchmarks/corelib/kernel/qobject/object.h b/tests/benchmarks/corelib/kernel/qobject/object.h
index 7e4933f..8f8fbe9 100644
--- a/tests/benchmarks/corelib/kernel/qobject/object.h
+++ b/tests/benchmarks/corelib/kernel/qobject/object.h
@@ -48,6 +48,7 @@ class Object : public QObject
Q_OBJECT
public:
void emitSignal0();
+ void emitSignal1();
signals:
void signal0();
void signal1();