summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2026-02-07 07:06:43 +0100
committerCarl Hetherington <cth@carlh.net>2026-02-07 07:06:43 +0100
commit2f93574e2ddef467bd879d559340f7967642615d (patch)
treef7946ba95e576cd420a289b47acc23619c8b414d /src/lib
parent3bffa32ae5083a61222b42f74a002bb4e061cec0 (diff)
Make "why_not" reasons an optional return.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dcp_content.cc96
-rw-r--r--src/lib/dcp_content.h8
-rw-r--r--src/lib/film.cc9
3 files changed, 70 insertions, 43 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index e37fbc9cc..ace0c0589 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -684,25 +684,31 @@ DCPContent::reel_split_points(shared_ptr<const Film> film) const
bool
-DCPContent::can_reuse_anything(shared_ptr<const Film> film, string& why_not) const
+DCPContent::can_reuse_anything(shared_ptr<const Film> film, string* why_not) const
{
/* We must be using the same standard as the film */
if (_standard) {
if (_standard.get() == dcp::Standard::INTEROP && !film->interop()) {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("it is Interop and the film is set to SMPTE.");
+ if (why_not) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("it is Interop and the film is set to SMPTE.");
+ }
return false;
} else if (_standard.get() == dcp::Standard::SMPTE && film->interop()) {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("it is SMPTE and the film is set to Interop.");
+ if (why_not) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("it is SMPTE and the film is set to Interop.");
+ }
return false;
}
}
/* And the same frame rate */
if (!video_frame_rate() || (lrint(video_frame_rate().get()) != film->video_frame_rate())) {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("it has a different frame rate to the film.");
+ if (why_not) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("it has a different frame rate to the film.");
+ }
return false;
}
@@ -724,8 +730,10 @@ DCPContent::can_reuse_anything(shared_ptr<const Film> film, string& why_not) con
*/
for (auto i: reel_list) {
if (find(fr.begin(), fr.end(), i) == fr.end()) {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("its reel lengths differ from those in the film; set the reel mode to 'split by video content'.");
+ if (why_not) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("its reel lengths differ from those in the film; set the reel mode to 'split by video content'.");
+ }
return false;
}
}
@@ -742,25 +750,31 @@ DCPContent::overlaps(shared_ptr<const Film> film, function<bool (shared_ptr<cons
bool
-DCPContent::can_reuse_video(shared_ptr<const Film> film, string& why_not) const
+DCPContent::can_reuse_video(shared_ptr<const Film> film, string* why_not) const
{
if (!video) {
- why_not = _("There is no video in this DCP");
+ if (why_not) {
+ *why_not = _("There is no video in this DCP");
+ }
return false;
}
if (film->resolution() != resolution()) {
- if (resolution() == Resolution::FOUR_K) {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("it is 4K and the film is 2K.");
- } else {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("it is 2K and the film is 4K.");
+ if (why_not) {
+ if (resolution() == Resolution::FOUR_K) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("it is 4K and the film is 2K.");
+ } else {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("it is 2K and the film is 4K.");
+ }
}
return false;
} else if (film->frame_size() != video->size()) {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("its video frame size differs from the film's.");
+ if (why_not) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("its video frame size differs from the film's.");
+ }
return false;
}
@@ -769,8 +783,10 @@ DCPContent::can_reuse_video(shared_ptr<const Film> film, string& why_not) const
};
if (overlaps(film, part)) {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("it overlaps other video content.");
+ if (why_not) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("it overlaps other video content.");
+ }
return false;
}
@@ -779,12 +795,14 @@ DCPContent::can_reuse_video(shared_ptr<const Film> film, string& why_not) const
bool
-DCPContent::can_reuse_audio(shared_ptr<const Film> film, string& why_not) const
+DCPContent::can_reuse_audio(shared_ptr<const Film> film, string* why_not) const
{
if (audio && audio->stream()) {
auto const channels = audio->stream()->channels();
if (channels != film->audio_channels()) {
- why_not = fmt::format(_("it has a different number of audio channels than the project; set the project to have {} channels."), channels);
+ if (why_not) {
+ *why_not = fmt::format(_("it has a different number of audio channels than the project; set the project to have {} channels."), channels);
+ }
return false;
}
}
@@ -794,8 +812,10 @@ DCPContent::can_reuse_audio(shared_ptr<const Film> film, string& why_not) const
};
if (overlaps(film, part)) {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("it overlaps other audio content.");
+ if (why_not) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("it overlaps other audio content.");
+ }
return false;
}
@@ -804,23 +824,29 @@ DCPContent::can_reuse_audio(shared_ptr<const Film> film, string& why_not) const
bool
-DCPContent::can_reuse_text(shared_ptr<const Film> film, TextType type, string& why_not) const
+DCPContent::can_reuse_text(shared_ptr<const Film> film, TextType type, string* why_not) const
{
if (_has_non_zero_entry_point[TextType::OPEN_SUBTITLE]) {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("one of its subtitle reels has a non-zero entry point so it must be re-written.");
+ if (why_not) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("one of its subtitle reels has a non-zero entry point so it must be re-written.");
+ }
return false;
}
if (_has_non_zero_entry_point[TextType::CLOSED_CAPTION]) {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("one of its closed caption has a non-zero entry point so it must be re-written.");
+ if (why_not) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("one of its closed caption has a non-zero entry point so it must be re-written.");
+ }
return false;
}
if (trim_start() != dcpomatic::ContentTime()) {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("it has a start trim so its subtitles or closed captions must be re-written.");
+ if (why_not) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("it has a start trim so its subtitles or closed captions must be re-written.");
+ }
return false;
}
@@ -829,8 +855,10 @@ DCPContent::can_reuse_text(shared_ptr<const Film> film, TextType type, string& w
};
if (overlaps(film, part)) {
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- why_not = _("it overlaps other text content.");
+ if (why_not) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ *why_not = _("it overlaps other text content.");
+ }
return false;
}
diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h
index 1dd00b015..bc60dadb7 100644
--- a/src/lib/dcp_content.h
+++ b/src/lib/dcp_content.h
@@ -130,7 +130,7 @@ public:
bool needs_kdm() const;
bool needs_assets() const;
- bool can_reuse_anything(std::shared_ptr<const Film> film, std::string& why_not) const;
+ bool can_reuse_anything(std::shared_ptr<const Film> film, std::string* why_not = nullptr) const;
void set_reference_video(bool r);
@@ -139,7 +139,7 @@ public:
return _reference_video;
}
- bool can_reuse_video(std::shared_ptr<const Film> film, std::string &) const;
+ bool can_reuse_video(std::shared_ptr<const Film> film, std::string* why_not = nullptr) const;
void set_reference_audio(bool r);
@@ -148,7 +148,7 @@ public:
return _reference_audio;
}
- bool can_reuse_audio(std::shared_ptr<const Film> film, std::string &) const;
+ bool can_reuse_audio(std::shared_ptr<const Film> film, std::string* why_not = nullptr) const;
void set_reference_text(TextType type, bool r);
@@ -160,7 +160,7 @@ public:
return _reference_text[type];
}
- bool can_reuse_text(std::shared_ptr<const Film> film, TextType type, std::string &) const;
+ bool can_reuse_text(std::shared_ptr<const Film> film, TextType type, std::string* why_not = nullptr) const;
bool reference_anything() const;
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 1a9185afa..16a38e21b 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -1810,20 +1810,19 @@ Film::check_settings_consistency()
continue;
}
- string why_not;
- if (d->reference_video() && !d->can_reuse_video(shared_from_this(), why_not)) {
+ if (d->reference_video() && !d->can_reuse_video(shared_from_this())) {
d->set_reference_video(false);
change_made = true;
}
- if (d->reference_audio() && !d->can_reuse_audio(shared_from_this(), why_not)) {
+ if (d->reference_audio() && !d->can_reuse_audio(shared_from_this())) {
d->set_reference_audio(false);
change_made = true;
}
- if (d->reference_text(TextType::OPEN_SUBTITLE) && !d->can_reuse_text(shared_from_this(), TextType::OPEN_SUBTITLE, why_not)) {
+ if (d->reference_text(TextType::OPEN_SUBTITLE) && !d->can_reuse_text(shared_from_this(), TextType::OPEN_SUBTITLE)) {
d->set_reference_text(TextType::OPEN_SUBTITLE, false);
change_made = true;
}
- if (d->reference_text(TextType::CLOSED_CAPTION) && !d->can_reuse_text(shared_from_this(), TextType::CLOSED_CAPTION, why_not)) {
+ if (d->reference_text(TextType::CLOSED_CAPTION) && !d->can_reuse_text(shared_from_this(), TextType::CLOSED_CAPTION)) {
d->set_reference_text(TextType::CLOSED_CAPTION, false);
change_made = true;
}