@@ -43,7 +43,7 @@ void RackScrollWidget::step() { | |||||
math::Rect scrollBox = moduleBox; | math::Rect scrollBox = moduleBox; | ||||
scrollBox.pos = scrollBox.pos.mult(zoom); | scrollBox.pos = scrollBox.pos.mult(zoom); | ||||
scrollBox.size = scrollBox.size.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. | // 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; | math::Rect viewportBox; | ||||
@@ -81,16 +81,17 @@ void PatchManager::save(std::string path) { | |||||
json_decref(rootJ); | 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) { | if (!file) { | ||||
// Fail silently | // Fail silently | ||||
return; | return; | ||||
} | } | ||||
DEFER({ | |||||
std::fclose(file); | |||||
}); | |||||
json_dumpf(rootJ, file, JSON_INDENT(2) | JSON_REAL_PRECISION(9)); | 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() { | void PatchManager::saveDialog() { | ||||