summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-12-22 03:58:05 +0000
committerCarl Hetherington <cth@carlh.net>2014-12-22 03:58:05 +0000
commit59f63e2b6d0dba963faee7dfee54fbb48dee396a (patch)
tree29ecb7853c0429a3c8050bde2d147b7d59ff2a8c /src
parent3f8953593f8f55cef214ca259fe4aa4fa2f25ad4 (diff)
Remove POSIX backtraces; move ScopedTemporary into its own file.
Diffstat (limited to 'src')
-rw-r--r--src/lib/internet.cc3
-rw-r--r--src/lib/scoped_temporary.cc64
-rw-r--r--src/lib/scoped_temporary.h44
-rw-r--r--src/lib/util.cc106
-rw-r--r--src/lib/util.h29
-rw-r--r--src/lib/wscript1
-rw-r--r--src/wx/about_dialog.cc2
7 files changed, 115 insertions, 134 deletions
diff --git a/src/lib/internet.cc b/src/lib/internet.cc
index 1c61e96e3..b45eaabf7 100644
--- a/src/lib/internet.cc
+++ b/src/lib/internet.cc
@@ -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
index 000000000..c64f63243
--- /dev/null
+++ b/src/lib/scoped_temporary.cc
@@ -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
index 000000000..927bce6e7
--- /dev/null
+++ b/src/lib/scoped_temporary.h
@@ -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;
+};
diff --git a/src/lib/util.cc b/src/lib/util.cc
index ebb7c046b..3ab864c2f 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -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)
{
diff --git a/src/lib/util.h b/src/lib/util.h
index 1c122b70c..ede53e0d9 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -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
diff --git a/src/lib/wscript b/src/lib/wscript
index ca6a49375..7d6895949 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -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
diff --git a/src/wx/about_dialog.cc b/src/wx/about_dialog.cc
index d4a8b2113..699a7aafc 100644
--- a/src/wx/about_dialog.cc
+++ b/src/wx/about_dialog.cc
@@ -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
);