On 22.08.2012 12:39, Daniel wrote:
>>>   iconbeingset = false
>>>   client.connect_signal("new",
>>>     function(c)
>>>       c:connect_signal("property::icon",
>>>         function()
>>>           if iconbeingset then return end
>>>             icon = c:client_get_icon()
>>
>> Uhm, shouldn't this cause errors? There is no client_get_icon.
> 
> It did, "methods are nil"... Thanks a bunch, I got them both working!
> 
> If I set the grayscale like so:  c.icon = ...create_from_png("foo")._native
> I guess I need to worry about the ImageSurface getting destroyed as well?

Yes, it just becomes a lot more unlikely to happy (and thus harder to debug if
it happens). :-)

local foo = create_from_png("bar")
c.icon = foo._native
foo = nil

This should be safe.

> And
> if so, would a local variable inside that function there be enough to be safe?

Yes.

> (and I guess I would lose a little memory everytime an application is started,
> since I don't keep track of the recolored images...)

No, I don't think so. It's possible that one gets memleaks if the userdata that
c.icon returns isn't sent through gears.surface(). However, after this, lua's
garbage collector should make sure everything is fine (eventually...).

Uli
-- 
- Captain, I think I should tell you I've never
  actually landed a starship before.
- That's all right, Lieutenant, neither have I.

-- 
To unsubscribe, send mail to [email protected].

Reply via email to