summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-01-08 16:25:42 +0100
committerCarl Hetherington <cth@carlh.net>2024-01-09 11:54:16 +0100
commit12d1abf033654727d6ab6278087ff7cfc65d63f6 (patch)
treeb920b3c3614fc91a1cb2a220972042e6318a6fd4
parentad41d2dd987ffcd2068d9fbf4273108c9f796762 (diff)
Move ScopeGuard into libdcp.
-rw-r--r--cscript2
-rw-r--r--src/lib/audio_buffers.cc6
-rw-r--r--src/lib/dcp_content.cc4
-rw-r--r--src/lib/scope_guard.h57
-rw-r--r--src/lib/util.cc4
-rw-r--r--src/lib/video_filter_graph.cc4
-rw-r--r--src/tools/dcpomatic_player.cc4
-rw-r--r--src/wx/content_panel.cc4
-rw-r--r--src/wx/controls.cc1
-rw-r--r--src/wx/fonts_dialog.cc1
-rw-r--r--src/wx/language_tag_widget.cc1
-rw-r--r--src/wx/region_subtag_widget.cc1
-rw-r--r--src/wx/screen_dialog.cc1
-rw-r--r--src/wx/screens_panel.cc8
-rw-r--r--src/wx/text_panel.cc4
-rw-r--r--src/wx/timeline.cc6
-rw-r--r--src/wx/timing_panel.cc1
-rw-r--r--test/scope_guard_test.cc36
-rw-r--r--test/wscript1
19 files changed, 23 insertions, 123 deletions
diff --git a/cscript b/cscript
index fde56ad77..7ef3b1c0d 100644
--- a/cscript
+++ b/cscript
@@ -507,7 +507,7 @@ def dependencies(target, options):
# Use distro-provided FFmpeg on Arch
deps = []
- deps.append(('libdcp', 'v1.8.92'))
+ deps.append(('libdcp', 'v1.8.93'))
deps.append(('libsub', 'v1.6.45'))
deps.append(('leqm-nrt', '30dcaea1373ac62fba050e02ce5b0c1085797a23'))
deps.append(('rtaudio', 'f619b76'))
diff --git a/src/lib/audio_buffers.cc b/src/lib/audio_buffers.cc
index 0e31793ea..9b88827f7 100644
--- a/src/lib/audio_buffers.cc
+++ b/src/lib/audio_buffers.cc
@@ -22,7 +22,7 @@
#include "audio_buffers.h"
#include "dcpomatic_assert.h"
#include "maths_util.h"
-#include "scope_guard.h"
+#include <dcp/scope_guard.h>
#include <cassert>
#include <cstring>
#include <cmath>
@@ -83,7 +83,7 @@ AudioBuffers::allocate (int channels, int frames)
DCPOMATIC_ASSERT (frames >= 0);
DCPOMATIC_ASSERT(frames == 0 || channels > 0);
- ScopeGuard sg = [this]() { update_data_pointers(); };
+ dcp::ScopeGuard sg = [this]() { update_data_pointers(); };
_data.resize(channels);
for (int channel = 0; channel < channels; ++channel) {
@@ -344,7 +344,7 @@ AudioBuffers::set_channels(int new_channels)
{
DCPOMATIC_ASSERT(new_channels > 0);
- ScopeGuard sg = [this]() { update_data_pointers(); };
+ dcp::ScopeGuard sg = [this]() { update_data_pointers(); };
int const old_channels = channels();
_data.resize(new_channels);
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index b9b64149f..f3751b1d8 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -31,7 +31,6 @@
#include "job.h"
#include "log.h"
#include "overlaps.h"
-#include "scope_guard.h"
#include "text_content.h"
#include "video_content.h"
#include <dcp/dcp.h>
@@ -41,6 +40,7 @@
#include <dcp/reel_picture_asset.h>
#include <dcp/reel_subtitle_asset.h>
#include <dcp/reel.h>
+#include <dcp/scope_guard.h>
#include <libxml++/libxml++.h>
#include <iterator>
#include <iostream>
@@ -224,7 +224,7 @@ DCPContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
string const old_name = name ();
ContentChangeSignalDespatcher::instance()->suspend();
- ScopeGuard sg = []() {
+ dcp::ScopeGuard sg = []() {
ContentChangeSignalDespatcher::instance()->resume();
};
diff --git a/src/lib/scope_guard.h b/src/lib/scope_guard.h
deleted file mode 100644
index ac60f9fea..000000000
--- a/src/lib/scope_guard.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic 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.
-
- DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-
-#ifndef DCPOMATIC_SCOPE_GUARD_H
-#define DCPOMATIC_SCOPE_GUARD_H
-
-
-#include <functional>
-
-
-class ScopeGuard
-{
-public:
- template <typename F>
- ScopeGuard (F const& function)
- : _function(function)
- {}
-
- ScopeGuard (ScopeGuard&& other)
- : _function(std::move(other._function))
- {
- other._function = []{};
- }
-
- ScopeGuard (ScopeGuard const&) = delete;
- ScopeGuard& operator=(ScopeGuard const&) = delete;
-
- ~ScopeGuard ()
- {
- _function();
- }
-
-private:
- std::function<void()> _function;
-};
-
-
-#endif
-
diff --git a/src/lib/util.cc b/src/lib/util.cc
index d23989afa..997470a21 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -46,7 +46,6 @@
#include "ratio.h"
#include "rect.h"
#include "render_text.h"
-#include "scope_guard.h"
#include "string_text.h"
#include "text_decoder.h"
#include "util.h"
@@ -58,6 +57,7 @@
#include <dcp/locale_convert.h>
#include <dcp/picture_asset.h>
#include <dcp/raw_convert.h>
+#include <dcp/scope_guard.h>
#include <dcp/sound_asset.h>
#include <dcp/subtitle_asset.h>
#include <dcp/util.h>
@@ -1094,7 +1094,7 @@ word_wrap(string input, int columns)
icu::Locale locale;
UErrorCode status = U_ZERO_ERROR;
auto iter = icu::BreakIterator::createLineInstance(locale, status);
- ScopeGuard sg = [iter]() { delete iter; };
+ dcp::ScopeGuard sg = [iter]() { delete iter; };
if (U_FAILURE(status)) {
return input;
}
diff --git a/src/lib/video_filter_graph.cc b/src/lib/video_filter_graph.cc
index 89467ae94..d5840c6d3 100644
--- a/src/lib/video_filter_graph.cc
+++ b/src/lib/video_filter_graph.cc
@@ -23,8 +23,8 @@
#include "dcpomatic_assert.h"
#include "exceptions.h"
#include "image.h"
-#include "scope_guard.h"
#include "video_filter_graph.h"
+#include <dcp/scope_guard.h>
extern "C" {
#include <libavfilter/buffersrc.h>
#include <libavfilter/buffersink.h>
@@ -63,7 +63,7 @@ VideoFilterGraph::process(shared_ptr<const Image> image)
throw std::bad_alloc();
}
- ScopeGuard sg = [&frame]() { av_frame_free(&frame); };
+ dcp::ScopeGuard sg = [&frame]() { av_frame_free(&frame); };
for (int i = 0; i < image->planes(); ++i) {
frame->data[i] = image->data()[i];
diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc
index 133cabf95..301e893ff 100644
--- a/src/tools/dcpomatic_player.cc
+++ b/src/tools/dcpomatic_player.cc
@@ -59,7 +59,6 @@
#include "lib/player.h"
#include "lib/player_video.h"
#include "lib/ratio.h"
-#include "lib/scope_guard.h"
#include "lib/scoped_temporary.h"
#include "lib/server.h"
#include "lib/text_content.h"
@@ -71,6 +70,7 @@
#include <dcp/exceptions.h>
#include <dcp/filesystem.h>
#include <dcp/raw_convert.h>
+#include <dcp/scope_guard.h>
#include <dcp/search.h>
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
@@ -707,7 +707,7 @@ private:
DCPOMATIC_ASSERT (dcp);
try {
if (dcp) {
- ScopeGuard sg([this]() {
+ dcp::ScopeGuard sg([this]() {
_viewer.set_coalesce_player_changes(false);
});
_viewer.set_coalesce_player_changes(true);
diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc
index 8a98bc1a4..1f54ae0cf 100644
--- a/src/wx/content_panel.cc
+++ b/src/wx/content_panel.cc
@@ -47,12 +47,12 @@
#include "lib/image_content.h"
#include "lib/log.h"
#include "lib/playlist.h"
-#include "lib/scope_guard.h"
#include "lib/string_text_file.h"
#include "lib/string_text_file_content.h"
#include "lib/text_content.h"
#include "lib/video_content.h"
#include <dcp/filesystem.h>
+#include <dcp/scope_guard.h>
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/display.h>
@@ -820,7 +820,7 @@ ContentPanel::set_selection (ContentList cl)
{
{
_no_check_selection = true;
- ScopeGuard sg = [this]() { _no_check_selection = false; };
+ dcp::ScopeGuard sg = [this]() { _no_check_selection = false; };
auto content = _film->content ();
for (size_t i = 0; i < content.size(); ++i) {
diff --git a/src/wx/controls.cc b/src/wx/controls.cc
index 0bb0960c8..097daf944 100644
--- a/src/wx/controls.cc
+++ b/src/wx/controls.cc
@@ -37,7 +37,6 @@
#include "lib/job.h"
#include "lib/job_manager.h"
#include "lib/player_video.h"
-#include "lib/scope_guard.h"
#include <dcp/cpl.h>
#include <dcp/dcp.h>
#include <dcp/reel.h>
diff --git a/src/wx/fonts_dialog.cc b/src/wx/fonts_dialog.cc
index f2c9de5cb..2fecdc086 100644
--- a/src/wx/fonts_dialog.cc
+++ b/src/wx/fonts_dialog.cc
@@ -25,7 +25,6 @@
#include "wx_util.h"
#include "lib/content.h"
#include "lib/font.h"
-#include "lib/scope_guard.h"
#include "lib/text_content.h"
#include <dcp/filesystem.h>
#include <dcp/warnings.h>
diff --git a/src/wx/language_tag_widget.cc b/src/wx/language_tag_widget.cc
index 17683daf1..2f6ad2b8a 100644
--- a/src/wx/language_tag_widget.cc
+++ b/src/wx/language_tag_widget.cc
@@ -23,7 +23,6 @@
#include "language_tag_dialog.h"
#include "language_tag_widget.h"
#include "wx_util.h"
-#include "lib/scope_guard.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/wx.h>
diff --git a/src/wx/region_subtag_widget.cc b/src/wx/region_subtag_widget.cc
index 66bba2285..d2c99762a 100644
--- a/src/wx/region_subtag_widget.cc
+++ b/src/wx/region_subtag_widget.cc
@@ -24,7 +24,6 @@
#include "region_subtag_dialog.h"
#include "region_subtag_widget.h"
#include "wx_util.h"
-#include "lib/scope_guard.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/wx.h>
diff --git a/src/wx/screen_dialog.cc b/src/wx/screen_dialog.cc
index 3b2a1bd85..0040ac31b 100644
--- a/src/wx/screen_dialog.cc
+++ b/src/wx/screen_dialog.cc
@@ -27,7 +27,6 @@
#include "table_dialog.h"
#include "wx_util.h"
#include "lib/compose.hpp"
-#include "lib/scope_guard.h"
#include "lib/util.h"
#include <dcp/warnings.h>
#include <dcp/exceptions.h>
diff --git a/src/wx/screens_panel.cc b/src/wx/screens_panel.cc
index 721f4f4cc..d3b1db77d 100644
--- a/src/wx/screens_panel.cc
+++ b/src/wx/screens_panel.cc
@@ -27,9 +27,9 @@
#include "wx_util.h"
#include "lib/cinema.h"
#include "lib/config.h"
-#include "lib/scope_guard.h"
#include "lib/screen.h"
#include "lib/timer.h"
+#include <dcp/scope_guard.h>
using std::cout;
@@ -258,7 +258,7 @@ ScreensPanel::add_cinema_clicked ()
try {
_ignore_cinemas_changed = true;
- ScopeGuard sg = [this]() { _ignore_cinemas_changed = false; };
+ dcp::ScopeGuard sg = [this]() { _ignore_cinemas_changed = false; };
Config::instance()->add_cinema(cinema);
} catch (FileError& e) {
error_dialog(GetParent(), _("Could not write cinema details to the cinemas.xml file. Check that the location of cinemas.xml is valid in DCP-o-matic's preferences."), std_to_wx(e.what()));
@@ -355,7 +355,7 @@ ScreensPanel::remove_cinema_clicked ()
for (auto const& cinema: cinemas_to_remove) {
_ignore_cinemas_changed = true;
- ScopeGuard sg = [this]() { _ignore_cinemas_changed = false; };
+ dcp::ScopeGuard sg = [this]() { _ignore_cinemas_changed = false; };
for (auto screen: cinema->screens()) {
_checked_screens.erase(screen);
}
@@ -717,7 +717,7 @@ bool
ScreensPanel::notify_cinemas_changed()
{
_ignore_cinemas_changed = true;
- ScopeGuard sg = [this]() { _ignore_cinemas_changed = false; };
+ dcp::ScopeGuard sg = [this]() { _ignore_cinemas_changed = false; };
try {
Config::instance()->changed(Config::CINEMAS);
diff --git a/src/wx/text_panel.cc b/src/wx/text_panel.cc
index 3b7973e30..78c024565 100644
--- a/src/wx/text_panel.cc
+++ b/src/wx/text_panel.cc
@@ -42,12 +42,12 @@
#include "lib/ffmpeg_subtitle_stream.h"
#include "lib/film.h"
#include "lib/job_manager.h"
-#include "lib/scope_guard.h"
#include "lib/string_text_file_content.h"
#include "lib/string_text_file_decoder.h"
#include "lib/subtitle_analysis.h"
#include "lib/text_content.h"
#include <dcp/filesystem.h>
+#include <dcp/scope_guard.h>
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/spinctrl.h>
@@ -813,7 +813,7 @@ TextPanel::try_to_load_analysis ()
}
_loading_analysis = true;
- ScopeGuard sg = [this]() {
+ dcp::ScopeGuard sg = [this]() {
_loading_analysis = false;
setup_sensitivity();
};
diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc
index 9af8c3b85..4683769d4 100644
--- a/src/wx/timeline.cc
+++ b/src/wx/timeline.cc
@@ -35,10 +35,10 @@
#include "lib/film.h"
#include "lib/image_content.h"
#include "lib/playlist.h"
-#include "lib/scope_guard.h"
#include "lib/text_content.h"
#include "lib/timer.h"
#include "lib/video_content.h"
+#include <dcp/scope_guard.h>
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/graphics.h>
@@ -161,7 +161,7 @@ Timeline::paint_labels ()
return;
}
- ScopeGuard sg = [gc]() { delete gc; };
+ dcp::ScopeGuard sg = [gc]() { delete gc; };
int vsx, vsy;
_labels_canvas->GetViewStart (&vsx, &vsy);
@@ -189,7 +189,7 @@ Timeline::paint_main ()
return;
}
- ScopeGuard sg = [gc]() { delete gc; };
+ dcp::ScopeGuard sg = [gc]() { delete gc; };
gc->SetAntialiasMode (wxANTIALIAS_DEFAULT);
diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc
index 98060bb87..55d9a5fbf 100644
--- a/src/wx/timing_panel.cc
+++ b/src/wx/timing_panel.cc
@@ -34,7 +34,6 @@
#include "lib/ffmpeg_content.h"
#include "lib/film.h"
#include "lib/image_content.h"
-#include "lib/scope_guard.h"
#include "lib/string_text_file_content.h"
#include "lib/text_content.h"
#include "lib/video_content.h"
diff --git a/test/scope_guard_test.cc b/test/scope_guard_test.cc
deleted file mode 100644
index f984f50db..000000000
--- a/test/scope_guard_test.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
-
- This file is part of DCP-o-matic.
-
- DCP-o-matic 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.
-
- DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-
-#include "lib/scope_guard.h"
-#include <boost/test/unit_test.hpp>
-
-
-BOOST_AUTO_TEST_CASE (scope_guard_test)
-{
- int x = 0;
-
- {
- ScopeGuard sg = [&x]() { x = 42; };
- BOOST_CHECK_EQUAL (x, 0);
- }
-
- BOOST_CHECK_EQUAL (x, 42);
-}
diff --git a/test/wscript b/test/wscript
index e8762009c..c5b06cc9e 100644
--- a/test/wscript
+++ b/test/wscript
@@ -138,7 +138,6 @@ def build(bld):
remake_with_subtitle_test.cc
render_subtitles_test.cc
scaling_test.cc
- scope_guard_test.cc
scoped_temporary_test.cc
silence_padding_test.cc
shuffler_test.cc