From 6917c547dfb9514db249e636f8e25fd0409f660b Mon Sep 17 00:00:00 2001 From: "pavlov%pavlov.net" Date: Mon, 22 Mar 1999 02:57:06 +0000 Subject: [PATCH] memory leak patch from bruce@cybersight.com --- widget/src/gtk/nsGtkEventHandler.cpp | 80 ++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/widget/src/gtk/nsGtkEventHandler.cpp b/widget/src/gtk/nsGtkEventHandler.cpp index 1475b42948f4..c16111f244ad 100644 --- a/widget/src/gtk/nsGtkEventHandler.cpp +++ b/widget/src/gtk/nsGtkEventHandler.cpp @@ -202,6 +202,14 @@ void InitMouseEvent(GdkEventButton *aGEB, } } +//============================================================== +void UninitMouseEvent(GdkEventButton *aGEB, + gpointer p, + nsMouseEvent &anEvent, + PRUint32 aEventType) +{ +} + //============================================================== void InitDrawEvent(GdkRectangle *area, gpointer p, @@ -219,6 +227,19 @@ void InitDrawEvent(GdkRectangle *area, anEvent.rect = rect; } } +//============================================================== +void UninitDrawEvent(GdkRectangle *area, + gpointer p, + nsPaintEvent &anEvent, + PRUint32 aEventType) +{ + if (area != NULL) { + delete anEvent.rect; + } + // While I'd think you should NS_RELEASE(anEvent.widget) here, + // if you do, it is a NULL pointer. Not sure where it is getting + // released. +} //============================================================== void InitExposeEvent(GdkEventExpose *aGEE, @@ -240,6 +261,17 @@ void InitExposeEvent(GdkEventExpose *aGEE, } } +//============================================================= +void UninitExposeEvent(GdkEventExpose *aGEE, + gpointer p, + nsPaintEvent &anEvent, + PRUint32 aEventType) +{ + if (aGEE != NULL) { + delete anEvent.rect; + } +} + //============================================================== void InitMotionEvent(GdkEventMotion *aGEM, gpointer p, @@ -259,6 +291,14 @@ void InitMotionEvent(GdkEventMotion *aGEM, } } +//============================================================== +void UninitMotionEvent(GdkEventMotion *aGEM, + gpointer p, + nsMouseEvent &anEvent, + PRUint32 aEventType) +{ +} + //============================================================== void InitCrossingEvent(GdkEventCrossing *aGEC, gpointer p, @@ -278,6 +318,14 @@ void InitCrossingEvent(GdkEventCrossing *aGEC, } } +//============================================================== +void UninitCrossingEvent(GdkEventCrossing *aGEC, + gpointer p, + nsMouseEvent &anEvent, + PRUint32 aEventType) +{ +} + //============================================================== void InitKeyEvent(GdkEventKey *aGEK, gpointer p, @@ -302,6 +350,14 @@ void InitKeyEvent(GdkEventKey *aGEK, } } +//============================================================= +void UninitKeyEvent(GdkEventKey *aGEK, + gpointer p, + nsKeyEvent &anEvent, + PRUint32 aEventType) +{ +} + //============================================================== void InitFocusEvent(GdkEventFocus *aGEF, gpointer p, @@ -319,6 +375,14 @@ void InitFocusEvent(GdkEventFocus *aGEF, anEvent.point.y = 0; } +//============================================================== +void UninitFocusEvent(GdkEventFocus *aGEF, + gpointer p, + nsGUIEvent &anEvent, + PRUint32 aEventType) +{ +} + /*============================================================== ============================================================== ============================================================= @@ -416,6 +480,8 @@ gint handle_draw_event(GtkWidget *w, GdkRectangle *area, gpointer p) win->OnPaint(pevent); + UninitDrawEvent(area, p, pevent, NS_PAINT); + return PR_TRUE; } @@ -431,6 +497,8 @@ gint handle_expose_event(GtkWidget *w, GdkEventExpose *event, gpointer p) win->OnPaint(pevent); + UninitExposeEvent(event, p, pevent, NS_PAINT); + return PR_TRUE; } @@ -492,6 +560,8 @@ gint handle_button_press_event(GtkWidget *w, GdkEventButton * event, gpointer p) nsWindow *win = (nsWindow *)p; win->DispatchMouseEvent(mevent); + UninitMouseEvent(event, p, mevent, b); + return PR_TRUE; } @@ -521,6 +591,8 @@ gint handle_button_release_event(GtkWidget *w, GdkEventButton * event, gpointer nsWindow *win = (nsWindow *)p; win->DispatchMouseEvent(mevent); + UninitMouseEvent(event, p, mevent, b); + return PR_TRUE; } @@ -533,6 +605,8 @@ gint handle_motion_notify_event(GtkWidget *w, GdkEventMotion * event, gpointer p nsWindow *win = (nsWindow *)p; win->DispatchMouseEvent(mevent); + UninitMotionEvent(event, p, mevent, NS_MOUSE_MOVE); + return PR_TRUE; } @@ -545,6 +619,8 @@ gint handle_enter_notify_event(GtkWidget *w, GdkEventCrossing * event, gpointer nsWindow *win = (nsWindow *)p; win->DispatchMouseEvent(mevent); + UninitCrossingEvent(event, p, mevent, NS_MOUSE_ENTER); + return PR_TRUE; } @@ -569,6 +645,8 @@ gint handle_focus_in_event(GtkWidget *w, GdkEventFocus * event, gpointer p) nsWindow *win = (nsWindow *)p; win->DispatchFocus(gevent); + UninitFocusEvent(event, p, gevent, NS_GOTFOCUS); + return PR_TRUE; } @@ -581,6 +659,8 @@ gint handle_focus_out_event(GtkWidget *w, GdkEventFocus * event, gpointer p) nsWindow *win = (nsWindow *)p; win->DispatchFocus(gevent); + UninitFocusEvent(event, p, gevent, NS_LOSTFOCUS); + return PR_TRUE; }