From e9d098bacbff7182ba503bac2fae357fd864f894 Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Tue, 16 Jul 2019 18:02:59 +0200 Subject: [PATCH] [apps] Remove AppsContainerStorage::sharedContainer Use AppsContainer::sharedAppsContainer instead. The AppsContainerStorage is initialised in AppsContainer. --- apps/Makefile | 2 +- apps/apps_container.cpp | 6 ++++++ apps/apps_container.h | 4 +--- apps/apps_container_storage.cpp | 5 ----- apps/apps_container_storage.h | 1 - apps/main.cpp | 8 ++++---- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/apps/Makefile b/apps/Makefile index 34eeb7463..beb157545 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -38,7 +38,7 @@ snapshots_count = $(words $(apps)) snapshot_includes = $(foreach i,$(app_headers),-include $(i) ) epsilon_app_names = '$(foreach i,${EPSILON_APPS},"$(i)", )' -$(call object_for,apps/apps_container_storage.cpp apps/main.cpp): CXXFLAGS += $(snapshot_includes) -DAPPS_CONTAINER_APPS_DECLARATION="$(apps_declaration)" -DAPPS_CONTAINER_SNAPSHOT_DECLARATIONS="$(snapshots_declaration)" -DAPPS_CONTAINER_SNAPSHOT_CONSTRUCTORS="$(snapshots_construction)" -DAPPS_CONTAINER_SNAPSHOT_LIST="$(snapshots_list)" -DAPPS_CONTAINER_SNAPSHOT_COUNT=$(snapshots_count) -DEPSILON_APPS_NAMES=$(epsilon_app_names) +$(call object_for,apps/apps_container_storage.cpp apps/apps_container.cpp): CXXFLAGS += $(snapshot_includes) -DAPPS_CONTAINER_APPS_DECLARATION="$(apps_declaration)" -DAPPS_CONTAINER_SNAPSHOT_DECLARATIONS="$(snapshots_declaration)" -DAPPS_CONTAINER_SNAPSHOT_CONSTRUCTORS="$(snapshots_construction)" -DAPPS_CONTAINER_SNAPSHOT_LIST="$(snapshots_list)" -DAPPS_CONTAINER_SNAPSHOT_COUNT=$(snapshots_count) -DEPSILON_APPS_NAMES=$(epsilon_app_names) # I18n file generation diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index 76ca26097..5682399f7 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -1,4 +1,5 @@ #include "apps_container.h" +#include "apps_container_storage.h" #include "global_preferences.h" #include #include @@ -52,6 +53,11 @@ static KDColor sPromptColors[] = { #endif +AppsContainer * AppsContainer::sharedAppsContainer() { + static AppsContainerStorage appsContainerStorage; + return &appsContainerStorage; +} + AppsContainer::AppsContainer() : Container(), m_window(), diff --git a/apps/apps_container.h b/apps/apps_container.h index c8236271b..dca1a48bb 100644 --- a/apps/apps_container.h +++ b/apps/apps_container.h @@ -24,9 +24,7 @@ class AppsContainer : public Container, ExamPopUpControllerDelegate, Ion::StorageDelegate { public: - static AppsContainer * sharedAppsContainer() { - return static_cast(Container::sharedContainer()); - } + static AppsContainer * sharedAppsContainer(); AppsContainer(); static bool poincareCircuitBreaker(); virtual int numberOfApps() = 0; diff --git a/apps/apps_container_storage.cpp b/apps/apps_container_storage.cpp index 57b1d24d9..2ef60aafa 100644 --- a/apps/apps_container_storage.cpp +++ b/apps/apps_container_storage.cpp @@ -14,11 +14,6 @@ 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 e726b1161..9abd3c27a 100644 --- a/apps/apps_container_storage.h +++ b/apps/apps_container_storage.h @@ -9,7 +9,6 @@ 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 fb2c90dc1..8fb2dc470 100644 --- a/apps/main.cpp +++ b/apps/main.cpp @@ -1,4 +1,4 @@ -#include "apps_container_storage.h" +#include "apps_container.h" #include "global_preferences.h" #include @@ -32,8 +32,8 @@ void ion_main(int argc, char * argv[]) { * $ ./epsilon.elf --code-script hello_world.py:print("hello") --code-lock-on-console */ const char * appNames[] = {"home", EPSILON_APPS_NAMES}; - for (int j = 0; j < AppsContainerStorage::sharedContainer()->numberOfApps(); j++) { - App::Snapshot * snapshot = AppsContainerStorage::sharedContainer()->appSnapshotAtIndex(j); + for (int j = 0; j < AppsContainer::sharedAppsContainer()->numberOfApps(); j++) { + App::Snapshot * snapshot = AppsContainer::sharedAppsContainer()->appSnapshotAtIndex(j); int cmp = strcmp(argv[i]+2, appNames[j]); if (cmp == '-') { snapshot->setOpt(argv[i]+2+strlen(appNames[j])+1, argv[i+1]); @@ -42,5 +42,5 @@ void ion_main(int argc, char * argv[]) { } } #endif - AppsContainerStorage::sharedContainer()->run(); + AppsContainer::sharedAppsContainer()->run(); }