Fix potential leak in macspellimp.mm
+ avoid macSpell var I'm not sure to retrieve [NSSpellChecker sharedSpellChecker] in a pointer is a good idea. Most of the examples using sharedSpellChecker just call [NSSpellChecker sharedSpellChecker] each time. If there's a bit more code, at least we're sure we won't leak because of this. Change-Id: I9818bd3d51f26b50849e1a5e69cc705acd92ad29 Reviewed-on: https://gerrit.libreoffice.org/43140 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
This commit is contained in:
@@ -63,7 +63,6 @@ class MacSpellChecker :
|
|||||||
Locale * aDLocs;
|
Locale * aDLocs;
|
||||||
OUString * aDNames;
|
OUString * aDNames;
|
||||||
sal_Int32 numdict;
|
sal_Int32 numdict;
|
||||||
NSSpellChecker * macSpell;
|
|
||||||
int macTag; // unique tag for this doc
|
int macTag; // unique tag for this doc
|
||||||
|
|
||||||
::comphelper::OInterfaceContainerHelper2 aEvtListeners;
|
::comphelper::OInterfaceContainerHelper2 aEvtListeners;
|
||||||
|
@@ -57,7 +57,6 @@ MacSpellChecker::MacSpellChecker() :
|
|||||||
numdict = 0;
|
numdict = 0;
|
||||||
NSApplicationLoad();
|
NSApplicationLoad();
|
||||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||||
macSpell = [NSSpellChecker sharedSpellChecker];
|
|
||||||
macTag = [NSSpellChecker uniqueSpellDocumentTag];
|
macTag = [NSSpellChecker uniqueSpellDocumentTag];
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
@@ -117,7 +116,7 @@ Sequence< Locale > SAL_CALL MacSpellChecker::getLocales()
|
|||||||
for (NSUInteger i = 0; i < [aLocales count]; i++)
|
for (NSUInteger i = 0; i < [aLocales count]; i++)
|
||||||
{
|
{
|
||||||
NSString* pLangStr = (NSString*)[aLocales objectAtIndex:i];
|
NSString* pLangStr = (NSString*)[aLocales objectAtIndex:i];
|
||||||
if( [macSpell setLanguage:pLangStr ] )
|
if( [[NSSpellChecker sharedSpellChecker] setLanguage:pLangStr ] )
|
||||||
{
|
{
|
||||||
postspdict.push_back( pLangStr );
|
postspdict.push_back( pLangStr );
|
||||||
}
|
}
|
||||||
@@ -241,7 +240,7 @@ sal_Int16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSInteger aCount;
|
NSInteger aCount;
|
||||||
NSRange range = [macSpell checkSpellingOfString:aNSStr startingAt:0 language:aLang wrap:false inSpellDocumentWithTag:macTag wordCount:&aCount];
|
NSRange range = [[NSSpellChecker sharedSpellChecker] checkSpellingOfString:aNSStr startingAt:0 language:aLang wrap:false inSpellDocumentWithTag:macTag wordCount:&aCount];
|
||||||
int rVal = 0;
|
int rVal = 0;
|
||||||
if(range.length>0)
|
if(range.length>0)
|
||||||
{
|
{
|
||||||
@@ -339,8 +338,8 @@ Reference< XSpellAlternatives >
|
|||||||
NSString* aTaggedCountry = [@"_" stringByAppendingString:aCountry];
|
NSString* aTaggedCountry = [@"_" stringByAppendingString:aCountry];
|
||||||
aLang = [aLang stringByAppendingString:aTaggedCountry];
|
aLang = [aLang stringByAppendingString:aTaggedCountry];
|
||||||
}
|
}
|
||||||
[macSpell setLanguage:aLang];
|
[[NSSpellChecker sharedSpellChecker] setLanguage:aLang];
|
||||||
NSArray *guesses = [macSpell guessesForWordRange:NSMakeRange(0, [aNSStr length]) inString:aNSStr language:aLang inSpellDocumentWithTag:0];
|
NSArray *guesses = [[NSSpellChecker sharedSpellChecker] guessesForWordRange:NSMakeRange(0, [aNSStr length]) inString:aNSStr language:aLang inSpellDocumentWithTag:0];
|
||||||
count = [guesses count];
|
count = [guesses count];
|
||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user