another part of the fix for bug 199170 - converting mac widget stuff over to static atoms

r=pinkerton, sr=sfraser
This commit is contained in:
alecf%netscape.com 2003-04-14 14:09:37 +00:00
Родитель b5b153abb8
Коммит 5e99cda65c
3 изменённых файлов: 13 добавлений и 26 удалений

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

@ -53,8 +53,7 @@
class nsWidgetAtoms {
public:
static void AddRefAtoms();
static void ReleaseAtoms();
static void RegisterAtoms();
/* Declare all atoms

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

@ -209,8 +209,6 @@ nsToolkit::nsToolkit() : mInited(false)
//-------------------------------------------------------------------------
nsToolkit::~nsToolkit()
{
nsWidgetAtoms::ReleaseAtoms();
/* StopPumping decrements a refcount on gEventQueueHandler; a prelude toward
stopping event handling. This is not something you want to do unless you've
bloody well started event handling and incremented the refcount. That's
@ -235,7 +233,7 @@ NS_IMETHODIMP nsToolkit::Init(PRThread */*aThread*/)
if (gEventQueueHandler)
gEventQueueHandler->StartPumping();
nsWidgetAtoms::AddRefAtoms();
nsWidgetAtoms::RegisterAtoms();
mInited = true;

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

@ -37,32 +37,22 @@
* ***** END LICENSE BLOCK ***** */
#include "nsWidgetAtoms.h"
#include "nsStaticAtom.h"
#include "nsMemory.h"
#define WIDGET_ATOM(_name, _value) nsIAtom* nsWidgetAtoms::_name = 0;
#include "nsWidgetAtomList.h"
#undef WIDGET_ATOM
static const nsStaticAtom widget_atoms[] = {
// define storage for all atoms
#define WIDGET_ATOM(_name, _value) nsIAtom* nsWidgetAtoms::_name;
#define WIDGET_ATOM(_name, _value) { _value, &nsWidgetAtoms::_name },
#include "nsWidgetAtomList.h"
#undef WIDGET_ATOM
};
static nsrefcnt gRefCnt = 0;
void nsWidgetAtoms::RegisterAtoms() {
void nsWidgetAtoms::AddRefAtoms() {
if (gRefCnt == 0) {
// now register the atoms
#define WIDGET_ATOM(_name, _value) _name = NS_NewPermanentAtom(_value);
#include "nsWidgetAtomList.h"
#undef WIDGET_ATOM
}
++gRefCnt;
}
void nsWidgetAtoms::ReleaseAtoms() {
NS_PRECONDITION(gRefCnt != 0, "bad release of xul atoms");
if (--gRefCnt == 0) {
#define WIDGET_ATOM(_name, _value) NS_RELEASE(_name);
#include "nsWidgetAtomList.h"
#undef WIDGET_ATOM
}
NS_RegisterStaticAtoms(widget_atoms, NS_ARRAY_LENGTH(widget_atoms));
}