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

This commit is contained in:
dbaron%dbaron.org 2003-09-25 05:36:25 +00:00
Родитель be8aa3c6f1
Коммит ce39727b01
2 изменённых файлов: 26 добавлений и 3 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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,