Skip to content

Commit

Permalink
Fix bad parent initialization bug
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Feb 14, 2025
1 parent 328c283 commit 9eaae85
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion libopensimcreator/UI/MeshWarper/MeshWarpingTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class osc::MeshWarpingTab::Impl final : public TabPrivate {

explicit Impl(MeshWarpingTab& owner, Widget* parent_) :
TabPrivate{owner, parent_, OSC_ICON_BEZIER_CURVE " Mesh Warping"},
m_Shared{std::make_shared<MeshWarpingTabSharedState>(id(), owner, App::singleton<SceneCache>(App::resource_loader()))}
m_Shared{std::make_shared<MeshWarpingTabSharedState>(id(), &owner, App::singleton<SceneCache>(App::resource_loader()))}
{
m_PanelManager->register_toggleable_panel(
"Source Mesh",
Expand Down
14 changes: 8 additions & 6 deletions libopensimcreator/UI/MeshWarper/MeshWarpingTabSharedState.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <liboscar/Maths/PolarPerspectiveCamera.h>
#include <liboscar/Maths/Vec2.h>
#include <liboscar/Maths/Vec3.h>
#include <liboscar/Platform/App.h>
#include <liboscar/Platform/Widget.h>
#include <liboscar/UI/Events/CloseTabEvent.h>
#include <liboscar/UI/Popups/PopupManager.h>
Expand All @@ -37,13 +38,13 @@ namespace osc
// top-level UI state that is shared by all UI panels
class MeshWarpingTabSharedState final {
public:
MeshWarpingTabSharedState(
explicit MeshWarpingTabSharedState(
UID tabID_,
Widget& parent_,
Widget* parent_,
std::shared_ptr<SceneCache> sceneCache_) :

m_TabID{tabID_},
m_Parent{parent_.weak_ref()},
m_Parent{parent_},
m_SceneCache{std::move(sceneCache_)}
{
OSC_ASSERT(m_SceneCache != nullptr);
Expand Down Expand Up @@ -183,8 +184,9 @@ namespace osc

void closeTab()
{
CloseTabEvent e{m_TabID};
m_Parent->on_event(e);
if (m_Parent) {
App::post_event(*m_Parent, std::make_unique<CloseTabEvent>(m_TabID));
}
}

bool canUndo() const
Expand Down Expand Up @@ -260,7 +262,7 @@ namespace osc
UID m_TabID;

// handle to the screen that owns the TPS3D tab
LifetimedPtr<Widget> m_Parent;
Widget* m_Parent;

// cached TPS3D algorithm result (to prevent recomputing it over and over)
TPSResultCache m_WarpingCache;
Expand Down

0 comments on commit 9eaae85

Please sign in to comment.