Skip to main content

⚠️ Please note that this topic or post has been archived. The information contained here may no longer be accurate or up-to-date. ⚠️

CO11 Applescript Bug for Selected Collection

Comments

5 comments

  • Jim_DK
    Hi Eric,

    Do you have a sample script that reproduces this error?
    0
  • Eric Valk
    [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_collection
    0
  • Eric Valk
    [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
    Proceedure:
    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_collection
    0
  • Jim_DK
    This should have been addressed in 11.1...
    0
  • Eric Valk
    [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.