Skip to content

Commit 6bde7ff

Browse files
author
zhourenjian
committed
Fixing bug that Display#timerExec adds all timer Runnable object into list without clearing them
1 parent 1bad590 commit 6bde7ff

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Console.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public void run() {
8282
Element wrapperEl = console.consoleWrapper.handle;
8383
wrapperEl.scrollLeft = scrollOffset.x;
8484
wrapperEl.scrollTop = scrollOffset.y;
85-
8685
}
8786

8887
});

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Display.java

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3290,11 +3290,21 @@ public boolean post (Event event) {
32903290
*/
32913291
}
32923292
}
3293+
/**
3294+
* @j2sNative
3295+
* window.setTimeout (function (disp) {
3296+
* return function () {
3297+
* disp.runDeferredEvents ();
3298+
* };
3299+
* } (this), 1);
3300+
*/ {}
3301+
/*
32933302
timerExec(1, new Runnable() {
32943303
public void run() {
32953304
runDeferredEvents();
32963305
}
32973306
});
3307+
*/
32983308
return false;
32993309
}
33003310

@@ -3318,11 +3328,21 @@ void postEvent (Event event) {
33183328
eventQueue = newQueue;
33193329
}
33203330
eventQueue [index] = event;
3331+
/**
3332+
* @j2sNative
3333+
* window.setTimeout (function (disp) {
3334+
* return function () {
3335+
* disp.runDeferredEvents ();
3336+
* };
3337+
* } (this), 1);
3338+
*/ {}
3339+
/*
33213340
timerExec(1, new Runnable() {
33223341
public void run() {
33233342
runDeferredEvents();
33243343
}
33253344
});
3345+
*/
33263346
}
33273347

33283348
/**
@@ -4034,6 +4054,7 @@ boolean runPopups () {
40344054
return result;
40354055
}
40364056

4057+
/*
40374058
boolean runTimer (int id) {
40384059
if (timerList != null && timerIds != null) {
40394060
int index = 0;
@@ -4052,6 +4073,7 @@ boolean runTimer (int id) {
40524073
}
40534074
return false;
40544075
}
4076+
*/
40554077

40564078
void sendEvent (int eventType, Event event) {
40574079
if (eventTable == null && filterTable == null) {
@@ -4396,9 +4418,9 @@ public void timerExec (int milliseconds, Runnable runnable) {
43964418
int timerId = 0;
43974419
if (index != timerList.length) {
43984420
timerId = timerIds [index];
4399-
if (milliseconds < 0) {
4421+
if (milliseconds < 0 && timerIds [index] != 0) {
44004422
//OS.KillTimer (hwndMessage, timerId);
4401-
window.clearInterval(timerId);
4423+
window.clearTimeout(timerId);
44024424
timerList [index] = null;
44034425
timerIds [index] = 0;
44044426
return;
@@ -4422,7 +4444,21 @@ public void timerExec (int milliseconds, Runnable runnable) {
44224444
}
44234445
}
44244446
//int newTimerID = OS.SetTimer (hwndMessage, timerId, milliseconds, 0);
4425-
int newTimerID = window.setTimeout(Clazz.makeFunction(runnable), milliseconds);
4447+
Runnable fun = null;
4448+
/**
4449+
* @j2sNative
4450+
* fun = (function (jsr, idx, disp) {
4451+
* return function () {
4452+
* try {
4453+
* jsr.run ();
4454+
* } finally {
4455+
* disp.timerList[idx] = null;
4456+
* disp.timerIds[idx] = 0;
4457+
* }
4458+
* };
4459+
* }) (runnable, index, this);
4460+
*/ {}
4461+
int newTimerID = window.setTimeout(fun, milliseconds);
44264462
if (newTimerID != 0) {
44274463
timerList [index] = runnable;
44284464
timerIds [index] = newTimerID;

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Link.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,7 @@ public void run() {
331331
e.widget = Link.this;
332332
e.display = display;
333333
sendEvent(SWT.Selection);
334-
if (!e.doit) {
335-
toReturn(false);
336-
}
334+
toReturn(false);
337335
}
338336
};
339337
for (int i = 0; i < anchors.length; i++) {

0 commit comments

Comments
 (0)