1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-13 18:15:48 +02:00

Fix crash when showing a browser error message

Closes 
This commit is contained in:
chylex 2018-11-20 14:55:40 +01:00
parent 52da4d8687
commit 651bbbb672

View File

@ -19,6 +19,8 @@ namespace TweetDuck.Core{
sealed class TweetDeckBrowser : IDisposable{
private static UserConfig Config => Program.Config.User;
private const string ErrorUrl = "http://td/error";
public bool Ready { get; private set; }
public bool Enabled{
@ -151,6 +153,10 @@ private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
ScriptLoader.ExecuteFile(frame, "update.js", browser);
}
if (frame.Url == ErrorUrl){
resourceHandlerFactory.UnregisterHandler(ErrorUrl);
}
}
private void browser_LoadError(object sender, LoadErrorEventArgs e){
@ -162,7 +168,8 @@ private void browser_LoadError(object sender, LoadErrorEventArgs e){
string errorPage = ScriptLoader.LoadResourceSilent("pages/error.html");
if (errorPage != null){
browser.LoadHtml(errorPage.Replace("{err}", BrowserUtils.GetErrorName(e.ErrorCode)), "http://td/error");
resourceHandlerFactory.RegisterHandler(ErrorUrl, ResourceHandler.FromString(errorPage.Replace("{err}", BrowserUtils.GetErrorName(e.ErrorCode))));
browser.Load(ErrorUrl);
}
}
}