BUG: masterUncollated readStream causes checkOut/checkIn (#2952)

- updating the header information (by copying) was closing the stream,
  removing all watches and doing a checkOut/checkIn, which could lead to
  dangling references.
  Now just close the stream and simply copy the IOobject header
  information directly.

STYLE: mark regIOobject assignment operator as possibly deprecated

- will revisit to revise or remove in the future
This commit is contained in:
Mark Olesen
2023-12-12 14:24:24 +01:00
parent c647e68e1f
commit a0e4ee0b3e
2 changed files with 13 additions and 5 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -116,9 +116,6 @@ private:
//- Construct object stream, read header if not already constructed
void readStream(const bool readOnProc);
//- No copy assignment
void operator=(const regIOobject&) = delete;
public:
@ -127,6 +124,12 @@ public:
friend class fileOperations::uncollatedFileOperation;
// Generated Methods
//- No copy assignment
void operator=(const regIOobject&) = delete;
// Static Data
//- Runtime type information
@ -366,6 +369,7 @@ public:
// Member Operators
//- Copy assignment
FOAM_DEPRECATED_STRICT(2023-12, "possibly remove in the future")
void operator=(const IOobject& io);

View File

@ -2007,6 +2007,8 @@ Foam::fileOperations::masterUncollatedFileOperation::readStream
<< " fName : " << fName << " readOnProc:" << readOnProc << endl;
}
// Close old stream
io.close();
autoPtr<ISstream> isPtr;
bool isCollated = false;
@ -2044,7 +2046,9 @@ Foam::fileOperations::masterUncollatedFileOperation::readStream
<< " doing straight IFstream input from "
<< fName << endl;
}
io = headerIO;
// Copy IOobject header information
io.IOobject::operator=(headerIO);
return isPtr;
}
}