qt - C++ type's destructor not called in QML -
i create sailfish app (using latest sailfish sdk). have problem exposing c++ object qml. inherits qsettings,
class settings : public qsettings { q_object /**/ public: explicit settings() : qsettings("marcin mielniczuk", "bigtext") {} ~settings() { qdebug() << "dying"; } /**/ };
i noticed destructor isn't called @ all. (there's not destructor output)
i create object that:
import qtquick 2.0 import sailfish.silica 1.0 import bigtext 1.0 import "pages" applicationwindow { initialpage: mainpage { } settings {id: settings} }
my main.cpp is:
q_decl_export int main(int argc, char *argv[]) { qscopedpointer<qguiapplication> app(sailfish::createapplication(argc, argv)); qmlregistertype<settings>("bigtext", 1, 0, "settings"); qscopedpointer<qquickview> view(sailfish::createview("main.qml")); sailfish::showview(view.data()); return app->exec(); }
what doing wrong?
/edit: text not being printed isn't actual problem - it's indicator of problem. qsettings sycing in destructor doesn't work too.
edit2: please note, applicationwindow in i'm using sailfish silica, not qtquick.controls, , window shown ok. these components must different stock qt quick components.
there's nothing inherently wrong logic. here simplified version of it. can run locally, , consistently dying message on output every time window closed , application terminates.
if cannot figure out, suggest transforming code you're doing until fails.
by way, surely snippet of larger you're doing, @ least far example goes, these scoped pointers aren't doing much.
main.qml
import qtquick 2.0 import bigtext 1.0 item { width: 300; height: 300 settings {id: settings} }
main.cpp
class settings : public qsettings { q_object public: settings() : qsettings("marcin mielniczuk", "bigtext") {} ~settings() { qdebug() << "dying"; } }; int main(int argc, char *argv[]) { qscopedpointer<qguiapplication> app(new qguiapplication(argc, argv)); qmlregistertype<settings>("bigtext", 1, 0, "settings"); qscopedpointer<qquickview> view(new qquickview()); view->setsource(qurl::fromlocalfile("main.qml")); view->show(); return app->exec(); }
Comments
Post a Comment