mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 21:55:34 +08:00
reworked GarExtract disposal logic.
This commit is contained in:
parent
98041015c1
commit
792b299037
@ -51,6 +51,7 @@ namespace GARbro.GUI
|
||||
SetStatusText (guiStrings.MsgChooseFiles);
|
||||
return;
|
||||
}
|
||||
GarExtract extractor = null;
|
||||
try
|
||||
{
|
||||
if (!ViewModel.IsArchive)
|
||||
@ -63,21 +64,19 @@ namespace GARbro.GUI
|
||||
// extract into directory named after archive
|
||||
if (!string.IsNullOrEmpty (Path.GetExtension (entry.Name)))
|
||||
destination = Path.GetFileNameWithoutExtension (source);
|
||||
using (var extractor = new GarExtract (this, source))
|
||||
extractor.ExtractAll (destination);
|
||||
extractor = new GarExtract (this, source);
|
||||
extractor.ExtractAll (destination);
|
||||
}
|
||||
}
|
||||
else if (null != m_app.CurrentArchive)
|
||||
{
|
||||
var vm = ViewModel as ArchiveViewModel;
|
||||
string destination = Path.GetDirectoryName (vm.Path);
|
||||
using (var extractor = new GarExtract (this, vm.Path, m_app.CurrentArchive))
|
||||
{
|
||||
if (null == entry || (entry.Name == ".." && vm.SubDir == "")) // root entry
|
||||
extractor.ExtractAll (destination);
|
||||
else
|
||||
extractor.Extract (entry, destination);
|
||||
}
|
||||
extractor = new GarExtract (this, vm.Path, m_app.CurrentArchive);
|
||||
if (null == entry || (entry.Name == ".." && vm.SubDir == "")) // root entry
|
||||
extractor.ExtractAll (destination);
|
||||
else
|
||||
extractor.Extract (entry, destination);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException X)
|
||||
@ -88,6 +87,11 @@ namespace GARbro.GUI
|
||||
{
|
||||
PopupError (X.Message, guiStrings.MsgErrorExtracting);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (null != extractor && !extractor.IsActive)
|
||||
extractor.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,6 +114,8 @@ namespace GARbro.GUI
|
||||
|
||||
public static readonly HashSet<string> CommonAudioFormats = new HashSet<string> { "wav", "mp3", "ogg" };
|
||||
|
||||
public bool IsActive { get { return m_extract_in_progress; } }
|
||||
|
||||
public GarExtract (MainWindow parent, string source)
|
||||
{
|
||||
m_main = parent;
|
||||
@ -367,16 +373,13 @@ namespace GARbro.GUI
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
if (!m_extract_in_progress)
|
||||
if (!disposed)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
if (m_should_dispose)
|
||||
m_arc.Dispose();
|
||||
disposed = true;
|
||||
}
|
||||
GC.SuppressFinalize (this);
|
||||
if (m_should_dispose)
|
||||
m_arc.Dispose();
|
||||
disposed = true;
|
||||
}
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
~GarExtract ()
|
||||
|
Loading…
Reference in New Issue
Block a user