larpon / QtFirebase

An effort to bring Google's Firebase C++ API to Qt + QML
MIT License
284 stars 83 forks source link

QML When import QtFirebase, app crashes #119

Closed AriosJentu closed 4 years ago

AriosJentu commented 5 years ago

Hi. I don't know whats happening, because I haven't any information how to correct connect QtFirebase to mine project. I've put mine directories for QtFirebase and Firebase CPP SDK, and with them, I have worked project QtFirebaseExample, but when I'm importing QtFirebase in my LoginView.qml, Ive got crash with error 255. What happening? Debug says only that LoginView component not found, but compiling works correct. And when I comment line with import QtFirebase, application run successfully.

larpon commented 5 years ago

Could be a lot of things. Is your LoginView.qml loaded dynamically? (I.e. via Loader { ... } or Qt.createQmlObject() or similar?

Complete setup instructions for custom projects are available here

larpon commented 5 years ago

... and if LoginView.qml can't be found I guess you need to get Qt to find it somehow ... maybe you didn't include it in your project qrc ?

AriosJentu commented 5 years ago

... and if LoginView.qml can't be found I guess you need to get Qt to find it somehow ... maybe you didn't include it in your project qrc ?

This view shows, when there is no import QtFirebase, it shows all widgets inside on screen. But when I import your module, I've got all what I've wrote on top. LoginView shows inside StackView, it's component creates in main.qml. Of course, I was done all work for project based on complete setup for custom project, but I don't know what's wrong I've done.

larpon commented 5 years ago

Try placing the import in a .qml file that follow your app's native life-cycle (like in main.qml and see if that helps. The C++ SDK we rely on is hard to control when it comes to dynamic loads - I've made it so you can load and unload modules but we use a singleton to keep a global reference and I suspect that this should follow the natural app life-cycle

AriosJentu commented 5 years ago

Try placing the import in a .qml file that follow your app's native life-cycle (like in main.qml and see if that helps.

No, that's also doesn't work. I put import QtFirebase 1.0 to main.qml, and it's also breaking. I think this problem in importing library, maybe in .pro file, but I check, I've done everything with project file, what wrote in docs.

larpon commented 5 years ago

Hmm... people have reported other issues with the 6.2 SDK - maybe try 6.1 and see if that helps? (Google Firebase C++ SDK)

AriosJentu commented 5 years ago

I'm already use 6.1, since previuos "issue".

larpon commented 5 years ago

Hi @AriosJentu - I've tried to compile your project and it seem you have it configured to be built as a library? While it should be possible to compile QtFirebase as a part of a lib you should be aware that QtFirebase can't auto register it's QML types in this case as it uses Q_COREAPP_STARTUP_FUNCTION (More on that macro here ) to do the auto registering of QML types - that's probably why your import doesn't work.

You need to register the QtFirebase types you need manually then - in your "Main" application i.e the one that has TEMPLATE = app in it's .pro - maybe it's worth a shot?

... or you could try and add QtFirebase as part of the main application instead as this will trigger the auto registering

AriosJentu commented 5 years ago

Thank you, I'll test it, when it can be possible for me.