• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

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

LEGEND ,
Nov 18, 2014 Nov 18, 2014

Copy link to clipboard

Copied

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...

Bug Investigating
TOPICS
SDK

Views

261

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Nov 18, 2014 Nov 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()

Votes

Translate

Translate
6 Comments
Adobe Employee ,
Nov 18, 2014 Nov 18, 2014

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
LEGEND ,
Nov 18, 2014 Nov 18, 2014

Copy link to clipboard

Copied

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"

Votes

Translate

Translate

Report

Report
LEGEND ,
Nov 18, 2014 Nov 18, 2014

Copy link to clipboard

Copied

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)

Votes

Translate

Translate

Report

Report
Adobe Employee ,
Nov 18, 2014 Nov 18, 2014

Copy link to clipboard

Copied

Okay, I could reproduce on mac only. Windows seems fine. I'll file a bug for this. Thanks for the post.

-paul

Votes

Translate

Translate

Report

Report
Adobe Employee ,
Nov 18, 2014 Nov 18, 2014

Copy link to clipboard

Copied

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()

Votes

Translate

Translate

Report

Report
LEGEND ,
Nov 20, 2014 Nov 20, 2014

Copy link to clipboard

Copied

LATEST
That works. Thanks much.

Votes

Translate

Translate

Report

Report