Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Swing|SWT]WLXPlugin.listCloseWindow(int) doesn't remove Shell/JFrame from internal HashTable #14

Open
meisl opened this issue Jan 23, 2014 · 0 comments
Labels

Comments

@meisl
Copy link
Owner

meisl commented Jan 23, 2014

Found just by looking at it (ie. haven't tried nor seen it fail). Oh, and Ken gave me a hint that there might be something wrong with types in somewhere in the wlx package:

I think a newer version should make use of javafx for the wlxplugin and there is a bug
somewhere in the wlxpluginadapter which should be visible if you would use type-safe
expressions.

Code looks like this:
in SWTWLXPlugin:

public final void listCloseWindow(final int listWin) {
    listCloseWindow();
    synchronized (shells) {
        Shell shell = (Shell) shells.get(listWin); // <<< unnecessary cast
        shells.remove(shell); // <<<<<<<<<<<<<<<<<<<<< should be listWin
        shell.dispose();
    }
}

...and in SwingWLXPlugin:

public final void listCloseWindow(final int listWin) {
    synchronized (frames) {
        // get JFrame identified by HWND
        final JFrame jframe = (JFrame) frames.get(new Integer(listWin)); // <<< unnecessary cast and boxing
        // remove stored JFrame instance, it is no longer used
        frames.remove(jframe); // <<<<<<<<<<<<<<<<<<<<< should be listWin
        // use seperate thread to call listClose (it could last a while)
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                // uninitialize the JFrame lister window contents
                listCloseWindow(jframe);
                // dispose the JFrame (it is no longer used)
                jframe.dispose();
            }
        });
    }
}

shells/frames is (should be) a Hashtable<Integer, Shell>/Hashtable<Integer, JFrame> so we should really pass an int (auto-boxed to Integer) to .remove rather than a Shell/JFrame, shouldn't we?

Note: the signature of java.util.Hashtable<K,V>.remove is: remove(Object key) - so the type system won't help us here. For what reason I don't know...

TODO: test-cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant