Skip to content

Commit

Permalink
Fix NRE on purging cache in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Mar 11, 2023
1 parent efb7fc8 commit e7a385b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion GUI/Controls/ManageMods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ private void purgeContentsToolStripMenuItem_Click(object sender, EventArgs e)
Main.Instance.Manager.Cache.Purge(mod);
}
selected.UpdateIsCached();
Main.Instance.UpdateModContentsTree(selected.ToCkanModule(), true);
Main.Instance.RefreshModContentsTree();
}
}

Expand Down
4 changes: 2 additions & 2 deletions GUI/Controls/ModInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public GUIMod SelectedModule
get => selectedModule;
}

public void UpdateModContentsTree(CkanModule module, bool force = false)
public void RefreshModContentsTree()
{
Contents.UpdateModContentsTree(module, force);
Contents.Refresh();
}

public event Action<GUIMod> OnDownloadClick;
Expand Down
9 changes: 6 additions & 3 deletions GUI/Controls/ModInfoTabs/Contents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ public GUIMod SelectedModule
if (value != selectedModule)
{
selectedModule = value;
UpdateModContentsTree(selectedModule.ToModule());
Util.Invoke(ContentsPreviewTree, () => _UpdateModContentsTree(selectedModule.ToModule()));
}
}
get => selectedModule;
}

public void UpdateModContentsTree(CkanModule module, bool force = false)
public void Refresh()
{
Util.Invoke(ContentsPreviewTree, () => _UpdateModContentsTree(module, force));
if (currentModContentsModule != null)
{
Util.Invoke(ContentsPreviewTree, () => _UpdateModContentsTree(currentModContentsModule, true));
}
}

public event Action<GUIMod> OnDownloadClick;
Expand Down
2 changes: 1 addition & 1 deletion GUI/Dialogs/SettingsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private void PurgeAllMenuItem_Click(object sender, EventArgs e)
}

// finally, clear the preview contents list
Main.Instance.UpdateModContentsTree(null, true);
Main.Instance.RefreshModContentsTree();

UpdateCacheInfo(config.DownloadCacheDir);
}
Expand Down
4 changes: 2 additions & 2 deletions GUI/Main/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,9 @@ private void SetupDefaultSearch()
}
}

public void UpdateModContentsTree(CkanModule module, bool force = false)
public void RefreshModContentsTree()
{
ModInfo.UpdateModContentsTree(module, force);
ModInfo.RefreshModContentsTree();
}

private void ExitToolButton_Click(object sender, EventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion GUI/Main/MainDownload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void _PostModCaching(GUIMod module)
// Update mod list in case is:cached or not:cached filters are active
RefreshModList();
// User might have selected another row. Show current in tree.
UpdateModContentsTree(ModInfo.SelectedModule.ToCkanModule(), true);
RefreshModContentsTree();
}
}
}

0 comments on commit e7a385b

Please sign in to comment.