Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Program crash when I combine Loader and ProgressBar

Program crash when I combine Loader and ProgressBar

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #1

    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.1

    main.qml
    @
    import QtQuick 2.1
    import QtQuick.Controls 1.0
    import QtQuick.Dialogs 1.0
    import QtQuick.Layouts 1.0

    import Test 1.0

    ApplicationWindow{
    id: root

    title: "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?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chrisadams
      wrote on last edited by
      #2

      Please post a backtrace / stacktrace of the crash, from your debugger.

      Cheers,
      Chris.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stereomatching
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • C Offline
          C Offline
          chrisadams
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            stereomatching
            wrote on last edited by
            #5

            Filed it already, thanks for your help.
            Hope that Qt5 could become more stable with every release

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved