Fix dangling pointer dereferencing

That long call chain is screaming "here, I'm dereferencing dangling
pointers! Valgrind me!" but 2006 Thiago didn't see them...

Change-Id: I44de5aea113d05edec2227e9db6be8cec9303be9
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
This commit is contained in:
Thiago Macieira 2014-05-08 15:24:27 -07:00 committed by The Qt Project
parent a982243b97
commit e0e86d5651

View File

@ -367,11 +367,11 @@ void emitSignalPeer(const QString &interface, const QString &name, const QVarian
QTest::qWait(1000);
}
const char* slotSpyPeer()
QString slotSpyPeer()
{
QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "slotSpyServer");
QDBusMessage reply = QDBusConnection::sessionBus().call(req);
return reply.arguments().at(0).toString().toLatin1().data();
return reply.arguments().at(0).toString();
}
QString valueSpyPeer()
@ -1108,7 +1108,7 @@ void tst_QDBusAbstractAdaptor::methodCallsPeer()
// simple call: one such method exists
QCOMPARE(if2.call(QDBus::BlockWithGui, "method").type(), QDBusMessage::ReplyMessage);
QCOMPARE(slotSpyPeer(), "void Interface2::method()");
QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface2::method()"));
if (!nInterfaces--)
return;
@ -1121,24 +1121,24 @@ void tst_QDBusAbstractAdaptor::methodCallsPeer()
QCOMPARE(if2.call(QDBus::BlockWithGui, "methodString").type(), QDBusMessage::ErrorMessage);
QCOMPARE(if3.call(QDBus::BlockWithGui, "methodVoid").type(), QDBusMessage::ReplyMessage);
QCOMPARE(slotSpyPeer(), "void Interface3::methodVoid()");
QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface3::methodVoid()"));
QCOMPARE(if3.call(QDBus::BlockWithGui, "methodInt", 42).type(), QDBusMessage::ReplyMessage);
QCOMPARE(slotSpyPeer(), "void Interface3::methodInt(int)");
QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface3::methodInt(int)"));
QCOMPARE(if3.call(QDBus::BlockWithGui, "methodString", QString("")).type(), QDBusMessage::ReplyMessage);
QCOMPARE(slotSpyPeer(), "void Interface3::methodString(QString)");
QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface3::methodString(QString)"));
if (!nInterfaces--)
return;
// method overloading: different interfaces
QCOMPARE(if4.call(QDBus::BlockWithGui, "method").type(), QDBusMessage::ReplyMessage);
QCOMPARE(slotSpyPeer(), "void Interface4::method()");
QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface4::method()"));
// method overloading: different parameters
QCOMPARE(if4.call(QDBus::BlockWithGui, "method.i", 42).type(), QDBusMessage::ReplyMessage);
QCOMPARE(slotSpyPeer(), "void Interface4::method(int)");
QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface4::method(int)"));
QCOMPARE(if4.call(QDBus::BlockWithGui, "method.s", QString()).type(), QDBusMessage::ReplyMessage);
QCOMPARE(slotSpyPeer(), "void Interface4::method(QString)");
QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface4::method(QString)"));
}
void tst_QDBusAbstractAdaptor::methodCallScriptablePeer()
@ -1152,7 +1152,7 @@ void tst_QDBusAbstractAdaptor::methodCallScriptablePeer()
QDBusInterface if2(QString(), "/", "local.Interface2", con);
QCOMPARE(if2.call(QDBus::BlockWithGui,"scriptableMethod").type(), QDBusMessage::ReplyMessage);
QCOMPARE(slotSpyPeer(), "void Interface2::scriptableMethod()");
QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface2::scriptableMethod()"));
}
void tst_QDBusAbstractAdaptor::signalEmissionsPeer_data()