diff --git a/pandatool/src/flt/fltRecord.cxx b/pandatool/src/flt/fltRecord.cxx index 6c016f8826..fbf8d282cd 100644 --- a/pandatool/src/flt/fltRecord.cxx +++ b/pandatool/src/flt/fltRecord.cxx @@ -710,23 +710,6 @@ write_record_and_children(FltRecordWriter &writer) const { } } - // Any subfaces? - if (!_subfaces.empty()) { - result = writer.write_record(FO_push_face); - if (result != FE_ok) { - return result; - } - - for (ci = _subfaces.begin(); ci != _subfaces.end(); ++ci) { - (*ci)->write_record_and_children(writer); - } - - result = writer.write_record(FO_pop_face); - if (result != FE_ok) { - return result; - } - } - // Any extensions? if (!_extensions.empty()) { result = writer.write_record(FO_push_face); @@ -761,6 +744,24 @@ write_record_and_children(FltRecordWriter &writer) const { } } + // We must write subfaces *after* the list of children, or Creator + // will crash trying to load the file. + if (!_subfaces.empty()) { + result = writer.write_record(FO_push_face); + if (result != FE_ok) { + return result; + } + + for (ci = _subfaces.begin(); ci != _subfaces.end(); ++ci) { + (*ci)->write_record_and_children(writer); + } + + result = writer.write_record(FO_pop_face); + if (result != FE_ok) { + return result; + } + } + return FE_ok; }