Skip to content

Commit

Permalink
libcore|App|Loop: Improvements
Browse files Browse the repository at this point in the history
Version number parsing is more tolerant.

LoopCallbacks calls are made after the LoopCallback lock has been
released, so that the callbacks don't get stuck.
  • Loading branch information
skyjake committed Jan 24, 2016
1 parent debc02a commit 52be20e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
2 changes: 2 additions & 0 deletions doomsday/sdk/libcore/include/de/core/app.h
Expand Up @@ -177,6 +177,8 @@ class DENG2_PUBLIC App : DENG2_OBSERVES(Clock, TimeChange)
*/
void removeSystem(System &system);

void notifyStartupComplete();

/**
* Determines if an instance of App currently exists.
*/
Expand Down
10 changes: 9 additions & 1 deletion doomsday/sdk/libcore/src/core/app.cpp
Expand Up @@ -674,7 +674,7 @@ void App::initSubsystems(SubsystemInitFlags flags)
#endif
}

LOG_VERBOSE("libcore::App %s subsystems initialized.") << Version().asText();
LOG_VERBOSE("libcore::App %s subsystems initialized") << Version().asText();
}

void App::addSystem(System &system)
Expand All @@ -688,6 +688,14 @@ void App::removeSystem(System &system)
d->systems.removeAll(&system);
}

void App::notifyStartupComplete()
{
DENG2_FOR_AUDIENCE2(StartupComplete, i)
{
i->appStartupCompleted();
}
}

bool App::appExists()
{
return singletonApp != 0;
Expand Down
15 changes: 10 additions & 5 deletions doomsday/sdk/libcore/src/core/loop.cpp
Expand Up @@ -142,13 +142,18 @@ void LoopCallback::enqueue(Callback func)

void LoopCallback::loopIteration()
{
DENG2_GUARD(this);
QList<Callback> funcs;

Loop::get().audienceForIteration() -= this;
// Lock while modifying but not during the callbacks themselves.
{
DENG2_GUARD(this);
Loop::get().audienceForIteration() -= this;

// Make a copy of the list if new callbacks get enqueued in the callback.
funcs = _funcs;
_funcs.clear();
}

// Make a copy of the list if new callbacks get enqueued in the callback.
QList<Callback> const funcs = _funcs;
_funcs.clear();
for(Callback const &cb : funcs)
{
cb();
Expand Down
6 changes: 3 additions & 3 deletions doomsday/sdk/libcore/src/version.cpp
Expand Up @@ -74,9 +74,9 @@ void Version::parseVersionString(String const &version)
int dashPos = version.indexOf('-');

QStringList parts = version.left(dashPos).split('.');
if(parts.size() >= 1) major = parts[0].toInt();
if(parts.size() >= 2) minor = parts[1].toInt();
if(parts.size() >= 3) patch = parts[2].toInt();
if(parts.size() >= 1) major = String(parts[0]).toInt();
if(parts.size() >= 2) minor = String(parts[1]).toInt();
if(parts.size() >= 3) patch = String(parts[2]).toInt();

if(dashPos >= 0 && dashPos < version.size() - 1)
{
Expand Down

0 comments on commit 52be20e

Please sign in to comment.