gui: PreviewResult*: Wrap result in shared pointer immediatly
This commit is contained in:
parent
abce4cfcd9
commit
9686ef30c7
@ -30,7 +30,7 @@ QByteArray PreviewResultPdf::serialize() const
|
|||||||
|
|
||||||
QSharedPointer<PreviewResultPdf> PreviewResultPdf::deserialize(QByteArray &ba)
|
QSharedPointer<PreviewResultPdf> PreviewResultPdf::deserialize(QByteArray &ba)
|
||||||
{
|
{
|
||||||
PreviewResultPdf *result = new PreviewResultPdf();
|
QSharedPointer<PreviewResultPdf> result(new PreviewResultPdf());
|
||||||
PreviewResultType type;
|
PreviewResultType type;
|
||||||
|
|
||||||
QDataStream stream{&ba, QIODevice::ReadOnly};
|
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");
|
throw std::runtime_error("Invalid byte array: Not a pdf preview");
|
||||||
}
|
}
|
||||||
stream >> result->documentPath >> result->page >> result->previewImage;
|
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)
|
QSharedPointer<PreviewResultPlainText> PreviewResultPlainText::deserialize(QByteArray &ba)
|
||||||
{
|
{
|
||||||
PreviewResultPlainText *result = new PreviewResultPlainText();
|
QSharedPointer<PreviewResultPlainText> result(new PreviewResultPlainText());
|
||||||
|
|
||||||
PreviewResultType type;
|
PreviewResultType type;
|
||||||
|
|
||||||
QDataStream stream{&ba, QIODevice::ReadOnly};
|
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");
|
throw std::runtime_error("Invalid byte array: Not a pdf preview");
|
||||||
}
|
}
|
||||||
stream >> result->documentPath >> result->page >> result->text;
|
stream >> result->documentPath >> result->page >> result->text;
|
||||||
return QSharedPointer<PreviewResultPlainText>(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user