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.
This commit is contained in:
Eric Rozell
2023-11-28 10:42:20 +01:00
committed by GitHub
parent fc1c9a0347
commit 20de90d272
+4 -2
View File
@@ -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<RNSVG::SvgView>()}) {
m_loaded = true;
svgView.CreateResources();
if (!m_loaded) {
m_loaded = true;
svgView.CreateResources();
}
}
}