Script Hangs with Progress

When I run this script from ScriptDebugger’s script menu, the script runs as expected, but when you make a selection as to which library to open, the progress window appears and won’t go away after the dictionary opens and the script finishes. You have to force quit.

I can’t reproduce with any other script run from that menu, but I’ll keep trying.

–>Script Debugger 6.0.4 (6A196) on OS X 10.11.6


use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set scriptLibrariesFolder to path to library folder from user domain as text
set scriptLibrariesFolder to scriptLibrariesFolder & "Script Libraries:"
set myScriptLibraries to my GetFileNames(scriptLibrariesFolder, "scptd")

set listTitle to "Script Libraries"
set listPrompt to "Which script dictionary would you like to try to open?"
set okbuttonName to "This One"
set multipleSelections to true
set emptySelectionAllowed to false

set userChoice to choose from list myScriptLibraries ¬
	with title listTitle ¬
	with prompt listPrompt ¬
	OK button name okbuttonName ¬
	multiple selections allowed multipleSelections ¬
	empty selection allowed emptySelectionAllowed
if userChoice is false then return
set scriptList to {}
repeat with thisScript in userChoice
	set the end of scriptList to ((scriptLibrariesFolder as text) & thisScript as text) as alias
end repeat

repeat with thisScriptLibrary in scriptList
	tell application "Script Debugger"
		set myLib to open thisScriptLibrary showing script dictionary
	end tell
end repeat

on GetFileNames(folderWithFiles, fileExtension)
	set folderWithFiles to POSIX path of (folderWithFiles)
	set thePaths to current application's NSFileManager's defaultManager()'s contentsOfDirectoryAtPath:folderWithFiles |error|:(missing value)
	set fileNames to (thePaths's pathsMatchingExtensions:{fileExtension}) as list
	return fileNames
end GetFileNames

More SD Script Menu woes.

I made 1 small change to the script I posted earlier:

repeat with thisScriptLibrary in scriptList
   tell application "Script Debugger"
      with timeout of 100 seconds
         set myLib to open thisScriptLibrary showing script dictionary
      end timeout
   end tell
end repeat

Simply adding a timeout. I first tried 10 seconds then 100 and got the same result. As soon as the script got to that point it timed out.

This bug (and the previous one) occur only when the script is run from SD’s script menu. It also won’t occur if the script is open in SD and run from the SD script menu.

Here’s the full script again, as modified:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set scriptLibrariesFolder to path to library folder from user domain as text
set scriptLibrariesFolder to scriptLibrariesFolder & "Script Libraries:"
set myScriptLibraries to my GetFileNames(scriptLibrariesFolder, "scptd")

set listTitle to "Script Libraries"
set listPrompt to "Which script dictionary would you like to try to open?"
set okbuttonName to "This One"
set multipleSelections to true
set emptySelectionAllowed to false

set userChoice to choose from list myScriptLibraries ¬
   with title listTitle ¬
   with prompt listPrompt ¬
   OK button name okbuttonName ¬
   multiple selections allowed multipleSelections ¬
   empty selection allowed emptySelectionAllowed
if userChoice is false then return
set scriptList to {}
repeat with thisScript in userChoice
   set the end of scriptList to ((scriptLibrariesFolder as text) & thisScript as text) as alias
end repeat

repeat with thisScriptLibrary in scriptList
   tell application "Script Debugger"
      with timeout of 100 seconds
         set myLib to open thisScriptLibrary showing script dictionary
      end timeout
   end tell
end repeat

on GetFileNames(folderWithFiles, fileExtension)
   set folderWithFiles to POSIX path of (folderWithFiles)
   set thePaths to current application's NSFileManager's defaultManager()'s contentsOfDirectoryAtPath:folderWithFiles |error|:(missing value)
   set fileNames to (thePaths's pathsMatchingExtensions:{fileExtension}) as list
   return fileNames
end GetFileNames

And still more Script Menu problems…

In trying to minimize the script to reproduce the bug with as few steps as possible I tried the script below. (You’ll need an alias to the MT tables library to run it.)

The script runs just fine from a script window, and just fine from the script menu if the script is open in SD. But if I close the script in SD and run it from the SD script menu I immediately get an apple event timed out error.

set thisScriptLibrary to alias "Macintosh HD:Users:stocklys:Library:Script Libraries:Myriad Tables Lib.scptd:"

tell application "Script Debugger"
   set myLib to open thisScriptLibrary showing script dictionary
end tell

Same on Yosemite. The first script runs fine from a window; runs fine from the Scripts menu when the script is open in a window; runs from the script menu, but the progress window appears and won’t go away and SD has to be force quit.

–>Script Debugger 6.0.4 (6A196) on OSX 10.10.4

Ed,

Can you confirm these only happen when there’s a dictionary window already open?

No and yes.

I think we have two bugs here. The bug where the progress bar displays and does not go away happens whether there are dictionary windows open or not.

The instant apple event time out bug happens when another dictionary is open.

Also, when another dictionary window is open, you get the timeout error instead of the progress window that won’t go away.

Also, if there is not another dictionary open and you have a with timeout block in the script, you still get the progress won’t go away bug. (I was mistaken that the timeout block had an effect. It was the dictionary being open). Also, with the timeout block the progress dialog stays up beyond the time specified in the timeout.

All that said, while trying to reproduce this in various scenarios, the progress dialog error went away.

I quit and relaunched SD and tried again with no windows open and the bug was back.

Also, these bugs only occur when run from the SD Scripts menu.

If they’re run from the system scripts menu or Script Editor they work fine.

(Of course, the progress window but only occurs in SD, but the same with the instantaneous timeout bug. Even with a dictionary window open it doesn’t occur if run from SE, etc.)