From e2f8ea2809e8026f35a8e5e5d9b14b49c0f1e32f Mon Sep 17 00:00:00 2001 From: bubnikv Date: Mon, 13 Feb 2017 12:36:46 +0100 Subject: [PATCH] When renaming the exported G-code (removing the .tmp suffix), some other application (thank you, Windows Explorer) may keep the file locked. Try to wait a bit and then rename the file again. --- lib/Slic3r/Print.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 7fc2bdd86..e2b328474 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -419,7 +419,13 @@ sub write_gcode { close $fh; if ($tempfile) { - rename $tempfile, $file; + my $i; + for ($i = 0; $i < 5; $i += 1) { + last if (rename $tempfile, $file); + # Wait for 1/4 seconds and try to rename once again. + select(undef, undef, undef, 0.25); + } + Slic3r::debugf "Faild t remove the output G-code file from $tempfile to $file. Is $tempfile locked?\n" if ($i == 5); } }