Call moz_gtk_shutdown before the event loop shuts down so that objects can be freed completely on shutdown. b=219523 r=bryner sr=blizzard

git-svn-id: svn://10.0.0.236/trunk@147284 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dbaron%dbaron.org
2003-09-25 05:36:25 +00:00
parent a61bd135a2
commit ed90ee6110
2 changed files with 26 additions and 3 deletions

View File

@@ -41,6 +41,8 @@
#include "nsDrawingSurfaceGTK.h"
#include "gtkdrawing.h"
#include "nsIObserverService.h"
#include "nsIServiceManager.h"
#include "nsIFrame.h"
#include "nsIPresShell.h"
#include "nsIDocument.h"
@@ -57,7 +59,7 @@
#include <gdk/gdkx.h>
NS_IMPL_ISUPPORTS1(nsNativeThemeGTK, nsITheme)
NS_IMPL_ISUPPORTS2(nsNativeThemeGTK, nsITheme, nsIObserver)
static int gLastXError;
@@ -68,6 +70,11 @@ nsNativeThemeGTK::nsNativeThemeGTK()
return;
}
// We have to call moz_gtk_shutdown before the event loop stops running.
nsCOMPtr<nsIObserverService> obsServ =
do_GetService("@mozilla.org/observer-service;1");
obsServ->AddObserver(this, "quit-application", PR_FALSE);
mDisabledAtom = do_GetAtom("disabled");
mCheckedAtom = do_GetAtom("checked");
mSelectedAtom = do_GetAtom("selected");
@@ -90,7 +97,20 @@ nsNativeThemeGTK::nsNativeThemeGTK()
}
nsNativeThemeGTK::~nsNativeThemeGTK() {
moz_gtk_shutdown();
}
NS_IMETHODIMP
nsNativeThemeGTK::Observe(nsISupports *aSubject, const char *aTopic,
const PRUnichar *aData)
{
if (!nsCRT::strcmp(aTopic, "quit-application")) {
moz_gtk_shutdown();
} else {
NS_NOTREACHED("unexpected topic");
return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}
static void GetPrimaryPresShell(nsIFrame* aFrame, nsIPresShell** aResult)

View File

@@ -39,14 +39,17 @@
#include "nsITheme.h"
#include "nsCOMPtr.h"
#include "nsIAtom.h"
#include "nsIObserver.h"
#include <gtk/gtkwidget.h>
#include "gtkdrawing.h"
class nsNativeThemeGTK: public nsITheme {
class nsNativeThemeGTK: public nsITheme, public nsIObserver {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
// The nsITheme interface.
NS_IMETHOD DrawWidgetBackground(nsIRenderingContext* aContext,
nsIFrame* aFrame, PRUint8 aWidgetType,