Skip to content

Commit

Permalink
Client: Tweaking the application initialization procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent f90b06c commit 9b40059
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
42 changes: 26 additions & 16 deletions doomsday/apps/client/src/dd_main.cpp
Expand Up @@ -56,6 +56,7 @@
#ifdef __CLIENT__
# include <de/texgamma.h>
# include <de/DisplayMode>
# include <de/GLWindow>
#endif
#include <doomsday/AbstractSession>
#include <doomsday/console/alias.h>
Expand Down Expand Up @@ -1055,6 +1056,7 @@ static void initializeWithWindowReady()
static char const *AUTOEXEC_NAME = "autoexec.cfg";

#ifdef __CLIENT__
GLWindow::main().glActivate();
GL_EarlyInit();
#endif

Expand Down Expand Up @@ -1292,22 +1294,30 @@ void DD_FinishInitializationAfterWindowReady()
#endif // __CLIENT__

// Initialize engine subsystems and initial state.
try
{
initializeWithWindowReady();
// Let everyone know we're up and running (via another timer callback).
Loop::timer(0.1, [] () { App::app().notifyStartupComplete(); });
return;
}
catch (Error const &er)
{
EscapeParser esc;
esc.parse(er.asText());
Sys_CriticalMessage(esc.plainText());
}
catch (...)
{}
exit(2); // Cannot continue...
Loop::timer(0.01, []() {
try
{
// The rest of the initialization assumes that the main window exists.
initializeWithWindowReady();
// Let everyone know we're up and running.
/*Loop::timer(0.1, []() {*/ App::app().notifyStartupComplete(); //});
return;
}
catch (Error const &er)
{
EscapeParser esc;
esc.parse(er.asText());
Sys_CriticalMessage(esc.plainText());
}
catch (...)
{}
// Shut down the application.
#if defined (__CLIENT__)
DE_GUI_APP->quit(2);
#else
DE_TEXT_APP->quit(2);
#endif
});
}

static dint DD_StartupWorker(void * /*context*/)
Expand Down
13 changes: 6 additions & 7 deletions doomsday/apps/client/src/main_client.cpp
Expand Up @@ -101,18 +101,17 @@ int main(int argc, char **argv)
* parse tr strings from inside private implementation classes. Workaround
* or fix is needed?
*/
#if 0
/*#if 0
// Load the current locale's translation.
QTranslator translator;
translator.load(QString("client_") + QLocale::system().name());
clientApp.installTranslator(&translator);
#endif
#endif*/

try
{
clientApp.initialize();

#if defined (DE_MOBILE)
/*
#if defined (DE_MOBILE)
// On mobile, Qt Quick is actually in charge of drawing the screen.
// GLWindow is just an item that draws the UI background.
qmlRegisterType<de::GLQuickItemT<ClientWindow>>("Doomsday", 1, 0, "ClientWindow");
Expand All @@ -121,8 +120,8 @@ int main(int argc, char **argv)
view.setSource(QUrl("qrc:///qml/main.qml"));
view.show();
#endif

exitCode = clientApp.exec();
*/
exitCode = clientApp.exec([&]() { clientApp.initialize(); });
}
catch (const de::Error &er)
{
Expand Down
2 changes: 2 additions & 0 deletions doomsday/apps/client/src/ui/inputsystem.cpp
Expand Up @@ -577,6 +577,7 @@ DE_PIMPL(InputSystem)
*/
void readMouse()
{
#if 0
if (!Mouse_IsPresent())
return;

Expand Down Expand Up @@ -675,6 +676,7 @@ DE_PIMPL(InputSystem)
}
}
}
#endif
}

/**
Expand Down
5 changes: 3 additions & 2 deletions doomsday/libs/legacy/src/concurrency.cpp
Expand Up @@ -25,6 +25,7 @@
#include <de/App>
#include <de/Time>
#include <de/Log>
#include <de/Loop>
#include <de/Garbage>
#include <assert.h>

Expand Down Expand Up @@ -58,10 +59,10 @@ CallbackThread::~CallbackThread()
}
}

//void CallbackThread::deleteNow()
void CallbackThread::threadFinished(Thread &)
{
de::trash(this); //delete this;
using namespace de;
Loop::mainCall([this]() { trash(this); });
}

void CallbackThread::run()
Expand Down

0 comments on commit 9b40059

Please sign in to comment.