From e3c289e26c49a15f4c38d4e765cf98f1acf15f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Thu, 9 Feb 2017 10:14:36 +0200 Subject: [PATCH] Fixed|libcore: Potential crash when shutting down a text-based app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The public instance shouldn’t observe the private one. --- doomsday/sdk/libcore/include/de/core/textapp.h | 4 +--- doomsday/sdk/libcore/src/core/textapp.cpp | 17 +++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/doomsday/sdk/libcore/include/de/core/textapp.h b/doomsday/sdk/libcore/include/de/core/textapp.h index 5faa6eee6a..774dfbd307 100644 --- a/doomsday/sdk/libcore/include/de/core/textapp.h +++ b/doomsday/sdk/libcore/include/de/core/textapp.h @@ -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 @@ -58,7 +57,6 @@ class DENG2_PUBLIC TextApp : public QCoreApplication, public App, protected: NativePath appDataPath() const; - void loopIteration(); private: DENG2_PRIVATE(d) diff --git a/doomsday/sdk/libcore/src/core/textapp.cpp b/doomsday/sdk/libcore/src/core/textapp.cpp index a45df20ba4..8dca137d94 100644 --- a/doomsday/sdk/libcore/src/core/textapp.cpp +++ b/doomsday/sdk/libcore/src/core/textapp.cpp @@ -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) @@ -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