|
|
On Thursday, March 16, 2023 at 10:53:01 AM UTC-7 Albrecht Schlosser wrote:
My proposed changes: since I'm not sure that we are using the same
version of the Cartesian project, following is the full code of the
two mentioned d'tors with fixes.
```
Cartesian.cpp-728-Ca_X_Axis::~Ca_X_Axis(){
Cartesian.cpp-729- if(canvas_){
Cartesian.cpp-730- Ca_ObjectChain *ochain=canvas_->first_object_;
Cartesian.cpp-731- Ca_ObjectChain *next;
Cartesian.cpp-732- Ca_ObjectChain *previous=0;
Cartesian.cpp-733- while (ochain){
Cartesian.cpp-734- next=ochain->next;
Cartesian.cpp-735- if(ochain->object->x_axis_==this){
Cartesian.cpp-736- delete ochain->object;
Cartesian.cpp-737- if(previous)
Cartesian.cpp-738- previous->next=next;
Cartesian.cpp-739- else
Cartesian.cpp-740- canvas_->first_object_=next;
Cartesian.cpp:741: // delete ochain; // would cause double free <<<<<<<
Cartesian.cpp-742- }
Cartesian.cpp-743- ochain=next;
Cartesian.cpp-744- }
Cartesian.cpp-745- }
Cartesian.cpp-746-}
--
Cartesian.cpp-1051-Ca_Y_Axis::~Ca_Y_Axis(){
Cartesian.cpp-1052- if(canvas_){
Cartesian.cpp-1053- Ca_ObjectChain *ochain=canvas_->first_object_;
Cartesian.cpp-1054- Ca_ObjectChain *next;
Cartesian.cpp-1055- Ca_ObjectChain *previous=0;
Cartesian.cpp-1056- while (ochain){
Cartesian.cpp-1057- next=ochain->next;
Cartesian.cpp-1058- if(ochain->object->y_axis_==this){
Cartesian.cpp-1059- delete ochain->object;
Cartesian.cpp-1060- if(previous)
Cartesian.cpp-1061- previous->next=next;
Cartesian.cpp-1062- else
Cartesian.cpp-1063- canvas_->first_object_=next;
Cartesian.cpp:1064: // delete ochain; // would cause double free <<<<<<<
Cartesian.cpp-1065- }
Cartesian.cpp-1066- ochain=next;
Cartesian.cpp-1067- }
Cartesian.cpp-1068- }
Cartesian.cpp-1069-}
```
This fix works for me.
It took a while for me to figure out what he was doing -- it feels much more complex than a singly linked list should be. It took even longer to convince myself that the fix is right.
As you say -- it is hard to understand why the FLTK change would trigger this.
I also removed everything to do with previous -- it looks like a remnant of a doubly linked list, but it isn't used now.
Thanks again,
Rob
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/ad0ad9c9-59df-48af-9e64-74e6d7844b99n%40googlegroups.com.
[ Direct Link to Message ] | |
|
| |