Fixed a pixmap resource leak with selected pixmap in menus. menu.hilite.selected.pixmap and menu.selected.pixmap was not deleted while switching between non-pixmap styles and pixmap styles.
Henrik Kinnunen fluxgen@fluxbox.org
4 files changed,
30 insertions(+),
5 deletions(-)
M
ChangeLog
→
ChangeLog
@@ -1,5 +1,8 @@
(Format: Year/Month/Day) Changes for 1.1 +*08/09/14: + * Fixed a minor pixmap resource leak (Henrik) + FbTk/Menu.cc, FbTk/ImageControl.cc/hh *08/09/01: * When the current menu item gets disabled, highlight its nearest neighbor and add separators to the focus model menu (Mark)
M
src/FbTk/ImageControl.cc
→
src/FbTk/ImageControl.cc
@@ -227,10 +227,17 @@
Pixmap ImageControl::renderImage(unsigned int width, unsigned int height, const FbTk::Texture &texture, - FbTk::Orientation orient) { + FbTk::Orientation orient, + bool use_cache ) { if (texture.type() & FbTk::Texture::PARENTRELATIVE) return ParentRelative; + + // If we are not suppose to cache this pixmap, just render and return it + if ( ! use_cache) { + TextureRender image(*this, width, height, orient, m_colors, m_num_colors); + return image.render(texture); + } // search cache first Pixmap pixmap = searchCache(width, height, texture, orient);
M
src/FbTk/ImageControl.hh
→
src/FbTk/ImageControl.hh
@@ -54,11 +54,14 @@ Render to pixmap
@param width width of pixmap @param height height of pixmap @param src_texture texture type to render + @param orient Orientation of the texture. + @param use_cache whether or not to use cache @return pixmap of the rendered image, on failure None */ Pixmap renderImage(unsigned int width, unsigned int height, const FbTk::Texture &src_texture, - Orientation orient = ROT0); + Orientation orient = ROT0, + bool use_cache = true); void installRootColormap(); void removeImage(Pixmap thepix);
M
src/FbTk/Menu.cc
→
src/FbTk/Menu.cc
@@ -460,12 +460,24 @@
if (!theme()->selectedPixmap().pixmap().drawable()) { int hw = theme()->itemHeight() / 2; - theme()->setSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme()->hiliteTexture()), true); + // render image, disable cache and let the theme remove the pixmap + theme()->setSelectedPixmap(m_image_ctrl. + renderImage(hw, hw, + theme()->hiliteTexture(), ROT0, + false // no cache + ), + false); // the theme takes care of this pixmap if (!theme()->highlightSelectedPixmap().pixmap().drawable()) { int hw = theme()->itemHeight() / 2; - theme()->setHighlightSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme()->frameTexture()), true); - } + // render image, disable cache and let the theme remove the pixmap + theme()->setHighlightSelectedPixmap(m_image_ctrl. + renderImage(hw, hw, + theme()->frameTexture(), ROT0, + false // no cache + ), + false); // theme takes care of this pixmap + } } if (m_title_vis) {