gong-shell icon indicating copy to clipboard operation
gong-shell copied to clipboard

ShellTreeView.RefreshItem null reference exception

Open tmedanovic opened this issue 9 years ago • 5 comments

Something odd is happening randomly when running an app using ShellTreeView:

Null reference happens when

ShellItem folder = (ShellItem) node.Tag;

is acessed in RefreshItem(TreeNode node) because it's null

What is really strange is that second argument of FindItem(e.Item.Parent, m_TreeView.Nodes[0]); m_TreeView.Nodes[0] is different when calling method and when passed to FindItem as you can see on the pictures below.

Another this that I don't understand is how is parent returned from FindItem if first arg is null and second doesn't have any nodes, really strange.

gongshellnullreference2 gongshellnullreference3 gongshellnullreference4 gongshellnullreference5 gongshellnullreference6 gongshellnullreference7 gongshellnullreference8 gongshellnullreference9

Here is details on few objects during debugging:

void m_ShellListener_ItemUpdated(object sender, ShellItemEventArgs e) e.Item {shell:///Desktop} ComInterface: COM Object DisplayName: "Desktop" FileSystemPath: "C:\Users\username\Desktop" HasSubFolders: true IsFileSystem: true IsFileSystemAncestor: true IsFolder: true IsReadOnly: false m_ComInterface: COM Object Parent: null ParsingName: "C:\Users\username\Desktop" Pidl: 83534968 ShellIcon: {(Icon)} ToolTipText: ""

m_TreeView.Nodes[0] {Text = "This PC"} base: {Text = "This PC"} BackColor: "{Name=0, ARGB=(0, 0, 0, 0)}" Bounds: {X = 22 Y = -108 Width = 44 Height = 18} Checked: false ContextMenu: null ContextMenuStrip: null FirstNode: {Text = "Desktop"} ForeColor: "{Name=0, ARGB=(0, 0, 0, 0)}" FullPath: "This PC" Handle: 83754648 ImageIndex: -1 ImageKey: "" Index: 0 IsEditing: false IsExpanded: true IsSelected: false IsVisible: false LastNode: {Text = "DVD RW Drive (F:)"} Level: 0 Name: "" NextNode: null NextVisibleNode: {Text = "Desktop"} NodeFont: null Nodes: {System.Windows.Forms.TreeNodeCollection} Parent: null PrevNode: null PrevVisibleNode: null SelectedImageIndex: -1 SelectedImageKey: "" StateImageIndex: -1 StateImageKey: "" Tag: {shell:///MyComputerFolder} Text: "This PC" ToolTipText: "" TreeView: {System.Windows.Forms.TreeView, Nodes.Count: 1, Nodes[0]: TreeNode: This PC}

parent {Text = ""} base: {Text = ""} BackColor: "{Name=0, ARGB=(0, 0, 0, 0)}" Bounds: {X = 0 Y = 0 Width = 0 Height = 0} Checked: false ContextMenu: null ContextMenuStrip: null FirstNode: null ForeColor: "{Name=0, ARGB=(0, 0, 0, 0)}" FullPath: "This PC\Desktop" Handle: 83752416 ImageIndex: -1 ImageKey: "" Index: 0 IsEditing: false IsExpanded: false IsSelected: false IsVisible: false LastNode: null Level: 2 Name: "" NextNode: null NextVisibleNode: {Text = "Documents"} NodeFont: null Nodes: {System.Windows.Forms.TreeNodeCollection} Parent: {Text = "Desktop"} PrevNode: null PrevVisibleNode: {Text = "This PC"} SelectedImageIndex: -1 SelectedImageKey: "" StateImageIndex: -1 StateImageKey: "" Tag: null Text: "" ToolTipText: "" TreeView: {System.Windows.Forms.TreeView, Nodes.Count: 1, Nodes[0]: TreeNode: This PC}

TreeNode FindItem(ShellItem item, TreeNode parent) parent {Text = ""} base: {Text = ""} BackColor: "{Name=0, ARGB=(0, 0, 0, 0)}" Bounds: {X = 0 Y = 0 Width = 0 Height = 0} Checked: false ContextMenu: null ContextMenuStrip: null FirstNode: null ForeColor: "{Name=0, ARGB=(0, 0, 0, 0)}" FullPath: "This PC\Desktop" Handle: 83752416 ImageIndex: -1 ImageKey: "" Index: 0 IsEditing: false IsExpanded: false IsSelected: false IsVisible: false LastNode: null Level: 2 Name: "" NextNode: null NextVisibleNode: {Text = "Documents"} NodeFont: null Nodes: {System.Windows.Forms.TreeNodeCollection} Parent: {Text = "Desktop"} PrevNode: null PrevVisibleNode: {Text = "This PC"} SelectedImageIndex: -1 SelectedImageKey: "" StateImageIndex: -1 StateImageKey: "" Tag: null Text: "" ToolTipText: "" TreeView: {System.Windows.Forms.TreeView, Nodes.Count: 1, Nodes[0]: TreeNode: This PC}

tmedanovic avatar Mar 20 '15 17:03 tmedanovic

Could you try to create a minimal repro that exhibits this behaviour? It's not something I've seen before.

grokys avatar Mar 20 '15 18:03 grokys

Well the thing is that I don't know what triggers it, it happens randomly, but I think that it happend everytime app was minimized and running for some time, then when you bring it up it crashes. I will try to catch it, create a repro, and post back here.

tmedanovic avatar Mar 20 '15 21:03 tmedanovic

I managed to reproduce it, I also tried it with clean build, here are steps:

  1. Run the app with ShellView
  2. Go to charms -> Settings -> Change PC settings -> OneDrive -> File storage -> Save documents to OneDrive by default

tmedanovic avatar Mar 20 '15 21:03 tmedanovic

Ah! Indeed changing the OneDrive setting seems to trigger it.

I need to take a look in more depth as to what is causing it, but it's Friday night here now so it will be next week (and I might not have much time then as I'll be on on a business trip :( )

grokys avatar Mar 20 '15 21:03 grokys

No hurry, my browser is still in development :laughing:

tmedanovic avatar Mar 20 '15 21:03 tmedanovic