[Liblas-commits] hg: fix #213, liblas::Cleanup methods no using the proper cast t...

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Feb 17 13:14:51 EST 2011


details:   http://hg.liblas.orghg/rev/36ee969435d0
changeset: 2866:36ee969435d0
user:      Howard Butler <hobu.inc at gmail.com>
date:      Thu Feb 17 12:14:44 2011 -0600
description:
fix #213, liblas::Cleanup methods no using the proper cast to determine if they have a file-based stream

diffstat:

 include/liblas/liblas.hpp |  25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diffs (56 lines):

diff -r 04b6b1969b01 -r 36ee969435d0 include/liblas/liblas.hpp
--- a/include/liblas/liblas.hpp	Thu Feb 17 11:33:38 2011 -0600
+++ b/include/liblas/liblas.hpp	Thu Feb 17 12:14:44 2011 -0600
@@ -168,17 +168,22 @@
     if (!ofs) return;
 #ifdef USE_BOOST_IO
     namespace io = boost::iostreams;
-    if (static_cast<io::stream<io::file_sink>&>(*ofs))
+    namespace io = boost::iostreams;
+    io::stream<io::file_sink>* source = dynamic_cast<io::stream<io::file_sink>*>(ofs);
+    if (source)
     {
-        static_cast<io::stream<io::file_sink>&>(*ofs).close();
+        source->close();
         delete ofs;
     }
+
 #else
-    if (static_cast<std::ofstream&>(*ofs))
+    std::ofstream* source = dynamic_cast<std::ofstream*>(ofs);
+    if (source)
     {
-        static_cast<std::ofstream&>(*ofs).close();
+        source->close();
         delete ofs;
     }
+    
 #endif
 }
 
@@ -189,17 +194,21 @@
     if (!ifs) return;
 #ifdef USE_BOOST_IO
     namespace io = boost::iostreams;
-    if (static_cast<io::stream<io::file_source>&>(*ifs))
+    io::stream<io::file_source>* source = dynamic_cast<io::stream<io::file_source>*>(ifs);
+    if (source)
     {
-        static_cast<io::stream<io::file_source>&>(*ifs).close();
+        source->close();
         delete ifs;
     }
 #else
-    if (static_cast<std::ifstream&>(*ifs))
+    std::ifstream* source = dynamic_cast<std::ifstream*>(ifs);
+    if (source)
     {
-        static_cast<std::ifstream&>(*ifs).close();
+        source->close();
         delete ifs;
     }
+
+
 #endif
 }
 


More information about the Liblas-commits mailing list