From 2628a0a4cfae6d45f8d3115fecb6ede3f8da02e6 Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Sun, 23 Oct 2011 11:51:36 +0200 Subject: clean up resources on shutdown --- src/FbTk/FbPixmap.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc index 160d478..90a1754 100644 --- a/src/FbTk/FbPixmap.cc +++ b/src/FbTk/FbPixmap.cc @@ -29,6 +29,7 @@ #include #include #include +#include #ifdef HAVE_CSTRING #include #else @@ -41,7 +42,7 @@ namespace FbTk { namespace { -Pixmap *root_pixmaps = 0; +std::vector s_root_pixmaps; struct RootProps { const char* name; @@ -409,14 +410,15 @@ bool FbPixmap::rootwinPropertyNotify(int screen_num, Atom atom) { // returns whether or not the background was changed bool FbPixmap::setRootPixmap(int screen_num, Pixmap pm) { - if (!root_pixmaps) { - root_pixmaps = new Pixmap[ScreenCount(display())]; - for (int i=0; i < ScreenCount(display()); ++i) - root_pixmaps[i] = None; + + if (s_root_pixmaps.empty()) { + int i; + for (i = 0; i < ScreenCount(display()); ++i) + s_root_pixmaps.push_back(None); } - if (root_pixmaps[screen_num] != pm) { - root_pixmaps[screen_num] = pm; + if (s_root_pixmaps[screen_num] != pm) { + s_root_pixmaps[screen_num] = pm; FbWindow::updatedAlphaBackground(screen_num); return true; } @@ -430,8 +432,8 @@ Pixmap FbPixmap::getRootPixmap(int screen_num, bool force_update) { */ // check and see if if we have the pixmaps in cache - if (root_pixmaps && !force_update) - return root_pixmaps[screen_num]; + if (!s_root_pixmaps.empty() && !force_update) + return s_root_pixmaps[screen_num]; checkAtoms(); @@ -481,7 +483,7 @@ Pixmap FbPixmap::getRootPixmap(int screen_num, bool force_update) { setRootPixmap(i, root_pm); } - return root_pixmaps[screen_num]; + return s_root_pixmaps[screen_num]; } void FbPixmap::free() { -- cgit v0.11.2