albfan / jmeld

A visual diff and merge tool
44 stars 31 forks source link

NullpointerException in FileComparison.java:122 #50

Closed WolfgangFahl closed 6 years ago

WolfgangFahl commented 6 years ago
java.lang.NullPointerException
    at org.jmeld.ui.FileComparison.done(FileComparison.java:122)
    at org.jdesktop.swingworker.SwingWorker$5.run(SwingWorker.java:716)

the tabbedPane is null in my case here ..

also the catch for this only does a printStackTrace ...

how can this be avoided - a more robust solution created?

WolfgangFahl commented 6 years ago

Here is my patch - to avoid the non existence of the tabbedPain already construct it when the panel is constructed ... just move the new call a few lines up ....

diff --git a/src/main/java/org/jmeld/ui/JMeldPanel.java b/src/main/java/org/jmeld/ui/JMeldPanel.java
index 7aa9318..2c883e3 100644
--- a/src/main/java/org/jmeld/ui/JMeldPanel.java
+++ b/src/main/java/org/jmeld/ui/JMeldPanel.java
@@ -84,7 +84,8 @@ public class JMeldPanel extends JPanel implements ConfigurationListenerIF {
         SHOW_FILE_STATUSBAR_OPTION = new Option(this, true);
         STANDALONE_INSTALLKEY_OPTION = new Option(this, false);
         actions = new Actions();
-    }
+        tabbedPane = new JideTabbedPane();
+     }

     public JideTabbedPane getTabbedPane() {
         return tabbedPane;
@@ -97,7 +98,6 @@ public class JMeldPanel extends JPanel implements ConfigurationListenerIF {

         started = true;

-        tabbedPane = new JideTabbedPane();
         getTabbedPane().setFocusable(false);
         getTabbedPane().setShowCloseButtonOnTab(true);
         getTabbedPane().setShowCloseButtonOnSelectedTab(true);
albfan commented 6 years ago

I need to check it.

No problem with apply your patches, but would be easy to review from a PR

See now we have jemmy to test GUI components, so you can wrap this into a test (I will try to cover it with a test, just mention if you want to try yourself)

albfan commented 6 years ago

Can't see how to reproduce this, but anyway, it makes sense, so this should be fixed on 6d6e9e2