projectplus icon indicating copy to clipboard operation
projectplus copied to clipboard

tree folders on top

Open albeva opened this issue 14 years ago • 6 comments

This option doesn't work properly. Often files jump to top randomly (when file is added/deleted) etc on Lion

albeva avatar Nov 09 '11 12:11 albeva

Thanks for the report. I'll look into it as soon as I have the chance.

fdintino avatar Nov 09 '11 15:11 fdintino

This pull request will fix the problem in most cases: https://github.com/fdintino/projectplus/pull/3

jacob-carlborg avatar Jul 09 '12 08:07 jacob-carlborg

Actually, inspired by your pull requests, I started trying to tackle this one. Re-sorting on focus is one part, but the project pane also has to re-sort when files or a folder are added or removed via right-click, or when files are dragged from one place to another. That's all done now, but what I've learned is that [NSOutlineView reloadData] isn't thread safe, so I need to implement some sort of locking mechanism to prevent race condition bugs caused by overlapping calls to the sort and reloadData methods.

fdintino avatar Jul 09 '12 13:07 fdintino

As far as I know, nothing in Cocoa is thread safe, at least not the GUI. There's the @synchronized statement and the [NSObject performSelectorOnMainThread:withObject:waitUntilDone:] method.

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsobject_Class/Reference/Reference.html

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocThreading.html#//apple_ref/doc/uid/TP30001163-CH19-SW1

jacob-carlborg avatar Jul 09 '12 14:07 jacob-carlborg

That's my understanding too. What complicates matters is that [NSOutlineView reloadData] can be (and is) called from outside of ProjectPlus, since we're using swizzle methods to monkey patch. I've used @synchronized in the SCM code for this purpose, though I believe there is a bit of a performance hit with that. Ideally I'd like to make the sorting atomic so that I don't need to manage the threads at all.

fdintino avatar Jul 09 '12 14:07 fdintino

Are items added to the outline view from other threads than the main thread? If reloadData is only called on the main thread there is no problem. If reloadData is called from some other thread then there already was a problem?

jacob-carlborg avatar Jul 09 '12 18:07 jacob-carlborg