diff --git a/libs/main/serialization/pibinarystream.h b/libs/main/serialization/pibinarystream.h
index e1dbeb62..8b1be096 100644
--- a/libs/main/serialization/pibinarystream.h
+++ b/libs/main/serialization/pibinarystream.h
@@ -109,7 +109,7 @@ public:
}
//! \~english Returns whether there has been an incomplete read since last \a resetReadError() or after the stream was created
- //! \~russian Возвращает было ли неполное чтение с момента последнего вызова \a resetReadError()
+ //! \~russian Возвращает было ли неполное чтение с момента последнего вызова \a resetReadError() или создания потока
bool wasReadError() const { return _was_read_error_; }
//! \~english Reset incomplete read flag
@@ -467,6 +467,11 @@ inline PIBinaryStream
& operator>>(PIBinaryStream
& s, PIVector2D & v)
r = s.binaryStreamTakeInt();
c = s.binaryStreamTakeInt();
s >> tmp;
+ if (s.wasReadError()) {
+ printf("error with PIVector2D<%s>\n", __PIP_TYPENAME__(T));
+ v.clear();
+ return s;
+ }
v = PIVector2D(r, c, tmp);
return s;
}
@@ -536,7 +541,13 @@ inline PIBinaryStream & operator<<(PIBinaryStream
& s, const PIVector2D
//! \~russian Оператор извлечения для PIVector сложных типов
template::value, int>::type = 0>
inline PIBinaryStream & operator>>(PIBinaryStream
& s, PIVector & v) {
- v.resize(s.binaryStreamTakeInt());
+ int sz = s.binaryStreamTakeInt();
+ if (s.wasReadError()) {
+ printf("error with PIVector<%s>\n", __PIP_TYPENAME__(T));
+ v.clear();
+ return s;
+ }
+ v.resize(sz);
for (size_t i = 0; i < v.size(); ++i) {
s >> v[i];
if (s.wasReadError()) {
@@ -553,7 +564,13 @@ inline PIBinaryStream & operator>>(PIBinaryStream
& s, PIVector & v) {
//! \~russian Оператор извлечения для PIDeque сложных типов
template::value, int>::type = 0>
inline PIBinaryStream & operator>>(PIBinaryStream
& s, PIDeque & v) {
- v.resize(s.binaryStreamTakeInt());
+ int sz = s.binaryStreamTakeInt();
+ if (s.wasReadError()) {
+ printf("error with PIDeque<%s>\n", __PIP_TYPENAME__(T));
+ v.clear();
+ return s;
+ }
+ v.resize(sz);
for (size_t i = 0; i < v.size(); ++i) {
s >> v[i];
if (s.wasReadError()) {
@@ -575,6 +592,11 @@ inline PIBinaryStream & operator>>(PIBinaryStream
& s, PIVector2D & v)
r = s.binaryStreamTakeInt();
c = s.binaryStreamTakeInt();
s >> tmp;
+ if (s.wasReadError()) {
+ printf("error with PIVector2D<%s>\n", __PIP_TYPENAME__(T));
+ v.clear();
+ return s;
+ }
v = PIVector2D(r, c, tmp);
return s;
}
@@ -602,6 +624,11 @@ inline PIBinaryStream & operator<<(PIBinaryStream
& s, const PIMap
template
inline PIBinaryStream & operator>>(PIBinaryStream
& s, PIMap & v) {
int sz = s.binaryStreamTakeInt();
+ if (s.wasReadError()) {
+ printf("error with PIMap<%s, %s>\n", __PIP_TYPENAME__(Key), __PIP_TYPENAME__(T));
+ v.clear();
+ return s;
+ }
v.pim_index.resize(sz);
int ind = 0;
for (int i = 0; i < sz; ++i) {