diff --git a/src/app/RackScrollWidget.cpp b/src/app/RackScrollWidget.cpp index 63728a71..cc7808cd 100644 --- a/src/app/RackScrollWidget.cpp +++ b/src/app/RackScrollWidget.cpp @@ -43,7 +43,7 @@ void RackScrollWidget::step() { math::Rect scrollBox = moduleBox; scrollBox.pos = scrollBox.pos.mult(zoom); scrollBox.size = scrollBox.size.mult(zoom); - scrollBox = scrollBox.grow(box.size.div(2)); + scrollBox = scrollBox.grow(box.size.mult(0.6666)); // Expand to the current viewport box so that moving modules (and thus changing the module bounding box) doesn't clamp the scroll offset. math::Rect viewportBox; diff --git a/src/patch.cpp b/src/patch.cpp index f6cc9b81..fc0eda6a 100644 --- a/src/patch.cpp +++ b/src/patch.cpp @@ -81,16 +81,17 @@ void PatchManager::save(std::string path) { json_decref(rootJ); }); - FILE *file = std::fopen(path.c_str(), "w"); + // Write to temporary path and then rename it to the correct path + std::string tmpPath = path + ".tmp"; + FILE *file = std::fopen(tmpPath.c_str(), "w"); if (!file) { // Fail silently return; } - DEFER({ - std::fclose(file); - }); json_dumpf(rootJ, file, JSON_INDENT(2) | JSON_REAL_PRECISION(9)); + std::fclose(file); + std::rename(tmpPath.c_str(), path.c_str()); } void PatchManager::saveDialog() {