From 91408776f0b04dbc5a5da99f555b33f9abc5a905 Mon Sep 17 00:00:00 2001 From: Henrik Kinnunen Date: Sun, 14 Sep 2008 21:36:16 +0200 Subject: 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. --- ChangeLog | 3 +++ src/FbTk/ImageControl.cc | 9 ++++++++- src/FbTk/ImageControl.hh | 5 ++++- src/FbTk/Menu.cc | 18 +++++++++++++++--- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 63aaf07..d577aae 100644 --- a/ChangeLog +++ b/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) diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc index 38114c8..067bcde 100644 --- a/src/FbTk/ImageControl.cc +++ b/src/FbTk/ImageControl.cc @@ -227,11 +227,18 @@ Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, 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); if (pixmap) { diff --git a/src/FbTk/ImageControl.hh b/src/FbTk/ImageControl.hh index a9c2eb7..b7b90f7 100644 --- a/src/FbTk/ImageControl.hh +++ b/src/FbTk/ImageControl.hh @@ -54,11 +54,14 @@ public: @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); diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index f4e8f3d..7d50302 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -460,12 +460,24 @@ void Menu::updateMenu(int active_index) { 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) { -- cgit v0.11.2