diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2005-09-05 10:32:39 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2005-09-05 10:32:39 +0000 |
| commit | edcc1980a1bbeaf07a48ce5ce6225d5ae6cfb004 (patch) | |
| tree | ea4f7f038fd678740c5a1bc45a2c69807801a810 | |
| parent | f0d44ed955e4752de823d3489599abab08030a98 (diff) | |
STR #1010: if a widget callback is generated inside a widget class, the static callback uses the parent() function to find the 'this' pointer, instead of the 'user_data()' member, which would be NULL anyways
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4556 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | fluid/Fl_Widget_Type.cxx | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index f949b64a5..b4740b56b 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -1838,10 +1838,13 @@ void Fl_Widget_Type::write_static() { write_c("\n}\n"); if (k) { write_c("void %s::%s(%s* o, %s v) {\n", k, cn, t, ut); - write_c(" ((%s*)(o->", k); - for (Fl_Type* p = parent; p && p->is_widget(); p = p->parent) - write_c("parent()->"); - write_c("user_data()))->%s_i(o,v);\n}\n", cn); + write_c(" ((%s*)(o", k); + Fl_Type *q = 0; + for (Fl_Type* p = parent; p && p->is_widget(); q = p, p = p->parent) + write_c("->parent()"); + if (!q || strcmp(q->type_name(), "widget_class")) + write_c("->user_data()"); + write_c("))->%s_i(o,v);\n}\n", cn); } } if (image) { @@ -1881,7 +1884,7 @@ void Fl_Widget_Type::write_code1() { write_h(" void %s_i(%s*, %s);\n", cn, t, ut); write_h(" static void %s(%s*, %s);\n", cn, t, ut); } - // figure out if local varaible will be used (prevent compiler warnings): + // figure out if local variable will be used (prevent compiler warnings): if (is_parent()) varused = 1; else { |
