private void GetDiff()
{
if (TheArticle == null)
{
DisableButtons();
return;
}
try
{
if (webBrowser.Document == null)
{
Tools.WriteDebug("GetDiff", "GetDiff called but webBrowser.Document null");
return;
}
webBrowser.Document.OpenNew(false);
if (TheArticle.OriginalArticleText.Equals(txtEdit.Text))
{
webBrowser.Document.Write(
@"<h2 style='padding-top: .5em;
padding-bottom: .17em;
border-bottom: 1px solid #aaa;
font-size: 150%;'>No changes</h2><p>Press the ""Skip"" button below to skip to the next page.</p>");
}
else
{
// when less than 10 edits show user help info on double click to undo etc.
webBrowser.Document.Write("<!DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"
+ "<html><head>" +
WikiDiff.DiffHead() + @"</head><body>" +
((NumberOfEdits < 10)
? WikiDiff.TableHeader
: WikiDiff.TableHeaderNoMessages) +
Diff.GetDiff(TheArticle.OriginalArticleText, txtEdit.Text, 2) +
"</table></body></html>");
}
txtEdit.Focus();
txtEdit.SelectionLength = 0;
_diffAccessViolationSeen = false;
GuiUpdateAfterProcessing();
}
catch (Exception ex)
{
// https://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser/Bugs/Archive_22#AccessViolationException_in_MainForm.GetDiff
// catch this and use Refresh x2 to get around it
// but only try once (diffAccessViolationSeen = false) so we don't get stuck in a loop
if (ex is AccessViolationException && !_diffAccessViolationSeen)
{
_diffAccessViolationSeen = true;
Tools.WriteDebug("GetDiff", "AccessViolationException seen");
webBrowser.Refresh();
webBrowser.Refresh();
GetDiff();
}
else
ErrorHandler.HandleException(ex);
}
}