aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorHenrik Kinnunen <fluxgen@fluxbox.org>2008-09-14 19:36:16 (GMT)
committerHenrik Kinnunen <fluxgen@fluxbox.org>2008-09-14 19:36:16 (GMT)
commit91408776f0b04dbc5a5da99f555b33f9abc5a905 (patch)
tree6173a78017f7981ae1ad17825461907973a08777 /src/FbTk
parent9f519ec0fcb7cd0dec61a4c31d246800f9a73cb3 (diff)
downloadfluxbox-91408776f0b04dbc5a5da99f555b33f9abc5a905.zip
fluxbox-91408776f0b04dbc5a5da99f555b33f9abc5a905.tar.bz2
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.
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/ImageControl.cc9
-rw-r--r--src/FbTk/ImageControl.hh5
-rw-r--r--src/FbTk/Menu.cc18
3 files changed, 27 insertions, 5 deletions
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,
227 227
228Pixmap ImageControl::renderImage(unsigned int width, unsigned int height, 228Pixmap ImageControl::renderImage(unsigned int width, unsigned int height,
229 const FbTk::Texture &texture, 229 const FbTk::Texture &texture,
230 FbTk::Orientation orient) { 230 FbTk::Orientation orient,
231 bool use_cache ) {
231 232
232 if (texture.type() & FbTk::Texture::PARENTRELATIVE) 233 if (texture.type() & FbTk::Texture::PARENTRELATIVE)
233 return ParentRelative; 234 return ParentRelative;
234 235
236 // If we are not suppose to cache this pixmap, just render and return it
237 if ( ! use_cache) {
238 TextureRender image(*this, width, height, orient, m_colors, m_num_colors);
239 return image.render(texture);
240 }
241
235 // search cache first 242 // search cache first
236 Pixmap pixmap = searchCache(width, height, texture, orient); 243 Pixmap pixmap = searchCache(width, height, texture, orient);
237 if (pixmap) { 244 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:
54 @param width width of pixmap 54 @param width width of pixmap
55 @param height height of pixmap 55 @param height height of pixmap
56 @param src_texture texture type to render 56 @param src_texture texture type to render
57 @param orient Orientation of the texture.
58 @param use_cache whether or not to use cache
57 @return pixmap of the rendered image, on failure None 59 @return pixmap of the rendered image, on failure None
58 */ 60 */
59 Pixmap renderImage(unsigned int width, unsigned int height, 61 Pixmap renderImage(unsigned int width, unsigned int height,
60 const FbTk::Texture &src_texture, 62 const FbTk::Texture &src_texture,
61 Orientation orient = ROT0); 63 Orientation orient = ROT0,
64 bool use_cache = true);
62 65
63 void installRootColormap(); 66 void installRootColormap();
64 void removeImage(Pixmap thepix); 67 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) {
460 460
461 if (!theme()->selectedPixmap().pixmap().drawable()) { 461 if (!theme()->selectedPixmap().pixmap().drawable()) {
462 int hw = theme()->itemHeight() / 2; 462 int hw = theme()->itemHeight() / 2;
463 theme()->setSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme()->hiliteTexture()), true); 463 // render image, disable cache and let the theme remove the pixmap
464 theme()->setSelectedPixmap(m_image_ctrl.
465 renderImage(hw, hw,
466 theme()->hiliteTexture(), ROT0,
467 false // no cache
468 ),
469 false); // the theme takes care of this pixmap
464 470
465 if (!theme()->highlightSelectedPixmap().pixmap().drawable()) { 471 if (!theme()->highlightSelectedPixmap().pixmap().drawable()) {
466 int hw = theme()->itemHeight() / 2; 472 int hw = theme()->itemHeight() / 2;
467 theme()->setHighlightSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme()->frameTexture()), true); 473 // render image, disable cache and let the theme remove the pixmap
468 } 474 theme()->setHighlightSelectedPixmap(m_image_ctrl.
475 renderImage(hw, hw,
476 theme()->frameTexture(), ROT0,
477 false // no cache
478 ),
479 false); // theme takes care of this pixmap
480 }
469 } 481 }
470 482
471 if (m_title_vis) { 483 if (m_title_vis) {