aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--src/FbTk/FbPixmap.cc19
-rw-r--r--src/FbTk/FbPixmap.hh7
-rw-r--r--src/FbTk/Menu.cc4
-rw-r--r--src/FbTk/MenuTheme.hh13
5 files changed, 35 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 6da5371..8547ce9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
1 (Format: Year/Month/Day) 1 (Format: Year/Month/Day)
2Changes for 1.0rc2: 2Changes for 1.0rc2:
3*06/06/24:
4 * Fix bug #1362463, menu selection pixmaps disappear (Simon)
5 - pixmap from image cache was put into FbPixmap, which freed it.
6 FbPixmap.hh/cc MenuTheme.hh Menu.cc
3*06/06/23: 7*06/06/23:
4 * Make startfluxbox aware of --program-prefix and --program-suffix (Mark) 8 * Make startfluxbox aware of --program-prefix and --program-suffix (Mark)
5 configure.in util/Makefile.am util/startfluxbox.in 9 configure.in util/Makefile.am util/startfluxbox.in
diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc
index c605feb..46ee97c 100644
--- a/src/FbTk/FbPixmap.cc
+++ b/src/FbTk/FbPixmap.cc
@@ -54,18 +54,18 @@ Atom FbPixmap::root_prop_atoms[] = {
54 54
55FbPixmap::FbPixmap():m_pm(0), 55FbPixmap::FbPixmap():m_pm(0),
56 m_width(0), m_height(0), 56 m_width(0), m_height(0),
57 m_depth(0) { 57 m_depth(0), m_dont_free(false) {
58} 58}
59 59
60FbPixmap::FbPixmap(const FbPixmap &the_copy):FbDrawable(), m_pm(0), 60FbPixmap::FbPixmap(const FbPixmap &the_copy):FbDrawable(), m_pm(0),
61 m_width(0), m_height(0), 61 m_width(0), m_height(0),
62 m_depth(0){ 62 m_depth(0), m_dont_free(false) {
63 copy(the_copy); 63 copy(the_copy);
64} 64}
65 65
66FbPixmap::FbPixmap(Pixmap pm):m_pm(0), 66FbPixmap::FbPixmap(Pixmap pm):m_pm(0),
67 m_width(0), m_height(0), 67 m_width(0), m_height(0),
68 m_depth(0) { 68 m_depth(0), m_dont_free(false) {
69 if (pm == 0) 69 if (pm == 0)
70 return; 70 return;
71 // assign X pixmap to this 71 // assign X pixmap to this
@@ -76,7 +76,7 @@ FbPixmap::FbPixmap(const FbDrawable &src,
76 unsigned int width, unsigned int height, 76 unsigned int width, unsigned int height,
77 unsigned int depth):m_pm(0), 77 unsigned int depth):m_pm(0),
78 m_width(0), m_height(0), 78 m_width(0), m_height(0),
79 m_depth(0) { 79 m_depth(0), m_dont_free(false) {
80 80
81 create(src.drawable(), width, height, depth); 81 create(src.drawable(), width, height, depth);
82} 82}
@@ -85,7 +85,7 @@ FbPixmap::FbPixmap(Drawable src,
85 unsigned int width, unsigned int height, 85 unsigned int width, unsigned int height,
86 unsigned int depth):m_pm(0), 86 unsigned int depth):m_pm(0),
87 m_width(0), m_height(0), 87 m_width(0), m_height(0),
88 m_depth(0) { 88 m_depth(0), m_dont_free(false) {
89 89
90 create(src, width, height, depth); 90 create(src, width, height, depth);
91} 91}
@@ -470,10 +470,13 @@ void FbPixmap::checkAtoms() {
470} 470}
471 471
472void FbPixmap::free() { 472void FbPixmap::free() {
473 if (m_pm != 0) { 473 if (!m_dont_free && m_pm != 0)
474 XFreePixmap(display(), m_pm); 474 XFreePixmap(display(), m_pm);
475 m_pm = 0; 475
476 } 476 /* note: m_dont_free shouldnt be required anywhere else,
477 because then free() isn't being called appropriately! */
478 m_dont_free = false;
479 m_pm = 0;
477 m_width = 0; 480 m_width = 0;
478 m_height = 0; 481 m_height = 0;
479 m_depth = 0; 482 m_depth = 0;
diff --git a/src/FbTk/FbPixmap.hh b/src/FbTk/FbPixmap.hh
index 2935978..dab364a 100644
--- a/src/FbTk/FbPixmap.hh
+++ b/src/FbTk/FbPixmap.hh
@@ -77,12 +77,19 @@ public:
77 unsigned int width, unsigned int height, 77 unsigned int width, unsigned int height,
78 unsigned int depth); 78 unsigned int depth);
79 79
80 /* Will be reset to false whenever this pixmap is reassigned */
81 void dontFree() { m_dont_free = true; }
82
80private: 83private:
81 void free(); 84 void free();
85
82 Pixmap m_pm; 86 Pixmap m_pm;
83 unsigned int m_width, m_height; 87 unsigned int m_width, m_height;
84 unsigned int m_depth; 88 unsigned int m_depth;
85 89
90 // if pixmap not *owned* by this object (eg assigned from cache object)
91 bool m_dont_free;
92
86 /// Functions relating to the maintenance of root window pixmap caching 93 /// Functions relating to the maintenance of root window pixmap caching
87 static void checkAtoms(); 94 static void checkAtoms();
88 95
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index b0e5c4e..b067361 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -470,11 +470,11 @@ void Menu::updateMenu(int active_index) {
470 470
471 if (!theme().selectedPixmap().pixmap().drawable()) { 471 if (!theme().selectedPixmap().pixmap().drawable()) {
472 int hw = theme().itemHeight() / 2; 472 int hw = theme().itemHeight() / 2;
473 m_theme.setSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme().hiliteTexture())); 473 m_theme.setSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme().hiliteTexture()), true);
474 474
475 if (!theme().highlightSelectedPixmap().pixmap().drawable()) { 475 if (!theme().highlightSelectedPixmap().pixmap().drawable()) {
476 int hw = theme().itemHeight() / 2; 476 int hw = theme().itemHeight() / 2;
477 m_theme.setHighlightSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme().frameTexture())); 477 m_theme.setHighlightSelectedPixmap(m_image_ctrl.renderImage(hw, hw, theme().frameTexture()), true);
478 } 478 }
479 } 479 }
480 480
diff --git a/src/FbTk/MenuTheme.hh b/src/FbTk/MenuTheme.hh
index c423cf4..da5b65c 100644
--- a/src/FbTk/MenuTheme.hh
+++ b/src/FbTk/MenuTheme.hh
@@ -126,8 +126,17 @@ public:
126 inline const FbTk::Color &borderColor() const { return *m_border_color; } 126 inline const FbTk::Color &borderColor() const { return *m_border_color; }
127 127
128 // special override 128 // special override
129 inline void setSelectedPixmap(Pixmap pm) { m_selected_pixmap->pixmap() = pm; } 129 inline void setSelectedPixmap(Pixmap pm, bool is_imagecached) {
130 inline void setHighlightSelectedPixmap(Pixmap pm) { m_hl_selected_pixmap->pixmap() = pm; } 130 m_selected_pixmap->pixmap() = pm;
131 if (is_imagecached)
132 m_selected_pixmap->pixmap().dontFree();
133 }
134
135 inline void setHighlightSelectedPixmap(Pixmap pm, bool is_imagecached) {
136 m_hl_selected_pixmap->pixmap() = pm;
137 if (is_imagecached)
138 m_hl_selected_pixmap->pixmap().dontFree();
139 }
131 140
132private: 141private:
133 FbTk::ThemeItem<FbTk::Color> t_text, f_text, h_text, d_text; 142 FbTk::ThemeItem<FbTk::Color> t_text, f_text, h_text, d_text;