PDA

View Full Version : Startup, loading CT with tokens on map API error



celestian
November 7th, 2019, 02:05
I get an API error when starting up FGU with a active CT and tokens on a map.



[11/6/2019 7:58:34 PM] [<color="red">ERROR</color>] API: System.NullReferenceException: Object reference not set to an instance of an object
at GMGNGILAJHH.GLPNDFJGGNJ (System.Int32 BOIPGENFHAM) [0x00052] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
at GMGNGILAJHH.IFEEOGEPEOF () [0x0002f] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
at GMGNGILAJHH.BPHCCJGNDPI (System.IntPtr ANIKPCBCLNB) [0x0000a] in <41600b80fbc04a89a7507a7f2dadaf6f>:0


I couldn't narrow down WHY but if the API error code means something that someone can explain I 'll do what I can to reduce the variables and figure out the exact reason.

Moon Wizard
November 7th, 2019, 19:01
It looks like it's tied to the imagecontrol.clearSelectedTokens API. What were you doing when it happened?

Thanks,
JPG

Moon Wizard
November 7th, 2019, 19:24
I just tried the double-click on token that opens the underlying linked PC/NPC sheet; and I didn't get any exception. So, I'm guessing that it's a data issue (something specific in your campaign data), or a workflow issue (something specific to the steps you were following or the code you were executing).

Let me know if you have any ideas, or can give me steps with your campaign data.

Thanks,
JPG

celestian
November 7th, 2019, 20:10
It looks like it's tied to the imagecontrol.clearSelectedTokens API. What were you doing when it happened?

Thanks,
JPG

I had an issue with selected tokens and some features I was working on (discussion found here (https://www.fantasygrounds.com/forums/showthread.php?49586-API-calls-to-remove-quot-token-selection-quot)) and I clear selected tokens. I do not get errors in FGC when I do this so perhaps it's a bit more lenient on something I'm not seeing yet.

I'll review what is happening and verify values are not null.

Moon Wizard
November 7th, 2019, 22:11
It's an internal null error, which means that something is not connected right. This is is why I'm more concerned with recreating the issue rather than tracking down or covering it up.

If you have a reproduceable case, that would help us track down and prevent that it doesn't happen in other places as well.

Regards,
JPG

celestian
November 7th, 2019, 22:51
So I added a bit more sanity checking to make sure I'm passing valid variables.



-- clean any selected token, select active one
-- a side effect of doing this is if the map is NOT opened it will open the map
function clearMapSelectedToken()
local nodeCT = getDatabaseNode();
local tokenMap = CombatManager.getTokenFromCT(nodeCT);
local imageControl = ImageManager.getImageControl(tokenMap, true);
if imageControl then
imageControl.clearSelectedTokens();
imageControl.selectToken( tokenMap, true ) ;
end
TokenManagerADND.resetIndicators(nodeCT, false);
end


That is run when the "active" value (whomever has initiative) is updated which also means when the CT is opened.

It's looking like because I clearSelectedTokens for all tokens when the CT is first loaded (not just the one that had ".active" updated)... after the first token initializes the clear the following ones get the error.

The console output log buffer is filling up and the copy/paste of it only copies what I can see, not the entire buffer so making it hard to track this down.



[11/7/2019 4:46:42 PM] [NOTICE] s'cta_entry.lua' | s'onInit:name' | s'Harpy'
[11/7/2019 4:46:43 PM] [NOTICE] s'cta_entry.lua' | s'clearMapSelectedToken:name' | s'Harpy'
[11/7/2019 4:46:44 PM] [NOTICE] s'cta_entry.lua' | s'onInit:name' | s'Bugbear 1'
[11/7/2019 4:46:44 PM] [NOTICE] s'cta_entry.lua' | s'clearMapSelectedToken:name' | s'Bugbear 1'
[11/7/2019 4:46:44 PM] [<color="red">ERROR</color>] API: System.NullReferenceException: Object reference not set to an instance of an object
at GMGNGILAJHH.GLPNDFJGGNJ (System.Int32 BOIPGENFHAM) [0x00052] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
at GMGNGILAJHH.IFEEOGEPEOF () [0x0002f] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
at GMGNGILAJHH.BPHCCJGNDPI (System.IntPtr ANIKPCBCLNB) [0x0000a] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
[11/7/2019 4:46:44 PM] [NOTICE] s'cta_entry.lua' | s'onInit:name' | s'Bugbear 2'
[11/7/2019 4:46:44 PM] [NOTICE] s'cta_entry.lua' | s'clearMapSelectedToken:name' | s'Bugbear 2'
[11/7/2019 4:46:44 PM] [<color="red">ERROR</color>] API: System.NullReferenceException: Object reference not set to an instance of an object
at GMGNGILAJHH.GLPNDFJGGNJ (System.Int32 BOIPGENFHAM) [0x00052] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
at GMGNGILAJHH.IFEEOGEPEOF () [0x0002f] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
at GMGNGILAJHH.BPHCCJGNDPI (System.IntPtr ANIKPCBCLNB) [0x0000a] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
[11/7/2019 4:46:44 PM] [NOTICE] s'cta_entry.lua' | s'onInit:name' | s'Bugbear 3'
[11/7/2019 4:46:44 PM] [NOTICE] s'cta_entry.lua' | s'clearMapSelectedToken:name' | s'Bugbear 3'
[11/7/2019 4:46:44 PM] [<color="red">ERROR</color>] API: System.NullReferenceException: Object reference not set to an instance of an object
at GMGNGILAJHH.GLPNDFJGGNJ (System.Int32 BOIPGENFHAM) [0x00052] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
at GMGNGILAJHH.IFEEOGEPEOF () [0x0002f] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
at GMGNGILAJHH.BPHCCJGNDPI (System.IntPtr ANIKPCBCLNB) [0x0000a] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
[11/7/2019 4:46:44 PM] [NOTICE] s'cta_entry.lua' | s'onInit:name' | s'Test Character'
[11/7/2019 4:46:44 PM] [NOTICE] s'cta_entry.lua' | s'clearMapSelectedToken:name' | s'Test Character'
[11/7/2019 4:46:44 PM] [<color="red">ERROR</color>] API: System.NullReferenceException: Object reference not set to an instance of an object
at GMGNGILAJHH.GLPNDFJGGNJ (System.Int32 BOIPGENFHAM) [0x00052] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
at GMGNGILAJHH.IFEEOGEPEOF () [0x0002f] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
at GMGNGILAJHH.BPHCCJGNDPI (System.IntPtr ANIKPCBCLNB) [0x0000a] in <41600b80fbc04a89a7507a7f2dadaf6f>:0
[11/7/2019 4:46:44 PM] [WARNING] Frame d10red contains out-of-range values in TopLeft.


You'll note after the harpy there is no error but every token after that has an error.

For me I can "cover" (which I will probably do because I don't NEED to clear all selected but once) this by making sure that it only clears the selected if the token is "active" but the cause certainly seems because I'm calling clearSelectedTokens multiple times. That said right after the clear I force it to select THAT token so in theory there should be a token selected to clear when it goes to the next NPC...

During normal initiative cycle this doesn't happen. Only when the CT is opened.

Moon Wizard
November 7th, 2019, 22:54
Can you get me an example campaign and files, so that I can recreate this?

It looks like something is getting unhooked internally after the first clearSelectedTokens.

Thanks,
JPG

celestian
November 7th, 2019, 23:13
Can you get me an example campaign and files, so that I can recreate this?

It looks like something is getting unhooked internally after the first clearSelectedTokens.

Thanks,
JPG

I've attached the campaign file I'm using right now. It should happen with any campaign that has multiple tokens on the map. Close the CT and then re-open the CT.

Moon Wizard
November 8th, 2019, 01:01
Thanks, I was able to reproduce; and I'll work on getting the fix in the next build.

Regards,
JPG