September 17, 2012
On 16/09/2012 23:32, cal wrote:
> On Sunday, 16 September 2012 at 22:08:53 UTC, deed wrote:
>> Exactly. I couldn't remember seeing this error before.
>
> I've only used the dsource Win32 bindings, because there is often stuff
> missing from the phobos ones:
>
> http://www.dsource.org/projects/bindings/wiki/WindowsApi
>
> But I don't understand the reason for the change to the phobos bindings.
> Like someone above said, the easiest solution is to wrap your wndProc
> body in a try/catch.

A window proc is being called directly by Win32 which expects that the wndproc is a strict C function. You MUST NOT allow a D exception to propagate out of the wndproc (or indeed any other Win32 callback function) as the Win32 calling code has no idea how to process it and you'll just get a crash.

Also the crash address that you get will be in a windows system dll which will just confuse matters when you try and debug the problem.

So yes, the correct thing to do is wrap all D code in try catch block.

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
September 17, 2012
On 9/17/12, Simon <s.d.hammett@gmail.com> wrote:
> You MUST NOT allow a D exception to
> propagate out of the wndproc (or indeed any other Win32 callback
> function) as the Win32 calling code has no idea how to process it and
> you'll just get a crash.
>

That's just complete and utter bullshit. A try/catch can be set in WinMain, and any thrown exceptions in WndProc will propagate there.

Code:
http://dpaste.dzfl.pl/84293982

Screenshot:
http://i.imgur.com/r5wJh.png
September 18, 2012
On 17/09/2012 23:13, Andrej Mitrovic wrote:
> On 9/17/12, Simon <s.d.hammett@gmail.com> wrote:
>> You MUST NOT allow a D exception to
>> propagate out of the wndproc (or indeed any other Win32 callback
>> function) as the Win32 calling code has no idea how to process it and
>> you'll just get a crash.
>>
>
> That's just complete and utter bullshit. A try/catch can be set in
> WinMain, and any thrown exceptions in WndProc will propagate there.
>
> Code:
> http://dpaste.dzfl.pl/84293982
>
> Screenshot:
> http://i.imgur.com/r5wJh.png
>

Hmm, didn't work for me when I ported the Atl windowing stuff.
And it doesn't work in VC++.

Have they changed D exception mechanism to use Structured exception handling?

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
September 18, 2012
On 9/18/12, Simon <s.d.hammett@gmail.com> wrote:
>> That's just complete and utter bullshit. A try/catch can be set in WinMain, and any thrown exceptions in WndProc will propagate there.
>>
>> Code:
>> http://dpaste.dzfl.pl/84293982
>>
>> Screenshot:
>> http://i.imgur.com/r5wJh.png
>>
>
> Hmm, didn't work for me when I ported the Atl windowing stuff. And it doesn't work in VC++.
>
> Have they changed D exception mechanism to use Structured exception handling?

I think Don has been busy doing that. MSDN says the exceptions are
passed to "higher-level handlers":
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633573%28v=vs.85%29.aspx

I did have to compile with -g and run the .exe through cv2pdb before the stacktrace printed proper files and lines.

Also sorry for my harsh words I was in a bad mood yesterday. :)
September 18, 2012
On 18/09/2012 18:47, Andrej Mitrovic wrote:
> On 9/18/12, Simon <s.d.hammett@gmail.com> wrote:
>>> That's just complete and utter bullshit. A try/catch can be set in
>>> WinMain, and any thrown exceptions in WndProc will propagate there.
>>>
>>> Code:
>>> http://dpaste.dzfl.pl/84293982
>>>
>>> Screenshot:
>>> http://i.imgur.com/r5wJh.png
>>>
>>
>> Hmm, didn't work for me when I ported the Atl windowing stuff.
>> And it doesn't work in VC++.
>>
>> Have they changed D exception mechanism to use Structured exception
>> handling?
>
> I think Don has been busy doing that. MSDN says the exceptions are
> passed to "higher-level handlers":
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms633573%28v=vs.85%29.aspx
>
> I did have to compile with -g and run the .exe through cv2pdb before
> the stacktrace printed proper files and lines.
>
> Also sorry for my harsh words I was in a bad mood yesterday. :)
>

No worries; I'm sure that the main reason (apart from pron) why the internet is so popular is just for people to vent their spleen!

I've just gone though my ATL port and taken out the special exception handling I had in and it just works.

It's even got a full stack backtrace, w/ DMD 2.058 :)

Cool. I never did like that special handling.

Though to go back to the OPs question then, that nothrow attribute is clearly erogenous now. Mind you I've never used the phobos provided win32 bindings as they were pants.

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
September 18, 2012
On 9/18/12, Simon <s.d.hammett@gmail.com> wrote:
> No worries; I'm sure that the main reason (apart from pron)

Why, I've not a clue what you speaketh of!

> Though to go back to the OPs question then, that nothrow attribute is clearly erogenous now.

Also I would assume that adding a try/catch in every wndproc would slow down the message pump. Maybe not by much but that function is called often enough to matter.

> Mind you I've never used the phobos provided
> win32 bindings as they were pants.

They are pants, these are better: http://www.dsource.org/projects/bindings/wiki/WindowsApi

I used them for: https://github.com/AndrejMitrovic/DWinProgramming
1 2
Next ›   Last »