PttreeModifyString causing Seg fault

Hey all,

I ran into this weird problem at work today. Basically, on some call to
PtModifyString where the string length changes, a seg fault would result on
that call.

I’m 99.999% sure its my problem somewhere else in my code, as I’ve tried to
run tests to just test PttreeModifyString scenarious and they all seem to
pass.

But just to check. Are there any known issues with PttreeModifyString or
anything else you guys can think of besides me messing up memory somewhere?
There’s not many calls to dynamic memory allocation, so I’m guessing maybe
writing outside of array bounds or something like that. If it’s an issue, I
am using the pttree inside a PtOsContainer to prevent flickering.

I remember having a similar problem like this a while ago, but it just
seemed to disappear as I kept coding…guess it comes back to haunt me.

Thanx all,

Yamin

Yamin,

How are you using PtTreeModifyItemString( )? Are you doing anything with
the PtTreeItem pointer, or have any data associated with that particular
PtTreeItem?

If you change the length of the string, it may cause the PtTreeItem to be
reallocated. This would definitely screw up any references you may have had
to that item.

e.g. if you are modifying “my_tree_item” make sure you do something like
this:

void* tmp_data = my_tree_item->data;
PtTreeItem_t* new_item = PtTreeModifyItemString( my_tree_widget,
my_tree_item, “My new string” );
if ( new_item == NULL )
return some_error;
new_item->data = tmp_data;
my_tree_item = new_item;

-Chris

“Yamin” <y2bismil@uwaterloo.ca> wrote in message
news:aellt1$k90$1@inn.qnx.com

Hey all,

I ran into this weird problem at work today. Basically, on some call to
PtModifyString where the string length changes, a seg fault would result
on
that call.

I’m 99.999% sure its my problem somewhere else in my code, as I’ve tried
to
run tests to just test PttreeModifyString scenarious and they all seem to
pass.

But just to check. Are there any known issues with PttreeModifyString or
anything else you guys can think of besides me messing up memory
somewhere?
There’s not many calls to dynamic memory allocation, so I’m guessing maybe
writing outside of array bounds or something like that. If it’s an issue,
I
am using the pttree inside a PtOsContainer to prevent flickering.

I remember having a similar problem like this a while ago, but it just
seemed to disappear as I kept coding…guess it comes back to haunt me.

Thanx all,

Yamin

moved to qnx.public.qnxrtp.photon

“Chris Wiebe” <cwiebe@qnx.com> wrote in message
news:aelu63$3nq$1@nntp.qnx.com

Yamin,

How are you using PtTreeModifyItemString( )? Are you doing anything with
the PtTreeItem pointer, or have any data associated with that particular
PtTreeItem?

If you change the length of the string, it may cause the PtTreeItem to be
reallocated. This would definitely screw up any references you may have
had
to that item.

e.g. if you are modifying “my_tree_item” make sure you do something like
this:

void* tmp_data = my_tree_item->data;
PtTreeItem_t* new_item = PtTreeModifyItemString( my_tree_widget,
my_tree_item, “My new string” );
if ( new_item == NULL )
return some_error;
new_item->data = tmp_data;
my_tree_item = new_item;

-Chris

“Yamin” <> y2bismil@uwaterloo.ca> > wrote in message
news:aellt1$k90$> 1@inn.qnx.com> …
Hey all,

I ran into this weird problem at work today. Basically, on some call to
PtModifyString where the string length changes, a seg fault would result
on
that call.

I’m 99.999% sure its my problem somewhere else in my code, as I’ve tried
to
run tests to just test PttreeModifyString scenarious and they all seem
to
pass.

But just to check. Are there any known issues with PttreeModifyString
or
anything else you guys can think of besides me messing up memory
somewhere?
There’s not many calls to dynamic memory allocation, so I’m guessing
maybe
writing outside of array bounds or something like that. If it’s an
issue,
I
am using the pttree inside a PtOsContainer to prevent flickering.

I remember having a similar problem like this a while ago, but it just
seemed to disappear as I kept coding…guess it comes back to haunt me.

Thanx all,

Yamin
\