mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 02:57:25 +08:00
Fix potential nullref in SkinProvidingContainer
This commit is contained in:
parent
3ff9f9c89d
commit
282c5a9177
@ -73,7 +73,8 @@ namespace osu.Game.Skinning
|
||||
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 @@ namespace osu.Game.Skinning
|
||||
}
|
||||
|
||||
[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 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
public event Action SourceChanged;
|
||||
|
||||
[CanBeNull]
|
||||
private readonly ISkin skin;
|
||||
|
||||
[CanBeNull]
|
||||
private ISkinSource fallbackSource;
|
||||
|
||||
protected virtual bool AllowDrawableLookup(ISkinComponent component) => true;
|
||||
@ -43,10 +46,10 @@ namespace osu.Game.Skinning
|
||||
|
||||
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 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
if (canUseSkinLookup)
|
||||
{
|
||||
var bindable = skin.GetConfig<TLookup, TValue>(lookup);
|
||||
var bindable = skin?.GetConfig<TLookup, TValue>(lookup);
|
||||
if (bindable != null)
|
||||
return bindable;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user