Skip to content
Permalink
Browse files

when saving scorefile always use tmp file

  • Loading branch information...
wschweer committed Nov 24, 2015
1 parent b45c2fc commit 067b5af84dd08da0b8bc676727730b965e338740
Showing with 28 additions and 44 deletions.
  1. +28 −43 libmscore/scorefile.cpp
  2. +0 −1 mscore/musescore.cpp
@@ -355,26 +355,6 @@ bool Score::saveFile()
MScore::lastError = tr("The following file is locked: \n%1 \n\nTry saving to a different location.").arg(info.filePath());
return false;
}

// if file was already saved in this session
// save but don't overwrite backup again

if (saved()) {
try {
if (suffix == "mscx")
saveFile(info);
else
saveCompressedFile(info, false);
}
catch (QString s) {
MScore::lastError = s;
return false;
}
undo()->setClean();
info.refresh();
update();
return true;
}
//
// step 1
// save into temporary file to prevent partially overwriting
@@ -404,31 +384,36 @@ bool Score::saveFile()
}
temp.close();

//
// step 2
// remove old backup file if exists
//
QDir dir(info.path());
QString backupName = QString(".") + info.fileName() + QString(",");
if (dir.exists(backupName)) {
if (!dir.remove(backupName)) {
// if (!MScore::noGui)
// QMessageBox::critical(0, tr("MuseScore: Save File"),
// tr("Removing old backup file ") + backupName + tr(" failed"));
QString name(info.filePath());
if (!saved()) {
// if file was already saved in this session
// save but don't overwrite backup again

//
// step 2
// remove old backup file if exists
//
QDir dir(info.path());
QString backupName = QString(".") + info.fileName() + QString(",");
if (dir.exists(backupName)) {
if (!dir.remove(backupName)) {
// if (!MScore::noGui)
// QMessageBox::critical(0, tr("MuseScore: Save File"),
// tr("Removing old backup file ") + backupName + tr(" failed"));
}
}
}

//
// step 3
// rename old file into backup
//
QString name(info.filePath());
if (dir.exists(name)) {
if (!dir.rename(name, backupName)) {
// if (!MScore::noGui)
// QMessageBox::critical(0, tr("MuseScore: Save File"),
// tr("Renaming old file <")
// + name + tr("> to backup <") + backupName + tr("> failed"));
//
// step 3
// rename old file into backup
//
if (dir.exists(name)) {
if (!dir.rename(name, backupName)) {
// if (!MScore::noGui)
// QMessageBox::critical(0, tr("MuseScore: Save File"),
// tr("Renaming old file <")
// + name + tr("> to backup <") + backupName + tr("> failed"));
}
}
}
#ifdef Q_OS_WIN
@@ -538,7 +538,6 @@ MuseScore::MuseScore()
fileTools->addSeparator();
mag = new MagBox;
connect(mag, SIGNAL(magChanged(MagIdx)), SLOT(magChanged(MagIdx)));
connect(mag, SIGNAL(magTextChanged()), SLOT(magTextChanged()));
fileTools->addWidget(mag);
viewModeCombo = new QComboBox(this);
#if defined(Q_OS_MAC)

0 comments on commit 067b5af

Please sign in to comment.
You can’t perform that action at this time.