classpath-patches
[Top][All Lists]
Advanced

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

Re: [cp-patches] FYI: gnu_java_awt_peer_gtk_GtkClipboard.c 64-bit fix


From: Mark Wielaard
Subject: Re: [cp-patches] FYI: gnu_java_awt_peer_gtk_GtkClipboard.c 64-bit fix
Date: Sun, 20 Nov 2005 22:05:36 +0100

On Wed, 2005-11-16 at 01:04 +0100, Christian Thalinger wrote:
> On Mon, 2005-11-07 at 21:36 +0100, Christian Thalinger wrote:
> > On Mon, 2005-11-07 at 14:15 -0700, Tom Tromey wrote:
> > > >>>>> "Twisti" == Christian Thalinger <address@hidden> writes:
> > > 
> > > Twisti> +#if SIZEOF_VOID_P == 8
> > > Twisti> +static long current_selection = 0;
> > > Twisti> +#else
> > > Twisti>  static int current_selection = 0;
> > > Twisti> +#endif
> > >  
> > > How about, instead of testing SIZEOF_VOID_P all over, we use a
> > > typedef?  Or, given that this is gtk-using code, use the
> > > GPOINTER_TO_SIZE and GSIZE_TO_POINTER macros where appropriate?
> > 
> > Sounds good to me.  Didn't know that such macros exist in classpath.  In
> > CACAO we use a typedef for such stuff.
> 
> So, what is the suggested fix now?

According to
http://developer.gnome.org/doc/API/2.0/glib/glib-Type-Conversion-Macros.html
the following seems appropriate:

2005-11-20  Mark Wielaard  <address@hidden>

        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
        (current_selection): Define as gint.
        (clipboard_clear_func): Extract user_data with GPOINTER_TO_INT.
        (Java_gnu_java_awt_peer_gtk_GtkClipboard_advertiseContent):
        Convert current_selection with GINT_TO_POINTER.

Since we are only using the current_selection as small counter anyway.
Does this work for you?

Cheers,

Mark
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c,v
retrieving revision 1.17
diff -u -r1.17 gnu_java_awt_peer_gtk_GtkClipboard.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c    7 Nov 2005 
19:36:28 -0000       1.17
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c    20 Nov 2005 
21:04:29 -0000
@@ -53,11 +53,7 @@
 jstring cp_gtk_filesTarget;
 
 /* Simple id to keep track of the selection we are currently managing. */
-#if SIZEOF_VOID_P == 8
-static long current_selection = 0;
-#else
-static int current_selection = 0;
-#endif
+static gint current_selection = 0;
 
 /* Whether we "own" the clipboard. And may clear it. */
 static int owner = 0;
@@ -265,11 +261,7 @@
 clipboard_clear_func (GtkClipboard *clipboard __attribute__((unused)),
                      gpointer user_data)
 {
-#if SIZEOF_VOID_P == 8
-  if (owner && (long) user_data == current_selection)
-#else
-  if (owner && (int) user_data == current_selection)
-#endif
+  if (owner && GPOINTER_TO_INT(user_data) == current_selection)
     {
       JNIEnv *env = cp_gtk_gdk_env();
       owner = 0;
@@ -359,7 +351,7 @@
       if (gtk_clipboard_set_with_data (cp_gtk_clipboard, targets, n,
                                       clipboard_get_func,
                                       clipboard_clear_func,
-                                      (gpointer) current_selection))
+                                      GINT_TO_POINTER(current_selection)))
        {
          owner = 1;
          if (gtk_clipboard_instance == NULL)

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]