deconstructScreen() not inlined anymore

This commit is contained in:
2021-12-30 03:43:04 +01:00
parent 8914f2cc3b
commit 8c450b8116
2 changed files with 12 additions and 13 deletions

View File

@ -5,4 +5,13 @@ namespace espgui {
std::unique_ptr<Display> currentDisplay;
std::function<void()> changeScreenCallback;
void deconstructScreen()
{
if (currentDisplay)
{
currentDisplay->stop();
currentDisplay = nullptr;
}
}
} // namespace espgui

View File

@ -12,23 +12,14 @@ namespace espgui {
extern std::unique_ptr<Display> currentDisplay;
inline void deconstructScreen()
{
if (currentDisplay)
{
currentDisplay->stop();
//currentDisplay->~Display();
currentDisplay = nullptr;
}
}
void deconstructScreen();
template<typename T, typename... Args>
void switchScreenImpl(Args... args)
{
deconstructScreen();
std::unique_ptr<T> ptr = std::make_unique<T>(args...);
currentDisplay = std::move(ptr);
currentDisplay = std::make_unique<T>(args...);
currentDisplay->start();
currentDisplay->initScreen();
currentDisplay->update();
@ -40,8 +31,7 @@ void switchScreenRefImpl(Args&&... args)
{
deconstructScreen();
std::unique_ptr<T> ptr = std::make_unique<T>(std::forward<Args>(args)...);
currentDisplay = std::move(ptr);
currentDisplay = std::make_unique<T>(std::forward<Args>(args)...);
currentDisplay->start();
currentDisplay->initScreen();
currentDisplay->update();