Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NaN and Infinity issue with gr.arc and gr. modify #267

Open
olimaticer opened this issue Jan 22, 2019 · 1 comment
Open

NaN and Infinity issue with gr.arc and gr. modify #267

olimaticer opened this issue Jan 22, 2019 · 1 comment

Comments

@olimaticer
Copy link
Contributor

No description provided.

@olimaticer
Copy link
Contributor Author

olimaticer commented Jan 22, 2019

Normally NaN and Infinity values should be ignored by default, but on some devices (Android 6) these values trigger crashes in conjunction with arcs.

Solutions:

` private boolean execute_gr_arc() {
GR.BDraw b = createGrObj_start(GR.Type.Arc); // create Graphic Object and get variable
if (b == null) return false;
Var.Val saveVal = mVal;

	if (!isNext(',')) return false;
	int[] ltrb = getArgs4I();
	if (ltrb == null) return false;

	if (!isNext(',')) return false;
	//Double[] angles = getArgsDD();
	//if (angles == null) return false;
	// vv 2018-12-25gt
	if (!evalNumericExpression()) return false;					// get angle
	if (EvalNumericExpressionValue.isNaN())return RunTimeError("Start angle is Not a Number (NaN)");
	if (EvalNumericExpressionValue.isInfinite())return RunTimeError("Start angle is infinite");
	float startAngle = EvalNumericExpressionValue.floatValue();
	if (!isNext(','))				{ return false; }
	if (!evalNumericExpression()) return false;					// get angle
	if (EvalNumericExpressionValue.isNaN())return RunTimeError("Sweep angle is Not a Number (NaN)");
	if (EvalNumericExpressionValue.isInfinite())return RunTimeError("Sweep angle is infinite");
	float sweepAngle = EvalNumericExpressionValue.floatValue();
	// ^^ 2018-12-25gt

	if (!isNext(',') || !evalNumericExpression()) return false;
	int fillMode = EvalNumericExpressionValue.intValue();

	//b.arc(ltrb, (float)angles[0], (float)angles[1], fillMode);
	b.arc(ltrb, startAngle, sweepAngle, fillMode);// 2018-12-25gt

	return createGrObj_finish(b, saveVal);						// store the object and return its index
}

`

` private boolean execute_gr_modify() {
int obj = getObjectNumber("Object Number out of range");
if (obj < 0) return false;
GR.BDraw b = DisplayList.get(obj); // get the object to change
GR.Type type = b.type();

	while (isNext(',')) {
		if (!getStringArg()) return false;						// get the parameter string
		if (!isNext(',')) return false;
		String parm = StringConstant;

		String sVal = "";
		int iVal = 0;
		float fVal = 0.0f;
		if (parm.equals("text")|| parm.toLowerCase().equals("_text")) { // Also to lower case 2017-07-15gt
			if (!getStringArg()) return false;					// get the parameter string
			sVal = StringConstant;
		} else {
			if (!evalNumericExpression()) return false;			// get parameter value
			// vv 2018-12-25gt
			if (EvalNumericExpressionValue.isNaN())return RunTimeError("An numeric argument is Not a Number (NaN)");
			if (EvalNumericExpressionValue.isInfinite())return RunTimeError("An numeric argument is infinite");
			b.angle(EvalNumericExpressionValue.floatValue());
			// ^^ 2018-12-25gt
			fVal = EvalNumericExpressionValue.floatValue();
			iVal = EvalNumericExpressionValue.intValue();
		}

.......
........
`

Gregor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant