When using both simpleimage and DWT my program crashes with "core.exception.InvalidMemoryOperationError" after I show an image in a GUI window and then close the window. I'm presumably misunderstanding something about how the windows deal with memory deallocation, but this happens even when copying tutorial examples.

e.g.

module main;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.graphics.all;

void main ()
{
    auto display = new Display;
    auto shell = new Shell;

    shell.setText("Title");

    Label label = new Label (shell, SWT.BORDER);
    label.setBounds(shell.getClientArea());

    Image image = new Image(display, "C:/dev/data/tree.png");
    label.setImage(image);

    shell.pack();
    shell.open();

    while (!shell.isDisposed)
        if (!display.readAndDispatch())
            display.sleep();

    display.dispose();
}

This successfully creates the display and shows an image, but when I close the window the memory error exception is thrown. If I run the same code without creating the image then there's no errors. If I create the image without setting it on the label I still get the error. Any ideas?

Reply via email to