5
votes

I have project on QML 2 (Qt 5.2.1). It seems works fine.

But when I close running project (ALT+F4, or whatever) in Qt Creator's "Application Output" (that thing at the bottom), after 1-2 sec, I get the following message:

The program has unexpectedly finished.
bla-bla-bla.exe crashed

This happens in release and debug modes. I Launched under debug, but not got any errors. I follow step-by-step from my last destructor till the very return app.exec();, which return 1.

I mean except this - I don't see any errors. Should I worry about this? Can I know a reason for this message? Is there a way to get more specific message?


I tried to launch application from cmd, but not get any errors. My main.cpp:

#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"
#include "painter.h"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    qmlRegisterType<Painter>("MyCanvas", 1, 0, "MyCanvas");

    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile(QStringLiteral("qml/test_painteditem/main.qml"));
    viewer.showExpanded();    

    return app.exec();
}

Main.qml:

import QtQuick 2.0
import MyCanvas 1.0

Rectangle {
    width: 360
    height: 360
    color: "white";
     focus: true;
    Keys.onLeftPressed: {
            mc.frame--;
            mc.update();
    }
    Keys.onRightPressed: {
            mc.frame++;
            mc.update();
    }
    Keys.onPressed: {
        if (event.key === Qt.Key_C){
             mc.switchCurve();
        }else if (event.key === Qt.Key_O){
            mc.switchCurveOffset();
       }    
   }

   MouseArea {
        anchors.fill: parent
        onClicked: {
            // mc.x += 10;
            //mc.update();
            if (!tim.running){
                tim.start();
            } else {
                tim.stop();
            }
        }
        onWheel: {
                if (wheel.angleDelta.y > 0)
                    mc.zoomIn();
                else
                    mc.zoomOut();
        }
        onPressed: {    
        }
    }

    Timer {
        id:tim
        interval: 1; running: false; repeat: true
        onTriggered:  {    
            mc.frame++;
            mc.update();
        }
    }    

    MyCanvas {
        id:mc;
        x:0;
        y:0;
        width:1000;         /** 2000x2000 not supported in Android  */
        height:1000;
    }
}
1
And what do you want we do without any code and any specific error message? - Jepessen
I would worry if I see that in my program :) - BЈовић
I can't put there code of my project, but maybe there is a way to get more specific error message? Because that message that I showed is the only one I see. - tower120
Debug your program until you find the error. When exec is called the Qt part of your program start. Set some breakpoint and try to localize the point in which crashes. - Jepessen
Make a copy of your project, compile it, see if you still get the error. If so, try commenting out as much of your code as possible so that you get a very small program which still produces that error. Once you have that, share the whole source code of that problematic program so we can figure out a solution much more easily. - Tim Meyer

1 Answers

2
votes

There is a app.quit() method you could call or connect to, when exiting your Qt application. Apart from that a return value of 1 might not what Qt creator is expecting. You want a return value equal to EXIT_SUCCESS (or 0).