#!/usr/bin/python

from gi.repository import Gtk, Gio, GLib

def __get_cb(connection, result_async, data):
    mainloop.quit

connection = Gio.bus_get_sync(Gio.BusType.SESSION, None)

# tuple_v is ref floating
tuple_v = GLib.Variant.new_tuple(GLib.Variant.new_string('org.freedesktop.DBus'))

# tuple_v is consumed
connection.call(
    'org.freedesktop.DBus', '/org/freedesktop/DBus',
    'org.freedesktop.DBus', 'GetNameOwner',
    tuple_v,
    GLib.VariantType.new("(s)"), Gio.DBusCallFlags.NONE,
    -1, None, __get_cb, None)

# python releases tuple_v, although it will still be used very soon by the GDBus thread :(
tuple_v = None

# BOOM!
# (test.py:30009): GLib-CRITICAL **: g_variant_unref: assertion 'value->ref_count > 0' failed

mainloop = GLib.MainLoop()
mainloop.run()

