Add a m_thisWeakPtr member to Views

Allows to promote back to shared pointer
This commit is contained in:
Sergio Martins
2022-07-02 20:12:33 +01:00
parent ba71ad7407
commit 7d21516f6d
14 changed files with 83 additions and 59 deletions

View File

@@ -12,6 +12,7 @@
#include "ViewWrapper_qtquick.h"
#include "qtquick/views/RubberBand_qtquick.h"
#include "qtquick/views/View_qtquick.h"
#include "private/View_p.h"
#include "qtquick/views/DockWidget_qtquick.h"
#include "qtquick/views/FloatingWindow_qtquick.h"
@@ -459,3 +460,22 @@ SizePolicy ViewWrapper_qtquick::horizontalSizePolicy() const
}
return {};
}
/*static*/
std::shared_ptr<View> ViewWrapper_qtquick::create(QObject *item)
{
return create(qobject_cast<QQuickItem *>(item));
}
/*static*/
std::shared_ptr<View> ViewWrapper_qtquick::create(QQuickItem *item)
{
if (!item)
return {};
auto wrapper = new ViewWrapper_qtquick(item);
auto sharedptr = std::shared_ptr<View>(wrapper);
wrapper->d->m_thisWeakPtr = sharedptr;
return sharedptr;
}