From 970f19bdb55cd559e9ef97228d30fd52b20e39cb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 8 Dec 2009 20:28:45 +0100 Subject: Fix crash in QDBusPendingReply/QDBusReply in case of unconnected calls. If we made calls on a QDBusConnection that isn't connected, the d pointer is 0. Ensure we don't crash. Task-number: QTBUG-6571 Reviewed-by: Bradley T. Hughes --- src/dbus/qdbuspendingcall.cpp | 2 +- src/dbus/qdbuspendingreply.h | 1 + .../qdbuspendingreply/tst_qdbuspendingreply.cpp | 25 ++++++++++++++++++++++ tests/auto/qdbusreply/tst_qdbusreply.cpp | 16 ++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index d10179e..d8eb53e 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -310,7 +310,7 @@ QDBusPendingCall &QDBusPendingCall::operator=(const QDBusPendingCall &other) bool QDBusPendingCall::isFinished() const { - return d && (d->replyMessage.type() != QDBusMessage::InvalidMessage); + return !d || (d->replyMessage.type() != QDBusMessage::InvalidMessage); } void QDBusPendingCall::waitForFinished() diff --git a/src/dbus/qdbuspendingreply.h b/src/dbus/qdbuspendingreply.h index b7f54e4..4f90c98 100644 --- a/src/dbus/qdbuspendingreply.h +++ b/src/dbus/qdbuspendingreply.h @@ -188,6 +188,7 @@ public: private: inline void calculateMetaTypes() { + if (!d) return; int typeIds[Count > 0 ? Count : 1]; // use at least one since zero-sized arrays aren't valid ForEach::fillMetaTypes(typeIds); setMetaTypes(Count, typeIds); diff --git a/tests/auto/qdbuspendingreply/tst_qdbuspendingreply.cpp b/tests/auto/qdbuspendingreply/tst_qdbuspendingreply.cpp index 6398d9c..82e6389 100644 --- a/tests/auto/qdbuspendingreply/tst_qdbuspendingreply.cpp +++ b/tests/auto/qdbuspendingreply/tst_qdbuspendingreply.cpp @@ -93,6 +93,7 @@ private slots: } void init(); + void unconnected(); void simpleTypes(); void complexTypes(); void wrongTypes(); @@ -252,6 +253,30 @@ void tst_QDBusPendingReply::init() QVERIFY(iface->isValid()); } +void tst_QDBusPendingReply::unconnected() +{ + QDBusConnection con("invalid stored connection"); + QVERIFY(!con.isConnected()); + QDBusInterface iface("doesnt.matter", "/", "doesnt.matter", con); + QVERIFY(!iface.isValid()); + + QDBusPendingReply<> rvoid = iface.asyncCall("ReloadConfig"); + QVERIFY(rvoid.isFinished()); + QVERIFY(!rvoid.isValid()); + QVERIFY(rvoid.isError()); + rvoid.waitForFinished(); + QVERIFY(!rvoid.isValid()); + QVERIFY(rvoid.isError()); + + QDBusPendingReply rstring = iface.asyncCall("GetId"); + QVERIFY(rstring.isFinished()); + QVERIFY(!rstring.isValid()); + QVERIFY(rstring.isError()); + rstring.waitForFinished(); + QVERIFY(!rstring.isValid()); + QVERIFY(rstring.isError()); +} + void tst_QDBusPendingReply::simpleTypes() { QDBusPendingReply<> rvoid = iface->asyncCall("retrieveVoid"); diff --git a/tests/auto/qdbusreply/tst_qdbusreply.cpp b/tests/auto/qdbusreply/tst_qdbusreply.cpp index 9866302..e36d288 100644 --- a/tests/auto/qdbusreply/tst_qdbusreply.cpp +++ b/tests/auto/qdbusreply/tst_qdbusreply.cpp @@ -93,6 +93,7 @@ private slots: } void init(); + void unconnected(); void simpleTypes(); void complexTypes(); void wrongTypes(); @@ -236,6 +237,21 @@ void tst_QDBusReply::init() QVERIFY(iface->isValid()); } +void tst_QDBusReply::unconnected() +{ + QDBusConnection con("invalid stored connection"); + QVERIFY(!con.isConnected()); + QDBusInterface iface("doesnt.matter", "/", "doesnt.matter", con); + QVERIFY(!iface.isValid()); + + QDBusReply rvoid = iface.asyncCall("ReloadConfig"); + QVERIFY(!rvoid.isValid()); + + QDBusReply rstring = iface.asyncCall("GetId"); + QVERIFY(!rstring.isValid()); + QVERIFY(rstring.value().isEmpty()); +} + void tst_QDBusReply::simpleTypes() { QDBusReply rbool = iface->call(QDBus::BlockWithGui, "retrieveBool"); -- cgit v0.12 From 9fd117106c4c18fc5299816ab62cdaeb574b608d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 9 Dec 2009 13:36:52 +0100 Subject: Fix crash in QFontDialog::getFont() on Mac 10.4 [NSFontManager setTarget] is not available on 10.4. Rev-by: Richard Moe Gustavsen --- src/gui/dialogs/qfontdialog_mac.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm index dacb54c..b9f918f 100644 --- a/src/gui/dialogs/qfontdialog_mac.mm +++ b/src/gui/dialogs/qfontdialog_mac.mm @@ -394,7 +394,9 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) } [mFontPanel setDelegate:nil]; [[NSFontManager sharedFontManager] setDelegate:nil]; +#ifdef QT_MAC_USE_COCOA [[NSFontManager sharedFontManager] setTarget:nil]; +#endif } @end @@ -518,7 +520,9 @@ void *QFontDialogPrivate::openCocoaFontPanel(const QFont &initial, extraHeight:dialogExtraHeight]; [ourPanel setDelegate:delegate]; [[NSFontManager sharedFontManager] setDelegate:delegate]; +#ifdef QT_MAC_USE_COCOA [[NSFontManager sharedFontManager] setTarget:delegate]; +#endif setFont(delegate, initial); // hack to get correct initial layout -- cgit v0.12 From 1bbb6e4db246d7be69a7592e2e700f79d7858d5a Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Thu, 10 Sep 2009 08:49:56 +0200 Subject: Add a mkspec for selecting gcc-4.0 on Mac OS X. This has one known use case: compiling with the 10.4u SDKi on 10.6. (cherry picked from commit 855f1705ceb15c303b55fcced8b0303d90352a44) --- mkspecs/macx-g++40/Info.plist.app | 20 ++++++ mkspecs/macx-g++40/Info.plist.lib | 18 +++++ mkspecs/macx-g++40/qmake.conf | 20 ++++++ mkspecs/macx-g++40/qplatformdefs.h | 132 +++++++++++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 mkspecs/macx-g++40/Info.plist.app create mode 100644 mkspecs/macx-g++40/Info.plist.lib create mode 100644 mkspecs/macx-g++40/qmake.conf create mode 100644 mkspecs/macx-g++40/qplatformdefs.h diff --git a/mkspecs/macx-g++40/Info.plist.app b/mkspecs/macx-g++40/Info.plist.app new file mode 100644 index 0000000..393b615 --- /dev/null +++ b/mkspecs/macx-g++40/Info.plist.app @@ -0,0 +1,20 @@ + + + + + CFBundleIconFile + @ICON@ + CFBundlePackageType + APPL + CFBundleGetInfoString + Created by Qt/QMake + CFBundleSignature + @TYPEINFO@ + CFBundleExecutable + @EXECUTABLE@ + CFBundleIdentifier + com.yourcompany.@EXECUTABLE@ + NOTE + This file was generated by Qt/QMake. + + diff --git a/mkspecs/macx-g++40/Info.plist.lib b/mkspecs/macx-g++40/Info.plist.lib new file mode 100644 index 0000000..97609ed --- /dev/null +++ b/mkspecs/macx-g++40/Info.plist.lib @@ -0,0 +1,18 @@ + + + + + CFBundlePackageType + FMWK + CFBundleShortVersionString + @SHORT_VERSION@ + CFBundleGetInfoString + Created by Qt/QMake + CFBundleSignature + @TYPEINFO@ + CFBundleExecutable + @LIBRARY@ + NOTE + Please, do NOT change this file -- It was generated by Qt/QMake. + + diff --git a/mkspecs/macx-g++40/qmake.conf b/mkspecs/macx-g++40/qmake.conf new file mode 100644 index 0000000..d6fd09d --- /dev/null +++ b/mkspecs/macx-g++40/qmake.conf @@ -0,0 +1,20 @@ +#macx-g++ (different from g++.conf) + +# +# qmake configuration for macx-g++ +# +# Mac OS X + command-line compiler +# + +MAKEFILE_GENERATOR = UNIX +TEMPLATE = app +CONFIG += qt warn_on release app_bundle incremental global_init_link_order lib_version_first plugin_no_soname link_prl +QT += core gui +QMAKE_INCREMENTAL_STYLE = sublib + +QMAKE_CC = gcc-4.0 +QMAKE_CXX = g++-4.0 + +include(../common/mac-g++.conf) + +load(qt_config) diff --git a/mkspecs/macx-g++40/qplatformdefs.h b/mkspecs/macx-g++40/qplatformdefs.h new file mode 100644 index 0000000..98e5eaf --- /dev/null +++ b/mkspecs/macx-g++40/qplatformdefs.h @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** 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 qmake spec 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$ +** +****************************************************************************/ + +#ifndef QPLATFORMDEFS_H +#define QPLATFORMDEFS_H + +// Get Qt defines/settings + +#include "qglobal.h" + +// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs + +#include + + +// We are hot - unistd.h should have turned on the specific APIs we requested + + +#include +#include +#include +#include +#include +#include +#define QT_NO_LIBRARY_UNLOAD + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef QT_NO_IPV6IFNAME +#include +#endif + +#define QT_FOPEN ::fopen +#define QT_FSEEK ::fseeko +#define QT_FTELL ::ftello +#define QT_FGETPOS ::fgetpos +#define QT_FSETPOS ::fsetpos +#define QT_FPOS_T fpos_t +#define QT_OFF_T off_t + +#define QT_STATBUF struct stat +#define QT_STATBUF4TSTAT struct stat +#define QT_STAT ::stat +#define QT_FSTAT ::fstat +#define QT_LSTAT ::lstat +#define QT_STAT_REG S_IFREG +#define QT_STAT_DIR S_IFDIR +#define QT_STAT_MASK S_IFMT +#define QT_STAT_LNK S_IFLNK +#define QT_SOCKET_CONNECT ::connect +#define QT_SOCKET_BIND ::bind +#define QT_FILENO fileno +#define QT_OPEN ::open +#define QT_CLOSE ::close +#define QT_TRUNCATE ::truncate +#define QT_FTRUNCATE ::ftruncate +#define QT_LSEEK ::lseek +#define QT_READ ::read +#define QT_WRITE ::write +#define QT_ACCESS ::access +#define QT_GETCWD ::getcwd +#define QT_CHDIR ::chdir +#define QT_MKDIR ::mkdir +#define QT_RMDIR ::rmdir +#define QT_OPEN_LARGEFILE 0 +#define QT_OPEN_RDONLY O_RDONLY +#define QT_OPEN_WRONLY O_WRONLY +#define QT_OPEN_RDWR O_RDWR +#define QT_OPEN_CREAT O_CREAT +#define QT_OPEN_TRUNC O_TRUNC +#define QT_OPEN_APPEND O_APPEND + +#define QT_SIGNAL_RETTYPE void +#define QT_SIGNAL_ARGS int +#define QT_SIGNAL_IGNORE (void (*)(int))1 + +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) +#define QT_SOCKLEN_T socklen_t +#else +#define QT_SOCKLEN_T int +#endif + +#define QT_SNPRINTF ::snprintf +#define QT_VSNPRINTF ::vsnprintf + + +#endif // QPLATFORMDEFS_H -- cgit v0.12 From cd0c4934ed60a3eae12d85d93aa950e9296cdb83 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Mon, 14 Dec 2009 21:22:58 +0100 Subject: Change some examples of Webkit to create the mainwindow on the stack --- examples/webkit/fancybrowser/main.cpp | 4 ++-- examples/webkit/googlechat/main.cpp | 4 ++-- examples/webkit/previewer/main.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/webkit/fancybrowser/main.cpp b/examples/webkit/fancybrowser/main.cpp index 7f3c983..7ca862d 100644 --- a/examples/webkit/fancybrowser/main.cpp +++ b/examples/webkit/fancybrowser/main.cpp @@ -45,7 +45,7 @@ int main(int argc, char * argv[]) { QApplication app(argc, argv); - MainWindow *browser = new MainWindow; - browser->show(); + MainWindow browser; + browser.show(); return app.exec(); } diff --git a/examples/webkit/googlechat/main.cpp b/examples/webkit/googlechat/main.cpp index 6b5e11f..ca94131 100644 --- a/examples/webkit/googlechat/main.cpp +++ b/examples/webkit/googlechat/main.cpp @@ -49,7 +49,7 @@ int main(int argc, char * argv[]) QNetworkProxyFactory::setUseSystemConfiguration(true); - GoogleChat *chat = new GoogleChat; - chat->show(); + GoogleChat chat; + chat.show(); return app.exec(); } diff --git a/examples/webkit/previewer/main.cpp b/examples/webkit/previewer/main.cpp index 183b03f..1c80c19 100644 --- a/examples/webkit/previewer/main.cpp +++ b/examples/webkit/previewer/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char * argv[]) { QApplication app(argc, argv); - MainWindow *mainWindow = new MainWindow; - mainWindow->show(); + MainWindow mainWindow; + mainWindow.show(); return app.exec(); } //! [0] -- cgit v0.12 From 7a3c595421b98087da638a5e706320d0d936d828 Mon Sep 17 00:00:00 2001 From: Tristan Chabredier Date: Tue, 15 Dec 2009 10:20:29 +0100 Subject: Fix compilation on HP-UX 11.11. Error was: thread/qthread_unix.cpp: In static member function 'static int QThread::idealThreadCount()': thread/qthread_unix.cpp:325: error: aggregate 'pst_dynamic psd' has incomplete type and cannot be defined thread/qthread_unix.cpp:326: error: 'pstat_getdynamic' was not declared in this scope Task-number: QTBUG-6576 Reviewed-by: Thiago Macieira --- mkspecs/hpux-g++-64/qmake.conf | 4 ++-- mkspecs/hpux-g++-64/qplatformdefs.h | 2 +- src/corelib/thread/qthread_unix.cpp | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mkspecs/hpux-g++-64/qmake.conf b/mkspecs/hpux-g++-64/qmake.conf index 38595c9..f76bd4e 100644 --- a/mkspecs/hpux-g++-64/qmake.conf +++ b/mkspecs/hpux-g++-64/qmake.conf @@ -15,7 +15,7 @@ QMAKE_LEX = flex QMAKE_LEXFLAGS = QMAKE_YACC = yacc QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = +DA2.0W +QMAKE_CFLAGS = QMAKE_CFLAGS_DEPS = -M QMAKE_CFLAGS_WARN_ON = -Wall -W QMAKE_CFLAGS_WARN_OFF = -w @@ -51,7 +51,7 @@ QMAKE_LINK = g++ QMAKE_LINK_SHLIB = g++ QMAKE_LINK_C = gcc QMAKE_LINK_C_SHLIB = gcc -QMAKE_LFLAGS = +DA2.0W -Wl,+s -lpthread +QMAKE_LFLAGS = -Wl,+s -lpthread QMAKE_LFLAGS_RELEASE = QMAKE_LFLAGS_DEBUG = QMAKE_LFLAGS_SHLIB = -fPIC -shared diff --git a/mkspecs/hpux-g++-64/qplatformdefs.h b/mkspecs/hpux-g++-64/qplatformdefs.h index a8d06d8..ac13799 100644 --- a/mkspecs/hpux-g++-64/qplatformdefs.h +++ b/mkspecs/hpux-g++-64/qplatformdefs.h @@ -145,7 +145,7 @@ #define QT_SIGNAL_ARGS int #define QT_SIGNAL_IGNORE SIG_IGN -#define QT_SOCKLEN_T int +#define QT_SOCKLEN_T socklen_t #endif // QPLATFORMDEFS_H diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 21b5e65..0309c67 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -74,6 +74,10 @@ # endif #endif +#ifdef Q_OS_HPUX +#include +#endif + #if defined(Q_OS_MAC) # ifdef qDebug # define old_qDebug qDebug -- cgit v0.12 From 1f4a4cca0067b1d4a9784f00e41c3fc1aca1f712 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 14 Dec 2009 16:27:25 +0100 Subject: Optimisations to gesture event filtering. Now we don't filter some events through the gesture manager and use QMap instead of QHash, which seem to be a bit faster in our cases. Reviewed-by: Olivier Goffart --- src/gui/kernel/qapplication.cpp | 46 +++++++++++++++++++++++++++++++++----- src/gui/kernel/qgesturemanager.cpp | 42 +++++++++++++++++----------------- src/gui/kernel/qgesturemanager_p.h | 4 ++-- 3 files changed, 64 insertions(+), 28 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 8c63968..bd13423 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -3629,12 +3629,46 @@ bool QApplication::notify(QObject *receiver, QEvent *e) // walk through parents and check for gestures if (qt_gestureManager) { - if (receiver->isWidgetType()) { - if (qt_gestureManager->filterEvent(static_cast(receiver), e)) - return true; - } else if (QGesture *gesture = qobject_cast(receiver)) { - if (qt_gestureManager->filterEvent(gesture, e)) - return true; + switch (e->type()) { + case QEvent::Paint: + case QEvent::MetaCall: + case QEvent::DeferredDelete: + case QEvent::DragEnter: case QEvent::DragMove: case QEvent::DragLeave: + case QEvent::Drop: case QEvent::DragResponse: + case QEvent::ChildAdded: case QEvent::ChildPolished: +#ifdef QT3_SUPPORT + case QEvent::ChildInsertedRequest: + case QEvent::ChildInserted: + case QEvent::LayoutHint: +#endif + case QEvent::ChildRemoved: + case QEvent::UpdateRequest: + case QEvent::UpdateLater: + case QEvent::AccessibilityPrepare: + case QEvent::LocaleChange: + case QEvent::Style: + case QEvent::IconDrag: + case QEvent::StyleChange: + case QEvent::AccessibilityHelp: + case QEvent::AccessibilityDescription: + case QEvent::GraphicsSceneDragEnter: + case QEvent::GraphicsSceneDragMove: + case QEvent::GraphicsSceneDragLeave: + case QEvent::GraphicsSceneDrop: + case QEvent::DynamicPropertyChange: + case QEvent::NetworkReplyUpdated: + break; + default: + if (receiver->isWidgetType()) { + if (qt_gestureManager->filterEvent(static_cast(receiver), e)) + return true; + } else { + // a special case for events that go to QGesture objects. + // We pass the object to the gesture manager and it'll figure + // out if it's QGesture or not. + if (qt_gestureManager->filterEvent(receiver, e)) + return true; + } } } diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 192f9ac..d7cbebd 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -187,10 +187,8 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni #endif } - QList states = - m_objectGestures.value(QGestureManager::ObjectGesture(object, type)); // check if the QGesture for this recognizer has already been created - foreach (QGesture *state, states) { + foreach (QGesture *state, m_objectGestures.value(QGestureManager::ObjectGesture(object, type))) { if (m_gestureToRecognizer.value(state) == recognizer) return state; } @@ -215,14 +213,13 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni return state; } -bool QGestureManager::filterEventThroughContexts(const QMultiHash &contexts, QEvent *event) { QSet triggeredGestures; QSet finishedGestures; QSet newMaybeGestures; - QSet canceledGestures; QSet notGestures; // TODO: sort contexts by the gesture type and check if one of the contexts @@ -231,7 +228,7 @@ bool QGestureManager::filterEventThroughContexts(const QMultiHash::const_iterator ContextIterator; + typedef QMultiMap::const_iterator ContextIterator; for (ContextIterator cit = contexts.begin(), ce = contexts.end(); cit != ce; ++cit) { Qt::GestureType gestureType = cit.value(); QMap::const_iterator @@ -271,6 +268,9 @@ bool QGestureManager::filterEventThroughContexts(const QMultiHash startedGestures = triggeredGestures - m_activeGestures; triggeredGestures &= m_activeGestures; @@ -280,8 +280,7 @@ bool QGestureManager::filterEventThroughContexts(const QMultiHash activeToCancelGestures = m_activeGestures & notGestures; - canceledGestures += activeToCancelGestures; + QSet canceledGestures = m_activeGestures & notGestures; // start timers for new gestures in maybe state foreach (QGesture *state, newMaybeGestures) { @@ -449,14 +448,14 @@ void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) // return true if accepted (consumed) bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) { - QSet types; - QMultiHash contexts; + QMap types; + QMultiMap contexts; QWidget *w = receiver; typedef QMap::const_iterator ContextIterator; if (!w->d_func()->gestureContext.isEmpty()) { for(ContextIterator it = w->d_func()->gestureContext.begin(), e = w->d_func()->gestureContext.end(); it != e; ++it) { - types.insert(it.key()); + types.insert(it.key(), 0); contexts.insertMulti(w, it.key()); } } @@ -468,7 +467,7 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) e = w->d_func()->gestureContext.end(); it != e; ++it) { if (!(it.value() & Qt::DontStartGestureOnChildren)) { if (!types.contains(it.key())) { - types.insert(it.key()); + types.insert(it.key(), 0); contexts.insertMulti(w, it.key()); } } @@ -477,20 +476,20 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) break; w = w->parentWidget(); } - return filterEventThroughContexts(contexts, event); + return contexts.isEmpty() ? false : filterEventThroughContexts(contexts, event); } #ifndef QT_NO_GRAPHICSVIEW bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) { - QSet types; - QMultiHash contexts; + QMap types; + QMultiMap contexts; QGraphicsObject *item = receiver; if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()) { typedef QMap::const_iterator ContextIterator; for(ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { - types.insert(it.key()); + types.insert(it.key(), 0); contexts.insertMulti(item, it.key()); } } @@ -503,20 +502,23 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { if (!(it.value() & Qt::DontStartGestureOnChildren)) { if (!types.contains(it.key())) { - types.insert(it.key()); + types.insert(it.key(), 0); contexts.insertMulti(item, it.key()); } } } item = item->parentObject(); } - return filterEventThroughContexts(contexts, event); + return contexts.isEmpty() ? false : filterEventThroughContexts(contexts, event); } #endif -bool QGestureManager::filterEvent(QGesture *state, QEvent *event) +bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) { - QMultiHash contexts; + if (!m_gestureToRecognizer.contains(static_cast(receiver))) + return false; + QGesture *state = static_cast(receiver); + QMultiMap contexts; contexts.insert(state, state->gestureType()); return filterEventThroughContexts(contexts, event); } diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index 4efa10b..5329d1d 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -73,7 +73,7 @@ public: void unregisterGestureRecognizer(Qt::GestureType type); bool filterEvent(QWidget *receiver, QEvent *event); - bool filterEvent(QGesture *receiver, QEvent *event); + bool filterEvent(QObject *receiver, QEvent *event); #ifndef QT_NO_GRAPHICSVIEW bool filterEvent(QGraphicsObject *receiver, QEvent *event); #endif //QT_NO_GRAPHICSVIEW @@ -86,7 +86,7 @@ public: protected: void timerEvent(QTimerEvent *event); - bool filterEventThroughContexts(const QMultiHash &contexts, + bool filterEventThroughContexts(const QMultiMap &contexts, QEvent *event); private: -- cgit v0.12 From 44f7c1e097582a704a06ccbbf516536b88ddcd3a Mon Sep 17 00:00:00 2001 From: dka Date: Mon, 12 Oct 2009 16:25:23 +0300 Subject: Changes to support locale change event for symbian platform Subscribing to the locale change notification to be able to update the system locale whenever the user changes the current system locale. Also changed the initialization of the system locale to make construction of the QLocale object as lightweight as possible. So now the default contructor just creates a QLocale and QSystemLocale objects, but doesn't try to fill the cache in the latter with data from the system and postpones it until it is actually requested (most applications create QLocale objects on the stack and might not even use the data from the system locale, so we don't need to initialize system locale right away). Modified-by: axis Modified-by: Denis Dzyubenko Reviewed-by: Denis Dzyubenko Reviewed-by: axis --- src/corelib/kernel/qcore_symbian_p.h | 3 +- src/corelib/kernel/qcoreapplication.cpp | 10 +++ src/corelib/kernel/qcoreapplication.h | 4 ++ src/corelib/kernel/qcoreapplication_p.h | 4 ++ src/corelib/tools/qlocale.cpp | 43 +++++++++--- src/corelib/tools/qlocale_p.h | 5 +- src/corelib/tools/qlocale_symbian.cpp | 121 ++++++++++++++++++++++++++++++-- src/plugins/s60/src/qlocale_3_1.cpp | 8 +++ 8 files changed, 181 insertions(+), 17 deletions(-) diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h index f86bfd3..2ef48b5 100644 --- a/src/corelib/kernel/qcore_symbian_p.h +++ b/src/corelib/kernel/qcore_symbian_p.h @@ -139,7 +139,8 @@ enum S60PluginFuncOrdinals S60Plugin_GetLongDateFormatSpec = 3, S60Plugin_GetShortDateFormatSpec = 4, S60Plugin_LocalizedDirectoryName = 5, - S60Plugin_GetSystemDrive = 6 + S60Plugin_GetSystemDrive = 6, + S60Plugin_RefreshLocaleInfo = 7 }; Q_CORE_EXPORT TLibraryFunction qt_resolveS60PluginFunc(int ordinal); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 8a55bad..93df45d 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -69,6 +69,7 @@ # include # include "qeventdispatcher_symbian_p.h" # include "private/qcore_symbian_p.h" +# include "private/qlocale_p.h" #elif defined(Q_OS_UNIX) # if !defined(QT_NO_GLIB) # include "qeventdispatcher_glib_p.h" @@ -2601,4 +2602,13 @@ int QCoreApplication::loopLevel() \sa Q_OBJECT, QObject::tr(), QObject::trUtf8() */ +#if defined(Q_OS_SYMBIAN) +void QCoreApplicationPrivate::_q_symbianRegisterLocaleNotifier() +{ + QLocalePrivate::symbianRegisterLocaleNotifier(); +} +#endif + QT_END_NAMESPACE + +#include "moc_qcoreapplication.cpp" diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 097b8b4..152a775 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -196,6 +196,10 @@ private: static QCoreApplication *self; +#if defined(Q_OS_SYMBIAN) + Q_PRIVATE_SLOT(d_func(), void _q_symbianRegisterLocaleNotifier()) +#endif + Q_DISABLE_COPY(QCoreApplication) friend class QEventDispatcherUNIXPrivate; diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index bf43f88..39e50c4 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -122,6 +122,10 @@ public: static uint attribs; static inline bool testAttribute(uint flag) { return attribs & (1 << flag); } + +#if defined(Q_OS_SYMBIAN) + void _q_symbianRegisterLocaleNotifier(); +#endif }; QT_END_NAMESPACE diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 4a66b92..22114c2 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -129,6 +129,10 @@ inline bool isascii(int c) } #endif +#if defined(Q_OS_SYMBIAN) +void symbianUpdateSystemPrivate(); +#endif + /****************************************************************************** ** Helpers for accessing Qt locale database */ @@ -1388,7 +1392,8 @@ QSystemLocale::QSystemLocale() /*! \internal */ QSystemLocale::QSystemLocale(bool) -{ } +{ +} /*! Deletes the object. @@ -1407,16 +1412,29 @@ static const QSystemLocale *systemLocale() { if (_systemLocale) return _systemLocale; +#if defined(Q_OS_SYMBIAN) + symbianInitSystemLocale(); +#endif return QSystemLocale_globalSystemLocale(); } -void QLocalePrivate::updateSystemPrivate() +void QLocalePrivate::updateSystemPrivate(bool initialize) { const QSystemLocale *sys_locale = systemLocale(); if (!system_lp) system_lp = globalLocalePrivate(); *system_lp = *sys_locale->fallbackLocale().d(); + system_lp->m_language_id = 0; +#if defined(Q_OS_SYMBIAN) + RDebug::Print(_L("updateSystemPrivate")); +#endif + if (!initialize) + return; + +#if defined(Q_OS_SYMBIAN) + symbianUpdateSystemPrivate(); +#endif QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant()); if (!res.isNull()) system_lp->m_language_id = res.toInt(); @@ -1446,12 +1464,12 @@ void QLocalePrivate::updateSystemPrivate() } #endif -static const QLocalePrivate *systemPrivate() +static const QLocalePrivate *systemPrivate(bool initialize = true) { #ifndef QT_NO_SYSTEMLOCALE // copy over the information from the fallback locale and modify if (!system_lp || system_lp->m_language_id == 0) - QLocalePrivate::updateSystemPrivate(); + QLocalePrivate::updateSystemPrivate(initialize); return system_lp; #else @@ -1459,10 +1477,10 @@ static const QLocalePrivate *systemPrivate() #endif } -static const QLocalePrivate *defaultPrivate() +static const QLocalePrivate *defaultPrivate(bool initialize = true) { if (!default_lp) - default_lp = systemPrivate(); + default_lp = systemPrivate(initialize); return default_lp; } @@ -2169,7 +2187,7 @@ QLocale::QLocale() : v(0) { p.numberOptions = default_number_options; - p.index = localePrivateIndex(defaultPrivate()); + p.index = localePrivateIndex(defaultPrivate(false)); } /*! @@ -2199,7 +2217,7 @@ QLocale::QLocale(Language language, Country country) // If not found, should default to system if (d->languageId() == QLocale::C && language != QLocale::C) { p.numberOptions = default_number_options; - p.index = localePrivateIndex(defaultPrivate()); + p.index = localePrivateIndex(defaultPrivate(false)); } else { p.numberOptions = 0; p.index = localePrivateIndex(d); @@ -2283,6 +2301,7 @@ void QLocale::setDefault(const QLocale &locale) */ QLocale::Language QLocale::language() const { + systemPrivate(); // make sure inline data is initialized from the system. return Language(d()->languageId()); } @@ -2293,6 +2312,7 @@ QLocale::Language QLocale::language() const */ QLocale::Country QLocale::country() const { + systemPrivate(); // make sure inline data is initialized from the system. return Country(d()->countryId()); } @@ -3021,6 +3041,7 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format) cons */ QChar QLocale::decimalPoint() const { + systemPrivate(); // make sure inline data is initialized from the system. return d()->decimal(); } @@ -3031,6 +3052,7 @@ QChar QLocale::decimalPoint() const */ QChar QLocale::groupSeparator() const { + systemPrivate(); // make sure inline data is initialized from the system. return d()->group(); } @@ -3041,6 +3063,7 @@ QChar QLocale::groupSeparator() const */ QChar QLocale::percent() const { + systemPrivate(); // make sure inline data is initialized from the system. return d()->percent(); } @@ -3051,6 +3074,7 @@ QChar QLocale::percent() const */ QChar QLocale::zeroDigit() const { + systemPrivate(); // make sure inline data is initialized from the system. return d()->zero(); } @@ -3061,6 +3085,7 @@ QChar QLocale::zeroDigit() const */ QChar QLocale::negativeSign() const { + systemPrivate(); // make sure inline data is initialized from the system. return d()->minus(); } @@ -3071,6 +3096,7 @@ QChar QLocale::negativeSign() const */ QChar QLocale::positiveSign() const { + systemPrivate(); // make sure inline data is initialized from the system. return d()->plus(); } @@ -3081,6 +3107,7 @@ QChar QLocale::positiveSign() const */ QChar QLocale::exponential() const { + systemPrivate(); // make sure inline data is initialized from the system. return d()->exponential(); } diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 0123a6e..63e9e0f 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -132,7 +132,10 @@ public: CharBuff *result) const; inline char digitToCLocale(const QChar &c) const; - static void updateSystemPrivate(); + static void updateSystemPrivate(bool initialize = true); +#if defined(Q_OS_SYMBIAN) + static void symbianRegisterLocaleNotifier(); +#endif enum NumberMode { IntegerMode, DoubleStandardMode, DoubleScientificMode }; bool validateChars(const QString &str, NumberMode numMode, QByteArray *buff, int decDigits = -1) const; diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index 1273d06..c4ad67c 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -46,11 +46,95 @@ #include #include +#include +#include #include "private/qcore_symbian_p.h" - +#include "private/qcoreapplication_p.h" +#include "qlocale_p.h" +#include "qdebug.h" QT_BEGIN_NAMESPACE +class CLocaleChangeNotifier : public CActive +{ +public: + static CLocaleChangeNotifier *NewL(); + ~CLocaleChangeNotifier(); + +private: + CLocaleChangeNotifier(); + void ConstructL(); + void RunL(); + void DoCancel(); + +private: + RChangeNotifier changeNotifier; +}; + +static CLocaleChangeNotifier *qt_changeNotifier = NULL; + +CLocaleChangeNotifier *CLocaleChangeNotifier::NewL() +{ + CLocaleChangeNotifier *self = new (ELeave) CLocaleChangeNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; +} + +CLocaleChangeNotifier::CLocaleChangeNotifier() + : CActive(CActive::EPriorityStandard) +{ +} + + +CLocaleChangeNotifier::~CLocaleChangeNotifier() +{ + Cancel(); + changeNotifier.Close(); +} + +void CLocaleChangeNotifier::ConstructL() +{ + changeNotifier.Create(); + CActiveScheduler::Add(this); + SetActive(); +} + +void CLocaleChangeNotifier::DoCancel() +{ + changeNotifier.LogonCancel(); +} + +void CLocaleChangeNotifier::RunL() +{ + SetActive(); + if (changeNotifier.Logon(iStatus) == KErrNone) { + if (iStatus.Int() == EChangesLocale) { + RDebug::Print(_L("notifier:locale changed")); + QT_TRYCATCH_LEAVING(QLocalePrivate::updateSystemPrivate()); + } else { + RDebug::Print(_L("notifier:something else changed")); + } + } else { + RDebug::Print(_L("notifier:logon failed")); + } +} + +static void qt_cleanupLocaleNotifier() +{ + delete qt_changeNotifier; + qt_changeNotifier = NULL; +} + +void QLocalePrivate::symbianRegisterLocaleNotifier() +{ + if (!qt_changeNotifier) { + QT_TRAP_THROWING(qt_changeNotifier = CLocaleChangeNotifier::NewL()); + qAddPostRoutine(qt_cleanupLocaleNotifier); + } +} + // Located in qlocale.cpp extern void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Country &cntry); @@ -65,6 +149,7 @@ static FormatFunc ptrTimeFormatL = NULL; static FormatSpecFunc ptrGetTimeFormatSpec = NULL; static FormatSpecFunc ptrGetLongDateFormatSpec = NULL; static FormatSpecFunc ptrGetShortDateFormatSpec = NULL; +static FormatSpecFunc ptrRefreshLocaleInfo = NULL; // Default functions if functions cannot be resolved static void defaultTimeFormatL(TTime&, TDes& des, const TDesC&, const TLocale&) @@ -214,6 +299,8 @@ static const char *jp_locale_dep[] = { */ static QString s60ToQtFormat(const QString &sys_fmt) { + RDebug::Print(_L("Time Format \"%S\""), &timeFormat); + TLocale *locale = _s60Locale.GetLocale(); QString result; @@ -679,6 +766,8 @@ static QString symbianDateFormat(bool short_format) dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale)); } + RDebug::Print(_L("symDateFormat: \"%S\""), &dateFormat); + return s60ToQtFormat(qt_TDesC2QString(dateFormat)); } @@ -688,6 +777,8 @@ static QString symbianDateFormat(bool short_format) */ static QString symbianTimeFormat() { + TPtrC timeFormat = ptrGetTimeFormatSpec(_s60Locale); + RDebug::Print(_L("symTimeFormat: \"%S\""), &timeFormat); return s60ToQtFormat(qt_TDesC2QString(ptrGetTimeFormatSpec(_s60Locale))); } @@ -771,22 +862,35 @@ static QLocale::MeasurementSystem symbianMeasurementSystem() return QLocale::MetricSystem; } -QLocale QSystemLocale::fallbackLocale() const +void symbianUpdateSystemPrivate() { + RDebug::Print(_L("symbianUpdateSystemPrivate")); // load system data before query calls + _s60Locale.LoadSystemSettings(); + if (ptrRefreshLocaleInfo) + ptrRefreshLocaleInfo(); +} + +void symbianInitSystemLocale() +{ + RDebug::Print(_L("symbianInitSystemLocale")); static QBasicAtomicInt initDone = Q_BASIC_ATOMIC_INITIALIZER(0); if (initDone.testAndSetRelaxed(0, 1)) { - _s60Locale.LoadSystemSettings(); + if (!qt_changeNotifier) { + QMetaObject::invokeMethod(qApp, SLOT(_q_symbianRegisterLocaleNotifier()), Qt::AutoConnection); + } // Initialize platform version dependent function pointers ptrTimeFormatL = reinterpret_cast - (qt_resolveS60PluginFunc(S60Plugin_TimeFormatL)); + (qt_resolveS60PluginFunc(S60Plugin_TimeFormatL)); ptrGetTimeFormatSpec = reinterpret_cast - (qt_resolveS60PluginFunc(S60Plugin_GetTimeFormatSpec)); + (qt_resolveS60PluginFunc(S60Plugin_GetTimeFormatSpec)); ptrGetLongDateFormatSpec = reinterpret_cast - (qt_resolveS60PluginFunc(S60Plugin_GetLongDateFormatSpec)); + (qt_resolveS60PluginFunc(S60Plugin_GetLongDateFormatSpec)); ptrGetShortDateFormatSpec = reinterpret_cast - (qt_resolveS60PluginFunc(S60Plugin_GetShortDateFormatSpec)); + (qt_resolveS60PluginFunc(S60Plugin_GetShortDateFormatSpec)); + ptrRefreshLocaleInfo = reinterpret_cast + (qt_resolveS60PluginFunc(S60Plugin_RefreshLocaleInfo)); if (!ptrTimeFormatL) ptrTimeFormatL = &defaultTimeFormatL; if (!ptrGetTimeFormatSpec) @@ -801,7 +905,10 @@ QLocale QSystemLocale::fallbackLocale() const } while(initDone != 2) QThread::yieldCurrentThread(); +} +QLocale QSystemLocale::fallbackLocale() const +{ TLanguage lang = User::Language(); QString locale = QLatin1String(qt_symbianLocaleName(lang)); return QLocale(locale); diff --git a/src/plugins/s60/src/qlocale_3_1.cpp b/src/plugins/s60/src/qlocale_3_1.cpp index beeee7f..d597861 100644 --- a/src/plugins/s60/src/qlocale_3_1.cpp +++ b/src/plugins/s60/src/qlocale_3_1.cpp @@ -50,6 +50,7 @@ _LIT(KLocaleIndependent, "%F"); static TBuf<10> dateFormat; static TBuf<10> timeFormat; +#define _DEBUG static void initialiseDateFormat() { if(dateFormat.Length()) @@ -146,3 +147,10 @@ EXPORT_C TPtrC defaultGetShortDateFormatSpec(TExtendedLocale&) initialiseDateFormat(); return TPtrC(dateFormat); } + +EXPORT_C void refreshLocaleInfo() +{ + // clear the buffers, so next time we re-read data from the system. + dateFormat.Zero(); + timeFormat.Zero(); +} -- cgit v0.12 From 66d28ef6125294113d6f9b04abdc10d935d0f4b5 Mon Sep 17 00:00:00 2001 From: miniak Date: Tue, 15 Dec 2009 10:38:07 +0100 Subject: Allow the WM_TASKBARCREATED message through the UIPI filter on Windows Vista and higher This is necessary to allow Windows Explorer send the WM_TASKBARCREATED message to a Qt application (to recreate its QSystemTrayIcon-s) even when it is running in a higher UIPI privilege level. Merge-request: 1626 Reviewed-by: Denis Dzyubenko Reviewed-by: Prasanth Ullattil --- src/gui/util/qsystemtrayicon_win.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp index 362be5b..474555b 100644 --- a/src/gui/util/qsystemtrayicon_win.cpp +++ b/src/gui/util/qsystemtrayicon_win.cpp @@ -83,7 +83,11 @@ struct Q_NOTIFYICONIDENTIFIER { GUID guidItem; }; +#define Q_MSGFLT_ALLOW 1 + typedef HRESULT (WINAPI *PtrShell_NotifyIconGetRect)(const Q_NOTIFYICONIDENTIFIER* identifier, RECT* iconLocation); +typedef BOOL (WINAPI *PtrChangeWindowMessageFilter)(UINT message, DWORD dwFlag); +typedef BOOL (WINAPI *PtrChangeWindowMessageFilterEx)(HWND hWnd, UINT message, DWORD action, void* pChangeFilterStruct); class QSystemTrayIconSys : QWidget { @@ -143,6 +147,23 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object) if (!MYWM_TASKBARCREATED) { MYWM_TASKBARCREATED = RegisterWindowMessage(L"TaskbarCreated"); } + + // Allow the WM_TASKBARCREATED message through the UIPI filter on Windows Vista and higher + static PtrChangeWindowMessageFilterEx pChangeWindowMessageFilterEx = + (PtrChangeWindowMessageFilterEx)QLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilterEx"); + + if (pChangeWindowMessageFilterEx) { + // Call the safer ChangeWindowMessageFilterEx API if available + pChangeWindowMessageFilterEx(winId(), MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW, 0); + } else { + static PtrChangeWindowMessageFilter pChangeWindowMessageFilter = + (PtrChangeWindowMessageFilter)QLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilter"); + + if (pChangeWindowMessageFilter) { + // Call the deprecated ChangeWindowMessageFilter API otherwise + pChangeWindowMessageFilter(MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW); + } + } } QSystemTrayIconSys::~QSystemTrayIconSys() -- cgit v0.12 From 9f8d3a39606abc3888fb9f19594b7db54f5306be Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 15 Dec 2009 10:29:27 +0100 Subject: Calling removeToolBar() on native Mac toolbars (Cocoa) causes crash. The hash and the list which stores the references are already cleared by the delegate function toolbarDidRemoveItem: There is no need to remove them manually after a call to [NSToolbar removeItemAtIndex]. Task-number: QTBUG-6200 Reviewed-by: Richard Moe Gustavsen --- src/gui/widgets/qmainwindowlayout_mac.mm | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm index 8d8ffa7..6d50678 100644 --- a/src/gui/widgets/qmainwindowlayout_mac.mm +++ b/src/gui/widgets/qmainwindowlayout_mac.mm @@ -463,9 +463,6 @@ void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar) NSToolbarItem *item = static_cast(it.key()); [[qt_mac_window_for(layoutState.mainWindow->window()) toolbar] removeItemAtIndex:toolbarItemsCopy.indexOf(item)]; - // In Carbon this hash and list gets emptied via events. In Cocoa, we have to do it ourselves here. - it = unifiedToolbarHash.erase(it); - qtoolbarsInUnifiedToolbarList.removeAll(toolbar); #endif break; } -- cgit v0.12 From acaaf55b118322d7edc80e401b20187cf6251683 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 15 Dec 2009 17:05:35 +0100 Subject: doc: Final fix. Example image links now display the image. Task-number: QTBUG-4484 --- tools/qdoc3/generator.cpp | 42 +++++++++++++++++++++++++++++++++++++++++- tools/qdoc3/generator.h | 2 ++ tools/qdoc3/htmlgenerator.cpp | 4 ++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/tools/qdoc3/generator.cpp b/tools/qdoc3/generator.cpp index 95319ca..56fca06 100644 --- a/tools/qdoc3/generator.cpp +++ b/tools/qdoc3/generator.cpp @@ -65,6 +65,8 @@ QMap Generator::imgFileExts; QSet Generator::outputFormats; QStringList Generator::imageFiles; QStringList Generator::imageDirs; +QStringList Generator::exampleDirs; +QStringList Generator::exampleImgExts; QString Generator::outDir; QString Generator::project; @@ -120,12 +122,19 @@ void Generator::initialize(const Config &config) if (!dirInfo.mkdir(outDir + "/images")) config.lastLocation().fatal(tr("Cannot create output directory '%1'") .arg(outDir + "/images")); + if (!dirInfo.mkdir(outDir + "/images/used-in-examples")) + config.lastLocation().fatal(tr("Cannot create output directory '%1'") + .arg(outDir + "/images/used-in-examples")); } imageFiles = config.getStringList(CONFIG_IMAGES); imageDirs = config.getStringList(CONFIG_IMAGEDIRS); + exampleDirs = config.getStringList(CONFIG_EXAMPLEDIRS); + exampleImgExts = config.getStringList(CONFIG_EXAMPLES + Config::dot + + CONFIG_IMAGEEXTENSIONS); - QString imagesDotFileExtensions = CONFIG_IMAGES + Config::dot + CONFIG_FILEEXTENSIONS; + QString imagesDotFileExtensions = + CONFIG_IMAGES + Config::dot + CONFIG_FILEEXTENSIONS; QSet formats = config.subVars(imagesDotFileExtensions); QSet::ConstIterator f = formats.begin(); while (f != formats.end()) { @@ -530,6 +539,13 @@ void Generator::generateInheritedBy(const ClassNode *classe, } } +/*! + This function is called when the documentation for an + example is being formatted. It outputs the list of source + files comprising the example, and the list of images used + by the example. The images are copied into a subtree of + \c{...doc/html/images/used-in-examples/...} + */ void Generator::generateFileList(const FakeNode* fake, CodeMarker* marker, Node::SubType subtype, @@ -546,6 +562,30 @@ void Generator::generateFileList(const FakeNode* fake, if (child->subType() == subtype) { ++count; QString file = child->name(); + if (subtype == Node::Image) { + if (!file.isEmpty()) { + QDir dirInfo; + QString userFriendlyFilePath; + QString srcPath = Config::findFile(fake->location(), + QStringList(), + exampleDirs, + file, + exampleImgExts, + userFriendlyFilePath); + userFriendlyFilePath.truncate(userFriendlyFilePath.lastIndexOf('/')); + + QString imgOutDir = outDir + "/images/used-in-examples/" + userFriendlyFilePath; + if (!dirInfo.mkpath(imgOutDir)) + fake->location().fatal(tr("Cannot create output directory '%1'") + .arg(imgOutDir)); + + QString imgOutName = Config::copyFile(fake->location(), + srcPath, + file, + imgOutDir); + } + + } openedList.next(); text << Atom(Atom::ListItemNumber, openedList.numberString()) diff --git a/tools/qdoc3/generator.h b/tools/qdoc3/generator.h index 7667789..cc1ea25 100644 --- a/tools/qdoc3/generator.h +++ b/tools/qdoc3/generator.h @@ -183,6 +183,8 @@ class Generator static QSet outputFormats; static QStringList imageFiles; static QStringList imageDirs; + static QStringList exampleDirs; + static QStringList exampleImgExts; static QString outDir; static QString project; }; diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 8711c6b..ae7bd81 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -3429,6 +3429,8 @@ QString HtmlGenerator::fileName(const Node *node) if (node->type() == Node::Fake) { if (static_cast(node)->subType() == Node::ExternalPage) return node->name(); + if (static_cast(node)->subType() == Node::Image) + return node->name(); } return PageGenerator::fileName(node); } @@ -4000,6 +4002,8 @@ QString HtmlGenerator::getLink(const Atom *atom, if (path.isEmpty()) { link = linkForNode(*node, relative); + if (*node && (*node)->subType() == Node::Image) + link = "images/used-in-examples/" + link; if (targetAtom) link += "#" + refForAtom(targetAtom, *node); } -- cgit v0.12