#include "lib/exceptions.h"
#include "lib/ffmpeg_encoder.h"
#include "lib/film.h"
+#include "lib/font_config.h"
#include "lib/hints.h"
#include "lib/job_manager.h"
#include "lib/kdm_with_metadata.h"
, _right_panel(new wxPanel(_splitter, wxID_ANY))
, _film_viewer(_right_panel)
{
-#if defined(DCPOMATIC_WINDOWS)
- if (Config::instance()->win32_console()) {
- AllocConsole();
-
- HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
- int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT);
- FILE* hf_out = _fdopen(hCrt, "w");
- setvbuf(hf_out, NULL, _IONBF, 1);
- *stdout = *hf_out;
-
- HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
- hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT);
- FILE* hf_in = _fdopen(hCrt, "r");
- setvbuf(hf_in, NULL, _IONBF, 128);
- *stdin = *hf_in;
-
- cout << "DCP-o-matic is starting." << "\n";
- }
-#endif
auto bar = new wxMenuBar;
setup_menu (bar);
left_panel->SetSizerAndFit(left_sizer);
_controls = new StandardControls(_right_panel, _film_viewer, true);
+ _controls->set_film(_film_viewer.film());
auto job_manager_view = new JobManagerView(_right_panel, false);
auto right_sizer = new wxBoxSizer (wxVERTICAL);
} catch (boost::filesystem::filesystem_error& e) {
#ifdef DCPOMATIC_WINDOWS
string bad_chars = "<>:\"/|?*";
- string const filename = d->path().filename().string();
+ string const filename = dialog.path().filename().string();
string found_bad_chars;
for (size_t i = 0; i < bad_chars.length(); ++i) {
if (filename.find(bad_chars[i]) != string::npos && found_bad_chars.find(bad_chars[i]) == string::npos) {
void file_save ()
{
- _film->write_metadata ();
+ try {
+ _film->write_metadata ();
+ } catch (exception& e) {
+ error_dialog(this, _("Could not save project."), std_to_wx(e.what()));
+ }
}
void file_save_as_template ()
{
SaveTemplateDialog dialog(this);
if (dialog.ShowModal() == wxID_OK) {
- Config::instance()->save_template(_film, dialog.name());
+ try {
+ Config::instance()->save_template(_film, dialog.name());
+ } catch (exception& e) {
+ error_dialog(this, _("Could not save template."), std_to_wx(e.what()));
+ }
}
}
auto film = make_shared<Film>(dialog.path());
film->copy_from (_film);
film->set_name(dialog.path().filename().generic_string());
- film->write_metadata ();
+ try {
+ film->write_metadata();
+ } catch (exception& e) {
+ error_dialog(this, _("Could not duplicate project."), std_to_wx(e.what()));
+ }
}
}
auto film = make_shared<Film>(dialog.path());
film->copy_from (_film);
film->set_name(dialog.path().filename().generic_string());
- film->write_metadata ();
- set_film (film);
+ try {
+ film->write_metadata ();
+ set_film (film);
+ } catch (exception& e) {
+ error_dialog(this, _("Could not duplicate project."), std_to_wx(e.what()));
+ }
}
}
void edit_copy ()
{
auto const sel = _film_editor->content_panel()->selected();
- DCPOMATIC_ASSERT (sel.size() == 1);
- _clipboard = sel.front()->clone();
+ if (sel.size() == 1) {
+ _clipboard = sel.front()->clone();
+ }
}
void edit_paste ()
{
- DCPOMATIC_ASSERT (_clipboard);
+ if (!_clipboard) {
+ return;
+ }
PasteDialog dialog(this, static_cast<bool>(_clipboard->video), static_cast<bool>(_clipboard->audio), !_clipboard->text.empty());
if (dialog.ShowModal() != wxID_OK) {
dcp::LocalTime to (Config::instance()->signer_chain()->leaf().not_after());
to.add_days (-1);
- optional<dcp::EncryptedKDM> kdm;
- try {
- kdm = _film->make_kdm (
- Config::instance()->decryption_chain()->leaf(),
- vector<string>(),
- dialog.cpl(),
- from, to,
- dcp::Formulation::MODIFIED_TRANSITIONAL_1,
- true,
- 0
- );
- } catch (dcp::NotEncryptedError& e) {
- error_dialog (this, _("CPL's content is not encrypted."));
- } catch (exception& e) {
- error_dialog (this, e.what ());
- } catch (...) {
- error_dialog (this, _("An unknown exception occurred."));
+ auto signer = Config::instance()->signer_chain();
+ if (!signer->valid()) {
+ error_dialog(this, _("The certificate chain for signing is invalid"));
+ return;
}
- if (kdm) {
+ optional<dcp::EncryptedKDM> kdm;
+ try {
+ auto const decrypted_kdm = _film->make_kdm(dialog.cpl(), from, to);
+ auto const kdm = decrypted_kdm.encrypt(signer, Config::instance()->decryption_chain()->leaf(), {}, dcp::Formulation::MODIFIED_TRANSITIONAL_1, true, 0);
if (dialog.internal()) {
auto dkdms = Config::instance()->dkdms();
- dkdms->add (make_shared<DKDM>(kdm.get()));
+ dkdms->add(make_shared<DKDM>(kdm));
Config::instance()->changed ();
} else {
auto path = dialog.directory() / (_film->dcp_name(false) + "_DKDM.xml");
- kdm->as_xml (path);
+ kdm.as_xml(path);
}
+ } catch (dcp::NotEncryptedError& e) {
+ error_dialog (this, _("CPL's content is not encrypted."));
+ } catch (exception& e) {
+ error_dialog (this, e.what ());
+ } catch (...) {
+ error_dialog (this, _("An unknown exception occurred."));
}
}
for (auto i: translations) {
body += i.first + "\n" + i.second + "\n\n";
}
- list<string> to = { "carl@dcpomatic.com" };
if (dialog.email().find("@") == string::npos) {
error_dialog (this, _("You must enter a valid email address when sending translations, "
"otherwise the DCP-o-matic maintainers cannot credit you or contact you with questions."));
} else {
- Emailer emailer(dialog.email(), to, "DCP-o-matic translations", body);
+ Emailer emailer(dialog.email(), { "carl@dcpomatic.com" }, "DCP-o-matic translations", body);
try {
emailer.send ("main.carlh.net", 2525, EmailProtocol::STARTTLS);
} catch (NetworkError& e) {
/* Also stop hearing about analytics-related stuff */
_analytics_message_connection.disconnect ();
+ FontConfig::drop();
+
ev.Skip ();
}
return true;
}
- if (_film->dirty ()) {
- T d (_film->name ());
- switch (d.run ()) {
+ while (_film->dirty()) {
+ T dialog(_film->name());
+ switch (dialog.run()) {
case wxID_NO:
return true;
case wxID_YES:
- _film->write_metadata ();
- return true;
+ try {
+ _film->write_metadata();
+ return true;
+ } catch (exception& e) {
+ error_dialog(this, _("Could not save project."), std_to_wx(e.what()));
+ /* Go round again for another try */
+ }
+ break;
case wxID_CANCEL:
return false;
}
bool OnInit () override
{
try {
+
+#if defined(DCPOMATIC_WINDOWS)
+ if (Config::instance()->win32_console()) {
+ AllocConsole();
+
+ HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
+ int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT);
+ FILE* hf_out = _fdopen(hCrt, "w");
+ setvbuf(hf_out, NULL, _IONBF, 1);
+ *stdout = *hf_out;
+
+ HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
+ hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT);
+ FILE* hf_in = _fdopen(hCrt, "r");
+ setvbuf(hf_in, NULL, _IONBF, 128);
+ *stdin = *hf_in;
+
+ cout << "DCP-o-matic is starting." << "\n";
+ }
+#endif
wxInitAllImageHandlers ();
Config::FailedToLoad.connect(boost::bind(&App::config_failed_to_load, this, _1));
}
catch (exception& e)
{
- _splash.reset();
+ close_splash();
error_dialog (nullptr, wxString::Format ("DCP-o-matic could not start."), std_to_wx(e.what()));
}
void close_splash ()
{
- _splash.reset();
+ if (_splash) {
+ _splash->Destroy();
+ _splash = nullptr;
+ }
}
void config_failed_to_load (Config::LoadFailure what)
/* Destroy the splash screen here, as otherwise bad things seem to happen (for reasons unknown)
when we open our recreate dialog, close it, *then* try to Destroy the splash (the Destroy fails).
*/
- _splash.reset();
+ close_splash();
auto config = Config::instance();
switch (reason) {
}
DOMFrame* _frame = nullptr;
- wx_ptr<wxSplashScreen> _splash;
+ wxSplashScreen* _splash = nullptr;
shared_ptr<wxTimer> _timer;
string _film_to_load;
string _film_to_create;