gui: PreviewResult*: Wrap result in shared pointer immediatly

This commit is contained in:
Albert S. 2022-11-13 17:37:35 +01:00
부모 abce4cfcd9
커밋 9686ef30c7
2개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제

파일 보기

@ -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;
}

파일 보기

@ -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;
}