Hi Costantino,
Costantino Cerbo wrote:
> It works correctly, but only if we don't use the GTK L&F.
> I didn't realise it and this is a very useful clue: it means that we
> do something wrong with the initialization of GTK.
>
> With the GTK L&F, I get these errors:
> Xlib: sequence lost (0x11fae > 0x2233) in reply type 0x1c!
>
> *** glibc detected ***
> /home/c.cerbo/openjdk-awt/jdk/build/linux-i586/bin/java: double free
> or corruption (fasttop): 0x912db9d0 ***
> *** glibc detected ***
> /home/c.cerbo/openjdk-awt/jdk/build/linux-i586/bin/java: double free
> or corruption (out): 0x912d2d10 ***
I tried again, this time with your newest patch
http://cr.openjdk.java.net/~anthony/7-43-GTKFileDialog-6913179.2/
My only change was to start a new thread in GtkFileDialogPeer (see
gtkfd2.patch, attached). It worked with GTK LAF for me, and i wasn't
getting any messages. I was running attached GtkFD.java on a Gentoo box
with gtk+-2.16.6, and was using latest jdk7 sources.
Could you try my patch and test on your machine?
Thanks!
--
Peter
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GtkFD {
JComponent getContent() {
return b;
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new com.sun.java.swing.plaf.gtk.GTKLookAndFeel());
// UIManager.setLookAndFeel(new javax.swing.plaf.nimbus.NimbusLookAndFeel());
// UIManager.setLookAndFeel(new com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel());
// UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
JButton b = new JButton("Choose...");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileDialog fd = new FileDialog((Frame) null);
fd.setVisible(true);
}
});
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(b);
f.pack();
f.setVisible(true);
}
});
}
}
*** src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java.old Thu Feb 11
13:07:16 2010
--- src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java Thu Feb 11
13:07:22 2010
***************
*** 84,93 ****
XToolkit.awtLock();
try {
if (b) {
! run(fd.getTitle(), fd.getMode(), fd.getDirectory(),
! fd.getFile(), fd.getFilenameFilter());
! fd.setVisible(false);
} else {
quit();
fd.setVisible(false);
--- 84,98 ----
XToolkit.awtLock();
try {
if (b) {
! Thread t = new Thread() {
! public void run() {
! GtkFileDialogPeer.this.run(fd.getTitle(),
fd.getMode(), fd.getDirectory(),
! fd.getFile(), fd.getFilenameFilter());
! fd.setVisible(false);
! }
! };
! t.start();
} else {
quit();
fd.setVisible(false);