mac: Fix more memory warnings
This commit is contained in:
parent
bc749a31f5
commit
84413d2c53
|
@ -40,6 +40,8 @@ namespace SparkleShare {
|
||||||
public SparkleAbout (IntPtr handle) : base (handle) { }
|
public SparkleAbout (IntPtr handle) : base (handle) { }
|
||||||
|
|
||||||
public SparkleAbout () : base ()
|
public SparkleAbout () : base ()
|
||||||
|
{
|
||||||
|
using (var a = new NSAutoreleasePool ())
|
||||||
{
|
{
|
||||||
SetFrame (new RectangleF (0, 0, 640, 281), true);
|
SetFrame (new RectangleF (0, 0, 640, 281), true);
|
||||||
Center ();
|
Center ();
|
||||||
|
@ -53,46 +55,64 @@ namespace SparkleShare {
|
||||||
BackingType = NSBackingStore.Buffered;
|
BackingType = NSBackingStore.Buffered;
|
||||||
|
|
||||||
CreateAbout ();
|
CreateAbout ();
|
||||||
|
}
|
||||||
|
|
||||||
Controller.HideWindowEvent += delegate {
|
Controller.HideWindowEvent += delegate {
|
||||||
|
using (var a = new NSAutoreleasePool ())
|
||||||
|
{
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
PerformClose (this);
|
PerformClose (this);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.ShowWindowEvent += delegate {
|
Controller.ShowWindowEvent += delegate {
|
||||||
|
using (var a = new NSAutoreleasePool ())
|
||||||
|
{
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
OrderFrontRegardless ();
|
OrderFrontRegardless ();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.NewVersionEvent += delegate (string new_version) {
|
Controller.NewVersionEvent += delegate (string new_version) {
|
||||||
|
using (var a = new NSAutoreleasePool ())
|
||||||
|
{
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
UpdatesTextField.StringValue = "A newer version (" + new_version + ") is available!";
|
UpdatesTextField.StringValue = "A newer version (" + new_version + ") is available!";
|
||||||
UpdatesTextField.TextColor =
|
UpdatesTextField.TextColor =
|
||||||
NSColor.FromCalibratedRgba (0.45f, 0.62f, 0.81f, 1.0f);
|
NSColor.FromCalibratedRgba (0.45f, 0.62f, 0.81f, 1.0f);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.VersionUpToDateEvent += delegate {
|
Controller.VersionUpToDateEvent += delegate {
|
||||||
|
using (var a = new NSAutoreleasePool ())
|
||||||
|
{
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
UpdatesTextField.StringValue = "You are running the latest version.";
|
UpdatesTextField.StringValue = "You are running the latest version.";
|
||||||
UpdatesTextField.TextColor =
|
UpdatesTextField.TextColor =
|
||||||
NSColor.FromCalibratedRgba (0.45f, 0.62f, 0.81f, 1.0f);
|
NSColor.FromCalibratedRgba (0.45f, 0.62f, 0.81f, 1.0f);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.CheckingForNewVersionEvent += delegate {
|
Controller.CheckingForNewVersionEvent += delegate {
|
||||||
|
using (var a = new NSAutoreleasePool ())
|
||||||
|
{
|
||||||
InvokeOnMainThread (delegate {
|
InvokeOnMainThread (delegate {
|
||||||
UpdatesTextField.StringValue = "Checking for updates...";
|
UpdatesTextField.StringValue = "Checking for updates...";
|
||||||
UpdatesTextField.TextColor =
|
UpdatesTextField.TextColor =
|
||||||
NSColor.FromCalibratedRgba (0.45f, 0.62f, 0.81f, 1.0f); // Tango Sky Blue #1
|
NSColor.FromCalibratedRgba (0.45f, 0.62f, 0.81f, 1.0f); // Tango Sky Blue #1
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void CreateAbout ()
|
private void CreateAbout ()
|
||||||
|
{
|
||||||
|
using (var a = new NSAutoreleasePool ())
|
||||||
{
|
{
|
||||||
string about_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
|
string about_image_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
|
||||||
"Pixmaps", "about.png");
|
"Pixmaps", "about.png");
|
||||||
|
@ -162,6 +182,7 @@ namespace SparkleShare {
|
||||||
ContentView.AddSubview (UpdatesTextField);
|
ContentView.AddSubview (UpdatesTextField);
|
||||||
ContentView.AddSubview (CreditsTextField);
|
ContentView.AddSubview (CreditsTextField);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void OrderFrontRegardless ()
|
public override void OrderFrontRegardless ()
|
||||||
|
|
|
@ -244,11 +244,16 @@ namespace SparkleShare {
|
||||||
this.popup_button.Menu.AddItem (NSMenuItem.SeparatorItem);
|
this.popup_button.Menu.AddItem (NSMenuItem.SeparatorItem);
|
||||||
this.popup_button.AddItems (folders);
|
this.popup_button.AddItems (folders);
|
||||||
|
|
||||||
this.popup_button.Activated += delegate {
|
this.popup_button.Activated += delegate { // FIXME: Still causes some memory leak warnings
|
||||||
|
using (var b = new NSAutoreleasePool ())
|
||||||
|
{
|
||||||
|
InvokeOnMainThread (delegate {
|
||||||
if (this.popup_button.IndexOfSelectedItem == 0)
|
if (this.popup_button.IndexOfSelectedItem == 0)
|
||||||
Controller.SelectedFolder = null;
|
Controller.SelectedFolder = null;
|
||||||
else
|
else
|
||||||
Controller.SelectedFolder = this.popup_button.SelectedItem.Title;
|
Controller.SelectedFolder = this.popup_button.SelectedItem.Title;
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ContentView.AddSubview (this.popup_button);
|
ContentView.AddSubview (this.popup_button);
|
||||||
|
|
|
@ -41,13 +41,13 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
public SparkleUI ()
|
public SparkleUI ()
|
||||||
|
{
|
||||||
|
using (var a = new NSAutoreleasePool ())
|
||||||
{
|
{
|
||||||
// Use translations
|
// Use translations
|
||||||
Catalog.Init ("sparkleshare",
|
Catalog.Init ("sparkleshare",
|
||||||
Path.Combine (NSBundle.MainBundle.ResourcePath, "Translations"));
|
Path.Combine (NSBundle.MainBundle.ResourcePath, "Translations"));
|
||||||
|
|
||||||
using (NSAutoreleasePool pool = new NSAutoreleasePool ()) {
|
|
||||||
|
|
||||||
// Needed for Growl
|
// Needed for Growl
|
||||||
GrowlApplicationBridge.WeakDelegate = this;
|
GrowlApplicationBridge.WeakDelegate = this;
|
||||||
GrowlApplicationBridge.Delegate = new SparkleGrowlDelegate ();
|
GrowlApplicationBridge.Delegate = new SparkleGrowlDelegate ();
|
||||||
|
@ -76,6 +76,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
public void SetFolderIcon ()
|
public void SetFolderIcon ()
|
||||||
|
{
|
||||||
|
using (var a = new NSAutoreleasePool ())
|
||||||
{
|
{
|
||||||
string folder_icon_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
|
string folder_icon_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
|
||||||
"sparkleshare-mac.icns");
|
"sparkleshare-mac.icns");
|
||||||
|
@ -85,6 +87,7 @@ namespace SparkleShare {
|
||||||
NSWorkspace.SharedWorkspace.SetIconforFile (folder_icon,
|
NSWorkspace.SharedWorkspace.SetIconforFile (folder_icon,
|
||||||
Program.Controller.SparklePath, 0);
|
Program.Controller.SparklePath, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Run ()
|
public void Run ()
|
||||||
|
@ -113,9 +116,12 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
private void ShowDockIcon ()
|
private void ShowDockIcon ()
|
||||||
|
{
|
||||||
|
using (var a = new NSAutoreleasePool ())
|
||||||
{
|
{
|
||||||
NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;
|
NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[Export("registrationDictionaryForGrowl")]
|
[Export("registrationDictionaryForGrowl")]
|
||||||
|
|
Loading…
Reference in a new issue