Page MenuHomePhabricator

Can not open images on first run via command line arguments
Closed, ResolvedPublic

Description

This bug was reported by Miklos via the users list:

it seems that you cannot open files from the command line with the latest release. I tried it with MitkWorkbench.

The command line arguments are processed by the activator of org.mitk.gui.qt.ext (LoadDataFromDisk function). But berry::Platform::GetApplicationArgs() returns and empty list there, hence no argument is processed, no file is opened.

Am I missing something?

I could reproduce this issue. However, if MITK Workbench is already running you can open new images via the command line.

e.g.

open command line with correct environment set
.\Release\MitkWorkbench.exe ..\..\MITK-Data\Pic3D.nrrd
-> Workbench opens, no image loaded
.\Release\MitkWorkbench.exe ..\..\MITK-Data\Pic3D.nrrd
-> Pic3D is added to the datamanager (provided you did not choose to start a new instance in the properties)

Event Timeline

Do you have a plan how to fix this? It is high priority for me, and I'm happy to work on it. I do not see, though, where are the arguments swallowed.

Any idea?

I also tried to add a 'repeatable' -o|--open option, but you cannot access the repeatable options through configuration properties. That's a limitation in Poco. You get only the last value for the option, not the whole list.

The "-o|--open" option is not important, it would be fine just to process the arguments as file names. (As it was.)

The arguments are swallowed in mitk::BaseApplication::main().

This works for me, at least the arguments are passed down this way. I have not tried if the files are actually opened.

int BaseApplication::main(const std::vector<std::string>& args)
{

// Start the plugin framework and all installed plug-ins according with
// their auto-start setting.

ctkPluginFrameworkLauncher::startup(0);

QStringList arguments;
for (std::string arg: args)
{
  arguments.push_back(QString::fromStdString(arg));
}

QVariant result = ctkPluginFrameworkLauncher::run(QVariant::fromValue(arguments));

return result.toInt();

}

This is simpler than what is done in ctkPluginFrameworkLauncher::run(QRunnable*), so I'm not sure that it can be integrated as is.

In my opinion this is a missing feature/bug in the CTK method we are using. I would prefer to fix this in CTK and then use the new API accordingly.

I have opened a CTK pull request for this change:
https://github.com/commontk/CTK/pull/603

If this is accepted I will fix the bug in MITK and update to a new CTK version.

I agree, the proper fix would need that change in CTK. Thanks!

User goch has pushed new remote branch:

bug-19289-pass-command-line-argument

[887fa1]: Merge branch 'bug-19289-pass-command-line-argument'

Merged commits:

2016-01-28 14:53:22 Caspar Goch [25aae4]
Update CTK


2015-09-21 17:00:18 Caspar Goch [c2c84c]
Pass command line parameters


2015-09-21 16:59:58 Caspar Goch [cd7a08]
prevent executable name from being passed along