Check input and output converters do support the relevant directions

It was previously possible to select an input-only converter for
output or an output-only converter for input. Also add a comment to
explain why failure to probe for the auto output converter isn't an
error, where failure to probe for the auto input converter is.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I17dfbbee7d8b5a9629e66d0e1a6a4014b01a7262
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
(cherry picked from commit ccd59b2d4f8f1c4fde3f1498d28c0dc91ba75efd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Edward Welbourne 2023-09-04 14:43:02 +02:00 committed by Qt Cherry-pick Bot
parent 7bd8ab4917
commit b4e09800bb

View File

@ -113,8 +113,9 @@ int main(int argc, char *argv[])
}
}
if (!inconv) {
fprintf(stderr, "Unknown file format \"%s\"\n", qPrintable(format));
if (!inconv || !inconv->directions().testFlag(Converter::Direction::In)) {
fprintf(stderr, inconv ? "File format \"%s\" cannot be used for input\n"
: "Unknown input file format \"%s\"\n", qPrintable(format));
return EXIT_FAILURE;
}
}
@ -129,8 +130,9 @@ int main(int argc, char *argv[])
}
}
if (!outconv) {
fprintf(stderr, "Unknown file format \"%s\"\n", qPrintable(format));
if (!outconv || !outconv->directions().testFlag(Converter::Direction::Out)) {
fprintf(stderr, outconv ? "File format \"%s\" cannot be used for output\n"
: "Unknown output file format \"%s\"\n", qPrintable(format));
return EXIT_FAILURE;
}
}
@ -184,6 +186,7 @@ int main(int argc, char *argv[])
break;
}
}
// If that failed, loadFile() shall supply a fallback.
}
// now finally perform the conversion