From 0043e7a44daa1b910d82d37a20c23b2b11245ed3 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Wed, 26 Jul 2006 23:27:32 +0000 Subject: Fix return of window widget - use "w" or the name of the window, as appropriate. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5268 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- fluid/Fl_Function_Type.cxx | 13 ++++++++++--- fluid/Fl_Widget_Type.cxx | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index 5167657e5..6638c235d 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/fluid/Fl_Function_Type.cxx @@ -334,7 +334,8 @@ void Fl_Function_Type::write_code1() { write_c("%s%s %s {\n", rtype, star, s); } } -// if (havewidgets) write_c(" %s* w;\n",subclassname(child)); + + if (havewidgets && !child->name()) write_c(" %s* w;\n", subclassname(child)); indentation += 2; } @@ -342,8 +343,14 @@ void Fl_Function_Type::write_code2() { if (ismain()) { if (havewidgets) write_c(" w->show(argc, argv);\n"); write_c(" return Fl::run();\n"); - } else if (havewidgets && !constructor && !return_type) - write_c(" return w;\n"); + } else if (havewidgets && !constructor && !return_type) { + Fl_Type *child; + const char *var = "w"; + for (child = next; child && child->level > level; child = child->next) + if (child->is_window() && child->name()) var = child->name(); + + write_c(" return %s;\n", var); + } write_c("}\n"); indentation = 0; } diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx index b799fc173..b5f7441dc 100644 --- a/fluid/Fl_Widget_Type.cxx +++ b/fluid/Fl_Widget_Type.cxx @@ -2010,7 +2010,7 @@ void Fl_Widget_Type::write_code1() { if (oused) indentation += 2; - if (wused) write_c("%s%s* w = o;\n",indent(), subclassname(this)); + if (wused) write_c("%sw = o;\n", indent()); write_widget_code(); } -- cgit v1.2.3