From ccebf9941ac1a8b71bd0d24b1100cc75964b82ea Mon Sep 17 00:00:00 2001 From: Henri Sivonen Date: Thu, 19 Nov 2009 13:53:32 +0200 Subject: [PATCH] Bug 529544 - Avoid creating parser thread when HTML5 parser not enabled. (orange fix) --- parser/html/nsHtml5Module.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/parser/html/nsHtml5Module.cpp b/parser/html/nsHtml5Module.cpp index 039ae38953b..8c21504e6c1 100644 --- a/parser/html/nsHtml5Module.cpp +++ b/parser/html/nsHtml5Module.cpp @@ -59,7 +59,6 @@ nsHtml5Module::InitializeStatics() { nsContentUtils::AddBoolPrefVarCache("html5.enable", &sEnabled); nsContentUtils::AddBoolPrefVarCache("html5.offmainthread", &sOffMainThread); - NS_NewThread(&sStreamParserThread); NS_GetMainThread(&sMainThread); nsHtml5Atoms::AddRefAtoms(); nsHtml5AttributeName::initializeStatics(); @@ -92,7 +91,9 @@ nsHtml5Module::ReleaseStatics() nsHtml5Tokenizer::releaseStatics(); nsHtml5TreeBuilder::releaseStatics(); nsHtml5UTF16Buffer::releaseStatics(); - sStreamParserThread->Shutdown(); + if (sStreamParserThread) { + sStreamParserThread->Shutdown(); + } NS_IF_RELEASE(sStreamParserThread); NS_IF_RELEASE(sMainThread); } @@ -120,7 +121,14 @@ nsHtml5Module::Initialize(nsIParser* aParser, nsIDocument* aDoc, nsIURI* aURI, n nsIThread* nsHtml5Module::GetStreamParserThread() { - return sOffMainThread ? sStreamParserThread : sMainThread; + if (sOffMainThread) { + if (!sStreamParserThread) { + NS_NewThread(&sStreamParserThread); + NS_ASSERTION(sStreamParserThread, "Thread creation failed!"); + } + return sStreamParserThread; + } + return sMainThread; } #ifdef DEBUG