Changeset 225

Show
Ignore:
Timestamp:
08/02/06 14:35:05 (2 years ago)
Author:
pragma
Message:

Patch to ensure that module initalizers are always run.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ddl/Linker.d

    r224 r225  
    260260    public void link(DynamicLibrary lib){ 
    261261        ModuleSet moduleSet; 
     262        Exception exception = null; 
    262263         
    263264        // link 
    264         foreach(DynamicModule mod; lib.getModules){ 
    265             this.link(mod,moduleSet); 
    266         } 
    267         // init 
     265        try{ 
     266            foreach(DynamicModule mod; lib.getModules){ 
     267                this.link(mod,moduleSet); 
     268            } 
     269        } 
     270        catch(Exception e){ 
     271            exception = e; // re-throw in a minute... 
     272        } 
     273         
     274        // init (run whatever initalizers are pending, regardless of failure) 
    268275        foreach(mod,moduleInfo; moduleSet){ 
    269276            debug debugLog("running %s init at [%0.8X]",mod.getName,cast(void*)moduleInfo); 
    270277            this.initModule(moduleInfo,0); 
    271278        } 
     279         
     280        //re-throw if need be 
     281        if(exception) throw exception; 
    272282    } 
    273283