mirror of https://github.com/ppy/osu
Fix skin editor freezing game if opened during active gameplay
This commit is contained in:
parent
b5cb538004
commit
5ad962070c
|
@ -21,5 +21,11 @@ public struct ImportParameters
|
|||
/// Whether this import should use hard links rather than file copy operations if available.
|
||||
/// </summary>
|
||||
public bool PreferHardLinks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If set to <see langword="true"/>, this import will not respect <see cref="RealmArchiveModelImporter{TModel}.PauseImports"/>.
|
||||
/// This is useful for cases where an import <em>must</em> complete even if gameplay is in progress.
|
||||
/// </summary>
|
||||
public bool ImportImmediately { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,7 +261,7 @@ await Task.WhenAll(tasks.Select(async task =>
|
|||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||
public virtual Live<TModel>? ImportModel(TModel item, ArchiveReader? archive = null, ImportParameters parameters = default, CancellationToken cancellationToken = default) => Realm.Run(realm =>
|
||||
{
|
||||
pauseIfNecessary(cancellationToken);
|
||||
pauseIfNecessary(parameters, cancellationToken);
|
||||
|
||||
TModel? existing;
|
||||
|
||||
|
@ -560,9 +560,9 @@ protected virtual void UndeleteForReuse(TModel existing)
|
|||
/// <returns>Whether to perform deletion.</returns>
|
||||
protected virtual bool ShouldDeleteArchive(string path) => false;
|
||||
|
||||
private void pauseIfNecessary(CancellationToken cancellationToken)
|
||||
private void pauseIfNecessary(ImportParameters importParameters, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!PauseImports)
|
||||
if (!PauseImports || importParameters.ImportImmediately)
|
||||
return;
|
||||
|
||||
Logger.Log($@"{GetType().Name} is being paused.");
|
||||
|
|
|
@ -182,7 +182,10 @@ public bool EnsureMutableSkin()
|
|||
Name = NamingUtils.GetNextBestName(existingSkinNames, $@"{s.Name} (modified)")
|
||||
};
|
||||
|
||||
var result = skinImporter.ImportModel(skinInfo);
|
||||
var result = skinImporter.ImportModel(skinInfo, parameters: new ImportParameters
|
||||
{
|
||||
ImportImmediately = true // to avoid possible deadlocks when editing skin during gameplay.
|
||||
});
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue