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);
|
SetStatusText (guiStrings.MsgChooseFiles);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
GarExtract extractor = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!ViewModel.IsArchive)
|
if (!ViewModel.IsArchive)
|
||||||
@ -63,7 +64,7 @@ namespace GARbro.GUI
|
|||||||
// extract into directory named after archive
|
// extract into directory named after archive
|
||||||
if (!string.IsNullOrEmpty (Path.GetExtension (entry.Name)))
|
if (!string.IsNullOrEmpty (Path.GetExtension (entry.Name)))
|
||||||
destination = Path.GetFileNameWithoutExtension (source);
|
destination = Path.GetFileNameWithoutExtension (source);
|
||||||
using (var extractor = new GarExtract (this, source))
|
extractor = new GarExtract (this, source);
|
||||||
extractor.ExtractAll (destination);
|
extractor.ExtractAll (destination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,15 +72,13 @@ namespace GARbro.GUI
|
|||||||
{
|
{
|
||||||
var vm = ViewModel as ArchiveViewModel;
|
var vm = ViewModel as ArchiveViewModel;
|
||||||
string destination = Path.GetDirectoryName (vm.Path);
|
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
|
if (null == entry || (entry.Name == ".." && vm.SubDir == "")) // root entry
|
||||||
extractor.ExtractAll (destination);
|
extractor.ExtractAll (destination);
|
||||||
else
|
else
|
||||||
extractor.Extract (entry, destination);
|
extractor.Extract (entry, destination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (OperationCanceledException X)
|
catch (OperationCanceledException X)
|
||||||
{
|
{
|
||||||
SetStatusText (X.Message);
|
SetStatusText (X.Message);
|
||||||
@ -88,6 +87,11 @@ namespace GARbro.GUI
|
|||||||
{
|
{
|
||||||
PopupError (X.Message, guiStrings.MsgErrorExtracting);
|
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 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)
|
public GarExtract (MainWindow parent, string source)
|
||||||
{
|
{
|
||||||
m_main = parent;
|
m_main = parent;
|
||||||
@ -366,8 +372,6 @@ namespace GARbro.GUI
|
|||||||
bool disposed = false;
|
bool disposed = false;
|
||||||
|
|
||||||
public void Dispose ()
|
public void Dispose ()
|
||||||
{
|
|
||||||
if (!m_extract_in_progress)
|
|
||||||
{
|
{
|
||||||
if (!disposed)
|
if (!disposed)
|
||||||
{
|
{
|
||||||
@ -377,7 +381,6 @@ namespace GARbro.GUI
|
|||||||
}
|
}
|
||||||
GC.SuppressFinalize (this);
|
GC.SuppressFinalize (this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
~GarExtract ()
|
~GarExtract ()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user