mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 15:44:00 +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,7 +64,7 @@ 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 = new GarExtract (this, source);
|
||||
extractor.ExtractAll (destination);
|
||||
}
|
||||
}
|
||||
@ -71,15 +72,13 @@ namespace GARbro.GUI
|
||||
{
|
||||
var vm = ViewModel as ArchiveViewModel;
|
||||
string destination = Path.GetDirectoryName (vm.Path);
|
||||
using (var extractor = new GarExtract (this, vm.Path, m_app.CurrentArchive))
|
||||
{
|
||||
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)
|
||||
{
|
||||
SetStatusText (X.Message);
|
||||
@ -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;
|
||||
@ -366,8 +372,6 @@ namespace GARbro.GUI
|
||||
bool disposed = false;
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
if (!m_extract_in_progress)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
@ -377,7 +381,6 @@ namespace GARbro.GUI
|
||||
}
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
}
|
||||
|
||||
~GarExtract ()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user