Remove POSIX backtraces; move ScopedTemporary into its own file.
authorCarl Hetherington <cth@carlh.net>
Mon, 22 Dec 2014 03:58:05 +0000 (03:58 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 22 Dec 2014 03:58:05 +0000 (03:58 +0000)
src/lib/internet.cc
src/lib/scoped_temporary.cc [new file with mode: 0644]
src/lib/scoped_temporary.h [new file with mode: 0644]
src/lib/util.cc
src/lib/util.h
src/lib/wscript
src/wx/about_dialog.cc

index 1c61e96e3bebe3eeced3e1a9a3717ff737675fde..b45eaabf7580ec2c74a0d0559d3b0ed54b377223 100644 (file)
@@ -23,7 +23,8 @@
 #include <boost/filesystem.hpp>
 #include <curl/curl.h>
 #include <zip.h>
-#include "util.h"
+#include "scoped_temporary.h"
+#include "compose.hpp"
 #include "safe_stringstream.h"
 
 #include "i18n.h"
diff --git a/src/lib/scoped_temporary.cc b/src/lib/scoped_temporary.cc
new file mode 100644 (file)
index 0000000..c64f632
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "scoped_temporary.h"
+
+/** Construct a ScopedTemporary.  A temporary filename is decided but the file is not opened
+ *  until ::open() is called.
+ */
+ScopedTemporary::ScopedTemporary ()
+       : _open (0)
+{
+       _file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path ();
+}
+
+/** Close and delete the temporary file */
+ScopedTemporary::~ScopedTemporary ()
+{
+       close ();       
+       boost::system::error_code ec;
+       boost::filesystem::remove (_file, ec);
+}
+
+/** @return temporary filename */
+char const *
+ScopedTemporary::c_str () const
+{
+       return _file.string().c_str ();
+}
+
+/** Open the temporary file.
+ *  @return File's FILE pointer.
+ */
+FILE*
+ScopedTemporary::open (char const * params)
+{
+       _open = fopen (c_str(), params);
+       return _open;
+}
+
+/** Close the file */
+void
+ScopedTemporary::close ()
+{
+       if (_open) {
+               fclose (_open);
+               _open = 0;
+       }
+}
diff --git a/src/lib/scoped_temporary.h b/src/lib/scoped_temporary.h
new file mode 100644 (file)
index 0000000..927bce6
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <boost/filesystem.hpp>
+#include <cstdio>
+
+/** @class ScopedTemporary
+ *  @brief A temporary file which is deleted when the ScopedTemporary object goes out of scope.
+ */
+class ScopedTemporary
+{
+public:
+       ScopedTemporary ();
+       ~ScopedTemporary ();
+
+       /** @return temporary filename */
+       boost::filesystem::path file () const {
+               return _file;
+       }
+
+       char const * c_str () const;
+       FILE* open (char const *);
+       void close ();
+
+private:
+       boost::filesystem::path _file;
+       FILE* _open;
+};
index ebb7c046b7831c7d1624d1ac07db7709d6d91307..3ab864c2ff5db919c31b5224dc5731dd52379444 100644 (file)
@@ -188,65 +188,6 @@ seconds_to_approximate_hms (int s)
        return ap.str ();
 }
 
-#ifdef DCPOMATIC_POSIX
-/** @param l Mangled C++ identifier.
- *  @return Demangled version.
- */
-static string
-demangle (string l)
-{
-       string::size_type const b = l.find_first_of (N_("("));
-       if (b == string::npos) {
-               return l;
-       }
-
-       string::size_type const p = l.find_last_of (N_("+"));
-       if (p == string::npos) {
-               return l;
-       }
-
-       if ((p - b) <= 1) {
-               return l;
-       }
-       
-       string const fn = l.substr (b + 1, p - b - 1);
-
-       int status;
-       try {
-               
-               char* realname = abi::__cxa_demangle (fn.c_str(), 0, 0, &status);
-               string d (realname);
-               free (realname);
-               return d;
-               
-       } catch (std::exception) {
-               
-       }
-       
-       return l;
-}
-
-/** Write a stacktrace to an ostream.
- *  @param out Stream to write to.
- *  @param levels Number of levels to go up the call stack.
- */
-void
-stacktrace (ostream& out, int levels)
-{
-       void *array[200];
-       size_t size = backtrace (array, 200);
-       char** strings = backtrace_symbols (array, size);
-     
-       if (strings) {
-               for (size_t i = 0; i < size && (levels == 0 || i < size_t(levels)); i++) {
-                       out << N_("  ") << demangle (strings[i]) << "\n";
-               }
-               
-               free (strings);
-       }
-}
-#endif
-
 /** @param v Version as used by FFmpeg.
  *  @return A string representation of v.
  */
@@ -365,9 +306,6 @@ terminate ()
                          << std::endl;
        }
 
-#ifdef DCPOMATIC_POSIX
-       stacktrace (cout, 50);
-#endif
        abort();
 }
 
@@ -934,50 +872,6 @@ dependency_version_summary ()
        return s.str ();
 }
 
-/** Construct a ScopedTemporary.  A temporary filename is decided but the file is not opened
- *  until ::open() is called.
- */
-ScopedTemporary::ScopedTemporary ()
-       : _open (0)
-{
-       _file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path ();
-}
-
-/** Close and delete the temporary file */
-ScopedTemporary::~ScopedTemporary ()
-{
-       close ();       
-       boost::system::error_code ec;
-       boost::filesystem::remove (_file, ec);
-}
-
-/** @return temporary filename */
-char const *
-ScopedTemporary::c_str () const
-{
-       return _file.string().c_str ();
-}
-
-/** Open the temporary file.
- *  @return File's FILE pointer.
- */
-FILE*
-ScopedTemporary::open (char const * params)
-{
-       _open = fopen (c_str(), params);
-       return _open;
-}
-
-/** Close the file */
-void
-ScopedTemporary::close ()
-{
-       if (_open) {
-               fclose (_open);
-               _open = 0;
-       }
-}
-
 ContentTimePeriod
 subtitle_period (AVSubtitle const & sub)
 {
index 1c122b70c9e018f4ddefc392c356d6b6d841b925..ede53e0d9797c27a1d6ae04847fb4c3bc0df219b 100644 (file)
@@ -1,6 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
-    Copyright (C) 2000-2007 Paul Davis
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -45,7 +44,9 @@ extern "C" {
 
 /** The maximum number of audio channels that we can have in a DCP */
 #define MAX_DCP_AUDIO_CHANNELS 12
+/** Message broadcast to find possible encoding servers */
 #define DCPOMATIC_HELLO "Boys, you gotta learn not to talk to nuns that way"
+/** Number of films to keep in history */
 #define HISTORY_SIZE 10
 #define REPORT_PROBLEM _("Please report this problem by using Help -> Report a problem or via email to carl@dcpomatic.com")
 
@@ -56,7 +57,6 @@ struct AVSubtitle;
 
 extern std::string seconds_to_hms (int);
 extern std::string seconds_to_approximate_hms (int);
-extern void stacktrace (std::ostream &, int);
 extern std::string dependency_version_summary ();
 extern double seconds (struct timeval);
 extern void dcpomatic_setup ();
@@ -128,28 +128,5 @@ private:
 
 extern int64_t video_frames_to_audio_frames (VideoFrame v, float audio_sample_rate, float frames_per_second);
 
-/** @class ScopedTemporary
- *  @brief A temporary file which is deleted when the ScopedTemporary object goes out of scope.
- */
-class ScopedTemporary
-{
-public:
-       ScopedTemporary ();
-       ~ScopedTemporary ();
-
-       /** @return temporary filename */
-       boost::filesystem::path file () const {
-               return _file;
-       }
-
-       char const * c_str () const;
-       FILE* open (char const *);
-       void close ();
-
-private:
-       boost::filesystem::path _file;
-       FILE* _open;
-};
-
 #endif
 
index ca6a493759dcd23d8babb81073dee5f8da3ec7ab..7d68959494d7631c88a218219962ea75c9c626c3 100644 (file)
@@ -71,6 +71,7 @@ sources = """
           safe_stringstream.cc
           scp_dcp_job.cc
           scaler.cc
+          scoped_temporary.cc
           send_kdm_email_job.cc
           send_problem_report_job.cc
           server.cc
index d4a8b2113b9d9adb1338b1594f58e3894e0d5e3b..699a7aafcf2f676621a0db326fcee35f881d6495 100644 (file)
@@ -79,7 +79,7 @@ AboutDialog::AboutDialog (wxWindow* parent)
 
        t = new wxStaticText (
                this, wxID_ANY,
-               _("(C) 2012-2014 Carl Hetherington, Terrence Meiczinger, Paul Davis,\n Ole Laursen, Brecht Sanders"),
+               _("(C) 2012-2014 Carl Hetherington, Terrence Meiczinger\n Ole Laursen, Brecht Sanders"),
                wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER
                );