Possible bug plugin interface (GetFindData)

A place where plug-in developers can share their knowledge and experience.
Posts: 9
Joined: Wed Aug 17, 2005 8:43 pm

Possible bug plugin interface (GetFindData)

Post by prikryl »


I posting bug report that I've sent to support@farmanager.com almost two years ago. It seems that the issue is still present in the latest 1.70 alpha 6. I cannot confirm this on 100% as for some reasons I'm having difficulties debugging the alpha versions of FAR. However the symptoms are still present.

Report follows:

Hello all,

I'm developer of WinSCP plugin for FAR filemanager. I believe that I have
find a bug in far-to-plugin interface. I think that the problem may occur in
many situation, however I'll explain it on one particular occurence for
which I have found it.

The problem concerns GetFindData() function. In the function I fill UserData
field with pointer to plugin's internal object representing the file. I rely
on FAR to return the value with each calls to functions like GetFiles() etc.
The reference to object is usually freed at most with next call to
GetFindData(), in which I return new references. This all works in usual
situations. I have found at least one situation, in which it seems that it
does not.

The plugin file system is in panel. I'm in subdirectory. I open quick view
panel. I leave the subdirectory. FAR calls GetFindData() for the parent
directory. The plugin returns file data including pointers to the objects in
UserData. As panel item with subdirectory is selected automatically and
quick view is on, FAR starts immediatelly to scan the leaved subdirectory to
get number of files, total subdirectory size etc. To achieve this it agains
sets current directory back to the subdirectory and calls GetFindData() for
it. It does it for all sub-subdirectories (if any) iteratively. When
scanning finishes, it agains sets back current directory to the parent
directory and calls again (for second time) GetFindData() for it. My plugin
returns directory listing, with different references to file objects

Now comes the problem. The results of the last call to GetFindData() seems
to be ignored and FAR actually uses results of the first call. But the first
results includes references to objects, which are no longer valid. So on
next call to function like GetFiles(), the plugin fails (access violation or
similar), because it expects the values of UserData to be valid pointers,
which are not.

I have tried to delete file from parent directory in between the two calls
to GetFindData() (during subdirectory scanning). Actually the file was
displayed in panel depite the fact that the last (second) call to
GetFindData() did not returned the the deleted file.

I believe that it is a bug. Can you confirm this or tell me what am I doing

Thanks in advance for your answer.

Martin Prikryl