Results 1 to 4 of 4

Thread: Unmarshal complex type from QDBus

  1. #1

    Default Unmarshal complex type from QDBus

    Hello,

    i have problem with unmarshaling complex type from QDBusArgument. Method returns a{sa{sv}}. I declared typedef for this complex type:

    Qt Code:
    1. typedef QMap<QString, QMap<QString, QVariant>> ConnectionSettings;
    2. Q_DECLARE_METATYPE(ConnectionSettings)
    To copy to clipboard, switch view to plain text mode 

    And i'm trying to call method:

    Qt Code:
    1. ConnectionSettings NetworkConnection::getSettings()
    2. {
    3. QDBusInterface iface(m_serviceName, m_objectPath, m_interfaceName,
    4. SystemBusConnectionFactory::getInstance());
    5.  
    6. auto msg = iface.call("GetSettings");
    7. qDebug() << msg;
    8. auto retVal = msg.arguments()
    9. .first()
    10. .value<QDBusArgument>();
    11.  
    12. ConnectionSettings cs;
    13.  
    14. retVal.beginMap();
    15. while( !retVal.atEnd() ) {
    16. QString key;
    17. QVariantMap value;
    18. retVal.beginMapEntry();
    19. retVal >> key >> value; //This line crashes!
    20. retVal.endMapEntry();
    21. cs.insert(key, value);
    22. qDebug() << key << value;
    23. }
    24. retVal.endMap();
    25.  
    26. return cs;
    27. }
    To copy to clipboard, switch view to plain text mode 

    Unfortunately there is a segfault - debugger show line 331 in qdbusargument.h:

    Qt Code:
    1. ...
    2. template<typename Key, typename T>
    3. inline const QDBusArgument &operator>>(const QDBusArgument &arg, QMap<Key, T> &map)
    4. {
    5. arg.beginMap();
    6. map.clear();
    7. while (!arg.atEnd()) {
    8. Key key;
    9. T value;
    10. arg.beginMapEntry(); // SIGSEGV here!
    11. arg >> key >> value;
    12. map.insertMulti(key, value);
    13. arg.endMapEntry();
    14. }
    15. arg.endMap();
    16. return arg;
    17. }
    18. ...
    To copy to clipboard, switch view to plain text mode 

    Where should I search for the problem?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Unmarshal complex type from QDBus

    Have you tried separating the two stream reads?

    Does it crash on the key or the value?

    Cheers,
    _

  3. #3

    Default Re: Unmarshal complex type from QDBus

    Its crashing on value.

    How can I separate stream?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Unmarshal complex type from QDBus

    Maybe try other value types instead of QVariantMap, e.g. maybe it is a QDBusVariant which contains a map.

    Or maybe it is possible to handle a nested map by first streaming the key and then calling beginMap() for the inner map, handling it in an inner loop.

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 19th February 2010, 16:33
  2. QDbus and wpa_supplicant
    By knee in forum Qt Programming
    Replies: 2
    Last Post: 11th February 2010, 15:49
  3. QDBus-cpptoxml
    By diptiman in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2009, 09:15
  4. Using QDBus
    By Sandip in forum Qt Programming
    Replies: 3
    Last Post: 27th May 2008, 07:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.