Save object in document only when locked for painting
parent
484f6aaaba
commit
f6ea8bd206
|
@ -85,8 +85,6 @@ void AutoSaver::check()
|
|||
Snapshot *snapshot = new Snapshot;
|
||||
m_document->toSnapshot(snapshot);
|
||||
|
||||
Object *object = new Object(m_document->currentPostProcessedObject());
|
||||
|
||||
QByteArray *turnaroundPngByteArray = nullptr;
|
||||
if (!m_document->turnaround.isNull() && m_document->turnaroundPngByteArray.size() > 0) {
|
||||
turnaroundPngByteArray = new QByteArray(m_document->turnaroundPngByteArray);
|
||||
|
@ -103,7 +101,12 @@ void AutoSaver::check()
|
|||
scriptVariables = new std::map<QString, std::map<QString, QString>>(variables);
|
||||
}
|
||||
|
||||
DocumentSaver::Textures *textures = new DocumentSaver::Textures;
|
||||
Object *object = nullptr;
|
||||
DocumentSaver::Textures *textures = nullptr;
|
||||
|
||||
if (m_document->objectLocked) {
|
||||
object = new Object(m_document->currentPostProcessedObject());
|
||||
textures = new DocumentSaver::Textures;
|
||||
if (nullptr != m_document->textureImage) {
|
||||
textures->textureImage = new QImage(*m_document->textureImage);
|
||||
}
|
||||
|
@ -120,7 +123,7 @@ void AutoSaver::check()
|
|||
textures->textureAmbientOcclusionImage = new QImage(*m_document->textureAmbientOcclusionImage);
|
||||
}
|
||||
textures->textureHasTransparencySettings = m_document->textureHasTransparencySettings;
|
||||
|
||||
}
|
||||
QThread *thread = new QThread;
|
||||
m_documentSaver = new DocumentSaver(&m_filename,
|
||||
snapshot,
|
||||
|
|
|
@ -109,7 +109,7 @@ bool DocumentSaver::save(const QString *filename,
|
|||
ds3Writer.add("model.xml", "model", &modelXml);
|
||||
}
|
||||
|
||||
{
|
||||
if (nullptr != object) {
|
||||
QByteArray objectXml;
|
||||
QXmlStreamWriter stream(&objectXml);
|
||||
saveObjectToXmlStream(object, &stream);
|
||||
|
@ -117,7 +117,7 @@ bool DocumentSaver::save(const QString *filename,
|
|||
ds3Writer.add("object.xml", "object", &objectXml);
|
||||
}
|
||||
|
||||
if (nullptr != textures) {
|
||||
if (nullptr != object && nullptr != textures) {
|
||||
if (nullptr != textures->textureImage && !textures->textureImage->isNull()) {
|
||||
if (nullptr == textures->textureImageByteArray) {
|
||||
textures->textureImageByteArray = new QByteArray;
|
||||
|
|
|
@ -1584,7 +1584,9 @@ void DocumentWindow::saveTo(const QString &saveAsFilename)
|
|||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
Snapshot snapshot;
|
||||
m_document->toSnapshot(&snapshot);
|
||||
bool saveObject = m_document->objectLocked;
|
||||
DocumentSaver::Textures textures;
|
||||
if (saveObject) {
|
||||
textures.textureImage = m_document->textureImage;
|
||||
textures.textureImageByteArray = m_document->textureImageByteArray;
|
||||
textures.textureNormalImage = m_document->textureNormalImage;
|
||||
|
@ -1596,16 +1598,18 @@ void DocumentWindow::saveTo(const QString &saveAsFilename)
|
|||
textures.textureAmbientOcclusionImage = m_document->textureAmbientOcclusionImage;
|
||||
textures.textureAmbientOcclusionImageByteArray = m_document->textureAmbientOcclusionImageByteArray;
|
||||
textures.textureHasTransparencySettings = m_document->textureHasTransparencySettings;
|
||||
}
|
||||
if (DocumentSaver::save(&filename,
|
||||
&snapshot,
|
||||
&m_document->currentPostProcessedObject(),
|
||||
&textures,
|
||||
saveObject ? &m_document->currentPostProcessedObject() : nullptr,
|
||||
saveObject ? &textures : nullptr,
|
||||
(!m_document->turnaround.isNull() && m_document->turnaroundPngByteArray.size() > 0) ?
|
||||
&m_document->turnaroundPngByteArray : nullptr,
|
||||
(!m_document->script().isEmpty()) ? &m_document->script() : nullptr,
|
||||
(!m_document->variables().empty()) ? &m_document->variables() : nullptr)) {
|
||||
setCurrentFilename(filename);
|
||||
}
|
||||
if (saveObject) {
|
||||
textures.textureImage = nullptr;
|
||||
textures.textureNormalImage = nullptr;
|
||||
textures.textureMetalnessImage = nullptr;
|
||||
|
@ -1636,7 +1640,7 @@ void DocumentWindow::saveTo(const QString &saveAsFilename)
|
|||
std::swap(textures.textureAmbientOcclusionImageByteArray, m_document->textureAmbientOcclusionImageByteArray);
|
||||
else
|
||||
textures.textureAmbientOcclusionImageByteArray = nullptr;
|
||||
|
||||
}
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue