Skip to content

Commit 486e22d

Browse files
committed
Merge pull request #867 from fdorg/fix/targetbuild_clear
Prevent occasional loss of target build value when building
2 parents 6ec7f2d + b5837b2 commit 486e22d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

External/Plugins/ProjectManager/Controls/FDMenus.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ public FDMenus(IMainForm mainForm)
9898

9999
public void EnableTargetBuildSelector(bool enabled)
100100
{
101+
var target = TargetBuildSelector.Text; // prevent occasional loss of value when the control is disabled
101102
TargetBuildSelector.Enabled = enabled;
103+
TargetBuildSelector.Text = target;
102104
}
103105

104106
public bool DisabledForBuild
@@ -139,18 +141,26 @@ public void ProjectChanged(Project project)
139141
{
140142
TargetBuildSelector.Items.AddRange(project.MovieOptions.TargetBuildTypes);
141143
string target = project.TargetBuild ?? project.MovieOptions.TargetBuildTypes[0];
142-
if (!String.IsNullOrEmpty(target) && !TargetBuildSelector.Items.Contains(target)) TargetBuildSelector.Items.Insert(0, target);
144+
AddTargetBuild(target);
143145
TargetBuildSelector.Text = target;
144146
}
145147
else
146148
{
147149
string target = project.TargetBuild ?? "";
148-
if (target != "") TargetBuildSelector.Items.Insert(0, target);
150+
AddTargetBuild(target);
149151
TargetBuildSelector.Text = target;
150152
}
151153
EnableTargetBuildSelector(true);
152154
}
153155

156+
internal void AddTargetBuild(string target)
157+
{
158+
if (target == null) return;
159+
target = target.Trim();
160+
if (target.Length > 0 && !TargetBuildSelector.Items.Contains(target))
161+
TargetBuildSelector.Items.Insert(0, target);
162+
}
163+
154164

155165
public void ToggleDebugRelease()
156166
{

External/Plugins/ProjectManager/PluginMain.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ private void ApplyTargetBuild()
320320
Project project = activeProject;
321321
if (project != null && project.TargetBuild != target)
322322
{
323-
if (!menus.TargetBuildSelector.Items.Contains(target))
324-
menus.TargetBuildSelector.Items.Insert(0, target);
323+
menus.AddTargetBuild(target);
325324
FlexCompilerShell.Cleanup();
326325
project.TargetBuild = menus.TargetBuildSelector.Text;
327326
project.UpdateVars(false);

0 commit comments

Comments
 (0)