Skip to content

Commit d205b88

Browse files
committed
Added missing Dispose calls
1 parent 1dcc38e commit d205b88

8 files changed

Lines changed: 21 additions & 13 deletions

File tree

Analyzer/SQLite/Handlers/AnimationClipHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace UnityDataTools.Analyzer.SQLite.Handlers;
99

10-
public class AnimationClipProcessor : ISQLiteHandler, IDisposable
10+
public class AnimationClipHandler : ISQLiteHandler
1111
{
1212
SQLiteCommand m_InsertCommand;
1313

Analyzer/SQLite/Handlers/AssetBundleHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace UnityDataTools.Analyzer.SQLite.Handlers;
99

10-
public class AssetBundleHandler : ISQLiteHandler, IDisposable
10+
public class AssetBundleHandler : ISQLiteHandler
1111
{
1212
SQLiteCommand m_InsertCommand;
1313

Analyzer/SQLite/Handlers/AudioClipHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace UnityDataTools.Analyzer.SQLite.Handlers;
99

10-
public class AudioClipHandler : ISQLiteHandler, IDisposable
10+
public class AudioClipHandler : ISQLiteHandler
1111
{
1212
SQLiteCommand m_InsertCommand;
1313

Analyzer/SQLite/Handlers/ISQLiteHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Data.SQLite;
34
using UnityDataTools.FileSystem.TypeTreeReaders;
45

56
namespace UnityDataTools.Analyzer.SQLite.Handlers;
67

7-
public interface ISQLiteHandler
8+
public interface ISQLiteHandler : IDisposable
89
{
910
void Init(SQLiteConnection db);
1011
void Process(ObjectIdProvider idProvider, long objectId, Dictionary<int, int> localToDbFileId, RandomAccessReader reader, out string name, out long streamDataSize);

Analyzer/SQLite/Handlers/MeshHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace UnityDataTools.Analyzer.SQLite.Handlers;
99

10-
public class MeshHandler : ISQLiteHandler, IDisposable
10+
public class MeshHandler : ISQLiteHandler
1111
{
1212
SQLiteCommand m_InsertCommand;
1313

Analyzer/SQLite/Handlers/ShaderHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace UnityDataTools.Analyzer.SQLite.Handlers;
88

9-
public class ShaderHandler : ISQLiteHandler, IDisposable
9+
public class ShaderHandler : ISQLiteHandler
1010
{
1111
SQLiteCommand m_InsertCommand;
1212
SQLiteCommand m_InsertSubProgramCommand;
@@ -158,6 +158,7 @@ void IDisposable.Dispose()
158158
{
159159
m_InsertCommand.Dispose();
160160
m_InsertSubProgramCommand.Dispose();
161+
m_InsertKeywordCommand.Dispose();
161162
m_InsertSubProgramKeywordsCommand.Dispose();
162163
}
163164
}

Analyzer/SQLite/Handlers/Texture2DHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace UnityDataTools.Analyzer.SQLite.Handlers;
99

10-
public class Texture2DHandler : ISQLiteHandler, IDisposable
10+
public class Texture2DHandler : ISQLiteHandler
1111
{
1212
SQLiteCommand m_InsertCommand;
1313

Analyzer/SQLite/SQLiteWriter.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public class SQLiteWriter : IWriter
2222
private IdProvider<string> m_SerializedFileIdProvider = new ();
2323
private ObjectIdProvider m_ObjectIdProvider = new ();
2424

25-
private Dictionary<string, ISQLiteHandler> m_Processors = new ()
25+
private Dictionary<string, ISQLiteHandler> m_Handlers = new ()
2626
{
2727
{ "Mesh", new MeshHandler() },
2828
{ "Texture2D", new Texture2DHandler() },
2929
{ "Shader", new ShaderHandler() },
3030
{ "AudioClip", new AudioClipHandler() },
31-
{ "AnimationClip", new AnimationClipProcessor() },
31+
{ "AnimationClip", new AnimationClipHandler() },
3232
{ "AssetBundle", new AssetBundleHandler() },
3333
};
3434

@@ -61,7 +61,7 @@ public void Begin()
6161
command.CommandText = Properties.Resources.Init;
6262
command.ExecuteNonQuery();
6363

64-
foreach (var processor in m_Processors.Values)
64+
foreach (var processor in m_Handlers.Values)
6565
{
6666
processor.Init(m_Database);
6767
}
@@ -76,7 +76,7 @@ public void End()
7676
throw new InvalidOperationException("SQLiteWriter.End called before SQLiteWriter.Begin");
7777
}
7878

79-
foreach (var processor in m_Processors.Values)
79+
foreach (var processor in m_Handlers.Values)
8080
{
8181
processor.Finalize(m_Database);
8282
}
@@ -201,7 +201,7 @@ public void WriteSerializedFile(string filename, string fullPath)
201201
string name = null;
202202
long streamDataSize = 0;
203203

204-
if (m_Processors.TryGetValue(root.Type, out var processor))
204+
if (m_Handlers.TryGetValue(root.Type, out var processor))
205205
{
206206
processor.Process(m_ObjectIdProvider, currentObjectId, localToDbFileId, randomAccessReader, out name, out streamDataSize);
207207
}
@@ -248,11 +248,17 @@ public void AddReference(long objectId, long referencedObjectId, string property
248248

249249
public void Dispose()
250250
{
251+
foreach (var handler in m_Handlers.Values)
252+
{
253+
handler.Dispose();
254+
}
255+
251256
m_AddAssetBundleCommand.Dispose();
252257
m_AddSerializedFileCommand.Dispose();
253258
m_AddReferenceCommand.Dispose();
254259
m_AddObjectCommand.Dispose();
255260
m_AddTypeCommand.Dispose();
261+
256262
m_Database.Dispose();
257263
}
258264
}

0 commit comments

Comments
 (0)