From 2b6347d0bd279ab2e45dfedc9390fd8c886b6a00 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Fri, 1 Feb 2019 21:32:48 +0100 Subject: [PATCH] STR #3445: Duplicating Widget Class in Fluid no longer crashes. --- CHANGES.txt | 1 + fluid/Fl_Widget_Type.cxx | 2 +- fluid/factory.cxx | 10 +++++-- fluid/file.cxx | 62 +++++++++++++++++++++------------------- 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 6884618b4..36696174f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -145,6 +145,7 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2019 Bug Fixes - (add new items here) + - Duplicating Widget Class in Fluid no longer crashes (STR #3445). - Fl_Check_Browser::add(item) now accepts NULL (STR #3498). - Interface to set maximum width of spinner text field (STR #3386). - Fl_Text_Display no longer wiggles (STR #2531). diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index 7023fbf2d..2123074c4 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -102,7 +102,7 @@ Fl_Type *Fl_Widget_Type::make() { Fl_Widget_Type* q = (Fl_Widget_Type*)qq; // find the parent widget: Fl_Widget_Type* p = q; - if ((force_parent || !p->is_group()) && p->parent->is_widget()) + if ((force_parent || !p->is_group()) && p->parent && p->parent->is_widget()) p = (Fl_Widget_Type*)(p->parent); force_parent = 0; diff --git a/fluid/factory.cxx b/fluid/factory.cxx index 4008536df..c71fc97ae 100644 --- a/fluid/factory.cxx +++ b/fluid/factory.cxx @@ -1116,8 +1116,14 @@ Fl_Type *Fl_Type_make(const char *tn) { Fl_Menu_Item *m = New_Menu+i; if (!m->user_data()) continue; Fl_Type *t = (Fl_Type*)(m->user_data()); - if (!fl_ascii_strcasecmp(tn,t->type_name())) {r = t->make(); break;} - if (!fl_ascii_strcasecmp(tn,t->alt_type_name())) {r = t->make(); break;} + if (!fl_ascii_strcasecmp(tn,t->type_name())) { + r = t->make(); + break; + } + if (!fl_ascii_strcasecmp(tn,t->alt_type_name())) { + r = t->make(); + break; + } } reading_file = 0; return r; diff --git a/fluid/file.cxx b/fluid/file.cxx index 10259f267..65c4131bb 100644 --- a/fluid/file.cxx +++ b/fluid/file.cxx @@ -450,40 +450,44 @@ static void read_children(Fl_Type *p, int paste) { goto CONTINUE; } - {Fl_Type *t = Fl_Type_make(c); - if (!t) { - read_error("Unknown word \"%s\"", c); - continue; - } - t->name(read_word()); + { + Fl_Type *t = Fl_Type_make(c); + if (!t) { + read_error("Unknown word \"%s\"", c); + continue; + } + t->name(read_word()); - c = read_word(1); - if (strcmp(c,"{") && t->is_class()) { // - ((Fl_Class_Type*)t)->prefix(t->name()); - t->name(c); c = read_word(1); + if (strcmp(c,"{") && t->is_class()) { // + ((Fl_Class_Type*)t)->prefix(t->name()); + t->name(c); + c = read_word(1); + } + + if (strcmp(c,"{")) { + read_error("Missing property list for %s\n",t->title()); + goto REUSE_C; + } + + t->open_ = 0; + for (;;) { + const char *cc = read_word(); + if (!cc || !strcmp(cc,"}")) break; + t->read_property(cc); + } + + if (!t->is_parent()) continue; + c = read_word(1); + if (strcmp(c,"{")) { + read_error("Missing child list for %s\n",t->title()); + goto REUSE_C; + } + read_children(t, 0); } - if (strcmp(c,"{")) { - read_error("Missing property list for %s\n",t->title()); - goto REUSE_C; - } - - t->open_ = 0; - for (;;) { - const char *cc = read_word(); - if (!cc || !strcmp(cc,"}")) break; - t->read_property(cc); - } - - if (!t->is_parent()) continue; - c = read_word(1); - if (strcmp(c,"{")) { - read_error("Missing child list for %s\n",t->title()); - goto REUSE_C; - } - read_children(t, 0);} Fl_Type::current = p; + CONTINUE:; } }