Skip to main content
johnrellis
Legend
November 18, 2014

P: SDK: folder:getChildren() incorrectly returning 0 return values

  • November 18, 2014
  • 6 replies
  • 583 views

On one of my catalogs, folder:getChildren() is returning 0 return values for a particular folder (that is, it is executing a "return;" statement, with no value):

I've optimized the catalog to no effect.

If I hide the root folder "/", then the method works correctly.

This may be related to these topics (or it may not):
http://feedback.photoshop.com/photosh...
http://feedback.photoshop.com/photosh...

This topic has been closed for replies.

6 replies

johnrellis
Legend
November 21, 2014
That works. Thanks much.
Adobe Employee
November 18, 2014
Try getting the first sub-folder by path and then using that folder. That worked for me. So...

local root = catalog:getFolders()[1]
local rootName = root:getName()

local subFolder = root:getChildren()[1]
local subFolderName = subFolder:getName()

local subFolderByPath = catalog:getFolderByPath(subFolder:getPath())

local subSubFolder = subFolderByPath:getChildren()[1]
local subSubFolderName = subSubFolder:getName()
Adobe Employee
November 18, 2014
Okay, I could reproduce on mac only. Windows seems fine. I'll file a bug for this. Thanks for the post.

-paul
johnrellis
Legend
November 18, 2014
Also, I just created a brand new catalog with about 50 test pics, and the problem occurs on that catalog too. (LR 5.6, OS X 10.9.5)
johnrellis
Legend
November 18, 2014
With the root folder "/" showing, the expression subFolder:getChildren()[1] gets "attempt to index a nil value". Here's the log from my debugger session showing each of the assignments and resulting value:

14/11/18 14:54:50com.johnrellis.logger TRACE Eval: root = catalog:getFolders()[1]

14/11/18 14:54:57com.johnrellis.logger TRACE Eval: root
LrFolder

14/11/18 14:55:04com.johnrellis.logger TRACE Eval: rootName = root:getName()

14/11/18 14:55:09com.johnrellis.logger TRACE Eval: rootName
"/"

14/11/18 14:55:24com.johnrellis.logger TRACE Eval: subFolder = root:getChildren()[1]

14/11/18 14:55:31com.johnrellis.logger TRACE Eval: subFolder
LrFolder

14/11/18 14:55:40com.johnrellis.logger TRACE Eval: subFolderName = subFolder:getName()

14/11/18 14:55:45com.johnrellis.logger TRACE Eval: subFolderName
"Users"

14/11/18 14:57:14com.johnrellis.logger TRACE Eval: subFolderName
"Users"

14/11/18 15:01:55com.johnrellis.logger TRACE Eval: LrTasks.pcall (function () return subFolder:getChildren()[1] end)
false
"[string \"return function (catalog, LrApplication, Lr...\"]:1: attempt to index a nil value"
Adobe Employee
November 18, 2014
I couldn't reproduce this problem. I actually did think I saw the behavior once, but then I could not reproduce so I think I may have just had a bug in my test code.

Can you try breaking out the calls into multiple lines like this:

local root = catalog:getFolders()[1]
local rootName = root:getName()

local subFolder = root:getChildren()[1]
local subFolderName = subFolder:getName()

local subSubFolder = subFolder:getChildren()[1]
local subSubFolderName = subSubFolder:getName()

and let me know if you still are seeing an issue...?

Thanks,

-paul