returning structs doesn't work
Submitted by Reiner Merk
Link to original bug (#690551)
Description
In the generated c code, vala tries to copy a struct and returns pointer of that copy instead of the a pointer to the original struct.
relevant section vala:
DBusNodeInfo dbni;
DBusInterfaceVTable entry;
public static void on_bus_acquired (DBusConnection conn) {
try {
dbni = new DBusNodeInfo.for_xml (MEDIASERVER2_XML);
}
catch (Error e) {
log.error ("%s", e.message);
}
// entry subtree
entry = DBusInterfaceVTable () {
method_call = (connection, sender, object_path, interface_name,
method_name, parameters, invocation) => {
log.info ("method call: " + object_path + " - " + method_name);
},
get_property = (connection, sender, object_path, interface_name,
property_name) => {
log.info ("get_property: " + object_path + " - " + property_name);
return new Variant.string ("string");
},
set_property = null};
var entry_subtree = DBusSubtreeVTable () {
enumerate = (connection, sender, object_path) => {
log.info("enumerate");
return {};
},
introspect = (connection, sender, object_path, node) => {
log.info("introspect");
return {
dbni.lookup_interface (MEDIASERVER2_OBJECT_INTERFACE),
dbni.lookup_interface (MEDIASERVER2_CONTAINER_INTERFACE)};
},
dispatch = (connection, sender, object_path, interface_name, node,
out_user_data) => {
log.info("dispatch");
out_user_data = null; // shouldn't be null, but works anyway
return entry;
}};
conn.register_subtree (ROOT_PATH, entry_subtree,
GLib.DBusSubtreeFlags.DISPATCH_TO_UNENUMERATED_NODES,
null, (data) => {}).to_string ();
}
dispatch function generated in c:
static GDBusInterfaceVTable* __lambda11_ (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* node, void* out_user_data) {
GDBusInterfaceVTable* result = NULL;
LoggingLogger* _tmp0_;
GDBusInterfaceVTable _tmp1_;
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (sender != NULL, NULL);
g_return_val_if_fail (object_path != NULL, NULL);
g_return_val_if_fail (interface_name != NULL, NULL);
g_return_val_if_fail (node != NULL, NULL);
_tmp0_ = media_server2_log;
logging_logger_info (_tmp0_, "Services2.vala:429: dispatch");
out_user_data = NULL;
_tmp1_ = media_server2_entry;
result = &_tmp1_;
return result;
}
nemequ suggested a workaround: defining the struct as struct? which works.
Version: 0.18.x