On 07/04/2012 01:42 AM, Scott Kostyshak wrote:
In tools > Preferences > File Handling > File Formats
my first entry is BMP. Despite the fact that "gimp" is in the viewerCO
combo box, it is set to Custom and "gimp" is in the text box. What
should happen is that "gimp" should be set in the combo box. (Note
that gimp is just being used as an example here.)
This happens because <<"gimp">> is being compared to <<gimp>>. Pasted
at the end of this email is PrefFileformats::updateViewers(), which
does the work. PrefFileformats::updateEditors() has the same problem
and similar code.
I see the problem.
Which is the best solution?
(a) change the source of <<"gimp">> to be <<gimp>>
(b) change the source of <<gimp>> to be <<"gimp">>
(c) leave the two sources the same and change updateComboBox so that
it changes <<"gimp">> to <<gimp>>
(d) leave the two sources the same and change updateViewers?
[By the "source of <<"gimp">>" I am referring to viewer_alternatives
and its origins and by "the source of <<gimp>>" I am referring to
f.viewer() and its origins]
I'm surprised myself that the quotes are being included in the read
string. I would have expected them not to be there, but to delimit the
string read. I think the reason we see them is because of the use of
eatLine() in this code:
case RC_VIEWER_ALTERNATIVES: {
string format, command;
if (lexrc.next())
format = lexrc.getString();
if (lexrc.eatLine())
command = lexrc.getString();
viewer_alternatives[format].insert(command);
break;
}
case RC_EDITOR_ALTERNATIVES: {
string format, command;
if (lexrc.next())
format = lexrc.getString();
if (lexrc.eatLine())
command = lexrc.getString();
editor_alternatives[format].insert(command);
break;
}
Since we do use eatLine(), we don't need them as delimiters. So it would
be an option just not to write them.
On a different note, and more out of curiosity, would it be a bad idea
to combine updateViewers() and updateEditors() into one function
update(enum ViewerOrEditor)?
The parallels are impressive, but I'm not sure it's worth it.
rh