commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 06/07: call do_update after calling open in


From: git
Subject: [Commit-gnuradio] [gnuradio] 06/07: call do_update after calling open in the file source constructor, otherwise if seek is called before work, a segmentation fault will occur as d_fp is null
Date: Thu, 26 Jun 2014 19:54:37 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch maint
in repository gnuradio.

commit 4f6b982c87b36a377ed270f2fd4ae6cddb6e0aa3
Author: cottrema <address@hidden>
Date:   Mon Jun 23 11:02:08 2014 +1200

    call do_update after calling open in the file source constructor,
    otherwise if seek is called before work, a segmentation fault will occur
    as d_fp is null
---
 gr-blocks/lib/file_source_impl.cc              |  1 +
 gr-blocks/python/blocks/qa_file_source_sink.py | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/gr-blocks/lib/file_source_impl.cc 
b/gr-blocks/lib/file_source_impl.cc
index 941ca15..0c3d752 100644
--- a/gr-blocks/lib/file_source_impl.cc
+++ b/gr-blocks/lib/file_source_impl.cc
@@ -67,6 +67,7 @@ namespace gr {
        d_updated(false)
     {
       open(filename, repeat);
+      do_update();
     }
 
     file_source_impl::~file_source_impl()
diff --git a/gr-blocks/python/blocks/qa_file_source_sink.py 
b/gr-blocks/python/blocks/qa_file_source_sink.py
index f35912b..89841d3 100644
--- a/gr-blocks/python/blocks/qa_file_source_sink.py
+++ b/gr-blocks/python/blocks/qa_file_source_sink.py
@@ -88,6 +88,22 @@ class test_file_source_sink(gr_unittest.TestCase):
         result_data = snk2.data()
         self.assertFloatTuplesAlmostEqual(expected_result, result_data)
 
+    def test_file_source_can_seek_after_open(self):
+        src_data = range(1000)
+
+        filename = "tmp.32f"
+        src = blocks.vector_source_f(src_data)
+        snk = blocks.file_sink(gr.sizeof_float, filename)
+        snk.set_unbuffered(True)
+
+        self.tb.connect(src, snk)
+        self.tb.run()
+
+        source = blocks.file_source(gr.sizeof_float, filename)
+        self.assertTrue(source.seek(0, os.SEEK_SET))
+
+        os.remove(filename)
+
 if __name__ == '__main__':
     gr_unittest.run(test_file_source_sink, "test_file_source_sink.xml")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]