Fix removal and deletion of the resizable() of Fl_Group

If the resizable() of an Fl_Group is deleted it is automatically
removed from the group.

New: to avoid dangling resizable() pointers the resizable widget
is set to the group itself.
This commit is contained in:
Albrecht Schlosser
2022-10-28 17:37:18 +02:00
parent f9acdb6edb
commit a918292547
2 changed files with 10 additions and 1 deletions
+9 -1
View File
@@ -1,7 +1,7 @@
// //
// Group header file for the Fast Light Tool Kit (FLTK). // Group header file for the Fast Light Tool Kit (FLTK).
// //
// Copyright 1998-2021 by Bill Spitzak and others. // Copyright 1998-2022 by Bill Spitzak and others.
// //
// This library is free software. Distribution and use rights are outlined in // This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this // the file "COPYING" which should have been included with this file. If this
@@ -152,6 +152,14 @@ public:
dimensions of the box are scaled to the new size. Widgets outside the dimensions of the box are scaled to the new size. Widgets outside the
box are moved. box are moved.
\note The resizable of a group \b must be one of
- NULL
- the group itself
- a direct child of the group.
\note If you set any other widget that is not a direct child of the group as
its resizable then the behavior is undefined. This is \b not checked by
Fl_Group for historical reasons.
In these examples the gray area is the resizable: In these examples the gray area is the resizable:
\image html resizebox1.png \image html resizebox1.png
+1
View File
@@ -501,6 +501,7 @@ void Fl_Group::remove(int index) {
if (index < 0 || index >= children_) return; if (index < 0 || index >= children_) return;
Fl_Widget &o = *child(index); Fl_Widget &o = *child(index);
if (&o == savedfocus_) savedfocus_ = 0; if (&o == savedfocus_) savedfocus_ = 0;
if (&o == resizable_) resizable_ = this;
if (o.parent_ == this) { // this should always be true if (o.parent_ == this) { // this should always be true
o.parent_ = 0; o.parent_ = 0;
} }