fix bug 71358. Use xpcom pointer and do right thing for ref count

r/sr=hyatt
This commit is contained in:
ftang%netscape.com 2001-05-15 11:57:22 +00:00
parent 80fdeac6f8
commit fdfd99773b
4 changed files with 18 additions and 20 deletions

View File

@ -60,9 +60,8 @@ nsBidiPresUtils::nsBidiPresUtils() : mSuccess(NS_ERROR_FAILURE),
mIndexMap(nsnull),
mLevels(nsnull)
{
nsCOMPtr<nsIBidi> bidiEngine = do_GetService("@mozilla.org/intl/bidi;1");
if (bidiEngine) {
mBidiEngine = bidiEngine;
mBidiEngine = do_GetService("@mozilla.org/intl/bidi;1");
if (mBidiEngine) {
mSuccess = NS_OK;
}
}
@ -841,11 +840,10 @@ nsBidiPresUtils::FormatUnicodeText(nsIPresContext* aPresContext,
{
nsresult rv;
if (!mUnicodeUtils) {
nsCOMPtr<nsIUBidiUtils> bidiUtils = do_GetService("@mozilla.org/intl/unicharbidiutil;1");
if (!bidiUtils) {
mUnicodeUtils = do_GetService("@mozilla.org/intl/unicharbidiutil;1");
if (!mUnicodeUtils) {
return NS_ERROR_FAILURE;
}
mUnicodeUtils = bidiUtils;
}
// ahmed
//adjusted for correct numeral shaping
@ -1023,6 +1021,7 @@ nsresult nsBidiPresUtils::GetBidiEngine(nsIBidi** aBidiEngine)
nsresult rv = NS_ERROR_FAILURE;
if (mBidiEngine) {
*aBidiEngine = mBidiEngine;
NS_ADDREF(*aBidiEngine);
rv = NS_OK;
}
return rv;

View File

@ -29,8 +29,8 @@
#include "nsVoidArray.h"
#include "nsIFrame.h"
#include "nsIBidi.h"
class nsIUBidiUtils;
#include "nsIUBidiUtils.h"
#include "nsCOMPtr.h"
class nsBidiPresUtils {
public:
@ -146,8 +146,8 @@ private:
PRUint8* mLevels;
nsresult mSuccess;
nsIBidi* mBidiEngine;
nsIUBidiUtils* mUnicodeUtils;
nsCOMPtr<nsIBidi> mBidiEngine;
nsCOMPtr<nsIUBidiUtils> mUnicodeUtils;
};
#endif /* nsBidiPresUtils_h___ */

View File

@ -29,8 +29,8 @@
#include "nsVoidArray.h"
#include "nsIFrame.h"
#include "nsIBidi.h"
class nsIUBidiUtils;
#include "nsIUBidiUtils.h"
#include "nsCOMPtr.h"
class nsBidiPresUtils {
public:
@ -146,8 +146,8 @@ private:
PRUint8* mLevels;
nsresult mSuccess;
nsIBidi* mBidiEngine;
nsIUBidiUtils* mUnicodeUtils;
nsCOMPtr<nsIBidi> mBidiEngine;
nsCOMPtr<nsIUBidiUtils> mUnicodeUtils;
};
#endif /* nsBidiPresUtils_h___ */

View File

@ -60,9 +60,8 @@ nsBidiPresUtils::nsBidiPresUtils() : mSuccess(NS_ERROR_FAILURE),
mIndexMap(nsnull),
mLevels(nsnull)
{
nsCOMPtr<nsIBidi> bidiEngine = do_GetService("@mozilla.org/intl/bidi;1");
if (bidiEngine) {
mBidiEngine = bidiEngine;
mBidiEngine = do_GetService("@mozilla.org/intl/bidi;1");
if (mBidiEngine) {
mSuccess = NS_OK;
}
}
@ -841,11 +840,10 @@ nsBidiPresUtils::FormatUnicodeText(nsIPresContext* aPresContext,
{
nsresult rv;
if (!mUnicodeUtils) {
nsCOMPtr<nsIUBidiUtils> bidiUtils = do_GetService("@mozilla.org/intl/unicharbidiutil;1");
if (!bidiUtils) {
mUnicodeUtils = do_GetService("@mozilla.org/intl/unicharbidiutil;1");
if (!mUnicodeUtils) {
return NS_ERROR_FAILURE;
}
mUnicodeUtils = bidiUtils;
}
// ahmed
//adjusted for correct numeral shaping
@ -1023,6 +1021,7 @@ nsresult nsBidiPresUtils::GetBidiEngine(nsIBidi** aBidiEngine)
nsresult rv = NS_ERROR_FAILURE;
if (mBidiEngine) {
*aBidiEngine = mBidiEngine;
NS_ADDREF(*aBidiEngine);
rv = NS_OK;
}
return rv;