[Gambas-user] [Gambas Bug Tracker] Bug #893: Variables become Null after "Unable to load class file" error?
bugtracker at ...3416...
bugtracker at ...3416...
Thu Feb 4 19:05:56 CET 2016
http://gambaswiki.org/bugtracker/edit?object=BUG.893&from=L21haW4-
Tobias BOEGE reported a new bug.
Summary
-------
Variables become Null after "Unable to load class file" error?
Type : Bug
Priority : Medium
Gambas version : 3.8.90 (TRUNK)
Product : Unknown
Description
-----------
Hi Benoit,
I hit a bug again, approximately this[0] level of weirdness; it's actually
the same project, this time apparently not related to Settings, but again
deep down in the interpreter.
The bug works as follows: I have a library which depends on gb.image(.io) to
load and save images. It contains a line such as
Try hImage = Image.Load(...)
in one of its modules. Now I use this library in a project which does *not*
have gb.image(.io) ticked. Apparently when the library is loaded, its
dependencies gb.image(.io) are *not* automatically loaded, too. It so
happens that the above line would fail (if I omit the Try) with an error:
Cannot load class 'Image': Unable to load class file
but the Try maskes this error away. I find this strange to begin with.
Shouldn't the library's dependencies be loaded, too, even if they are not
explicit dependencies of the project?
But the actual error shows itself a little later. After this failed Try
statement, if you only have a deep enough function call stack, variables in
non-exported modules magically become Null. (If the module is exported, the
variables retain their values.)
I attach two projects which demonstrate this behaviour (at least on my
system and I have just compiled Gambas from scratch after completely
uninstalling it). The one, "image-lib" is the library. You compile it and
install it with the new library mechanism, then open the other project,
"image-test", and add the library there. The main code is
Public Sub Main()
MyModule.Init("xyz") ' Initialise a variable in a non-exported module
Module1.Init() ' Raise the Try'd image class loading error
Debug MyModule.Str ' Show that the variable is still good
MyOther.Test(100) ' Show the variable after 100 recursive calls, where it is somehow Null
End
yields
Main.Main.6: xyz
MyOther.Test.5:
Regards,
Tobi
[0] http://sourceforge.net/p/gambas/mailman/message/34523004/
More information about the User
mailing list