Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-08-05 06:40:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-08-05 06:40:51 +0400
commit8aa33834087bf5e717c0b671254d528d93cf6001 (patch)
tree8496f2b372b4faaab90ff0129d14e79366d2d448
parent2a999890fb0c9839e8eb7666ce58178fac7da538 (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.
-rw-r--r--intern/ghost/intern/GHOST_EventManager.cpp9
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp7
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.h6
-rw-r--r--intern/ghost/intern/GHOST_WindowManager.cpp1
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp10
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c2
-rw-r--r--source/blender/windowmanager/intern/wm_window.c8
-rw-r--r--source/blender/windowmanager/wm_window.h1
8 files changed, 40 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;
}
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 599844f1020..7179efb186d 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -274,6 +274,8 @@ void WM_exit(bContext *C)
RNA_exit();
+ wm_ghost_exit();
+
CTX_free(C);
if(MEM_get_memory_blocks_in_use()!=0) {
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 31e6de2527b..4d80836dd05 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -756,6 +756,14 @@ void wm_ghost_init(bContext *C)
}
}
+void wm_ghost_exit(void)
+{
+ if(g_system)
+ GHOST_DisposeSystem(g_system);
+
+ g_system= NULL;
+}
+
/* **************** timer ********************** */
/* to (de)activate running timers temporary */
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
index c2a2b00b796..f159f7f098d 100644
--- a/source/blender/windowmanager/wm_window.h
+++ b/source/blender/windowmanager/wm_window.h
@@ -33,6 +33,7 @@ struct bScreen;
/* *************** internal api ************** */
void wm_ghost_init (bContext *C);
+void wm_ghost_exit(void);
wmWindow *wm_window_new (bContext *C);
void wm_window_free (bContext *C, wmWindow *win);