Results 1 to 4 of 4

Thread: segfault with adding a QAbstractVideoFilter qml/c++

  1. #1
    Join Date
    Jul 2016
    Posts
    18
    Thanks
    3
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default segfault with adding a QAbstractVideoFilter qml/c++

    I am developing on a desktop as a host and the target is an iMX6 board. The OS for both is Ubuntu. I have ported the qmlvideofx example provided by Qt as a base application. From here, I want to add a QAbstractVideoFilter so that I can access the frames in the QMediaPlayer. I have two kits with this project, the Desktop Qt GCC 64bit (host) and an apalis-imx6 (target).

    .h

    Qt Code:
    1. #ifndef VIDEOFILTERTOSATELLITE_H
    2. #define VIDEOFILTERTOSATELLITE_H
    3.  
    4. #include <QObject>
    5. #include <QAbstractVideoFilter>
    6. #include <QVideoFilterRunnable>
    7. #include <QDebug>
    8. #include <QSize>
    9.  
    10. class VideoFilterToSatellite;
    11.  
    12. class VideoFilterToSatelliteRunnable : public QVideoFilterRunnable
    13. {
    14. public:
    15. VideoFilterToSatelliteRunnable ( VideoFilterToSatellite* parent = 0 );
    16. ~VideoFilterToSatelliteRunnable ();
    17.  
    18. QVideoFrame run ( QVideoFrame *input,
    19. const QVideoSurfaceFormat &surfaceFormat,
    20. RunFlags flags ) Q_DECL_OVERRIDE;
    21. private:
    22. VideoFilterToSatellite* m_filterParent;
    23. };
    24.  
    25. class VideoFilterToSatellite : public QAbstractVideoFilter
    26. {
    27. Q_OBJECT
    28. public:
    29. explicit VideoFilterToSatellite ( QAbstractVideoFilter *parent = 0 );
    30. QVideoFilterRunnable* createFilterRunnable ();
    31. };
    32.  
    33. #endif // VIDEOFILTERTOSATELLITE_H
    To copy to clipboard, switch view to plain text mode 


    .cpp

    Qt Code:
    1. #include "VideoFilterToSatellite.h"
    2.  
    3. VideoFilterToSatellite::VideoFilterToSatellite ( QAbstractVideoFilter *parent )
    4. : QAbstractVideoFilter ( parent ) {}
    5.  
    6. QVideoFilterRunnable* VideoFilterToSatellite::createFilterRunnable ()
    7. {
    8. return reinterpret_cast<QVideoFilterRunnable*>( new VideoFilterToSatelliteRunnable ( this ) );
    9. }
    10.  
    11. VideoFilterToSatelliteRunnable::VideoFilterToSatelliteRunnable ( VideoFilterToSatellite* parent )
    12. : m_filterParent ( parent ) {}
    13.  
    14. VideoFilterToSatelliteRunnable::~VideoFilterToSatelliteRunnable() {}
    15.  
    16. QVideoFrame VideoFilterToSatelliteRunnable::run ( QVideoFrame *input,
    17. const QVideoSurfaceFormat &surfaceFormat,
    18. RunFlags flags )
    19. {
    20. Q_UNUSED ( surfaceFormat );
    21. Q_UNUSED ( flags );
    22.  
    23. if (!input->isValid())
    24. return *input;
    25.  
    26. // future work
    27.  
    28. return *input;
    29. }
    To copy to clipboard, switch view to plain text mode 

    .pro
    Qt Code:
    1. TEMPLATE = app
    2. TARGET = MCS_Host
    3.  
    4. QT += qml quick multimedia network
    5. CONFIG += c++11
    6. CONFIG += qml_debug
    7.  
    8. SOURCES += main.cpp \
    9. filereader.cpp \
    10. NetworkServer.cpp \
    11. NetworkThread.cpp \
    12. VideoFilterToSatellite.cpp
    13.  
    14. RESOURCES += qml.qrc
    15.  
    16. # Additional import path used to resolve QML modules in Qt Creator's code model
    17. QML_IMPORT_PATH =
    18.  
    19. # Default rules for deployment.
    20. qnx: target.path = /tmp/$${TARGET}/bin
    21. else: unix:!android: target.path = /opt/$${TARGET}/bin
    22. !isEmpty(target.path): INSTALLS += target
    23.  
    24. HEADERS += \
    25. filereader.h \
    26. NetworkServer.h \
    27. NetworkThread.h \
    28. trace.h \
    29. VideoFilterToSatellite.h
    To copy to clipboard, switch view to plain text mode 

    main.cpp

    Qt Code:
    1. ... includes ...
    2. #include "VideoFilterToSatellite.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. qputenv ( "QT_IM_MODULE", QByteArray ( "qtvirtualkeyboard" ) );
    7.  
    8. qSetMessagePattern ( "\033[34m%{function}[%{line}]:\033[0m %{message}" );
    9.  
    10. QGuiApplication app ( argc, argv );
    11. qmlRegisterType<VideoFilterToSatellite>("VideoFilter.ToSatellite", 1, 0, "VideoFilterToSatellite" );
    12.  
    13. QQuickView viewer;
    14.  
    15. viewer.setSource ( QUrl ( QLatin1String ( "qrc:/qml/qmlvideofx/Main.qml" ) ) );
    16.  
    17. viewer.show ();
    18.  
    19. // Delay invocation of init until the event loop has started, to work around
    20. // a GL context issue on Harmattan: without this, we get the following error
    21. // when the first ShaderEffectItem is created:
    22. // "QGLShaderProgram::addShader: Program and shader are not associated with same context"
    23. QMetaObject::invokeMethod ( rootObject, "init", Qt::QueuedConnection );
    24.  
    25. return app.exec();
    26. }
    To copy to clipboard, switch view to plain text mode 


    If I run this code on the desktop, it all works. If I run it on the target, it immediately segfaults in dl-debug.c on line 46 dl_debug_initialize. If I take out the filter, everything works on both platforms. I am missing something and am unsure where to go from here. Thanks for any pointers.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: segfault with adding a QAbstractVideoFilter qml/c++

    Have you tried without the unneccessary reinterpret_cast?

    Also, since you are delaying some form of init for some reason, might it not also be better to delay the QML loading as well?
    Maybe until after init has been done?

    Not saying this could cause the difference between platforms, but it looks weird.

    Cheers,
    _

  3. #3
    Join Date
    Jul 2016
    Posts
    18
    Thanks
    3
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: segfault with adding a QAbstractVideoFilter qml/c++

    Thank you anda_skoa for your feedback. I put the cast in there because QtCreator was giving me a warning at one point. The init delay as well as 99% of this entire app is from "qmlvideofx" example from Qt/Examples. I removed both the cast and the delay and the issue persists. While I can't nail this down, I am thinking it has something to do with the compile/linker differences. I am examining the "Project" tab difference right now. I'm probably wrong, but it seems like the right direction.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: segfault with adding a QAbstractVideoFilter qml/c++

    ABI differences would also be my guess, e.g. different compiler or different flags that change binary layout, etc.

    Cheers,
    _

Similar Threads

  1. SegFault when using QString
    By french13 in forum Qt Programming
    Replies: 2
    Last Post: 14th April 2016, 17:22
  2. Weird Segfault...
    By chimby in forum Qt Programming
    Replies: 3
    Last Post: 22nd January 2009, 23:31
  3. Segfault
    By Dumbledore in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2007, 07:31
  4. segfault
    By conexion2000 in forum Qt Programming
    Replies: 1
    Last Post: 31st May 2006, 12:34
  5. Why does setTextColor() cause a segfault?
    By johnny_sparx in forum Qt Programming
    Replies: 1
    Last Post: 1st April 2006, 16:58

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.