Bugfix: clean up static resources correctly
93924af160
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')
This commit is contained in:
parent
3f76e117bf
commit
ee34b376d7
2 changed files with 11 additions and 13 deletions
|
@ -30,11 +30,20 @@
|
|||
|
||||
namespace {
|
||||
|
||||
typedef std::map<int, Imlib_Context> ScreenImlibContextContainer;
|
||||
class ScreenImlibContextContainer : public std::map<int, Imlib_Context> {
|
||||
public:
|
||||
~ScreenImlibContextContainer() {
|
||||
|
||||
std::map<int, Imlib_Context>::iterator it = this->begin();
|
||||
std::map<int, Imlib_Context>::iterator it_end = this->end();
|
||||
for (; it != it_end; it++) {
|
||||
imlib_context_free(it->second);
|
||||
}
|
||||
}
|
||||
};
|
||||
typedef ScreenImlibContextContainer::iterator ScreenImlibContext;
|
||||
|
||||
ScreenImlibContextContainer contexts;
|
||||
|
||||
} // anon namespace
|
||||
|
||||
|
||||
|
@ -69,16 +78,6 @@ ImageImlib2::ImageImlib2() {
|
|||
}
|
||||
}
|
||||
|
||||
ImageImlib2::~ImageImlib2() {
|
||||
|
||||
ScreenImlibContext it = contexts.begin();
|
||||
ScreenImlibContext it_end = contexts.end();
|
||||
for (; it != it_end; it++) {
|
||||
imlib_context_free(it->second);
|
||||
}
|
||||
contexts.clear();
|
||||
}
|
||||
|
||||
PixmapWithMask *ImageImlib2::load(const std::string &filename, int screen_num) const {
|
||||
|
||||
Display *dpy = FbTk::App::instance()->display();
|
||||
|
|
|
@ -28,7 +28,6 @@ namespace FbTk {
|
|||
class ImageImlib2: public ImageBase {
|
||||
public:
|
||||
ImageImlib2();
|
||||
~ImageImlib2();
|
||||
PixmapWithMask *load(const std::string &filename, int screen_num) const;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue