fix potential crash at shutdown

This commit is contained in:
wimh 2011-12-28 01:03:27 +01:00
parent 867098d483
commit b8667b7b8b

View file

@ -223,8 +223,11 @@ namespace SparkleLib {
public void Dispose ()
{
this.remote_timer.Dispose ();
this.remote_timer = null;
this.local_timer.Dispose ();
this.local_timer = null;
this.listener.Dispose ();
this.listener = null;
}
@ -399,6 +402,7 @@ namespace SparkleLib {
SparkleHelpers.DebugInfo ("Event", "[" + Name + "] " + wct.ToString () + " '" + args.Name + "'");
SparkleHelpers.DebugInfo ("Event", "[" + Name + "] Changes found, checking if settled.");
if (this.remote_timer != null)
this.remote_timer.Stop ();
lock (this.change_lock) {
@ -448,6 +452,7 @@ namespace SparkleLib {
{
try {
DisableWatching ();
if (this.remote_timer != null)
this.remote_timer.Stop ();
SparkleHelpers.DebugInfo ("SyncUp", "[" + Name + "] Initiated");
@ -463,6 +468,7 @@ namespace SparkleLib {
if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.Idle);
if (this.listener != null)
this.listener.AnnounceBase (new SparkleAnnouncement(Identifier, CurrentRevision));
} else {
@ -477,6 +483,7 @@ namespace SparkleLib {
if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.Idle);
if (this.listener != null)
this.listener.AnnounceBase (new SparkleAnnouncement (Identifier, CurrentRevision));
} else {
@ -486,6 +493,7 @@ namespace SparkleLib {
}
} finally {
if (this.remote_timer != null)
this.remote_timer.Start ();
EnableWatching ();
}
@ -495,6 +503,7 @@ namespace SparkleLib {
private void SyncDownBase ()
{
SparkleHelpers.DebugInfo ("SyncDown", "[" + Name + "] Initiated");
if (this.remote_timer != null)
this.remote_timer.Stop ();
DisableWatching ();
@ -551,6 +560,7 @@ namespace SparkleLib {
if (SyncStatusChanged != null)
SyncStatusChanged (SyncStatus.Idle);
if (this.remote_timer != null)
this.remote_timer.Start ();
EnableWatching ();
}
@ -560,6 +570,7 @@ namespace SparkleLib {
{
lock (watch_lock) {
this.watcher.EnableRaisingEvents = false;
if (this.local_timer != null)
this.local_timer.Stop ();
}
}
@ -569,6 +580,7 @@ namespace SparkleLib {
{
lock (watch_lock) {
this.watcher.EnableRaisingEvents = true;
if (this.local_timer != null)
this.local_timer.Start ();
}
}