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 615979 - Delegate type conversion failure when missing extraneous "static" keyword
Delegate type conversion failure when missing extraneous "static" keyword
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Semantic Analyzer
0.8.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-04-16 17:48 UTC by Travis Reitter
Modified: 2018-05-22 13:33 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Travis Reitter 2010-04-16 17:48:33 UTC
With the following setup, valac fails to automatically convert get_contacts_by_handle_cb() to ConnectionContactsByHandleCb. If I add the "static" keyword to the declaration of get_contacts_by_handle_cb(), then the conversion works as expected.


=============================
.vapi file
=============================

        public delegate void ConnectionContactsByHandleCb (Tp.Connection connection, uint n_contacts, Tp.Contact[] contacts, uint n_failed, Tp.Handle[] failed, GLib.Error error, void* user_data, GLib.Object weak_object);

=============================
Source file
=============================

using GLib;
using Gee;
using Tp.Individual;
using Tp.Channel;
using Tp.ConnectionContactsByHandleCb;
using Tp.Contact;
using Tp.ContactFeature;
using Tp.Handle;
using Tp.Account;
using Tp.AccountManager;
using Tp.Lowlevel;

...

        private void get_contacts_by_handle_cb (Tp.Connection connection,
                        uint n_contacts,
                        Tp.Contact[] contacts,
                        uint n_failed,
                        Tp.Handle[] failed,
                        GLib.Error error,
                        void* user_data,
                        GLib.Object weak_object) {
            ...
        }


...
                this.conn.get_contacts_by_handle (handles_array_length,
                                handles_array, features.length, features,
                                this.get_contacts_by_handle_cb, null, null,
                                this.conn);
                                
=============================
Build Error
=============================

make[2]: *** [telepathy-people.vala.stamp] Error 1
make[2]: *** Waiting for unfinished jobs....
persona-store.vala:105.33-105.62: error: Argument 5: Cannot convert from `Tp.PersonaStore.get_contacts_by_handle_cb' to `Tp.ConnectionContactsByHandleCb'
                                this.get_contacts_by_handle_cb, null, null,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Comment 1 Alexander Kojevnikov 2010-05-04 11:41:30 UTC
Confirming. This is pretty annoying when a callback needs access to the class variables. A work-around is indeed to declare the callback as `static` and pass `this` with the user_data.
Comment 2 GNOME Infrastructure Team 2018-05-22 13:33:42 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/89.