Wings 3D Development Forum
Erlang Run Time Errors - Printable Version

+- Wings 3D Development Forum (https://www.wings3d.com/forum)
+-- Forum: Wings 3D (https://www.wings3d.com/forum/forumdisplay.php?fid=1)
+--- Forum: Programming (https://www.wings3d.com/forum/forumdisplay.php?fid=7)
+--- Thread: Erlang Run Time Errors (/showthread.php?tid=2421)



Erlang Run Time Errors - oort - 03-02-2017

Starting a thread with questions about how to read Run Time errors.

I am back to playing with converting the Stereoscopic patch to a plugin.

Still working with Wings 1.4.1, since that was where I had already started.

How do we read the information in the error that is generated?

I get an undef error, which is described as follows: "The function cannot be found when evaluating a function call."

How do we know which function is the problem and what does the rest of the information in the report mean? See report below.

Thanks,
oort

Quote:wpc_stereoscopic:command/3: bad return value: {'EXIT',
{undef,
[{wings,geom_title,[{geom,2}]},
{wpc_stereoscopic,
new_viewer,6},
{wpc_stereoscopic,
new_viewer_stereo,1},
{wpc_stereoscopic,command,2},
{wings_develop,time_command,
2},
{wings_plugin,command,3},
{wings,raw_command_1,3},
{wings,raw_command,4}]}}



RE: Erlang Run Time Errors - micheus - 03-02-2017

The command in our plugins usually returns the St - if is is changed or not, keep, next or another 'event' - a tuple that can be processed by the main event handler that will result in another command be call.

I may be a little wrong about the correct options. I'm away from my PC.

I see you are managing a command that calls new_viewer_stereo which calls new_viewer that seems to end up by returning a tuple {wings,geom_title,[{geom,2}]} which I think it's a Geometry window 'id'.
Surely it's not a expect value to be returned to the main event handler.


RE: Erlang Run Time Errors - oort - 03-03-2017

Micheus,
Thanks for the response.

Yes, I think {wings,geom_title,[{geom,2}]} is supposed to define a new geometry window id number that is one higher than any existing windows.

I think new_viewer is supposed to create a geometry window.

This is all code I am hacking from the original patch created by someone else... Sad

Which item are you saying is causing the undef error?

"Surely it's not a expect value to be returned to the main event handler."
Not sure what you are saying. Still just a hacker... Smile Sad

Here is the part of the code that is supposed to create two geometry windows, in case it helps???

Quote:new_viewer_stereo(St) ->
{Pos,{W,H}} = wings_wm:win_rect(desktop),
Size = {W div 2-40,H div 2-40},
N = free_viewer_num(2),
Active = wings_wm:this(),
Props = wings_wm:get_props(Active),
ToolbarHidden = wings_wm:is_hidden({toolbar,Active}),
Name = {geom,N},
new_viewer(Name, Pos, Size, Props, ToolbarHidden, St),
% second window
N2 = free_viewer_num(2),
Name2 = {geom,N2},
{X2,Y2} = Pos,
new_viewer(Name2, {X2+element(1,Size),Y2}, Size, Props, ToolbarHidden, St),
% now link
stereo_link(Name,Name2).

Thanks,
oort


RE: Erlang Run Time Errors - micheus - 03-03-2017

(03-03-2017, 12:23 AM)oort Wrote: "Surely it's not a expect value to be returned to the main event handler."
Not sure what you are saying. Still just a hacker... Smile Sad

Here is the part of the code that is supposed to create two geometry windows, in case it helps???
oort, sorry for making things confuse to you.
I could look better the problem and the code. The return value in 'command' isn't the problem in this case. By checking this code fragment from the original coder I saw that he already took care of that, so you probably didn't touched that:
Code:
+command_1({window,geom_viewer_stereo}, St) ->
+    new_viewer_stereo(St),
+    keep;
Just in case, as I told in the previous post, there are some specific "values" expected to be returned among those I enumerate you find the other in the wings.erl:command_response/3


Ok, back to your problem...
(03-03-2017, 12:23 AM)oort Wrote: Yes, I think {wings,geom_title,[{geom,2}]} is supposed to define a new geometry window id number that is one higher than any existing windows.

I think new_viewer is supposed to create a geometry window.
Yes, you are right.

Let's read the message from the top of the stack of the error dump:
bad return value:
{'EXIT', {undef,
[{wings,geom_title,[{geom,2}]},
{wpc_stereoscopic,new_viewer,6},


the function new_viewer/6 into wpc_stereoscopic module tried to call the function geom_title into wings module with the parameter [{geom,2}] (list of one parameter), but this function is undefined.

I took a look at the source and the function is really in wings.erl module, but it isn't exported. That is why it's crashing.

what you can do is to copy it to your plugin source:
Quote:geom_title(geom) ->
?__(1,"Geometry");
geom_title({geom,N}) ->
?__(2,"Geometry #") ++ integer_to_list(N).

and in the function new_viewer you remove the module name prefixing the function call (that actually is wings).


RE: Erlang Run Time Errors - oort - 03-03-2017

Micheus,
Thanks! That got rid of that error... Smile

So, the first item listed after the undef error (geom_title in this example) will be the part that is undefined. That makes sense...

What do the numbers that are listed in the error report mean?


It looks like I need to fix "toplevel" in the same way. I think I should be able to fix that now... See the code below:

Thanks,
oort

Quote:wpc_stereoscopic:command/3: bad return value: {'EXIT',
{undef,
[{wings,toplevel,
[{geom,2},
"Geometry #2",
{0,0,highest},
{600,429},
[resizable,closable,
{anchor,nw},
{toolbar,
#Fun<wpc_stereoscopic.0.13891985>},
menubar,{...}]]},
{wpc_stereoscopic,
new_viewer,6},
{wpc_stereoscopic,
new_viewer_stereo,1},
{wpc_stereoscopic,command,2},
{wings_develop,time_command,
2},
{wings_plugin,command,3},
{wings,raw_command_1,3},
{wings,raw_command,4}]}}



RE: Erlang Run Time Errors - micheus - 03-03-2017

(03-03-2017, 05:08 PM)oort Wrote: What do the numbers that are listed in the error report mean?
oort, each tuple in the dump stack list means: {<module name>, <function name>, <param count for the function>}, except for the first tuple (on top) in which the 3rd item isn't the param count, but the parameters it self - the ones used when the crash happened.

I removed the line breaks to make easy to see them:
Quote:[Image: dump-detail_zps2c995967.png]
In this case, if the crashes had happened in another function called in toplevel function, instead of the list of parameters you was going to see the number 5 ({wpc_stereoscopic, toplevel, 5}).

Quote:It looks like I need to fix "toplevel" in the same way. I think I should be able to fix that now...
Yes (twice Smile)


RE: Erlang Run Time Errors - oort - 03-04-2017

Micheus,
Thanks for the additional information. That helps...

Unfortunately finding the right code to fix the problem with "toplevel" isn't as easy as I thought it would be. I have tried several things but can't get it right.

The code which includes "toplevel" is listed below. No hurry in you looking at this, since I probably won't be able to get back to it till next week... Sad

Thanks,
oort

Quote:%% wings.erl missing stuff added start 2-28-17
new_viewer(St) ->
{Pos,{W,H}} = wings_wm:win_rect(desktop),
Size = {W div 2-40,H div 2-40},
N = free_viewer_num(2),
Active = wings_wm:this(),
Props = wings_wm:get_props(Active),
ToolbarHidden = wings_wm:is_hidden({toolbar,Active}),
Name = {geom,N},
new_viewer(Name, Pos, Size, Props, ToolbarHidden, St).

new_viewer(Name, {X,Y}, Size, Props, ToolbarHidden, St) ->
%% Op = wings:main_loop_noredraw(St),
Title = geom_title(Name),
wings_wm:toplevel(Name, Title, {X,Y,highest}, Size,
[resizable,closable,{anchor,nw},
{toolbar,fun(A, B, C) ->
wings_toolbar:create(A, B, C)
end},
menubar,
%% {properties,Props}],
{properties,Props}]
),
%% Op),

wings_wm:menubar(Name, get(wings_menu_template)),
wings_wmConfusedend({menubar,Name}, {current_state,St}),
wings_wmConfusedend({toolbar,Name}, {current_state,St}),
wingsConfusedet_drag_filter(Name),
if
ToolbarHidden -> wings_wm:hide({toolbar,Name});
true -> ok
end,
Name.
%% wings.erl missing stuff added end 2-28-17



RE: Erlang Run Time Errors - oort - 03-11-2017

I forced myself to learn a little bit about Erlang. The following site was a big help.... Learn You Some Erlang

I am happy to report that I have made some progress with this. The good news is that I am able to get the two geometry windows to open. The bad news is that I had to cheat to get there. I added
Quote:-export([new_viewer/6]).
to the wings.erl module and added
Quote:-import(wings, [new_viewer/6]).
to my stereoscopic.erl module.

I need to figure out the right code for the new_viewer function in order to get it to work without cheating...

I am getting compile errors when I try to get that function working in my plugin. Next week I plan to start a new thread on Erlang Compile Errors, in hopes of figuring it out... Smile

oort


RE: Erlang Run Time Errors - micheus - 03-11-2017

Sorry oort. I forgot completely about your previous post. Blush
Nice to know you got some progress.


RE: Erlang Run Time Errors - oort - 03-11-2017

Micheus,
No problem... Smile I saw in your other posts that you lost your system and are working on restoring it. Sorry you have to go through that... Sad

oort