tags:

views:

69

answers:

1

I wanted to list all my "Recently Used" Items. I use this code:

public static void Main(string[] args)
{
    Application.Init ();
    RecentManager rm = RecentManager.Default;
    GLib.List items = rm.Items;
    Console.WriteLine(items.Count+" items.");
    foreach(object item in items)
    {
     Console.WriteLine(item.ToString());
    }   
    Console.WriteLine("Done.");
    Console.ReadKey();
}

If the Items-list is empty all works as expected. However if the RecentManager does in fact contain Items, I'm getting:

3 items.
Stacktrace:

  at (wrapper managed-to-native) GLib.Object.gtksharp_is_object (intptr) <0x00070>
  at (wrapper managed-to-native) GLib.Object.gtksharp_is_object (intptr) <0xffffffff>
  at GLib.Object.IsObject (intptr) <0x00013>
  at GLib.ListBase.DataMarshal (intptr) <0x003ff>
  at GLib.ListBase/ListEnumerator.get_Current () <0x0004b>
  at ruCmd.MainClass.Main (string[]) [0x00038] in /home/nils/Projekte/RecentlyUsed/ruCmd/Main.cs:14
  at (wrapper runtime-invoke) ruCmd.MainClass.runtime_invoke_void_object (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

    /usr/bin/mono [0x480c90]
    /usr/bin/mono [0x4b004d]
    /lib/libpthread.so.0 [0x7fad5b7c85a0]
    /usr/lib/libgobject-2.0.so.0(g_type_check_instance_is_a+0x53) [0x7fad55c642e3]
    [0x41d48b00]

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Is there an error in my handling of Gtk#/GLib ? I have already rebuild my mono-environment.

A: 

Gtk-sharp mailing list helped out:
This is a known bug, but a workaround exists. The following code works:

public static void Main(string[] args)
{
    Application.Init ();
    RecentManager rm = RecentManager.Default;
    GLib.List items = new GLib.List(rm.Items.Handle, typeof(RecentInfo), true, true);
    Console.WriteLine(items.Count+" items.");
    foreach(RecentInfo item in items)
    {
     Console.WriteLine(item.DisplayName);
    }   
    Console.WriteLine("Done.");
    Console.ReadKey();
}
Nils