[Silabs]Make changes to the window manager class so its static constructor do… (#33473)

* Make changes to the window manager class so its static constructor do not call a dynamic allocation before code entry. Limitation with sl memory manager

* Restyled by clang-format

* implement a destructor for the Timer object to delete the allocated timer

---------

Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/examples/window-app/silabs/include/WindowManager.h b/examples/window-app/silabs/include/WindowManager.h
index 8ae75e8..7578396 100644
--- a/examples/window-app/silabs/include/WindowManager.h
+++ b/examples/window-app/silabs/include/WindowManager.h
@@ -40,6 +40,7 @@
         typedef void (*Callback)(Timer & timer);
 
         Timer(uint32_t timeoutInMs, Callback callback, void * context);
+        ~Timer();
 
         void Start();
         void Stop();
@@ -155,7 +156,7 @@
 
     LEDWidget mActionLED;
 #ifdef DISPLAY_ENABLED
-    Timer mIconTimer;
-    LcdIcon mIcon = LcdIcon::None;
+    Timer * mIconTimer = nullptr;
+    LcdIcon mIcon      = LcdIcon::None;
 #endif
 };
diff --git a/examples/window-app/silabs/src/WindowManager.cpp b/examples/window-app/silabs/src/WindowManager.cpp
index 0b8639d..8ae78b3 100644
--- a/examples/window-app/silabs/src/WindowManager.cpp
+++ b/examples/window-app/silabs/src/WindowManager.cpp
@@ -514,6 +514,15 @@
     }
 }
 
+WindowManager::Timer::~Timer()
+{
+    if (mHandler)
+    {
+        osTimerDelete(mHandler);
+        mHandler = nullptr;
+    }
+}
+
 void WindowManager::Timer::Stop()
 {
     mIsActive = false;
@@ -538,11 +547,7 @@
     return WindowManager::sWindow;
 }
 
-#ifdef DISPLAY_ENABLED
-WindowManager::WindowManager() : mIconTimer(LCD_ICON_TIMEOUT, OnIconTimeout, this) {}
-#else
 WindowManager::WindowManager() {}
-#endif
 
 void WindowManager::OnIconTimeout(WindowManager::Timer & timer)
 {
@@ -556,6 +561,9 @@
 {
     chip::DeviceLayer::PlatformMgr().LockChipStack();
 
+#ifdef DISPLAY_ENABLED
+    mIconTimer = new Timer(LCD_ICON_TIMEOUT, OnIconTimeout, this);
+#endif
     // Timers
     mLongPressTimer = new Timer(LONG_PRESS_TIMEOUT, OnLongPressTimeout, this);
 
@@ -768,13 +776,19 @@
         window->UpdateLCD();
         break;
     case AppEvent::kEventType_CoverChange:
-        window->mIconTimer.Start();
+        if (window->mIconTimer != nullptr)
+        {
+            window->mIconTimer->Start();
+        }
         window->mIcon = (window->GetCover().mEndpoint == 1) ? LcdIcon::One : LcdIcon::Two;
         window->UpdateLCD();
         break;
     case AppEvent::kEventType_TiltModeChange:
         ChipLogDetail(AppServer, "App control mode changed to %s", window->mTiltMode ? "Tilt" : "Lift");
-        window->mIconTimer.Start();
+        if (window->mIconTimer != nullptr)
+        {
+            window->mIconTimer->Start();
+        }
         window->mIcon = window->mTiltMode ? LcdIcon::Tilt : LcdIcon::Lift;
         window->UpdateLCD();
         break;