Skip to content

Commit 205f092

Browse files
committed
try to avoid the duplicated dispoase call of the buffer data
1 parent 91b2020 commit 205f092

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Data/BinaryData/HDSPack/FileSystem/StreamBuffer.vb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ Namespace FileSystem
222222
Return intptr
223223
End Function
224224

225+
Dim disposedFlag As Boolean = False
226+
225227
''' <summary>
226228
''' write the in-memory content data into
227229
''' the base file stream, and then update
@@ -251,9 +253,17 @@ Namespace FileSystem
251253
''' </summary>
252254
''' <param name="disposing"></param>
253255
Protected Overrides Sub Dispose(disposing As Boolean)
254-
writeBuffer()
255-
buffer.Dispose()
256-
MyBase.Dispose(disposing)
256+
If Not disposedFlag Then
257+
' avoid unexpected multiple action calls
258+
disposedFlag = True
259+
260+
' flush current data to file stream
261+
Call writeBuffer()
262+
' release the memory buffer
263+
Call buffer.Dispose()
264+
' release base data
265+
Call MyBase.Dispose(disposing)
266+
End If
257267
End Sub
258268
End Class
259269
End Namespace

0 commit comments

Comments
 (0)