Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4461,6 +4461,15 @@ private long identity() {
return Gdip.Matrix_new(1, 0, 0, 1, 0, 0);
}

private void initWithImageHandle(Drawable drawable, GCData data, long hDC, ImageHandle imageHandle) {
Image image = data.image;
data.image = null;
init(drawable, data, hDC);
data.hNullBitmap = OS.SelectObject(hDC, imageHandle.getHandle());
image.memGC = this;
data.image = image;
}

private void init(Drawable drawable, GCData data, long hDC) {
int foreground = data.foreground;
if (foreground != -1) {
Expand Down Expand Up @@ -5935,12 +5944,12 @@ Point textExtentInPixels(String string, int flags) {
return new Point(rect.right, rect.bottom);
}

void refreshFor(Drawable drawable) {
void refreshFor(Drawable drawable, ImageHandle imageHandle) {
if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
destroy();
GCData newData = new GCData();
originalData.copyTo(newData);
createGcHandle(drawable, newData);
createGcHandle(drawable, newData, imageHandle);
}

/**
Expand Down Expand Up @@ -6059,10 +6068,10 @@ private void removePreviousOperationIfSupercededBy(Operation operation) {
}
}

private void createGcHandle(Drawable drawable, GCData newData) {
private void createGcHandle(Drawable drawable, GCData newData, ImageHandle imageHandle) {
long newHandle = drawable.internal_new_GC(newData);
if (newHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
init(drawable, newData, newHandle);
initWithImageHandle(drawable, newData, newHandle, imageHandle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change to GC necessary? Is it a bug in the existing implementation?

Copy link
Contributor Author

@amartya4256 amartya4256 Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this method is created from the earlier implementation of the PlainImageDataProvider as in case it uses GC to scale, it uses this specific method. In the init method of GC, it uses the Image.win32_getHandle, which would want to create a handle and since we already are in the middle of creation of the handle it will fail. Since we also had a specific method in the past for this case, the idea is to use the ImageHandle we just obtained and pass that directly instead of calling win32_getHandle.

for (Operation operation : operations) {
operation.apply();
}
Expand Down
Loading
Loading