From b83fa2d5168cae14dbf74a7de74446d33fdf7524 Mon Sep 17 00:00:00 2001 From: Silenio Quarti Date: Mon, 15 Oct 2012 14:04:34 +0530 Subject: Bug 380966-Tree crash calling OS.object_getInstanceVariable() --- .../internal/cocoa/FoundationFull.bridgesupport.extras | 3 +++ .../cocoa/org/eclipse/swt/internal/cocoa/NSObject.java | 6 +++++- .../cocoa/org/eclipse/swt/widgets/Display.java | 3 +++ .../Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java | 12 +++--------- .../cocoa/org/eclipse/swt/widgets/TreeItem.java | 15 +++++++++++++-- .../Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java | 4 ++++ 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras index 7b1602cdb9..640b813dbb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras @@ -774,6 +774,9 @@ + + + diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSObject.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSObject.java index fe68483433..4e502c3d0c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSObject.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSObject.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -121,6 +121,10 @@ public id copy() { return result != 0 ? new id(result) : null; } +public void dealloc () { + OS.objc_msgSend (this.id, OS.sel_dealloc); +} + public NSString description() { long /*int*/ result = OS.objc_msgSend(this.id, OS.sel_description); return result != 0 ? new NSString(result) : null; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java index 7706c173b9..038bab63bd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java @@ -2849,6 +2849,7 @@ void initClasses () { className = "SWTTreeItem"; cls = OS.objc_allocateClassPair(OS.class_NSObject, className, 0); OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types); + OS.class_addMethod(cls, OS.sel_dealloc, proc2, "@:"); OS.objc_registerClassPair(cls); className = "SWTView"; @@ -5358,6 +5359,8 @@ static long /*int*/ windowProc(long /*int*/ id, long /*int*/ sel) { if (widget == null) return 0; if (sel == OS.sel_sendSelection) { widget.sendSelection(); + } else if (sel == OS.sel_dealloc) { + widget.dealloc(id, sel); } else if (sel == OS.sel_sendDoubleSelection) { widget.sendDoubleSelection(); } else if (sel == OS.sel_sendVerticalSelection) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java index 871d7c2716..591e3caeb1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java @@ -2330,11 +2330,6 @@ void register () { } void releaseChildren (boolean destroy) { - itemCount = 0; - ignoreSelect = true; - ((NSOutlineView) view).reloadData (); - ignoreSelect = false; - for (int i=0; i