mirror of https://github.com/ppy/osu
Fix potential nullref in `SkinProvidingContainer`
This commit is contained in:
parent
3ff9f9c89d
commit
282c5a9177
|
@ -73,7 +73,8 @@ public LegacySkin(SkinInfo skin, IStorageResourceProvider resources)
|
|||
protected LegacySkin(SkinInfo skin, [CanBeNull] IResourceStore<byte[]> storage, [CanBeNull] IStorageResourceProvider resources, string configurationFilename)
|
||||
: base(skin, resources)
|
||||
{
|
||||
legacyDefaultFallback = CreateFallbackSkin(storage, resources);
|
||||
if (resources != null)
|
||||
legacyDefaultFallback = CreateFallbackSkin(storage, resources);
|
||||
|
||||
using (var stream = storage?.GetStream(configurationFilename))
|
||||
{
|
||||
|
@ -115,8 +116,7 @@ protected LegacySkin(SkinInfo skin, [CanBeNull] IResourceStore<byte[]> storage,
|
|||
}
|
||||
|
||||
[CanBeNull]
|
||||
protected virtual DefaultLegacySkin CreateFallbackSkin(IResourceStore<byte[]> storage, IStorageResourceProvider resources) =>
|
||||
new DefaultLegacySkin(storage, resources);
|
||||
protected virtual DefaultLegacySkin CreateFallbackSkin(IResourceStore<byte[]> storage, IStorageResourceProvider resources) => new DefaultLegacySkin(resources);
|
||||
|
||||
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
|
@ -20,8 +21,10 @@ public class SkinProvidingContainer : Container, ISkinSource
|
|||
{
|
||||
public event Action SourceChanged;
|
||||
|
||||
[CanBeNull]
|
||||
private readonly ISkin skin;
|
||||
|
||||
[CanBeNull]
|
||||
private ISkinSource fallbackSource;
|
||||
|
||||
protected virtual bool AllowDrawableLookup(ISkinComponent component) => true;
|
||||
|
@ -43,10 +46,10 @@ public SkinProvidingContainer(ISkin skin)
|
|||
|
||||
public ISkin FindProvider(Func<ISkin, bool> lookupFunction)
|
||||
{
|
||||
if (lookupFunction(skin))
|
||||
if (skin != null && lookupFunction(skin))
|
||||
return skin;
|
||||
|
||||
return fallbackSource.FindProvider(lookupFunction);
|
||||
return fallbackSource?.FindProvider(lookupFunction);
|
||||
}
|
||||
|
||||
public Drawable GetDrawableComponent(ISkinComponent component)
|
||||
|
@ -93,7 +96,7 @@ private IBindable<TValue> lookupWithFallback<TLookup, TValue>(TLookup lookup, bo
|
|||
{
|
||||
if (canUseSkinLookup)
|
||||
{
|
||||
var bindable = skin.GetConfig<TLookup, TValue>(lookup);
|
||||
var bindable = skin?.GetConfig<TLookup, TValue>(lookup);
|
||||
if (bindable != null)
|
||||
return bindable;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue