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

Cannot read property 'id' of undefined #29

Open
RossComputerGuy opened this issue Sep 11, 2017 · 2 comments
Open

Cannot read property 'id' of undefined #29

RossComputerGuy opened this issue Sep 11, 2017 · 2 comments

Comments

@RossComputerGuy
Copy link

const FontManager = require("font-manager");
const ntk = require("ntk");
const x11 = require("x11");

function setFont(i,ctx) {
	var fnt = FontManager.getAvailableFontsSync()[i];
	var font = ctx.loadFont(fnt.path,fnt.weight,10,10);
	ctx.setFont(font);
	return ctx;
}

function draw(ctx,wnd) {
	setFont(0,ctx);
	ctx.fillStyle = "blue";
	ctx.fillRect(0,0,wnd.width,wnd.height);
	var txt = "Unfortunately, TGAC has stopped working!";
	ctx.fillText(txt,(wnd.width/2)-(ctx.measureText(txt).width/2),(wnd.height/2)-(ctx.measureText(txt).height/2));
}

ntk.createClient( (err, app) => {
	var window = app.createWindow({ width: 500, height: 300, title: "TGAC" });
	var ctx = window.getContext("2d");
	window.on("resize",(ev) => {
		draw(ctx,window);
	});
	window.map();
	draw(ctx,window);
});

This code results in this error:

/home/spaceboyross/Documents/TGAC/node_modules/ntk/lib/glyphset.js:13
    X.FreeGlyphSet(obj.id);
                      ^

TypeError: Cannot read property 'id' of undefined
    at EventEmitter.<anonymous> (/home/spaceboyross/Documents/TGAC/node_modules/ntk/lib/glyphset.js:13:23)
    at emitNone (events.js:86:13)
    at EventEmitter.emit (events.js:188:7)
    at callback (/home/spaceboyross/Documents/TGAC/node_modules/weak/lib/weak.js:108:11)
@sidorares
Copy link
Owner

thanks @SpaceboyRoss01 , I'll have a look later today when I'm at linux desktop

not sure exactly why obj can be undefined here

var ref = weak(this, function (obj) {

you cat temporarily try to comment out X.FreeGlyphSet(obj.id); line that causes error

@RossComputerGuy
Copy link
Author

I patched it myself by changing the code to

var ref = weak(this,() => {
    X.FreeGlyphSet(this.id);
});

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