summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
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/corelib/kernel
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/corelib/kernel')
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.h2
-rw-r--r--src/corelib/kernel/qabstractitemmodel.h2
-rw-r--r--src/corelib/kernel/qcore_symbian_p.cpp8
-rw-r--r--src/corelib/kernel/qcore_symbian_p.h4
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp4
-rw-r--r--src/corelib/kernel/qcoreapplication.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp44
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian_p.h5
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h2
-rw-r--r--src/corelib/kernel/qeventloop.h2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp2
-rw-r--r--src/corelib/kernel/qmimedata.h2
-rw-r--r--src/corelib/kernel/qobject.cpp99
-rw-r--r--src/corelib/kernel/qobject.h2
-rw-r--r--src/corelib/kernel/qsharedmemory.h2
-rw-r--r--src/corelib/kernel/qsignalmapper.h2
-rw-r--r--src/corelib/kernel/qsocketnotifier.h2
-rw-r--r--src/corelib/kernel/qsystemsemaphore_symbian.cpp4
-rw-r--r--src/corelib/kernel/qtranslator.h2
-rw-r--r--src/corelib/kernel/qvariant.cpp18
-rw-r--r--src/corelib/kernel/qwineventnotifier_p.h2
23 files changed, 139 insertions, 77 deletions
diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h
index 0550dde..93815f6 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.h
+++ b/src/corelib/kernel/qabstracteventdispatcher.h
@@ -58,7 +58,7 @@ template <typename T1, typename T2> struct QPair;
class Q_CORE_EXPORT QAbstractEventDispatcher : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QAbstractEventDispatcher)
+ Q_DECLARE_SCOPED_PRIVATE(QAbstractEventDispatcher)
public:
typedef QPair<int, int> TimerInfo;
diff --git a/src/corelib/kernel/qabstractitemmodel.h b/src/corelib/kernel/qabstractitemmodel.h
index a6bbff4..2503393 100644
--- a/src/corelib/kernel/qabstractitemmodel.h
+++ b/src/corelib/kernel/qabstractitemmodel.h
@@ -287,7 +287,7 @@ protected:
void setRoleNames(const QHash<int,QByteArray> &roleNames);
private:
- Q_DECLARE_PRIVATE(QAbstractItemModel)
+ Q_DECLARE_SCOPED_PRIVATE(QAbstractItemModel)
Q_DISABLE_COPY(QAbstractItemModel)
};
diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp
index a3a85b0..c681b1f 100644
--- a/src/corelib/kernel/qcore_symbian_p.cpp
+++ b/src/corelib/kernel/qcore_symbian_p.cpp
@@ -61,13 +61,12 @@ Q_CORE_EXPORT HBufC* qt_QString2HBufC(const QString& aString)
#else
TPtrC16 ptr(qt_QString2TPtrC(aString));
#endif
- buffer = HBufC::New(ptr.Length());
- Q_CHECK_PTR(buffer);
+ buffer = q_check_ptr(HBufC::New(ptr.Length()));
buffer->Des().Copy(ptr);
return buffer;
}
-Q_CORE_EXPORT QString qt_TDesC2QStringL(const TDesC& aDescriptor)
+Q_CORE_EXPORT QString qt_TDesC2QString(const TDesC& aDescriptor)
{
#ifdef QT_NO_UNICODE
return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length());
@@ -82,9 +81,8 @@ QHBufC::QHBufC()
}
QHBufC::QHBufC(const QHBufC &src)
+ : m_hBufC(q_check_ptr(src.m_hBufC->Alloc()))
{
- m_hBufC = src.m_hBufC->Alloc();
- Q_CHECK_PTR(m_hBufC);
}
/*!
diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h
index bd8f304..453c3d3 100644
--- a/src/corelib/kernel/qcore_symbian_p.h
+++ b/src/corelib/kernel/qcore_symbian_p.h
@@ -65,8 +65,8 @@ QT_BEGIN_NAMESPACE
Q_CORE_EXPORT HBufC* qt_QString2HBufC(const QString& aString);
-Q_CORE_EXPORT QString qt_TDesC2QStringL(const TDesC& aDescriptor);
-inline QString qt_TDes2QStringL(const TDes& aDescriptor) { return qt_TDesC2QStringL(aDescriptor); }
+Q_CORE_EXPORT QString qt_TDesC2QString(const TDesC& aDescriptor);
+inline QString qt_TDes2QString(const TDes& aDescriptor) { return qt_TDesC2QString(aDescriptor); }
static inline QSize qt_TSize2QSize(const TSize& ts)
{
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index b84ad53..4a1da35 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1119,6 +1119,9 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority)
event->d = reinterpret_cast<QEventPrivate *>(quintptr(data->loopLevel));
}
+ // delete the event on exceptions to protect against memory leaks till the event is
+ // properly owned in the postEventList
+ QScopedPointer<QEvent> eventDeleter(event);
if (data->postEventList.isEmpty() || data->postEventList.last().priority >= priority) {
// optimization: we can simply append if the last event in
// the queue has higher or equal priority
@@ -1133,6 +1136,7 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority)
QPostEventList::iterator at = qUpperBound(begin, end, priority);
data->postEventList.insert(at, QPostEvent(receiver, event, priority));
}
+ eventDeleter.take();
event->posted = true;
++receiver->d_func()->postedEvents;
data->canWait = false;
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 48e65a7..60b0882 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -76,7 +76,7 @@ class Q_CORE_EXPORT QCoreApplication : public QObject
Q_PROPERTY(QString organizationName READ organizationName WRITE setOrganizationName)
Q_PROPERTY(QString organizationDomain READ organizationDomain WRITE setOrganizationDomain)
- Q_DECLARE_PRIVATE(QCoreApplication)
+ Q_DECLARE_SCOPED_PRIVATE(QCoreApplication)
public:
QCoreApplication(int &argc, char **argv);
~QCoreApplication();
diff --git a/src/corelib/kernel/qeventdispatcher_glib_p.h b/src/corelib/kernel/qeventdispatcher_glib_p.h
index 80ec9fa..bcb655b 100644
--- a/src/corelib/kernel/qeventdispatcher_glib_p.h
+++ b/src/corelib/kernel/qeventdispatcher_glib_p.h
@@ -67,7 +67,7 @@ class QEventDispatcherGlibPrivate;
class Q_CORE_EXPORT QEventDispatcherGlib : public QAbstractEventDispatcher
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QEventDispatcherGlib)
+ Q_DECLARE_SCOPED_PRIVATE(QEventDispatcherGlib)
public:
explicit QEventDispatcherGlib(QObject *parent = 0);
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index 34a20da..e876843 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -194,7 +194,7 @@ void QWakeUpActiveObject::RunL()
{
iStatus = KRequestPending;
SetActive();
- QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(m_dispatcher->wakeUpWasCalled());
+ QT_TRYCATCH_LEAVING(m_dispatcher->wakeUpWasCalled());
}
QTimerActiveObject::QTimerActiveObject(QEventDispatcherSymbian *dispatcher, SymbianTimerInfo *timerInfo)
@@ -224,7 +224,7 @@ void QTimerActiveObject::DoCancel()
void QTimerActiveObject::RunL()
{
int error;
- QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR(error, Run());
+ QT_TRYCATCH_ERROR(error, Run());
if (error < 0) {
CActiveScheduler::Current()->Error(error); // stop and report here, as this timer will be deleted on scope exit
}
@@ -274,6 +274,11 @@ void QTimerActiveObject::Start()
}
}
+SymbianTimerInfo::SymbianTimerInfo()
+: timerAO(0)
+{
+}
+
SymbianTimerInfo::~SymbianTimerInfo()
{
delete timerAO;
@@ -314,7 +319,7 @@ void QCompleteDeferredAOs::RunL()
iStatus = KRequestPending;
SetActive();
- QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(m_dispatcher->reactivateDeferredActiveObjects());
+ QT_TRYCATCH_LEAVING(m_dispatcher->reactivateDeferredActiveObjects());
}
QSelectThread::QSelectThread()
@@ -587,7 +592,7 @@ void QSocketActiveObject::RunL()
if (!okToRun())
return;
- QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(m_dispatcher->socketFired(this));
+ QT_TRYCATCH_LEAVING(m_dispatcher->socketFired(this));
}
void QSocketActiveObject::deleteLater()
@@ -619,11 +624,11 @@ QEventDispatcherSymbian::~QEventDispatcherSymbian()
void QEventDispatcherSymbian::startingUp()
{
if( !CActiveScheduler::Current() ) {
- m_activeScheduler = new(ELeave)CQtActiveScheduler();
+ m_activeScheduler = q_check_ptr(new CQtActiveScheduler()); // CBase derived class needs to be checked on new
CActiveScheduler::Install(m_activeScheduler);
}
- m_wakeUpAO = new(ELeave) QWakeUpActiveObject(this);
- m_completeDeferredAOs = new(ELeave) QCompleteDeferredAOs(this);
+ m_wakeUpAO = q_check_ptr(new QWakeUpActiveObject(this));
+ m_completeDeferredAOs = q_check_ptr(new QCompleteDeferredAOs(this));
// We already might have posted events, wakeup once to process them
wakeUp();
}
@@ -647,7 +652,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla
QT_TRY {
Q_D(QAbstractEventDispatcher);
-
+
// It is safe if this counter overflows. The main importance is that each
// iteration count is different from the last.
m_iterationCount++;
@@ -742,7 +747,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla
m_noSocketEvents = oldNoSocketEventsValue;
} QT_CATCH (const std::exception& ex) {
#ifndef QT_NO_EXCEPTIONS
- CActiveScheduler::Current()->Error(qt_translateExceptionToSymbianError(ex));
+ CActiveScheduler::Current()->Error(qt_exception2SymbianError(ex));
#endif
}
@@ -896,7 +901,7 @@ bool QEventDispatcherSymbian::hasPendingEvents()
void QEventDispatcherSymbian::registerSocketNotifier ( QSocketNotifier * notifier )
{
- QSocketActiveObject *socketAO = new (ELeave) QSocketActiveObject(this, notifier);
+ QSocketActiveObject *socketAO = q_check_ptr(new QSocketActiveObject(this, notifier));
m_notifiers.insert(notifier, socketAO);
m_selectThread.requestSocketEvents(notifier, &socketAO->iStatus);
}
@@ -930,7 +935,7 @@ void QEventDispatcherSymbian::registerTimer ( int timerId, int interval, QObject
timer->inTimerEvent = false;
timer->receiver = object;
timer->dispatcher = this;
- timer->timerAO = new(ELeave) QTimerActiveObject(this, timer.data());
+ timer->timerAO = q_check_ptr(new QTimerActiveObject(this, timer.data()));
m_timerList.insert(timerId, timer);
timer->timerAO->Start();
@@ -952,16 +957,20 @@ bool QEventDispatcherSymbian::unregisterTimer ( int timerId )
bool QEventDispatcherSymbian::unregisterTimers ( QObject * object )
{
- QList<TimerInfo> idsToRemove = registeredTimers(object);
-
- if (idsToRemove.isEmpty())
+ if (m_timerList.isEmpty())
return false;
- for (int c = 0; c < idsToRemove.size(); ++c) {
- unregisterTimer(idsToRemove[c].first);
+ bool unregistered = false;
+ for (QHash<int, SymbianTimerInfoPtr>::iterator i = m_timerList.begin(); i != m_timerList.end(); ) {
+ if ((*i)->receiver == object) {
+ i = m_timerList.erase(i);
+ unregistered = true;
+ } else {
+ ++i;
+ }
}
- return true;
+ return unregistered;
}
QList<QEventDispatcherSymbian::TimerInfo> QEventDispatcherSymbian::registeredTimers ( QObject * object ) const
@@ -993,4 +1002,3 @@ void CQtActiveScheduler::Error(TInt aError) const
}
QT_END_NAMESPACE
-
diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h
index b39d6df..310d74d 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian_p.h
+++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h
@@ -112,6 +112,7 @@ private:
struct SymbianTimerInfo : public QSharedData
{
+ SymbianTimerInfo();
~SymbianTimerInfo();
int timerId;
@@ -183,7 +184,7 @@ private:
class QSelectThread : public QThread
{
- Q_DECLARE_PRIVATE(QThread)
+ Q_DECLARE_SCOPED_PRIVATE(QThread)
public:
QSelectThread();
@@ -217,7 +218,7 @@ public: // from CActiveScheduler
class Q_CORE_EXPORT QEventDispatcherSymbian : public QAbstractEventDispatcher
{
- Q_DECLARE_PRIVATE(QAbstractEventDispatcher)
+ Q_DECLARE_SCOPED_PRIVATE(QAbstractEventDispatcher)
public:
QEventDispatcherSymbian(QObject *parent = 0);
diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h
index a52af00..70c287f 100644
--- a/src/corelib/kernel/qeventdispatcher_unix_p.h
+++ b/src/corelib/kernel/qeventdispatcher_unix_p.h
@@ -142,7 +142,7 @@ class QEventDispatcherUNIXPrivate;
class Q_CORE_EXPORT QEventDispatcherUNIX : public QAbstractEventDispatcher
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QEventDispatcherUNIX)
+ Q_DECLARE_SCOPED_PRIVATE(QEventDispatcherUNIX)
public:
explicit QEventDispatcherUNIX(QObject *parent = 0);
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index ca5dbf8..37578a0 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -67,7 +67,7 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcher
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QEventDispatcherWin32)
+ Q_DECLARE_SCOPED_PRIVATE(QEventDispatcherWin32)
void createInternalHwnd();
friend class QGuiEventDispatcherWin32;
diff --git a/src/corelib/kernel/qeventloop.h b/src/corelib/kernel/qeventloop.h
index 60d00df..e14e352 100644
--- a/src/corelib/kernel/qeventloop.h
+++ b/src/corelib/kernel/qeventloop.h
@@ -55,7 +55,7 @@ class QEventLoopPrivate;
class Q_CORE_EXPORT QEventLoop : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QEventLoop)
+ Q_DECLARE_SCOPED_PRIVATE(QEventLoop)
public:
explicit QEventLoop(QObject *parent = 0);
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 9ff0bc1..7f8d2e8 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -1571,7 +1571,9 @@ bool QMetaMethod::invoke(QObject *object,
int nargs = 1; // include return type
void **args = (void **) qMalloc(paramCount * sizeof(void *));
+ Q_CHECK_PTR(args);
int *types = (int *) qMalloc(paramCount * sizeof(int));
+ Q_CHECK_PTR(types);
types[0] = 0; // return type
args[0] = 0;
diff --git a/src/corelib/kernel/qmimedata.h b/src/corelib/kernel/qmimedata.h
index 609528a..9366c5d 100644
--- a/src/corelib/kernel/qmimedata.h
+++ b/src/corelib/kernel/qmimedata.h
@@ -94,7 +94,7 @@ protected:
QVariant::Type preferredType) const;
private:
Q_DISABLE_COPY(QMimeData)
- Q_DECLARE_PRIVATE(QMimeData)
+ Q_DECLARE_SCOPED_PRIVATE(QMimeData)
};
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index e849227..2630b63 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -72,6 +72,7 @@ static int DIRECT_CONNECTION_ONLY = 0;
static int *queuedConnectionTypes(const QList<QByteArray> &typeNames)
{
int *types = new int [typeNames.count() + 1];
+ Q_CHECK_PTR(types);
for (int i = 0; i < typeNames.count(); ++i) {
const QByteArray typeName = typeNames.at(i);
if (typeName.endsWith('*'))
@@ -405,6 +406,10 @@ void QMetaObject::changeGuard(QObject **ptr, QObject *o)
return;
}
QMutexLocker locker(guardHashLock());
+ if (o) {
+ hash->insert(o, ptr);
+ QObjectPrivate::get(o)->hasGuards = true;
+ }
if (*ptr) {
bool more = false; //if the QObject has more pointer attached to it.
GuardHash::iterator it = hash->find(*ptr);
@@ -421,10 +426,6 @@ void QMetaObject::changeGuard(QObject **ptr, QObject *o)
QObjectPrivate::get(*ptr)->hasGuards = false;
}
*ptr = o;
- if (*ptr) {
- hash->insert(*ptr, ptr);
- QObjectPrivate::get(*ptr)->hasGuards = true;
- }
}
/*! \internal
@@ -685,12 +686,18 @@ QObject::QObject(QObject *parent)
: d_ptr(new QObjectPrivate)
{
Q_D(QObject);
- qt_addObject(d_ptr->q_ptr = this);
+ d_ptr->q_ptr = this;
d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current();
d->threadData->ref();
- if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
- parent = 0;
- setParent(parent);
+ QT_TRY {
+ if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
+ parent = 0;
+ setParent(parent);
+ } QT_CATCH(...) {
+ d->threadData->deref();
+ QT_RETHROW;
+ }
+ qt_addObject(this);
}
#ifdef QT3_SUPPORT
@@ -720,20 +727,26 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent)
: d_ptr(&dd)
{
Q_D(QObject);
- qt_addObject(d_ptr->q_ptr = this);
+ d_ptr->q_ptr = this;
d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current();
d->threadData->ref();
- if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
- parent = 0;
- if (d->isWidget) {
- if (parent) {
- d->parent = parent;
- d->parent->d_func()->children.append(this);
+ QT_TRY {
+ if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
+ parent = 0;
+ if (d->isWidget) {
+ if (parent) {
+ d->parent = parent;
+ d->parent->d_func()->children.append(this);
+ }
+ // no events sent here, this is done at the end of the QWidget constructor
+ } else {
+ setParent(parent);
}
- // no events sent here, this is done at the end of the QWidget constructor
- } else {
- setParent(parent);
+ } QT_CATCH(...) {
+ d->threadData->deref();
+ QT_RETHROW;
}
+ qt_addObject(this);
}
/*!
@@ -785,11 +798,26 @@ QObject::~QObject()
// all the signal/slots connections are still in place - if we don't
// quit now, we will crash pretty soon.
qWarning("Detected an unexpected exception in ~QObject while emitting destroyed().");
+#if defined(Q_AUTOTEST_EXPORT) && !defined(QT_NO_EXCEPTIONS)
+ struct AutotestException : public std::exception
+ {
+ const char *what() const throw() { return "autotest swallow"; }
+ } autotestException;
+ // throw autotestException;
+
+#else
QT_RETHROW;
+#endif
}
{
- QMutexLocker locker(signalSlotLock(this));
+ QMutex *signalSlotMutex = 0;
+ QT_TRY {
+ signalSlotMutex = signalSlotLock(this);
+ } QT_CATCH(const std::bad_alloc &) {
+ // out of memory - swallow to prevent a crash
+ }
+ QMutexLocker locker(signalSlotMutex);
// set ref to zero to indicate that this object has been deleted
if (d->currentSender != 0)
@@ -2709,8 +2737,14 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
QByteArray signal_name;
bool signal_found = false;
if (signal) {
- signal_name = QMetaObject::normalizedSignature(signal);
- signal = signal_name;
+ QT_TRY {
+ signal_name = QMetaObject::normalizedSignature(signal);
+ signal = signal_name.constData();
+ } QT_CATCH (const std::bad_alloc &) {
+ // if the signal is already normalized, we can continue.
+ if (sender->metaObject()->indexOfSignal(signal + 1) == -1)
+ QT_RETHROW;
+ }
if (!check_signal_macro(sender, signal, "disconnect", "unbind"))
return false;
@@ -2722,8 +2756,15 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
int membcode = -1;
bool method_found = false;
if (method) {
- method_name = QMetaObject::normalizedSignature(method);
- method = method_name;
+ QT_TRY {
+ method_name = QMetaObject::normalizedSignature(method);
+ method = method_name.constData();
+ } QT_CATCH(const std::bad_alloc &) {
+ // if the method is already normalized, we can continue.
+ if (receiver->metaObject()->indexOfMethod(method + 1) == -1)
+ QT_RETHROW;
+ }
+
membcode = extract_code(method);
if (!check_method_code(membcode, receiver, method, "disconnect"))
return false;
@@ -2882,14 +2923,20 @@ bool QMetaObject::connect(const QObject *sender, int signal_index,
c->method = method_index;
c->connectionType = type;
c->argumentTypes = types;
+
+ QT_TRY {
+ s->d_func()->addConnection(signal_index, c);
+ } QT_CATCH(...) {
+ delete c;
+ QT_RETHROW;
+ }
+
c->prev = &r->d_func()->senders;
c->next = *c->prev;
*c->prev = c;
if (c->next)
c->next->prev = &c->next;
- s->d_func()->addConnection(signal_index, c);
-
if (signal_index < 0) {
for (uint i = 0; i < (sizeof sender->d_func()->connectedSignals
/ sizeof sender->d_func()->connectedSignals[0] ); ++i)
@@ -3081,7 +3128,9 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect
while (c->argumentTypes[nargs-1])
++nargs;
int *types = (int *) qMalloc(nargs*sizeof(int));
+ Q_CHECK_PTR(types);
void **args = (void **) qMalloc(nargs*sizeof(void *));
+ Q_CHECK_PTR(args);
types[0] = 0; // return type
args[0] = 0; // return value
for (int n = 1; n < nargs; ++n)
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index a9f005b..200c97d 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -118,7 +118,7 @@ class Q_CORE_EXPORT QObject
{
Q_OBJECT
Q_PROPERTY(QString objectName READ objectName WRITE setObjectName)
- Q_DECLARE_PRIVATE(QObject)
+ Q_DECLARE_SCOPED_PRIVATE(QObject)
public:
Q_INVOKABLE explicit QObject(QObject *parent=0);
diff --git a/src/corelib/kernel/qsharedmemory.h b/src/corelib/kernel/qsharedmemory.h
index 4957c3e..0e15ebe 100644
--- a/src/corelib/kernel/qsharedmemory.h
+++ b/src/corelib/kernel/qsharedmemory.h
@@ -57,7 +57,7 @@ class QSharedMemoryPrivate;
class Q_CORE_EXPORT QSharedMemory : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QSharedMemory)
+ Q_DECLARE_SCOPED_PRIVATE(QSharedMemory)
public:
enum AccessMode
diff --git a/src/corelib/kernel/qsignalmapper.h b/src/corelib/kernel/qsignalmapper.h
index 7bc5035..8c1f663 100644
--- a/src/corelib/kernel/qsignalmapper.h
+++ b/src/corelib/kernel/qsignalmapper.h
@@ -56,7 +56,7 @@ class QSignalMapperPrivate;
class Q_CORE_EXPORT QSignalMapper : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QSignalMapper)
+ Q_DECLARE_SCOPED_PRIVATE(QSignalMapper)
public:
explicit QSignalMapper(QObject *parent = 0);
~QSignalMapper();
diff --git a/src/corelib/kernel/qsocketnotifier.h b/src/corelib/kernel/qsocketnotifier.h
index 96dda35..bc5d97d 100644
--- a/src/corelib/kernel/qsocketnotifier.h
+++ b/src/corelib/kernel/qsocketnotifier.h
@@ -53,7 +53,7 @@ QT_MODULE(Core)
class Q_CORE_EXPORT QSocketNotifier : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QObject)
+ Q_DECLARE_SCOPED_PRIVATE(QObject)
public:
enum Type { Read, Write, Exception };
diff --git a/src/corelib/kernel/qsystemsemaphore_symbian.cpp b/src/corelib/kernel/qsystemsemaphore_symbian.cpp
index 8179046..1516841 100644
--- a/src/corelib/kernel/qsystemsemaphore_symbian.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_symbian.cpp
@@ -47,7 +47,7 @@
#include <qcore_symbian_p.h>
#include <e32cmn.h>
QT_BEGIN_NAMESPACE
-
+
#ifndef QT_NO_SYSTEMSEMAPHORE
QSystemSemaphorePrivate::QSystemSemaphorePrivate() :
@@ -65,7 +65,7 @@ void QSystemSemaphorePrivate::setErrorString(const QString &function, int err)
errorString = QCoreApplication::tr("%1: already exists", "QSystemSemaphore").arg(function);
error = QSystemSemaphore::AlreadyExists;
break;
- case KErrNotFound:
+ case KErrNotFound:
errorString = QCoreApplication::tr("%1: doesn't exists", "QSystemSemaphore").arg(function);
error = QSystemSemaphore::NotFound;
break;
diff --git a/src/corelib/kernel/qtranslator.h b/src/corelib/kernel/qtranslator.h
index b4cea18..1f94210 100644
--- a/src/corelib/kernel/qtranslator.h
+++ b/src/corelib/kernel/qtranslator.h
@@ -86,7 +86,7 @@ public:
private:
Q_DISABLE_COPY(QTranslator)
- Q_DECLARE_PRIVATE(QTranslator)
+ Q_DECLARE_SCOPED_PRIVATE(QTranslator)
};
#endif // QT_NO_TRANSLATION
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index b487615..5016d3b 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -156,7 +156,7 @@ static void construct(QVariant::Private *x, const void *copy)
x->data.b = copy ? *static_cast<const bool *>(copy) : false;
break;
case QVariant::Double:
-#if defined(Q_CC_RVCT)
+#if defined(Q_CC_RVCT)
// Using trinary operator with 64bit constants crashes when ran on Symbian device
if (copy){
x->data.d = *static_cast<const double*>(copy);
@@ -165,13 +165,13 @@ static void construct(QVariant::Private *x, const void *copy)
}
#else
x->data.d = copy ? *static_cast<const double*>(copy) : 0.0;
-#endif
+#endif
break;
case QMetaType::Float:
x->data.f = copy ? *static_cast<const float*>(copy) : 0.0f;
break;
case QVariant::LongLong:
-#if defined(Q_CC_RVCT)
+#if defined(Q_CC_RVCT)
// Using trinary operator with 64bit constants crashes when ran on Symbian device
if (copy){
x->data.ll = *static_cast<const qlonglong *>(copy);
@@ -180,10 +180,10 @@ static void construct(QVariant::Private *x, const void *copy)
}
#else
x->data.ll = copy ? *static_cast<const qlonglong *>(copy) : Q_INT64_C(0);
-#endif
+#endif
break;
case QVariant::ULongLong:
-#if defined(Q_CC_RVCT)
+#if defined(Q_CC_RVCT)
// Using trinary operator with 64bit constants crashes when ran on Symbian device
if (copy){
x->data.ull = *static_cast<const qulonglong *>(copy);
@@ -192,7 +192,7 @@ static void construct(QVariant::Private *x, const void *copy)
}
#else
x->data.ull = copy ? *static_cast<const qulonglong *>(copy) : Q_UINT64_C(0);
-#endif
+#endif
break;
case QVariant::Invalid:
case QVariant::UserType:
@@ -618,7 +618,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
ok = &dummy;
switch (uint(t)) {
- case QVariant::Url:
+ case QVariant::Url:
switch (d->type) {
case QVariant::String:
*static_cast<QUrl *>(result) = QUrl(*v_cast<QString>(d));
@@ -1214,8 +1214,8 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler;
and versatile, but may prove less memory and speed efficient than
storing specific types in standard data structures.
- QVariant also supports the notion of null values, where you can
- have a defined type with no value set. However, note that QVariant
+ QVariant also supports the notion of null values, where you can
+ have a defined type with no value set. However, note that QVariant
types can only be cast when they have had a value set.
\snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 1
diff --git a/src/corelib/kernel/qwineventnotifier_p.h b/src/corelib/kernel/qwineventnotifier_p.h
index 07aa0ae..2c8934f 100644
--- a/src/corelib/kernel/qwineventnotifier_p.h
+++ b/src/corelib/kernel/qwineventnotifier_p.h
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QWinEventNotifier : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QObject)
+ Q_DECLARE_SCOPED_PRIVATE(QObject)
public:
explicit QWinEventNotifier(QObject *parent = 0);