Program crash when I combine Loader and ProgressBar
-
When I use Loader to load my own component and change the value of the ProgressBar through it
the program always crash;If I don't use Loader to load my own component, the program wouldn't
crash, why?os : mac 10.8.3
compiler: clang3.2
Qt ver : 5.1main.qml
@
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Dialogs 1.0
import QtQuick.Layouts 1.0import Test 1.0
ApplicationWindow{
id: roottitle: "Color Correction" color: syspal.window width: 1450 height: 750 minimumHeight: 750 minimumWidth: 1400 SystemPalette {id: syspal} //with Loader, this version would crash Component{ id: compProgressTest ProgressConnection{ } } Loader{ id: loader sourceComponent: null onStatusChanged: { if(loader.status == Loader.Ready){ console.log("Ready") } } } Row{ anchors.fill: parent Button{ text: "reload" onClicked: { loader.sourceComponent = null loader.sourceComponent = compProgressTest } } Button{ text: "run" onClicked: { if(loader.status == Loader.Ready){ loader.item.addProgressValue() } } } ProgressBar{ id: progressBar maximumValue: loader.status == Loader.Ready ? loader.item.progressMaximum : 1 value: loader.status == Loader.Ready ? loader.item.progressValue : 0 onValueChanged: { console.log("progress bar value = " + progressBar.value) } } } //*/ /* //without Loader, this version wouldn't crash ProgressConnection{ id: progressConnection } Row{ anchors.fill: parent Button{ text: "run" onClicked: { progressConnection.addProgressValue() } } ProgressBar{ id: progressBar maximumValue: progressConnection.progressMaximum value: progressConnection.progressValue onValueChanged: { console.log("progress bar value = " + progressBar.value) } } }//*/
}
@
.hpp
@
#ifndef PROGRESSCONNECTION_HPP
#define PROGRESSCONNECTION_HPP#include <QObject>
class progressConnection : public QObject
{
Q_OBJECT
Q_PROPERTY(int progressMaximum READ progressMaximum WRITE setProgressMaximum NOTIFY progressMaximumChanged)
Q_PROPERTY(int progressValue READ progressValue WRITE setProgressValue NOTIFY progressValueChanged)
public:
explicit progressConnection(QObject *parent = 0);Q_INVOKABLE void addProgressValue(); int progressMaximum() const; int progressValue() const; void setProgressMaximum(int value); void setProgressValue(int value);
signals:
void progressMaximumChanged();
void progressValueChanged();private:
void addProgressValueImpl();private:
int progressMaximum_; int progressValue_; int size_;
};
#endif // PROGRESSCONNECTION_HPP
@
.cpp
@
#include "progressConnection.hpp"progressConnection::progressConnection(QObject *parent) :
QObject(parent),
progressMaximum_(1),
progressValue_(0),
size_(100000)
{
}void progressConnection::addProgressValue()
{
setProgressMaximum(size_);
setProgressValue(0);addProgressValueImpl();
}
int progressConnection::progressMaximum() const
{
return progressMaximum_;
}int progressConnection::progressValue() const
{
return progressValue_;
}void progressConnection::setProgressMaximum(int value)
{
if(value != progressMaximum_){
progressMaximum_ = value;
emit progressMaximumChanged();
}
}void progressConnection::setProgressValue(int value)
{
if(value != progressValue_){
progressValue_ = value;
emit progressValueChanged();
}
}void progressConnection::addProgressValueImpl()
{
for(int i = 0; i != size_; ++i){
setProgressValue(i);
}
}
@What is the problem?
-
Please post a backtrace / stacktrace of the crash, from your debugger.
Cheers,
Chris. -
Sorry, I don't know how to setup a debugger on mac yet, but I could get error messages every times the app
crash. I hope this is what you want"error messages":http://pastebin.com/QkYV9kKR
-
I only looked at it briefly, but that looks like a bug. Please file a bug report on bugreports.qt-project.org with a minimal example and that stacktrace.
Thanks,
Chris. -
Filed it already, thanks for your help.
Hope that Qt5 could become more stable with every release