From 5b379010d88ca80b21d4141e616aa28924e3aa7c Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Tue, 10 Apr 2018 15:04:58 +0200 Subject: [PATCH] [apps] Don't make the apps_container_storage a global variable --- apps/apps_container_storage.cpp | 5 +++++ apps/apps_container_storage.h | 1 + apps/main.cpp | 8 +++----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/apps_container_storage.cpp b/apps/apps_container_storage.cpp index 2ef60aafa..57b1d24d9 100644 --- a/apps/apps_container_storage.cpp +++ b/apps/apps_container_storage.cpp @@ -14,6 +14,11 @@ constexpr int k_numberOfCommonApps = 1+APPS_CONTAINER_SNAPSHOT_COUNT; // Take the Home app into account +AppsContainerStorage * AppsContainerStorage::sharedContainer() { + static AppsContainerStorage appsContainerStorage; + return &appsContainerStorage; +} + AppsContainerStorage::AppsContainerStorage() : AppsContainer() APPS_CONTAINER_SNAPSHOT_CONSTRUCTORS diff --git a/apps/apps_container_storage.h b/apps/apps_container_storage.h index 379c4ef95..c683b54bb 100644 --- a/apps/apps_container_storage.h +++ b/apps/apps_container_storage.h @@ -9,6 +9,7 @@ class AppsContainerStorage : public AppsContainer { public: + static AppsContainerStorage * sharedContainer(); AppsContainerStorage(); int numberOfApps() override; App::Snapshot * appSnapshotAtIndex(int index) override; diff --git a/apps/main.cpp b/apps/main.cpp index 63bece598..9c2adde8b 100644 --- a/apps/main.cpp +++ b/apps/main.cpp @@ -1,8 +1,6 @@ #include "apps_container_storage.h" #include "global_preferences.h" -AppsContainerStorage container; - void ion_main(int argc, char * argv[]) { #if EPSILON_GETOPT for (int i=1; inumberOfApps(); j++) { + App::Snapshot * snapshot = AppsContainerStorage::sharedContainer()->appSnapshotAtIndex(j); int cmp = strcmp(argv[i]+2, appNames[j]); if (cmp == '-') { snapshot->setOpt(argv[i]+2+strlen(appNames[j])+1, argv[i+1]); @@ -40,5 +38,5 @@ void ion_main(int argc, char * argv[]) { } } #endif - container.run(); + AppsContainerStorage::sharedContainer()->run(); }