From 77ee35a9bd24e66f031faea03c6814d55d5bbe0b Mon Sep 17 00:00:00 2001 From: wandererfan Date: Thu, 6 Feb 2020 20:10:11 -0500 Subject: [PATCH] [TD]fix hatch file not found message --- src/Mod/TechDraw/App/DrawViewSection.cpp | 41 +++++++++++++++--------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 589c2b81f8..79eb1bda6b 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -195,14 +195,20 @@ void DrawViewSection::onChanged(const App::Property* prop) if ((prop == &FileHatchPattern) && (doc != nullptr) ) { if (!FileHatchPattern.isEmpty()) { - replaceSvgIncluded(FileHatchPattern.getValue()); + Base::FileInfo fi(FileHatchPattern.getValue()); + if (fi.isReadable()) { + replaceSvgIncluded(FileHatchPattern.getValue()); + } } } if ( (prop == &FileGeomPattern) && (doc != nullptr) ) { if (!FileGeomPattern.isEmpty()) { - replacePatIncluded(FileGeomPattern.getValue()); + Base::FileInfo fi(FileGeomPattern.getValue()); + if (fi.isReadable()) { + replacePatIncluded(FileGeomPattern.getValue()); + } } } } @@ -213,19 +219,24 @@ void DrawViewSection::onChanged(const App::Property* prop) std::string fileSpec = FileGeomPattern.getValue(); Base::FileInfo fi(fileSpec); std::string ext = fi.extension(); - if ( (ext == "pat") || - (ext == "PAT") ) { - if ((!fileSpec.empty()) && - (!NameGeomPattern.isEmpty())) { - std::vector specs = - DrawGeomHatch::getDecodedSpecsFromFile(fileSpec, - NameGeomPattern.getValue()); - m_lineSets.clear(); - for (auto& hl: specs) { - //hl.dump("hl from section"); - LineSet ls; - ls.setPATLineSpec(hl); - m_lineSets.push_back(ls); + if (!fi.isReadable()) { + Base::Console().Message("%s can not read hatch file: %s\n", getNameInDocument(), fileSpec.c_str()); + Base::Console().Message("%s using included hatch file.\n", getNameInDocument()); + } else { + if ( (ext == "pat") || + (ext == "PAT") ) { + if ((!fileSpec.empty()) && + (!NameGeomPattern.isEmpty())) { + std::vector specs = + DrawGeomHatch::getDecodedSpecsFromFile(fileSpec, + NameGeomPattern.getValue()); + m_lineSets.clear(); + for (auto& hl: specs) { + //hl.dump("hl from section"); + LineSet ls; + ls.setPATLineSpec(hl); + m_lineSets.push_back(ls); + } } } }