summaryrefslogtreecommitdiff
path: root/src/ui/widget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-26 07:26:13 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-26 07:27:56 +0300
commit44b80a27509a5afa8763bd31b1d28883dbe43e10 (patch)
tree43621cf528630d375e725795675205b1b464ff6e /src/ui/widget.c
parentb6c2742f6beb0bc162ea9fdc43050e14c784eb33 (diff)
Root: Crash when closing split view
Some deleted widgets were kept around in the root's onTop list.
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r--src/ui/widget.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 6b9ee11d..bdc5f090 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -105,7 +105,12 @@ static void printInfo_Widget_(const iWidget *);
105 105
106void releaseChildren_Widget(iWidget *d) { 106void releaseChildren_Widget(iWidget *d) {
107 iForEach(ObjectList, i, d->children) { 107 iForEach(ObjectList, i, d->children) {
108 ((iWidget *) i.object)->parent = NULL; /* the actual reference being held */ 108 iWidget *child = i.object;
109 child->parent = NULL; /* the actual reference being held */
110 if (child->flags & keepOnTop_WidgetFlag) {
111 removeOne_PtrArray(onTop_Root(child->root), child);
112 child->flags &= ~keepOnTop_WidgetFlag;
113 }
109 } 114 }
110 iReleasePtr(&d->children); 115 iReleasePtr(&d->children);
111} 116}
@@ -318,6 +323,13 @@ void setCommandHandler_Widget(iWidget *d, iBool (*handler)(iWidget *, const char
318} 323}
319 324
320void setRoot_Widget(iWidget *d, iRoot *root) { 325void setRoot_Widget(iWidget *d, iRoot *root) {
326 if (d->flags & keepOnTop_WidgetFlag) {
327 iAssert(indexOf_PtrArray(onTop_Root(root), d) == iInvalidPos);
328 /* Move it over the new root's onTop list. */
329 removeOne_PtrArray(onTop_Root(d->root), d);
330 iAssert(indexOf_PtrArray(onTop_Root(d->root), d) == iInvalidPos);
331 pushBack_PtrArray(onTop_Root(root), d);
332 }
321 d->root = root; 333 d->root = root;
322 iForEach(ObjectList, i, d->children) { 334 iForEach(ObjectList, i, d->children) {
323 setRoot_Widget(i.object, root); 335 setRoot_Widget(i.object, root);
@@ -1667,7 +1679,13 @@ iAny *removeChild_Widget(iWidget *d, iAnyObject *child) {
1667 } 1679 }
1668 } 1680 }
1669 iAssert(found); 1681 iAssert(found);
1670 ((iWidget *) child)->parent = NULL; 1682 iWidget *childWidget = child;
1683// if (childWidget->flags & keepOnTop_WidgetFlag) {
1684// removeOne_PtrArray(onTop_Root(childWidget->root), childWidget);
1685// iAssert(indexOf_PtrArray(onTop_Root(childWidget->root), childWidget) == iInvalidPos);
1686// }
1687// printf("%s:%d [%p] parent = NULL\n", __FILE__, __LINE__, d);
1688 childWidget->parent = NULL;
1671 postRefresh_App(); 1689 postRefresh_App();
1672 return child; 1690 return child;
1673} 1691}