Skip to content

Thread still showing as running after termination #22

Description

@Gama11

When running the following code (thanks for the code example @gepatto) and pressing Space to open a file dialog, a second thread appears in the callstack view:

package;

import lime.ui.FileDialogType;
import lime.ui.FileDialog;
import openfl.events.Event;
import openfl.net.URLRequest;
import openfl.display.Loader;
import openfl.display.Sprite;
import openfl.ui.Keyboard;
import openfl.events.KeyboardEvent;

class Main extends Sprite {
	var dialogOpen:Bool = false;
	var l:Loader;

	public function new() {
		super();
		stage.addEventListener(KeyboardEvent.KEY_DOWN, stage_keydown);
	}

	function loadComplete(e:Event) {}

	function stage_keydown(e:KeyboardEvent) {
		switch (e.keyCode) {
			case Keyboard.SPACE:
				selectImage();
			case Keyboard.DELETE:
				if (l != null) {
					l.unload();
					removeChild(l);
					l = null;
				}
		}
	};

	function selectImage() {
		#if !js
		if (dialogOpen)
			return; // prevent multiple dialogs
		if (l == null) {
			l = new Loader();
			l.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
			addChild(l);
		} else {
			l.unload();
		}
		var dOpen = new FileDialog();
		dOpen.onSelect.add(function(path:String) {
			l.load(new URLRequest(path));
			dialogOpen = false;
		});
		dialogOpen = true;
		dOpen.browse(FileDialogType.OPEN);
		#end
	}
}

When the file dialog is closed, the thread should terminate, but the UI doesn't seem to update. I added some traces and found the following order of events:

threadStart {
	threadId : 0
}
threadStart {
	threadId : 2
}
threadExit {
	threadId : -1
}

So it looks like we don't get a valid thread ID on exit. Possibly a bug in hcxpp (@nulld)?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions