diff options
author | Marius Kintel <marius@kintel.net> | 2013-05-30 20:51:00 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-06-06 00:30:48 (GMT) |
commit | 6b16a0f8916c08201353faa8cd116e22b421dc3f (patch) | |
tree | 1a7c1782142763ec406de5eff5d23f5ea6b0fc52 | |
parent | 3bb22f9c53b0e0d21ec5845f4b5279f37edb27f3 (diff) |
Related to #181, also ignore removal of the main file when auto-reloading
Conflicts:
testdata/modulecache-tests/README.txt
testdata/modulecache-tests/cascade2.sh
-rw-r--r-- | src/mainwin.cc | 5 | ||||
-rw-r--r-- | testdata/modulecache-tests/README.txt | 32 | ||||
-rwxr-xr-x | testdata/modulecache-tests/cascade.sh | 3 | ||||
-rwxr-xr-x | testdata/modulecache-tests/cascade2.sh | 12 | ||||
-rw-r--r-- | testdata/modulecache-tests/cascadetest.scad | 9 |
5 files changed, 37 insertions, 24 deletions
diff --git a/src/mainwin.cc b/src/mainwin.cc index b4c1ed5..785aec6 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1027,7 +1027,10 @@ bool MainWindow::fileChangedOnDisk() if (!this->fileName.isEmpty()) { struct stat st; memset(&st, 0, sizeof(struct stat)); - stat(this->fileName.toLocal8Bit(), &st); + bool valid = (stat(this->fileName.toLocal8Bit(), &st) == 0); + // If file isn't there, just return and use current editor text + if (!valid) return false; + std::string newid = str(boost::format("%x.%x") % st.st_mtime % st.st_size); if (newid != this->autoReloadId) { diff --git a/testdata/modulecache-tests/README.txt b/testdata/modulecache-tests/README.txt index a46e3d3..214acc5 100644 --- a/testdata/modulecache-tests/README.txt +++ b/testdata/modulecache-tests/README.txt @@ -26,13 +26,6 @@ o Open use-mcad.scad o Compile (F5) o Check that you get a rounded box -Test4: USE Non-existing file ------- - -o Open usenonexsistingfile.scad -o Compile (F5) -o Verify that you get: WARNING: Can't open 'use' file 'nofile.scad'. - Test5: Overload USEd module ------ @@ -86,8 +79,11 @@ o Open includemissing.scad o Compile (F5) o Verify that you get: WARNING: Can't open include file 'missing.scad'. o echo "module missing() { sphere(10); }" > missing.scad +o Reload and Compile (F4) - verify that the sphere appeared o rm missing.scad -o Reload and Compile (F4) - verify that the sphere is gone +o Reload and Compile (F4) - verify that the sphere is still there +o echo "module missing() { sphere(20); }" > missing.scad +o Reload and Compile (F4) - verify that the sphere increased in size Test12: Missing include file in subpath appears ------ @@ -96,25 +92,35 @@ o Open includemissingsub.scad o Compile (F5) o Verify that you get: WARNING: Can't open include file 'subdir/missingsub.scad'. o echo "module missingsub() { sphere(10); }" > subdir/missingsub.scad +o Reload and Compile (F4) - verify that the sphere appeared o rm subdir/missingsub.scad -o Reload and Compile (F4) - verify that the sphere is gone +o Reload and Compile (F4) - verify that the sphere is still there +o echo "module missingsub() { sphere(20); }" > subdir/missingsub.scad +o Reload and Compile (F4) - verify that the sphere increased in size Test13: Missing library file appears ------- o rm missing.scad o Open usemissing.scad o Compile (F5) -o Verify that you get: WARNING: Can't open 'use' file 'missing.scad'. +o Verify that you get: WARNING: Can't open library file 'missing.scad'. o echo "module missing() { sphere(10); }" > missing.scad +o Reload and Compile (F4) - verify that the sphere appeared o rm missing.scad -o Compile (F5) - verify that the sphere is gone +o Reload and Compile (F4) - verify that the sphere is still there +o echo "module missing() { sphere(20); }" > missing.scad +o Reload and Compile (F4) - verify that the sphere increased in size Test14: Automatic reload of cascading changes ------- -o rm cascade-*.scad +o ./cascade.sh o Open cascadetest.scad o Turn on Automatic Reload and Compile o Verify that the 4 objects render correctly -o ./cascade.sh +o rm cascadetest.scad +o Verify that no rerendering was triggered (the 4 objects are still there) +o rm cascade*.scad +o Verify that no rerendering was triggered (the 4 objects are still there) +o ./cascade2.sh o Verify that everything reloads at once without flickering diff --git a/testdata/modulecache-tests/cascade.sh b/testdata/modulecache-tests/cascade.sh index 6f15c7f..5dd0ef7 100755 --- a/testdata/modulecache-tests/cascade.sh +++ b/testdata/modulecache-tests/cascade.sh @@ -1,6 +1,7 @@ #!/bin/bash -rm cascade-*.scad +rm cascade*.scad +echo "include <cascade-A.scad> include <cascade-B.scad> use <cascade-C.scad> use <cascade-D.scad> A(); translate([11,0,0]) B(); translate([22,0,0]) C(); translate([33,0,0]) D();" > cascadetest.scad sleep 0.05 echo "module A() { sphere(5); }" > cascade-A.scad sleep 0.05 diff --git a/testdata/modulecache-tests/cascade2.sh b/testdata/modulecache-tests/cascade2.sh new file mode 100755 index 0000000..50f98e0 --- /dev/null +++ b/testdata/modulecache-tests/cascade2.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +rm cascade-*.scad +echo "include <cascade-A.scad> include <cascade-B.scad> use <cascade-C.scad> use <cascade-D.scad> A(); translate([11,0,0]) B(); translate([22,0,0]) C(); translate([33,0,0]) D();" > cascadetest.scad +sleep 0.1 +echo "module A() { sphere(6); }" > cascade-A.scad +sleep 0.1 +echo "module B() { cube([10,10,10], center=true); }" > cascade-B.scad +sleep 0.1 +echo "module C() { cylinder(h=10, r=6, center=true); }" > cascade-C.scad +sleep 0.1 +echo "module D() { cylinder(h=12, r1=6, r2=0, center=true); }" > cascade-D.scad diff --git a/testdata/modulecache-tests/cascadetest.scad b/testdata/modulecache-tests/cascadetest.scad deleted file mode 100644 index 5cce652..0000000 --- a/testdata/modulecache-tests/cascadetest.scad +++ /dev/null @@ -1,9 +0,0 @@ -include <cascade-A.scad> -include <cascade-B.scad> -use <cascade-C.scad> -use <cascade-D.scad> - -A(); -translate([11,0,0]) B(); -translate([22,0,0]) C(); -translate([33,0,0]) D(); |