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(QIODevice* f, bool msczFormat, bool onlySelection = false);
bool saveCompressedFile(QFileInfo&, bool onlySelection);
bool saveCompressedFile(QIODevice*, QFileInfo&, bool onlySelection);
bool saveCompressedFile(QIODevice*, QFileInfo&, bool onlySelection, bool createThumbnail = true);
bool exportFile();
void print(QPainter* printer, int page);

View file

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

View file

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