vector madness
#1
Image

ok here is my problem.

in the picture you see a cguilistitem being created from a vector. when i debug the item gets set properly, but it also has a "hidden"? member that shows up in the locals. it says it has a cfileitem member but i can't access any parts of the cfileitem (because cfileitem isn't a member of cguilistitem). is there a way i can use a string and dump what the value field shows and then parse the string? or is there a way to retreive the cfileitem directly?
Reply
#2
what piece of data are you trying to get at?

you should be able to use a second pointer to get access to the cfileitem data. something like this:

Quote:cfileitem *pfileitem = m_vecitems[i + m_ioffset];
cstdstring strsomething = pfileitem->m_strmember;
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#3
this is in guilistcontrol, and there is no #include "../xbmc/fileitem.h"

the [cfileitem] shows up in the debugger without it, and i'm just trying to access any portion of the cfileitem


when i use this: (after adding the above include)
Quote:cfileitem *pfileitem = m_vecitems[i + m_ioffset];

i get this:
Quote:error c2440: 'initializing' : cannot convert from 'std::allocator<_ty>::value_type' to 'cfileitem *'
with
[
_ty=cguilistitem *
]

when i use this:
Quote:cfileitem pfileitem = *((cfileitem*)( m_vecitems[i + m_ioffset]));

the cguuilistitem memer of pfileitem gets populated correctly but the rest of the object like m_strpath gets default values.

thats kind of why i was thinking of casting it to a string and parsing the values between each {} but casting as a string results in memory access errors.

any ideas?
Reply
#4
yeah, i see your dilemma. i'm looking at the code and i;m not sure how to get access to the cfileitem members. cfileitem is derived from cguilistitem, but cguilistcontrol only has vector of cguilistitem objects.

if there's one particular member you need access to, you could move that member into cguilistitem. (cfileitem will gain access to it then via inheritance.)
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#5
in answer to my own question

i did have to add the

Quote: #include "../xbmc/fileitem.h"

Quote:cfileitem *pfileitem;

//allocate space for the item, (so it doesn't overlap and corrupt the heap)
pfileitem = (cfileitem *) malloc(sizeof(cfileitem));

//copy the data from pitem to pfileitem
memcpy(pfileitem,pitem,sizeof(cfileitem));

make sure to
Quote:free(pfileitem);
or you'll probably get an overlap in the memory (when i say probably i realy mean damn near every time)
Reply
#6
now that i look at it again, this may work too:

Quote:cfileitem *pfileitem = new cfileitem(*m_vecitems[i + m_ioffset]);
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply

Logout Mark Read Team Forum Stats Members Help
vector madness0