summaryrefslogtreecommitdiffstats
path: root/src/gui/util
diff options
context:
space:
mode:
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_s60.cpp57
-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
8 files changed, 51 insertions, 28 deletions
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
index 8fe32bd..89cb283 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 c1169ef..35ecc56 100644
--- a/src/gui/util/qcompleter.h
+++ b/src/gui/util/qcompleter.h
@@ -150,7 +150,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 dc4189f..def0235 100644
--- a/src/gui/util/qcompleter_p.h
+++ b/src/gui/util/qcompleter_p.h
@@ -213,7 +213,6 @@ class QCompletionModel : public QAbstractProxyModel
public:
QCompletionModel(QCompleterPrivate *c, QObject *parent);
- ~QCompletionModel() { delete engine; }
void createEngine();
void setFiltered(bool);
@@ -236,10 +235,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_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp
index 77cf254..567b4ee 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);
+ QAutoClose<RSendAs> sendAsCleanup(sendAs);
CSendAsAccounts* accounts = CSendAsAccounts::NewL();
@@ -109,7 +132,7 @@ static void handleMailtoSchemeL(const QUrl &url)
} else {
RSendAsMessage sendAsMessage;
sendAsMessage.CreateL(sendAs, KUidMsgTypeSMTP);
- CleanupClosePushL(sendAsMessage);
+ QAutoClose<RSendAsMessage> sendAsMessageCleanup(sendAsMessage);
// Subject
@@ -135,17 +158,14 @@ static void handleMailtoSchemeL(const QUrl &url)
// send the message
sendAsMessage.LaunchEditorAndCloseL();
-
- // sendAsMessage (already closed)
- CleanupStack::Pop();
+ // sendAsMessage is already closed
+ sendAsMessageCleanup.Forget();
}
- // sendAs
- CleanupStack::PopAndDestroy();
}
static bool handleMailtoScheme(const QUrl &url)
{
- TRAPD(err, handleMailtoSchemeL(url));
+ TRAPD(err, QT_TRYCATCH_LEAVING(handleMailtoSchemeLX(url)));
return err ? false : true;
}
@@ -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;
}
@@ -276,7 +298,9 @@ static bool handleUrl(const QUrl &url)
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;
}
@@ -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;
}
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)