Skip to content

Fix GUI instance name checking #2316

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

Merged
merged 1 commit into from
Feb 25, 2018

Conversation

HebaruSan
Copy link
Member

Problem

If you try to add a new game instance in GUI that has the same folder name as an existing instance, you get this exception:

image

This worked fine on previous versions.

Cause

In #2239, this function:

try
{
KSP instance = new KSP(path, GUI.user);
var instanceName = Path.GetFileName(path);
instanceName = _manager.GetNextValidInstanceName(instanceName);
_manager.AddInstance(instanceName, instance);
UpdateInstancesList();
}

was changed to pass the name of the instance to the constructor of KSP instead of AddInstance, because instances now know their own names. However, the GetNextValidInstanceName call ended up in the wrong place; it should be before we use the name, but it's after:

try
{
var instanceName = Path.GetFileName(path);
KSP instance = new KSP(path, instanceName, GUI.user);
instanceName = _manager.GetNextValidInstanceName(instanceName);
_manager.AddInstance(instance);
UpdateInstancesList();
}

Changes

Now GetNextValidInstanceName is called before the instance is created.

Fixes #2315.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@HebaruSan HebaruSan added Bug Something is not working as intended GUI Issues affecting the interactive GUI Pull request labels Feb 25, 2018
@politas politas merged commit 26056e8 into KSP-CKAN:master Feb 25, 2018
politas added a commit that referenced this pull request Feb 25, 2018
@politas politas removed Bug Something is not working as intended Pull request labels Feb 25, 2018
@HebaruSan HebaruSan deleted the fix/gui-add-instance-name branch February 25, 2018 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI Issues affecting the interactive GUI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants