Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Electron crash when call qt gui #29112

Closed
3 tasks done
HuangDeFa opened this issue May 12, 2021 · 1 comment
Closed
3 tasks done

[Bug]: Electron crash when call qt gui #29112

HuangDeFa opened this issue May 12, 2021 · 1 comment

Comments

@HuangDeFa
Copy link

HuangDeFa commented May 12, 2021

Preflight Checklist

Electron Version

12.0.5

What operating system are you using?

macOS

Operating System Version

macOs Majave 10.14.6

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

I would like to use the ffi-napi to call a dylib that builded by qt , then invoke the lib method should open a dialog(qt gui).

The code like:

JS part
`
const {Library:FFLib} = require('ffi-napi')

const lib = FFLib("resource/vendor/libdyLibDemo.dylib",{
"test":['void',[]],
})
lib.test()
`

QT part

`
#include
#ifdef __cplusplus
extern "C" {
void test(){
char *argv[0] = {};
int argc = 1;
qDebug() << "start checkLib";
QApplication a(argc, argv);
QDialog dl;
dl.setWindowTitle("Test Win");
dl.show();
dl.raise();
dl.exec();
}

#ifdef __cplusplus
}
#endif

`****

Actual Behavior

when use ffi-napi to call the lib method ,the native qt dialog can show but electron seems unresponsive , the menus disappear except the app name and the paste operation can not work for input element , then click the app name in menu bar it will crash or unresponsive

Testcase Gist URL

No response

Additional Information

As I test that , once run ffi-napi to invoke dylib method which in native qt part create QApplication (
the code like
void test(){ QApplication a(argc,argv); }
), in electron main process will make crash.

If someone hit this case , please kindly comment the solution , thanks advance.

@jkleinsc
Copy link
Contributor

Thanks for reaching out!

Given the warning from ffi-napi:
WARNING: node-ffi-napi assumes you know what you're doing. You can pretty easily create situations where you will segfault the interpreter and unless you've got C debugger skills, you probably won't know what's going on., you will probably have better luck with this question at one of the links at the project's Community page -- in particular, be sure to give the Electron Discord server a try.

I hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants