- Add const
- Add explicit (only effect under C++11;
C++98 knows no multi-arg implicit conversions)
- Add Q_DECL_OVERRIDE to qt_metacall reimplementation
- Add reserve() calls on containers
- Change 'args' from QList to QVector for a 2x
memory reduction on 64bit platforms
Change-Id: If6c779dac0499d4ab64e5191d37596edf7341f76
Reviewed-by: hjk <qthjk@ovi.com>
Reviewed-by: Andreas Aardal Hanssen <andreas@hanssen.name>
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
#include <QtCore/qobject.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/qvariant.h>
#include <QtCore/qobject.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/qvariant.h>
+#include <QtCore/qvector.h>
#include <QtTest/qtesteventloop.h>
QT_BEGIN_HEADER
#include <QtTest/qtesteventloop.h>
QT_BEGIN_HEADER
class QSignalSpy: public QObject, public QList<QList<QVariant> >
{
public:
class QSignalSpy: public QObject, public QList<QList<QVariant> >
{
public:
- QSignalSpy(QObject *obj, const char *aSignal)
+ explicit QSignalSpy(const QObject *obj, const char *aSignal)
: m_waiting(false)
{
#ifdef Q_CC_BOR
: m_waiting(false)
{
#ifdef Q_CC_BOR
- QByteArray ba = QMetaObject::normalizedSignature(aSignal + 1);
- const QMetaObject *mo = obj->metaObject();
- int sigIndex = mo->indexOfMethod(ba.constData());
+ const QByteArray ba = QMetaObject::normalizedSignature(aSignal + 1);
+ const QMetaObject * const mo = obj->metaObject();
+ const int sigIndex = mo->indexOfMethod(ba.constData());
if (sigIndex < 0) {
qWarning("QSignalSpy: No such signal: '%s'", ba.constData());
return;
if (sigIndex < 0) {
qWarning("QSignalSpy: No such signal: '%s'", ba.constData());
return;
return count() > origCount;
}
return count() > origCount;
}
- int qt_metacall(QMetaObject::Call call, int methodId, void **a)
+ int qt_metacall(QMetaObject::Call call, int methodId, void **a) Q_DECL_OVERRIDE
{
methodId = QObject::qt_metacall(call, methodId, a);
if (methodId < 0)
{
methodId = QObject::qt_metacall(call, methodId, a);
if (methodId < 0)
private:
void initArgs(const QMetaMethod &member)
{
private:
void initArgs(const QMetaMethod &member)
{
- QList<QByteArray> params = member.parameterTypes();
+ const QList<QByteArray> params = member.parameterTypes();
+ args.reserve(params.size());
for (int i = 0; i < params.count(); ++i) {
for (int i = 0; i < params.count(); ++i) {
- int tp = QMetaType::type(params.at(i).constData());
+ const int tp = QMetaType::type(params.at(i).constData());
if (tp == QMetaType::UnknownType) {
Q_ASSERT(tp != QMetaType::Void); // void parameter => metaobject is corrupt
qWarning("Don't know how to handle '%s', use qRegisterMetaType to register it.",
if (tp == QMetaType::UnknownType) {
Q_ASSERT(tp != QMetaType::Void); // void parameter => metaobject is corrupt
qWarning("Don't know how to handle '%s', use qRegisterMetaType to register it.",
void appendArgs(void **a)
{
QList<QVariant> list;
void appendArgs(void **a)
{
QList<QVariant> list;
+ list.reserve(args.count());
for (int i = 0; i < args.count(); ++i) {
for (int i = 0; i < args.count(); ++i) {
- QMetaType::Type type = static_cast<QMetaType::Type>(args.at(i));
+ const QMetaType::Type type = static_cast<QMetaType::Type>(args.at(i));
if (type == QMetaType::QVariant)
list << *reinterpret_cast<QVariant *>(a[i + 1]);
else
if (type == QMetaType::QVariant)
list << *reinterpret_cast<QVariant *>(a[i + 1]);
else
// the full, normalized signal name
QByteArray sig;
// holds the QMetaType types for the argument list of the signal
// the full, normalized signal name
QByteArray sig;
// holds the QMetaType types for the argument list of the signal
QTestEventLoop m_loop;
bool m_waiting;
QTestEventLoop m_loop;
bool m_waiting;
\snippet code/doc_src_qsignalspy.cpp 3
*/
\snippet code/doc_src_qsignalspy.cpp 3
*/
-/*! \fn QSignalSpy::QSignalSpy(QObject *object, const char *signal)
+/*! \fn QSignalSpy::QSignalSpy(const QObject *object, const char *signal)
Constructs a new QSignalSpy that listens for emissions of the \a signal
from the QObject \a object. If QSignalSpy is not able to listen for a
Constructs a new QSignalSpy that listens for emissions of the \a signal
from the QObject \a object. If QSignalSpy is not able to listen for a