[rt #69877] don't leave t1 marked as initialized if re-init fails
authorTony Cook <tony@develop-help.com>
Sun, 21 Aug 2011 10:36:16 +0000 (20:36 +1000)
committerTony Cook <tony@develop-help.com>
Sun, 21 Aug 2011 10:36:16 +0000 (20:36 +1000)
also, more error handling in Imager::init()

Changes
Imager.pm
T1/imt1.c

diff --git a/Changes b/Changes
index 470d896..5d7f4f5 100644 (file)
--- a/Changes
+++ b/Changes
@@ -33,6 +33,10 @@ Bug fixes:
    them when available.
    https://rt.cpan.org/Ticket/Display.html?id=69147
 
+ - if t1lib failed to reinitialize it would be left as marked
+   initialized.
+   https://rt.cpan.org/Ticket/Display.html?id=69877
+
 Imager 0.84_01 - 8 Aug 2011
 ==============
 
index 7710602..2ea3017 100644 (file)
--- a/Imager.pm
+++ b/Imager.pm
@@ -459,19 +459,26 @@ sub init_log {
 
 sub init {
   my %parms=(loglevel=>1,@_);
-  if ($parms{'log'}) {
-    Imager->open_log(log => $parms{log}, level => $parms{loglevel});
-  }
 
   if (exists $parms{'warn_obsolete'}) {
     $warn_obsolete = $parms{'warn_obsolete'};
   }
 
+  if ($parms{'log'}) {
+    Imager->open_log(log => $parms{log}, level => $parms{loglevel})
+      or return;
+  }
+
   if (exists $parms{'t1log'}) {
     if ($formats{t1}) {
-      Imager::Font::T1::i_init_t1($parms{'t1log'});
+      if (Imager::Font::T1::i_init_t1($parms{'t1log'})) {
+       Imager->_set_error(Imager->_error_as_msg);
+       return;
+      }
     }
   }
+
+  return 1;
 }
 
 {
index 1c4a1a7..9c19c53 100644 (file)
--- a/T1/imt1.c
+++ b/T1/imt1.c
@@ -34,6 +34,7 @@ i_init_t1(int t1log) {
 
   if (t1_initialized) {
     T1_CloseLib();
+    t1_initialized = 0;
   }
   
   if (t1log)