summaryrefslogtreecommitdiffstats
path: root/src/gui/util
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-08-04 11:17:47 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-08-04 11:17:47 (GMT)
commitbe212bf108e71ba3b5b75802b1f4de6613ba315c (patch)
treec541ad12e8698f04e8fe386c2e1b94e8baca6c1b /src/gui/util
parent67ae1b0dac175f48875507f3187ed49276a29ddf (diff)
parente6bb00250b321b149dd80259dc4f479088d5949b (diff)
downloadQt-be212bf108e71ba3b5b75802b1f4de6613ba315c.zip
Qt-be212bf108e71ba3b5b75802b1f4de6613ba315c.tar.gz
Qt-be212bf108e71ba3b5b75802b1f4de6613ba315c.tar.bz2
Merge commit 'origin/master'
Conflicts: src/corelib/global/qglobal.h src/corelib/kernel/qmetatype.cpp src/corelib/kernel/qobject.cpp src/corelib/thread/qthread_unix.cpp src/gui/graphicsview/qgraphicssceneevent.h src/gui/itemviews/qheaderview.h src/gui/kernel/qapplication_qws.cpp src/gui/kernel/qgesture.h src/gui/kernel/qgesturerecognizer.h src/gui/painting/qpaintengine_raster.cpp src/network/access/qhttpnetworkreply.cpp src/network/access/qnetworkcookie.h src/network/socket/qnativesocketengine_unix.cpp
Diffstat (limited to 'src/gui/util')
-rw-r--r--src/gui/util/qcompleter.cpp7
-rw-r--r--src/gui/util/qcompleter.h2
-rw-r--r--src/gui/util/qcompleter_p.h5
-rw-r--r--src/gui/util/qdesktopservices.cpp4
-rw-r--r--src/gui/util/qdesktopservices_s60.cpp149
-rw-r--r--src/gui/util/qsystemtrayicon.h2
-rw-r--r--src/gui/util/qundogroup.h2
-rw-r--r--src/gui/util/qundostack.h2
-rw-r--r--src/gui/util/qundoview.h2
9 files changed, 99 insertions, 76 deletions
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
index b823100..80678aa 100644
--- a/src/gui/util/qcompleter.cpp
+++ b/src/gui/util/qcompleter.cpp
@@ -158,7 +158,7 @@ QT_BEGIN_NAMESPACE
QCompletionModel::QCompletionModel(QCompleterPrivate *c, QObject *parent)
: QAbstractProxyModel(*new QCompletionModelPrivate, parent),
- c(c), engine(0), showAll(false)
+ c(c), showAll(false)
{
createEngine();
}
@@ -208,11 +208,10 @@ void QCompletionModel::createEngine()
break;
}
- delete engine;
if (sortedEngine)
- engine = new QSortedModelEngine(c);
+ engine.reset(new QSortedModelEngine(c));
else
- engine = new QUnsortedModelEngine(c);
+ engine.reset(new QUnsortedModelEngine(c));
}
QModelIndex QCompletionModel::mapToSource(const QModelIndex& index) const
diff --git a/src/gui/util/qcompleter.h b/src/gui/util/qcompleter.h
index a419154..ac8c0c6 100644
--- a/src/gui/util/qcompleter.h
+++ b/src/gui/util/qcompleter.h
@@ -154,7 +154,7 @@ Q_SIGNALS:
private:
Q_DISABLE_COPY(QCompleter)
- Q_DECLARE_PRIVATE(QCompleter)
+ Q_DECLARE_SCOPED_PRIVATE(QCompleter)
Q_PRIVATE_SLOT(d_func(), void _q_complete(QModelIndex))
Q_PRIVATE_SLOT(d_func(), void _q_completionSelected(const QItemSelection&))
diff --git a/src/gui/util/qcompleter_p.h b/src/gui/util/qcompleter_p.h
index 288f531..745afff 100644
--- a/src/gui/util/qcompleter_p.h
+++ b/src/gui/util/qcompleter_p.h
@@ -214,7 +214,6 @@ class QCompletionModel : public QAbstractProxyModel
public:
QCompletionModel(QCompleterPrivate *c, QObject *parent);
- ~QCompletionModel() { delete engine; }
void createEngine();
void setFiltered(bool);
@@ -237,10 +236,10 @@ public:
QModelIndex mapFromSource(const QModelIndex& sourceIndex) const;
QCompleterPrivate *c;
- QCompletionEngine *engine;
+ QScopedPointer<QCompletionEngine> engine;
bool showAll;
- Q_DECLARE_PRIVATE(QCompletionModel)
+ Q_DECLARE_SCOPED_PRIVATE(QCompletionModel)
signals:
void rowsAdded();
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp
index eb2d92e..18a0a73 100644
--- a/src/gui/util/qdesktopservices.cpp
+++ b/src/gui/util/qdesktopservices.cpp
@@ -287,10 +287,10 @@ void QDesktopServices::unsetUrlHandler(const QString &scheme)
\note The storage location returned can be a directory that does not exist; i.e., it
may need to be created by the system or the user.
-
+
\note On Symbian OS, DataLocation and ApplicationsLocation always point to appropriate
folder on same drive with executable. FontsLocation always points to folder on ROM drive.
- Rest of the standard locations point to folder on same drive with executable, except
+ Rest of the standard locations point to folder on same drive with executable, except
that if executable is in ROM the folder from C drive is returned.
\note On Mac OS X, DataLocation does not include QCoreApplication::organizationName.
diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp
index 77cf254..565dd6e 100644
--- a/src/gui/util/qdesktopservices_s60.cpp
+++ b/src/gui/util/qdesktopservices_s60.cpp
@@ -74,8 +74,31 @@ _LIT(KBrowserPrefix, "4 " );
_LIT(KFontsDir, "z:\\resource\\Fonts\\");
const TUid KUidBrowser = { 0x10008D39 };
-static void handleMailtoSchemeL(const QUrl &url)
+template<class R>
+class QAutoClose
{
+public:
+ QAutoClose(R& aObj) : mPtr(&aObj) {}
+ ~QAutoClose()
+ {
+ if (mPtr)
+ mPtr->Close();
+ }
+ void Forget()
+ {
+ mPtr = 0;
+ }
+private:
+ QAutoClose(const QAutoClose&);
+ QAutoClose& operator=(const QAutoClose&);
+private:
+ R* mPtr;
+};
+
+static void handleMailtoSchemeLX(const QUrl &url)
+{
+ // this function has many intermingled leaves and throws. Qt and Symbian objects do not have
+ // destructor dependencies, and cleanup object is used to prevent cleanup stack dependency on stack.
QString recipient = url.path();
QString subject = url.queryItemValue("subject");
QString body = url.queryItemValue("body");
@@ -84,15 +107,15 @@ static void handleMailtoSchemeL(const QUrl &url)
QString bcc = url.queryItemValue("bcc");
// these fields might have comma separated addresses
- QStringList recipients = recipient.split(",");
- QStringList tos = to.split(",");
- QStringList ccs = cc.split(",");
- QStringList bccs = bcc.split(",");
+ QStringList recipients = recipient.split(",", QString::SkipEmptyParts);
+ QStringList tos = to.split(",", QString::SkipEmptyParts);
+ QStringList ccs = cc.split(",", QString::SkipEmptyParts);
+ QStringList bccs = bcc.split(",", QString::SkipEmptyParts);
- RSendAs sendAs;
- User::LeaveIfError(sendAs.Connect());
- CleanupClosePushL(sendAs);
+ RSendAs sendAs;
+ User::LeaveIfError(sendAs.Connect());
+ QAutoClose<RSendAs> sendAsCleanup(sendAs);
CSendAsAccounts* accounts = CSendAsAccounts::NewL();
@@ -101,60 +124,57 @@ static void handleMailtoSchemeL(const QUrl &url)
TInt count = accounts->Count();
CleanupStack::PopAndDestroy(accounts);
- if(!count) {
+ if(!count) {
// TODO: we should try to create account if count == 0
// CSendUi would provide account creation service for us, but it requires ridicilous
// capabilities: LocalServices NetworkServices ReadDeviceData ReadUserData WriteDeviceData WriteUserData
- User::Leave(KErrNotSupported);
- } else {
- RSendAsMessage sendAsMessage;
+ User::Leave(KErrNotSupported);
+ } else {
+ RSendAsMessage sendAsMessage;
sendAsMessage.CreateL(sendAs, KUidMsgTypeSMTP);
- CleanupClosePushL(sendAsMessage);
-
-
+ QAutoClose<RSendAsMessage> sendAsMessageCleanup(sendAsMessage);
+
+
// Subject
sendAsMessage.SetSubjectL(qt_QString2TPtrC(subject));
-
+
// Body
sendAsMessage.SetBodyTextL(qt_QString2TPtrC(body));
-
+
// To
foreach(QString item, recipients)
sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo );
-
+
foreach(QString item, tos)
sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo );
-
+
// Cc
foreach(QString item, ccs)
sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientCc );
-
+
// Bcc
foreach(QString item, bccs)
sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientBcc );
-
+
// send the message
sendAsMessage.LaunchEditorAndCloseL();
-
- // sendAsMessage (already closed)
- CleanupStack::Pop();
- }
- // sendAs
- CleanupStack::PopAndDestroy();
+ // sendAsMessage is already closed
+ sendAsMessageCleanup.Forget();
+ }
}
static bool handleMailtoScheme(const QUrl &url)
{
- TRAPD(err, handleMailtoSchemeL(url));
+ TRAPD(err, QT_TRYCATCH_LEAVING(handleMailtoSchemeLX(url)));
return err ? false : true;
}
static void handleOtherSchemesL(const TDesC& aUrl)
{
// Other schemes are at the moment passed to WEB browser
- HBufC* buf16 = HBufC::NewLC( aUrl.Length() + KBrowserPrefix.iTypeLength );
- buf16->Des().Copy( KBrowserPrefix ); // Prefix used to launch correct browser view
- buf16->Des().Append( aUrl );
+ HBufC* buf16 = HBufC::NewLC( aUrl.Length() + KBrowserPrefix.iTypeLength );
+ buf16->Des().Copy( KBrowserPrefix ); // Prefix used to launch correct browser view
+ buf16->Des().Append( aUrl );
TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
TApaTask task = taskList.FindApp( KUidBrowser );
@@ -169,12 +189,12 @@ static void handleOtherSchemesL(const TDesC& aUrl)
else
{
// Start a new browser instance
- RApaLsSession appArcSession;
- User::LeaveIfError( appArcSession.Connect() );
- CleanupClosePushL<RApaLsSession>( appArcSession );
- TThreadId id;
+ RApaLsSession appArcSession;
+ User::LeaveIfError( appArcSession.Connect() );
+ CleanupClosePushL<RApaLsSession>( appArcSession );
+ TThreadId id;
appArcSession.StartDocument( *buf16, KUidBrowser , id );
- CleanupStack::PopAndDestroy(); // appArcSession
+ CleanupStack::PopAndDestroy(); // appArcSession
}
CleanupStack::PopAndDestroy( buf16 );
@@ -182,7 +202,9 @@ static void handleOtherSchemesL(const TDesC& aUrl)
static bool handleOtherSchemes(const QUrl &url)
{
- TRAPD( err, handleOtherSchemesL(qt_QString2TPtrC(url.toEncoded())));
+ QString encUrl(url.toEncoded());
+ TPtrC urlPtr(qt_QString2TPtrC(encUrl));
+ TRAPD( err, handleOtherSchemesL(urlPtr));
return err ? false : true;
}
@@ -233,8 +255,8 @@ static void openDocumentL(const TDesC& aUrl)
{
#ifndef USE_DOCUMENTHANDLER
// Start app associated to file MIME type by using RApaLsSession
- // Apparc base method cannot be used to open app in embedded mode,
- // but seems to be most stable way at the moment
+ // Apparc base method cannot be used to open app in embedded mode,
+ // but seems to be most stable way at the moment
RApaLsSession appArcSession;
User::LeaveIfError( appArcSession.Connect() );
CleanupClosePushL<RApaLsSession>( appArcSession );
@@ -242,25 +264,25 @@ static void openDocumentL(const TDesC& aUrl)
// ESwitchFiles means do not start another instance
// Leaves if file does not exist, leave is trapped in openDocument and false returned to user.
User::LeaveIfError( appArcSession.StartDocument( aUrl, id,
- RApaLsSession::ESwitchFiles ) ); // ELaunchNewApp
+ RApaLsSession::ESwitchFiles ) ); // ELaunchNewApp
CleanupStack::PopAndDestroy(); // appArcSession
#else
// This is an alternative way to launch app associated to MIME type
- // CDocumentHandler would support opening apps in embedded mode,
- // but our Qt application window group seems to always get switched on top of embedded one
- // -> Cannot use menus etc of embedded app -> used
-
- CDocumentHandler* docHandler = CDocumentHandler::NewLC();
- TDataType temp;
- //Standalone file opening fails for some file-types at least in S60 3.1 emulator
- //For example .txt file fails with KErrAlreadyInUse and music files with KERN-EXEC 0
- //Workaround is to use OpenFileEmbeddedL
- //docHandler->OpenFileL(aUrl, temp);
-
- // Opening file with CDocumentHandler will leave if file does not exist
- // Leave is trapped in openDocument and false returned to user.
- docHandler->OpenFileEmbeddedL(aUrl, temp);
- CleanupStack::PopAndDestroy(docHandler);
+ // CDocumentHandler would support opening apps in embedded mode,
+ // but our Qt application window group seems to always get switched on top of embedded one
+ // -> Cannot use menus etc of embedded app -> used
+
+ CDocumentHandler* docHandler = CDocumentHandler::NewLC();
+ TDataType temp;
+ //Standalone file opening fails for some file-types at least in S60 3.1 emulator
+ //For example .txt file fails with KErrAlreadyInUse and music files with KERN-EXEC 0
+ //Workaround is to use OpenFileEmbeddedL
+ //docHandler->OpenFileL(aUrl, temp);
+
+ // Opening file with CDocumentHandler will leave if file does not exist
+ // Leave is trapped in openDocument and false returned to user.
+ docHandler->OpenFileEmbeddedL(aUrl, temp);
+ CleanupStack::PopAndDestroy(docHandler);
#endif
}
@@ -273,10 +295,12 @@ static void openDocumentL(const TDesC& aUrl)
// wide range of schemes and is extensible by plugins
static bool handleUrl(const QUrl &url)
{
- if (!url.isValid())
- return false;
+ if (!url.isValid())
+ return false;
- TRAPD( err, handleUrlL(qt_QString2TPtrC(url.toString())));
+ QString urlString(url.toString());
+ TPtrC urlPtr(qt_QString2TPtrC(urlString));
+ TRAPD( err, handleUrlL(urlPtr));
return err ? false : true;
}
@@ -289,12 +313,12 @@ static void handleUrlL(const TDesC& aUrl)
}
static bool launchWebBrowser(const QUrl &url)
{
- return handleUrl(url);
+ return handleUrl(url);
}
static bool openDocument(const QUrl &file)
{
- return handleUrl(url);
+ return handleUrl(url);
}
#endif
@@ -316,7 +340,8 @@ static bool openDocument(const QUrl &file)
QString filePath = file.toLocalFile();
filePath = QDir::toNativeSeparators(filePath);
- TRAPD(err, openDocumentL(qt_QString2TPtrC(filePath)));
+ TPtrC filePathPtr(qt_QString2TPtrC(filePath));
+ TRAPD(err, openDocumentL(filePathPtr));
return err ? false : true;
}
@@ -366,7 +391,7 @@ QString QDesktopServices::storageLocation(StandardLocation type)
//return QDir::homePath(); break;
break;
case DataLocation:
- CEikonEnv::Static()->FsSession().PrivatePath( path );
+ CEikonEnv::Static()->FsSession().PrivatePath( path );
// TODO: Should we actually return phone mem if data is on ROM?
path.Insert( 0, exeDrive().Name() );
break;
diff --git a/src/gui/util/qsystemtrayicon.h b/src/gui/util/qsystemtrayicon.h
index 0f1e2d2..ac90487 100644
--- a/src/gui/util/qsystemtrayicon.h
+++ b/src/gui/util/qsystemtrayicon.h
@@ -117,7 +117,7 @@ protected:
private:
Q_DISABLE_COPY(QSystemTrayIcon)
- Q_DECLARE_PRIVATE(QSystemTrayIcon)
+ Q_DECLARE_SCOPED_PRIVATE(QSystemTrayIcon)
friend class QSystemTrayIconSys;
friend class QBalloonTip;
diff --git a/src/gui/util/qundogroup.h b/src/gui/util/qundogroup.h
index ddab6e0..24d4e12 100644
--- a/src/gui/util/qundogroup.h
+++ b/src/gui/util/qundogroup.h
@@ -60,7 +60,7 @@ QT_MODULE(Gui)
class Q_GUI_EXPORT QUndoGroup : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QUndoGroup)
+ Q_DECLARE_SCOPED_PRIVATE(QUndoGroup)
public:
explicit QUndoGroup(QObject *parent = 0);
diff --git a/src/gui/util/qundostack.h b/src/gui/util/qundostack.h
index 8efad0e..8ad4b198 100644
--- a/src/gui/util/qundostack.h
+++ b/src/gui/util/qundostack.h
@@ -90,7 +90,7 @@ private:
class Q_GUI_EXPORT QUndoStack : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QUndoStack)
+ Q_DECLARE_SCOPED_PRIVATE(QUndoStack)
Q_PROPERTY(bool active READ isActive WRITE setActive)
Q_PROPERTY(int undoLimit READ undoLimit WRITE setUndoLimit)
diff --git a/src/gui/util/qundoview.h b/src/gui/util/qundoview.h
index fa0c163..293c0c2 100644
--- a/src/gui/util/qundoview.h
+++ b/src/gui/util/qundoview.h
@@ -61,7 +61,7 @@ QT_MODULE(Gui)
class Q_GUI_EXPORT QUndoView : public QListView
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QUndoView)
+ Q_DECLARE_SCOPED_PRIVATE(QUndoView)
Q_PROPERTY(QString emptyLabel READ emptyLabel WRITE setEmptyLabel)
Q_PROPERTY(QIcon cleanIcon READ cleanIcon WRITE setCleanIcon)