call loadResources only once in init phase

This commit is contained in:
Mikulas Florek 2017-07-04 10:12:48 +02:00
parent 4b1791fb34
commit f318e9395e
3 changed files with 12 additions and 3 deletions

View file

@ -57,6 +57,7 @@ AssetBrowser::AssetBrowser(StudioApp& app)
, m_current_type(0)
, m_is_opened(false)
, m_activate(false)
, m_is_init_finished(false)
, m_history_index(-1)
{
auto& editor = *app.getWorldEditor();
@ -64,8 +65,6 @@ AssetBrowser::AssetBrowser(StudioApp& app)
m_filter[0] = '\0';
m_resources.emplace(allocator);
findResources();
const char* base_path = editor.getEngine().getDiskFileDevice()->getBasePath();
m_watchers[0] = FileSystemWatcher::create(base_path, allocator);
m_watchers[0]->getCallback().bind<AssetBrowser, &AssetBrowser::onFileChanged>(this);
@ -331,11 +330,18 @@ void AssetBrowser::selectResource(Resource* resource, bool record_history)
}
void AssetBrowser::onInitFinished()
{
m_is_init_finished = true;
findResources();
}
void AssetBrowser::addPlugin(IPlugin& plugin)
{
m_plugins.push(&plugin);
m_resources.emplace(m_editor.getAllocator());
findResources();
if(m_is_init_finished) findResources();
}

View file

@ -47,6 +47,7 @@ public:
int getTypeIndex(ResourceType type) const;
void selectResource(const Path& resource, bool record_history);
bool resourceInput(const char* label, const char* str_id, char* buf, int max_size, ResourceType type);
void onInitFinished();
void addPlugin(IPlugin& plugin);
void openInExternalEditor(Resource* resource);
void openInExternalEditor(const char* path);
@ -96,6 +97,7 @@ private:
bool m_is_focus_requested;
bool m_activate;
bool m_is_update_enabled;
bool m_is_init_finished;
Action* m_auto_reload_action;
Action* m_back_action;
Action* m_forward_action;

View file

@ -2170,6 +2170,7 @@ public:
loadUniverseFromCommandLine();
findLuaPlugins("plugins/lua/");
m_asset_browser->onInitFinished();
m_sleep_when_inactive = shouldSleepWhenInactive();
}