Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested dictionaries error #33

Closed
hwchen opened this issue Jan 25, 2016 · 8 comments
Closed

Nested dictionaries error #33

hwchen opened this issue Jan 25, 2016 · 8 comments

Comments

@hwchen
Copy link

hwchen commented Jan 25, 2016

I might be making a mistake in implementation, but I have not been able to get nested dictionaries to work.

Building the dictionary with a nested dictionary:
https://github.com/hwchen/secret-service-rs/blob/master/src/collection.rs#L224

The method call interface:
https://github.com/hwchen/secret-service-rs/blob/master/src/util.rs#L64

The test:
https://github.com/hwchen/secret-service-rs/blob/master/src/item.rs#L272

The error:

---- item::test::should_create_get_and_set_item_attributes stdout ----
    thread 'item::test::should_create_get_and_set_item_attributes' panicked at 'assertion failed: unsafe {
    ffi::dbus_message_iter_open_container(i, ffi::DBUS_TYPE_VARIANT, atype.as_ptr(), &mut subiter)
} != 0',
/home/hwchen/.cargo/registry/src/github.com-88ac128001ac3a9a/dbus-0.2.1/src/message.rs:154

Please excuse messy code, I have a lot of refactoring to do.

@diwic
Copy link
Owner

diwic commented Jan 25, 2016

What is the debug output from the messageitem causing this error?

@hwchen
Copy link
Author

hwchen commented Jan 25, 2016

Ah, I forgot about this output:

process 25101: arguments to dbus_message_iter_open_container() were incorrect, assertion "(type == DBUS_TYPE_ARRAY && contained_signature && *contained_signature == DBUS_DICT_ENTRY_BEGIN_CHAR) || (contained_signature == NULL || _dbus_check_is_valid_signature (contained_signature))" failed in file ../../dbus/dbus-message.c line 2801.
This is normally a bug in some application using the D-Bus library.

I'm not sure this is what you're looking for, but I think this is all the relevant output I'm getting. Let me know if you need something else.

@diwic
Copy link
Owner

diwic commented Jan 25, 2016

I mean something like this:

let m: MessageItem =  /* ... */;
println!("{:?}", m); // I want this output
message.append_items(&[m]);

DictEntry must be inside an array so if you are making a dict of dicts then it's actually something like Array(DictEntry(Str, Array(DictEntry(Str, Variant))))

@hwchen
Copy link
Author

hwchen commented Jan 25, 2016

Slightly Pretty:

Array([
  DictEntry( Str("org.freedesktop.Secret.Item.Label"), Variant(Str("Test")) ),
  DictEntry( Str("org.freedesktop.Secret.Item.Attributes"), Variant( Array([DictEntry(Str("one"), Str("one"))], "{ss}")))
], "{sv}")

Raw (in case I misformatted something):

Array([DictEntry(Str("org.freedesktop.Secret.Item.Label"), Variant(Str("Test"))), DictEntry(Str("org.freedesktop.Secret.Item.Attributes"), Variant(Array([DictEntry(Str("one"), Str("one"))], "{ss}")))], "{sv}")

@hwchen
Copy link
Author

hwchen commented Jan 26, 2016

Similar error, happens when I try to make a dictionary that's the same as the one that's nested in above errors.

---- item::test::should_get_and_set_item_attributes stdout ----
Array([DictEntry(Str("test"), Str("test"))], "{ss}")
thread 'item::test::should_get_and_set_item_attributes' panicked at 'assertion failed: unsafe {
    ffi::dbus_message_iter_open_container(i, ffi::DBUS_TYPE_VARIANT,
                                          atype.as_ptr(), &mut subiter)
} != 0', /home/hwchen/.cargo/registry/src/github.com-88ac128001ac3a9a/dbus-0.2.2/src/message.rs:156

diwic pushed a commit that referenced this issue Jan 26, 2016
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
@diwic
Copy link
Owner

diwic commented Jan 26, 2016

Hi,

I believe it was a bug in my D-Bus bindings, which I have now fixed in the commit above. Could you test it and reopen the bug in case I'm wrong?

@diwic diwic closed this as completed Jan 26, 2016
@hwchen
Copy link
Author

hwchen commented Jan 26, 2016

Works great, thanks!

@hwchen
Copy link
Author

hwchen commented Feb 9, 2016

Hello,
I'm hoping to publish my library, but the dbus bugfix does not appear to be published to crates.io. Do I need you to publish to crates.io, or is there another workaround? (for dev, I used the repo as a dependency).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants