Problem 2159 - G4UImanager::ApplyCommand returns 0 when executing non-existing macro file
Summary: G4UImanager::ApplyCommand returns 0 when executing non-existing macro file
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: intercoms (show other problems)
Version: 10.4
Hardware: PC Linux
: P4 major
Assignee: asai
URL:
Depends on:
Blocks:
 
Reported: 2019-04-17 12:17 CEST by Nicola Mori
Modified: 2019-04-18 14:02 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Nicola Mori 2019-04-17 12:17:09 CEST
In my application I execute the command given in a macro file by means of:

  G4UImanager* UImanager = G4UImanager::GetUIpointer();
  auto result UImanager->ApplyCommand(std::string("/control/execute ") + fileName);
  std::cout << "result: " << result << std::endl;

According to the comment in G4UImanager.hh, the return value should be positive non-zero when an error occurs. However, it is 0 when fileName is the name of a non-existing file:

  ERROR: Can not open a macro file <nonExistingFile.mac>. Set macro path with "/control/macroPath" if needed.
  result: 0

Similarly, when the macro contains a bad command the return value is again 0:

  ***** COMMAND NOT FOUND </nonExistingCommand> *****
  
  ***** Batch is interrupted!! *****
  result: 0


So how can I check whether the execution of the macro has been successful or not?
Comment 1 asai 2019-04-17 19:30:26 CEST
Thank you for reporting this issue. We will fix it with the next patch release.
Kind regards,
Makoto Asai
Comment 2 asai 2019-04-17 22:21:29 CEST
The fix will be included in the next patch release (version 10.5-patch02). There is no immediate plan of porting it back to the previous versions as this fix requires a functionality introduced with 10.5.

Thank you for reporting this issue, once again.
Makoto
Comment 3 Nicola Mori 2019-04-18 14:02:42 CEST
Thank you Makoto for the quick fix. Is there an estimate about when the 10.5-patch02 version will be released?