Make QDBusConnection and QDBusServer return an error on default objects
The error of "Not connected". This incidentally solves a crash when QDBusServer().lastError() is called but libdbus-1 couldn't be found. Change-Id: Id93f447d00c0aa6660d4528c4bbce5998d9186a8 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
This commit is contained in:
parent
aa83bacb14
commit
624ee454ec
@ -959,7 +959,7 @@ bool QDBusConnection::isConnected() const
|
|||||||
*/
|
*/
|
||||||
QDBusError QDBusConnection::lastError() const
|
QDBusError QDBusConnection::lastError() const
|
||||||
{
|
{
|
||||||
return d ? d->lastError : QDBusError();
|
return d ? d->lastError : QDBusError(QDBusError::Disconnected, QStringLiteral("Not connected."));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -129,7 +129,7 @@ bool QDBusServer::isConnected() const
|
|||||||
*/
|
*/
|
||||||
QDBusError QDBusServer::lastError() const
|
QDBusError QDBusServer::lastError() const
|
||||||
{
|
{
|
||||||
return d->lastError;
|
return d ? d->lastError : QDBusError(QDBusError::Disconnected, QStringLiteral("Not connected."));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -246,7 +246,7 @@ void tst_QDBusConnection::connectToBus()
|
|||||||
|
|
||||||
QDBusConnection con2("foo");
|
QDBusConnection con2("foo");
|
||||||
QVERIFY(!con2.isConnected());
|
QVERIFY(!con2.isConnected());
|
||||||
QVERIFY(!con2.lastError().isValid());
|
QVERIFY(con2.lastError().isValid());
|
||||||
|
|
||||||
con2 = con;
|
con2 = con;
|
||||||
QVERIFY(con.isConnected());
|
QVERIFY(con.isConnected());
|
||||||
@ -274,7 +274,7 @@ void tst_QDBusConnection::connectToBus()
|
|||||||
{
|
{
|
||||||
QDBusConnection con("bubu");
|
QDBusConnection con("bubu");
|
||||||
QVERIFY(!con.isConnected());
|
QVERIFY(!con.isConnected());
|
||||||
QVERIFY(!con.lastError().isValid());
|
QVERIFY(con.lastError().isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray address = qgetenv("DBUS_SESSION_BUS_ADDRESS");
|
QByteArray address = qgetenv("DBUS_SESSION_BUS_ADDRESS");
|
||||||
@ -314,7 +314,7 @@ void tst_QDBusConnection::connectToPeer()
|
|||||||
|
|
||||||
QDBusConnection con2("foo");
|
QDBusConnection con2("foo");
|
||||||
QVERIFY(!con2.isConnected());
|
QVERIFY(!con2.isConnected());
|
||||||
QVERIFY(!con2.lastError().isValid());
|
QVERIFY(con2.lastError().isValid());
|
||||||
|
|
||||||
con2 = con;
|
con2 = con;
|
||||||
QVERIFY(con.isConnected());
|
QVERIFY(con.isConnected());
|
||||||
@ -342,7 +342,7 @@ void tst_QDBusConnection::connectToPeer()
|
|||||||
{
|
{
|
||||||
QDBusConnection con("bubu");
|
QDBusConnection con("bubu");
|
||||||
QVERIFY(!con.isConnected());
|
QVERIFY(!con.isConnected());
|
||||||
QVERIFY(!con.lastError().isValid());
|
QVERIFY(con.lastError().isValid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user