mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
reworked GarExtract disposal logic.
This commit is contained in:
@@ -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,21 +64,19 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (null != m_app.CurrentArchive)
|
else if (null != m_app.CurrentArchive)
|
||||||
{
|
{
|
||||||
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)
|
||||||
@@ -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;
|
||||||
@@ -367,16 +373,13 @@ namespace GARbro.GUI
|
|||||||
|
|
||||||
public void Dispose ()
|
public void Dispose ()
|
||||||
{
|
{
|
||||||
if (!m_extract_in_progress)
|
if (!disposed)
|
||||||
{
|
{
|
||||||
if (!disposed)
|
if (m_should_dispose)
|
||||||
{
|
m_arc.Dispose();
|
||||||
if (m_should_dispose)
|
disposed = true;
|
||||||
m_arc.Dispose();
|
|
||||||
disposed = true;
|
|
||||||
}
|
|
||||||
GC.SuppressFinalize (this);
|
|
||||||
}
|
}
|
||||||
|
GC.SuppressFinalize (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
~GarExtract ()
|
~GarExtract ()
|
||||||
|
|||||||
Reference in New Issue
Block a user