Changeset 1757 for trunk


Ignore:
Timestamp:
15/11/11 12:44:33 (6 months ago)
Author:
Freddie Akeroyd
Message:

Tidy up error handling to see if that helps. Refs #303

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/napi.c

    r1750 r1757  
    289289  /*---------------------------------------------------------------------*/ 
    290290 
    291   void *NXpData = NULL; 
    292   void *NXEHpData = NULL; 
    293   void (*NXEHIReportError)(void *pData, char *string) = NXNXNXReportError; 
     291  static void *NXEHpData = NULL; 
     292  static void (*NXEHIReportError)(void *pData, char *string) = NXNXNXReportError; 
    294293#ifdef HAVE_TLS 
    295   __thread void *NXEHpTData = NULL; 
    296   __thread void (*NXEHIReportTError)(void *pData, char *string) = NULL; 
     294  static __thread void *NXEHpTData = NULL; 
     295  static __thread void (*NXEHIReportTError)(void *pData, char *string) = NULL; 
    297296#endif 
    298297 
    299298  void NXIReportError(void *pData, char *string) { 
    300         fprintf(stderr, "Your application uses NXIReportError, but its first parameter is ignored now."); 
     299        fprintf(stderr, "Your application uses NXIReportError, but its first parameter is ignored now - you should use NXReportError."); 
    301300        NXReportError(string); 
    302301  } 
     
    309308        }  
    310309#endif 
    311  
    312         (*NXEHIReportError)(NXEHpData, string); 
     310        if (NXEHIReportError) { 
     311            (*NXEHIReportError)(NXEHpData, string); 
     312        } 
    313313  } 
    314314 
     
    340340 
    341341/*----------------------------------------------------------------------*/ 
    342 void NXNXNoReport(void *pData, char *string){ 
     342static void NXNXNoReport(void *pData, char *string){ 
    343343  /* do nothing */ 
    344344 
    345345/*----------------------------------------------------------------------*/ 
    346346 
    347 ErrFunc last_global_errfunc = NXNXNXReportError; 
     347static ErrFunc last_global_errfunc = NXNXNXReportError; 
    348348#ifdef HAVE_TLS 
    349 __thread ErrFunc last_thread_errfunc = NULL; 
     349static __thread ErrFunc last_thread_errfunc = NULL; 
    350350#endif 
    351351 
     
    356356                last_thread_errfunc = NXEHIReportTError; 
    357357                NXEHIReportTError = NXNXNoReport; 
    358                 return; 
     358                return; 
    359359        }  
    360         last_thread_errfunc = NULL; 
    361360#endif 
    362         last_global_errfunc = NXEHIReportError; 
    363         NXEHIReportError = NXNXNoReport; 
     361        if (NXEHIReportError) { 
     362            last_global_errfunc = NXEHIReportError; 
     363            NXEHIReportError = NXNXNoReport; 
     364        } 
    364365} 
    365366 
     
    370371                NXEHIReportTError = last_thread_errfunc; 
    371372                last_thread_errfunc = NULL; 
    372                 return; 
     373                return; 
    373374        }  
    374375#endif 
    375         NXEHIReportError = last_global_errfunc; 
     376        if (last_global_errfunc) { 
     377            NXEHIReportError = last_global_errfunc; 
     378            last_global_errfunc = NULL; 
     379        } 
    376380} 
    377381 
Note: See TracChangeset for help on using the changeset viewer.