Skip to content

Commit

Permalink
Fixed crash that would occur because the window server was not yet cr…
Browse files Browse the repository at this point in the history
…eated when trying to create windows via scripts
  • Loading branch information
fLindahl committed Nov 11, 2024
1 parent c9ec6a8 commit 64efb04
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
22 changes: 15 additions & 7 deletions toolkit/editor/editor/editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ Create()
IO::AssignRegistry::Instance()->SetAssign(IO::Assign("work", "proj:work"));
IO::AssignRegistry::Instance()->SetAssign(IO::Assign("assets", "work:assets"));

Scripting::ScriptServer::Instance()->AddModulePath("edscr:");
Scripting::ScriptServer::Instance()->EvalFile("edscr:bootstrap.py");

/// Import reload to be able to reload modules.
Scripting::ScriptServer::Instance()->Eval("from importlib import reload");

Game::TimeSourceCreateInfo editorTimeSourceInfo;
editorTimeSourceInfo.hash = TIMESOURCE_EDITOR;
Game::TimeManager::CreateTimeSource(editorTimeSourceInfo);
Expand All @@ -63,7 +57,21 @@ Create()
CreatePathConverter({});

Game::EditorState::Singleton = new Game::EditorState();
Game::EditorState::Instance()->isRunning = true;
}

//------------------------------------------------------------------------------
/**
*/
void
Start()
{
Scripting::ScriptServer::Instance()->AddModulePath("edscr:");
Scripting::ScriptServer::Instance()->EvalFile("edscr:bootstrap.py");

/// Import reload to be able to reload modules.
Scripting::ScriptServer::Instance()->Eval("from importlib import reload");

Game::EditorState::Instance()->isRunning = true;
}

//------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions toolkit/editor/editor/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ struct State
/// Create the editor
void Create();

/// Start the editor
void Start();

/// Destroy the editor
void Destroy();

Expand Down
2 changes: 2 additions & 0 deletions toolkit/editor/editorfeature/editorfeatureunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ EditorFeatureUnit::OnActivate()

this->AttachManager(Editor::UIManager::Create());

Editor::Start();

// TODO: move this to a game manager that is created by the editor

Game::World* world = Game::GetWorld(WORLD_DEFAULT);
Expand Down

0 comments on commit 64efb04

Please sign in to comment.