diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index ce8c5c500..b4c41e6b0 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -252,6 +252,17 @@ void AppsContainer::run() { } else { // Exception if (activeApp() != nullptr) { + /* The app models can reference layouts or expressions that have been + * destroyed from the pool. To avoid using them before packing the app + * (in App::willBecomeInactive for instance), we tidy them early on. */ + activeApp()->snapshot()->tidy(); + /* When an app encoutered an exception due to a full pool, the next time + * the user enters the app, the same exception could happen again which + * would prevent from reopening the app. To avoid being stuck outside the + * app causing the issue, we reset its snapshot when leaving it due to + * exception. For instance, the calculation app can encounter an + * exception when displaying too many huge layouts, if we don't clean the + * history here, we will be stuck outside the calculation app. */ activeApp()->snapshot()->reset(); } switchTo(appSnapshotAtIndex(0)); diff --git a/escher/include/escher/app.h b/escher/include/escher/app.h index b924f91c9..ed164c7f4 100644 --- a/escher/include/escher/app.h +++ b/escher/include/escher/app.h @@ -39,7 +39,6 @@ public: #if EPSILON_GETOPT virtual void setOpt(const char * name, char * value) {} #endif - private: /* tidy clean all dynamically-allocated data */ virtual void tidy(); };