Skip navigation
Currently Being Moderated

collections becomes visible after 5 - 10 seconds. Message until it appears.

Apr 10, 2012 10:04 AM

Hi,

 

I have a plug-in that creates serveral collections and adds photos to a 1000 - 2000 photos to these.

Also in the loop the message is shown of the progress. After the loop has finished the processing is also finished.

This all works fine.

 

The code is something like:

 

After the loop has finished and the created collectiona are populated  the collections becomes visible after 5 to 10 seconds. There is a delay. On slower systems this can be longer.

 

The problem is that the user sees and thinks that nothing happens and tries again.

 

What I want is to show a message which automatically disappears when the collections gets visible. No pushing buttons, only the message that he should we for the collection to become visible.

Other solutions are also welcome.

A little example would help alot.

 

        xxxxCollection = catalog:createCollection(  ...  )

 

                           for i, photo in ipairs(cat_photos) do

 

           


message = 'processed: ' .. i
           


progressScope:setCaption(message)
           



                                                           .. processing

 

                        
-- adding photo to collection.
           


xxxxCollection:addPhotos{ photo }
           



           

     progressScope:setPortionComplete( i, nCountSelected )
       

end
       

progressScope:done()
   
end)


end)


end



 
Replies
  • Currently Being Moderated
    Apr 10, 2012 11:42 AM   in reply to dhmc05

    In general, the LR user interface updates asynchronously from changes made to the catalog, and changes made by plugins can take a while to get reflected in the user interface.  But one thought about your situation:

     

    Is the progressScope:done() inside or outside of the call to catalog:withWriteAccessDo()?  That is, is your structure:

     

     

    catalog:withWriteAccessDo()

    catalog:createCollection()

    loop

    collection:addPhoto()

    progressScope:setPortionComplete()

    progressScope:done()

     

    If the call to progressScope:done() is inside the call to catalog:withWriteAccessDo(), then perhaps it is indicating that the operation is finished before all the changes to the catalog actually get committed.  What happens if you move progressScope:done() outside of the call to catalog:withWriteAccessDo()?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 2:36 PM   in reply to dhmc05

    Just to help reinforce one of the points John is making - collections aren't created until after you exit the with-write-access-do function. Likewise, nothing else is really done database-wise until the database transaction is complete - after returning from with...do.

     

    It's worth noting that last edit date will not be the time the change was initiated, but the time it was finally committed.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2012 11:49 AM   in reply to dhmc05

    Re the progressScopes, it's not obvious what might be going wrong. 

     

    But it's not clear from your code fragment whether you've addressed the underlying issue, which is you'd prefer the collections and photos to appear in the user interface immediately when they're added.  Your code fragment appears to imply that the collection set and collections are all being created within one single catalog:withWriteAccessDo().

     

    I suggest that you restructure your code to create each collection set/collection and add each photo to a collection within separate calls to catalog:withWriteAccessDo:

     

    catalog:withWriteAccessDo

    delete collection set

    create collection set

     

    for each photo

    ...

    catalog:withWriteAccessDo

    create collection

    ...

    catalog:withWriteAccessDo

    add photo to collection

     

    Then it's more likely that the changes made to collections and their contents will appear incrementally on the screen as the plugin executes.

     

     

     

    
     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2012 10:26 AM   in reply to dhmc05

    Right.  But if you can't get the progress scope to work incrementally, another way to show "signs of life" is to have the collection building appear incrementally as it occurs, as sketched out above.  Personally, I would prefer that, since that's the way LR itself works with all of its long-running operations. 

     

    If performance of incremental collection-building becomes an actual problem (it may not be), then you can avoid that problem by processing the photos in batches of, say 5 at a time.  The Any Filter plugin, which searches entire catalogs of tens of thousands of photos, uses that simple approach to show incremental results without sacrificing performance.

     
    |
    Mark as:
  • Currently Being Moderated
    May 7, 2012 9:12 AM   in reply to dhmc05

    I may have time to look at it later this week.  You can see my email address here.

     
    |
    Mark as:
  • Currently Being Moderated
    May 12, 2012 10:03 PM   in reply to dhmc05

    To close this thread: The plugin's code had a number of undeclared variables, some of which were causing the progressScope to not get properly created.  By default, Lua errors are not displayed, so these were slipping past the author silently.  I recommended that he use the Debugging Toolkit or Rob Cole's plugin framework (which incorporates the toolkit).

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points