mirror of
https://github.com/RaindropViewer/RaindropViewer.git
synced 2026-07-27 22:11:39 +00:00
refactor: prevent NRE
This commit is contained in:
committed by
alexiscatnip
parent
23224cefbe
commit
993a6b2f08
@@ -27,7 +27,7 @@ namespace Raindrop.Bootstrap
|
||||
InitialiseUIVariant();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
private void OnDisable()
|
||||
{
|
||||
if (ServiceLocator.Instance.IsRegistered<MapService>())
|
||||
{
|
||||
|
||||
@@ -69,11 +69,14 @@ namespace Raindrop.Services
|
||||
public void Dispose()
|
||||
{
|
||||
_loadingController?.Dispose();
|
||||
|
||||
netcom.ClientLoginStatus -= new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus);
|
||||
netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut);
|
||||
netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
|
||||
instance.Names.NameUpdated -= new EventHandler<UUIDNameReplyEventArgs>(Names_NameUpdated);
|
||||
|
||||
if (netcom != null)
|
||||
{
|
||||
netcom.ClientLoginStatus -= new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus);
|
||||
netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut);
|
||||
netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
|
||||
instance.Names.NameUpdated -= new EventHandler<UUIDNameReplyEventArgs>(Names_NameUpdated);
|
||||
}
|
||||
|
||||
UnregisterClientEvents(client);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Raindrop.UI.map.Map_SceneHierachy
|
||||
Client.Grid.GridRegion -= new EventHandler<GridRegionEventArgs>(Grid_GridRegion);
|
||||
Client.Grid.GridLayer -= new EventHandler<GridLayerEventArgs>(Grid_GridLayer);
|
||||
|
||||
if (Instance == null) return;
|
||||
if (Instance?.Netcom == null) return;
|
||||
Instance.Netcom.ClientConnected -= NetcomOnClientConnected;
|
||||
Instance.Netcom.ClientDisconnected -= NetcomOnClientDisconnected;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user