Add missing calls to PR_UnloadLibrary (excluding XPCOM component loader and nsPluginsDir*). b=374332 r=bsmedberg

This commit is contained in:
dbaron@dbaron.org 2007-04-15 15:22:58 -07:00
Родитель d3b46055fb
Коммит 9b013dc30a
20 изменённых файлов: 175 добавлений и 37 удалений

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

@ -51,6 +51,7 @@
typedef GType (* AtkGetTypeType) (void);
GType g_atk_hyperlink_impl_type = G_TYPE_INVALID;
static PRBool sATKChecked = PR_FALSE;
static PRLibrary *sATKLib = nsnull;
static PRBool sInitialized = PR_FALSE;
static const char sATKLibName[] = "libatk-1.0.so.0";
static const char sATKHyperlinkImplGetTypeSymbol[] = "atk_hyperlink_impl_get_type";
@ -567,6 +568,7 @@ NS_IMETHODIMP nsAppRootAccessible::Init()
// an exit function registered will take care of it
// if (sAtkBridge.shutdown)
// (*sAtkBridge.shutdown)();
PR_UnloadLibrary(sAtkBridge.lib);
sAtkBridge.lib = NULL;
sAtkBridge.init = NULL;
sAtkBridge.shutdown = NULL;
@ -577,10 +579,15 @@ NS_IMETHODIMP nsAppRootAccessible::Init()
// 2) We need it to avoid assert in spi_atk_tidy_windows
// if (sGail.shutdown)
// (*sGail.shutdown)();
PR_UnloadLibrary(sGail.lib);
sGail.lib = NULL;
sGail.init = NULL;
sGail.shutdown = NULL;
}
if (sATKLib) {
PR_UnloadLibrary(sATKLib);
sATKLib = nsnull;
}
}
NS_IMETHODIMP nsAppRootAccessible::GetName(nsAString& _retval)
@ -820,9 +827,9 @@ nsAppRootAccessible *
nsAppRootAccessible::Create()
{
if (!sATKChecked) {
PRLibrary *atkLib = PR_LoadLibrary(sATKLibName);
if (atkLib) {
AtkGetTypeType pfn_atk_hyperlink_impl_get_type = (AtkGetTypeType) PR_FindFunctionSymbol(atkLib, sATKHyperlinkImplGetTypeSymbol);
sATKLib = PR_LoadLibrary(sATKLibName);
if (sATKLib) {
AtkGetTypeType pfn_atk_hyperlink_impl_get_type = (AtkGetTypeType) PR_FindFunctionSymbol(sATKLib, sATKHyperlinkImplGetTypeSymbol);
if (pfn_atk_hyperlink_impl_get_type) {
g_atk_hyperlink_impl_type = pfn_atk_hyperlink_impl_get_type();
}

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

@ -270,4 +270,11 @@ InitNegotiateAuth(nsIModule *self)
#define InitNegotiateAuth nsnull
#endif
NS_IMPL_NSGETMODULE_WITH_CTOR(nsAuthModule, components, InitNegotiateAuth)
PR_STATIC_CALLBACK(void)
DestroyNegotiateAuth(nsIModule *self)
{
nsAuthGSSAPI::Shutdown();
}
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(nsAuthModule, components,
InitNegotiateAuth, DestroyNegotiateAuth)

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

@ -103,7 +103,7 @@ static const char *gssFuncStr[] = {
static PRFuncPtr gssFunPtr[gssFuncItems];
static PRBool gssNativeImp = PR_TRUE;
static PRBool gssFunInit = PR_FALSE;
static PRLibrary* gssLibrary = nsnull;
#define gss_display_status_ptr ((gss_display_status_type)*gssFunPtr[0])
#define gss_init_sec_context_ptr ((gss_init_sec_context_type)*gssFunPtr[1])
@ -223,7 +223,7 @@ gssInit()
}
#endif
gssFunInit = PR_TRUE;
gssLibrary = lib;
return NS_OK;
}
@ -242,7 +242,7 @@ LogGssError(OM_uint32 maj_stat, OM_uint32 min_stat, const char *prefix)
nsCAutoString errorStr;
errorStr.Assign(prefix);
if (!gssFunInit)
if (!gssLibrary)
return;
errorStr += ": ";
@ -296,7 +296,7 @@ nsAuthGSSAPI::nsAuthGSSAPI(pType package)
mComplete = PR_FALSE;
if (!gssFunInit && NS_FAILED(gssInit()))
if (!gssLibrary && NS_FAILED(gssInit()))
return;
mCtx = GSS_C_NO_CONTEXT;
@ -340,7 +340,7 @@ nsAuthGSSAPI::nsAuthGSSAPI(pType package)
void
nsAuthGSSAPI::Reset()
{
if (gssFunInit && mCtx != GSS_C_NO_CONTEXT) {
if (gssLibrary && mCtx != GSS_C_NO_CONTEXT) {
OM_uint32 minor_status;
gss_delete_sec_context_ptr(&minor_status, &mCtx, GSS_C_NO_BUFFER);
}
@ -348,6 +348,15 @@ nsAuthGSSAPI::Reset()
mComplete = PR_FALSE;
}
/* static */ void
nsAuthGSSAPI::Shutdown()
{
if (gssLibrary) {
PR_UnloadLibrary(gssLibrary);
gssLibrary = nsnull;
}
}
NS_IMPL_ISUPPORTS1(nsAuthGSSAPI, nsIAuthModule)
NS_IMETHODIMP
@ -365,7 +374,7 @@ nsAuthGSSAPI::Init(const char *serviceName,
LOG(("entering nsAuthGSSAPI::Init()\n"));
if (!gssFunInit)
if (!gssLibrary)
return NS_ERROR_NOT_INITIALIZED;
mServiceName = serviceName;
@ -390,7 +399,7 @@ nsAuthGSSAPI::GetNextToken(const void *inToken,
LOG(("entering nsAuthGSSAPI::GetNextToken()\n"));
if (!gssFunInit)
if (!gssLibrary)
return NS_ERROR_NOT_INITIALIZED;
// If they've called us again after we're complete, reset to start afresh.

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

@ -60,6 +60,8 @@ public:
nsAuthGSSAPI(pType package);
static void Shutdown();
private:
~nsAuthGSSAPI() { Reset(); }

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

@ -610,6 +610,8 @@ GConfProxy::~GConfProxy()
(void)mObservers->EnumerateForwards(gconfDeleteObserver, nsnull);
delete mObservers;
}
PR_UnloadLibrary(mGConfLib);
}
PRBool

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

@ -56,10 +56,11 @@
#include "gfxPlatformGtk.h"
// Glue to avoid build/runtime dependencies on Pango > 1.6
#ifndef THEBES_USE_PANGO_CAIRO
static gboolean
(* PTR_pango_font_description_get_size_is_absolute)(PangoFontDescription*)
= nsnull;
static PRLibrary *gPangoLib = nsnull;
static void InitPangoLib()
{
@ -68,15 +69,23 @@ static void InitPangoLib()
return;
initialized = PR_TRUE;
PRLibrary* lib = PR_LoadLibrary("libpango-1.0.so");
if (!lib)
gPangoLib = PR_LoadLibrary("libpango-1.0.so");
if (!gPangoLib)
return;
PTR_pango_font_description_get_size_is_absolute =
(gboolean (*)(PangoFontDescription*))
PR_FindFunctionSymbol(lib, "pango_font_description_get_size_is_absolute");
PR_FindFunctionSymbol(gPangoLib,
"pango_font_description_get_size_is_absolute");
}
// leak lib deliberately
static void
ShutdownPangoLib()
{
if (gPangoLib) {
PR_UnloadLibrary(gPangoLib);
gPangoLib = nsnull;
}
}
static gboolean
@ -89,6 +98,21 @@ MOZ_pango_font_description_get_size_is_absolute(PangoFontDescription *desc)
// In old versions of pango, this was always false.
return PR_FALSE;
}
#else
static inline void InitPangoLib()
{
}
static inline void ShutdownPangoLib()
{
}
static inline gboolean
MOZ_pango_font_description_get_size_is_absolute(PangoFontDescription *desc)
{
pango_font_description_get_size_is_absolute(desc);
}
#endif
#define DEFAULT_PIXEL_FONT_SIZE 16.0f
@ -181,6 +205,11 @@ nsSystemFontsGTK2::nsSystemFontsGTK2()
gtk_widget_destroy(window); // no unref, windows are different
}
nsSystemFontsGTK2::~nsSystemFontsGTK2()
{
ShutdownPangoLib();
}
nsresult
nsSystemFontsGTK2::GetSystemFontInfo(GtkWidget *aWidget, nsString *aFontName,
gfxFontStyle *aFontStyle) const

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

@ -45,6 +45,7 @@ class nsSystemFontsGTK2
{
public:
nsSystemFontsGTK2();
~nsSystemFontsGTK2();
nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName,
gfxFontStyle *aFontStyle) const;

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

@ -65,6 +65,8 @@ public:
const gfxFontStyle *aFontStyle);
virtual ~gfxPangoFont ();
static void Shutdown();
virtual const gfxFont::Metrics& GetMetrics();
PangoFontDescription *GetPangoFontDescription() { RealizeFont(); return mPangoFontDesc; }

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

@ -37,6 +37,7 @@
#include "gfxBeOSPlatform.h"
#include "gfxFontconfigUtils.h"
#include "gfxPangoFonts.h"
#include "gfxImageSurface.h"
#include "gfxBeOSSurface.h"
@ -54,6 +55,8 @@ gfxBeOSPlatform::~gfxBeOSPlatform()
gfxFontconfigUtils::Shutdown();
sFontconfigUtils = nsnull;
gfxPangoFont::Shutdown();
#if 0
// It would be nice to do this (although it might need to be after
// the cairo shutdown that happens in ~gfxPlatform). It even looks

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

@ -196,6 +196,7 @@ gfxPangoFontGroup::Copy(const gfxFontStyle *aStyle)
static void
(* PTR_pango_font_description_set_absolute_size)(PangoFontDescription*, double)
= nsnull;
static PRLibrary *gPangoLib = nsnull;
static void InitPangoLib()
{
@ -206,17 +207,16 @@ static void InitPangoLib()
g_type_init();
PRLibrary *lib = PR_LoadLibrary("libpango-1.0.so");
if (!lib)
gPangoLib = PR_LoadLibrary("libpango-1.0.so");
if (!gPangoLib)
return;
PTR_pango_font_description_set_absolute_size =
(void (*)(PangoFontDescription*, double))
PR_FindFunctionSymbol(lib, "pango_font_description_set_absolute_size");
PR_FindFunctionSymbol(gPangoLib,
"pango_font_description_set_absolute_size");
// leak lib deliberately
lib = nsnull;
PRLibrary *lib = nsnull;
int *xft_max_freetype_files_ptr = nsnull;
xft_max_freetype_files_ptr = (int*) PR_FindSymbolAndLibrary("XftMaxFreeTypeFiles", &lib);
if (xft_max_freetype_files_ptr && *xft_max_freetype_files_ptr < 50)
@ -225,6 +225,15 @@ static void InitPangoLib()
PR_UnloadLibrary(lib);
}
static void
ShutdownPangoLib()
{
if (gPangoLib) {
PR_UnloadLibrary(gPangoLib);
gPangoLib = nsnull;
}
}
static void
MOZ_pango_font_description_set_absolute_size(PangoFontDescription *desc,
double size)
@ -238,11 +247,15 @@ MOZ_pango_font_description_set_absolute_size(PangoFontDescription *desc,
}
}
#else
static void InitPangoLib()
static inline void InitPangoLib()
{
}
static void
static inline void ShutdownPangoLib()
{
}
static inline void
MOZ_pango_font_description_set_absolute_size(PangoFontDescription *desc, double size)
{
pango_font_description_set_absolute_size(desc, size);
@ -271,6 +284,12 @@ gfxPangoFont::~gfxPangoFont()
cairo_scaled_font_destroy(mCairoFont);
}
/* static */ void
gfxPangoFont::Shutdown()
{
ShutdownPangoLib();
}
static PangoStyle
ThebesStyleToPangoStyle (const gfxFontStyle *fs)
{

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

@ -42,6 +42,7 @@
#include "gfxPlatformGtk.h"
#include "gfxFontconfigUtils.h"
#include "gfxPangoFonts.h"
#include "cairo.h"
#include <gtk/gtk.h>
@ -92,6 +93,9 @@ gfxPlatformGtk::~gfxPlatformGtk()
{
gfxFontconfigUtils::Shutdown();
sFontconfigUtils = nsnull;
gfxPangoFont::Shutdown();
#ifndef THEBES_USE_PANGO_CAIRO
pango_xft_shutdown_display(GDK_DISPLAY(), 0);
#endif

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

@ -102,14 +102,18 @@ static void
CleanUp()
{
// Unload all libraries
if (gnomeLib)
if (gnomeLib) {
PR_UnloadLibrary(gnomeLib);
if (gconfLib)
gnomeLib = nsnull;
}
if (gconfLib) {
PR_UnloadLibrary(gconfLib);
if (vfsLib)
gconfLib = nsnull;
}
if (vfsLib) {
PR_UnloadLibrary(vfsLib);
gnomeLib = gconfLib = vfsLib = nsnull;
vfsLib = nsnull;
}
}
static PRLibrary *

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

@ -124,6 +124,15 @@ nsSound::Init()
return NS_OK;
}
/* static */ void
nsSound::Shutdown()
{
if (elib) {
PR_UnloadLibrary(elib)
elib = nsnull;
}
}
#define GET_WORD(s, i) (s[i+1] << 8) | s[i]
#define GET_DWORD(s, i) (s[i+3] << 24) | (s[i+2] << 16) | (s[i+1] << 8) | s[i]

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

@ -53,6 +53,8 @@ class nsSound : public nsISound,
nsSound();
virtual ~nsSound();
static void Shutdown();
NS_DECL_ISUPPORTS
NS_DECL_NSISOUND
NS_DECL_NSISTREAMLOADEROBSERVER

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

@ -68,6 +68,7 @@ NS_IMPL_ISUPPORTS1(nsIdleServiceGTK, nsIIdleService)
nsIdleServiceGTK::nsIdleServiceGTK()
: mXssInfo(nsnull)
{
NS_ASSERTION(!xsslib, "created two instances of the idle service");
#ifdef PR_LOGGING
if (!sIdleLog)
sIdleLog = PR_NewLogModule("nsIIdleService");
@ -103,8 +104,10 @@ nsIdleServiceGTK::~nsIdleServiceGTK()
{
if (mXssInfo)
XFree(mXssInfo);
if (xsslib)
if (xsslib) {
PR_UnloadLibrary(xsslib);
xsslib = nsnull;
}
}
NS_IMETHODIMP

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

@ -95,7 +95,7 @@ nsSound::~nsSound()
{
/* see above comment */
if (esdref != -1) {
EsdCloseType EsdClose = (EsdCloseType) PR_FindSymbol(elib, "esd_close");
EsdCloseType EsdClose = (EsdCloseType) PR_FindFunctionSymbol(elib, "esd_close");
(*EsdClose)(esdref);
esdref = -1;
}
@ -117,7 +117,7 @@ nsSound::Init()
elib = PR_LoadLibrary("libesd.so.0");
if (!elib) return NS_ERROR_FAILURE;
EsdOpenSound = (EsdOpenSoundType) PR_FindSymbol(elib, "esd_open_sound");
EsdOpenSound = (EsdOpenSoundType) PR_FindFunctionSymbol(elib, "esd_open_sound");
if (!EsdOpenSound)
return NS_ERROR_FAILURE;
@ -132,6 +132,15 @@ nsSound::Init()
return NS_OK;
}
/* static */ void
nsSound::Shutdown()
{
if (elib) {
PR_UnloadLibrary(elib);
elib = nsnull;
}
}
#define GET_WORD(s, i) (s[i+1] << 8) | s[i]
#define GET_DWORD(s, i) (s[i+3] << 24) | (s[i+2] << 16) | (s[i+1] << 8) | s[i]
@ -259,8 +268,8 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
/* open up connection to esd */
EsdPlayStreamType EsdPlayStream =
(EsdPlayStreamType) PR_FindSymbol(elib,
"esd_play_stream");
(EsdPlayStreamType) PR_FindFunctionSymbol(elib,
"esd_play_stream");
// XXX what if that fails? (Bug 241738)
mask = ESD_PLAY | ESD_STREAM;
@ -298,9 +307,9 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
if (fd < 0) {
int *esd_audio_format = (int *) PR_FindSymbol(elib, "esd_audio_format");
int *esd_audio_rate = (int *) PR_FindSymbol(elib, "esd_audio_rate");
EsdAudioOpenType EsdAudioOpen = (EsdAudioOpenType) PR_FindSymbol(elib, "esd_audio_open");
EsdAudioWriteType EsdAudioWrite = (EsdAudioWriteType) PR_FindSymbol(elib, "esd_audio_write");
EsdAudioCloseType EsdAudioClose = (EsdAudioCloseType) PR_FindSymbol(elib, "esd_audio_close");
EsdAudioOpenType EsdAudioOpen = (EsdAudioOpenType) PR_FindFunctionSymbol(elib, "esd_audio_open");
EsdAudioWriteType EsdAudioWrite = (EsdAudioWriteType) PR_FindFunctionSymbol(elib, "esd_audio_write");
EsdAudioCloseType EsdAudioClose = (EsdAudioCloseType) PR_FindFunctionSymbol(elib, "esd_audio_close");
*esd_audio_format = mask;
*esd_audio_rate = samples_per_sec;

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

@ -53,6 +53,8 @@ public:
nsSound();
virtual ~nsSound();
static void Shutdown();
NS_DECL_ISUPPORTS
NS_DECL_NSISOUND
NS_DECL_NSISTREAMLOADEROBSERVER

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

@ -280,6 +280,7 @@ PR_STATIC_CALLBACK(void)
nsWidgetGtk2ModuleDtor(nsIModule *aSelf)
{
nsFilePicker::Shutdown();
nsSound::Shutdown();
nsWindow::ReleaseGlobals();
nsAppShellShutdown(aSelf);
}

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

@ -1012,8 +1012,18 @@ nsWindow::SetCursor(imgIContainer* aCursor,
PRLibrary* lib;
_gdk_cursor_new_from_pixbuf = (_gdk_cursor_new_from_pixbuf_fn)
PR_FindFunctionSymbolAndLibrary("gdk_cursor_new_from_pixbuf", &lib);
if (lib) {
// We already link against GDK, so we can unload it.
PR_UnloadLibrary(lib);
lib = nsnull;
}
_gdk_display_get_default = (_gdk_display_get_default_fn)
PR_FindFunctionSymbolAndLibrary("gdk_display_get_default", &lib);
if (lib) {
// We already link against GDK, so we can unload it.
PR_UnloadLibrary(lib);
lib = nsnull;
}
sPixbufCursorChecked = PR_TRUE;
}
mCursor = nsCursor(-1);

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

@ -101,9 +101,22 @@ interface nsILocalFile : nsIFile
*/
attribute PRBool followLinks;
/**
* Return the result of PR_Open on the file. The caller is
* responsible for calling PR_Close on the result.
*/
[noscript] PRFileDescStar openNSPRFileDesc(in long flags, in long mode);
/**
* Return the result of fopen on the file. The caller is
* responsible for calling fclose on the result.
*/
[noscript] FILE openANSIFileDesc(in string mode);
/**
* Return the result of PR_LoadLibrary on the file. The caller is
* responsible for calling PR_UnloadLibrary on the result.
*/
[noscript] PRLibraryStar load();
readonly attribute PRInt64 diskSpaceAvailable;