[SailfishDevel] Destructor of an QObject-derived class not executed

Marcin Mielniczuk marmistrz at inboxalias.com
Thu Sep 5 17:00:13 UTC 2013


Hi,

I'm creating an app with Sailfish Silica. My code looks like that.
settings.h:

> class Settings : public QSettings{
>     Q_OBJECT
>     /**/public:
>     explicit Settings() : QSettings("Marcin Mielniczuk", "BigText") {}
>     ~Settings() { qDebug() << "Dying"; }
>
>     /**/};
>
>
main.cpp

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();}
>
> main.qml

> import QtQuick 2.0import Sailfish.Silica 1.0import BigText 1.0import "pages"
> ApplicationWindow{
>     initialPage: MainPage { }
>     Settings {id: settings}}
>
> I added the qDebug stuff to the destructor to make sure it is called. When
using the main.qml as above, there's no destructor output. But as soon as I
change ApplicationWindow to Item (implies removing stuff not compatible
with Item). There's no problem with the destructor not executed. The output
is printed as it should be. What am I doing wrong? Thanks

Regards,
--
Marcin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20130905/acc240bd/attachment.html>


More information about the Devel mailing list