Having a problem using catalog:withWriteAccessDo
I'm having a problem using catalog:withWriteAccessDo() in a function attached to an adjustment change observer.
Here is a code fragment from my plugin
local function resetMykey( observer )
local writeAccessStatus
local catalog = LrApplication.activeCatalog()
local photo = catalog:getTargetPhoto()
if nil ~= photo and not catalog.hasWriteAccess then
-- gets here
writeAccessStatus = catalog:withWriteAccessDo( 'Reset mykey', function( context )
-- doesn't do this
photo:setPropertyForPlugin( _PLUGIN, 'mykey', nil )
end, { timeout = 15 } )
-- and never gets here
end
end
...
LrDevelopController.addAdjustmentChangeObserver( context, Observer, resetMykey )
When a setting is changed in the Develop modue, the function resetMykey executes as expected. It gets to the line with catalog:withWriteAccessDo, indicated by my comment gets here, but it doesn't execute the withWriteAccessDo function and therefore, doesn't execute the photo:setPropertyForPlugin function, indicated by my comment doesn't do this. The withWriteAccessDo doesn't timeout either, indicated by my comment and never gets here; it seems that the withWriteAccessDo function just dies a silent death, but doesn't kill off the plugin.
Since the withWriteAccessDo never returns, I can't inspect the returned writeAccessStatus, so I'm completely in the dark after spending many hours trying to resolve the problem.
Any insights from SDK gurus would be most appreciated.
