mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-04 01:44:13 +02:00
Honour --common-elements-dir and the other folder options in headless runs
Reported on #1178. Two things kept --common-elements-dir from working for --run and the command-line export: - main() runs both before QETApp exists, and only QETApp::parseArguments() applied the folder options, so they were ignored. The application of those options is now QETApp::applyDirectoryArguments(), static, and the two headless branches call it too. They also drop the options from the arguments they pass on: the export reads its project and output by position, so "--export-pdf --common-elements-dir=X p.qet out.pdf" took the option for the project ("Project not found"). - commonElementsDir() read the saved collection path before the command-line one, so a user's own setting beat a folder given for this run. The command line now comes first, in the GUI too. Tested with a --run script adding a symbol that exists only in a given folder: master fails with or without a saved collection path; this resolves it, before or after --run, and over a saved path to another folder. Without the option it still fails, and a saved path to the folder still works. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ELKpbGxqJd7EFiTUypBtVe
This commit is contained in:
+26
-2
@@ -93,6 +93,30 @@ void qetLogMessageHandler(QtMsgType type,
|
||||
\~French paramètres
|
||||
\~ @return exit code
|
||||
*/
|
||||
/**
|
||||
@brief headlessArguments
|
||||
For the headless export and --run, which return before QETApp parses
|
||||
the command line: apply the folder options (--common-elements-dir= and
|
||||
the others QETArguments knows) and return the arguments without them,
|
||||
so they are not read as the project or output path (issue #1178).
|
||||
*/
|
||||
static QStringList headlessArguments(const QStringList &args)
|
||||
{
|
||||
QETApp::applyDirectoryArguments(QETArguments(args.mid(1)));
|
||||
static const QStringList folder_options {
|
||||
QStringLiteral("--common-elements-dir="), QStringLiteral("--common-tbt-dir="),
|
||||
QStringLiteral("--config-dir="), QStringLiteral("--data-dir="),
|
||||
QStringLiteral("--lang-dir=")};
|
||||
QStringList kept;
|
||||
for (const QString &arg : args) {
|
||||
bool folder = false;
|
||||
for (const QString &option : folder_options)
|
||||
folder = folder || arg.startsWith(option);
|
||||
if (!folder) kept << arg;
|
||||
}
|
||||
return kept;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// before creating Application:
|
||||
@@ -159,7 +183,7 @@ int main(int argc, char **argv)
|
||||
// QETProject::readProjectXml(), and with nobody able to dismiss it
|
||||
// QDialog::exec() would spin its event loop forever.
|
||||
QET::QetMessageBox::setNonInteractive(true);
|
||||
return CLIExport::run(export_app.arguments());
|
||||
return CLIExport::run(headlessArguments(export_app.arguments()));
|
||||
}
|
||||
#ifdef QET_HAS_SCRIPTING
|
||||
// Headless scripting: --run <script.js> <project.qet> (bugtracker
|
||||
@@ -169,7 +193,7 @@ int main(int argc, char **argv)
|
||||
QApplication script_app(argc, argv);
|
||||
QETProject::setBackupEnabled(false);
|
||||
QET::QetMessageBox::setNonInteractive(true);
|
||||
return QetScripting::run(script_app.arguments());
|
||||
return QetScripting::run(headlessArguments(script_app.arguments()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user