nanogui: Thread: EndPaint free Pen and Brush !


[<<] [<] Page 1 of 1 [>] [>>]
Subject: EndPaint free Pen and Brush !
From: ####@####.####
Date: 20 Dec 2001 09:09:01 -0000
Message-Id: <GOMXBP$IXd4ZOE3EKp7zSmLuLf5IPbCuTP2qGT53aFY4uFGsmVGxktO86J@voila.fr>

Hello,

I catch a strange behaviour between true Win32 and microwindow.
I BeginPaint
I create Pen by my self : CreatePen
I select it in a DC : SelectObject
I draw ...
I EndPaint, and then the Pen is released !!!

In fact EnPaint -> ReleaseDC -> free the Pen
But the MSVC++ Doc specify that a CreatePen is release by the user
with a DeleteObject.

So I think we must not do it in ReleaseDC.
Here is the new ReleaseDC is use :

/* free a DC allocated from GetDC*/
int WINAPI 
ReleaseDC(HWND hwnd, HDC hdc)
{
	/* don't delete a memory dc on release*/
	if(!hdc || (hdc->psd->flags&PSF_MEMORY))
		return 0;

	if(hdc == cliphdc)
		cliphdc = NULL;

	/* handle private DC's*/
	if(hdc->hwnd->owndc && !(hdc->flags & DCX_WINDOW))
		return 1;

//--->	DeleteObject((HBRUSH)hdc->brush); <----
//--->	DeleteObject((HPEN)hdc->pen); <----
#if 0 /* don't delete font resources on ReleaseDC... use DeleteObject instead*/
	DeleteObject((HFONT)hdc->font);
#endif
	DeleteObject((HRGN)hdc->region);
	/*
	 * We can only select a bitmap in a memory DC,
	 * so bitmaps aren't released except through DeleteDC.
	 */
	DeleteObject((HBITMAP)hdc->bitmap);
	GdItemFree(hdc);
	return 1;
}

BUT i don't know if this modification affect other part of the
MW's code.

What do you think about it ?

Damien
Alpha3i TSI's Team

____________________________________________________________
Faites un voeu et puis Voila ! www.voila.fr 
Avec Voila Mail, consultez vos e-mails sur votre mobile Wap. 

Subject: Re: [nanogui] EndPaint free Pen and Brush !
From: "Greg Haerr" ####@####.####
Date: 20 Dec 2001 18:30:22 -0000
Message-Id: <032b01c18984$0d513a00$3aba46a6@xmission.com>

: I EndPaint, and then the Pen is released !!!
: So I think we must not do it in ReleaseDC.

I think you are correct.  For some reason, I was thinking
that releasing a DC should discard it's selected resources,
but it seems MS doesn't do that.  I'll add your fix to the tree.

The only issue could be that programs create resources that 
aren't released.  Microwindows doesn't currently check for this.

Thanks!

Regards,

Greg



[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.