summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorHarald Fernengel <harald@trolltech.com>2009-08-03 13:12:46 (GMT)
committerHarald Fernengel <harald@trolltech.com>2009-08-03 13:12:46 (GMT)
commit41a83e1ff19ad1396e6001e6b0ac003c701ba55a (patch)
tree609e40eda10418bbf925002c36552074796b96b6 /src/gui/kernel
parentd1f3b9df2bc5c57d414da73a7d4f9ed7b25df3db (diff)
downloadQt-41a83e1ff19ad1396e6001e6b0ac003c701ba55a.zip
Qt-41a83e1ff19ad1396e6001e6b0ac003c701ba55a.tar.gz
Qt-41a83e1ff19ad1396e6001e6b0ac003c701ba55a.tar.bz2
Squashed commit of the topic/exceptions branch.
Contains some smaller fixes and renaming of macros. Looks big, but isn't scary at all ;)
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qaction.h2
-rw-r--r--src/gui/kernel/qactiongroup.h2
-rw-r--r--src/gui/kernel/qapplication.cpp33
-rw-r--r--src/gui/kernel/qapplication.h2
-rw-r--r--src/gui/kernel/qapplication_qws.cpp12
-rw-r--r--src/gui/kernel/qapplication_s60.cpp12
-rw-r--r--src/gui/kernel/qapplication_win.cpp2
-rw-r--r--src/gui/kernel/qboxlayout.cpp29
-rw-r--r--src/gui/kernel/qboxlayout.h2
-rw-r--r--src/gui/kernel/qclipboard.h2
-rw-r--r--src/gui/kernel/qclipboard_s60.cpp15
-rw-r--r--src/gui/kernel/qdesktopwidget.h2
-rw-r--r--src/gui/kernel/qdesktopwidget_x11.cpp2
-rw-r--r--src/gui/kernel/qdnd_s60.cpp2
-rw-r--r--src/gui/kernel/qdnd_x11.cpp2
-rw-r--r--src/gui/kernel/qdrag.h2
-rw-r--r--src/gui/kernel/qeventdispatcher_glib_qws_p.h2
-rw-r--r--src/gui/kernel/qeventdispatcher_mac_p.h2
-rw-r--r--src/gui/kernel/qeventdispatcher_qws_p.h2
-rw-r--r--src/gui/kernel/qeventdispatcher_s60.cpp2
-rw-r--r--src/gui/kernel/qeventdispatcher_x11_p.h2
-rw-r--r--src/gui/kernel/qformlayout.h2
-rw-r--r--src/gui/kernel/qgesture.h4
-rw-r--r--src/gui/kernel/qgesturerecognizer.h2
-rw-r--r--src/gui/kernel/qgridlayout.h2
-rw-r--r--src/gui/kernel/qguieventdispatcher_glib_p.h2
-rw-r--r--src/gui/kernel/qkeymapper_mac.cpp10
-rw-r--r--src/gui/kernel/qkeymapper_p.h4
-rw-r--r--src/gui/kernel/qkeymapper_win.cpp9
-rw-r--r--src/gui/kernel/qkeysequence.cpp4
-rw-r--r--src/gui/kernel/qlayout.h2
-rw-r--r--src/gui/kernel/qsessionmanager.h2
-rw-r--r--src/gui/kernel/qshortcut.h2
-rw-r--r--src/gui/kernel/qshortcutmap_p.h2
-rw-r--r--src/gui/kernel/qsound.h2
-rw-r--r--src/gui/kernel/qstackedlayout.h2
-rw-r--r--src/gui/kernel/qt_s60_p.h10
-rw-r--r--src/gui/kernel/qwidget.cpp74
-rw-r--r--src/gui/kernel/qwidget.h2
-rw-r--r--src/gui/kernel/qwidget_mac.mm6
-rw-r--r--src/gui/kernel/qwidget_p.h7
-rw-r--r--src/gui/kernel/qwidget_qws.cpp9
-rw-r--r--src/gui/kernel/qwidget_s60.cpp34
-rw-r--r--src/gui/kernel/qwidget_win.cpp6
-rw-r--r--src/gui/kernel/qwidget_x11.cpp6
-rw-r--r--src/gui/kernel/qwidgetaction.h2
-rw-r--r--src/gui/kernel/qx11embed_x11.cpp2
-rw-r--r--src/gui/kernel/qx11embed_x11.h4
48 files changed, 217 insertions, 129 deletions
diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h
index b9bdcf1..f884a9a 100644
--- a/src/gui/kernel/qaction.h
+++ b/src/gui/kernel/qaction.h
@@ -64,7 +64,7 @@ class QGraphicsWidget;
class Q_GUI_EXPORT QAction : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QAction)
+ Q_DECLARE_SCOPED_PRIVATE(QAction)
Q_ENUMS(MenuRole)
Q_ENUMS(SoftKeyRole)
diff --git a/src/gui/kernel/qactiongroup.h b/src/gui/kernel/qactiongroup.h
index e42c2e5..07bdbda 100644
--- a/src/gui/kernel/qactiongroup.h
+++ b/src/gui/kernel/qactiongroup.h
@@ -57,7 +57,7 @@ class QActionGroupPrivate;
class Q_GUI_EXPORT QActionGroup : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QActionGroup)
+ Q_DECLARE_SCOPED_PRIVATE(QActionGroup)
Q_PROPERTY(bool exclusive READ isExclusive WRITE setExclusive)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 2f1ab0e..ab2672b 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -855,7 +855,7 @@ extern void qInitDrawhelperAsm();
void QApplicationPrivate::initialize()
{
QWidgetPrivate::mapper = new QWidgetMapper;
- QWidgetPrivate::uncreatedWidgets = new QWidgetSet;
+ QWidgetPrivate::allWidgets = new QWidgetSet;
if (qt_appType != QApplication::Tty)
(void) QApplication::style(); // trigger creation of application style
// trigger registering of QVariant's GUI types
@@ -1007,23 +1007,13 @@ QApplication::~QApplication()
qt_clipboard = 0;
#endif
- // delete widget mapper
- if (QWidgetPrivate::mapper) {
- QWidgetMapper * myMapper = QWidgetPrivate::mapper;
- QWidgetPrivate::mapper = 0;
- for (QWidgetMapper::ConstIterator it = myMapper->constBegin();
- it != myMapper->constEnd(); ++it) {
- register QWidget *w = *it;
- if (!w->parent()) // window
- w->destroy(true, true);
- }
- delete myMapper;
- }
+ delete QWidgetPrivate::mapper;
+ QWidgetPrivate::mapper = 0;
- // delete uncreated widgets
- if (QWidgetPrivate::uncreatedWidgets) {
- QWidgetSet *mySet = QWidgetPrivate::uncreatedWidgets;
- QWidgetPrivate::uncreatedWidgets = 0;
+ // delete all widgets
+ if (QWidgetPrivate::allWidgets) {
+ QWidgetSet *mySet = QWidgetPrivate::allWidgets;
+ QWidgetPrivate::allWidgets = 0;
for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) {
register QWidget *w = *it;
if (!w->parent()) // window
@@ -2050,12 +2040,9 @@ QWidgetList QApplication::topLevelWidgets()
QWidgetList QApplication::allWidgets()
{
- QWidgetList list;
- if (QWidgetPrivate::mapper)
- list += QWidgetPrivate::mapper->values();
- if (QWidgetPrivate::uncreatedWidgets)
- list += QWidgetPrivate::uncreatedWidgets->toList();
- return list;
+ if (QWidgetPrivate::allWidgets)
+ return QWidgetPrivate::allWidgets->toList();
+ return QWidgetList();
}
/*!
diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h
index 4b447b5..6305951 100644
--- a/src/gui/kernel/qapplication.h
+++ b/src/gui/kernel/qapplication.h
@@ -371,7 +371,7 @@ public:
private:
Q_DISABLE_COPY(QApplication)
- Q_DECLARE_PRIVATE(QApplication)
+ Q_DECLARE_SCOPED_PRIVATE(QApplication)
friend class QGraphicsWidget;
friend class QGraphicsScene;
diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp
index 92fe5f5..b7d1288 100644
--- a/src/gui/kernel/qapplication_qws.cpp
+++ b/src/gui/kernel/qapplication_qws.cpp
@@ -668,7 +668,7 @@ void QWSDisplay::Data::sendSynchronousCommand(QWSCommand & cmd)
int QWSDisplay::Data::takeId()
{
- if (unused_identifiers.count() == 10)
+ if (unused_identifiers.count() <= 10)
create(15);
if (unused_identifiers.count() == 0)
waitForCreation();
@@ -3758,4 +3758,14 @@ void QApplicationPrivate::initializeMultitouch_sys()
void QApplicationPrivate::cleanupMultitouch_sys()
{ }
+/* \internal
+ This is used to clean up the qws server
+ in case the QApplication constructor threw an exception
+*/
+QWSServerCleaner::~QWSServerCleaner()
+{
+ if (qwsServer && qws_single_process)
+ QWSServer::closedown();
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index 766ca4b..7836238 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -76,13 +76,18 @@ QT_BEGIN_NAMESPACE
static bool appNoGrab = false; // Grabbing enabled
#endif
-Q_GUI_EXPORT QS60Data *qt_s60Data = 0;
+Q_GLOBAL_STATIC(QS60Data, qt_s60Data);
extern bool qt_sendSpontaneousEvent(QObject*,QEvent*);
extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
QWidget *qt_button_down = 0; // widget got last button-down
+QS60Data* qGlobalS60Data()
+{
+ return qt_s60Data();
+}
+
bool qt_nograb() // application no-grab option
{
#if defined(QT_DEBUG)
@@ -441,7 +446,7 @@ void QSymbianControl::sendMouseEvent(QWidget *widget, QMouseEvent *mEvent)
TKeyResponse QSymbianControl::OfferKeyEventL(const TKeyEvent& keyEvent, TEventCode type)
{
TKeyResponse r = EKeyWasNotConsumed;
- QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(r = OfferKeyEvent(keyEvent, type));
+ QT_TRYCATCH_LEAVING(r = OfferKeyEvent(keyEvent, type));
return r;
}
@@ -706,8 +711,6 @@ TTypeUid::Ptr QSymbianControl::MopSupplyObject(TTypeUid id)
void qt_init(QApplicationPrivate * /* priv */, int)
{
- S60 = new QS60Data;
-
#ifdef QT_NO_DEBUG
if (!qgetenv("QT_S60_AUTO_FLUSH_WSERV").isEmpty())
#endif
@@ -723,7 +726,6 @@ void qt_init(QApplicationPrivate * /* priv */, int)
TSecureId securId = me.SecureId();
S60->uid = securId.operator TUid();
-
/*
### Commented out for now as parameter handling not needed in SOS(yet). Code below will break testlib with -o flag
int argc = priv->argc;
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index bb7d931..4f35583 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -1191,7 +1191,7 @@ static void qWinProcessConfigRequests() // perform requests in qu
class QGuiEventDispatcherWin32 : public QEventDispatcherWin32
{
- Q_DECLARE_PRIVATE(QEventDispatcherWin32)
+ Q_DECLARE_SCOPED_PRIVATE(QEventDispatcherWin32)
public:
QGuiEventDispatcherWin32(QObject *parent = 0);
bool processEvents(QEventLoop::ProcessEventsFlags flags);
diff --git a/src/gui/kernel/qboxlayout.cpp b/src/gui/kernel/qboxlayout.cpp
index 770f5bb..b51d77f 100644
--- a/src/gui/kernel/qboxlayout.cpp
+++ b/src/gui/kernel/qboxlayout.cpp
@@ -925,9 +925,15 @@ void QBoxLayout::insertSpacing(int index, int size)
else
b = QLayoutPrivate::createSpacerItem(this, 0, size, QSizePolicy::Minimum, QSizePolicy::Fixed);
- QBoxLayoutItem *it = new QBoxLayoutItem(b);
- it->magic = true;
- d->list.insert(index, it);
+ QT_TRY {
+ QBoxLayoutItem *it = new QBoxLayoutItem(b);
+ it->magic = true;
+ d->list.insert(index, it);
+
+ } QT_CATCH(...) {
+ delete b;
+ QT_RETHROW;
+ }
invalidate();
}
@@ -1027,8 +1033,21 @@ void QBoxLayout::insertWidget(int index, QWidget *widget, int stretch,
index = d->list.count();
QWidgetItem *b = QLayoutPrivate::createWidgetItem(this, widget);
b->setAlignment(alignment);
- QBoxLayoutItem *it = new QBoxLayoutItem(b, stretch);
- d->list.insert(index, it);
+
+ QBoxLayoutItem *it;
+ QT_TRY{
+ it = new QBoxLayoutItem(b, stretch);
+ } QT_CATCH(...) {
+ delete b;
+ QT_RETHROW;
+ }
+
+ QT_TRY{
+ d->list.insert(index, it);
+ } QT_CATCH(...) {
+ delete it;
+ QT_RETHROW;
+ }
invalidate();
}
diff --git a/src/gui/kernel/qboxlayout.h b/src/gui/kernel/qboxlayout.h
index f463c31..c399b8d 100644
--- a/src/gui/kernel/qboxlayout.h
+++ b/src/gui/kernel/qboxlayout.h
@@ -60,7 +60,7 @@ class QBoxLayoutPrivate;
class Q_GUI_EXPORT QBoxLayout : public QLayout
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QBoxLayout)
+ Q_DECLARE_SCOPED_PRIVATE(QBoxLayout)
public:
enum Direction { LeftToRight, RightToLeft, TopToBottom, BottomToTop,
Down = TopToBottom, Up = BottomToTop };
diff --git a/src/gui/kernel/qclipboard.h b/src/gui/kernel/qclipboard.h
index 8241812..68fbf33 100644
--- a/src/gui/kernel/qclipboard.h
+++ b/src/gui/kernel/qclipboard.h
@@ -62,7 +62,7 @@ class QClipboardPrivate;
class Q_GUI_EXPORT QClipboard : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QClipboard)
+ Q_DECLARE_SCOPED_PRIVATE(QClipboard)
private:
QClipboard(QObject *parent);
~QClipboard();
diff --git a/src/gui/kernel/qclipboard_s60.cpp b/src/gui/kernel/qclipboard_s60.cpp
index db5e7f3..27b4fdb 100644
--- a/src/gui/kernel/qclipboard_s60.cpp
+++ b/src/gui/kernel/qclipboard_s60.cpp
@@ -143,8 +143,10 @@ static QClipboardData *clipboardData()
return internalCbData;
}
-void writeToStream(const QMimeData* aData, RWriteStream& aStream)
+void writeToStreamLX(const QMimeData* aData, RWriteStream& aStream)
{
+ // This function both leaves and throws exceptions. There must be no destructor
+ // dependencies between cleanup styles, and no cleanup stack dependencies on stacked objects.
QStringList headers = aData->formats();
aStream << TCardinality(headers.count());
for (QStringList::const_iterator iter= headers.constBegin();iter != headers.constEnd();iter++)
@@ -162,8 +164,10 @@ void writeToStream(const QMimeData* aData, RWriteStream& aStream)
}
}
-void readFromStream(QMimeData* aData,RReadStream& aStream)
+void readFromStreamLX(QMimeData* aData,RReadStream& aStream)
{
+ // This function both leaves and throws exceptions. There must be no destructor
+ // dependencies between cleanup styles, and no cleanup stack dependencies on stacked objects.
TCardinality mimeTypeCount;
aStream >> mimeTypeCount;
for (int i = 0; i< mimeTypeCount;i++)
@@ -173,6 +177,7 @@ void readFromStream(QMimeData* aData,RReadStream& aStream)
aStream >> mimeTypeSize;
HBufC* mimeTypeBuf = HBufC::NewLC(aStream,mimeTypeSize);
QString mimeType = QString::fromUtf16(mimeTypeBuf->Des().Ptr(),mimeTypeBuf->Length());
+ CleanupStack::PopAndDestroy(mimeTypeBuf);
// mime data
TCardinality dataSize;
aStream >> dataSize;
@@ -182,8 +187,6 @@ void readFromStream(QMimeData* aData,RReadStream& aStream)
ba.data_ptr()->size = dataSize;
qDebug() << "paste from clipboard mime: " << mimeType << " data: " << ba;
aData->setData(mimeType,ba);
- CleanupStack::PopAndDestroy(mimeTypeBuf);
-
}
}
@@ -210,7 +213,7 @@ const QMimeData* QClipboard::mimeData(Mode mode) const
RStoreReadStream stream;
TStreamId stid = (cb->StreamDictionary()).At(KQtCbDataStream);
stream.OpenLC(cb->Store(),stid);
- readFromStream(d->source(),stream);
+ QT_TRYCATCH_LEAVING(readFromStreamLX(d->source(),stream));
CleanupStack::PopAndDestroy(2,cb);
return d->source();
});
@@ -235,7 +238,7 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode)
CClipboard* cb = CClipboard::NewForWritingLC(fs);
RStoreWriteStream stream;
TStreamId stid = stream.CreateLC(cb->Store());
- writeToStream(src,stream);
+ QT_TRYCATCH_LEAVING(writeToStreamLX(src,stream));
d->setSource(src);
stream.CommitL();
(cb->StreamDictionary()).AssignL(KQtCbDataStream,stid);
diff --git a/src/gui/kernel/qdesktopwidget.h b/src/gui/kernel/qdesktopwidget.h
index 470f10a..d61e00c 100644
--- a/src/gui/kernel/qdesktopwidget.h
+++ b/src/gui/kernel/qdesktopwidget.h
@@ -91,7 +91,7 @@ protected:
private:
Q_DISABLE_COPY(QDesktopWidget)
- Q_DECLARE_PRIVATE(QDesktopWidget)
+ Q_DECLARE_SCOPED_PRIVATE(QDesktopWidget)
friend class QApplication;
friend class QApplicationPrivate;
diff --git a/src/gui/kernel/qdesktopwidget_x11.cpp b/src/gui/kernel/qdesktopwidget_x11.cpp
index 59d3239..94032e3 100644
--- a/src/gui/kernel/qdesktopwidget_x11.cpp
+++ b/src/gui/kernel/qdesktopwidget_x11.cpp
@@ -197,7 +197,7 @@ void QDesktopWidgetPrivate::init()
if (screens) {
// leaks QWidget* pointers on purpose, can't delete them as pointer escapes
- screens = (QWidget**) realloc(screens, j * sizeof(QWidget*));
+ screens = q_check_ptr((QWidget**) realloc(screens, j * sizeof(QWidget*)));
if (j > screenCount)
memset(&screens[screenCount], 0, (j-screenCount) * sizeof(QWidget*));
}
diff --git a/src/gui/kernel/qdnd_s60.cpp b/src/gui/kernel/qdnd_s60.cpp
index c459f8f..07b196e 100644
--- a/src/gui/kernel/qdnd_s60.cpp
+++ b/src/gui/kernel/qdnd_s60.cpp
@@ -128,7 +128,7 @@ public:
QImage temp = pm.toImage();
QSize size = pm.size();
temp.bits();
- CFbsBitmap *curbm = new (ELeave) CFbsBitmap();
+ CFbsBitmap *curbm = q_check_ptr(new CFbsBitmap()); // CBase derived object needs check on new
curbm->Create(TSize(size.width(),size.height()),EColor16MA);
curbm->LockHeap(ETrue);
memcpy((uchar*)curbm->DataAddress(),temp.bits(),temp.numBytes());
diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp
index 7b445ea..410d1a9 100644
--- a/src/gui/kernel/qdnd_x11.cpp
+++ b/src/gui/kernel/qdnd_x11.cpp
@@ -316,7 +316,7 @@ static XdndData xdnd_data = { 0, 0 };
class QExtraWidget : public QWidget
{
- Q_DECLARE_PRIVATE(QWidget)
+ Q_DECLARE_SCOPED_PRIVATE(QWidget)
public:
inline QWExtra* extraData();
inline QTLWExtra* topData();
diff --git a/src/gui/kernel/qdrag.h b/src/gui/kernel/qdrag.h
index b49d82a..7e54b51 100644
--- a/src/gui/kernel/qdrag.h
+++ b/src/gui/kernel/qdrag.h
@@ -61,7 +61,7 @@ class QDragManager;
class Q_GUI_EXPORT QDrag : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QDrag)
+ Q_DECLARE_SCOPED_PRIVATE(QDrag)
public:
explicit QDrag(QWidget *dragSource);
~QDrag();
diff --git a/src/gui/kernel/qeventdispatcher_glib_qws_p.h b/src/gui/kernel/qeventdispatcher_glib_qws_p.h
index 826661e..f0751be 100644
--- a/src/gui/kernel/qeventdispatcher_glib_qws_p.h
+++ b/src/gui/kernel/qeventdispatcher_glib_qws_p.h
@@ -62,7 +62,7 @@ class QWSEventDispatcherGlibPrivate;
class QWSEventDispatcherGlib : public QEventDispatcherGlib
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QWSEventDispatcherGlib)
+ Q_DECLARE_SCOPED_PRIVATE(QWSEventDispatcherGlib)
public:
explicit QWSEventDispatcherGlib(QObject *parent = 0);
diff --git a/src/gui/kernel/qeventdispatcher_mac_p.h b/src/gui/kernel/qeventdispatcher_mac_p.h
index 88663c6..1986c4c 100644
--- a/src/gui/kernel/qeventdispatcher_mac_p.h
+++ b/src/gui/kernel/qeventdispatcher_mac_p.h
@@ -108,7 +108,7 @@ class QEventDispatcherMacPrivate;
class QEventDispatcherMac : public QAbstractEventDispatcher
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QEventDispatcherMac)
+ Q_DECLARE_SCOPED_PRIVATE(QEventDispatcherMac)
public:
explicit QEventDispatcherMac(QObject *parent = 0);
diff --git a/src/gui/kernel/qeventdispatcher_qws_p.h b/src/gui/kernel/qeventdispatcher_qws_p.h
index b83fa10..982ed58 100644
--- a/src/gui/kernel/qeventdispatcher_qws_p.h
+++ b/src/gui/kernel/qeventdispatcher_qws_p.h
@@ -62,7 +62,7 @@ class QEventDispatcherQWSPrivate;
class QEventDispatcherQWS : public QEventDispatcherUNIX
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QEventDispatcherQWS)
+ Q_DECLARE_SCOPED_PRIVATE(QEventDispatcherQWS)
public:
explicit QEventDispatcherQWS(QObject *parent = 0);
diff --git a/src/gui/kernel/qeventdispatcher_s60.cpp b/src/gui/kernel/qeventdispatcher_s60.cpp
index 51878df..2fea8a4 100644
--- a/src/gui/kernel/qeventdispatcher_s60.cpp
+++ b/src/gui/kernel/qeventdispatcher_s60.cpp
@@ -76,7 +76,7 @@ bool QEventDispatcherS60::processEvents ( QEventLoop::ProcessEventsFlags flags )
m_noInputEvents = oldNoInputEventsValue;
} QT_CATCH (const std::exception& ex) {
#ifndef QT_NO_EXCEPTIONS
- CActiveScheduler::Current()->Error(qt_translateExceptionToSymbianError(ex));
+ CActiveScheduler::Current()->Error(qt_exception2SymbianError(ex));
#endif
}
diff --git a/src/gui/kernel/qeventdispatcher_x11_p.h b/src/gui/kernel/qeventdispatcher_x11_p.h
index 9a54c36..b4c553d 100644
--- a/src/gui/kernel/qeventdispatcher_x11_p.h
+++ b/src/gui/kernel/qeventdispatcher_x11_p.h
@@ -62,7 +62,7 @@ class QEventDispatcherX11Private;
class QEventDispatcherX11 : public QEventDispatcherUNIX
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QEventDispatcherX11)
+ Q_DECLARE_SCOPED_PRIVATE(QEventDispatcherX11)
public:
explicit QEventDispatcherX11(QObject *parent = 0);
diff --git a/src/gui/kernel/qformlayout.h b/src/gui/kernel/qformlayout.h
index b560e85..0143711 100644
--- a/src/gui/kernel/qformlayout.h
+++ b/src/gui/kernel/qformlayout.h
@@ -56,7 +56,7 @@ class Q_GUI_EXPORT QFormLayout : public QLayout
{
Q_OBJECT
Q_ENUMS(FormStyle FieldGrowthPolicy RowWrapPolicy ItemRole)
- Q_DECLARE_PRIVATE(QFormLayout)
+ Q_DECLARE_SCOPED_PRIVATE(QFormLayout)
Q_PROPERTY(FieldGrowthPolicy fieldGrowthPolicy READ fieldGrowthPolicy WRITE setFieldGrowthPolicy RESET resetFieldGrowthPolicy)
Q_PROPERTY(RowWrapPolicy rowWrapPolicy READ rowWrapPolicy WRITE setRowWrapPolicy RESET resetRowWrapPolicy)
Q_PROPERTY(Qt::Alignment labelAlignment READ labelAlignment WRITE setLabelAlignment RESET resetLabelAlignment)
diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h
index f3c95cc..a7aba22 100644
--- a/src/gui/kernel/qgesture.h
+++ b/src/gui/kernel/qgesture.h
@@ -59,7 +59,7 @@ class QGesturePrivate;
class Q_GUI_EXPORT QGesture : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QGesture)
+ Q_DECLARE_SCOPED_PRIVATE(QGesture)
Q_PROPERTY(QString type READ type)
Q_PROPERTY(Qt::GestureState state READ state)
@@ -128,7 +128,7 @@ class QPanningGesturePrivate;
class Q_GUI_EXPORT QPanningGesture : public QGesture
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QPanningGesture)
+ Q_DECLARE_SCOPED_PRIVATE(QPanningGesture)
Q_PROPERTY(Qt::DirectionType lastDirection READ lastDirection)
Q_PROPERTY(Qt::DirectionType direction READ direction)
diff --git a/src/gui/kernel/qgesturerecognizer.h b/src/gui/kernel/qgesturerecognizer.h
index 2c1c61b..65c4ca0 100644
--- a/src/gui/kernel/qgesturerecognizer.h
+++ b/src/gui/kernel/qgesturerecognizer.h
@@ -53,7 +53,7 @@ class QGestureRecognizerPrivate;
class Q_GUI_EXPORT QGestureRecognizer : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QGestureRecognizer)
+ Q_DECLARE_SCOPED_PRIVATE(QGestureRecognizer)
public:
enum Result
diff --git a/src/gui/kernel/qgridlayout.h b/src/gui/kernel/qgridlayout.h
index 89a04a4..2b5299e 100644
--- a/src/gui/kernel/qgridlayout.h
+++ b/src/gui/kernel/qgridlayout.h
@@ -60,7 +60,7 @@ class QGridLayoutPrivate;
class Q_GUI_EXPORT QGridLayout : public QLayout
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QGridLayout)
+ Q_DECLARE_SCOPED_PRIVATE(QGridLayout)
QDOC_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
QDOC_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
diff --git a/src/gui/kernel/qguieventdispatcher_glib_p.h b/src/gui/kernel/qguieventdispatcher_glib_p.h
index 65d233e..8543836 100644
--- a/src/gui/kernel/qguieventdispatcher_glib_p.h
+++ b/src/gui/kernel/qguieventdispatcher_glib_p.h
@@ -62,7 +62,7 @@ class QGuiEventDispatcherGlibPrivate;
class QGuiEventDispatcherGlib : public QEventDispatcherGlib
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QGuiEventDispatcherGlib)
+ Q_DECLARE_SCOPED_PRIVATE(QGuiEventDispatcherGlib)
public:
explicit QGuiEventDispatcherGlib(QObject *parent = 0);
diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp
index 017c13c..87dad1e 100644
--- a/src/gui/kernel/qkeymapper_mac.cpp
+++ b/src/gui/kernel/qkeymapper_mac.cpp
@@ -563,7 +563,7 @@ QKeyMapperPrivate::QKeyMapperPrivate()
QKeyMapperPrivate::~QKeyMapperPrivate()
{
- clearMappings();
+ deleteLayouts();
}
bool
@@ -658,7 +658,7 @@ QKeyMapperPrivate::updateKeyboard()
}
void
-QKeyMapperPrivate::clearMappings()
+QKeyMapperPrivate::deleteLayouts()
{
keyboard_mode = NullMode;
for (int i = 0; i < 255; ++i) {
@@ -667,6 +667,12 @@ QKeyMapperPrivate::clearMappings()
keyLayout[i] = 0;
}
}
+}
+
+void
+QKeyMapperPrivate::clearMappings()
+{
+ deleteLayouts();
updateKeyboard();
}
diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h
index ba1fcfe..6c12b0f 100644
--- a/src/gui/kernel/qkeymapper_p.h
+++ b/src/gui/kernel/qkeymapper_p.h
@@ -85,7 +85,7 @@ public:
private:
friend QKeyMapperPrivate *qt_keymapper_private();
- Q_DECLARE_PRIVATE(QKeyMapper)
+ Q_DECLARE_SCOPED_PRIVATE(QKeyMapper)
Q_DISABLE_COPY(QKeyMapper)
};
@@ -161,6 +161,7 @@ public:
bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab);
void updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 scancode, quint32 vk_key);
bool isADeadKey(unsigned int vk_key, unsigned int modifiers);
+ void deleteLayouts();
KeyboardLayoutItem *keyLayout[256];
@@ -189,6 +190,7 @@ public:
bool updateKeyboard();
void updateKeyMap(EventHandlerCallRef, EventRef, void *);
bool translateKeyEvent(QWidget *, EventHandlerCallRef, EventRef, void *, bool);
+ void deleteLayouts();
enum { NullMode, UnicodeMode, OtherMode } keyboard_mode;
union {
diff --git a/src/gui/kernel/qkeymapper_win.cpp b/src/gui/kernel/qkeymapper_win.cpp
index e40dfa0..d1b3456 100644
--- a/src/gui/kernel/qkeymapper_win.cpp
+++ b/src/gui/kernel/qkeymapper_win.cpp
@@ -621,10 +621,10 @@ QKeyMapperPrivate::QKeyMapperPrivate()
QKeyMapperPrivate::~QKeyMapperPrivate()
{
- clearMappings();
+ deleteLayouts();
}
-void QKeyMapperPrivate::clearMappings()
+void QKeyMapperPrivate::deleteLayouts()
{
for (int i = 0; i < 255; ++i) {
if (keyLayout[i]) {
@@ -632,6 +632,11 @@ void QKeyMapperPrivate::clearMappings()
keyLayout[i] = 0;
}
}
+}
+
+void QKeyMapperPrivate::clearMappings()
+{
+ deleteLayouts();
/* MAKELCID()'s first argument is a WORD, and GetKeyboardLayout()
* returns a DWORD. */
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 6563dae..e2a5b27 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -753,7 +753,9 @@ QKeySequence::QKeySequence(StandardKey key)
*/
QKeySequence::QKeySequence()
{
- d = new QKeySequencePrivate();
+ static QKeySequencePrivate shared_empty;
+ d = &shared_empty;
+ d->ref.ref();
}
/*!
diff --git a/src/gui/kernel/qlayout.h b/src/gui/kernel/qlayout.h
index 4f46c1d..ec95ca8 100644
--- a/src/gui/kernel/qlayout.h
+++ b/src/gui/kernel/qlayout.h
@@ -89,7 +89,7 @@ class QLayoutPrivate;
class Q_GUI_EXPORT QLayout : public QObject, public QLayoutItem
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QLayout)
+ Q_DECLARE_SCOPED_PRIVATE(QLayout)
Q_ENUMS(SizeConstraint)
Q_PROPERTY(int margin READ margin WRITE setMargin)
diff --git a/src/gui/kernel/qsessionmanager.h b/src/gui/kernel/qsessionmanager.h
index f27dbaa..0a55d0c 100644
--- a/src/gui/kernel/qsessionmanager.h
+++ b/src/gui/kernel/qsessionmanager.h
@@ -60,7 +60,7 @@ class QSessionManagerPrivate;
class Q_GUI_EXPORT QSessionManager : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QSessionManager)
+ Q_DECLARE_SCOPED_PRIVATE(QSessionManager)
QSessionManager(QApplication *app, QString &id, QString &key);
~QSessionManager();
public:
diff --git a/src/gui/kernel/qshortcut.h b/src/gui/kernel/qshortcut.h
index c81ce7c..7b79faa 100644
--- a/src/gui/kernel/qshortcut.h
+++ b/src/gui/kernel/qshortcut.h
@@ -57,7 +57,7 @@ class QShortcutPrivate;
class Q_GUI_EXPORT QShortcut : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QShortcut)
+ Q_DECLARE_SCOPED_PRIVATE(QShortcut)
Q_PROPERTY(QKeySequence key READ key WRITE setKey)
Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
diff --git a/src/gui/kernel/qshortcutmap_p.h b/src/gui/kernel/qshortcutmap_p.h
index 8962ac7..53a39ec 100644
--- a/src/gui/kernel/qshortcutmap_p.h
+++ b/src/gui/kernel/qshortcutmap_p.h
@@ -74,7 +74,7 @@ class QObject;
class QShortcutMap
{
- Q_DECLARE_PRIVATE(QShortcutMap)
+ Q_DECLARE_SCOPED_PRIVATE(QShortcutMap)
public:
QShortcutMap();
~QShortcutMap();
diff --git a/src/gui/kernel/qsound.h b/src/gui/kernel/qsound.h
index 22cfdde..eeef047 100644
--- a/src/gui/kernel/qsound.h
+++ b/src/gui/kernel/qsound.h
@@ -82,7 +82,7 @@ public:
static inline QT3_SUPPORT bool available() { return isAvailable(); }
#endif
private:
- Q_DECLARE_PRIVATE(QSound)
+ Q_DECLARE_SCOPED_PRIVATE(QSound)
friend class QAuServer;
};
diff --git a/src/gui/kernel/qstackedlayout.h b/src/gui/kernel/qstackedlayout.h
index d14b2ab..ab215fa 100644
--- a/src/gui/kernel/qstackedlayout.h
+++ b/src/gui/kernel/qstackedlayout.h
@@ -55,7 +55,7 @@ class QStackedLayoutPrivate;
class Q_GUI_EXPORT QStackedLayout : public QLayout
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QStackedLayout)
+ Q_DECLARE_SCOPED_PRIVATE(QStackedLayout)
Q_ENUMS(StackingMode)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
Q_PROPERTY(StackingMode stackingMode READ stackingMode WRITE setStackingMode)
diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h
index bcbe48f..802a2f7 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/gui/kernel/qt_s60_p.h
@@ -80,11 +80,6 @@ QT_BEGIN_NAMESPACE
// system evens seems to start with 0x10
const TInt KInternalStatusPaneChange = 0x50000000;
-struct QS60Data;
-extern QS60Data *qt_s60Data;
-
-#define S60 qt_s60Data
-
class QS60Data
{
public:
@@ -114,6 +109,9 @@ public:
#endif
};
+QS60Data* qGlobalS60Data();
+#define S60 qGlobalS60Data()
+
class QAbstractLongTapObserver
{
public:
@@ -241,7 +239,7 @@ inline CEikButtonGroupContainer* QS60Data::buttonGroupContainer()
static inline QFont qt_TFontSpec2QFontL(const TFontSpec &fontSpec)
{
return QFont(
- qt_TDesC2QStringL(fontSpec.iTypeface.iName),
+ qt_TDesC2QString(fontSpec.iTypeface.iName),
fontSpec.iHeight / KTwipsPerPoint,
fontSpec.iFontStyle.StrokeWeight() == EStrokeWeightNormal ? QFont::Normal : QFont::Bold,
fontSpec.iFontStyle.Posture() == EPostureItalic
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 4c2fe9d..bfcb02b 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -922,8 +922,8 @@ void QWidget::setAutoFillBackground(bool enabled)
*/
-QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid
-QWidgetSet *QWidgetPrivate::uncreatedWidgets = 0; // widgets with no wid
+QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid
+QWidgetSet *QWidgetPrivate::allWidgets = 0; // widgets with no wid
/*****************************************************************************
@@ -969,7 +969,7 @@ struct QWidgetExceptionCleaner
static inline void cleanup(QWidget *that, QWidgetPrivate *d)
{
#ifndef QT_NO_EXCEPTIONS
- QWidgetPrivate::uncreatedWidgets->remove(that);
+ QWidgetPrivate::allWidgets->remove(that);
if (d->focus_next != that) {
if (d->focus_next)
d->focus_next->d_func()->focus_prev = d->focus_prev;
@@ -1121,8 +1121,8 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
if (QApplication::type() == QApplication::Tty)
qFatal("QWidget: Cannot create a QWidget when no GUI is being used");
- Q_ASSERT(uncreatedWidgets);
- uncreatedWidgets->insert(q);
+ Q_ASSERT(allWidgets);
+ allWidgets->insert(q);
QWidget *desktopWidget = 0;
if (parentWidget && parentWidget->windowType() == Qt::Desktop) {
@@ -1415,15 +1415,31 @@ QWidget::~QWidget()
}
#endif
- clearFocus();
+ QT_TRY {
+ clearFocus();
+ } QT_CATCH(...) {
+ // swallow this problem because we are in a destructor
+ }
d->setDirtyOpaqueRegion();
- if (isWindow() && isVisible() && internalWinId())
- d->close_helper(QWidgetPrivate::CloseNoEvent);
+ if (isWindow() && isVisible() && internalWinId()) {
+ QT_TRY {
+ d->close_helper(QWidgetPrivate::CloseNoEvent);
+ } QT_CATCH(...) {
+ // if we're out of memory, at least hide the window.
+ QT_TRY {
+ hide();
+ } QT_CATCH(...) {
+ // and if that also doesn't work, then give up
+ }
+ }
+ }
+
#if defined(Q_WS_WIN) || defined(Q_WS_X11)
- else if (!internalWinId() && isVisible())
+ else if (!internalWinId() && isVisible()) {
qApp->d_func()->sendSyntheticEnterLeave(this);
+ }
#endif
if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
@@ -1443,12 +1459,15 @@ QWidget::~QWidget()
QApplication::removePostedEvents(this);
- destroy(); // platform-dependent cleanup
-
+ QT_TRY {
+ destroy(); // platform-dependent cleanup
+ } QT_CATCH(...) {
+ // if this fails we can't do anything about it but at least we are not allowed to throw.
+ }
--QWidgetPrivate::instanceCounter;
- if (QWidgetPrivate::uncreatedWidgets) // might have been deleted by ~QApplication
- QWidgetPrivate::uncreatedWidgets->remove(this);
+ if (QWidgetPrivate::allWidgets) // might have been deleted by ~QApplication
+ QWidgetPrivate::allWidgets->remove(this);
QEvent e(QEvent::Destroy);
QCoreApplication::sendEvent(this, &e);
@@ -1468,7 +1487,6 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier
bool userDesktopWidget = qt_desktopWidget != 0 && qt_desktopWidget != q && q->windowType() == Qt::Desktop;
if (mapper && data.winid && !userDesktopWidget) {
mapper->remove(data.winid);
- uncreatedWidgets->insert(q);
}
data.winid = id;
@@ -1477,7 +1495,6 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier
#endif
if (mapper && id && !userDesktopWidget) {
mapper->insert(data.winid, q);
- uncreatedWidgets->remove(q);
}
}
@@ -4645,8 +4662,9 @@ void QWidget::setCursor(const QCursor &cursor)
#endif
{
d->createExtra();
+ QCursor *newCursor = new QCursor(cursor);
delete d->extra->curs;
- d->extra->curs = new QCursor(cursor);
+ d->extra->curs = newCursor;
}
setAttribute(Qt::WA_SetCursor);
d->setCursor_sys(cursor);
@@ -5359,6 +5377,17 @@ QString QWidget::windowTitle() const
return QString();
}
+/*!
+ Returns a modified window title with the [*] place holder
+ replaced according to the rules described in QWidget::setWindowTitle
+
+ This function assumes that "[*]" can be quoted by another
+ "[*]", so it will replace two place holders by one and
+ a single last one by either "*" or nothing depending on
+ the modified flag.
+
+ \internal
+*/
QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widget)
{
Q_ASSERT(widget);
@@ -5370,16 +5399,21 @@ QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widg
QString cap = title;
#endif
- QString placeHolder(QLatin1String("[*]"));
+ if (cap.isEmpty())
+ return cap;
+
+ QLatin1String placeHolder("[*]");
+ int placeHolderLength = 3; // QLatin1String doesn't have length()
int index = cap.indexOf(placeHolder);
+ // here the magic begins
while (index != -1) {
- index += placeHolder.length();
+ index += placeHolderLength;
int count = 1;
while (cap.indexOf(placeHolder, index) == index) {
++count;
- index += placeHolder.length();
+ index += placeHolderLength;
}
if (count%2) { // odd number of [*] -> replace last one
@@ -5394,7 +5428,7 @@ QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widg
index = cap.indexOf(placeHolder, index);
}
- cap.replace(QLatin1String("[*][*]"), QLatin1String("[*]"));
+ cap.replace(QLatin1String("[*][*]"), placeHolder);
return cap;
}
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index 2008723..51605ba 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -143,7 +143,7 @@ class QWidgetPrivate;
class Q_GUI_EXPORT QWidget : public QObject, public QPaintDevice
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QWidget)
+ Q_DECLARE_SCOPED_PRIVATE(QWidget)
Q_PROPERTY(bool modal READ isModal)
Q_PROPERTY(Qt::WindowModality windowModality READ windowModality WRITE setWindowModality)
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 045bcb3..4797ddf 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -2575,7 +2575,11 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
qt_mac_destructWindow(window);
}
}
- d->setWinId(0);
+ QT_TRY {
+ d->setWinId(0);
+ } QT_CATCH (const std::bad_alloc &) {
+ // swallow - destructors must not throw
+ }
}
}
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 84a15ed..b425450 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -490,10 +490,11 @@ public:
QWidgetItemV2 *widgetItem;
QPaintEngine *extraPaintEngine;
mutable const QMetaObject *polished;
- // All widgets are initially added into the uncreatedWidgets set. Once
- // they receive a window id they are removed and added to the mapper
+ // All widgets are added into the allWidgets set. Once
+ // they receive a window id they are also added to the mapper.
+ // This should just ensure that all widgets are deleted by QApplication
static QWidgetMapper *mapper;
- static QWidgetSet *uncreatedWidgets;
+ static QWidgetSet *allWidgets;
#if !defined(QT_NO_IM)
QPointer<QInputContext> ic;
Qt::InputMethodHints imHints;
diff --git a/src/gui/kernel/qwidget_qws.cpp b/src/gui/kernel/qwidget_qws.cpp
index 4ded5cf..eacf656 100644
--- a/src/gui/kernel/qwidget_qws.cpp
+++ b/src/gui/kernel/qwidget_qws.cpp
@@ -298,11 +298,16 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
d->hide_sys();
}
if (destroyWindow && isWindow()) {
- d->extra->topextra->backingStore->windowSurface->setGeometry(QRect());
+ if (d->extra && d->extra->topextra && d->extra->topextra->backingStore)
+ d->extra->topextra->backingStore->windowSurface->setGeometry(QRect());
qwsDisplay()->destroyRegion(internalWinId());
}
}
- d->setWinId(0);
+ QT_TRY {
+ d->setWinId(0);
+ } QT_CATCH (const std::bad_alloc &) {
+ // swallow - destructors must not throw
+ }
}
}
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index d860eba..bf53f5d 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -89,7 +89,7 @@ void QWidgetPrivate::setSoftKeys_sys(const QList<QAction*> &softkeys)
return;
}
CEikButtonGroupContainer* nativeContainer = S60->buttonGroupContainer();
- nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS);
+ QT_TRAP_THROWING(nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS));
int position = -1;
int command;
@@ -137,12 +137,12 @@ void QWidgetPrivate::setSoftKeys_sys(const QList<QAction*> &softkeys)
if (position != -1) {
TPtrC text = qt_QString2TPtrC(softKeyAction->text());
- nativeContainer->SetCommandL(position, command, text);
+ QT_TRAP_THROWING(nativeContainer->SetCommandL(position, command, text));
}
}
if (needsExitButton)
- nativeContainer->SetCommandL(2, EAknSoftkeyExit, qt_QString2TPtrC(QObject::tr("Exit")));
+ QT_TRAP_THROWING(nativeContainer->SetCommandL(2, EAknSoftkeyExit, qt_QString2TPtrC(QObject::tr("Exit"))));
nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation
#else
@@ -310,10 +310,8 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
} else if (topLevel) {
if (!q->testAttribute(Qt::WA_Moved) && !q->testAttribute(Qt::WA_DontShowOnScreen))
data.crect.moveTopLeft(QPoint(clientRect.iTl.iX, clientRect.iTl.iY));
- QSymbianControl *control= new QSymbianControl(q);
- control->ConstructL(true,desktop);
-
-
+ QSymbianControl *control= q_check_ptr(new QSymbianControl(q));
+ QT_TRAP_THROWING(control->ConstructL(true,desktop));
if (!desktop) {
TInt stackingFlags;
if ((q->windowType() & Qt::Popup) == Qt::Popup) {
@@ -350,7 +348,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
control->SetRect(TRect(TPoint(x, y), TSize(w, h)));
} else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget
QSymbianControl *control = new QSymbianControl(q);
- control->ConstructL(!parentWidget);
+ QT_TRAP_THROWING(control->ConstructL(!parentWidget));
TInt stackingFlags;
if ((q->windowType() & Qt::Popup) == Qt::Popup) {
@@ -362,7 +360,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
setWinId(control);
WId parentw = parentWidget->effectiveWinId();
- control->SetContainerWindowL(*parentw);
+ QT_TRAP_THROWING(control->SetContainerWindowL(*parentw));
q->setAttribute(Qt::WA_WState_Created);
int x, y, w, h;
@@ -397,7 +395,7 @@ void QWidgetPrivate::show_sys()
WId id = q->internalWinId();
if (!extra->topextra->activated) {
- id->ActivateL();
+ QT_TRAP_THROWING(id->ActivateL());
extra->topextra->activated = 1;
}
id->MakeVisible(true);
@@ -621,9 +619,9 @@ void QWidgetPrivate::s60UpdateIsOpaque()
}
}
-CFbsBitmap* qt_pixmapToNativeBitmapL(QPixmap pixmap, bool invert)
+CFbsBitmap* qt_pixmapToNativeBitmap(QPixmap pixmap, bool invert)
{
- CFbsBitmap* fbsBitmap = new(ELeave)CFbsBitmap;
+ CFbsBitmap* fbsBitmap = q_check_ptr(new CFbsBitmap); // CBase derived object needs check on new
TSize size(pixmap.size().width(), pixmap.size().height());
TDisplayMode mode(EColor16MU);
@@ -659,7 +657,7 @@ CFbsBitmap* qt_pixmapToNativeBitmapL(QPixmap pixmap, bool invert)
break;
}
- User::LeaveIfError(fbsBitmap->Create(size, mode));
+ qt_throwIfError(fbsBitmap->Create(size, mode));
fbsBitmap->LockHeap();
QImage image = pixmap.toImage();
@@ -714,7 +712,7 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
contextPane->SetPicture(nBitmap,nMask);
} else {
// Icon set to null -> set context pane picture to default
- contextPane->SetPictureToDefaultL();
+ QT_TRAP_THROWING(contextPane->SetPictureToDefaultL());
}
} else {
// Context pane does not exist, try setting small icon to title pane
@@ -769,7 +767,7 @@ void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
if(caption.isEmpty())
titlePane->SetTextToDefaultL();
else
- titlePane->SetTextL(qt_QString2TPtrC(caption));
+ QT_TRAP_THROWING(titlePane->SetTextL(qt_QString2TPtrC(caption)));
}
}
#else
@@ -1125,7 +1123,11 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
}
- d->setWinId(0);
+ QT_TRY {
+ d->setWinId(0);
+ } QT_CATCH (const std::bad_alloc &) {
+ // swallow - destructors must not throw
+ }
}
}
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index e39ca77..9d31f57 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -577,7 +577,11 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
}
#endif
- d->setWinId(0);
+ QT_TRY {
+ d->setWinId(0);
+ } QT_CATCH (const std::bad_alloc &) {
+ // swallow - destructors must not throw
+ }
}
}
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index 2a3d2f3..2bb3626 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -1008,7 +1008,11 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
if (destroyWindow)
qt_XDestroyWindow(this, X11->display, data->winid);
}
- d->setWinId(0);
+ QT_TRY {
+ d->setWinId(0);
+ } QT_CATCH (const std::bad_alloc &) {
+ // swallow - destructors must not throw
+ }
extern void qPRCleanup(QWidget *widget); // from qapplication_x11.cpp
if (testAttribute(Qt::WA_WState_Reparented))
diff --git a/src/gui/kernel/qwidgetaction.h b/src/gui/kernel/qwidgetaction.h
index 4ec489e..a39b281 100644
--- a/src/gui/kernel/qwidgetaction.h
+++ b/src/gui/kernel/qwidgetaction.h
@@ -57,7 +57,7 @@ class QWidgetActionPrivate;
class Q_GUI_EXPORT QWidgetAction : public QAction
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QWidgetAction)
+ Q_DECLARE_SCOPED_PRIVATE(QWidgetAction)
public:
explicit QWidgetAction(QObject *parent);
diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/gui/kernel/qx11embed_x11.cpp
index 3ddde1b..84d7d0a 100644
--- a/src/gui/kernel/qx11embed_x11.cpp
+++ b/src/gui/kernel/qx11embed_x11.cpp
@@ -269,7 +269,7 @@ const int XButtonRelease = ButtonRelease;
// need to to inspect window()'s embedded state.
class QHackWidget : public QWidget
{
- Q_DECLARE_PRIVATE(QWidget)
+ Q_DECLARE_SCOPED_PRIVATE(QWidget)
public:
QTLWExtra* topData() { return d_func()->topData(); }
};
diff --git a/src/gui/kernel/qx11embed_x11.h b/src/gui/kernel/qx11embed_x11.h
index 8659ed6..0d67c23 100644
--- a/src/gui/kernel/qx11embed_x11.h
+++ b/src/gui/kernel/qx11embed_x11.h
@@ -80,7 +80,7 @@ protected:
void resizeEvent(QResizeEvent *);
private:
- Q_DECLARE_PRIVATE(QX11EmbedWidget)
+ Q_DECLARE_SCOPED_PRIVATE(QX11EmbedWidget)
Q_DISABLE_COPY(QX11EmbedWidget)
};
@@ -121,7 +121,7 @@ protected:
bool event(QEvent *);
private:
- Q_DECLARE_PRIVATE(QX11EmbedContainer)
+ Q_DECLARE_SCOPED_PRIVATE(QX11EmbedContainer)
Q_DISABLE_COPY(QX11EmbedContainer)
};