Skip to content

Commit

Permalink
Call RoClearError when handling device lost errors
Browse files Browse the repository at this point in the history
This prevents the error state from staying around, which can cause
problems if there's a later error that doesn't call RoOriginateError.

XAML uses the error state to override the error code.  The result here
is that the UnhandledException handler will get called with the
device lost error state, rather than the real error state that was unhandled.

This is related to issue #194 where it looked like a device lost exception
was being unhandled, when instead it was another error.
  • Loading branch information
damyanp committed Dec 21, 2015
1 parent 549267f commit 1b25fae
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions winrt/lib/xaml/RecreatableDeviceManager.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,17 @@ namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { na
// This function must be called from inside a catch block.
assert(std::current_exception());

//
// When the exception we're handling was thrown, we also called RoOriginateError.
//
// We need to clear this.
//
// Otherwise, if any other errors occur that don't call RoOriginateError,
// this stored error state will override any subsequent errors, resulting
// in confusing UnhandledException reporting.
//
RoClearError();

// No m_device means that this exception has already been handled.
if (!m_device)
return;
Expand Down

0 comments on commit 1b25fae

Please sign in to comment.