[sword-svn] r3390 - trunk/bindings/objc/src

mdbergmann at crosswire.org mdbergmann at crosswire.org
Wed Sep 9 01:16:38 MST 2015


Author: mdbergmann
Date: 2015-09-09 01:16:38 -0700 (Wed, 09 Sep 2015)
New Revision: 3390

Modified:
   trunk/bindings/objc/src/SwordInstallSource.h
   trunk/bindings/objc/src/SwordInstallSource.mm
   trunk/bindings/objc/src/SwordManager.mm
Log:
Minor code cleanups.
Fix a memory management bug where SWMgr in SwordManager was deleted when it shouldn't.

Modified: trunk/bindings/objc/src/SwordInstallSource.h
===================================================================
--- trunk/bindings/objc/src/SwordInstallSource.h	2015-09-08 12:38:02 UTC (rev 3389)
+++ trunk/bindings/objc/src/SwordInstallSource.h	2015-09-09 08:16:38 UTC (rev 3390)
@@ -62,7 +62,7 @@
 /** list module types */
 - (NSArray *)listModuleTypes;
 
-/** Returns the SwordManager attached to this SwordInstallSourceController */
+/** Returns the SwordManager attached to this SwordInstallSource */
 - (SwordManager *)swordManager;
 
 #ifdef __cplusplus

Modified: trunk/bindings/objc/src/SwordInstallSource.mm
===================================================================
--- trunk/bindings/objc/src/SwordInstallSource.mm	2015-09-08 12:38:02 UTC (rev 3389)
+++ trunk/bindings/objc/src/SwordInstallSource.mm	2015-09-09 08:16:38 UTC (rev 3390)
@@ -141,7 +141,6 @@
     return ret;
 }
 
-// get associated SwordManager
 - (SwordManager *)swordManager {
     // create SwordManager from the SWMgr of this source
     sword::SWMgr *mgr;

Modified: trunk/bindings/objc/src/SwordManager.mm
===================================================================
--- trunk/bindings/objc/src/SwordManager.mm	2015-09-08 12:38:02 UTC (rev 3389)
+++ trunk/bindings/objc/src/SwordManager.mm	2015-09-09 08:16:38 UTC (rev 3390)
@@ -91,7 +91,9 @@
 
 - (void)dealloc {
     DLog(@"");
-    if(!self.deleteSWMgr) {
+    if(self.deleteSWMgr) {
+        // only delete swManager is we created it
+        // if it came from someplace else then we're not responsible
         ALog(@"Deleting SWMgr!");
         delete swManager;
     }
@@ -114,9 +116,6 @@
             ALog(@"Cannot create SWMgr instance for default module path!");
         } else {
             NSArray *subDirs = [fm contentsOfDirectoryAtPath:self.modulesPath error:NULL];
-            // for all sub directories add module
-            BOOL directory;
-            NSString *fullSubDir;
             NSString *subDir;
             for(subDir in subDirs) {
                 // as long as it's not hidden
@@ -124,10 +123,11 @@
                    ![subDir isEqualToString:@"InstallMgr"] && 
                    ![subDir isEqualToString:@"mods.d"] &&
                    ![subDir isEqualToString:@"modules"]) {
-                    fullSubDir = [self.modulesPath stringByAppendingPathComponent:subDir];
+                    NSString *fullSubDir = [self.modulesPath stringByAppendingPathComponent:subDir];
                     fullSubDir = [fullSubDir stringByStandardizingPath];
                     
                     //if its a directory
+                    BOOL directory;
                     if([fm fileExistsAtPath:fullSubDir isDirectory:&directory]) {
                         if(directory) {
                             DLog(@"Augmenting folder: %@", fullSubDir);




More information about the sword-cvs mailing list