Skip to content

Commit 6459866

Browse files
authored
Merge branch 'eclipse-platform:master' into master
2 parents d00f44a + 1ef11c0 commit 6459866

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/refresh/win32/Win32Monitor.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ private void openHandleOn(String path, boolean subtree) {
221221
setHandleValue(createHandleValue(path, subtree, Win32Natives.FILE_NOTIFY_CHANGE_FILE_NAME | Win32Natives.FILE_NOTIFY_CHANGE_DIR_NAME | Win32Natives.FILE_NOTIFY_CHANGE_LAST_WRITE | Win32Natives.FILE_NOTIFY_CHANGE_SIZE));
222222
if (isOpen()) {
223223
fHandleValueToHandle.put(getHandleValue(), this);
224-
setHandleValueArrays(createHandleArrays());
224+
setHandleValueArrays();
225225
} else {
226226
close();
227227
}
@@ -369,7 +369,7 @@ public Win32Monitor(IRefreshResult result) {
369369
setPriority(Job.DECORATE);
370370
setSystem(true);
371371
fHandleValueToHandle = new HashMap<>(1);
372-
setHandleValueArrays(createHandleArrays());
372+
setHandleValueArrays();
373373
}
374374

375375
/**
@@ -424,13 +424,18 @@ private Handle createHandle(IResource resource) {
424424
* Win32Natives.MAXIMUM_WAIT_OBJECTS. The arrays are balanced so that they
425425
* differ in size by no more than one element.
426426
*/
427-
protected long[][] createHandleArrays() {
427+
private long[][] createHandleArrays() {
428428
long[] handles;
429429
// synchronized: in order to protect the map during iteration
430430
synchronized (fHandleValueToHandle) {
431431
Set<Long> keys = fHandleValueToHandle.keySet();
432432
int size = keys.size();
433433
if (size == 0) {
434+
// This is dangerous: the documentation of WaitForMultipleObjects says that the
435+
// number of object handles cannot be zero and returning empty arrays will end
436+
// up passing zero as the 1st parameter to WaitForMultipleObjects. Therefore one
437+
// needs to make sure to check for this case when calling
438+
// Win32Natives.WaitForMultipleObjects(int, ...)
434439
return new long[0][0];
435440
}
436441
handles = new long[size];
@@ -524,7 +529,7 @@ private void removeHandles(Collection<Handle> handles) {
524529
fHandleValueToHandle.remove(handle.getHandleValue());
525530
handle.destroy();
526531
}
527-
setHandleValueArrays(createHandleArrays());
532+
setHandleValueArrays();
528533
}
529534
}
530535

@@ -572,8 +577,8 @@ protected IStatus run(IProgressMonitor monitor) {
572577
return Status.OK_STATUS;
573578
}
574579

575-
protected void setHandleValueArrays(long[][] arrays) {
576-
fHandleValueArrays = arrays;
580+
private void setHandleValueArrays() {
581+
fHandleValueArrays = createHandleArrays();
577582
}
578583

579584
@Override
@@ -607,6 +612,11 @@ public void unmonitor(IResource resource) {
607612
*/
608613
private void waitForNotification(long[] handleValues) {
609614
int handleCount = handleValues.length;
615+
if (handleCount == 0) {
616+
// According to the documentation of WaitForMultipleObjects,
617+
// nCount (the 1st parameter) cannot be zero
618+
return;
619+
}
610620
int index = Win32Natives.WaitForMultipleObjects(handleCount, handleValues, false, WAIT_FOR_MULTIPLE_OBJECTS_TIMEOUT);
611621
if (index == Win32Natives.WAIT_TIMEOUT) {
612622
// nothing happened.

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/refresh/win32/Win32Natives.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public static boolean FindNextChangeNotification(long hChangeHandle) {
193193
* <li>All of the objects are signaled, when bWaitAll is <code>true</code></li>
194194
* <li>The timeout interval of dwMilliseconds elapses.</li>
195195
* </ul>
196-
* @param nCount The number of handles, cannot be greater than MAXIMUM_WAIT_OBJECTS.
196+
* @param nCount The number of handles, cannot be zero and cannot be greater than MAXIMUM_WAIT_OBJECTS.
197197
* @param lpHandles The array of handles to objects to be waited upon cannot contain
198198
* duplicate handles.
199199
* @param bWaitAll If <code>true</code> requires all objects to be signaled before this

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void controlResized(ControlEvent e) {
121121
}
122122
});
123123

124-
browser = new Browser(shell, SWT.NONE);
124+
browser = new Browser(shell, SWT.SEARCH);
125125
browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
126126
initialize(browser);
127127

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BrowserPart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public class BrowserPart extends AbstractFormPart implements IHelpPart {
9797

9898
public BrowserPart(final Composite parent, FormToolkit toolkit,
9999
final IToolBarManager tbm, IMenuManager menuManager) {
100-
browser = new Browser(parent, SWT.NULL);
100+
browser = new Browser(parent, SWT.SEARCH);
101101
browser.addLocationListener(new LocationListener() {
102102

103103
@Override

0 commit comments

Comments
 (0)