mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-09 04:30:43 +00:00
Make XML recording thread-safe.
This commit is contained in:
parent
8fbf665b89
commit
92d0af220d
@ -30,9 +30,12 @@ public:
|
|||||||
XmlRecorder(QString & string);
|
XmlRecorder(QString & string);
|
||||||
~XmlRecorder();
|
~XmlRecorder();
|
||||||
inline QXmlStreamWriter & xml() { return *m_xml; }
|
inline QXmlStreamWriter & xml() { return *m_xml; }
|
||||||
|
inline void lock() { m_mutex.lock(); }
|
||||||
|
inline void unlock() { m_mutex.unlock(); }
|
||||||
protected:
|
protected:
|
||||||
QFile* m_file; // nullptr for non-file recordings
|
QFile* m_file; // nullptr for non-file recordings
|
||||||
QXmlStreamWriter* m_xml;
|
QXmlStreamWriter* m_xml;
|
||||||
|
QMutex m_mutex;
|
||||||
|
|
||||||
void prologue();
|
void prologue();
|
||||||
void epilogue();
|
void epilogue();
|
||||||
@ -222,7 +225,9 @@ void XmlReplayEvent::record(XmlRecorder* writer)
|
|||||||
{
|
{
|
||||||
// Do nothing if we're not recording.
|
// Do nothing if we're not recording.
|
||||||
if (writer != nullptr) {
|
if (writer != nullptr) {
|
||||||
|
writer->lock();
|
||||||
writer->xml() << *this;
|
writer->xml() << *this;
|
||||||
|
writer->unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user