From dec4c3d0b833f8e16d7e4e929db723c45b41eefd Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Wed, 27 Feb 2019 18:17:06 -0600 Subject: [PATCH] Fixed serialize crash when using "Backups Only" and "New Backups Pending" filters in Linux --- GBM/Forms/frmGameManager.vb | 4 ++-- GBM/Managers/mgrCommon.vb | 22 ---------------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index 4a85254..b91fde1 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -342,7 +342,7 @@ Public Class frmGameManager oRestoreData = mgrRestore.CompareManifests 'Only show games with data to restore - Dim oTemporaryList As OrderedDictionary = mgrCommon.GenericClone(GameData) + Dim oTemporaryList As OrderedDictionary = mgrMonitorList.ReadFilteredList(oCurrentIncludeTagFilters, oCurrentExcludeTagFilters, oCurrentFilters, eCurrentFilter, bCurrentAndOperator, bCurrentSortAsc, sCurrentSortField) For Each de As DictionaryEntry In oTemporaryList oGame = DirectCast(de.Value, clsGame) If Not oRestoreData.ContainsKey(oGame.ID) Then @@ -353,7 +353,7 @@ Public Class frmGameManager Next ElseIf optBackupData.Checked Then 'Only show games with backup data - Dim oTemporaryList As OrderedDictionary = mgrCommon.GenericClone(GameData) + Dim oTemporaryList As OrderedDictionary = mgrMonitorList.ReadFilteredList(oCurrentIncludeTagFilters, oCurrentExcludeTagFilters, oCurrentFilters, eCurrentFilter, bCurrentAndOperator, bCurrentSortAsc, sCurrentSortField) oRestoreData = oRemoteBackupData.Clone For Each de As DictionaryEntry In oTemporaryList diff --git a/GBM/Managers/mgrCommon.vb b/GBM/Managers/mgrCommon.vb index d592c89..6e0baf2 100644 --- a/GBM/Managers/mgrCommon.vb +++ b/GBM/Managers/mgrCommon.vb @@ -43,28 +43,6 @@ Public Class mgrCommon End Get End Property - 'Source - https://stackoverflow.com/questions/18873152/deep-copy-of-ordereddictionary - Public Shared Function GenericClone(ByVal oOriginal As Object) As Object - 'Construct a temporary memory stream - Dim oStream As MemoryStream = New MemoryStream() - - 'Construct a serialization formatter that does all the hard work - Dim oFormatter As BinaryFormatter = New BinaryFormatter() - - 'This line Is explained in the "Streaming Contexts" section - oFormatter.Context = New StreamingContext(StreamingContextStates.Clone) - - 'Serialize the object graph into the memory stream - oFormatter.Serialize(oStream, oOriginal) - - 'Seek back to the start of the memory stream before deserializing - oStream.Position = 0 - - 'Deserialize the graph into a New set of objects - 'Return the root of the graph (deep copy) to the caller - Return oFormatter.Deserialize(oStream) - End Function - Public Shared Function SafeIconFromFile(ByVal sPath As String) As Image Dim oImage As Image Dim oReturnImage As Image