Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ERROR: AV's and IWButton.picture.data: the parameter is incorrect
#39
(02-09-2020, 10:28 AM)MrSpock Wrote: That needs more explanation.

I have some variables declared as session variables but almost all of them are declared in the implementation part of the unit. For example I create bmp: TBitmap in form onCreate and remove it in form onDestroy. I expect the bmp variable to be different for each user. All forms, while creating them, should, as I expect, belong to the user's session. So the bmp should be independent for each user connected at the same time to a different session. But now I see the same variable is shared between users, which should not happen. When I use
TIWForm1.Create(WebApplication).Show
in fact user2 gets the same implementation part variables as user1 has got. User1 sees variables of user2 and vice versa!!

But moving a number of variables from many forms to usersession unit does not make sense, does it? This way intraweb is of no use to me.

As I explained in another thread yesterday, no global variables are safe even if declared in Implementation section. The fact that it is not "visible" outside the scope of the unit doesn't make it safe because multiple instances of the same session will share the same variable.

Global variables are *evil*. Even more in multi-threaded apps.

This has nothing to to with "Intraweb". That's how memory management works. No Delphi, Free Pascal or C or C++ global variable will *ever* be automatically thread safe doesn't matter what you do. You can use plain WebBroker applications made with Delphi and you will find the same "issue" (which is no issue at all, i.e. that's how compilers and memory managers work and has always been).
Not even in C# you will get that (although you don't have global variables like in Delphi, the concept is the same and there is no "automatic" management like this).
Reply


Messages In This Thread
RE: ERROR: AV's and IWButton.picture.data: the parameter is incorrect - by Alexandre Machado - 02-12-2020, 10:31 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)