[Issue 3442] New: scope(exit) Problem
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 26 04:00:33 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3442
Summary: scope(exit) Problem
Product: D
Version: 2.035
Platform: x86
OS/Version: Windows
Status: NEW
Severity: regression
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: moi at vermi.fr
--- Comment #0 from Vermi <moi at vermi.fr> 2009-10-26 04:00:32 PDT ---
I don't know if it's really a dmd bug or it's a windows bug, because I made
several tests and I don't really understand where is the error. Here is the
code : (Working with earlier version of dmd (2.022 if I remember well) :
protected bool _onPaint(PAINTSTRUCT paintStr)
{
int oldMode = SetBkMode(paintStr.hdc, TRANSPARENT);
scope(exit)
{
SetBkMode(paintStr.hdc, oldMode);
MessageBoxA(null, "tic", "tic", MB_OK);
}
// Some code
return true;
}
If the function return without exception, the code in the scope statement is
properly executed and functionnal, the Background Mode for the DC is restored
to OPAQUE (it's original value).
If an exception is thrown ( with the code : (cast(Object)null).toString() for
example ), The MessageBox show, but the background mode the DC is not restored,
and the background simply disapear in the window.
I made some tests on the return value of SetBkMode :
If an exception is thrown, SetBkMode return OPAQUE (wich is strange, it should
return TRANSPARENT according to msdn).
If no exception is thrown, SetBkMode return 0, wich is strange too, because 0
means error. I don't know what to think.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list