Lightroom: SDK: catalog.kLastCatalogExport and catalog.kTemporaryImages are swapped

  • 2
  • Problem
  • Updated 4 years ago
  • Not a Problem
  • (Edited)
In LR 5.2, the meanings of catalog.kLastCatalogExport and catalog.kTemporaryImages are incorrectly swapped. When “Added by Previous Export” is the currently active source, catalog:getActiveSources() returns catalog.kTemporaryImages instead of catalog.kLastCatalogExport. To set the active source to “Added by Previous Export”, you need to call catalog:setActiveSources (catalog. kTemporaryImages). Calling catalog:setActiveSources (catalog. kLastCatalogExport) results in “No photos in selected item”.

If this gets fixed, it won’t be backward compatible with previous versions of LR, so please add an explicit release note. This will help us plugin developers ensure our plugins won’t break. (In the past, many SDK fixes haven’t appeared in the release notes.)

Here’s a sample script that illustrates the problem:

local catalog = import 'LrApplication'.activeCatalog ()
-- catalog:setActiveSources (catalog.kTemporaryImages)
catalog:setActiveSources (catalog.kLastCatalogExport)
Photo of John R. Ellis

John R. Ellis, Champion

  • 3589 Posts
  • 928 Reply Likes

Posted 5 years ago

  • 2
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 379 Reply Likes
Hmm - can't corroborate - seems to work ok to me.

Note - you need curly brackets in your sample script, for example:

catalog:setActiveSources{ catalog.kLastCatalogExport }

seems to do the right thing in my copy.

PS - I can't seem to retract my "I'm having this problem too" vote.
Photo of John R. Ellis

John R. Ellis, Champion

  • 3589 Posts
  • 928 Reply Likes
Below are screenshots showing the behavior. I just tripled-checked, and it occurs with two different catalogs, in LR 5.2 and 5.3RC (Windows 7 64-bit), across machine reboots. (Even sprinkling magic fairy dust by deleting preferences doesn't change the behavior.)

I wonder what accounts for the difference in what we're seeing?

By the way, catalog:setActiveSources() takes a string or an array.

The results of catalog:getActiveSources():



The results of catalog:setActiveSources ({catalog.kLastCatalogExport}):



The results of catalog:setActiveSources (catalog.kTemporaryImages):

Photo of John R. Ellis

John R. Ellis, Champion

  • 3589 Posts
  • 928 Reply Likes
...and the values of the constants catalog.kLastCatalogExport and catalog.kTemporaryImages:

Photo of Paul Kleczka

Paul Kleczka, Employee

  • 44 Posts
  • 5 Reply Likes
Hi John-

I was confused by this too for awhile but we looked a bit more into it and realized I was reading "catalog.kLastCatalogExport" as "the last export from the catalog." However, it actually refers to the last export *as a catalog*.

I believe this is actually working as expected.

If you export as a catalog you will see a collection "Previous Export as Catalog" and the constant values will work correctly.

If you export any number of images (not as a catalog) you will see the "Added by Previous Export" which actually is a temporary source (and appropriately referenced by catalog.kLastCatalogExport.)

Hope that helps! Please let me know if I am still misunderstanding the problem.

Thanks!

-paul
Photo of John R. Ellis

John R. Ellis, Champion

  • 3589 Posts
  • 928 Reply Likes
Paul, thanks much for clarifying the naming of the constants. The meaning of "catalog.kTemporaryImages" isn't immediately obvious, but it does have a logic to it. In a better world, this would be documented in the SDK API reference. Thanks.
Photo of Paul Kleczka

Paul Kleczka, Employee

  • 44 Posts
  • 5 Reply Likes
The constants actually are documented under LrCatalog, but I was initially confused too because I didn't even look in the documentation and assumed I knew what the constant was referring too. Ideally, the constant names itself would be named in such a way to prevent confusing, but it is almost certainly not worth the cost of breaking backwards compatibility to do this.
Photo of John R. Ellis

John R. Ellis, Champion

  • 3589 Posts
  • 928 Reply Likes
The constants are listed in the LrCatalog documentation, but there is no explanatory text (of the sort you gave above). But this is obviously way down the list of priorities :->