|
From: John M M. <jo...@us...> - 2003-10-03 19:02:10
|
Update of /cvsroot/squeak/squeak/platforms/Mac OS/vm
In directory sc8-pr-cvs1:/tmp/cvs-serv17699/squeak/platforms/Mac OS/vm
Modified Files:
sqMacNSPlugin.c
Log Message:
3.5.3b1 lock/unlock drawing only when browser gives us event time to avoid crash or draw failure in un-thread-safe IE. Rework how path to libraries are found, use network/system/user directories. Fix issue with disposal of memory on free, bug prevented that from happening.
Index: sqMacNSPlugin.c
===================================================================
RCS file: /cvsroot/squeak/squeak/platforms/Mac OS/vm/sqMacNSPlugin.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** sqMacNSPlugin.c 31 Jul 2003 13:22:47 -0000 1.11
--- sqMacNSPlugin.c 3 Oct 2003 19:02:06 -0000 1.12
***************
*** 236,239 ****
--- 236,240 ----
int FindIdleURLRequest(void);
int InitFilePaths(void);
+ int InitFilePathsViaDomain(SInt16 domain);
void InitURLRequestTable(void);
int IsPrefixedBy(char *s, char *prefix);
***************
*** 252,255 ****
--- 253,257 ----
int URLPostCreate(char *url, char *buffer, char * window,int semaIndex);
NP_Port *getNP_Port(void);
+ void waitAFewMilliseconds(void);
/*** Initialize/Shutdown ***/
***************
*** 299,302 ****
--- 301,307 ----
void NPP_Shutdown(void) {
+ #if defined ( __APPLE__ ) && defined ( __MACH__ )
+ pthread_mutex_unlock(&gEventDrawLock);
+ #endif
ExitCleanup();
}
***************
*** 364,375 ****
long i;
ExitCleanup();
- if (pluginArgCount != 0) {
- for(i=0;i<pluginArgCount;i++) {
- NPN_MemFree(pluginArgName[i]);
- NPN_MemFree(pluginArgValue[i]);
- }
- pluginArgCount = 0;
- }
return NPERR_NO_ERROR;
}
--- 369,376 ----
long i;
+ #if defined ( __APPLE__ ) && defined ( __MACH__ )
+ pthread_mutex_unlock(&gEventDrawLock);
+ #endif
ExitCleanup();
return NPERR_NO_ERROR;
}
***************
*** 416,419 ****
--- 417,423 ----
gThreadManager = true;
+ #if defined ( __APPLE__ ) && defined ( __MACH__ )
+ pthread_mutex_lock(&gEventDrawLock);
+ #endif
err = createNewThread();
if (err != noErr)
***************
*** 582,585 ****
--- 586,593 ----
Boolean rememberWindowOnce=true;
+ #if defined ( __APPLE__ ) && defined ( __MACH__ )
+ pthread_mutex_unlock(&gEventDrawLock);
+ #endif
+
if (rememberWindowOnce) { //Remember who the front window is
rememberWindowOnce = false;
***************
*** 691,694 ****
--- 699,705 ----
if (ignoreFirstEvent && getFullScreenFlag()) {
ignoreFirstEvent = false;
+ #if defined ( __APPLE__ ) && defined ( __MACH__ )
+ pthread_mutex_lock(&gEventDrawLock);
+ #endif
return true;
}
***************
*** 700,703 ****
--- 711,718 ----
} while (getFullScreenFlag());
+
+ #if defined ( __APPLE__ ) && defined ( __MACH__ )
+ pthread_mutex_lock(&gEventDrawLock);
+ #endif
return true;
}
***************
*** 1072,1076 ****
oldStWindow = stWindow;
#if TARGET_API_MAC_CARBON
! GetWindowGreatestAreaDevice((GrafPtr) FrontWindow(),kWindowContentRgn,&dominantGDevice,&windRect);
#else
dominantGDevice = getDominateDevice(stWindow,&windRect);
--- 1087,1091 ----
oldStWindow = stWindow;
#if TARGET_API_MAC_CARBON
! GetWindowGreatestAreaDevice((WindowPtr) FrontWindow(),kWindowContentRgn,&dominantGDevice,&windRect);
#else
dominantGDevice = getDominateDevice(stWindow,&windRect);
***************
*** 1122,1126 ****
/*** File and Access Paths ***/
! int InitFilePaths(void) {
short vRefNum;
char imageInPreferenceFolder[256];
--- 1137,1141 ----
/*** File and Access Paths ***/
! int InitFilePathsViaDomain(SInt16 domain) {
short vRefNum;
char imageInPreferenceFolder[256];
***************
*** 1135,1141 ****
/* get the path to the sytem folder preference area*/
! err = FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, &vRefNum, &dirID);
if (err != noErr) {
- strcpy(imageName,"Problems finding the System Preference folder");
return err;
}
--- 1150,1155 ----
/* get the path to the sytem folder preference area*/
! err = FindFolder(domain, kPreferencesFolderType, kDontCreateFolder, &vRefNum, &dirID);
if (err != noErr) {
return err;
}
***************
*** 1154,1160 ****
strcpy(imageName, vmPath);
strcat(imageName, shortImageName);
}
!
int IsPrefixedBy(char *s, char *prefix) {
--- 1168,1187 ----
strcpy(imageName, vmPath);
strcat(imageName, shortImageName);
+ return noErr;
}
! int InitFilePaths() {
! static const SInt16 domain[] = {kOnSystemDisk,kUserDomain, kLocalDomain, kNetworkDomain, kSystemDomain, 0};
! int error;
! SInt32 domainIndex=0;
!
! do {
! error = InitFilePathsViaDomain(domain[domainIndex]);
! if (error == noErr)
! return noErr;
! domainIndex++;
! } while (domain[domainIndex] != 0);
! return error;
! }
int IsPrefixedBy(char *s, char *prefix) {
***************
*** 1586,1589 ****
--- 1613,1623 ----
plugInShutdown();
ioSetFullScreenRestore();
+ if (pluginArgCount != 0) {
+ for(i=0;i<pluginArgCount;i++) {
+ NPN_MemFree(pluginArgName[i]);
+ NPN_MemFree(pluginArgValue[i]);
+ }
+ pluginArgCount = 0;
+ }
NPP_Initialize(); /* reset local variables */
ignoreFirstEvent=false;
***************
*** 1675,1676 ****
--- 1709,1735 ----
return !CaseInsensitiveMatch(lookFor,"file:");
}
+
+ #if defined ( __APPLE__ ) && defined ( __MACH__ )
+ pthread_mutex_t sleepLock;
+ pthread_cond_t sleepLockCondition;
+ void waitAFewMilliseconds()
+ {
+ static Boolean doInitialization=true;
+ const int realTimeToWait = 16;
+ struct timespec tspec;
+ int err;
+
+ if (doInitialization) {
+ doInitialization = false;
+ pthread_mutex_init(&sleepLock, NULL);
+ pthread_cond_init(&sleepLockCondition,NULL);
+ }
+
+ tspec.tv_sec= realTimeToWait / 1000;
+ tspec.tv_nsec= (realTimeToWait % 1000)*1000000;
+
+ err = pthread_mutex_lock(&sleepLock);
+ err = pthread_cond_timedwait_relative_np(&sleepLockCondition,&sleepLock,&tspec);
+ err = pthread_mutex_unlock(&sleepLock);
+ }
+ #endif
\ No newline at end of file
|