Changeset 3052 for branches/mcstas-1.x

Show
Ignore:
Timestamp:
04/08/11 15:12:44 (14 months ago)
Author:
erkn
Message:

fixed potential crash (ticket #43)

Pol_simpleBfield set the precession routine pointer to NULL when
exiting the magnetic region. other components rely on its validity.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/mcstas-1.x/lib/optics/Pol_simpleBfield.comp

    r1673 r3052  
    145145  Coords localG = rot_apply(ROT_A_CURRENT_COMP, coords_set(0,-GRAVITY,0)); 
    146146 
     147  if(!mcMagnetPrecession)  
     148    mcMagnetPrecession = &SimpleNumMagnetPrecession; 
     149 
    147150  if(mcMagnet==0) { 
    148151     
     
    154157    parPtr[4] = yh; 
    155158    parPtr[5] = length; 
    156     MAGNET_ON; 
     159    //MAGNET_ON; 
    157160  } else {     
    158     MAGNET_OFF; 
     161    //MAGNET_OFF; 
    159162  } 
    160163 
     
    181184    MAGNET_ON; 
    182185    mcMagneticField = fieldFunction; 
    183     mcMagnetPrecession = &SimpleNumMagnetPrecession; 
    184186    mcMagnetData = parPtr; 
    185  
    186187    rot_copy(mcMagnetRot, ROT_A_CURRENT_COMP); 
    187188    mcMagnetPos = coords_scale(POS_A_CURRENT_COMP, 1.0); 
    188  
    189     // i=0: Bx parameter  
    190     // i=1: By parameter 
    191     // i=2: Bz parameter 
    192     // i=3: Magnet width 
    193     // i=4: Magnet height 
    194     // i=5: Magnet length 
    195      
    196189  } else { 
    197190     
     
    201194    MAGNET_OFF; 
    202195    mcMagneticField = NULL; 
    203     mcMagnetPrecession = NULL; 
    204196    mcMagnetData = NULL; 
    205197    // Here, we ought to clean up mcMagnet(Rot,Pos) 
    206198  } 
    207  
    208   //  printf("Exit z: %f, mcmagnet: %d\n", z, mcmagnet); 
    209  
    210   %} 
    211  
    212 /* This section is executed when the simulation ends (C code). Other    */ 
    213 /* optional sections are : SAVE                                         */ 
     199%} 
     200 
    214201FINALLY 
    215202%{