Skip to content

Commit

Permalink
Fixed|libcore: Potential crash when shutting down a text-based app
Browse files Browse the repository at this point in the history
The public instance shouldn’t observe the private one.
  • Loading branch information
skyjake committed Feb 9, 2017
1 parent f7c7da1 commit e3c289e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 1 addition & 3 deletions doomsday/sdk/libcore/include/de/core/textapp.h
Expand Up @@ -38,8 +38,7 @@ namespace de {
*
* @ingroup core
*/
class DENG2_PUBLIC TextApp : public QCoreApplication, public App,
DENG2_OBSERVES(Loop, Iteration)
class DENG2_PUBLIC TextApp : public QCoreApplication, public App
{
Q_OBJECT

Expand All @@ -58,7 +57,6 @@ class DENG2_PUBLIC TextApp : public QCoreApplication, public App,

protected:
NativePath appDataPath() const;
void loopIteration();

private:
DENG2_PRIVATE(d)
Expand Down
17 changes: 9 additions & 8 deletions doomsday/sdk/libcore/src/core/textapp.cpp
Expand Up @@ -25,16 +25,24 @@
namespace de {

DENG2_PIMPL(TextApp)
, DENG2_OBSERVES(Loop, Iteration)
{
Loop loop;

Impl(Public *i) : Base(i)
{
loop.audienceForIteration() += self();
loop.audienceForIteration() += this;

// In text-based apps, we can limit the loop frequency.
loop.setRate(35);
}

void loopIteration() override
{
// Update the clock time. App listens to this clock and will inform
// subsystems in the order they've been added in.
Clock::get().setTime(Time());
}
};

TextApp::TextApp(int &argc, char **argv)
Expand Down Expand Up @@ -99,12 +107,5 @@ NativePath TextApp::appDataPath() const
return NativePath(QDir::homePath()) / unixHomeFolderName();
}

void TextApp::loopIteration()
{
// Update the clock time. App listens to this clock and will inform
// subsystems in the order they've been added in.
Clock::get().setTime(Time());
}

} // namespace de

0 comments on commit e3c289e

Please sign in to comment.