Re: Size of GtkImage?



On Wednesday, July 23, 2003, at 11:06  PM, Matthias Bläsing wrote:

===snip===
sub grafik_add_response {
        my $fileselection = shift;
                my $response = shift;
                        if ( $response == -5) {
                                        my @filenames = $fileselection->get_selections;
                                        # Stuff that handles the files
                        }
                }
        }
}

two "{"s and four "}"s?  i presume you've clipped liberally.  :-)

===snap===

Failure:
(gallery.pl:6999): GLib-CRITICAL **: file gutf8.c: line 1536
(g_utf8_validate): assertion `str != NULL' failed
Segmentation fault

aha! the loop in get_selections was implemented incorrectly, basically updating the current item pointer at the wrong stage of the loop, and allowing NULL to get through. simplified the loop and everything's fine. also made it call newSVGChar instead of newSVpv, so it should handle utf8 filenames correctly as well, but i can't test that myself.

cvsweb's still a little behind, so here's a patch:

Index: GtkFileSelection.xs
===================================================================
RCS file: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/xs/GtkFileSelection.xs,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GtkFileSelection.xs 22 May 2003 14:23:23 -0000      1.6
+++ GtkFileSelection.xs 24 Jul 2003 12:32:55 -0000      1.7
@@ -16,7 +16,7 @@
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA  02111-1307  USA.
  *
- * $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/xs/GtkFileSelection.xs,v 1.6 2003/05/22 14:23:23 muppetman Exp $ + * $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/xs/GtkFileSelection.xs,v 1.7 2003/07/24 12:32:55 muppetman Exp $
  */

 #include "gtk2perl.h"
@@ -96,22 +96,16 @@
 gtk_file_selection_get_filename (filesel)
        GtkFileSelection * filesel

-## TODO: what about the utf8'ieness of all of this
 void
 gtk_file_selection_get_selections (filesel)
        GtkFileSelection * filesel
     PREINIT:
        int      i;
        gchar ** rets;
-       gchar *  curr;
     PPCODE:
        rets = gtk_file_selection_get_selections(filesel);
-       for( i = 0, curr = rets[0]; curr != NULL; i++ )
-       {
-               curr = rets[i];
-               XPUSHs(sv_2mortal(newSVpv(
-                       g_filename_to_utf8(curr, -1, NULL, NULL, NULL),
-                       PL_na)));
-       }
+       for (i = 0; rets[i] != NULL; i++)
+               XPUSHs (sv_2mortal (newSVGChar (
+ g_filename_to_utf8 (rets[i], -1, NULL, NULL, NULL))));
        g_strfreev(rets);




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]