scantailor/scantailor — pull request #101 by jbaiter (2014-07-04 20:22:38+00:00)
Title: Only set options from command-line if they were explicitely specified

This patch fixes an issue with `scantailor-cli` that caused settings from the configuration file to be overwritten by the command-line defaults. (see https://github.com/DIYBookScanner/spreads/pull/112#issuecomment-48022697)
This occured due to the fact that `QMap m_options` in the `CommandLine` class would set a key once it was queried.

As an example, the following method would be called **before** a later call to `hasColorParams`, which checks if an option was set from the commandline by calling `contains` on the `QMap`:

output::ColorParams::ColorMode
CommandLine::fetchColorMode()
{
// This seems to set "color-mode" in the QMap
QString cm = m_options["color-mode"].toLower();

if (cm == "color_grayscale")
return output::ColorParams::COLOR_GRAYSCALE;
else if (cm == "mixed")
return output::ColorParams::MIXED;

return output::ColorParams::BLACK_AND_WHITE;
}

When the program would later check for a user-supplied color parameter from the command-line via `hasColorParams` it would always return `true`, even though the `--color-mode` flag was never set.

As a solution, the new code now only calls `fetch*` methods if the corresponding `has*` method returns `true`.