[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 470d89643f3fad67660d38d75f66ad897e04d64a..5d7f4f546f400bbced8ba6c0912181e5d3116ba2 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 7710602171b4b7e6ea61d46bf8acbc01a68428d1..2ea30174636fbe62934622141d7390dd375e7059 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 1c4a1a7b9507c8f9a8cf6ec3064bf7912c47f0fb..9c19c53b1e126ec54bd67a5db419f8a732b6da6a 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)