CO11 Applescript Bug for Selected Collection
This bug breaks all my scripts. I don't have a good workaround so far. Does anyone else have a better work around?
When Applescript asks CO11 for a reference to a user collection (or executes any Applescript command that returns a reference to a user collection) which is the collection the user has currently selected, CO11 returns an incorrect reference, which is usually, but not always unuseable.
This makes it difficult and risky to write code that does something to the user selected collection.
By way of example, suppose the user collections in Document1 (a catalog) are arranged like this:
and suppose that the total number of top level collections, comprising the set {CO11 fixed collections, user collections, catalog folders} is 124
The reference to to Top_Collection1 is normally returned as: collection 4 of document "Document1"
The reference to to Subcollection1_1 is normally returned as: collection 1 of collection 4 of document "Document1"
The reference to to Subcollection1_2 is normally returned as: collection 2 of collection 4 of document "Document1"
and so forth...
But if the user has selected Subcollection1_2, then the reference to to Subcollection1_2 is returned as: collection 125 of collection 4 of document "Document1".
Now sending an Applescript command to CO11 asking for any information about collection 125 of collection 4 of document "Document1" results in an index error, because there there are only 4 collections in Collection 4 of Document 1.
One can make a partial work around by trapping the error, and replacing the invalid reference with a reference to collection 125 of document "Document1"
But this will only work as long as there are fewer subcollections in a user collection than there are top level collections. Once I have a user collection that contains more than 125 collections, selecting collection 130 of collection 4 of Document 1 will likely not generate an invalid reference, just an incorrect reference.
In my main catalog, I'm not likely to have more than 125 collections in any collection, however in a smaller catalog, perhaps with fewer top level collections and fewer catalog folders, the number of sub collections could practically exceed the number of top level collections, especially if I start grouping sets of burst images and sets of bracketted images.
When Applescript asks CO11 for a reference to a user collection (or executes any Applescript command that returns a reference to a user collection) which is the collection the user has currently selected, CO11 returns an incorrect reference, which is usually, but not always unuseable.
This makes it difficult and risky to write code that does something to the user selected collection.
By way of example, suppose the user collections in Document1 (a catalog) are arranged like this:
- Top_Collection1
- Subcollection1_1
- Subcollection1_2
- Subcollection1_3
- Subcollection1_4
and suppose that the total number of top level collections, comprising the set {CO11 fixed collections, user collections, catalog folders} is 124
The reference to to Top_Collection1 is normally returned as: collection 4 of document "Document1"
The reference to to Subcollection1_1 is normally returned as: collection 1 of collection 4 of document "Document1"
The reference to to Subcollection1_2 is normally returned as: collection 2 of collection 4 of document "Document1"
and so forth...
But if the user has selected Subcollection1_2, then the reference to to Subcollection1_2 is returned as: collection 125 of collection 4 of document "Document1".
Now sending an Applescript command to CO11 asking for any information about collection 125 of collection 4 of document "Document1" results in an index error, because there there are only 4 collections in Collection 4 of Document 1.
One can make a partial work around by trapping the error, and replacing the invalid reference with a reference to collection 125 of document "Document1"
But this will only work as long as there are fewer subcollections in a user collection than there are top level collections. Once I have a user collection that contains more than 125 collections, selecting collection 130 of collection 4 of Document 1 will likely not generate an invalid reference, just an incorrect reference.
In my main catalog, I'm not likely to have more than 125 collections in any collection, however in a smaller catalog, perhaps with fewer top level collections and fewer catalog folders, the number of sub collections could practically exceed the number of top level collections, especially if I start grouping sets of burst images and sets of bracketted images.
0
-
Hi Eric,
Do you have a sample script that reproduces this error?0 -
[quote="Jim_DK" wrote:
Hi Eric,
Do you have a sample script that reproduces this error?
Hi Jim, here's a script that will trigger the bug, along with comments on the configuration.
I do now have workarounds that I think will work 100% of the time as long as catalog folders are not selected.
This script is a little more complex than I would like because it has to find the user subcollection that has been selected.
## Test script for Capture One bug
## Open a catalog with referenced images, many user collections, and some hierarchy of user collections
## This bug also happens when selecting Catalog folders below top level
## The bug is not triggered by selecting a top level user collection or a Capture One collection
## To trigger the bug select collection which is below a top level user collection (project or group)
## The necessary condition for an obvious crash is that the parent project or group contains fewer collections than the number of top level collections
## Otherwise the bug likely causes incorrect information to to be returned, but not a crash
## In my test catalog I have 24 top level collections, including 11 catalog folders. Therefore I select a subcollection in a project or group containing less than 24 collections.
## Under these conditions CO11 sends an incorrect reference that refrs to a non exitent collection -> simple crash
## Under other condtions the the incorrect reference will refer to an existing (but wrong collection) -- much harder to demo
tell application "Capture One 11" to tell document 1
set countTopCollections to count of every collection
set kindOfLastTopCollection to (get kind of collection countTopCollections) as text
set topCollectionList to every collection
end tell
if (kindOfLastTopCollection = "catalog folder") then
log "This may not trigger a crash, but the script will run anyway"
else
log "Wait for the crash ...... "
end if
## Search the collection hierarchy
repeat with collectionIndex from 1 to countTopCollections
set thisTopCollection to item collectionIndex of topCollectionList
tell application "Capture One 11" to tell document 1 to set thisCollectionName to name of thisTopCollection -- no crash
search_collection(thisTopCollection)
end repeat
############ handler
on search_collection(thisCollection)
tell application "Capture One 11" to tell document 1 to tell thisCollection
set countSubCollections to count of every collection
set collectionList to every collection -- the actual error occurrs here
end tell
repeat with collectionIndex from 1 to countSubCollections
set thisSubCollection to item collectionIndex of collectionList
tell application "Capture One 11" to tell document 1 to tell thisCollection
set thisSubcollectionName to get name of thisSubCollection -- trigger the crash here else it will happen inside the next handler call
## Capture One throws an error because the collection reference refers to a nonexistent collection
end tell
my search_collection(thisSubCollection)
end repeat
end search_collection0 -
[quote="Jim_DK" wrote:
Hi Eric,
Do you have a sample script that reproduces this error?
Hi Jim
Here's an even better and simpler demonstration.
Setup a catalog with the following user collections, and no images. Ensure this is the ONLY Capture One document open. Add some referenced images, but from only one OS X folder (more OS X folders means we need more albums in Project11 to make demo part 3 work)- Group1
- Project11
- Album111
- Album112
- Album113
- Album114
- Album115
- Album116
- Album117
- Album118
- Project12
- Album111
- Album112
- Album113
- Project11
1) select "All Images", and run the script below. You will find a tree structure of all the collections, correctly identified.
2) select "Album 121" or "Album 122" and run the script again. The script will crash.
3) select "Album 114" (or any Album in Project 11) and run the script again. The information for Album 114 is now incorrect, the name is now listed as Album 117. See output listing below, the arrrow (my annotation) points to the incorrect output.
IMO what is happening is that when the parent of the selected collection asks?? for the index number of the selected collection, the wrong index is returned, the value returned is the index of the last top level collection.
I wonder if the selected user collection was made the last top level collection to make it discoverable to an Applescript. An alternative and perhaps more robust approach would have been to add the property "selected" (boolean) to the collection class, then the selected collection is easily discoverable by walking the collection hierarchy and checking the "selected" property of each collection. Besides not affecting the collection hierarchy, such a solution has the added benefit of finding all the parent collections.
Output of Applescript with Album 114 selected
(*..Searching within BugTest ....*)
(* Collection 1 is All Images*)
(* Collection 2 is Recent Captures*)
(* Collection 3 is Trash*)
(* Collection 4 is Group1*)
(* ..Searching within Group1 ....*)
(* Collection 1 is Project11*)
(* ..Searching within Project11 ....*)
(* Collection 1 is Album111*)
(* Collection 2 is Album112*)
(* Collection 3 is Album113*)
(* Collection 4 is Album117*) <----------------
(* Collection 5 is Album115*)
(* Collection 6 is Album116*)
(* Collection 7 is Album117*)
(* Collection 8 is Album118*)
(* Collection 2 is Project12*)
(* ..Searching within Project12 ....*)
(* Collection 1 is Album121*)
(* Collection 2 is Album122*)
(* Collection 5 is In Catalog*)
(* Collection 6 is Keith*)
(* Collection 7 is Album114*)
Applescript
## Test Applescript for Capture One bug
tell application "Capture One 11" to my search_collection(document 1, "")
############ handlers
on search_collection(thisCollection, level_Indent)
tell application "Capture One 11" to tell document 1 to tell thisCollection
set nameCollection to get name
set countSubCollections to count of every collection
set collectionList to every collection -- the actual error occurrs here
end tell
if countSubCollections > 0 then
set newlevel_Indent to level_Indent & " "
log (level_Indent & "..Searching within " & nameCollection & " ....")
repeat with collectionIndex from 1 to countSubCollections
set thisSubCollection to item collectionIndex of collectionList
tell application "Capture One 11" to tell document 1 to tell thisCollection
set thisSubCollectionName to get name of thisSubCollection
log (newlevel_Indent & "Collection " & collectionIndex & " is " & thisSubCollectionName)
end tell
my search_collection(thisSubCollection, newlevel_Indent)
end repeat
end if
end search_collection0 - Group1
-
This should have been addressed in 11.1... 0 -
[quote="Jim_DK" wrote:
This should have been addressed in 11.1...
Jim, Thanks for the follow-up.
Agreed, It has been addressed in 11.1 - I checked and saw that it was fixed in one of the early Beta releases, but of course I couldn't post at that time.0
Post is closed for comments.
Comments
5 comments