[TD] Fix win file spec backslash (fix #16646) (#16689)

* [TD]add method to clean win filespecs

- '\' in strings passed to Python as filespecs is interpreted as
  an escape of the following character.
- replace '\' with '/'

* [TD]remove '\' from filespecs before use
This commit is contained in:
WandererFan
2024-09-23 11:40:05 -04:00
committed by GitHub
parent 1ce5fca06b
commit c9beae7ef3
8 changed files with 58 additions and 20 deletions

View File

@@ -48,6 +48,7 @@
using namespace Gui;
using namespace TechDraw;
using namespace TechDrawGui;
using DU = DrawUtil;
//ctor for creation
TaskHatch::TaskHatch(TechDraw::DrawViewPart* inDvp, std::vector<std::string> subs) :
@@ -208,9 +209,11 @@ void TaskHatch::createHatch()
m_hatch = static_cast<TechDraw::DrawHatch *>(doc->getObject(FeatName.c_str()));
m_hatch->Source.setValue(m_dvp, m_subs);
auto filespec = Base::Tools::toStdString(ui->fcFile->fileName());
filespec = DU::cleanFilespecBackslash(filespec);
Command::doCommand(Command::Doc, "App.activeDocument().%s.HatchPattern = '%s'",
FeatName.c_str(),
Base::Tools::toStdString(ui->fcFile->fileName()).c_str());
filespec.c_str());
//view provider properties
Gui::ViewProvider* vp = Gui::Application::Instance->getDocument(doc)->getViewProvider(m_hatch);
@@ -236,9 +239,11 @@ void TaskHatch::updateHatch()
Command::openCommand(QT_TRANSLATE_NOOP("Command", "Update Hatch"));
auto filespec = Base::Tools::toStdString(ui->fcFile->fileName());
filespec = DU::cleanFilespecBackslash(filespec);
Command::doCommand(Command::Doc, "App.activeDocument().%s.HatchPattern = '%s'",
FeatName.c_str(),
Base::Tools::toStdString(ui->fcFile->fileName()).c_str());
filespec.c_str());
App::Color ac;
ac.setValue<QColor>(ui->ccColor->color());