Exceptions while loading layout

Hi there! First i would like to thank you for this great library.
I hope not to break any board rules but hadnt found any.

I randomly get on or two of
ConcurrentModificationException,
ArrayIndexOutOfBoundsException, and
NullPointerException
while loading a layout.

Im using DockingFrames Preview Version 1.0.8 5c but had simmilar issues unsing latest 1.0.7.

I hope that helps to find some bugs to improve DockingFrames.

MfG
Schumacb


java.lang.ArrayIndexOutOfBoundsException: 0
    at bibliothek.gui.dock.station.stack.tab.layouting.TabsLayoutBlock.getTabsOrderedByImportance(TabsLayoutBlock.java:293)
    at bibliothek.gui.dock.station.stack.tab.layouting.LineTabsLayoutBlock.getSizes(LineTabsLayoutBlock.java:91)
    at bibliothek.gui.dock.station.stack.tab.MenuLineLayout$Layout.listLayouts(MenuLineLayout.java:287)
    at bibliothek.gui.dock.station.stack.tab.MenuLineLayout$Layout.layout(MenuLineLayout.java:234)
    at bibliothek.gui.dock.station.stack.tab.MenuLineLayout.layout(MenuLineLayout.java:78)
    at bibliothek.gui.dock.station.stack.tab.AbstractTabPane.doLayout(AbstractTabPane.java:128)
    at bibliothek.gui.dock.station.stack.tab.AbstractTabPane.discardComponentsAndRebuild(AbstractTabPane.java:346)
    at bibliothek.extension.gui.dock.theme.eclipse.stack.EclipseTabPane.updateTabPainter(EclipseTabPane.java:181)
    at bibliothek.extension.gui.dock.theme.eclipse.stack.EclipseTabPane.setController(EclipseTabPane.java:129)
    at bibliothek.gui.dock.StackDockStation.setController(StackDockStation.java:506)
    at bibliothek.gui.dock.control.DockRegister.register(DockRegister.java:259)
    at bibliothek.gui.dock.control.DockRegister$1.handleDockable(DockRegister.java:145)
    at bibliothek.gui.dock.util.DockUtilities.visitDockable(DockUtilities.java:126)
    at bibliothek.gui.dock.util.DockUtilities.visit(DockUtilities.java:98)
    at bibliothek.gui.dock.control.DockRegister.add(DockRegister.java:142)
    at bibliothek.gui.dock.control.DockRegister.access$1(DockRegister.java:132)
    at bibliothek.gui.dock.control.DockRegister$StationListener.addDockable(DockRegister.java:522)
    at bibliothek.gui.dock.control.DockRegister$StationListener.fire(DockRegister.java:458)
    at bibliothek.gui.dock.control.DockRegister.setStalled(DockRegister.java:416)
    at bibliothek.gui.dock.support.mode.ModeManager.runTransaction(ModeManager.java:460)
    at bibliothek.gui.dock.facile.mode.LocationModeManager.runLayoutTransaction(LocationModeManager.java:353)
    at bibliothek.gui.dock.common.intern.CDockFrontend.setSetting(CDockFrontend.java:104)
    at bibliothek.gui.DockFrontend.read(DockFrontend.java:1723)
    at bibliothek.gui.dock.common.CControl$4.read(CControl.java:475)
    at bibliothek.gui.dock.support.util.ApplicationResourceManager.readStream(ApplicationResourceManager.java:144)
    at bibliothek.gui.dock.support.util.ApplicationResourceManager.readFile(ApplicationResourceManager.java:204)
    at bibliothek.gui.dock.common.CControl.read(CControl.java:2100)
    at de.fhtrier.themis.gui.main.Themis.loadLayout(Themis.java:482)
    at de.fhtrier.themis.gui.main.Themis.<init>(Themis.java:142)
    at de.fhtrier.themis.gui.main.Themis.getInstance(Themis.java:154)
    at de.fhtrier.themis.gui.main.Themis.main(Themis.java:238)


java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextEntry(HashMap.java:810)
    at java.util.HashMap$ValueIterator.next(HashMap.java:839)
    at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
    at java.util.ArrayList.<init>(ArrayList.java:151)
    at bibliothek.gui.dock.station.stack.tab.AbstractTabPane.getTabsList(AbstractTabPane.java:471)
    at bibliothek.extension.gui.dock.theme.eclipse.stack.EclipseTabPane.indexOfVisible(EclipseTabPane.java:262)
    at bibliothek.extension.gui.dock.theme.eclipse.stack.tab.BaseTabComponent.getTabIndex(BaseTabComponent.java:551)
    at bibliothek.extension.gui.dock.theme.eclipse.stack.tab.BaseTabComponent.isPreviousTabSelected(BaseTabComponent.java:483)
    at bibliothek.extension.gui.dock.theme.eclipse.stack.tab.ArchGradientPainter.update(ArchGradientPainter.java:220)
    at bibliothek.extension.gui.dock.theme.eclipse.stack.tab.ArchGradientPainter.updateSelected(ArchGradientPainter.java:181)
    at bibliothek.extension.gui.dock.theme.eclipse.stack.tab.BaseTabComponent.setSelected(BaseTabComponent.java:444)
    at bibliothek.extension.gui.dock.theme.eclipse.stack.EclipseTab.informSelectionChanged(EclipseTab.java:203)
    at bibliothek.gui.dock.station.stack.tab.AbstractTab.bind(AbstractTab.java:140)
    at bibliothek.extension.gui.dock.theme.eclipse.stack.EclipseTab.bind(EclipseTab.java:167)
    at bibliothek.extension.gui.dock.theme.eclipse.stack.EclipseTabPane.newTab(EclipseTabPane.java:246)
    at bibliothek.extension.gui.dock.theme.eclipse.stack.EclipseTabPane.newTab(EclipseTabPane.java:1)
    at bibliothek.gui.dock.station.stack.tab.AbstractTabPane.getOnTab(AbstractTabPane.java:513)
    at bibliothek.gui.dock.station.stack.tab.layouting.TabsLayoutBlock.getTabsOrderedByImportance(TabsLayoutBlock.java:253)
    at bibliothek.gui.dock.station.stack.tab.layouting.LineTabsLayoutBlock.getSizes(LineTabsLayoutBlock.java:91)
    at bibliothek.gui.dock.station.stack.tab.MenuLineLayout$Layout.listLayouts(MenuLineLayout.java:287)
    at bibliothek.gui.dock.station.stack.tab.MenuLineLayout$Layout.layout(MenuLineLayout.java:234)
    at bibliothek.gui.dock.station.stack.tab.MenuLineLayout.layout(MenuLineLayout.java:78)
    at bibliothek.gui.dock.station.stack.tab.AbstractTabPane.doLayout(AbstractTabPane.java:128)
    at bibliothek.gui.dock.station.stack.CombinedStackDockContentPane.doLayout(CombinedStackDockContentPane.java:75)
    at java.awt.Container.validateTree(Container.java:1568)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validate(Container.java:1540)
    at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:652)
    at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1549)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:226)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:602)
    at de.fhtrier.themis.gui.main.Themis$2.dispatchEvent(Themis.java:339)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

java.lang.NullPointerException
    at bibliothek.gui.dock.station.split.Node.updateBounds(Node.java:332)
    at bibliothek.gui.dock.station.split.Node.updateBounds(Node.java:329)
    at bibliothek.gui.dock.station.split.Node.updateBounds(Node.java:329)
    at bibliothek.gui.dock.station.split.Root.updateBounds(Root.java:235)
    at bibliothek.gui.dock.station.split.DefaultSplitLayoutManager.updateBounds(DefaultSplitLayoutManager.java:392)
    at bibliothek.gui.dock.facile.station.split.DelegatingSplitLayoutManager.updateBounds(DelegatingSplitLayoutManager.java:72)
    at bibliothek.gui.dock.facile.station.split.LockedResizeLayoutManager.updateBounds(LockedResizeLayoutManager.java:91)
    at bibliothek.gui.dock.SplitDockStation.updateBounds(SplitDockStation.java:2371)
    at bibliothek.gui.dock.SplitDockStation$Content.doLayout(SplitDockStation.java:2382)
    at java.awt.Container.validateTree(Container.java:1568)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validateTree(Container.java:1575)
    at java.awt.Container.validate(Container.java:1540)
    at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:652)
    at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1549)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:226)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:602)
    at de.fhtrier.themis.gui.main.Themis$2.dispatchEvent(Themis.java:339)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

ahhw forgot to add the code which saves and loads the layout.

    {
        if (true)
        {
            try
            {
                this.cControl.read(new File("layout.cfg"));
                this.cControl.load("current Layout");
            } catch (final Exception e)
            {
                System.out.println("Could not read current Layout");
                e.printStackTrace();
                try
                {
                    this.cControl
                            .read(new DataInputStream(
                                    ClassLoader
                                            .getSystemResourceAsStream("de/fhtrier/themis/gui/layout/layout.cfg")));
                    this.cControl.load("default Layout");
                } catch (final Exception ex)
                {
                    System.out.println("Could not read default Layout");
                    e.printStackTrace();
                }
            }
        }
    }

    private void saveLayout()
    {
        try
        {
            this.cControl.save("current Layout");
            final File f = new File("layout.cfg");
            if (!f.exists())
            {
                f.createNewFile();
                System.out
                        .println("New file \"layout.cfg\" has been created to the current directory");
            }
            this.cControl.write(f);
        } catch (final IOException e)
        {
            System.out.println("Could not write Layout config");
        }
    }```

Combining “random” and your stack trace: you do not load the layout in the EventDispatcherThread. This could be one cause of the bug. What happens if you use EventQueue.invokeLater for loading the layout?

[Edit: especially the last exception must be due to concurrent threads: because the method throwing the exception just calls “new ArrayList( aSetOfValues )”]

I also know that there is a bug in 1.0.8p5c which could cause similar problems, but that bug only exists since 1.0.8p4. So that might not be related to your problem.

Thanks for your quick help.
The exceptions are now gone after using the Event Dispatcher to load the Layout.

MfG
schumacb