Skip to content

Commit

Permalink
Merge pull request Rayerd#20 from shoo/add_nothrow
Browse files Browse the repository at this point in the history
Add nothrow
  • Loading branch information
Rayerd committed May 27, 2012
2 parents aba5eb6 + fe604e9 commit 6e0b9c4
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 179 deletions.
116 changes: 64 additions & 52 deletions win32/dfl/application.d
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ApplicationContext // docmain
}

/// ditto
final @property Form mainForm() // getter
final @property Form mainForm() nothrow // getter
{
return mform;
}
Expand Down Expand Up @@ -117,7 +117,7 @@ class ApplicationContext // docmain
}


private extern(Windows)
private extern(Windows) nothrow
{
alias UINT function(LPCWSTR lpPathName, LPCWSTR lpPrefixString, UINT uUnique,
LPWSTR lpTempFileName) GetTempFileNameWProc;
Expand Down Expand Up @@ -285,7 +285,7 @@ final class Application // docmain

/+
// ///
@property bool visualStyles() // getter
@property bool visualStyles() nothrow // getter
{
// IsAppThemed:
// "Do not call this function during DllMain or global objects contructors.
Expand Down Expand Up @@ -336,7 +336,7 @@ final class Application // docmain


///
@property bool messageLoop() // getter
@property bool messageLoop() nothrow // getter
{
return (threadFlags & TF.RUNNING) != 0;
}
Expand Down Expand Up @@ -595,7 +595,7 @@ final class Application // docmain


// Will be null if not in a successful Application.run.
package @property ApplicationContext context() // getter
package @property ApplicationContext context() nothrow // getter
{
return ctx;
}
Expand Down Expand Up @@ -871,53 +871,59 @@ final class Application // docmain


///
void onThreadException(DThrowable e)
void onThreadException(DThrowable e) nothrow
{
static bool except = false;

version(WINDOWS_HUNG_WORKAROUND)
try
{
version(WINDOWS_HUNG_WORKAROUND_NO_IGNORE)
static bool except = false;

version(WINDOWS_HUNG_WORKAROUND)
{
version(WINDOWS_HUNG_WORKAROUND_NO_IGNORE)
{
}
else
{
if(cast(WindowsHungDflException)e)
return;
}
}
else

if(except)
{
if(cast(WindowsHungDflException)e)
return;
cprintf("Error: %.*s\n", cast(int)getObjectString(e).length, getObjectString(e).ptr);

abort();
return;
}
}

if(except)
{
cprintf("Error: %.*s\n", cast(int)getObjectString(e).length, getObjectString(e).ptr);

abort();
return;
}

except = true;
//if(threadException.handlers.length)
if(threadException.hasHandlers)
{
threadException(typeid(Application), new ThreadExceptionEventArgs(e));
except = false;
return;
}
else
{
// No thread exception handlers, display a dialog.
if(showDefaultExceptionDialog(e))
except = true;
//if(threadException.handlers.length)
if(threadException.hasHandlers)
{
threadException(typeid(Application), new ThreadExceptionEventArgs(e));
except = false;
return;
}
else
{
// No thread exception handlers, display a dialog.
if(showDefaultExceptionDialog(e))
{
except = false;
return;
}
}
//except = false;

//throw e;
cprintf("Error: %.*s\n", cast(int)getObjectString(e).length, getObjectString(e).ptr);
//exitThread();
Environment.exit(EXIT_FAILURE);
}
catch (DThrowable e)
{
}
//except = false;

//throw e;
cprintf("Error: %.*s\n", cast(int)getObjectString(e).length, getObjectString(e).ptr);
//exitThread();
Environment.exit(EXIT_FAILURE);
}


Expand Down Expand Up @@ -1079,7 +1085,7 @@ final class Application // docmain
}

// Returns null if not found.
package Control lookupHwnd(HWND hwnd)
package Control lookupHwnd(HWND hwnd) nothrow
{
//if(hwnd in controls)
// return controls[hwnd];
Expand Down Expand Up @@ -1286,7 +1292,7 @@ final class Application // docmain
}


package void creatingControl(Control ctrl)
package void creatingControl(Control ctrl) nothrow
{
TlsSetValue(tlsControl, cast(Control*)ctrl);
}
Expand Down Expand Up @@ -1343,7 +1349,7 @@ final class Application // docmain
}

/// ditto
@property bool autoCollect() // getter
@property bool autoCollect() nothrow // getter
{
return gcinfo > 0;
}
Expand Down Expand Up @@ -1550,7 +1556,7 @@ final class Application // docmain
}
@property IMessageFilter[] filters() // getter
@property IMessageFilter[] filters() nothrow // getter
{
TlsFilterValue* val = cast(TlsFilterValue*)TlsGetValue(tlsFilter);
if(!val)
Expand All @@ -1568,14 +1574,14 @@ final class Application // docmain
}


@property HHOOK msghook() // getter
@property HHOOK msghook() nothrow // getter
{
return cast(HHOOK)TlsGetValue(tlsHook);
}
}


Control getCreatingControl()
Control getCreatingControl() nothrow
{
return cast(Control)cast(Control*)TlsGetValue(tlsControl);
}
Expand All @@ -1590,7 +1596,7 @@ final class Application // docmain
}


@property TF threadFlags() // getter
@property TF threadFlags() nothrow // getter
{
return cast(TF)cast(DWORD)TlsGetValue(tlsThreadFlags);
}
Expand Down Expand Up @@ -1668,7 +1674,7 @@ final class Application // docmain
package:


extern(Windows) void _gcTimeout(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
extern(Windows) void _gcTimeout(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime) nothrow
{
KillTimer(hwnd, Application.gctimer);
Application.gctimer = 0;
Expand Down Expand Up @@ -1857,7 +1863,7 @@ debug(SHOW_MESSAGE_INFO)
}


extern(Windows) LRESULT dflWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
extern(Windows) LRESULT dflWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) nothrow
{
//cprintf("HWND %p; WM %d(0x%X); WPARAM %d(0x%X); LPARAM %d(0x%X);\n", hwnd, msg, msg, wparam, wparam, lparam, lparam);

Expand Down Expand Up @@ -1990,9 +1996,15 @@ extern(Windows) LRESULT dflWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
if(ctrl)
{
do_msg:
ctrl.mustWndProc(dm);
if(!ctrl.preProcessMessage(dm))
ctrl._wndProc(dm);
try
{
ctrl.mustWndProc(dm);
if(!ctrl.preProcessMessage(dm))
ctrl._wndProc(dm);
}
catch (DThrowable e)
{
}
}
return dm.result;
}
Expand Down
Loading

0 comments on commit 6e0b9c4

Please sign in to comment.