wangqr / Aegisub

Win64 nightly builds available at GHA artifact, also at following link:
https://ftp.wangqr.tk/aegisub/
Other
799 stars 49 forks source link

how to execute "wxGetApp().NewProjectContext();" in child thread? #53

Closed glegender closed 4 years ago

glegender commented 4 years ago

i want to execute "wxGetApp().NewProjectContext();" in child thread,but I tried a lot of things and they didn't work,What should I do?

wangqr commented 4 years ago

What are you trying to achieve?

glegender commented 4 years ago

What are you trying to achieve

I want to execute "automation/lua/kara-templater/Apply karaoke template" in batches on the linux server,I've done part of it

glegender commented 4 years ago

What are you trying to achieve? grpc server execute the following steps 1,open ass file 2,execute "automation/lua/kara-templater/Apply karaoke template"

wangqr commented 4 years ago

Unfortunately wxWidgets is a GUI library. And just like most GUI library, they must be called from main thread, because main thread is the only thread that can make UI changes. The standard way of informing main thread to do certain thing is using Events. You need to define a custom event, add a handler to the main event loop, and send event. See https://docs.wxwidgets.org/trunk/overview_events.html

Although if you just want to do batch process, I would recommend using AutoHotKey instead of modifying the C++ code. That should take less effort.

I'm not sure why you want to use this on Linux server. But aegisub is a GUI application, it will not work on a headless environment without display. Either you need a standard Xorg display output, or you'll need to set up a VNC.

glegender commented 4 years ago

Unfortunately wxWidgets is a GUI library. And just like most GUI library, they must be called from main thread, because main thread is the only thread that can make UI changes. The standard way of informing main thread to do certain thing is using Events. You need to define a custom event, add a handler to the main event loop, and send event. See https://docs.wxwidgets.org/trunk/overview_events.html

Although if you just want to do batch process, I would recommend using AutoHotKey instead of modifying the C++ code. That should take less effort.

I'm not sure why you want to use this on Linux server. But aegisub is a GUI application, it will not work on a headless environment without display. Either you need a standard Xorg display output, or you'll need to set up a VNC.

We want to lower the barrier to entry for users who choose templates to create beautiful subtitle(我们想降低用户的使用门槛,用户选择模板就可以制作出好看的字幕)

wangqr commented 4 years ago

I'm not sure how that works.

User still need to do timing for each line or karaoke point manually. Pasting some predefined comment lines and then clicking "Apply karaoke template" as an extra step isn't that hard compared to the manual timing part. You can even wrap these 2 steps together with a lua script, let user choose the predefined template from a GUI list ctrl or a dropdown menu, and provide extra knobs for certain parameters if needed.

On the other hand, if you are planning to provide "Apply template as a Service" via some website where users can upload ass and it will automatically apply certain template. I suggest you use libaegisub directly, without the GUI. Although some GUI functions in the lua aegisub module, like progress reporting ones, are defined in Aegisub (src/auto4_*) itself, and you may need to provide a dummy implementation to make the script at least work.

glegender commented 4 years ago

I'm not sure how that works.

User still need to do timing for each line or karaoke point manually. Pasting some predefined comment lines and then clicking "Apply karaoke template" as an extra step isn't that hard compared to the manual timing part. You can even wrap these 2 steps together with a lua script, let user choose the predefined template from a GUI list ctrl or a dropdown menu, and provide extra knobs for certain parameters if needed.

On the other hand, if you are planning to provide "Apply template as a Service" via some website where users can upload ass and it will automatically apply certain template. I suggest you use libaegisub directly, without the GUI. Although some GUI functions in the lua aegisub module, like progress reporting ones, are defined in Aegisub (src/auto4_*) itself, and you may need to provide a dummy implementation to make the script at least work.

good idea,but how to create "lua_State"?

glegender commented 4 years ago

now ”lua_Statue“ is init in GUI