Fixed a leak, increased object counts to 100
parent
55c6e70f79
commit
449fc8d828
|
@ -36,8 +36,7 @@ if ([self window]==nil) NSLog(@"loaded browser window is nil");
|
||||||
|
|
||||||
- (NSDictionary*) deepSkyDict
|
- (NSDictionary*) deepSkyDict
|
||||||
{
|
{
|
||||||
std::vector<const Star*>* nearStars;
|
int objCount = 100;
|
||||||
int objCount = 50;
|
|
||||||
NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity: objCount];
|
NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity: objCount];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
DeepSkyCatalog* catalog = appCore->getSimulation()->getUniverse()->getDeepSkyCatalog();
|
DeepSkyCatalog* catalog = appCore->getSimulation()->getUniverse()->getDeepSkyCatalog();
|
||||||
|
@ -57,21 +56,24 @@ if ([self window]==nil) NSLog(@"loaded browser window is nil");
|
||||||
- (NSDictionary*) starDict: (int) kind
|
- (NSDictionary*) starDict: (int) kind
|
||||||
{
|
{
|
||||||
std::vector<const Star*>* nearStars;
|
std::vector<const Star*>* nearStars;
|
||||||
int starCount = 50;
|
int starCount = 100;
|
||||||
StarBrowser* sb = new StarBrowser(appCore->getSimulation(),kind);
|
StarBrowser* sb = new StarBrowser(appCore->getSimulation(),kind);
|
||||||
nearStars = sb->listStars( starCount );
|
nearStars = sb->listStars( starCount );
|
||||||
starCount = nearStars->size();
|
starCount = nearStars->size();
|
||||||
// if (nearStars == nil ) return 1;
|
// if (nearStars == nil ) return 1;
|
||||||
NSMutableDictionary* starDict = [NSMutableDictionary dictionaryWithCapacity: starCount+2];
|
NSMutableDictionary* starDict = [NSMutableDictionary dictionaryWithCapacity: starCount+2];
|
||||||
|
const Star *aStar;
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<starCount;i++)
|
for (i=0;i<starCount;i++)
|
||||||
{
|
{
|
||||||
Star* aStar = (*nearStars)[i];
|
aStar = (*nearStars)[i];
|
||||||
NSString* starName = [NSString stringWithStdString: appCore->getSimulation()->getUniverse()->getStarCatalog()->getStarName(*aStar) ];
|
NSString* starName = [NSString stringWithStdString: appCore->getSimulation()->getUniverse()->getStarCatalog()->getStarName(*aStar) ];
|
||||||
[starDict setObject: starName forKey: starName];
|
[starDict setObject: starName forKey: starName];
|
||||||
}
|
}
|
||||||
[starDict setObject: [[starDict allKeys]sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)] forKey: @"_keys" ];
|
[starDict setObject: [[starDict allKeys]sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)] forKey: @"_keys" ];
|
||||||
[starDict setObject: @"" forKey: @"_path" ];
|
[starDict setObject: @"" forKey: @"_path" ];
|
||||||
|
delete sb;
|
||||||
|
delete nearStars;
|
||||||
return starDict;
|
return starDict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +102,7 @@ if ([self window]==nil) NSLog(@"loaded browser window is nil");
|
||||||
-(id) newDictForPath: (NSString*) objPath
|
-(id) newDictForPath: (NSString*) objPath
|
||||||
{ // creates browser dictionary for star or planet
|
{ // creates browser dictionary for star or planet
|
||||||
NSMutableDictionary* newDict = NULL;
|
NSMutableDictionary* newDict = NULL;
|
||||||
PlanetarySystem* sys;
|
PlanetarySystem* sys = nil;
|
||||||
Body* bod;
|
|
||||||
Selection sel = appCore->getSimulation()->findObjectFromPath([objPath stdString]);
|
Selection sel = appCore->getSimulation()->findObjectFromPath([objPath stdString]);
|
||||||
if ( sel.getType() == Selection::Type_Body )
|
if ( sel.getType() == Selection::Type_Body )
|
||||||
{
|
{
|
||||||
|
@ -232,8 +233,8 @@ if ([self window]==nil) NSLog(@"loaded browser window is nil");
|
||||||
{ //returns dictionary for path array
|
{ //returns dictionary for path array
|
||||||
NSMutableDictionary* lastDict = [self rootDict];
|
NSMutableDictionary* lastDict = [self rootDict];
|
||||||
NSMutableDictionary* nextDict = lastDict;
|
NSMutableDictionary* nextDict = lastDict;
|
||||||
NSString* lastKey;
|
NSString* lastKey = nil;
|
||||||
int i;
|
unsigned i;
|
||||||
for (i=1;i<[pathNames count];i++)
|
for (i=1;i<[pathNames count];i++)
|
||||||
{
|
{
|
||||||
lastKey = [pathNames objectAtIndex: i];
|
lastKey = [pathNames objectAtIndex: i];
|
||||||
|
@ -254,7 +255,7 @@ if ([self window]==nil) NSLog(@"loaded browser window is nil");
|
||||||
- (id) infoForPathArray: (NSArray*) pathNames
|
- (id) infoForPathArray: (NSArray*) pathNames
|
||||||
{
|
{
|
||||||
NSDictionary* nextDict = [self rootDict];
|
NSDictionary* nextDict = [self rootDict];
|
||||||
int i;
|
unsigned i;
|
||||||
for (i=1;i<[pathNames count];i++)
|
for (i=1;i<[pathNames count];i++)
|
||||||
{
|
{
|
||||||
NSString* key = [pathNames objectAtIndex: i];
|
NSString* key = [pathNames objectAtIndex: i];
|
||||||
|
@ -266,7 +267,7 @@ if ([self window]==nil) NSLog(@"loaded browser window is nil");
|
||||||
|
|
||||||
- (Selection) selFromPathArray: (NSArray*) pathNames
|
- (Selection) selFromPathArray: (NSArray*) pathNames
|
||||||
{
|
{
|
||||||
NSString* objPath;
|
NSString* objPath = nil;
|
||||||
id obj = [self infoForPathArray: pathNames];
|
id obj = [self infoForPathArray: pathNames];
|
||||||
|
|
||||||
if ([obj isKindOfClass: [NSDictionary class]])
|
if ([obj isKindOfClass: [NSDictionary class]])
|
||||||
|
@ -278,7 +279,7 @@ if ([self window]==nil) NSLog(@"loaded browser window is nil");
|
||||||
objPath = (NSString*)obj;
|
objPath = (NSString*)obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
Selection sel = appCore->getSimulation()->findObjectFromPath([objPath stdString]);
|
Selection sel = appCore->getSimulation()->findObjectFromPath(objPath ? [objPath stdString] : std::string());
|
||||||
|
|
||||||
// if (sel == nil) NSLog([NSString stringWithFormat: @"obj %@ not found", objPath]);
|
// if (sel == nil) NSLog([NSString stringWithFormat: @"obj %@ not found", objPath]);
|
||||||
return sel;
|
return sel;
|
||||||
|
@ -307,7 +308,6 @@ if ([self window]==nil) NSLog(@"loaded browser window is nil");
|
||||||
if ([obj isKindOfClass: [NSString class]])
|
if ([obj isKindOfClass: [NSString class]])
|
||||||
{
|
{
|
||||||
Selection sel = appCore->getSimulation()->findObjectFromPath([obj stdString]);
|
Selection sel = appCore->getSimulation()->findObjectFromPath([obj stdString]);
|
||||||
PlanetarySystem* sys;
|
|
||||||
if ( sel.getType() == Selection::Type_Body )
|
if ( sel.getType() == Selection::Type_Body )
|
||||||
{
|
{
|
||||||
if ( sel.body()->getSatellites() || sel.body()->getLocations()) return NO;
|
if ( sel.body()->getSatellites() || sel.body()->getLocations()) return NO;
|
||||||
|
|
Loading…
Reference in New Issue