Skip to content

Graphics crash under Windows #6

Open
@vicuna

Description

@vicuna

Original bug ID: 7419
Reporter: Anax
Assigned to: @dra27
Status: assigned (set by @dra27 on 2016-11-22T15:49:09Z)
Resolution: open
Priority: normal
Severity: minor
Platform: Winodws
OS: Windows 10
Version: 4.02.3
Category: platform support (windows, cross-compilation, etc)
Monitored by: @gasche

Bug description

In class, we did some exercices on trees, and in the fil the teacher gave us, there were a function to trace trees (the fact that it is tree is not important).
I don't really know the module graphics.cma, but when I use it to trace a forest here, the forest is tarced, but when I when to close the windows with the space bar (there is the code let _ = read_key() in close_graph() at the end of the function) it crashes I have to launch again ocaml.
I use Windows 10 on my computer, and a friend of mine as the same problem on his Windows. At school, we use ubuntu and it works.

Steps to reproduce

As I don't really know how really works the graphics module, I give you the caml function :

let rec trace_arbre_binaire t (xmin, xmax, ymin, ymax) h =
	match t with
	| Vide -> ()
	| Noeud_Binaire (x, t1, t2) ->
			let dy = (ymax - ymin) / h in
			let xm = (xmin + xmax) / 2 in
			let s = string_of_int x in
			moveto (xm - (10 * String.length s) / 2)  ymax;
			set_color green;
			draw_string s;
			let dx = (xmax - xmin) / 2 in
			set_color yellow;
			if t1 <> Vide then (
				moveto xm (ymax - 5);
				lineto (xmin + dx / 2) (ymax - dy + 15);
			);
			if t2 <> Vide then (
				moveto xm (ymax - 5);
				lineto (xmin + dx / 2 + dx) (ymax - dy + 15);
			);
			trace_arbre_binaire t1 (xmin, xm, ymin, ymax - dy) (h - 1);
			trace_arbre_binaire t2 (xm, xmax, ymin, ymax - dy) (h - 1)

let voir_arbre_binaire t =
	let nx = 800
	and ny = 600 in
	open_graph (" " ^ (string_of_int nx) ^ "x" ^ (string_of_int ny));
	set_color black;
	fill_rect 0 0 nx ny;
	let k = 50 in
	trace_arbre_binaire t (k,nx - k,k,ny - k) (hauteur_arbre_binaire t);
	let _ = read_key() in close_graph();;

where the type 'a arbre is

type 'a arbre_binaire =
|  Vide
|  Noeud_Binaire of 'a * 'a arbre_binaire * 'a arbre_binaire

Additional information

(I'm a French student, so I apologize for my apporxiamtive English)

File attachments

Metadata

Metadata

Assignees

Labels

mantisIssues imported from Mantis (i.e. old...)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions