Skip to main content
johnrellis
Legend
Nov 18, 2014 9:53 PM UTC
Needs More Info

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

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 is closed to new replies. Start a new post to keep the conversation going.

6 replies

johnrellis
Legend
Nov 21, 2014 1:30 AM UTC
That works. Thanks much.
Translate
Participating Frequently
Nov 18, 2014 11:46 PM UTC
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()
Translate
Participating Frequently
Nov 18, 2014 11:28 PM UTC
Okay, I could reproduce on mac only. Windows seems fine. I'll file a bug for this. Thanks for the post.

-paul
Translate
johnrellis
Legend
Nov 18, 2014 11:10 PM UTC
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)
Translate
johnrellis
Legend
Nov 18, 2014 11:06 PM UTC
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"
Translate
Participating Frequently
Nov 18, 2014 10:40 PM UTC
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
Translate