gui: PreviewResult*: Wrap result in shared pointer immediatly

This commit is contained in:
Albert S. 2022-11-13 17:37:35 +01:00
parent abce4cfcd9
commit 9686ef30c7
2 ha cambiato i file con 5 aggiunte e 4 eliminazioni

Vedi File

@ -30,7 +30,7 @@ QByteArray PreviewResultPdf::serialize() const
QSharedPointer<PreviewResultPdf> PreviewResultPdf::deserialize(QByteArray &ba)
{
PreviewResultPdf *result = new PreviewResultPdf();
QSharedPointer<PreviewResultPdf> result(new PreviewResultPdf());
PreviewResultType type;
QDataStream stream{&ba, QIODevice::ReadOnly};
@ -40,5 +40,5 @@ QSharedPointer<PreviewResultPdf> PreviewResultPdf::deserialize(QByteArray &ba)
throw std::runtime_error("Invalid byte array: Not a pdf preview");
}
stream >> result->documentPath >> result->page >> result->previewImage;
return QSharedPointer<PreviewResultPdf>(result);
return result;
}

Vedi File

@ -40,7 +40,8 @@ QByteArray PreviewResultPlainText::serialize() const
QSharedPointer<PreviewResultPlainText> PreviewResultPlainText::deserialize(QByteArray &ba)
{
PreviewResultPlainText *result = new PreviewResultPlainText();
QSharedPointer<PreviewResultPlainText> result(new PreviewResultPlainText());
PreviewResultType type;
QDataStream stream{&ba, QIODevice::ReadOnly};
@ -50,5 +51,5 @@ QSharedPointer<PreviewResultPlainText> PreviewResultPlainText::deserialize(QByte
throw std::runtime_error("Invalid byte array: Not a pdf preview");
}
stream >> result->documentPath >> result->page >> result->text;
return QSharedPointer<PreviewResultPlainText>(result);
return result;
}