initialize the Rendering Context from a GrafPort to fix a crash on print

This commit is contained in:
pierre%netscape.com 1999-01-21 08:41:21 +00:00
parent 6da61fa838
commit abd275880c
4 changed files with 21 additions and 2 deletions

View File

@ -80,7 +80,7 @@ double pix_inch;
*/
NS_IMETHODIMP nsDeviceContextMac :: CreateRenderingContext(nsIRenderingContext *&aContext)
{
nsIRenderingContext *pContext;
nsRenderingContextMac *pContext;
nsresult rv;
GrafPtr thePort;

View File

@ -464,6 +464,24 @@ NS_IMETHODIMP nsRenderingContextMac::Init(nsIDeviceContext* aContext, nsDrawingS
//------------------------------------------------------------------------
// used by nsDeviceContextMac::CreateRenderingContext() for printing
nsresult nsRenderingContextMac::Init(nsIDeviceContext* aContext, GrafPtr aPort)
{
mContext = aContext;
NS_IF_ADDREF(mContext);
if (mOriginalSurface->GetPort() == nsnull)
mOriginalSurface->Init(aPort);
// select the surface
mFrontSurface->Init(aPort);
SelectDrawingSurface(mFrontSurface);
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac::SelectDrawingSurface(DrawingSurface* aSurface)
{
if (! aSurface)

View File

@ -111,6 +111,7 @@ public:
//locals
NS_IMETHOD SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD SetPortTextState();
nsresult Init(nsIDeviceContext* aContext, GrafPtr aPort);
protected:
void SelectDrawingSurface(DrawingSurface* aSurface);

View File

@ -80,7 +80,7 @@ double pix_inch;
*/
NS_IMETHODIMP nsDeviceContextMac :: CreateRenderingContext(nsIRenderingContext *&aContext)
{
nsIRenderingContext *pContext;
nsRenderingContextMac *pContext;
nsresult rv;
GrafPtr thePort;