Forum

Author Topic: Project auto close at the end of Python script launched from menu  (Read 5992 times)

Gall

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Hello, I just found an unintended behavior (I hope..) using shortcut with autoloaded scripts in version 1.2.4 (no problem with version 1.2.3).

For the context, I'm working in a virtual machine on Linux so PhotoScan takes a few seconds to load the interface. I noticed that if I launch a given script with a shortcut during that time it will automatically close the project at the end.

Here is a MCVE to add to the script folder, just hit Alt+z right before PhotoScan finishes loading up the interface.

Code: [Select]
import PhotoScan


def foo():
project_file = PhotoScan.app.getOpenFileName('Open project file')

doc = PhotoScan.app.document
doc.open(project_file)
doc.chunk.label = 'test'


if __name__ == '__main__':
PhotoScan.app.addMenuItem('test close project bug', foo, 'alt+z')

This is really annoying to see PhotoScan close a project after an error or at the end...

Edit: I just tested on Windows and the same behavior happens (though I had a way smaller time frame to test it).
« Last Edit: April 05, 2016, 01:32:19 PM by Gall »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Project auto close at the end of Python script launched from menu
« Reply #1 on: April 05, 2016, 01:33:03 PM »
Hello Gall,

Looks strange, maybe you can specify the steps to follow to reproduce the problem? I've just ran the script on a virtual Lixux machine and it worked without any issues and unexpected project closing, even I've hit Alt-Z multiple times.

Will it behave in a same way if you change the hotkey?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Gall

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: Project auto close at the end of Python script launched from menu
« Reply #2 on: April 05, 2016, 03:10:21 PM »
Yes it behaves the same way with another hotkey. I know this can be a tricky one to check because it depends on the resources available to load up the GUI. In my case the window shows up and stay grey 2-4 seconds before showing all the ui elements, it's in that time frame that hitting the hotkey will trigger this behavior.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Project auto close at the end of Python script launched from menu
« Reply #3 on: April 05, 2016, 03:11:48 PM »
Hello Gall,

And what happens if you use any of the predefined hotkeys? For example, CTRL+O or CTRL+N?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Gall

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: Project auto close at the end of Python script launched from menu
« Reply #4 on: April 05, 2016, 03:40:28 PM »
With Ctrl+O I select a project, it loads then closes. I don't see anything happening with Ctrl+N. So it might not be Python related.

Under version 1.2.3, Ctrl+O works correctly.

James

  • Hero Member
  • *****
  • Posts: 756
    • View Profile
Re: Project auto close at the end of Python script launched from menu
« Reply #5 on: April 05, 2016, 03:43:11 PM »
Tried it myself out of curiosity and was able to reproduce using the script provided by Gall with ALT-Z, and also by using the CTRL-O shortcut.

Took about 5 attempts each to hit the shortcut quickly before the GUI loaded as I'm running locally on windows, but in each attempt the project loaded, as shown in the console, but was not displayed (or was opened and subsequently closed).

Well that was fun.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14965
    • View Profile
Re: Project auto close at the end of Python script launched from menu
« Reply #6 on: April 06, 2016, 02:41:25 PM »
We were able to reproduce such behavior and we'll try to fix in the next version update.
Best regards,
Alexey Pasumansky,
Agisoft LLC