зеркало из https://github.com/mozilla/pjs.git
temporary changes to use a pref to switch between localized date code and non-localized date code, so QA can test my fix for #10412 in a release build. also, some nsCOMPtr changes
This commit is contained in:
Родитель
c0f1a81582
Коммит
41d0838da4
|
@ -54,6 +54,13 @@
|
||||||
#include "nsDateTimeFormatCID.h"
|
#include "nsDateTimeFormatCID.h"
|
||||||
#include "nsIScriptableDateFormat.h"
|
#include "nsIScriptableDateFormat.h"
|
||||||
|
|
||||||
|
/* sspitzer: temporary */
|
||||||
|
#ifdef XP_UNIX
|
||||||
|
#include "nsIPref.h"
|
||||||
|
#define PREF_TEST_10412_FIX "test.10412.fix"
|
||||||
|
static NS_DEFINE_CID(kCPrefServiceCID, NS_PREF_CID);
|
||||||
|
#endif
|
||||||
|
|
||||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||||
|
@ -286,64 +293,67 @@ nsresult
|
||||||
nsRDFContentUtils::GetTextForNode(nsIRDFNode* aNode, nsString& aResult)
|
nsRDFContentUtils::GetTextForNode(nsIRDFNode* aNode, nsString& aResult)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsIRDFResource *resource;
|
nsCOMPtr <nsIRDFResource> resource;
|
||||||
nsIRDFLiteral *literal;
|
nsCOMPtr <nsIRDFLiteral> literal;
|
||||||
nsIRDFDate *dateLiteral;
|
nsCOMPtr <nsIRDFDate> dateLiteral;
|
||||||
nsIRDFInt *intLiteral;
|
nsCOMPtr <nsIRDFInt> intLiteral;
|
||||||
|
|
||||||
if (! aNode) {
|
if (! aNode) {
|
||||||
aResult.Truncate();
|
aResult.Truncate();
|
||||||
rv = NS_OK;
|
rv = NS_OK;
|
||||||
}
|
}
|
||||||
else if (NS_SUCCEEDED(rv = aNode->QueryInterface(kIRDFResourceIID, (void**) &resource))) {
|
else if (NS_SUCCEEDED(rv = aNode->QueryInterface(kIRDFResourceIID, getter_AddRefs(resource)))) {
|
||||||
nsXPIDLCString p;
|
nsXPIDLCString p;
|
||||||
if (NS_SUCCEEDED(rv = resource->GetValue( getter_Copies(p) ))) {
|
if (NS_SUCCEEDED(rv = resource->GetValue( getter_Copies(p) ))) {
|
||||||
aResult = p;
|
aResult = p;
|
||||||
}
|
}
|
||||||
NS_RELEASE(resource);
|
|
||||||
}
|
}
|
||||||
else if (NS_SUCCEEDED(rv = aNode->QueryInterface(kIRDFDateIID, (void**) &dateLiteral))) {
|
else if (NS_SUCCEEDED(rv = aNode->QueryInterface(kIRDFDateIID, getter_AddRefs(dateLiteral)))) {
|
||||||
PRInt64 theDate;
|
PRInt64 theDate;
|
||||||
if (NS_SUCCEEDED(rv = dateLiteral->GetValue( &theDate ))) {
|
if (NS_SUCCEEDED(rv = dateLiteral->GetValue( &theDate ))) {
|
||||||
/* sspitzer: don't switch off until #10412 is fixed. this causes crashers on UNIX. I'm investigating */
|
/* sspitzer: temporary code until I can verify my fix for #10412. I can't reproduce the bug on my box, so I can't be 100% certain I fixed the problem until jay or ester test it. This way, they can test the fix in a release build by setting a pref. this temporary code will go away soon. */
|
||||||
#if 1
|
PRBool test_10412_fix = PR_FALSE;
|
||||||
PRExplodedTime dateData;
|
#ifdef XP_UNIX
|
||||||
PR_ExplodeTime(theDate, PR_LocalTimeParameters, &dateData);
|
NS_WITH_SERVICE(nsIPref, prefs, kCPrefServiceCID, &rv);
|
||||||
char dateBuf[128];
|
if (NS_FAILED(rv) || !prefs) return rv;
|
||||||
PR_FormatTime(dateBuf, sizeof(dateBuf)-1, "%c", &dateData);
|
rv = prefs->GetBoolPref(PREF_TEST_10412_FIX, &test_10412_fix);
|
||||||
aResult = dateBuf;
|
if (NS_FAILED(rv)) { test_10412_fix = PR_FALSE; rv = NS_OK;}
|
||||||
#else
|
#endif /* XP_UNIX */
|
||||||
// XXX can we catch this somehow instead of creating/destroying it all the time?
|
|
||||||
nsIDateTimeFormat *aDateTimeFormat;
|
if (!test_10412_fix) {
|
||||||
rv = nsComponentManager::CreateInstance(kDateTimeFormatCID, NULL,
|
PRExplodedTime dateData;
|
||||||
nsIDateTimeFormat::GetIID(), (void **) &aDateTimeFormat);
|
PR_ExplodeTime(theDate, PR_LocalTimeParameters, &dateData);
|
||||||
if (NS_SUCCEEDED(rv) && (aDateTimeFormat))
|
char dateBuf[128];
|
||||||
{
|
PR_FormatTime(dateBuf, sizeof(dateBuf)-1, "%c", &dateData);
|
||||||
if (NS_SUCCEEDED(rv = aDateTimeFormat->FormatPRTime(nsnull /* nsILocale* locale */, kDateFormatLong,
|
aResult = dateBuf;
|
||||||
kTimeFormatSeconds, (PRTime)theDate, aResult)))
|
}
|
||||||
{
|
else {
|
||||||
}
|
// XXX can we cache this somehow instead of creating/destroying it all the time?
|
||||||
NS_RELEASE(aDateTimeFormat);
|
nsCOMPtr <nsIDateTimeFormat> aDateTimeFormat;
|
||||||
|
rv = nsComponentManager::CreateInstance(kDateTimeFormatCID, NULL,
|
||||||
|
nsIDateTimeFormat::GetIID(), getter_AddRefs(aDateTimeFormat));
|
||||||
|
if (NS_SUCCEEDED(rv) && aDateTimeFormat)
|
||||||
|
{
|
||||||
|
rv = aDateTimeFormat->FormatPRTime(nsnull /* nsILocale* locale */, kDateFormatLong, kTimeFormatSeconds, (PRTime)theDate, aResult);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
aResult.Truncate();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
NS_RELEASE(dateLiteral);
|
|
||||||
}
|
}
|
||||||
else if (NS_SUCCEEDED(rv = aNode->QueryInterface(kIRDFIntIID, (void**) &intLiteral))) {
|
else if (NS_SUCCEEDED(rv = aNode->QueryInterface(kIRDFIntIID, getter_AddRefs(intLiteral)))) {
|
||||||
PRInt32 theInt;
|
PRInt32 theInt;
|
||||||
aResult.Truncate();
|
aResult.Truncate();
|
||||||
if (NS_SUCCEEDED(rv = intLiteral->GetValue( &theInt ))) {
|
if (NS_SUCCEEDED(rv = intLiteral->GetValue( &theInt ))) {
|
||||||
aResult.Append(theInt, 10);
|
aResult.Append(theInt, 10);
|
||||||
}
|
}
|
||||||
NS_RELEASE(intLiteral);
|
|
||||||
}
|
}
|
||||||
else if (NS_SUCCEEDED(rv = aNode->QueryInterface(kIRDFLiteralIID, (void**) &literal))) {
|
else if (NS_SUCCEEDED(rv = aNode->QueryInterface(kIRDFLiteralIID, getter_AddRefs(literal)))) {
|
||||||
nsXPIDLString p;
|
nsXPIDLString p;
|
||||||
if (NS_SUCCEEDED(rv = literal->GetValue( getter_Copies(p) ))) {
|
if (NS_SUCCEEDED(rv = literal->GetValue( getter_Copies(p) ))) {
|
||||||
aResult = p;
|
aResult = p;
|
||||||
}
|
}
|
||||||
NS_RELEASE(literal);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NS_ERROR("not a resource or a literal");
|
NS_ERROR("not a resource or a literal");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче