From 31e926fd447931c7ee0ce6aa2ab06bd9f8f55231 Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:28:49 -0500 Subject: [PATCH] Fixed NPE in byte viewer when switching themes --- .../ghidra/app/plugin/core/byteviewer/ByteViewerPanel.java | 2 +- .../app/plugin/core/byteviewer/IndexFieldFactory.java | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerPanel.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerPanel.java index d6f279f7bf..654d0b75ae 100644 --- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerPanel.java +++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerPanel.java @@ -612,8 +612,8 @@ public class ByteViewerPanel extends JPanel implements LayoutModel, LayoutListen c.setFontMetrics(fm); } indexFactory = new IndexFieldFactory(fm); - updateIndexMap(); indexFactory.setSize(getIndexSizeInChars()); + updateIndexMap(); indexPanel.modelSizeChanged(IndexMapper.IDENTITY_MAPPER); } diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/IndexFieldFactory.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/IndexFieldFactory.java index 5f4ac0b0ca..22bd48bddb 100644 --- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/IndexFieldFactory.java +++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/IndexFieldFactory.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -52,6 +52,9 @@ class IndexFieldFactory { width = ByteViewerComponentProvider.DEFAULT_NUMBER_OF_CHARS * charWidth; missingValueColor = ByteViewerComponentProvider.SEPARATOR_COLOR; startX = charWidth; + + // initialize to a non-null value + setSize(1); } /**