From 20de90d27285ea842b5815fffb94db5f6299f0c9 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Tue, 28 Nov 2023 04:42:20 -0500 Subject: [PATCH] Minor fix to prevent crash when Loaded fires twice (#2180) There are many reasons Loaded can fire twice. Usually, it will happen when the native SvgView component is moved, but it can also happen if an ancestor of SvgView is reparented. There is a crash that appears to occur when we attempt to call CreateResources twice. This resolves that crash. --- windows/RNSVG/SvgView.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/windows/RNSVG/SvgView.cpp b/windows/RNSVG/SvgView.cpp index 90445486..acd35e51 100644 --- a/windows/RNSVG/SvgView.cpp +++ b/windows/RNSVG/SvgView.cpp @@ -202,8 +202,10 @@ void SvgView::CreateResources() { void SvgView::Panel_Loaded(IInspectable const &sender, xaml::RoutedEventArgs const & /*args*/) { if (auto const &svgView{sender.try_as()}) { - m_loaded = true; - svgView.CreateResources(); + if (!m_loaded) { + m_loaded = true; + svgView.CreateResources(); + } } }