Skip to content

Commit 4a44887

Browse files
committed
- dont die upon selecting an unknown resource type/file
1 parent dbddbfa commit 4a44887

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

code/resource/resources/resourceserver.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class ResourceServer : public Core::RefCounted
7979
void DeregisterStreamLoader(const Util::StringAtom& ext, const Core::Rtti& loaderClass);
8080
/// get stream pool for later use
8181
template <class POOL_TYPE> POOL_TYPE* GetStreamLoader() const;
82+
/// query if a stream loader is registered for a given extension
83+
bool HasStreamLoader(const Util::StringAtom& ext) const;
8284

8385
/// Wait for all loader threads
8486
void WaitForLoaderThread();
@@ -198,6 +200,17 @@ ResourceServer::ReloadResource(const ResourceName& res, std::function<void(const
198200
loader->ReloadResource(res, success, failed);
199201
}
200202

203+
204+
//------------------------------------------------------------------------------
205+
/**
206+
*/
207+
inline bool
208+
ResourceServer::HasStreamLoader(const Util::StringAtom& ext) const
209+
{
210+
IndexT i = this->extensionMap.FindIndex(ext);
211+
return i != InvalidIndex;
212+
}
213+
201214
//------------------------------------------------------------------------------
202215
/**
203216
*/

toolkit/editor/editor/ui/windows/asseteditor/asseteditor.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ AssetEditor::Open(const Resources::ResourceName& asset, const AssetType type)
277277
}
278278
}
279279

280+
if (!Resources::ResourceServer::Instance()->HasStreamLoader(asset.AsString().GetFileExtension()))
281+
{
282+
// we just ignore for now
283+
return;
284+
}
280285
// Otherwise, trigger an async load and setup a new item
281286
Resources::CreateResource(asset, "editor",
282287
[asset, type](Resources::ResourceId id)

0 commit comments

Comments
 (0)