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

Release the cache for a GIcon (directly affected: indicator multiload) #4953

Closed
ghost opened this issue Dec 21, 2015 · 3 comments
Closed

Release the cache for a GIcon (directly affected: indicator multiload) #4953

ghost opened this issue Dec 21, 2015 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 21, 2015

I suppose if i do:

let icon1 = Gio.icon_new_for_string(icon_path);

and then i change the icon in the icon_path location for a new one and then i do again:

let icon2 = Gio.icon_new_for_string(icon_path);

if i do:

let equals = icon1.equal(icon2);

equals need to be false, but this not occurs inside cinnamon, because the icon1 was never released and there are no way for release this icon. As icon1 is in cache with the id: icon_path, the seconds call of the construction of icon2 return the icon1 that is in cache instead of create a new one.

I know this is the cause of also there are not a procedure for release the memory inside cinnamon menu and this is in most of cases a good thing, but not in all cases.

So need to be a way for remove the icons from this cache.

@ghost ghost changed the title Release the cache for a Gicon (direct afected: indicator multiload) Release the cache for a GIcon (directly affected: indicator multiload) Dec 21, 2015
@ghost
Copy link
Author

ghost commented Jan 1, 2016

@JosephMcc Here there are an another reason of why the indicator icons have a different colour.
#4883

If the indicator icons are set in a passive mode with an orange colour, then If the passive mode of the indicator changed to any other mode, is needed the process of replace the icons with a new one (the blue colour). In this point we need to release the cache of the icons, but currently in cinnamon it's not possible release an icon from the cache, without perform a hard procedure to refresh that involved the release of the whole desktop icons, so, the passive icons will be displayed, instead of the correct ones for the current mode.

An icon cache its a good things, but maybe not inside the gio, could be place in a different class and then you can decide if you want to use the cache class or the gio implementation.

See also that indicators have an internal cache for icons, this also need to be improved to not cache all icons of course, but currently will not resolve anything as there are two icon caches.

@ghost
Copy link
Author

ghost commented Jan 2, 2016

Instead of create a gicon we can create an St.TextureCahe, but we can not apply style to the texture cache directly, another alternative is create Pixbuf, then create a Clutter.Image, and then set it at the content of a St.Icon, but then we also can not apply any style directly to the St.Icon any attempt will be omitted, like this:

            let pixbuf = GdkPixbuf.Pixbuf.new_from_file(path);
            let pixelFormat = pixbuf.get_has_alpha() ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888;
            let pixbufWidth = pixbuf.get_width();
            let pixbufHeight = pixbuf.get_height();
            let realHeight = Math.min(pixbufHeight, realSize);
            let realWidth = (realHeight*pixbufWidth/pixbufHeight);
            let contentImage = new Clutter.Image();
            contentImage.set_bytes(pixbuf.get_pixels(), pixelFormat, pixbufWidth, pixbufHeight, pixbuf.get_rowstride());
            return new St.Icon({ style_class: 'applet-icon', content: contentImage, width: realWidth, height: realHeight });

Where the style_class: 'applet-icon', can not be apply. If there are another way i can not find it.

@ghost
Copy link
Author

ghost commented Sep 4, 2016

This was fixed by @mtwebster

@ghost ghost closed this as completed Sep 4, 2016
This issue was closed.
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

0 participants