mac: fix occasional crash when updating the menu whilst it's open
This commit is contained in:
parent
495ec98663
commit
3450354f12
|
@ -603,7 +603,7 @@ namespace SparkleLib.Git {
|
||||||
|
|
||||||
SparkleLogger.LogInfo ("Git", Name + " | Restoring \"" + path + "\" (revision " + revision + ")");
|
SparkleLogger.LogInfo ("Git", Name + " | Restoring \"" + path + "\" (revision " + revision + ")");
|
||||||
|
|
||||||
// FIXME: git-show doesn't decrypt objects, so we can't use it to retrieve
|
// git-show doesn't decrypt objects, so we can't use it to retrieve
|
||||||
// files from the index. This is a suboptimal workaround but it does the job
|
// files from the index. This is a suboptimal workaround but it does the job
|
||||||
if (this.is_encrypted) {
|
if (this.is_encrypted) {
|
||||||
// Restore the older file...
|
// Restore the older file...
|
||||||
|
|
|
@ -96,6 +96,9 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.UpdateMenuEvent += delegate {
|
Controller.UpdateMenuEvent += delegate {
|
||||||
|
while ((this.menu.Delegate as SparkleMenuDelegate).MenuIsOpen)
|
||||||
|
System.Threading.Thread.Sleep (100);
|
||||||
|
|
||||||
Program.Controller.Invoke (() => CreateMenu ());
|
Program.Controller.Invoke (() => CreateMenu ());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -205,7 +208,35 @@ namespace SparkleShare {
|
||||||
this.menu.AddItem (NSMenuItem.SeparatorItem);
|
this.menu.AddItem (NSMenuItem.SeparatorItem);
|
||||||
this.menu.AddItem (this.quit_item);
|
this.menu.AddItem (this.quit_item);
|
||||||
|
|
||||||
|
this.menu.Delegate = new SparkleMenuDelegate ();
|
||||||
this.status_item.Menu = this.menu;
|
this.status_item.Menu = this.menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class SparkleMenuDelegate : NSMenuDelegate {
|
||||||
|
|
||||||
|
public SparkleMenuDelegate (IntPtr handle) : base (handle) { }
|
||||||
|
public SparkleMenuDelegate () { }
|
||||||
|
|
||||||
|
public bool MenuIsOpen { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
public override void MenuWillHighlightItem (NSMenu menu, NSMenuItem item)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void MenuWillOpen (NSMenu menu)
|
||||||
|
{
|
||||||
|
MenuIsOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void MenuDidClose (NSMenu menu)
|
||||||
|
{
|
||||||
|
MenuIsOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,8 @@ namespace SparkleShare {
|
||||||
public IconState CurrentState = IconState.Idle;
|
public IconState CurrentState = IconState.Idle;
|
||||||
public string StateText = "Welcome to SparkleShare!";
|
public string StateText = "Welcome to SparkleShare!";
|
||||||
|
|
||||||
public string [] Folders;
|
public string [] Folders = new string [0];
|
||||||
public string [] FolderErrors;
|
public string [] FolderErrors = new string [0];
|
||||||
|
|
||||||
|
|
||||||
public string FolderSize {
|
public string FolderSize {
|
||||||
|
@ -95,7 +95,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public bool RecentEventsItemEnabled {
|
public bool RecentEventsItemEnabled {
|
||||||
get {
|
get {
|
||||||
return (Program.Controller.Folders.Count > 0);
|
return (Folders.Length > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ namespace SparkleShare {
|
||||||
if (CurrentState != IconState.Error) {
|
if (CurrentState != IconState.Error) {
|
||||||
CurrentState = IconState.Idle;
|
CurrentState = IconState.Idle;
|
||||||
|
|
||||||
if (Program.Controller.Folders.Count == 0)
|
if (Folders.Length == 0)
|
||||||
StateText = "Welcome to SparkleShare!";
|
StateText = "Welcome to SparkleShare!";
|
||||||
else
|
else
|
||||||
StateText = "Projects up to date " + FolderSize;
|
StateText = "Projects up to date " + FolderSize;
|
||||||
|
@ -132,7 +132,7 @@ namespace SparkleShare {
|
||||||
if (CurrentState != IconState.Error) {
|
if (CurrentState != IconState.Error) {
|
||||||
CurrentState = IconState.Idle;
|
CurrentState = IconState.Idle;
|
||||||
|
|
||||||
if (Program.Controller.Folders.Count == 0)
|
if (Folders.Length == 0)
|
||||||
StateText = "Welcome to SparkleShare!";
|
StateText = "Welcome to SparkleShare!";
|
||||||
else
|
else
|
||||||
StateText = "Projects up to date " + FolderSize;
|
StateText = "Projects up to date " + FolderSize;
|
||||||
|
|
Loading…
Reference in a new issue