aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2011-10-22 22:01:45 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2011-10-22 22:01:45 (GMT)
commitee34b376d768ecafc2fa21a79a854df503d1f115 (patch)
treeb6be7d0cbb8ae8899d5faa70ec1b7b9b478c62ad /src/FbTk
parent3f76e117bf7735058f2b135beb72e015658f97eb (diff)
downloadfluxbox_paul-ee34b376d768ecafc2fa21a79a854df503d1f115.zip
fluxbox_paul-ee34b376d768ecafc2fa21a79a854df503d1f115.tar.bz2
Bugfix: clean up static resources correctly
93924af160ea303c94a2576b0e57a04e94c9228c might corrupt memory with gcc-4.6.1 when finishing fluxbox (clicking 'exit', sending it a SIGINT). Allthough the order, in which static / global objects are initialized is undefined (at least between separate compilation units), the order in which they are destroyed is well defined: in reverse order of initialization. this means, that if 'ScreenImlibContextContainer contexts' (of ImageImlib2.cc) gets initialized AFTER 'ImageImlib2 imlib2_loader' of Image.cc, it gets destroyed before imlib2_loader. When that happens, ~ImageImlib2() works on a destroyed object. (That lead to '* glibc detected * fluxbox: corrupted double-linked list: 0x0000000000dd2710 ***' later on in 'iconv_close')
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/ImageImlib2.cc23
-rw-r--r--src/FbTk/ImageImlib2.hh1
2 files changed, 11 insertions, 13 deletions
diff --git a/src/FbTk/ImageImlib2.cc b/src/FbTk/ImageImlib2.cc
index 5bac7a4..69fc333 100644
--- a/src/FbTk/ImageImlib2.cc
+++ b/src/FbTk/ImageImlib2.cc
@@ -30,11 +30,20 @@
30 30
31namespace { 31namespace {
32 32
33typedef std::map<int, Imlib_Context> ScreenImlibContextContainer; 33class ScreenImlibContextContainer : public std::map<int, Imlib_Context> {
34public:
35 ~ScreenImlibContextContainer() {
36
37 std::map<int, Imlib_Context>::iterator it = this->begin();
38 std::map<int, Imlib_Context>::iterator it_end = this->end();
39 for (; it != it_end; it++) {
40 imlib_context_free(it->second);
41 }
42 }
43};
34typedef ScreenImlibContextContainer::iterator ScreenImlibContext; 44typedef ScreenImlibContextContainer::iterator ScreenImlibContext;
35 45
36ScreenImlibContextContainer contexts; 46ScreenImlibContextContainer contexts;
37
38} // anon namespace 47} // anon namespace
39 48
40 49
@@ -69,16 +78,6 @@ ImageImlib2::ImageImlib2() {
69 } 78 }
70} 79}
71 80
72ImageImlib2::~ImageImlib2() {
73
74 ScreenImlibContext it = contexts.begin();
75 ScreenImlibContext it_end = contexts.end();
76 for (; it != it_end; it++) {
77 imlib_context_free(it->second);
78 }
79 contexts.clear();
80}
81
82PixmapWithMask *ImageImlib2::load(const std::string &filename, int screen_num) const { 81PixmapWithMask *ImageImlib2::load(const std::string &filename, int screen_num) const {
83 82
84 Display *dpy = FbTk::App::instance()->display(); 83 Display *dpy = FbTk::App::instance()->display();
diff --git a/src/FbTk/ImageImlib2.hh b/src/FbTk/ImageImlib2.hh
index 21bb854..b5da5a1 100644
--- a/src/FbTk/ImageImlib2.hh
+++ b/src/FbTk/ImageImlib2.hh
@@ -28,7 +28,6 @@ namespace FbTk {
28class ImageImlib2: public ImageBase { 28class ImageImlib2: public ImageBase {
29public: 29public:
30 ImageImlib2(); 30 ImageImlib2();
31 ~ImageImlib2();
32 PixmapWithMask *load(const std::string &filename, int screen_num) const; 31 PixmapWithMask *load(const std::string &filename, int screen_num) const;
33}; 32};
34 33