Skip to content

Commit

Permalink
Fix for test.
Browse files Browse the repository at this point in the history
Seems await in catch is breaking things.
  • Loading branch information
RichardLake committed Jun 1, 2015
1 parent 814da57 commit a5fa0a4
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions GUI/MainModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void _UpdateModsList(bool repo_updated)

public void MarkModForInstall(string identifier, bool uninstall = false)
{
Util.Invoke(this, () => _MarkModForInstall(identifier,uninstall));
Util.Invoke(this, () => _MarkModForInstall(identifier, uninstall));
}

private void _MarkModForInstall(string identifier, bool uninstall)
Expand Down Expand Up @@ -139,7 +139,8 @@ public class MainModList
{
internal List<DataGridViewRow> full_list_of_mod_rows;

public MainModList(ModFiltersUpdatedEvent onModFiltersUpdated, HandleTooManyProvides too_many_provides, IUser user = null)
public MainModList(ModFiltersUpdatedEvent onModFiltersUpdated, HandleTooManyProvides too_many_provides,
IUser user = null)
{
this.too_many_provides = too_many_provides;
this.user = user ?? new NullUser();
Expand All @@ -149,6 +150,7 @@ public MainModList(ModFiltersUpdatedEvent onModFiltersUpdated, HandleTooManyProv
}

public delegate void ModFiltersUpdatedEvent(MainModList source);

//TODO Move to relationship resolver and have it use this.
public delegate Task<CkanModule> HandleTooManyProvides(TooManyModsProvideKraken kraken);

Expand Down Expand Up @@ -192,7 +194,7 @@ public string ModAuthorFilter
private GUIModFilter _modFilter = GUIModFilter.Compatible;
private string _modNameFilter = String.Empty;
private string _modAuthorFilter = String.Empty;
private IUser user;
private IUser user;

/// <summary>
/// This function returns a changeset based on the selections of the user.
Expand Down Expand Up @@ -231,31 +233,39 @@ public async Task<IEnumerable<KeyValuePair<CkanModule, GUIModChangeType>>> Compu
}
}

//May throw InconsistentKraken
while (true)
bool handled_all_to_many_provides = false;
while (!handled_all_to_many_provides)
{
//Can't await in catch clause - doesn't seem to work in mono. Hence this flag
TooManyModsProvideKraken kraken = null;
try
{
new RelationshipResolver(modules_to_install.ToList(), options, registry, version);
handled_all_to_many_provides = true;
continue;
}
catch (TooManyModsProvideKraken kraken)
catch (TooManyModsProvideKraken k)
{
var mod = await too_many_provides(kraken);
if (mod != null)
{
modules_to_install.Add(mod.identifier);
continue;
}
throw;
kraken = k;
}
catch (ModuleNotFoundKraken kraken)
catch (ModuleNotFoundKraken k)
{
//We shouldn't need this. However the relationship provider will throw TMPs with incompatible mods.
user.RaiseError("Module {0} has not been found. This may be because it is not compatible " +
"with the currently installed version of KSP", kraken.module);
"with the currently installed version of KSP", k.module);
return null;
}
break;
//Shouldn't get here unless there is a kraken.
var mod = await too_many_provides(kraken);
if (mod != null)
{
modules_to_install.Add(mod.identifier);
}
else
{
//TODO Is could be a new type of Kraken.
throw kraken;
}
}

var resolver = new RelationshipResolver(modules_to_install.ToList(), options, registry, version);
Expand Down Expand Up @@ -319,7 +329,7 @@ public IEnumerable<DataGridViewRow> ConstructModList(IEnumerable<GUIMod> modules
: new DataGridViewTextBoxCell();

installed_cell.Value = mod.IsInstallable()
? (object)mod.IsInstalled
? (object) mod.IsInstalled
: (mod.IsAutodetected ? "AD" : "-");

var update_cell = mod.HasUpdate && !mod.IsAutodetected
Expand Down

0 comments on commit a5fa0a4

Please sign in to comment.