Lightroom SDK: Long delay required after adding a photo to catalog, before white balance can be changed to custom, reliably.

  • 2
  • Problem
  • Updated 6 years ago
As it stands, if one adds a photo to the catalog in a with-do function, one must sleep for a good while before it's ok to change white-balance to custom in a subsequent with-do function. If wait is not long enough, the temperature and tint values will be wrong afterward (they will change to "unpredictable" values).

For example:
this works:

local s, m = cat:update( 10, "Upd1", function( context, phase )
photo = catalog:addPhoto( "X:\\MyPictures\\____IMPORT_____\\_DSC4415.NEF" )
end )
--
LrTasks.sleep( 2 ) -- 2 SECOND SLEEP IS BARELY ENOUGH
--
local s, m = cat:update( 10, "Upd2", function( context, phase )
local s, m = devSettings:adjustPhotos( { photo }, "Temp for Test...", { WhiteBalance='Custom' }, 10 )
if not s then
error( m )
end
end )
-- temperature and tint are correct (unchanged)


this doesn't work:

local s, m = cat:update( 10, "Upd1", function( context, phase )
photo = catalog:addPhoto( "X:\\MyPictures\\____IMPORT_____\\_DSC4415.NEF" )
end )
--
-- LrTasks.sleep( 1 ) - NO SLEEP (also, 1 SECOND IS NOT ENOUGH).
--
local s, m = cat:update( 10, "Upd2", function( context, phase )
local s, m = devSettings:adjustPhotos( { photo }, "Temp for Test...", { WhiteBalance='Custom' }, 10 )
if not s then
error( m )
end
end )
-- temperature and tint are catty-whompus (changed).

Note: cat:update is just a thin wrapper for catalog:withWriteAccessDo.
And: devSettings:adjustPhotos just creates/applies a (plugin) preset with the "white-balance->custom" setting in it.

This would not be much of a problem if it was possible to know what to wait for, or how long... - but I can't tell that, so it's a problem.

So far, this problem is only with white balance, all other settings (that I've tried - many but not all) can be applied immediately after adding photo to catalog, without a hitch...
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 382 Reply Likes

Posted 6 years ago

  • 2

Be the first to post a reply!