#12105: [Tracker][Add-On API] process_refs gets wrong directory entry_ref
------------------------------------+----------------------------
Reporter: ahwayakchih | Owner: waddlesplash
Type: bug | Status: assigned
Priority: normal | Milestone: Unscheduled
Component: Applications/Tracker | Version: R1/Development
Resolution: | Keywords: process_refs
Blocked By: | Blocking:
Has a Patch: 0 | Platform: All
------------------------------------+----------------------------
Comment (by ahwayakchih):
After looking into it some more, now i know why the condition was written
like that:
https://github.com/haiku/haiku/commit/2634c39731fdbbbd5324944bffb5075abe71619f
So, if we do not want to pass the query / virtual directory as ref, only
first of their items, then we should get first item's directory.
What other TargetModel there can be? If it is not a directory, virtual
directory nor a query?
Maybe it should just check if it is directory (in which case, get
TargetModel entry ref) or not (in which case get entry_ref of first items
parent directory)?
Something like this:
{{{
#!cpp
const entry_ref* modelRef;
if (TargetModel()->IsDirectory())
{
modelRef = TargetModel()->EntryRef();
}
else if (selectionList->ItemAt(0) != NULL)
{
// This is just a pseudo code for example purposes.
// There is no ParentEntryRef function AFAIK :).
modelRef =
selectionList->ItemAt(0)->TargetModel()->ParentEntryRef();
}
else
{
// Not a directory, and no items selected?
// Show some error
// Cleanup
delete refs; // refs is created above.
// we could move condition that to prevent object
creation instead
return;
}
LaunchInNewThread("Add-on", B_NORMAL_PRIORITY, &AddOnThread, refs,
addonRef, *modelRef);
}}}
--
Ticket URL: <https://dev.haiku-os.org/ticket/12105#comment:4>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.