View Issue Details

IDProjectCategoryView StatusLast Update
0011277MMW v4Framework: Scripts/Extensionspublic2013-09-18 22:34
Reporterzvezdan Assigned To 
PriorityurgentSeverityminorReproducibilityalways
Status closedResolutionfixed 
Fixed in Version4.1 
Summary0011277: Error -2147418113 with hidden Node_Library_InCollection, then Catastrophic failure
DescriptionIf I have hidden some collection (in the next example it is Podcast) then the following code causes two error boxes, one with Error -2147418113, and another saying "Error happened during script execution: Catastrophic failure".

Option Explicit

Sub OnStartUp()
    Dim oMenuItem

    Set oMenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_Tree, 0, 0)
    oMenuItem.Caption = "Test FirstChildNode"
    oMenuItem.OnClickFunc = "Test"
    oMenuItem.UseScript = Script.ScriptPath
End Sub

Sub Test(oMenuItem)
    Dim iIndex
    Dim iCollection
    Dim oParentNode

    For iIndex = 0 To SDB.Collections.Count - 1
        If SDB.Collections.Item(iIndex).Name = "Podcast" Then
            iCollection = SDB.Collections.Item(iIndex).ID
            Exit For
        End If
    Next

    If iCollection Then
        Set oParentNode = SDB.MainTree.FirstChildNode(SDB.MainTree.ParentNode _
                (SDB.MainTree.Node_Library_InCollection(iCollection)))
        If Not oParentNode Is Nothing Then
            SDB.MessageBox oParentNode.Caption, mtInformation, Array(mbOK)
        End If
    End If
End Sub

If I replace Node_Library_InCollection(iCollection) with Node_Library_InCollection(-1) or Node_Library or any other Node_xxx, then everything is fine even when those nodes are hidden. If the specified collection is not hidden, then everything is fine with this script as well.
Steps To Reproduce- Copy script to Auto folder and restart program;
- hide Podcast collection using Manage Collections;
- right-click some node and choose Test FirstChildNode -> error.
TagsNo tags attached.
Fixed in build1659

Activities

Ludek

2013-09-17 17:02

developer   ~0037582

Last edited: 2013-09-17 17:18

Yes, this happens, because as is noted here:
http://www.mediamonkey.com/wiki/index.php/ISDBTree::Node_Library_InCollection

SDB.MainTree.Node_Library_InCollection(iCollection) returns an existings node in specified collection in the tree, but in this case the node doesn't exists in the tree (the collection is hidden)

You can check collection visibility via http://www.mediamonkey.com/wiki/index.php/ISDBCollection::Visible

But the true is that SDB.MainTree.Node_Library_InCollection(iCollection) should return nothing if the node is not visible in the tree or iCollection is out of bounds.

Fixed in build 1659.

i.e. you can use this condition starting from 1659:

  Dim oNode
  Set oNode = SDB.MainTree.Node_Library_InCollection(iCollection)
  If Not oNode Is Nothing Then
    SDB.MessageBox oNode.Caption, mtInformation, Array(mbOK)
  End If

zvezdan

2013-09-17 17:21

updater   ~0037584

Last edited: 2013-09-17 17:23

I cannot see that it is noted why this happens in: http://www.mediamonkey.com/wiki/index.php/ISDBTree::Node_Library_InCollection

OK, I understand what you want to say, I already came to the same conclusion. I already have modified Magic Nodes to check visibility of collection node. However, I did not report this problem because I cannot find the solution, but because I want you to remove bugs in program, and this is clearly a bug.

You did not answer the main question: why this is not happening with "Entire Library" node or any another node on the topmost level that is hidden, but only with collection nodes?

EDIT: I see that you added text to the previous post, but I am still interested to hear some answer to my last question.

Ludek

2013-09-17 18:03

developer   ~0037586

Last edited: 2013-09-17 18:04

There is written "returns an existings node" and this is the answer, some nodes exist even if they are not visible, but invisible collection nodes and its subnodes doesn't exists.
Why you need to access invisible collection nodes?

OK, I fixed also FirstChildNode and ParentNode methods so that it doesn't crash when input node is nothing, i.e. your example script will not throw an error in build 1659+

peke

2013-09-18 22:34

developer   ~0037605

Verified 1659 Using example script.