Skip to content

Commit 81ee856

Browse files
committed
Enable reporting in init
1 parent f8015ff commit 81ee856

File tree

1 file changed

+9
-7
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics

1 file changed

+9
-7
lines changed

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,23 @@ private static class ResourceTracker implements Runnable {
5858
/**
5959
* Allows to disarm this cleaning action.
6060
*/
61-
private final AtomicBoolean ignore = new AtomicBoolean(false);
61+
private final AtomicBoolean reporting = new AtomicBoolean(false);
6262

6363
ResourceTracker(Error allocationStack) {
6464
this.allocationStack = allocationStack;
6565
}
6666

6767
/**
68-
* Causes all future invocations of {@link #run()} to be ignored
68+
* @param value whether the {@link Resource#nonDisposedReporter} should be
69+
* notified
6970
*/
70-
public void ignore() {
71-
ignore.set(true);
71+
public void setReporting(boolean value) {
72+
reporting.set(value);
7273
}
7374

7475
@Override
7576
public void run() {
76-
if (ignore.get()) return;
77+
if (!reporting.get()) return;
7778
if (nonDisposedReporter == null) return;
7879

7980
nonDisposedReporter.accept(allocationStack);
@@ -145,7 +146,7 @@ void destroyHandlesExcept(Set<Integer> zoomLevels) {
145146
* This method does nothing if the resource is already disposed.
146147
*/
147148
public void dispose() {
148-
if (tracker != null) tracker.ignore();
149+
if (tracker != null) tracker.setReporting(false);
149150
if (device == null) return;
150151
if (device.isDisposed()) return;
151152
destroy();
@@ -169,12 +170,13 @@ public Device getDevice() {
169170

170171
void ignoreNonDisposed() {
171172
if (tracker != null) {
172-
tracker.ignore();
173+
tracker.setReporting(false);
173174
}
174175
}
175176

176177
void init() {
177178
if (device.tracking) device.new_Object(this);
179+
if (tracker != null) tracker.setReporting(true);
178180
}
179181

180182
void initNonDisposeTracking() {

0 commit comments

Comments
 (0)