Catch all exceptions (even SEH).

Fix #7?
This commit is contained in:
Paddy Xu
2017-05-10 23:22:23 +03:00
parent 3e99427d0b
commit ba2d5d2ab2
2 changed files with 27 additions and 2 deletions

View File

@@ -4,4 +4,7 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<legacyCorruptedStateExceptionsPolicy enabled="true" />
</runtime>
</configuration>

View File

@@ -47,15 +47,37 @@ namespace QuickLook
{
_viewWindow.BeginShow(matchedPlugin, path);
}
catch (Exception e) // if current plugin failed, switch to default one
catch (Exception e) // if current plugin failed, switch to default one.
{
_viewWindow.Close();
Debug.WriteLine(e.ToString());
Debug.WriteLine(e.StackTrace);
if (matchedPlugin.GetType() != PluginManager.GetInstance().DefaultPlugin)
{
matchedPlugin.Dispose();
_viewWindow.BeginShow(PluginManager.GetInstance().DefaultPlugin.CreateInstance<IViewer>(), path);
matchedPlugin = PluginManager.GetInstance().DefaultPlugin.CreateInstance<IViewer>();
BeginShowNewWindow(matchedPlugin, path);
}
else
{
throw;
}
}
catch // Catch SEH exceptions here.
{
_viewWindow.Close();
if (matchedPlugin.GetType() != PluginManager.GetInstance().DefaultPlugin)
{
matchedPlugin.Dispose();
matchedPlugin = PluginManager.GetInstance().DefaultPlugin.CreateInstance<IViewer>();
BeginShowNewWindow(matchedPlugin, path);
}
else
{
throw;
}
}
}