plcopen/instances_path.xslt
author |
Andrey Skvortsov <andrej.skvortzov@gmail.com> |
|
Tue, 26 Jun 2018 17:34:15 +0300 |
changeset 2229 |
3c94bac4526e |
parent 1949 |
c266fbaae0f6
|
child 2626 |
39d78c530cbb |
permissions |
-rw-r--r-- |
Fix 'DoGetTextExtent - invalid DC' error
most likely this error happens only on certain wx backends.
GTK3+ on GNU/Linux is apparently one of them.
The problem is described in wxWidgets issue tracker.
http://trac.wxwidgets.org/ticket/12486
[-------------------------------------------------------------------------------------------------------------------]
platform:
Linux-4.16.0-2-rt-amd64-x86_64-with-debian-buster-sid
python-version:
2.7.15
traceback:
File "/home/developer/WorkData/PLC/beremiz/beremiz/ProjectController.py", line 1605, in DispatchDebugValuesProc
self.CallWeakcallables("__tick__", "NewDataAvailable", debug_ticks)
File "/home/developer/WorkData/PLC/beremiz/beremiz/ProjectController.py", line 1585, in CallWeakcallables
function(*cargs)
File "/home/developer/WorkData/PLC/beremiz/beremiz/editors/Viewer.py", line 1217, in NewDataAvailable
refresh_rect.Union(element.GetRedrawRect())
File "/home/developer/WorkData/PLC/beremiz/beremiz/graphics/GraphicCommons.py", line 1609, in GetRedrawRect
self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue)
File "/home/developer/WorkData/PLC/beremiz/beremiz/editors/Viewer.py", line 932, in GetMiniTextExtent
return self.MiniTextDC.GetTextExtent(text)
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk3/wx/_gdi.py", line 4127, in GetTextExtent
return _gdi_.DC_GetTextExtent(*args, **kwargs)
<class 'wx._core.PyAssertionError'>: C++ assertion "m_graphicContext" failed at ../src/common/dcgraph.cpp(1160) in DoGetTextExtent(): wxGCDC(cg)::DoGetTextExtent - invalid DC
wx-platform:
__WXGTK__
wx-version:
3.0.2.0
[-------------------------------------------------------------------------------------------------------------------]
traceback:
File "/home/developer/WorkData/PLC/beremiz/beremiz/controls/LogViewer.py", line 740, in OnMessageToolTipTimer
self.MessageToolTip.SetFont(self.Font)
File "/home/developer/WorkData/PLC/beremiz/beremiz/controls/CustomToolTip.py", line 75, in SetFont
self.RefreshTip()
File "/home/developer/WorkData/PLC/beremiz/beremiz/controls/CustomToolTip.py", line 158, in RefreshTip
self.SetClientSize(self.GetToolTipSize())
File "/home/developer/WorkData/PLC/beremiz/beremiz/controls/CustomToolTip.py", line 145, in GetToolTipSize
w, h = dc.GetTextExtent(line)
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk3/wx/_gdi.py", line 4127, in GetTextExtent
return _gdi_.DC_GetTextExtent(*args, **kwargs)
<class 'wx._core.PyAssertionError'>: C++ assertion "m_graphicContext" failed at ../src/common/dcgraph.cpp(1160) in DoGetTextExtent(): wxGCDC(cg)::DoGetTextExtent - invalid DC
[-------------------------------------------------------------------------------------------------------------------]
<?xml version="1.0"?>
<xsl:stylesheet xmlns:exsl="http://exslt.org/common" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:ppx="http://www.plcopen.org/xml/tc6_0201" xmlns:ns="beremiz" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" extension-element-prefixes="ns" version="1.0" exclude-result-prefixes="ns">
<xsl:output method="xml"/>
<xsl:param name="instance_type"/>
<xsl:template match="text()"/>
<xsl:variable name="project" select="ns:GetProject()"/>
<xsl:variable name="stdlib" select="ns:GetStdLibs()"/>
<xsl:variable name="extensions" select="ns:GetExtensions()"/>
<xsl:variable name="all_types" select="($project | $stdlib | $extensions)/ppx:types"/>
<xsl:template match="ppx:project">
<xsl:apply-templates select="ppx:instances/ppx:configurations/ppx:configuration"/>
</xsl:template>
<xsl:template match="ppx:configuration">
<xsl:apply-templates select="ppx:globalVars/ppx:variable[ppx:type/ppx:derived] | ppx:resource">
<xsl:with-param name="parent_path">
<xsl:value-of select="@name"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="ppx:resource">
<xsl:param name="parent_path"/>
<xsl:variable name="resource_path">
<xsl:value-of select="$parent_path"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:apply-templates select="ppx:globalVars/ppx:variable[ppx:type/ppx:derived] | ppx:pouInstance | ppx:task/ppx:pouInstance">
<xsl:with-param name="parent_path">
<xsl:value-of select="$resource_path"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="ppx:pouInstance">
<xsl:param name="parent_path"/>
<xsl:variable name="pou_instance_path">
<xsl:value-of select="$parent_path"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="@typeName=$instance_type">
<xsl:value-of select="ns:AddInstance($pou_instance_path)"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="type_name">
<xsl:value-of select="@typeName"/>
</xsl:variable>
<xsl:apply-templates select="$all_types/ppx:pous/ppx:pou[@name=$type_name] | $all_types/ppx:dataTypes/ppx:dataType[@name=$type_name]">
<xsl:with-param name="instance_path">
<xsl:value-of select="$pou_instance_path"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="ppx:pou">
<xsl:param name="instance_path"/>
<xsl:apply-templates select="ppx:interface/*/ppx:variable[ppx:type/ppx:derived]">
<xsl:with-param name="parent_path">
<xsl:value-of select="$instance_path"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="ppx:dataType">
<xsl:param name="instance_path"/>
<xsl:apply-templates select="ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]">
<xsl:with-param name="parent_path">
<xsl:value-of select="$instance_path"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="ppx:variable">
<xsl:param name="parent_path"/>
<xsl:variable name="variable_path">
<xsl:value-of select="$parent_path"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:apply-templates select="ppx:type/ppx:derived">
<xsl:with-param name="variable_path">
<xsl:value-of select="$variable_path"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="ppx:derived">
<xsl:param name="variable_path"/>
<xsl:choose>
<xsl:when test="@name=$instance_type">
<xsl:value-of select="ns:AddInstance($variable_path)"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="type_name">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:apply-templates select="$all_types/ppx:pous/ppx:pou[@name=$type_name] | $all_types/ppx:dataTypes/ppx:dataType[@name=$type_name]">
<xsl:with-param name="instance_path">
<xsl:value-of select="$variable_path"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="ppx:struct">
<xsl:param name="variable_path"/>
<xsl:for-each select="ppx:variable[ppx:type/ppx:derived or ppx:type/ppx:struct or ppx:type/ppx:array]">
<xsl:variable name="element_path">
<xsl:value-of select="$variable_path"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="@name"/>
</xsl:variable>
</xsl:for-each>
<xsl:apply-templates select="ppx:type/*[self::ppx:derived or self::ppx:struct or self::ppx:array]">
<xsl:with-param name="variable_path">
<xsl:value-of select="$element_path"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="ppx:array">
<xsl:param name="variable_path"/>
<xsl:apply-templates select="ppx:baseType/*[self::ppx:derived or self::ppx:struct or self::ppx:array]">
<xsl:with-param name="variable_path">
<xsl:value-of select="$variable_path"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>