Adding support for more papersizes [fixed]

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Adding support for more papersizes

Post by uwestoehr »

uwestoehr wrote: Sat Jan 23, 2021 10:31 pm I had a look at the ones in
https://wiki.freecadweb.org/Arch_templates
but they are broken.
OK, it took me while to figure out what is causing this: there are several wrong transform statements and also the page size itself is incorrect. The Arch format is normed in its overall size:
https://www.agooddaytoprint.com/page/pa ... -chart-faq

Here is the first fixed file:
Arch_E3_Landscape.svg
(73.39 KiB) Downloaded 53 times
that looks now correct within FC:
FreeCAD_fHDDa2t9Ok.png
FreeCAD_fHDDa2t9Ok.png (19.17 KiB) Viewed 961 times
So I will update the other Arch files and make a PR to include them to FreeCAD.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Adding support for more papersizes

Post by uwestoehr »

uwestoehr wrote: Sat Jan 23, 2021 11:50 pm So I will update the other Arch files and make a PR to include them to FreeCAD.
Here is the PR: https://github.com/FreeCAD/FreeCAD/pull/4309

I also updated all templates in Arch_templates accordingly.
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Adding support for more papersizes

Post by chennes »

uwestoehr wrote: Sun Jan 24, 2021 2:09 am Here is the PR: https://github.com/FreeCAD/FreeCAD/pull/4309
I manually looked at all of your templates and they seemed fine, but I am actually getting an abort() in FC when I try to load them up. Are they loading OK for you?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Adding support for more papersizes

Post by uwestoehr »

chennes wrote: Sun Jan 24, 2021 2:49 am but I am actually getting an abort() in FC when I try to load them up.
What do you mean with abort()? I put them into the Templates folder of TechDraw, then I can create new from template using them. The behave like any other template and the report panels shows no warning, error, not even a note.
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Adding support for more papersizes

Post by chennes »

More details about the crash... right before the abort the Report View shows:

Code: Select all

ASSERT failure in __cdecl QXmlName::QXmlName(class QXmlNamePool &,const class QString &,const class QString &,const clas QString &): "The local name is invalid, maybe the arguments were mixed up?", file api\qxmlname.cpp, line 188
and the backtrace is:

Code: Select all

>	ucrtbased.dll!issue_debug_notification(const wchar_t * const message) Line 28	C++
 	ucrtbased.dll!__acrt_report_runtime_error(const wchar_t * message) Line 154	C++
 	ucrtbased.dll!abort() Line 61	C++
 	FreeCADGui_d.dll!messageHandler(QtMsgType type, const QMessageLogContext & context, const QString & msg) Line 1697	C++
 	[External Code]	
 	TechDraw_d.pyd!QDomNodeModel::name(const QXmlNodeModelIndex & ni) Line 195	C++
 	[External Code]	
 	TechDraw_d.pyd!TechDraw::DrawSVGTemplate::getEditableTextsFromTemplate() Line 315	C++
 	TechDraw_d.pyd!TechDraw::DrawSVGTemplate::onChanged(const App::Property * prop) Line 119	C++
 	FreeCADApp_d.dll!App::Property::hasSetValue() Line 217	C++
 	FreeCADApp_d.dll!App::PropertyString::setValue(const char * newLabel) Line 1462	C++
 	FreeCADApp_d.dll!App::PropertyString::setValue(const std::string & sString) Line 1472	C++
 	FreeCADApp_d.dll!App::PropertyString::setPyObject(_object * value) Line 1508	C++
 	TechDraw_d.pyd!TechDraw::DrawSVGTemplatePy::setCustomAttributes(const char * attr, _object * obj) Line 58	C++
 	TechDraw_d.pyd!TechDraw::DrawSVGTemplatePy::_setattr(const char * attr, _object * value) Line 350	C++
 	FreeCADBase_d.dll!Base::PyObjectBase::__setattro(_object * obj, _object * attro, _object * value) Line 260	C++
 	[External Code]	
 	FreeCADBase_d.dll!Base::InterpreterSingleton::runString(const char * sCmd) Line 268	C++
 	FreeCADGui_d.dll!Gui::Command::_runCommand(const char * file, int line, Gui::Command::DoCmd_Type eType, const char * sCmd) Line 692	C++
 	FreeCADGui_d.dll!Gui::Command::_doCommand(const char * file, int line, Gui::Command::DoCmd_Type eType, const char * sCmd, ...) Line 647	C++
 	TechDrawGui_d.pyd!CmdTechDrawPageTemplate::activated(int iMsg) Line 211	C++
 	FreeCADGui_d.dll!Gui::Command::invoke(int i, Gui::Command::TriggerSource trigger) Line 415	C++
 	FreeCADGui_d.dll!Gui::Action::onActivated() Line 107	C++
 	FreeCADGui_d.dll!Gui::Action::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 75	C++
 	[External Code]	
 	FreeCADGui_d.dll!Gui::GUIApplication::notify(QObject * receiver, QEvent * event) Line 92	C++
 	[External Code]	
 	FreeCADGui_d.dll!Gui::GUIApplication::notify(QObject * receiver, QEvent * event) Line 92	C++
 	[External Code]	
 	FreeCADGui_d.dll!Gui::Application::runApplication() Line 2287	C++
 	FreeCAD_d.exe!main(int argc, char * * argv) Line 302	C++
 	FreeCAD_d.exe!WinMain(HINSTANCE__ * __formal, HINSTANCE__ * __formal, char * __formal, int __formal) Line 97	C++
 	[External Code]	
I am able to load other templates (e.g. the Arch4 template from the original discussion here), so there is something with these specific new templates that is failing.

ETA: For completeness
OS: Windows 10 Version 2004
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.23755 +1 (Git)
Build type: Debug
Branch: pr/4309
Hash: 1fb7242c953b6556b69e31306307306e17e8b8db
Python version: 3.8.6+
Qt version: 5.15.1
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/United States (en_US)
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Adding support for more papersizes

Post by chennes »

I poked at this for a little bit, and the crash is actually in the code that is printing that error message, and the error message will only print if you are in Debug mode. So whatever it is complaining about is some sort of minor error (I presume, if it only complains in debug builds), but then the error handler itself is actually crashing. Oops.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Adding support for more papersizes

Post by chennes »

It turns out that the Qt DOM parser does not like the xml:space="default" attribute on the editable elements: it does not recognize "xml" as a valid namespace, so tries to just create a named element with "xml:space", but that's not a valid NCName (because of the colon).
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
aapo
Posts: 626
Joined: Mon Oct 29, 2018 6:41 pm

Re: Adding support for more papersizes

Post by aapo »

chennes wrote: Sun Jan 24, 2021 4:44 am It turns out that the Qt DOM parser does not like the xml:space="default" attribute on the editable elements: it does not recognize "xml" as a valid namespace, so tries to just create a named element with "xml:space", but that's not a valid NCName (because of the colon).
Great find! I guess we can't fix it, if the problem is in the upstream code. However, I hope you'll be able to fix the crash in FreeCAD debug mode code, or is it something non-trivial?
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Adding support for more papersizes

Post by chennes »

aapo wrote: Sun Jan 24, 2021 11:58 am However, I hope you'll be able to fix the crash in FreeCAD debug mode code, or is it something non-trivial?
Well, it's a deliberately-called abort() -- so I think we have to assume that this error is in that area where letting it slide could result in unpredictable behavior later. Unfortunately, Qt does not maintain that DOM parser anymore and they discourage its use. I don't think it's a good idea to keep that attribute in the XML -- if their parser can't handle it, I suggest removing it. None of the other templates use it, which is why this error is only appearing now. As an alternative, our code could "sanitize" the incoming SVG to remove elements that are going to do this, but I'd guess that's more work than just tweaking these templates (though maybe @uwestoehr would disagree if he's already spent a lot of time on this!).
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Adding support for more papersizes

Post by uwestoehr »

chennes wrote: Sun Jan 24, 2021 3:13 pm if their parser can't handle it, I suggest removing it. None of the other templates use it, which is why this error is only appearing now.
Ehm, no. It should be the opposite. The SVG contains a valid SVG tag in terms of the SVG specs. The files were created with latest Inkscape 1.02 and this automatically adds the xml:space tag. When I delete it and press Save, it will be automatically re-added, even when I save as plain SVG. Note that I already saved the templates as plain SVG, so they don't contain Inkscape-specific overhead but follow plain the SVG specs.

So as for other FreeCAD features, we should stay according to the standards and not make our own home-brewn rules.

(Furthermore the older versions of the templates originated from 2014. Opening them with Inkscape's XML editor show me that there are also the xml:space tag, the only difference is that its content is "preserve" instead of "default".)
Post Reply