Thread overview
[Issue 6158] New: winsamp and dhry samples need an update
Jun 15, 2011
Andrej Mitrovic
Jun 15, 2011
Andrej Mitrovic
Jun 15, 2011
Walter Bright
Jun 15, 2011
Andrej Mitrovic
Jun 18, 2011
Walter Bright
June 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6158

           Summary: winsamp and dhry samples need an update
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-06-14 18:20:05 PDT ---
winsamp:

- WinMain was catching Exceptions instead of Throwable. Throwable should be caught in order to demonstrate the creation of a message box on a null dereference.

- With optimizations On the compiler is smart enough to detect that a null dereference is in play and it denies compilation. To trick the compiler I've made a pointer variable in module scope which is null-initialized.

- The example was leaking GDI objects. Here's a tip:
In the task manager, select View>Select Columns> and put a check next to GDI
Objects. On the old example try resizing the window and witness the holy grail
of GDI leakage!

- The example used old-style prototypes of runtime initialization functions. I've replaced this with an import to cure.runtime and used that inside of WinMain.

- Added a pragma to gdi32.lib, and a note that the user can compile via "-L-Subsystem:Windows". .def files are rarely required unless you're doing something super-special like renaming symbols.

- The window size was too small to even show the message.

- The switch statements were missing default cases. The example wouldn't compile in the next release.

The updated sample is in the attachment. Tested on XP32 and Win7.

dhry: Just a missing default case.

Finally, why aren't the samples on Github anywhere?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6158



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-06-14 18:21:23 PDT ---
Created an attachment (id=1000)
description

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6158


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2011-06-15 00:55:14 PDT ---
The samples are now on github!

https://github.com/D-Programming-Language/dmd/tree/master/samples

So now pull requests can be done.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6158



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-06-15 08:58:03 PDT ---
Yay, thanks a bunch!! I'll make a pull later.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 18, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6158


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2011-06-17 21:11:40 PDT ---
https://github.com/D-Programming-Language/dmd/commit/5315dcd82a74c196e21887212bb58a0327d75235

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------