Skip to content

Commit

Permalink
Merge pull request mono#8874 from mono/pr-david-dispose
Browse files Browse the repository at this point in the history
Fix 997787 and Fix 992438
  • Loading branch information
abock authored Oct 10, 2019
2 parents b3b3564 + d7b7b6b commit 6db2d57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ public ManagedGtkNSViewHostControl (ICocoaTextViewHost textViewHost)
if (textViewHost == null)
throw new ArgumentNullException (nameof (textViewHost));

GtkView = new Gtk.GtkNSViewHost (textViewHost.HostControl);
GtkView = new Gtk.GtkNSViewHost (
textViewHost.HostControl,
disposeViewOnGtkDestroy: true);

GtkView.Show ();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,18 @@ static NSEvent GetNSEvent (Gdk.Event evnt)

NSView view;
NSView superview;
bool disposeViewOnGtkDestroy;
bool sizeAllocated;

public GtkNSViewHost (NSView view)
: this (view, disposeViewOnGtkDestroy: false)
{
}

public GtkNSViewHost (NSView view, bool disposeViewOnGtkDestroy)
{
this.view = view ?? throw new ArgumentNullException (nameof (view));
this.disposeViewOnGtkDestroy = disposeViewOnGtkDestroy;

WidgetFlags |= WidgetFlags.NoWindow;

Expand Down Expand Up @@ -151,6 +158,10 @@ protected override void OnDestroyed ()
LogEnter ();
try {
view?.RemoveFromSuperview ();

if (disposeViewOnGtkDestroy)
view?.Dispose ();

view = null;
superview = null;

Expand Down

0 comments on commit 6db2d57

Please sign in to comment.