Chameleon Applications

Chameleon Applications Commit Details

Date:2011-12-05 07:10:53 (5 years 5 months ago)
Author:Rekursor
Commit:451
Parents: 450
Message:Fixed small memory leaks, thanks to new Xcode4 analyser
Changes:
M/trunk/ChameleonPrefPane/Sources/BootSetupController.mm
M/trunk/ChameleonPrefPane/Sources/TableViewsController.mm
M/trunk/ChameleonPrefPane/bin/OSX106/Chameleon.zip
M/trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.mm
M/trunk/ChameleonPrefPane/Sources/PartitionInfoElement.h
M/trunk/ChameleonPrefPane/Sources/AboutController.mm
M/trunk/ChameleonPrefPane/English.lproj/Chameleon.xib
M/trunk/ChameleonPrefPane/Sources/PartitionInfoElement.mm
M/trunk/ChameleonPrefPane/Sources/PartitionInfoManager.mm
M/trunk/ChameleonPrefPane/Sources/PreferencesControllerBase.mm
M/trunk/ChameleonPrefPane/bin/version

File differences

trunk/ChameleonPrefPane/Sources/ChameleonPrefPane.mm
198198
199199
200200
201
201
202202
203203
204204
......
242242
243243
244244
245
245
246246
247247
248248
//--------------------------------------------------------------------------
- (void) initBootConfig
{
static bool ft=true;
//static bool ft=true;
[self initAuthorization];
//NSString* ns = [ [NSString alloc] initWithUTF8String:BootProp::instance().propFilePath() ];
[mStatusText setStringValue: [NSString stringWithFormat: @""] ];
BootSetupController* bsc = [BootSetupController instance];
[bsc->mBootConfigPathText setStringValue: [[NSString alloc] initWithUTF8String: BootProp::instance().propFilePath()] ];
[bsc->mBootConfigPathText setStringValue: [NSString stringWithUTF8String: BootProp::instance().propFilePath()] ];
[bsc->mBootExtraPathText setStringValue: [[bsc->mBootConfigPathText stringValue] stringByDeletingLastPathComponent] ];
[bsc->mBootCdbootPathText setStringValue: [[bsc->mBootConfigPathText stringValue] stringByDeletingLastPathComponent]];
trunk/ChameleonPrefPane/Sources/AboutController.mm
1111
1212
1313
14
14
1515
1616
1717
......
2828
2929
3030
31
31
3232
3333
3434
3535
3636
37
38
37
38
3939
4040
4141
@implementation AboutController
- (id) init
{
[super init];
self = [super init];
bundle = [NSBundle bundleForClass:[self class]];
sCredits = [bundle pathForResource: @"CREDITS" ofType: nil ];
NSString* revFile = [bundle pathForResource: @"version" ofType: nil ];
NSString* rev = [NSString stringWithContentsOfFile:revFile encoding:NSUTF8StringEncoding error:nil] ;
NSString * info = [[NSString alloc] initWithFormat:@"Version %@ - %@", sVer, rev ];
NSString * info = [[[NSString alloc] initWithFormat:@"Version %@ - %@", sVer, rev ] autorelease];
return info;
}
- (NSString *)credits
{
NSString* s = [[NSString alloc]
initWithContentsOfFile:sCredits encoding: NSASCIIStringEncoding error: nil];
NSString* s = [[[NSString alloc]
initWithContentsOfFile:sCredits encoding: NSASCIIStringEncoding error: nil] autorelease];
return s ? s : @"";
}
trunk/ChameleonPrefPane/Sources/PartitionInfoManager.mm
1616
1717
1818
19
19
2020
2121
2222
......
7777
7878
7979
80
8180
8281
8382
......
9089
9190
9291
93
92
9493
9594
9695
......
224223
225224
226225
227
226
228227
229228
230229
-(id) init
{
[super init];
self = [super init];
return self;
}
//[PartsInfoMgr resetSwapping];
NSArray* partArr = [PartitionInfoElement createBSDPartitionList];
sParts = (NSMutableArray*) [PartitionInfoElement extractInfoWithBSDNames: partArr withArray: nil];
[partArr release];
}
return [sParts retain];
}
+(PartitionInfoElement*) objectAtIndex:(NSUInteger) index
{
PartitionInfoElement* elt = [ [[PartsInfoMgr parts] objectAtIndex:index] retain];
PartitionInfoElement* elt = [[PartsInfoMgr parts] objectAtIndex:index];
return elt;
{
if (partInfo != nil && currentStr!=nil)
{
NSMutableString* ms = [[NSMutableString alloc ] initWithCapacity: 512];
NSMutableString* ms = [[[NSMutableString alloc ] initWithCapacity: 512] autorelease];
NSArray* sPairs =
[currentStr componentsSeparatedByCharactersInSet:
trunk/ChameleonPrefPane/Sources/PreferencesControllerBase.mm
375375
376376
377377
378
379378
380379
381380
......
406405
407406
408407
409
408
410409
411410
412411
......
437436
438437
439438
440
441439
442440
443441
if (f)
{
[(NSTextField*)bod->contentID setStringValue: f];
[f release];
}
}
[self synchronizeTextContent: bod withValue: state];
[task waitUntilExit]; // wait for process termination
int status = [task terminationStatus];
[task release];
return (status == 0) ? true : false;
}
NSArray* fileTypes = [NSArray arrayWithObjects: @"plist", nil];
NSString * s= [self selectFileWithFileTypes: @"/" withName: name
withTypes: fileTypes];
[fileTypes release];
return s;
}
trunk/ChameleonPrefPane/Sources/TableViewsController.mm
6666
6767
6868
69
69
7070
7171
7272
......
119119
120120
121121
122
122
123123
124124
125125
......
130130
131131
132132
133
134133
135134
136135
......
154153
155154
156155
157
156
158157
159158
160159
......
248247
249248
250249
251
252
253
254250
255251
256252
......
312308
313309
314310
315
316311
317312
318313
//--------------------------------------------------------------------------
- (id) init
{
[super init];
self = [super init];
_instance = self;
currentRowSel = -1;
if(!str) return nil;
NSBundle * b = [NSBundle bundleForClass:[self class]];
NSString* sRes = [b pathForResource: str ofType:sType ];
img = [[NSImage alloc] initWithContentsOfFile: sRes];
img = [[[NSImage alloc] initWithContentsOfFile: sRes] autorelease];
return img;
}
//--------------------------------------------------------------------------
PartitionInfoElement* partInfo = [PartsInfoMgr objectAtIndex:row];
BOOL ret = (partInfo != nil && [partInfo hidden]== false) ? YES : NO;
[partInfo release];
return ret;
}
currentRowSel = [tv selectedRow];
if (currentRowSel>=0)
{
PartitionInfoElement* partInfo = [PartsInfoMgr objectAtIndex:currentRowSel];
PartitionInfoElement* partInfo = [[PartsInfoMgr objectAtIndex:currentRowSel] retain];
NSString* s;
#if 0
}
}
[partInfo release];
NSLog(@"object at column %@ row %ld Set %@", [[tableColumn headerCell] stringValue], (long) row, object);
}
//--------------------------------------------------------------------------
ret= [partInfo hdString];
}
[partInfo release];
}
else if (tableView == mTabViewPanesSelect)
{
trunk/ChameleonPrefPane/Sources/PartitionInfoElement.h
5050
5151
5252
53
53
5454
5555
5656
-(bool)isValid;
// Get any DA attribute from dict
-(NSString*) createStringValueWithKey: (NSString*) key;
-(NSString*) stringValueWithKey: (NSString*) key;
-(int) diskNumber;
-(int) partitionNumber;
trunk/ChameleonPrefPane/Sources/BootSetupController.mm
4848
4949
5050
51
52
53
54
55
51
52
53
54
55
5656
5757
5858
......
6464
6565
6666
67
67
6868
6969
7070
......
8686
8787
8888
89
89
9090
9191
9292
93
93
9494
9595
9696
......
222222
223223
224224
225
226
225
226
227227
228
229
230228
231229
232230
......
236234
237235
238236
237
238
239239
240240
241241
......
244244
245245
246246
247
247
248248
249249
250250
251251
252252
253
254
255253
256254
257255
258256
259257
260
258
261259
262260
263261
264262
265
263
266264
267265
268266
//--------------------------------------------------------------------------
- (void) setDefaultsValues: (NSMutableDictionary*) dict
{
[dict setObject: [[NSNumber alloc] initWithBool: false] forKey: keySwapHD01];
[dict setObject: [[NSNumber alloc] initWithBool: false] forKey: keySwapHD02];
[dict setObject:[[NSNumber alloc] initWithBool: false] forKey: keyUseFrozenParts];
[dict setObject:[[NSNumber alloc] initWithBool: false] forKey: keyUseFrozenParts];
[dict setObject:[[NSString alloc] initWithString: @""] forKey: keyForceBootConfigPath];
[dict setObject:[[[NSNumber alloc] initWithBool: false] autorelease] forKey: keySwapHD01];
[dict setObject:[[[NSNumber alloc] initWithBool: false] autorelease] forKey: keySwapHD02];
[dict setObject:[[[NSNumber alloc] initWithBool: false] autorelease] forKey: keyUseFrozenParts];
[dict setObject:[[[NSNumber alloc] initWithBool: false] autorelease] forKey: keyUseFrozenParts];
[dict setObject:[[[NSString alloc] initWithString: @""] autorelease] forKey: keyForceBootConfigPath];
}
//--------------------------------------------------------------------------
-(void) loadOptionsFromPreferencesFile: (NSMutableDictionary*) dict
[mBootConfigPathText setStringValue: obj ? obj : @"" ];
int val = (obj && [[mBootConfigPathText stringValue] length] >0 ? 1 : 0);
[mBootConfigPath setIntValue: val];
[dict setObject:[[NSString alloc] initWithString: [mBootConfigPathText stringValue]]
[dict setObject:[NSString stringWithString: [mBootConfigPathText stringValue]]
forKey: keyForceBootConfigPath];
[mBootConfigPathText setEnabled: val ? true : false];
[mBootConfigPathText setEditable: val ? true : false];
{
// get the key
snprintf(keyPartN, sizeof(keyPartN)-1, "partition%02d",i);
NSString* obj = [[self preferencesParts] objectForKey: [[NSString alloc] initWithUTF8String: keyPartN] ];
NSString* obj = [[self preferencesParts] objectForKey: [NSString stringWithUTF8String: keyPartN] ];
// assign this key if valid
if (obj!=nil && [obj length]>0)
{
PartitionInfoElement* p = [[PartitionInfoElement alloc] init];
PartitionInfoElement* p = [[[PartitionInfoElement alloc] init] autorelease];
// parse string
NSArray* words = [obj componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString: @";"]];
k=0;
[[p vUUID] UTF8String]);
// write it to the dictionary
NSString * key = [[NSString alloc] initWithUTF8String: keyPartN];
NSString * desc = [[NSString alloc] initWithUTF8String: partDesc];
NSString * key = [NSString stringWithUTF8String: keyPartN];
NSString * desc = [NSString stringWithUTF8String: partDesc];
[[self preferencesParts] setObject: desc forKey: key];
[p release];
}
[[self preferencesFile] setObject: [self preferencesParts] forKey: keyPartitionsList];
[self savePreferences ];
//--------------------------------------------------------------------------
- (IBAction) onForceBootConfigPath: (id) sender
{
NSString * f;
if (sender == mBootConfigPath)
{
int val = [mBootConfigPath intValue];
if (val)
{
NSString * f = [self selectPlistFile: @"org.chameleon.Boot.plist"];
f = [self selectPlistFile: @"org.chameleon.Boot.plist"];
if(f)
{
[mBootConfigPathText setStringValue:f];
[mBootExtraPathText setStringValue: [f stringByDeletingLastPathComponent] ];
[mBootCdbootPathText setStringValue: [f stringByDeletingLastPathComponent]];
[f release];
}
}
[[self preferencesFile] setObject:
val ? [mBootConfigPathText stringValue] : [[NSString alloc] initWithUTF8String: ""]
val ? [mBootConfigPathText stringValue] : [NSString stringWithUTF8String: ""]
forKey: keyForceBootConfigPath];
}
else{
NSString * f = [mBootConfigPathText stringValue];
f = [mBootConfigPathText stringValue];
[[self preferencesFile] setObject:f forKey: keyForceBootConfigPath];
[mBootExtraPathText setStringValue: [f stringByDeletingLastPathComponent] ];
[mBootCdbootPathText setStringValue: [f stringByDeletingLastPathComponent]];
trunk/ChameleonPrefPane/Sources/PartitionInfoElement.mm
2020
2121
2222
23
23
2424
2525
2626
......
3232
3333
3434
35
35
3636
3737
3838
......
8888
8989
9090
91
91
9292
9393
9494
......
129129
130130
131131
132
133
134132
135133
136134
137135
138
136
139137
138
139
140
141
142
143
144
145
146
147
148
140149
141
142
143150
144151
145
146
147
148
149
150
151
152
153
154
155152
156153
157154
158
159
155
156
160157
161
162
163
164
158
159
160
161
165162
166163
167164
......
170167
171168
172169
173
174170
175171
176172
......
186182
187183
188184
189
185
190186
191187
192188
......
194190
195191
196192
197
193
198194
199
195
200196
201197
202198
203
204199
205200
206201
......
272267
273268
274269
275
270
276271
277272
278273
......
281276
282277
283278
284
279
285280
286281
287282
/// Create a list of all bsd partitions
+(NSArray*) createBSDPartitionList
{
NSMutableArray* arr = [[NSMutableArray alloc] init];
NSMutableArray* arr = [[[NSMutableArray alloc] init] autorelease];
char line[256];
ShellProcess p;
if (l==0 || strstr(line, "ls:")!=NULL) continue;
if (line[l-1]) line[l-1]='\0';
const char * p = strstr(line, "disk");
NSString* s = [[NSString stringWithUTF8String: p] retain];
NSString* s = [NSString stringWithUTF8String: p] ;
[arr addObject: s];
}
}
/// Extract a particular information from the disk partition dictionary from a key, generate a string value output
-(NSString*) createStringValueWithKey: (NSString*) key
-(NSString*) stringValueWithKey: (NSString*) key
{
if (err) return @"";
CFTypeRef o = [descDict objectForKey: key];
{
session = DASessionCreate(NULL);
}
DADiskRef disk;
if (session == NULL)err = EINVAL;
if (err == 0) {
disk = DADiskCreateFromBSDName(NULL, session, [name UTF8String] );
DADiskRef disk = DADiskCreateFromBSDName(NULL, session, [name UTF8String] );
if (disk == NULL) err = EINVAL;
else
{
[self cleanup];
CFDictionaryRefdr = DADiskCopyDescription(disk);
if (dr!=NULL)
{
descDict = (NSDictionary*) dr;
CFRelease(dr);
}
}
if (disk) CFRelease(disk);
}
[self cleanup];
if (err == 0) {
CFDictionaryRefdr = DADiskCopyDescription(disk);
if (dr!=NULL)
{
self.descDict = [((NSDictionary*) dr) copy];
CFRelease(dr);
if (self.descDict == NULL) err = EINVAL;
}
}
if (err == 0) {
diskNum = [sDiskintValue];
partNum = [sPartintValue];
self.vUUID = [self createStringValueWithKey: @"DAVolumeUUID"];
self.vName = [self createStringValueWithKey: @"DAVolumeName"];
self.vUUID = [self stringValueWithKey: @"DAVolumeUUID"];
self.vName = [self stringValueWithKey: @"DAVolumeName"];
self.vAliasName = self.vName; // by default renamed = original part name
self.vKind = [self createStringValueWithKey: @"DAVolumeKind"];
self.mediaPath = [self createStringValueWithKey: @"DAMediaPath"];
self.devProtocol = [self createStringValueWithKey: @"DADeviceProtocol"];
self.bsdName = [[NSString stringWithString:name] retain];
self.vKind = [self stringValueWithKey: @"DAVolumeKind"];
self.mediaPath = [self stringValueWithKey: @"DAMediaPath"];
self.devProtocol = [self stringValueWithKey: @"DADeviceProtocol"];
self.bsdName = [NSString stringWithString:name];
self.devInternal = (bool) [[descDict objectForKey: @"DADeviceInternal"] boolValue];
self.mediaRemovable = (bool) [[descDict objectForKey: @"DAMediaRemovable"] boolValue];
// Clean up.
if (disk != NULL)CFRelease(disk);
if (session != NULL && mustRelease) CFRelease(session);
return err;
{
NSArray* partArr = [PartitionInfoElement createBSDPartitionList];
if (arr == nil)
arr = [[NSMutableArray alloc ] init];
arr = [[[NSMutableArray alloc ] init] autorelease];
if (partArr!=nil && [partArr count]>0)
{
for (NSString* part in partArr)
{
PartitionInfoElement* elt =
[[PartitionInfoElement alloc] initWithBSDName: part withinSession: session];
[[[PartitionInfoElement alloc] initWithBSDName: part withinSession: session] autorelease];
if (elt!=nil && [[elt vName] length] >0 && [elt isValid] )
[arr addObject:elt];
[arr addObject: elt];
}
if (session!=nil) CFRelease(session);
}
[partArr release];
return arr;
}
/// initialize a partition element with DA partition info
-(id) initWithBSDName:(NSString*) name
{
[super init];
self = [super init];
diskNum = partNum = -1;
err = [self extractInfoWithBSDName: name withinSession: nil];
return self;
/// initialize a partition element with DA partition info and an optional opened session
-(id) initWithBSDName:(NSString*) name withinSession:(DASessionRef) session
{
[super init];
self = [super init];
diskNum = partNum = -1;
err = [self extractInfoWithBSDName: name withinSession: session];
trunk/ChameleonPrefPane/bin/version
1
1
Revision: 446
Revision: 450
trunk/ChameleonPrefPane/English.lproj/Chameleon.xib
43774377
43784378
43794379
4380
4380
43814381
43824382
43834383
43844384
4385
4385
43864386
43874387
43884388
......
76367636
76377637
76387638
7639
76397640
7640
76417641
76427642
76437643
......
96979697
96989698
96999699
9700
9700
97019701
97029702
97039703
<object class="NSView" id="787301749">
<reference key="NSNextResponder" ref="833529377"/>
<int key="NSvFlags">274</int>
<string key="NSFrame">{{1, 1}, {509, 212}}</string>
<string key="NSFrame">{{1, 1}, {509, 204}}</string>
<reference key="NSSuperview" ref="833529377"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
</object>
</object>
<string key="NSFrame">{{44, 190.88671875}, {511, 228.36328125}}</string>
<string key="NSFrame">{{44, 190}, {511, 220.5859375}}</string>
<reference key="NSSuperview" ref="270074358"/>
<reference key="NSNextKeyView" ref="787301749"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
<reference ref="573633185"/>
<reference ref="274013770"/>
<reference ref="390072205"/>
<reference ref="460924763"/>
<reference ref="833529377"/>
<reference ref="460924763"/>
</object>
<reference key="parent" ref="1010390976"/>
</object>
<string>RoundedBox</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">AUIwAABDQgAAA</bytes>
<bytes key="NSTransformStruct">AUIwAABDRqoAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">

Archive Download the corresponding diff file

Revision: 451