Re: Mime type woes in beagle
- From: Michael Levy <mlevy wardium homeip net>
- To: Todd Berman <tberman sevenl net>
- Cc: Jon Trowbridge <trow ximian com>, Dashboard <dashboard-hackers gnome org>
- Subject: Re: Mime type woes in beagle
- Date: Thu, 17 Jun 2004 00:41:38 +0200
Sorry, I forgot the attachement! here it is.
On Thu, Jun 17, 2004 at 12:39:50AM +0200, Michael Levy wrote:
> I really appreciate the initial response, and this more detailed follow-up!
>
> I copied your suggestion into test.cs, but I am afraid that I still get the
> strange behaviour... I've attached a copy of test.cs just to make sure that I
> haven't made another glaring silly...It still looks like memory corruption as
> somethimes I enter the "loop" I described, others I get non-sensical
> mime types (potentially non-printable characters) and other times I get a mime
> type "g_free". I understand that there is a marshalling problem, but I'm afraid
> I don't yet know what to do. I remain open to any and all suggestions ;)
>
> In case it's important:
> $ rpm -q gtk-sharp
> gtk-sharp-0.93-1.ximian.6.0
> I'm using Mono Beta 2
>
> Thanks again,
> Mike
>
>
> On Wed, Jun 16, 2004 at 01:05:55PM -0400, Todd Berman wrote:
> > And as I sent this, I realized i should be more explicit. Here you go.
> >
> > instead of just calling:
> >
> > gnome_vfs_mime_type_from_name_or_default you need to use:
> >
> > [DllImport ("libgnomevfs-2")] extern static IntPtr
> > gnome_vfs_mime_type_from_name_or_default (string filename, string defaultv);
> >
> > string GetMimeType (string filename, string default)
> > {
> > return GLib.Marshaller.PtrToStringGFree
> > (gnome_vfs_mime_type_from_name_or_default (filename, default));
> > }
> >
> > That should help you out.
> >
> > Note: GLib.Marshaller is in glib-sharp.dll, so you will have to compile
> > against it.
> >
> > Todd Berman wrote:
> > >You are getting memory corruption because of the string marshalling.
> > >
> > >If you look at how gtk#, MD, etc do string marshalling (MD even has an
> > >example from gnome_vfs) you will see how to fix it.
> > >
> > >Basically marshalling the string like that is just not gonna work :)
> > >
> > >--Todd
> > >
> > >Michael Levy wrote:
> > >
> > >>I would agree that it looks like memory corruption. Maybe I should try
> > >>to send this to another list such as one of the mono lists?
> > >>
> > >>Mike
> > >>
> > >>On Wed, Jun 16, 2004 at 12:34:11AM -0500, Jon Trowbridge wrote:
> > >>
> > >>>On Sat, 2004-06-12 at 23:44 +0200, Michael Levy wrote:
> > >>>
> > >>>>Unfortunately, I get some strange behaviour. I've written
> > >>>>a small test to demonstrate.
> > >>>
> > >>>
> > >>>I also get strange behavior, but it seems to be different strange
> > >>>behavior. I get weird behavior if I put more than one file on the
> > >>>command line, or put something on the command line that ends with /.
> > >>>Maybe some sort of memory corruption?
> > >>>
> > >>>-J
> > >>>
> > >>
> > >>_______________________________________________
> > >>Dashboard-hackers mailing list
> > >>Dashboard-hackers gnome org
> > >>http://mail.gnome.org/mailman/listinfo/dashboard-hackers
> > >>
> > >
> > >_______________________________________________
> > >Dashboard-hackers mailing list
> > >Dashboard-hackers gnome org
> > >http://mail.gnome.org/mailman/listinfo/dashboard-hackers
> > >
> _______________________________________________
> Dashboard-hackers mailing list
> Dashboard-hackers gnome org
> http://mail.gnome.org/mailman/listinfo/dashboard-hackers
using System;
using System.Runtime.InteropServices;
public class Test {
[DllImport ("libgnomevfs-2")] extern static bool gnome_vfs_init ();
[DllImport ("libgnomevfs-2")] extern static IntPtr gnome_vfs_mime_type_from_name_or_default (string filename, string defaultv);
static string GetMimeType (string filename, string def)
{
return GLib.Marshaller.PtrToStringGFree (gnome_vfs_mime_type_from_name_or_default (filename, def));
}
static int Main (String [] args)
{
gnome_vfs_init ();
foreach (String name in args) {
String mime = GetMimeType (name, "DON'T KNOW");
Console.WriteLine ("{0}\t{1}", name, mime);
}
return 0;
}
}
// Compile with :
// mcs test.cs `pkg-config --libs gtk-sharp`
//
// Run with (should work):
// mono test.exe test.cs
//
// Or to see "looping"
// mono test.exe noSuchFile1 noSuchFile2
//
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]