diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-09-22 14:01:43 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-09-22 14:01:43 +0100 |
| commit | 292012d86ffda3c19530ad8e9d8788a51db2b6c5 (patch) | |
| tree | f17d437780741d0b7a7f213fa7984ceae858be57 /src | |
| parent | 29ea42492bc810fed9cd62be5d6ffc735c851979 (diff) | |
Do interruption of ThreadStaticText properly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/film.cc | 10 | ||||
| -rw-r--r-- | src/lib/film.h | 1 | ||||
| -rw-r--r-- | src/wx/properties_dialog.cc | 7 | ||||
| -rw-r--r-- | src/wx/wx_util.cc | 2 |
4 files changed, 16 insertions, 4 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 92b91d0ac..d5327aa3a 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -647,6 +647,12 @@ Film::encoded_frames () const if (format() == 0) { return 0; } - - return distance (filesystem::directory_iterator (j2k_dir()), filesystem::directory_iterator ()); + + int N = 0; + for (filesystem::directory_iterator i = filesystem::directory_iterator (j2k_dir ()); i != filesystem::directory_iterator(); ++i) { + ++N; + this_thread::interruption_point (); + } + + return N; } diff --git a/src/lib/film.h b/src/lib/film.h index 40aa7b0f6..cd3b1b8a8 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -29,6 +29,7 @@ #include <vector> #include <inttypes.h> #include <boost/thread/mutex.hpp> +#include <boost/thread.hpp> #include <sigc++/signal.h> extern "C" { #include <libavcodec/avcodec.h> diff --git a/src/wx/properties_dialog.cc b/src/wx/properties_dialog.cc index 0a997bc41..e6c6c9f81 100644 --- a/src/wx/properties_dialog.cc +++ b/src/wx/properties_dialog.cc @@ -76,7 +76,12 @@ string PropertiesDialog::frames_already_encoded () const { stringstream u; - u << _film->encoded_frames(); + try { + u << _film->encoded_frames (); + } catch (thread_interrupted &) { + return ""; + } + if (_film->length()) { u << " (" << (_film->encoded_frames() * 100 / _film->length()) << "%)"; } diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 712e23570..44d9462e5 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -70,7 +70,7 @@ ThreadedStaticText::ThreadedStaticText (wxWindow* parent, string initial, functi ThreadedStaticText::~ThreadedStaticText () { - /* XXX: this is a bit unfortunate */ + _thread->interrupt (); _thread->join (); delete _thread; } |
