diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-08-05 06:40:51 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-08-05 06:40:51 +0400 |
commit | 8aa33834087bf5e717c0b671254d528d93cf6001 (patch) | |
tree | 8496f2b372b4faaab90ff0129d14e79366d2d448 /intern | |
parent | 2a999890fb0c9839e8eb7666ce58178fac7da538 (diff) |
fix for ghost memory leaks
- ghost data wasn't being freed (added wm_ghost_exit() call to wm_init_exit.c)
- GHOST_EventManager wasn't freeing GHOST_IEventConsumer's
- ghost/X11 wasnt calling XCloseDisplay(), some junk from X11 wasnt being freed
- ghost/X11 XAllocNamedColor wasn't freeing the colors when done making a custom cursor.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/intern/GHOST_EventManager.cpp | 9 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.cpp | 7 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.h | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowManager.cpp | 1 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowX11.cpp | 10 |
5 files changed, 29 insertions, 4 deletions
diff --git a/intern/ghost/intern/GHOST_EventManager.cpp b/intern/ghost/intern/GHOST_EventManager.cpp index f9b13115f32..92cea8d8ff7 100644 --- a/intern/ghost/intern/GHOST_EventManager.cpp +++ b/intern/ghost/intern/GHOST_EventManager.cpp @@ -51,6 +51,15 @@ GHOST_EventManager::GHOST_EventManager() GHOST_EventManager::~GHOST_EventManager() { disposeEvents(); + + TConsumerVector::iterator iter= m_consumers.begin(); + while (iter != m_consumers.end()) + { + GHOST_IEventConsumer* consumer = *iter; + delete consumer; + m_consumers.erase(iter); + iter = m_consumers.begin(); + } } diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index dbdb65a14f4..5dba76adb02 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -148,6 +148,13 @@ GHOST_SystemX11( } +GHOST_SystemX11:: +~GHOST_SystemX11() +{ + XCloseDisplay(m_display); +} + + GHOST_TSuccess GHOST_SystemX11:: init( diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h index afd960d1ec3..782f08f6737 100644 --- a/intern/ghost/intern/GHOST_SystemX11.h +++ b/intern/ghost/intern/GHOST_SystemX11.h @@ -59,6 +59,12 @@ public: GHOST_SystemX11( ); + /** + * Destructor. + */ + virtual ~GHOST_SystemX11(); + + GHOST_TSuccess init( ); diff --git a/intern/ghost/intern/GHOST_WindowManager.cpp b/intern/ghost/intern/GHOST_WindowManager.cpp index 2b0809929c5..af96653db13 100644 --- a/intern/ghost/intern/GHOST_WindowManager.cpp +++ b/intern/ghost/intern/GHOST_WindowManager.cpp @@ -54,6 +54,7 @@ GHOST_WindowManager::GHOST_WindowManager() : GHOST_WindowManager::~GHOST_WindowManager() { + /* m_windows is freed by GHOST_System::disposeWindow */ } diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 41c62be0966..f9774b6df70 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -1325,13 +1325,12 @@ setWindowCustomCursorShape( int fg_color, int bg_color ){ + Colormap colormap= DefaultColormap(m_display, DefaultScreen(m_display)); Pixmap bitmap_pix, mask_pix; XColor fg, bg; - if(XAllocNamedColor(m_display, DefaultColormap(m_display, DefaultScreen(m_display)), - "White", &fg, &fg) == 0) return GHOST_kFailure; - if(XAllocNamedColor(m_display, DefaultColormap(m_display, DefaultScreen(m_display)), - "Black", &bg, &bg) == 0) return GHOST_kFailure; + if(XAllocNamedColor(m_display, colormap, "White", &fg, &fg) == 0) return GHOST_kFailure; + if(XAllocNamedColor(m_display, colormap, "Black", &bg, &bg) == 0) return GHOST_kFailure; if (m_custom_cursor) { XFreeCursor(m_display, m_custom_cursor); @@ -1347,6 +1346,9 @@ setWindowCustomCursorShape( XFreePixmap(m_display, bitmap_pix); XFreePixmap(m_display, mask_pix); + XFreeColors(m_display, colormap, &fg.pixel, 1, 0L); + XFreeColors(m_display, colormap, &bg.pixel, 1, 0L); + return GHOST_kSuccess; } |