After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 599487 - Calling delegate functions from async functions does not work
Calling delegate functions from async functions does not work
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator: GAsync
0.7.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-10-24 14:33 UTC by Philipp Zabel
Modified: 2010-01-09 12:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example program that calls a delegate function from an async function (462 bytes, application/octet-stream)
2009-10-24 14:33 UTC, Philipp Zabel
  Details
Code generated by vala 0.7.7 from async-owned-delegate.vala (11.56 KB, text/x-csrc)
2009-10-24 14:34 UTC, Philipp Zabel
  Details
codegen: add destroy_notify function for owned delegate parameters to async methods (1.08 KB, patch)
2009-10-24 16:39 UTC, Philipp Zabel
none Details | Review
codegen: fix async methods with delegate parameters (1.18 KB, patch)
2009-10-24 21:54 UTC, Philipp Zabel
none Details | Review

Description Philipp Zabel 2009-10-24 14:33:36 UTC
Created attachment 146171 [details]
Example program that calls a delegate function from an async function

Compiling the attached test program fails with the following error message:

** (valac:5121): CRITICAL **: vala_data_type_get_value_owned: assertion `self
!= NULL' failed
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:44: error: expected
specifier-qualifier-list before ‘AsyncDelegateTestFunc’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c: In function
‘async_delegate_test_async_data_free’:
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:89: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f_target_destroy_notify’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:89: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f_target_destroy_notify’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:89: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f_target’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:90: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:91: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f_target’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:92: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f_target_destroy_notify’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c: In function
‘async_delegate_test_async’:
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:103: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:104: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f_target’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c: In function
‘async_delegate_test_async_co’:
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:140: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:140: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f_target’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:142: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f_target_destroy_notify’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:142: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f_target_destroy_notify’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:142: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f_target’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:143: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:144: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f_target’
/home/ph5/src/vala/async-delegate/async-owned-delegate.c:145: error:
‘AsyncDelegateTestAsyncData’ has no member named ‘f_target_destroy_notify’
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

The generated C code (also attached) has two problems:

1) The AsyncDelegateTestFunc delegate typedef appears only after the struct
_AsyncDelegateTestAsyncData, in which it is referenced.

2) The struct _AsyncDelegateTestAsyncData is missing a GDestroyNotify
f_target_destroy_notify member.
Comment 1 Philipp Zabel 2009-10-24 14:34:22 UTC
Created attachment 146172 [details]
Code generated by vala 0.7.7 from async-owned-delegate.vala
Comment 2 Philipp Zabel 2009-10-24 16:39:01 UTC
Created attachment 146179 [details] [review]
codegen: add  destroy_notify function for owned delegate parameters to async methods

This patch addresses the second issue only. I still do not know how to make Vala emit the delegate function's AsyncDelegateTestFunc typedef before the struct _AsyncDelegateTestAsyncData.
Comment 3 Philipp Zabel 2009-10-24 21:54:29 UTC
Created attachment 146187 [details] [review]
codegen: fix async methods with delegate parameters

Add GDestroyNotify function pointer for owned delegate parameters to async methods and make sure the delegate function type is declared before the async data structure.

There are no more compilation errors and the result runs fine, but valac still emits this error message:

** (valac:1106): CRITICAL **: vala_data_type_get_value_owned: assertion `self != NULL' failed

of which I don't know where it comes from.
Comment 4 Philipp Zabel 2009-10-26 12:11:08 UTC
I tried this with Vala master, which already adds the GDestroyNotify fields (since the fix for Bug 597294). Unfortunately, now just adding the generate_type_declaration doesn't seem to help anymore. There are no compilation warnings or errors, but two critical error messages:

valac[16410]: GLIB CRITICAL ** default - vala_ccode_expression_statement_construct: assertion `expr != NULL' failed
valac[16410]: GLIB CRITICAL ** default - vala_ccode_fragment_append: assertion `node != NULL' failed

The resulting binary just calls the async function and starts the loop, but never returns into the async function. Program output:

async enter
loop
Comment 5 Jürg Billeter 2010-01-09 12:56:37 UTC
The example program works fine with master. Program output:

async enter
loop
delegate
async leave