From 8c450b8116d2aa1c982843a0b6144f626b721301 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Thu, 30 Dec 2021 03:43:04 +0100 Subject: [PATCH] deconstructScreen() not inlined anymore --- src/screenmanager.cpp | 9 +++++++++ src/screenmanager.h | 16 +++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/screenmanager.cpp b/src/screenmanager.cpp index 619fd22..f609ce9 100644 --- a/src/screenmanager.cpp +++ b/src/screenmanager.cpp @@ -5,4 +5,13 @@ namespace espgui { std::unique_ptr currentDisplay; std::function changeScreenCallback; +void deconstructScreen() +{ + if (currentDisplay) + { + currentDisplay->stop(); + currentDisplay = nullptr; + } +} + } // namespace espgui diff --git a/src/screenmanager.h b/src/screenmanager.h index 2424490..944e149 100644 --- a/src/screenmanager.h +++ b/src/screenmanager.h @@ -12,23 +12,14 @@ namespace espgui { extern std::unique_ptr currentDisplay; -inline void deconstructScreen() -{ - if (currentDisplay) - { - currentDisplay->stop(); - //currentDisplay->~Display(); - currentDisplay = nullptr; - } -} +void deconstructScreen(); template void switchScreenImpl(Args... args) { deconstructScreen(); - std::unique_ptr ptr = std::make_unique(args...); - currentDisplay = std::move(ptr); + currentDisplay = std::make_unique(args...); currentDisplay->start(); currentDisplay->initScreen(); currentDisplay->update(); @@ -40,8 +31,7 @@ void switchScreenRefImpl(Args&&... args) { deconstructScreen(); - std::unique_ptr ptr = std::make_unique(std::forward(args)...); - currentDisplay = std::move(ptr); + currentDisplay = std::make_unique(std::forward(args)...); currentDisplay->start(); currentDisplay->initScreen(); currentDisplay->update();