diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index 21bdb5b37..3576e837b 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/fluid/Fl_Function_Type.cxx @@ -208,7 +208,7 @@ 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) + } else if (havewidgets && !constructor && !return_type) write_c(" return w;\n"); write_c("}\n"); indentation = 0; diff --git a/fluid/code.cxx b/fluid/code.cxx index a8028acc1..5a5312528 100644 --- a/fluid/code.cxx +++ b/fluid/code.cxx @@ -243,8 +243,14 @@ int write_code(const char *s, const char *t) { if (t && include_H_from_C) write_c("#include \"%s\"\n", filename_name(t)); - for (p = Fl_Type::first; p; p = p->next) p->write_static(); - for (p = Fl_Type::first; p;) p = write_code(p); + for (p = Fl_Type::first; p;) { + // write all static data for this & all children first + p->write_static(); + for (Fl_Type* q = p->next; q && q->level > p->level; q = q->next) + q->write_static(); + // then write the nested code: + p = write_code(p); + } if (!s) return 1; int x = fclose(code_file);