From e4bd0c3b01562d2a05a721743a5ec58f5049c58d Mon Sep 17 00:00:00 2001 From: "saari%netscape.com" Date: Sat, 7 Nov 1998 01:45:03 +0000 Subject: [PATCH] Mac only change. Don't unlock GDeviceHandles. Fixed. Don't dereference unlocked handles. Fixed. --- gfx/src/mac/nsDeviceContextMac.cpp | 17 ++++++++++++++--- widget/src/mac/nsDeviceContextMac.cpp | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/gfx/src/mac/nsDeviceContextMac.cpp b/gfx/src/mac/nsDeviceContextMac.cpp index 307f3e6466a8..0f4aae11227e 100644 --- a/gfx/src/mac/nsDeviceContextMac.cpp +++ b/gfx/src/mac/nsDeviceContextMac.cpp @@ -38,10 +38,18 @@ double pix_inch; NS_INIT_REFCNT(); - // see IM Imaging with Quickdraw, chapter 5. This is an imcomplete implementation + // see IM Imaging with Quickdraw, chapter 5. This is an incomplete implementation + + // cps - see technote + // Basically it says: don't unlock GDevice handles thegd = ::GetMainDevice(); - HLock((Handle)thegd); + SInt8 hState = ::HGetState ((Handle) thegd); + ::HLock((Handle)thegd); thepix = (**thegd).gdPMap; + + // Be sure to lock the PixMapHandle before dereferencing it + SInt8 PixMapHState = ::HGetState ((Handle) thepix); + ::HLock((Handle)thepix); pix_inch = Fix2X((**thepix).hRes); mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(72); @@ -49,7 +57,10 @@ double pix_inch; mDepth = (**thepix).pixelSize; - HUnlock((Handle)thegd); + ::HSetState ((Handle)thepix,PixMapHState); + // cps - Unlocking GDeviceHandles is a no - no. See above. + //::HUnlock((Handle)thegd); + ::HSetState ((Handle)thegd,hState); } //------------------------------------------------------------------------ diff --git a/widget/src/mac/nsDeviceContextMac.cpp b/widget/src/mac/nsDeviceContextMac.cpp index 307f3e6466a8..0f4aae11227e 100644 --- a/widget/src/mac/nsDeviceContextMac.cpp +++ b/widget/src/mac/nsDeviceContextMac.cpp @@ -38,10 +38,18 @@ double pix_inch; NS_INIT_REFCNT(); - // see IM Imaging with Quickdraw, chapter 5. This is an imcomplete implementation + // see IM Imaging with Quickdraw, chapter 5. This is an incomplete implementation + + // cps - see technote + // Basically it says: don't unlock GDevice handles thegd = ::GetMainDevice(); - HLock((Handle)thegd); + SInt8 hState = ::HGetState ((Handle) thegd); + ::HLock((Handle)thegd); thepix = (**thegd).gdPMap; + + // Be sure to lock the PixMapHandle before dereferencing it + SInt8 PixMapHState = ::HGetState ((Handle) thepix); + ::HLock((Handle)thepix); pix_inch = Fix2X((**thepix).hRes); mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(72); @@ -49,7 +57,10 @@ double pix_inch; mDepth = (**thepix).pixelSize; - HUnlock((Handle)thegd); + ::HSetState ((Handle)thepix,PixMapHState); + // cps - Unlocking GDeviceHandles is a no - no. See above. + //::HUnlock((Handle)thegd); + ::HSetState ((Handle)thegd,hState); } //------------------------------------------------------------------------