Project

General

Profile

Bug #14819

PopupDialog.SpawnDialog throws NullReferenceException on 32-bit versions if addon is set to startup instantly

Added by Xinayder about 7 years ago. Updated almost 7 years ago.

Status:
New
Severity:
Normal
Assignee:
-
Category:
Plugins/Add-Ons
Target version:
-
Start date:
04/14/2017
% Done:

0%

Version:
Platform:
Linux, OSX, Windows
Expansion:
Language:
English (US)
Mod Related:
No
Votes:
Arrow u r green
Arrow d r red

Description

The API method PopupDialog.SpawnDialog is sort of broken for 32-bit versions of KSP. If you have a mod/addon that uses this method, and this addon uses

[KSPAddon(KSPAddon.Startup.Instantly, true)]
it will certainly throw a NRE.

Take a look at the following code:

    [KSPAddon(KSPAddon.Startup.Instantly, true)]
    public class NRETesterKSP : MonoBehaviour
    {
        public void Awake()
        {
            PopupDialog.SpawnPopupDialog(
                Vector2.zero, Vector2.zero, "A simple dialog", "this is a title", "this should be the message", 
                "this should be a button", true, HighLogic.UISkin, true);
        }
    }

If I compile and use the resulting DLL in a 32-bit version of KSP, it will throw a NRE and the dialog will only contain the title, message and buttons are gone, as soon as the addon is loaded (which is instantly). If I change the first line of the code above to

[KSPAddon(KSPAddon.Startup.MainMenu, true)]
it won't throw and the dialog will be displayed correctly.

Reference thread: http://forum.kerbalspaceprogram.com/index.php?/topic/159162-popupdialog-is-still-throwing-nre-on-ksp_win32/

History

#1 Updated by JPLRepo almost 7 years ago

  • Severity changed from Critical to Normal

Refer to the priority classifications on the wiki.
http://bugs.kerbalspaceprogram.com/projects/ksp/wiki
Set to normal, although is almost a low.

Also available in: Atom PDF