Fixed NPE in byte viewer when switching themes

This commit is contained in:
dragonmacher 2025-01-13 13:28:49 -05:00 committed by Ryan Kurtz
parent 2f8217af10
commit 31e926fd44
2 changed files with 6 additions and 3 deletions

View file

@ -612,8 +612,8 @@ public class ByteViewerPanel extends JPanel implements LayoutModel, LayoutListen
c.setFontMetrics(fm); c.setFontMetrics(fm);
} }
indexFactory = new IndexFieldFactory(fm); indexFactory = new IndexFieldFactory(fm);
updateIndexMap();
indexFactory.setSize(getIndexSizeInChars()); indexFactory.setSize(getIndexSizeInChars());
updateIndexMap();
indexPanel.modelSizeChanged(IndexMapper.IDENTITY_MAPPER); indexPanel.modelSizeChanged(IndexMapper.IDENTITY_MAPPER);
} }

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -52,6 +52,9 @@ class IndexFieldFactory {
width = ByteViewerComponentProvider.DEFAULT_NUMBER_OF_CHARS * charWidth; width = ByteViewerComponentProvider.DEFAULT_NUMBER_OF_CHARS * charWidth;
missingValueColor = ByteViewerComponentProvider.SEPARATOR_COLOR; missingValueColor = ByteViewerComponentProvider.SEPARATOR_COLOR;
startX = charWidth; startX = charWidth;
// initialize to a non-null value
setSize(1);
} }
/** /**