Don't create ViewWrappers with nullptr

Instead return a null shared ptr
This commit is contained in:
Sergio Martins
2022-04-04 22:36:16 +01:00
parent 55ab08129a
commit 1116eff816
2 changed files with 14 additions and 4 deletions

View File

@@ -226,12 +226,18 @@ bool ViewWrapper_qtwidgets::is(Type t) const
std::shared_ptr<ViewWrapper> ViewWrapper_qtwidgets::window() const
{
return std::shared_ptr<ViewWrapper>(new ViewWrapper_qtwidgets(m_widget->window()));
if (auto w = m_widget->window())
return std::shared_ptr<ViewWrapper>(new ViewWrapper_qtwidgets(w));
return {};
}
std::shared_ptr<ViewWrapper> ViewWrapper_qtwidgets::parentView() const
{
return std::shared_ptr<ViewWrapper>(new ViewWrapper_qtwidgets(m_widget->parentWidget()));
if (auto p = m_widget->parentWidget())
return std::shared_ptr<ViewWrapper>(new ViewWrapper_qtwidgets(p));
return {};
}
HANDLE ViewWrapper_qtwidgets::handle() const