Reputation: 784
This is driving me nuts, I've tried everything for about a week. Hope some kind sole can help. I'm trying to create a new modal popup color picker. However, StopModal()
keeps creating a new window.
I created a new NSWindow
programatically a little like this:
class ColorPicker:NSWindow{
void ColorPicker(IntPtr Value):base(Value){
}
void ColorPicker(Color StartColor){
//Set up window here.
}
public void ShowModal(NSWindow NewParent){
this.ParentWindow = NewParent;
NSApplication.SharedApplication.RunModalForWindow(this);
return DialogResult;
}
}
I create like this:
ColorPicker CP=new ColorPicker(Color.Red);
Then show it
CP.ShowDialog(MyMainWindow);
I have a button on the form that closes it and calls
NSApplication.SharedApplication.StopModal();
But for some reason this creates a second window by calling:
void ColorPicker(IntPtr Value):base(Value){
}
Then I get leak errors and soon it crashes:
NativeRelease ERROR]: type: ColorPicker handle: 137041376 count: 2 gchandle: 0
objc[350]: Object 0x103070 of class NSConcreteMapTable autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Upvotes: 0
Views: 572
Reputation: 1602
This might be happening if you are not retaining a reference to the ColorPicker object in .NET. It will be garbage collected, then re-created when the Cocoa/objective-c system tries to send it a message.
Happens to me when I Dispose of the object after it closes.
Upvotes: 1