Small bugfix: save options on tech setup page

The effect was: when not having save options in the technology
setup (for example, when migrating from 0.24 to 0.25), it was
not possible to edit the save options page in the technology
manager because the data slot of the save options wasn't
initialized.
This commit is contained in:
Matthias Koefferlein 2017-07-31 23:13:36 +02:00
parent 919d2d56fa
commit ffeacd4630
1 changed files with 9 additions and 1 deletions

View File

@ -285,7 +285,14 @@ TechSaveOptionsEditorPage::setup ()
{
for (std::vector< std::pair<StreamWriterOptionsPage *, std::string> >::iterator page = m_pages.begin (); page != m_pages.end (); ++page) {
if (page->first) {
page->first->setup (tech ()->save_layout_options ().get_options (page->second), tech ());
const db::FormatSpecificWriterOptions *specific_options = tech ()->save_layout_options ().get_options (page->second);
std::auto_ptr<db::FormatSpecificWriterOptions> default_options;
if (! specific_options) {
// In case there is no option object yet, create a first one for initialization
default_options.reset (StreamWriterPluginDeclaration::plugin_for_format (page->second)->create_specific_options ());
specific_options = default_options.get ();
}
page->first->setup (specific_options, tech ());
}
}
}
@ -299,6 +306,7 @@ TechSaveOptionsEditorPage::commit ()
if (page->first) {
db::FormatSpecificWriterOptions *specific_options = options.get_options (page->second);
if (! specific_options) {
// Create a container for the options unless there is one already
specific_options = StreamWriterPluginDeclaration::plugin_for_format (page->second)->create_specific_options ();
options.set_options (specific_options);
}