-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prevent non-init map NPEs #1745
base: develop
Are you sure you want to change the base?
prevent non-init map NPEs #1745
Conversation
pZoom = map.PieceScalerBoardZoom(firstPiece); | ||
if (!(firstPiece instanceof Stack)) { | ||
boundingBox = this.scalePiece(firstPiece.getShape().getBounds(), pZoom); //Centred on 0 0, with min and max corresponding to width | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simpler would be:
if (map != null && !(firstPiece instanceof Stack)) {
final double pZoom = map.PieceScalerBoardZoom(firstPiece);
boundingBox = this.scalePiece(firstPiece.getShape().getBounds(), pZoom); //Centred on 0 0, with min and max corresponding to width
}
and similar below at 1045.
@@ -1148,7 +1151,11 @@ private void drawDragImage(BufferedImage image, Component target, | |||
//JY | |||
//final Map map = piece.getMap(); | |||
final ASLMap map = (ASLMap) piece.getMap(); | |||
double pZoom = ((ASLMap)map).PieceScalerBoardZoom(piece); | |||
|
|||
double pZoom = 0.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you want pZoom
to be zero? I don't know that there are any circumstances in which zero is a valid value for the scale factor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its fine to change it to 1.0 or anything really, it just needs to be initialized to something so it can be built. Outside of the un-initialized "map" at startup on Linux it doesn't matter becuase once "map" is initialized that value is never used. Here is an example of a stack trace I am trying to prevent from happening. With the changes in this PR they go away.
2024-05-23 00:17:48,698 [269570-main] INFO VASSAL.launch.StartUp - OS Linux 6.7.12-amd64 amd64
2024-05-23 00:17:48,698 [269570-main] INFO VASSAL.launch.StartUp - Java version 17.0.11
2024-05-23 00:17:48,698 [269570-main] INFO VASSAL.launch.StartUp - Java home /usr/lib/jvm/java-17-openjdk-amd64
2024-05-23 00:17:48,698 [269570-main] INFO VASSAL.launch.StartUp - VASSAL version 3.7.12
2024-05-23 00:17:48,839 [269570-AWT-EventQueue-0] INFO VASSAL.launch.ModuleManager - Manager
2024-05-23 00:17:50,677 [269570-SwingWorker-pool-1-thread-1] INFO VASSAL.launch.AbstractLaunchAction - Loading module file /home/euterpe/asl/vasl/VASSAL-3.7.12/../vasl/vasl-6.6.9-beta1.second.vmod
2024-05-23 00:17:52,189 [269570-SwingWorker-pool-1-thread-1] INFO VASSAL.launch.TilingHandler - No images to tile.
2024-05-23 00:17:52,194 [269570-SwingWorker-pool-1-thread-1] INFO VASSAL.launch.AbstractLaunchAction - Loading module VASL
2024-05-23 00:17:52,204 [269570-SwingWorker-pool-1-thread-1] INFO VASSAL.tools.io.ProcessLauncher - launching /usr/lib/jvm/java-17-openjdk-amd64/bin/java -Xms1024M -Xmx1024M -Duser.home=/home/euterpe -Duser.dir=/home/euterpe/asl/vasl/VASSAL-3.7.12 -cp /home/euterpe/asl/vasl/VASSAL-3.7.12/lib/Vengine.jar VASSAL.launch.Player --load -- ../vasl/vasl-6.6.9-beta1.second.vmod
2024-05-23 00:17:53,070 [269614-main] INFO VASSAL.launch.StartUp - Starting
2024-05-23 00:17:53,087 [269614-main] INFO VASSAL.launch.StartUp - OS Linux 6.7.12-amd64 amd64
2024-05-23 00:17:53,087 [269614-main] INFO VASSAL.launch.StartUp - Java version 17.0.11
2024-05-23 00:17:53,087 [269614-main] INFO VASSAL.launch.StartUp - Java home /usr/lib/jvm/java-17-openjdk-amd64
2024-05-23 00:17:53,088 [269614-main] INFO VASSAL.launch.StartUp - VASSAL version 3.7.12
2024-05-23 00:17:53,088 [269614-main] INFO VASSAL.launch.Launcher - Player
2024-05-23 00:18:05,770 [269614-AWT-EventQueue-0] INFO VASSAL.build.GameModule - VASL version 6.6.9-beta1
2024-05-23 00:18:05,814 [269614-AWT-EventQueue-0] WARN VASSAL.build.GameModule - No more than one [Stacking options] allowed in Main Map [Map Window]
2024-05-23 00:18:14,593 [269614-AWT-EventQueue-0] INFO VASSAL.launch.TilingHandler - No images to tile.
2024-05-23 00:19:51,950 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - java.lang.NullPointerException: Cannot invoke "VASL.build.module.ASLMap.PieceScalerBoardZoom(VASSAL.counters.GamePiece)" because "map" is null
2024-05-23 00:19:51,951 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at VASL.build.module.map.ASLPieceMover$AbstractDragHandler.buildBoundingBox(ASLPieceMover.java:1025)
2024-05-23 00:19:51,951 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at VASL.build.module.map.ASLPieceMover$AbstractDragHandler.makeDragImageCursorCommon(ASLPieceMover.java:961)
2024-05-23 00:19:51,951 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at VASL.build.module.map.ASLPieceMover$DragHandlerNoImage.makeDragCursor(ASLPieceMover.java:1628)
2024-05-23 00:19:51,951 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at VASL.build.module.map.ASLPieceMover$DragHandlerNoImage.dragEnter(ASLPieceMover.java:1711)
2024-05-23 00:19:51,951 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.dnd.DropTarget.dragEnter(DropTarget.java:358)
2024-05-23 00:19:51,951 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/sun.awt.dnd.SunDropTargetContextPeer.processEnterMessage(SunDropTargetContextPeer.java:335)
2024-05-23 00:19:51,951 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/sun.awt.X11.XDropTargetContextPeer.processEnterMessage(XDropTargetContextPeer.java:166)
2024-05-23 00:19:51,951 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEnterEvent(SunDropTargetContextPeer.java:811)
2024-05-23 00:19:51,952 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEvent(SunDropTargetContextPeer.java:779)
2024-05-23 00:19:51,952 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/sun.awt.dnd.SunDropTargetEvent.dispatch(SunDropTargetEvent.java:48)
2024-05-23 00:19:51,952 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4866)
2024-05-23 00:19:51,952 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
2024-05-23 00:19:51,952 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
2024-05-23 00:19:51,952 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
2024-05-23 00:19:51,952 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.LightweightDispatcher.retargetMouseEnterExit(Container.java:4726)
2024-05-23 00:19:51,952 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.LightweightDispatcher.trackDropTargetEnterExit(Container.java:4675)
2024-05-23 00:19:51,952 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4688)
2024-05-23 00:19:51,952 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.LightweightDispatcher.processDropTargetEvent(Container.java:4641)
2024-05-23 00:19:51,953 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4511)
2024-05-23 00:19:51,953 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
2024-05-23 00:19:51,953 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
2024-05-23 00:19:51,953 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
2024-05-23 00:19:51,953 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775)
2024-05-23 00:19:51,953 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
2024-05-23 00:19:51,953 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
2024-05-23 00:19:51,953 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
2024-05-23 00:19:51,953 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
2024-05-23 00:19:51,953 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
2024-05-23 00:19:51,954 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)
2024-05-23 00:19:51,954 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
2024-05-23 00:19:51,954 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
2024-05-23 00:19:51,954 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
2024-05-23 00:19:51,954 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744)
2024-05-23 00:19:51,954 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
2024-05-23 00:19:51,954 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
2024-05-23 00:19:51,954 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
2024-05-23 00:19:51,955 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
2024-05-23 00:19:51,955 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
2024-05-23 00:19:51,955 [269614-AWT-EventQueue-0] WARN VASSAL.tools.logging.LoggedOutputStream - at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)```
I have absolutely no idea of how to integrate @uckelman's revisions and proceed with the pull request. Normally, I like to learn but at this point in time I just can't. If anyone knows how to do this, please go ahead, add @uckelman 's changes and process the pull request. Otherwise, I will just make the changes in my own code, push it to develop and scrap this entirely. |
No description provided.