do not create thumbnail when autosave

This commit is contained in:
Werner Schweer 2017-06-02 11:21:01 +02:00
parent f80caadfe8
commit 4cd48850a3
3 changed files with 15 additions and 13 deletions

View file

@ -738,7 +738,7 @@ class Score : public QObject, ScoreElement {
bool saveFile(QFileInfo& info); bool saveFile(QFileInfo& info);
bool saveFile(QIODevice* f, bool msczFormat, bool onlySelection = false); bool saveFile(QIODevice* f, bool msczFormat, bool onlySelection = false);
bool saveCompressedFile(QFileInfo&, bool onlySelection); bool saveCompressedFile(QFileInfo&, bool onlySelection);
bool saveCompressedFile(QIODevice*, QFileInfo&, bool onlySelection); bool saveCompressedFile(QIODevice*, QFileInfo&, bool onlySelection, bool createThumbnail = true);
bool exportFile(); bool exportFile();
void print(QPainter* printer, int page); void print(QPainter* printer, int page);

View file

@ -526,7 +526,7 @@ QImage Score::createThumbnail()
// file is already opened // file is already opened
//--------------------------------------------------------- //---------------------------------------------------------
bool Score::saveCompressedFile(QIODevice* f, QFileInfo& info, bool onlySelection) bool Score::saveCompressedFile(QIODevice* f, QFileInfo& info, bool onlySelection, bool doCreateThumbnail)
{ {
MQZipWriter uz(f); MQZipWriter uz(f);
@ -539,7 +539,7 @@ bool Score::saveCompressedFile(QIODevice* f, QFileInfo& info, bool onlySelection
xml.stag("rootfiles"); xml.stag("rootfiles");
xml.stag(QString("rootfile full-path=\"%1\"").arg(XmlWriter::xmlString(fn))); xml.stag(QString("rootfile full-path=\"%1\"").arg(XmlWriter::xmlString(fn)));
xml.etag(); xml.etag();
foreach(ImageStoreItem* ip, imageStore) { for (ImageStoreItem* ip : imageStore) {
if (!ip->isUsed(this)) if (!ip->isUsed(this))
continue; continue;
QString path = QString("Pictures/") + ip->hashName(); QString path = QString("Pictures/") + ip->hashName();
@ -562,15 +562,17 @@ bool Score::saveCompressedFile(QIODevice* f, QFileInfo& info, bool onlySelection
} }
// create thumbnail // create thumbnail
QImage pm = createThumbnail(); if (doCreateThumbnail) {
QImage pm = createThumbnail();
QByteArray ba; QByteArray ba;
QBuffer b(&ba); QBuffer b(&ba);
if (!b.open(QIODevice::WriteOnly)) if (!b.open(QIODevice::WriteOnly))
qDebug("open buffer failed"); qDebug("open buffer failed");
if (!pm.save(&b, "PNG")) if (!pm.save(&b, "PNG"))
qDebug("save failed"); qDebug("save failed");
uz.addFile("Thumbnails/thumbnail.png", ba); uz.addFile("Thumbnails/thumbnail.png", ba);
}
#ifdef OMR #ifdef OMR
// //

View file

@ -3870,7 +3870,7 @@ void MuseScore::removeSessionFile()
void MuseScore::autoSaveTimerTimeout() void MuseScore::autoSaveTimerTimeout()
{ {
bool sessionChanged = false; bool sessionChanged = false;
foreach (MasterScore* s, scoreList) { for (MasterScore* s : scoreList) {
if (s->autosaveDirty()) { if (s->autosaveDirty()) {
QString tmp = s->tmpName(); QString tmp = s->tmpName();
if (!tmp.isEmpty()) { if (!tmp.isEmpty()) {
@ -3889,7 +3889,7 @@ void MuseScore::autoSaveTimerTimeout()
} }
s->setTmpName(tf.fileName()); s->setTmpName(tf.fileName());
QFileInfo info(tf.fileName()); QFileInfo info(tf.fileName());
s->saveCompressedFile(&tf, info, false); s->saveCompressedFile(&tf, info, false, false); // no thumbnail
tf.close(); tf.close();
sessionChanged = true; sessionChanged = true;
} }