From 1ae907ef313d1ea34637ef50b93b5c8c28ddd6d2 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 9 Nov 2000 18:49:42 +0000 Subject: [PATCH] *** empty log message *** --- pandatool/src/cvscopy/cvsSourceTree.cxx | 7 ------- pandatool/src/flt/config_flt.cxx | 8 ++++++++ pandatool/src/flt/config_flt.h | 2 +- pandatool/src/flt/fltBead.cxx | 4 ++++ pandatool/src/flt/fltHeader.cxx | 12 ++++++++++++ pandatool/src/flt/fltRecord.cxx | 12 ++++++++++-- pandatool/src/flt/fltRecordReader.cxx | 9 +++++++++ pandatool/src/flt/fltRecordWriter.cxx | 6 ++++++ 8 files changed, 50 insertions(+), 10 deletions(-) diff --git a/pandatool/src/cvscopy/cvsSourceTree.cxx b/pandatool/src/cvscopy/cvsSourceTree.cxx index cb48407d33..da3b7f365c 100644 --- a/pandatool/src/cvscopy/cvsSourceTree.cxx +++ b/pandatool/src/cvscopy/cvsSourceTree.cxx @@ -286,13 +286,6 @@ prompt_user(const string &filename, CVSSourceDirectory *suggested_dir, if (result != (CVSSourceDirectory *)NULL) { return result; } - - } else { // dirs.empty() - nassertr(dirs.empty(), (CVSSourceDirectory *)NULL); - // The file does not already exist. - if (!interactive) { - return suggested_dir; - } } // The file does not already exist, or the user declined to replace diff --git a/pandatool/src/flt/config_flt.cxx b/pandatool/src/flt/config_flt.cxx index 72b23d724b..25f2a62746 100644 --- a/pandatool/src/flt/config_flt.cxx +++ b/pandatool/src/flt/config_flt.cxx @@ -34,6 +34,13 @@ Configure(config_flt); +// Set this true to trigger an assertion failure (and core dump) +// immediately when an error is detected on reading or writing a flt +// file. This is primarily useful for debugging the flt reader +// itself, to generate a stack trace to determine precisely at what +// point a flt file failed. +const bool flt_error_abort = config_flt.GetBool("flt-error-abort", false); + ConfigureFn(config_flt) { FltRecord::init_type(); FltBead::init_type(); @@ -61,3 +68,4 @@ ConfigureFn(config_flt) { FltTransformRotateScale::init_type(); FltExternalReference::init_type(); } + diff --git a/pandatool/src/flt/config_flt.h b/pandatool/src/flt/config_flt.h index 82116f21f7..538004cb9e 100644 --- a/pandatool/src/flt/config_flt.h +++ b/pandatool/src/flt/config_flt.h @@ -6,6 +6,6 @@ #ifndef CONFIG_FLT_H #define CONFIG_FLT_H -// No configure variables. +extern const bool flt_error_abort; #endif diff --git a/pandatool/src/flt/fltBead.cxx b/pandatool/src/flt/fltBead.cxx index 82910625f9..b8aae5ade4 100644 --- a/pandatool/src/flt/fltBead.cxx +++ b/pandatool/src/flt/fltBead.cxx @@ -13,6 +13,9 @@ #include "fltTransformScale.h" #include "fltTransformTranslate.h" #include "fltTransformRotateScale.h" +#include "config_flt.h" + +#include TypeHandle FltBead::_type_handle; @@ -356,6 +359,7 @@ write_transform(FltRecordWriter &writer) const { Transforms::const_iterator ti; for (ti = _transform_steps.begin(); ti != _transform_steps.end(); ++ti) { if (!(*ti)->build_record(writer)) { + assert(!flt_error_abort); return FE_invalid_record; } FltError result = writer.advance(); diff --git a/pandatool/src/flt/fltHeader.cxx b/pandatool/src/flt/fltHeader.cxx index bb434a4b12..43d109d206 100644 --- a/pandatool/src/flt/fltHeader.cxx +++ b/pandatool/src/flt/fltHeader.cxx @@ -7,6 +7,9 @@ #include "fltRecordReader.h" #include "fltRecordWriter.h" #include "fltUnsupportedRecord.h" +#include "config_flt.h" + +#include TypeHandle FltHeader::_type_handle; @@ -76,6 +79,7 @@ read_flt(Filename filename) { ifstream in; if (!filename.open_read(in)) { + assert(!flt_error_abort); return FE_could_not_open; } @@ -101,6 +105,7 @@ read_flt(istream &in) { FltRecordReader reader(in); FltError result = reader.advance(); if (result == FE_end_of_file) { + assert(!flt_error_abort); return FE_empty_file; } else if (result != FE_ok) { return result; @@ -112,6 +117,7 @@ read_flt(istream &in) { } if (!reader.eof()) { + assert(!flt_error_abort); return FE_extra_data; } @@ -132,6 +138,7 @@ write_flt(Filename filename) { ofstream out; if (!filename.open_write(out)) { + assert(!flt_error_abort); return FE_could_not_open; } @@ -151,6 +158,7 @@ write_flt(ostream &out) { FltError result = write_record_and_children(writer); if (out.fail()) { + assert(!flt_error_abort); return FE_write_error; } return result; @@ -1455,6 +1463,7 @@ write_color_palette(FltRecordWriter &writer) const { Colors::const_iterator ci; for (ci = _colors.begin(); num_colors > 0 && ci != _colors.end(); ++ci) { if (!(*ci).build_record(writer)) { + assert(!flt_error_abort); return FE_invalid_record; } num_colors--; @@ -1466,6 +1475,7 @@ write_color_palette(FltRecordWriter &writer) const { FltPackedColor empty; while (num_colors > 0) { if (!empty.build_record(writer)) { + assert(!flt_error_abort); return FE_invalid_record; } num_colors--; @@ -1573,6 +1583,7 @@ write_eyepoint_palette(FltRecordWriter &writer) const { int num_eyepoints = get_num_eyepoints(); for (i = 0; i < num_eyepoints; i++) { if (!_eyepoints[i].build_record(writer)) { + assert(!flt_error_abort); return FE_bad_data; } } @@ -1580,6 +1591,7 @@ write_eyepoint_palette(FltRecordWriter &writer) const { int num_trackplanes = get_num_trackplanes(); for (i = 0; i < num_trackplanes; i++) { if (!_trackplanes[i].build_record(writer)) { + assert(!flt_error_abort); return FE_bad_data; } } diff --git a/pandatool/src/flt/fltRecord.cxx b/pandatool/src/flt/fltRecord.cxx index 4e47e49ff1..2dc7000792 100644 --- a/pandatool/src/flt/fltRecord.cxx +++ b/pandatool/src/flt/fltRecord.cxx @@ -16,9 +16,12 @@ #include "fltInstanceRef.h" #include "fltUnsupportedRecord.h" #include "fltExternalReference.h" +#include "config_flt.h" #include +#include + TypeHandle FltRecord::_type_handle; //////////////////////////////////////////////////////////////////// @@ -44,8 +47,8 @@ FltRecord:: //////////////////////////////////////////////////////////////////// // Function: FltRecord::get_num_children // Access: Public -// Description: Returns the number of child records of this record. This -// reflects the normal scene graph hierarchy. +// Description: Returns the number of child records of this record. +// This reflects the normal scene graph hierarchy. //////////////////////////////////////////////////////////////////// int FltRecord:: get_num_children() const { @@ -430,6 +433,7 @@ FltError FltRecord:: read_record_and_children(FltRecordReader &reader) { if (!extract_record(reader)) { nout << "Could not extract record for " << *this << "\n"; + assert(!flt_error_abort); return FE_invalid_record; } FltError result = reader.advance(); @@ -468,6 +472,7 @@ read_record_and_children(FltRecordReader &reader) { } if (reader.eof() || reader.error()) { + assert(!flt_error_abort); return FE_end_of_file; } } @@ -487,6 +492,7 @@ read_record_and_children(FltRecordReader &reader) { } add_subface(subface); if (reader.eof() || reader.error()) { + assert(!flt_error_abort); return FE_end_of_file; } } @@ -555,6 +561,7 @@ FltError FltRecord:: write_record_and_children(FltRecordWriter &writer) const { // First, write the record. if (!build_record(writer)) { + assert(!flt_error_abort); return FE_bad_data; } @@ -571,6 +578,7 @@ write_record_and_children(FltRecordWriter &writer) const { Records::const_iterator ci; for (ci = _ancillary.begin(); ci != _ancillary.end(); ++ci) { if (!(*ci)->build_record(writer)) { + assert(!flt_error_abort); return FE_bad_data; } result = writer.advance(); diff --git a/pandatool/src/flt/fltRecordReader.cxx b/pandatool/src/flt/fltRecordReader.cxx index 05b8fa9940..da4bf1a1ed 100644 --- a/pandatool/src/flt/fltRecordReader.cxx +++ b/pandatool/src/flt/fltRecordReader.cxx @@ -4,9 +4,12 @@ //////////////////////////////////////////////////////////////////// #include "fltRecordReader.h" +#include "config_flt.h" #include +#include + //////////////////////////////////////////////////////////////////// // Function: FltRecordReader::Constructor // Access: Public @@ -95,9 +98,11 @@ get_record_length() const { FltError FltRecordReader:: advance() { if (_state == S_eof) { + assert(!flt_error_abort); return FE_end_of_file; } if (_state == S_error) { + assert(!flt_error_abort); return FE_read_error; } if (_iterator != (DatagramIterator *)NULL) { @@ -113,10 +118,12 @@ advance() { if (_in.eof()) { _state = S_eof; + assert(!flt_error_abort); return FE_end_of_file; } else if (_in.fail()) { _state = S_error; + assert(!flt_error_abort); return FE_read_error; } @@ -137,11 +144,13 @@ advance() { if (_in.eof()) { _state = S_eof; + assert(!flt_error_abort); return FE_end_of_file; } if (_in.fail()) { _state = S_error; + assert(!flt_error_abort); return FE_read_error; } diff --git a/pandatool/src/flt/fltRecordWriter.cxx b/pandatool/src/flt/fltRecordWriter.cxx index 826def18c0..f5eb64edcf 100644 --- a/pandatool/src/flt/fltRecordWriter.cxx +++ b/pandatool/src/flt/fltRecordWriter.cxx @@ -6,9 +6,12 @@ #include "fltRecordWriter.h" #include "fltInstanceDefinition.h" #include "fltHeader.h" +#include "config_flt.h" #include +#include + //////////////////////////////////////////////////////////////////// // Function: FltRecordWriter::Constructor // Access: Public @@ -86,12 +89,14 @@ advance() { _out.write(dg.get_message().data(), dg.get_length()); if (_out.fail()) { + assert(!flt_error_abort); return FE_write_error; } // Now write the rest of the record. _out.write(_datagram.get_message().data(), _datagram.get_length()); if (_out.fail()) { + assert(!flt_error_abort); return FE_write_error; } @@ -133,6 +138,7 @@ write_instance_def(FltHeader *header, int instance_index) { FltInstanceDefinition *instance = header->get_instance(instance_index); if (instance == (FltInstanceDefinition *)NULL) { + assert(!flt_error_abort); return FE_undefined_instance; }