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

Small issue in the cairo binding #162

Open
fstirlitz opened this issue Mar 18, 2017 · 2 comments
Open

Small issue in the cairo binding #162

fstirlitz opened this issue Mar 18, 2017 · 2 comments

Comments

@fstirlitz
Copy link
Contributor

>>> return tostring(require('lgi').cairo.PathData._field.header[3])
stdin:1: '__tostring' must return a string
stack traceback:
	[C]: in function 'tostring'
	stdin:1: in main chunk
	[C]: in ?
>>> return getmetatable(require('lgi').cairo.PathData._field.header[3]):__tostring()
nil

And similarly for cairo.PathData._field.point. I got this error by attempting to perform a recursive dump on _G; I'm not sure where else it may come up.

@psychon
Copy link
Collaborator

psychon commented Mar 18, 2017

Looks like the third argument of component.create is supposed to be the name. According to git grep, there are many calls to that function with just two arguments (not just in cairo).

A possible fix (besides fixing all callers) might be:

diff --git a/lgi/component.lua b/lgi/component.lua
index a6803ae..d15a177 100644
--- a/lgi/component.lua
+++ b/lgi/component.lua
@@ -319,7 +319,7 @@ function component.create(info, mt, name)
    end
 
    -- Fill in meta of the compound.
-   local component = { _name = name }
+   local component = { _name = name or "__unnamed__" }
    if gtype then
       -- Bind component in repo, make the relation using GType.
       component._gtype = gtype

@fstirlitz What's your Lua version? My Lua 5.2 does not really complain here:

> return tostring(require('lgi').cairo.PathData._field.header[3])
nil

@pavouk I'll leave it up to you to fix this. I don't know if all callers should be fixed or the implementation should work around this issue (as in the above example patch). Also, no idea what good names for these things would be.

@fstirlitz
Copy link
Contributor Author

I use Lua 5.3.

I'd rather use something that isn't a valid identifier instead of "__unnamed__" to avoid the usual problems with in-band signalling.

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