mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 01:37:46 +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)
|
protected LegacySkin(SkinInfo skin, [CanBeNull] IResourceStore<byte[]> storage, [CanBeNull] IStorageResourceProvider resources, string configurationFilename)
|
||||||
: base(skin, resources)
|
: base(skin, resources)
|
||||||
{
|
{
|
||||||
legacyDefaultFallback = CreateFallbackSkin(storage, resources);
|
if (resources != null)
|
||||||
|
legacyDefaultFallback = CreateFallbackSkin(storage, resources);
|
||||||
|
|
||||||
using (var stream = storage?.GetStream(configurationFilename))
|
using (var stream = storage?.GetStream(configurationFilename))
|
||||||
{
|
{
|
||||||
@ -115,8 +116,7 @@ namespace osu.Game.Skinning
|
|||||||
}
|
}
|
||||||
|
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
protected virtual DefaultLegacySkin CreateFallbackSkin(IResourceStore<byte[]> storage, IStorageResourceProvider resources) =>
|
protected virtual DefaultLegacySkin CreateFallbackSkin(IResourceStore<byte[]> storage, IStorageResourceProvider resources) => new DefaultLegacySkin(resources);
|
||||||
new DefaultLegacySkin(storage, resources);
|
|
||||||
|
|
||||||
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -20,8 +21,10 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
public event Action SourceChanged;
|
public event Action SourceChanged;
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
private readonly ISkin skin;
|
private readonly ISkin skin;
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
private ISkinSource fallbackSource;
|
private ISkinSource fallbackSource;
|
||||||
|
|
||||||
protected virtual bool AllowDrawableLookup(ISkinComponent component) => true;
|
protected virtual bool AllowDrawableLookup(ISkinComponent component) => true;
|
||||||
@ -43,10 +46,10 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
public ISkin FindProvider(Func<ISkin, bool> lookupFunction)
|
public ISkin FindProvider(Func<ISkin, bool> lookupFunction)
|
||||||
{
|
{
|
||||||
if (lookupFunction(skin))
|
if (skin != null && lookupFunction(skin))
|
||||||
return skin;
|
return skin;
|
||||||
|
|
||||||
return fallbackSource.FindProvider(lookupFunction);
|
return fallbackSource?.FindProvider(lookupFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable GetDrawableComponent(ISkinComponent component)
|
public Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
@ -93,7 +96,7 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
if (canUseSkinLookup)
|
if (canUseSkinLookup)
|
||||||
{
|
{
|
||||||
var bindable = skin.GetConfig<TLookup, TValue>(lookup);
|
var bindable = skin?.GetConfig<TLookup, TValue>(lookup);
|
||||||
if (bindable != null)
|
if (bindable != null)
|
||||||
return bindable;
|
return bindable;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user