deconstructScreen() not inlined anymore
This commit is contained in:
@ -5,4 +5,13 @@ namespace espgui {
|
|||||||
std::unique_ptr<Display> currentDisplay;
|
std::unique_ptr<Display> currentDisplay;
|
||||||
std::function<void()> changeScreenCallback;
|
std::function<void()> changeScreenCallback;
|
||||||
|
|
||||||
|
void deconstructScreen()
|
||||||
|
{
|
||||||
|
if (currentDisplay)
|
||||||
|
{
|
||||||
|
currentDisplay->stop();
|
||||||
|
currentDisplay = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace espgui
|
} // namespace espgui
|
||||||
|
@ -12,23 +12,14 @@ namespace espgui {
|
|||||||
|
|
||||||
extern std::unique_ptr<Display> currentDisplay;
|
extern std::unique_ptr<Display> currentDisplay;
|
||||||
|
|
||||||
inline void deconstructScreen()
|
void deconstructScreen();
|
||||||
{
|
|
||||||
if (currentDisplay)
|
|
||||||
{
|
|
||||||
currentDisplay->stop();
|
|
||||||
//currentDisplay->~Display();
|
|
||||||
currentDisplay = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... Args>
|
template<typename T, typename... Args>
|
||||||
void switchScreenImpl(Args... args)
|
void switchScreenImpl(Args... args)
|
||||||
{
|
{
|
||||||
deconstructScreen();
|
deconstructScreen();
|
||||||
|
|
||||||
std::unique_ptr<T> ptr = std::make_unique<T>(args...);
|
currentDisplay = std::make_unique<T>(args...);
|
||||||
currentDisplay = std::move(ptr);
|
|
||||||
currentDisplay->start();
|
currentDisplay->start();
|
||||||
currentDisplay->initScreen();
|
currentDisplay->initScreen();
|
||||||
currentDisplay->update();
|
currentDisplay->update();
|
||||||
@ -40,8 +31,7 @@ void switchScreenRefImpl(Args&&... args)
|
|||||||
{
|
{
|
||||||
deconstructScreen();
|
deconstructScreen();
|
||||||
|
|
||||||
std::unique_ptr<T> ptr = std::make_unique<T>(std::forward<Args>(args)...);
|
currentDisplay = std::make_unique<T>(std::forward<Args>(args)...);
|
||||||
currentDisplay = std::move(ptr);
|
|
||||||
currentDisplay->start();
|
currentDisplay->start();
|
||||||
currentDisplay->initScreen();
|
currentDisplay->initScreen();
|
||||||
currentDisplay->update();
|
currentDisplay->update();
|
||||||
|
Reference in New Issue
Block a user