Exception thrown when using Phonon::VideoWidget / Phonon::MediaObject



  • I am trying to use the Phonon::VideoWidget and the Phonon::MediaObject together, as it is suggested in the documentation ("http://doc.qt.nokia.com/4.7/phonon-videowidget.html#details":http://doc.qt.nokia.com/4.7/phonon-videowidget.html#details).
    Basically, when using a Phonon::VideoPlayer component, everything works fine, but when using those 2 components, an unhandled exception is thrown when closing the window.

    It seems like the destruction of the Phonon::Path between the 2 objects crashes.
    When I checked in the Phonon::VideoPlayer source code, I did not see anything magic, and I am actually wondering if the Phonon::VideoPlayer class does not contain the same kind of trouble that we could not see because the encapsulated objects would not be properly destroyed before the application closes.

    As I am not sure to be totally clear or exhaustive, a code snippet is worth a thousand words:

    Test.h
    @#ifndef TEST_H_
    #define TEST_H_

    #include <QGraphicsProxyWidget>
    #include <Phonon/VideoPlayer>
    #include <Phonon/MediaObject>
    #include <Phonon/VideoWidget>

    class Test : public QGraphicsProxyWidget
    {
    Q_OBJECT

    public:
    Test(QGraphicsItem *parent = 0)
    : QGraphicsProxyWidget(parent)
    {
    // --------------
    // Works properly
    Phonon::VideoPlayer *player = new Phonon::VideoPlayer();
    player->mediaObject()->setCurrentSource(Phonon::MediaSource("trailer_400p.ogg"));
    player->mediaObject()->play();
    setWidget(player);
    // --------------

        // --------------------
        // Crashes when closing
        Phonon::MediaObject *media = new Phonon::MediaObject();
        Phonon::VideoWidget *vwidget = new Phonon::VideoWidget();
        Phonon::createPath(media, vwidget);
        media->setCurrentSource(Phonon::MediaSource("trailer_400p.ogg"));
        media->play();
        setWidget(vwidget);
        // --------------------
    }
    

    };

    #endif /* TEST_H_ */@

    main.cpp
    @#include <QApplication>
    #include <QGraphicsScene>
    #include <QGraphicsView>

    #include "Test.h"

    int main(int argc, char **argv)
    {
    QApplication app(argc, argv);

    QGraphicsScene *scene = new QGraphicsScene();
    QGraphicsView *gv = new QGraphicsView();
    gv->setScene(scene);
    
    Test *test = new Test();
    scene->addItem(test);
    test->resize(1280, 720);
    gv->show();
    
    return app.exec();
    

    }@

    Oh, just to precise things:

    • I've tried many different versions of this code, deleting the pointers in the destructor, connecting the deleteLater() slot on the destroyed() signals of the dynamically created objects, ... nothing changed!
    • the class inherits QGraphicsProxyWidget in order to be used as a QML widget afterwards.

    Is there a bug in the Qt implementation of Phonon? Or did I miss something important?
    Can anybody help me solving this please...

    Thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.