Fixing crash in Tester plugin after it chooses not to unload -- not part of the build

This commit is contained in:
av%netscape.com 2002-03-31 05:59:15 +00:00
parent 0bd79203b3
commit e4c2edd119
5 changed files with 33 additions and 3 deletions

View File

@ -59,7 +59,8 @@ CLogger::CLogger(LPSTR szTarget) :
m_bBlockLogToFrame(FALSE),
m_pStream(NULL),
m_dwStartTime(0xFFFFFFFF),
m_iStringDataWrap(LOGGER_DEFAULT_STRING_WRAP)
m_iStringDataWrap(LOGGER_DEFAULT_STRING_WRAP),
m_bStale(FALSE)
{
if(szTarget != NULL)
strcpy(m_szTarget, szTarget);
@ -329,3 +330,13 @@ void CLogger::blockDumpToFrame(BOOL bBlock)
{
m_bBlockLogToFrame = bBlock;
}
void CLogger::markStale()
{
m_bStale = TRUE;
}
BOOL CLogger::isStale()
{
return m_bStale;
}

View File

@ -45,7 +45,7 @@
#include "logger.h"
CLogger * pLogger = NULL;
static char szTarget[] = "_npapi_Log";
static char szTarget[] = LOGGER_DEFAULT_TARGET;
NPNetscapeFuncs NPNFuncs;

View File

@ -44,6 +44,7 @@
extern CLogger * pLogger;
static char szINIFile[] = NPAPI_INI_FILE_NAME;
static char szTarget[] = LOGGER_DEFAULT_TARGET;
// here the plugin creates a plugin instance object which
// will be associated with this newly created NPP instance and
@ -67,6 +68,15 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, ch
}
instance->pdata = (void *)pPlugin;
// recreate logger if needed
if (!pLogger)
pLogger = new CLogger(szTarget);
else if (pLogger->isStale()) {
delete pLogger;
pLogger = new CLogger(szTarget);
}
pLogger->associate(pPlugin);
char szFileName[_MAX_PATH];
@ -106,6 +116,10 @@ Return:
DWORD dwTickReturn = XP_GetTickCount();
pLogger->appendToLog(action_npp_destroy, dwTickEnter, dwTickReturn, (DWORD)ret, (DWORD)instance, (DWORD)save);
pLogger->blockDumpToFrame(FALSE);
// mark logger stale as the dll can remain in memory with no NP_Shutdown called
// and then come back with NPP_New where we should recreate the logger
pLogger->markStale();
return ret;
}

View File

@ -44,7 +44,7 @@
extern CLogger * pLogger;
static char szINIFile[] = NPAPI_INI_FILE_NAME;
#ifdef XP_UNIX
static char szTarget[] = "_npapi_Log";
static char szTarget[] = LOGGER_DEFAULT_TARGET;
#endif
CPluginBase::CPluginBase(NPP pNPInstance, WORD wMode) :

View File

@ -61,6 +61,7 @@ private:
DWORD m_dwStartTime;
char m_szItemSeparator[80];
int m_iStringDataWrap;
BOOL m_bStale;
public:
CLogger(LPSTR szTarget = NULL);
@ -92,9 +93,13 @@ public:
void blockDumpToFrame(BOOL bBlock);
void closeLogToFile();
void markStale();
BOOL isStale();
};
#define LOGGER_DEFAULT_STRING_WRAP 32
#define LOGGER_DEFAULT_TARGET "_npapi_Log"
// Preferences profile stuff
#define SECTION_LOG "Log"