Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash calling canvas.destroy_children() #58

Open
josuigoa opened this issue Jan 11, 2017 · 4 comments
Open

Crash calling canvas.destroy_children() #58

josuigoa opened this issue Jan 11, 2017 · 4 comments

Comments

@josuigoa
Copy link
Contributor

Hi!

I've set the empty_luxe project and called canvas.destroy_children() here. When I click the button, the app crashes.

It seems that onmouseup is set to null in the middle of the emit function. Maybe it is set to null in some of the listeners?

This is how I've traced the function and this is the result:

macro public function emit( ethis : Expr, args:Array<Expr> ) {
    return macro {
        var _idx = 0;
        trace( 'out.ethis: '+$ethis );
        var _count = $ethis.listeners.length;
        trace( '_count: ' + _count );
        while(_idx < _count) {
            trace( 'while.0.in.ethis: '+$ethis );
            var fn = $ethis.listeners[_idx];
            if(fn != null) {
                fn($a{args});
            }
            _idx++;
        }

        while(_count > 0) {
            trace( 'while.1.in.ethis: '+$ethis );
            var fn = $ethis.listeners[_count-1];
            if(fn == null) $ethis.listeners.splice(_count-1, 1);
            _count--;
        }
    }
} //emit
Signal.hx::51   out.ethis: { listeners : [<function>,<function>] }  mint_luxe_empty.js:5140:2
Signal.hx::53   _count: 2  mint_luxe_empty.js:5140:2
Signal.hx::55   while.0.in.ethis: { listeners : [<function>,<function>] } mint_luxe_empty.js:5140:2
Signal.hx::64   while.1.in.ethis: { listeners : [null,null] }  mint_luxe_empty.js:5140:2
Signal.hx::64   while.1.in.ethis: { listeners : [null]}  mint_luxe_empty.js:5140:2
Signal.hx::64   while.1.in.ethis: null  mint_luxe_empty.js:5140:2
TypeError: this.onmouseup is null[Learn More]  mint_luxe_empty.js:527:8
   mint_Control.prototype.mouseup http://localhost:40404/mint_luxe_empty.js:527:8
   mint_focus_Focus.prototype.mouseup http://localhost:40404/mint_luxe_empty.js:15201:27
   $bind/f http://localhost:40404/mint_luxe_empty.js:28157:233
   mint_Canvas.prototype<.mouseup http://localhost:40404/mint_luxe_empty.js:1162:19
   AutoCanvas.prototype<.conv_mouseup http://localhost:40404/mint_luxe_empty.js:1450:3
   $bind/f http://localhost:40404/mint_luxe_empty.js:28157:233
   luxe_Emitter.prototype.emit http://localhost:40404/mint_luxe_empty.js:3887:5
   luxe_Input.prototype.onmouseup http://localhost:40404/mint_luxe_empty.js:6363:3
   luxe_Engine.prototype<.onmouseup http://localhost:40404/mint_luxe_empty.js:5957:3
   snow_systems_input_Input.prototype.dispatch_mouse_up_event http://localhost:40404/mint_luxe_empty.js:26892:3
   snow_core_web_Runtime.prototype.setup_events/<
@ruby0x1
Copy link
Member

ruby0x1 commented Jan 11, 2017

destroying a control should destroy itself and all it's listeners so that part is intended, but it seems that the focus model isn't aware of the change. i.e to me it seems the issue comes from mint_focus_Focus.prototype.mouseup rather than the signals per se.

It's interesting because it should assert if destroyed right above the this.onmouseup line:
assert(destroyed == false, '$name was already destroyed but is being interacted with');

I'll have a closer look at it!

@ruby0x1
Copy link
Member

ruby0x1 commented Jan 11, 2017

Also, I can't get it to crash :C
Is this what you had?

import luxe.Input;
import luxe.Color;
import luxe.Vector;

import mint.Control;
import mint.types.Types;
import mint.render.luxe.*;
import mint.layout.margins.Margins;
import mint.focus.Focus;

import AutoCanvas;

class Main extends luxe.Game {

    var focus: Focus;
    var layout: Margins;
    var canvas: AutoCanvas;
    var rendering: LuxeMintRender;

    override function config(config:luxe.GameConfig) {

        return config;

    } //config

    override function ready() {

        rendering = new LuxeMintRender();
        layout = new Margins();
        
        var _scale = Luxe.screen.device_pixel_ratio;
        canvas = new AutoCanvas({
            name:'canvas',
            rendering: rendering,
            options: { color:new Color(1,1,1,0) },
            x: 0, y:0, scale:_scale, w: Luxe.screen.w/_scale, h: Luxe.screen.h/_scale
        });

        focus = new Focus(canvas);
        canvas.auto_listen();

            //optional!
        new mint.Button({
            parent: canvas,
            name: 'button',
            x: 90, y: 40, w: 60, h: 32,
            text: 'mint',
            text_size: 14,
            options: { label: { color:new Color().rgb(0x9dca63) } },
            onclick: function(e,c) { canvas.destroy_children(); }
        });

    } //ready

    override function onkeyup( e:luxe.KeyEvent ) {

        if(e.keycode == Key.escape) {
            Luxe.shutdown();
        }

    } //onkeyup

} //Main

@josuigoa
Copy link
Contributor Author

josuigoa commented Jan 11, 2017

I would say that's the code I've tried, but I'm not on the computer and I can't look.
I'll try tomorrow and I'll tell you

@josuigoa
Copy link
Contributor Author

yep! I copy/pasted the code above in empty_luxe and it crashes. I'm on Window 10, tried in Firefox Developer Edition, Chrome and Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants