Skip to content
Snippets Groups Projects
Commit 90859b34 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix images embeded in titles incorrect path on extract

parent bdd25855
No related branches found
No related tags found
No related merge requests found
Pipeline #383640 failed with stages
in 10 minutes and 39 seconds
......@@ -74,7 +74,7 @@ void TitleDocument::setScene(QGraphicsScene *_scene, int width, int height)
m_height = height;
}
int TitleDocument::base64ToUrl(QGraphicsItem *item, QDomElement &content, bool embed, const QString &pojectPath)
int TitleDocument::base64ToUrl(QGraphicsItem *item, QDomElement &content, bool embed, const QString &projectPath)
{
if (embed) {
if (!item->data(Qt::UserRole + 1).toString().isEmpty()) {
......@@ -88,10 +88,10 @@ int TitleDocument::base64ToUrl(QGraphicsItem *item, QDomElement &content, bool e
QString base64 = item->data(Qt::UserRole + 1).toString();
if (!base64.isEmpty()) {
QString titlePath;
if (!pojectPath.isEmpty()) {
titlePath = pojectPath;
if (!projectPath.isEmpty()) {
titlePath = projectPath;
} else {
titlePath = QStringLiteral("/tmp/titles");
titlePath = QStringLiteral("/tmp/titles/");
}
QString filename = extractBase64Image(titlePath, base64);
if (!filename.isEmpty()) {
......@@ -109,9 +109,9 @@ int TitleDocument::base64ToUrl(QGraphicsItem *item, QDomElement &content, bool e
// static
const QString TitleDocument::extractBase64Image(const QString &titlePath, const QString &data)
{
QString filename = titlePath + QString(QCryptographicHash::hash(data.toLatin1(), QCryptographicHash::Md5).toHex().append(".titlepart"));
QDir dir;
QDir dir(titlePath);
dir.mkpath(titlePath);
const QString filename = dir.absoluteFilePath(QString(QCryptographicHash::hash(data.toLatin1(), QCryptographicHash::Md5).toHex().append(".titlepart")));
QFile f(filename);
if (f.open(QIODevice::WriteOnly)) {
f.write(QByteArray::fromBase64(data.toLatin1()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment