mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 16:19:21 +02:00
* pas2jni: Fixed invoking of Java event handlers from non-main threads.
git-svn-id: trunk@34309 -
This commit is contained in:
parent
57c1338aa1
commit
3b8db21c2c
@ -1265,6 +1265,7 @@ begin
|
|||||||
Fps.WriteLn('var');
|
Fps.WriteLn('var');
|
||||||
Fps.IncI;
|
Fps.IncI;
|
||||||
Fps.WriteLn('_env: PJNIEnv;');
|
Fps.WriteLn('_env: PJNIEnv;');
|
||||||
|
Fps.WriteLn('_new_env: boolean;');
|
||||||
Fps.WriteLn('_mpi: _TMethodPtrInfo;');
|
Fps.WriteLn('_mpi: _TMethodPtrInfo;');
|
||||||
if d.Count > 0 then begin
|
if d.Count > 0 then begin
|
||||||
Fps.WriteLn(Format('_args: array[0..%d] of jvalue;', [d.Count - 1]));
|
Fps.WriteLn(Format('_args: array[0..%d] of jvalue;', [d.Count - 1]));
|
||||||
@ -1281,6 +1282,8 @@ begin
|
|||||||
Fps.WriteLn('begin');
|
Fps.WriteLn('begin');
|
||||||
Fps.IncI;
|
Fps.IncI;
|
||||||
Fps.WriteLn('CurJavaVM^^.GetEnv(CurJavaVM, @_env, JNI_VERSION_1_6);');
|
Fps.WriteLn('CurJavaVM^^.GetEnv(CurJavaVM, @_env, JNI_VERSION_1_6);');
|
||||||
|
Fps.WriteLn('_new_env:=_env = nil;');
|
||||||
|
Fps.WriteLn('if _new_env then CurJavaVM^^.AttachCurrentThread(CurJavaVM, @_env, nil);');
|
||||||
Fps.WriteLn('_env^^.PushLocalFrame(_env, 100);');
|
Fps.WriteLn('_env^^.PushLocalFrame(_env, 100);');
|
||||||
Fps.WriteLn('try');
|
Fps.WriteLn('try');
|
||||||
Fps.IncI;
|
Fps.IncI;
|
||||||
@ -1347,6 +1350,7 @@ begin
|
|||||||
Fps.DecI;
|
Fps.DecI;
|
||||||
Fps.WriteLn('finally');
|
Fps.WriteLn('finally');
|
||||||
Fps.WriteLn('_env^^.PopLocalFrame(_env, nil);', 1);
|
Fps.WriteLn('_env^^.PopLocalFrame(_env, nil);', 1);
|
||||||
|
Fps.WriteLn('if _new_env then CurJavaVM^^.DetachCurrentThread(CurJavaVM);', 1);
|
||||||
Fps.WriteLn('end;');
|
Fps.WriteLn('end;');
|
||||||
Fps.DecI;
|
Fps.DecI;
|
||||||
Fps.WriteLn('end;');
|
Fps.WriteLn('end;');
|
||||||
|
Loading…
Reference in New Issue
Block a user