Adding error handling for function argument errors.
This commit is contained in:
parent
75e70903f1
commit
35ce1c4824
9 changed files with 112 additions and 3 deletions
|
@ -1046,6 +1046,14 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Ausdruck analysiert: %3</translation>
|
Ausdruck analysiert: %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1066,6 +1074,11 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Ausdruck analysiert: %3</translation>
|
Ausdruck analysiert: %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -1046,6 +1046,14 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Evaluated expression: %3</translation>
|
Evaluated expression: %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1066,6 +1074,11 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Evaluated expression: %3</translation>
|
Evaluated expression: %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -991,6 +991,14 @@ These settings can be changed at any time from the "Settings" menu.</s
|
||||||
Evaluated expression: %3</source>
|
Evaluated expression: %3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1008,6 +1016,11 @@ Evaluated expression: %3</source>
|
||||||
Evaluated expression: %3</source>
|
Evaluated expression: %3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -1055,6 +1055,14 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Formule analysée : %3</translation>
|
Formule analysée : %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1075,6 +1083,11 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Formule analysée : %3</translation>
|
Formule analysée : %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -1046,6 +1046,14 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Kiértékelt kifejezés: %3</translation>
|
Kiértékelt kifejezés: %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1066,6 +1074,11 @@ Evaluated expression: %3</source>
|
||||||
|
|
||||||
Kiértékelt kifejezés: %3</translation>
|
Kiértékelt kifejezés: %3</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -1043,6 +1043,14 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen.</tr
|
||||||
Evaluated expression: %3</source>
|
Evaluated expression: %3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1060,6 +1068,11 @@ Evaluated expression: %3</source>
|
||||||
Evaluated expression: %3</source>
|
Evaluated expression: %3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -991,6 +991,14 @@ These settings can be changed at any time from the "Settings" menu.</s
|
||||||
Evaluated expression: %3</source>
|
Evaluated expression: %3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="179"/>
|
||||||
|
<source>Error while attempting to draw %1 %2:
|
||||||
|
%3
|
||||||
|
|
||||||
|
Undoing last change.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>expression</name>
|
<name>expression</name>
|
||||||
|
@ -1008,6 +1016,11 @@ Evaluated expression: %3</source>
|
||||||
Evaluated expression: %3</source>
|
Evaluated expression: %3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../qml/eu/ad5001/LogarithmPlotter/LogGraphCanvas.qml" line="176"/>
|
||||||
|
<source>LogarithmPlotter - Drawing error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>function</name>
|
<name>function</name>
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
import Qt.labs.platform as Native
|
||||||
import "js/objects.js" as Objects
|
import "js/objects.js" as Objects
|
||||||
import "js/utils.js" as Utils
|
import "js/utils.js" as Utils
|
||||||
import "js/mathlib.js" as MathLib
|
import "js/mathlib.js" as MathLib
|
||||||
|
@ -170,6 +171,16 @@ Canvas {
|
||||||
|
|
||||||
Component.onCompleted: imageLoaders = {}
|
Component.onCompleted: imageLoaders = {}
|
||||||
|
|
||||||
|
Native.MessageDialog {
|
||||||
|
id: drawingErrorDialog
|
||||||
|
title: qsTranslate("expression", "LogarithmPlotter - Drawing error")
|
||||||
|
text: ""
|
||||||
|
function showDialog(objType, objName, error) {
|
||||||
|
text = qsTranslate("error", "Error while attempting to draw %1 %2:\n%3\n\nUndoing last change.").arg(objType).arg(objName).arg(error)
|
||||||
|
open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onPaint: function(rect) {
|
onPaint: function(rect) {
|
||||||
//console.log('Redrawing')
|
//console.log('Redrawing')
|
||||||
if(rect.width == canvas.width) { // Redraw full canvas
|
if(rect.width == canvas.width) { // Redraw full canvas
|
||||||
|
@ -183,7 +194,14 @@ Canvas {
|
||||||
for(var obj of Objects.currentObjects[objType]){
|
for(var obj of Objects.currentObjects[objType]){
|
||||||
ctx.strokeStyle = obj.color
|
ctx.strokeStyle = obj.color
|
||||||
ctx.fillStyle = obj.color
|
ctx.fillStyle = obj.color
|
||||||
if(obj.visible) obj.draw(canvas, ctx)
|
if(obj.visible)
|
||||||
|
try {
|
||||||
|
obj.draw(canvas, ctx)
|
||||||
|
} catch(e) {
|
||||||
|
// Drawing throws an error. Generally, it's due to a new modification (or the opening of a file)
|
||||||
|
drawingErrorDialog.showDialog(objType, obj.name, e.message)
|
||||||
|
history.undo()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.lineWidth = 1
|
ctx.lineWidth = 1
|
||||||
|
|
Loading…
Reference in a new issue