sajmplus
23rd February 2017, 20:20
Hello,
i have problem with unmarshaling complex type from QDBusArgument. Method returns a{sa{sv}}. I declared typedef for this complex type:
typedef QMap<QString, QMap<QString, QVariant>> ConnectionSettings;
Q_DECLARE_METATYPE(ConnectionSettings)
And i'm trying to call method:
ConnectionSettings NetworkConnection::getSettings()
{
QDBusInterface iface(m_serviceName, m_objectPath, m_interfaceName,
SystemBusConnectionFactory::getInstance());
auto msg = iface.call("GetSettings");
qDebug() << msg;
auto retVal = msg.arguments()
.first()
.value<QDBusArgument>();
ConnectionSettings cs;
retVal.beginMap();
while( !retVal.atEnd() ) {
QString key;
QVariantMap value;
retVal.beginMapEntry();
retVal >> key >> value; //This line crashes!
retVal.endMapEntry();
cs.insert(key, value);
qDebug() << key << value;
}
retVal.endMap();
return cs;
}
Unfortunately there is a segfault - debugger show line 331 in qdbusargument.h:
...
template<typename Key, typename T>
inline const QDBusArgument &operator>>(const QDBusArgument &arg, QMap<Key, T> &map)
{
arg.beginMap();
map.clear();
while (!arg.atEnd()) {
Key key;
T value;
arg.beginMapEntry(); // SIGSEGV here!
arg >> key >> value;
map.insertMulti(key, value);
arg.endMapEntry();
}
arg.endMap();
return arg;
}
...
Where should I search for the problem?
i have problem with unmarshaling complex type from QDBusArgument. Method returns a{sa{sv}}. I declared typedef for this complex type:
typedef QMap<QString, QMap<QString, QVariant>> ConnectionSettings;
Q_DECLARE_METATYPE(ConnectionSettings)
And i'm trying to call method:
ConnectionSettings NetworkConnection::getSettings()
{
QDBusInterface iface(m_serviceName, m_objectPath, m_interfaceName,
SystemBusConnectionFactory::getInstance());
auto msg = iface.call("GetSettings");
qDebug() << msg;
auto retVal = msg.arguments()
.first()
.value<QDBusArgument>();
ConnectionSettings cs;
retVal.beginMap();
while( !retVal.atEnd() ) {
QString key;
QVariantMap value;
retVal.beginMapEntry();
retVal >> key >> value; //This line crashes!
retVal.endMapEntry();
cs.insert(key, value);
qDebug() << key << value;
}
retVal.endMap();
return cs;
}
Unfortunately there is a segfault - debugger show line 331 in qdbusargument.h:
...
template<typename Key, typename T>
inline const QDBusArgument &operator>>(const QDBusArgument &arg, QMap<Key, T> &map)
{
arg.beginMap();
map.clear();
while (!arg.atEnd()) {
Key key;
T value;
arg.beginMapEntry(); // SIGSEGV here!
arg >> key >> value;
map.insertMulti(key, value);
arg.endMapEntry();
}
arg.endMap();
return arg;
}
...
Where should I search for the problem?