Skip to content

Display class not properly ported to D2 #111

@torhus

Description

@torhus

I think it's not the only one. I tried adding some "mixin(gshared!(...)" etc. But just got a segfault. Shouldn't the docs state that the Linux build is not quite ready?
This test program doesn't reach the second writefln, because Display.getDefault either fails or returns the wrong object:

#!/usr/bin/env dub
/+
dub.sdl:
    name "snippet7"
    dependency "dwt" version="~>1.0.5"
    libs \
      "atk-1.0" \
      "cairo" \
      "dl" \
      "fontconfig" \
      "gdk-x11-2.0" \
      "gdk_pixbuf-2.0" \
      "gio-2.0" \
      "glib-2.0" \
      "gmodule-2.0" \
      "gobject-2.0" \
      "gthread-2.0" \
      "gtk-x11-2.0" \
      "pango-1.0" \
      "pangocairo-1.0" \
      "X11" \
      "Xcomposite" \
      "Xcursor" \
      "Xdamage" \
      "Xext" \
      "Xfixes" \
      "Xi" \
      "Xinerama" \
      "Xrandr" \
      "Xrender" \
      "Xtst" \
      platform="linux"
+/

/*
 * Bug test: Display.getDefault fails on Linux.
 */
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import java.lang.all : dgRunnable;

import core.thread;
import std.stdio;

void main () {
    Display display = Display.getDefault();

    Shell shell = new Shell (display);
    Thread thread = new Thread({
        writefln("Is main thread: %s", Thread.getThis.isMainThread);

        Display.getDefault().syncExec (dgRunnable({
            writefln("Is main thread: %s", Thread.getThis.isMainThread);
        }));
    });

    thread.start ();
    shell.open ();
    while (!shell.isDisposed ()) {
        if (!display.readAndDispatch ()) display.sleep ();
    }
    display.dispose ();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions