mirror of
https://github.com/correl/mage.git
synced 2025-02-16 15:54:35 +00:00
GUI: fixed rare NPE error on images loading in the games;
This commit is contained in:
parent
42364f7e27
commit
1239a0299b
2 changed files with 15 additions and 3 deletions
|
@ -563,11 +563,23 @@ public class CardPanelRenderModeImage extends CardPanel {
|
|||
public void doLayout() {
|
||||
super.doLayout();
|
||||
|
||||
int cardWidth = getCardLocation().getCardWidth(); // must use current panel sizes to scale real image
|
||||
int cardHeight = getCardLocation().getCardHeight();
|
||||
int cardWidth;
|
||||
int cardHeight;
|
||||
int cardXOffset = 0;
|
||||
int cardYOffset = 0;
|
||||
|
||||
// workaround to fix a rare NPE error with image loading
|
||||
// reason: panel runs image load in another thread and that thread can be completed before top panel init, see updateArtImage
|
||||
if (getTopPanelRef() == null) {
|
||||
//noinspection deprecation - it's ok for workaround
|
||||
cardWidth = this.getWidth();
|
||||
//noinspection deprecation - it's ok for workaround
|
||||
cardHeight = this.getHeight();
|
||||
} else {
|
||||
cardWidth = getCardLocation().getCardWidth(); // must use real card sizes to scale real image
|
||||
cardHeight = getCardLocation().getCardHeight();
|
||||
}
|
||||
|
||||
CardSizes sizes = new CardSizes(getInsets(), cardXOffset, cardYOffset, cardWidth, cardHeight);
|
||||
|
||||
// origin card without selection
|
||||
|
|
|
@ -22,7 +22,7 @@ public final class Util {
|
|||
public static final boolean isMac = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("mac");
|
||||
public static final boolean isWindows = !System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows");
|
||||
|
||||
public static final ThreadPoolExecutor threadPool;
|
||||
public static final ThreadPoolExecutor threadPool; // uses for card images loading
|
||||
static private int threadCount;
|
||||
|
||||
static {
|
||||
|
|
Loading…
Reference in a new issue