mac: fix occasional crash when updating the menu whilst it's open
This commit is contained in:
parent
b78d0c11c5
commit
b20bd558d7
|
@ -603,7 +603,7 @@ namespace SparkleLib.Git {
|
|||
|
||||
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
|
||||
if (this.is_encrypted) {
|
||||
// Restore the older file...
|
||||
|
|
|
@ -96,6 +96,9 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
Controller.UpdateMenuEvent += delegate {
|
||||
while ((this.menu.Delegate as SparkleMenuDelegate).MenuIsOpen)
|
||||
System.Threading.Thread.Sleep (100);
|
||||
|
||||
Program.Controller.Invoke (() => CreateMenu ());
|
||||
};
|
||||
|
||||
|
@ -205,7 +208,35 @@ namespace SparkleShare {
|
|||
this.menu.AddItem (NSMenuItem.SeparatorItem);
|
||||
this.menu.AddItem (this.quit_item);
|
||||
|
||||
this.menu.Delegate = new SparkleMenuDelegate ();
|
||||
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 string StateText = "Welcome to SparkleShare!";
|
||||
|
||||
public string [] Folders;
|
||||
public string [] FolderErrors;
|
||||
public string [] Folders = new string [0];
|
||||
public string [] FolderErrors = new string [0];
|
||||
|
||||
|
||||
public string FolderSize {
|
||||
|
@ -95,7 +95,7 @@ namespace SparkleShare {
|
|||
|
||||
public bool RecentEventsItemEnabled {
|
||||
get {
|
||||
return (Program.Controller.Folders.Count > 0);
|
||||
return (Folders.Length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ namespace SparkleShare {
|
|||
if (CurrentState != IconState.Error) {
|
||||
CurrentState = IconState.Idle;
|
||||
|
||||
if (Program.Controller.Folders.Count == 0)
|
||||
if (Folders.Length == 0)
|
||||
StateText = "Welcome to SparkleShare!";
|
||||
else
|
||||
StateText = "Projects up to date " + FolderSize;
|
||||
|
@ -132,7 +132,7 @@ namespace SparkleShare {
|
|||
if (CurrentState != IconState.Error) {
|
||||
CurrentState = IconState.Idle;
|
||||
|
||||
if (Program.Controller.Folders.Count == 0)
|
||||
if (Folders.Length == 0)
|
||||
StateText = "Welcome to SparkleShare!";
|
||||
else
|
||||
StateText = "Projects up to date " + FolderSize;
|
||||
|
|
Loading…
Reference in a new issue