0
votes

I need your help please!

I have 8 dockwidget in my Qmainwindow without a centralwidget, when I try to move, float, and undock dockwidget that contains a 3D view, the program crash with segmentation fault!

I remain at your disposal for more information, thanks a lot!

    SUB_WIN_3D_VIEW.cpp  
    /* -----------------------
     * ----------------------- */

    #include "sub_win_3dview.h"
    #include <QtWidgets/QAction>
    #include <iostream>
    #include <QDesktopServices>

    SUB_WIN_3D_VIEW::SUB_WIN_3D_VIEW(Mainwindow const& p) : QDockWidget(),mainwindow_ins(p)
    {
        ui.setupUi(this);
        this->setWindowTitle("3D view");
        // Initiate the 3D scene
        view.defaultFrameGraph()->setClearColor(QColor("#FFC0CBD9")); // light blue
        widget = QWidget::createWindowContainer(&view);
        view.renderSettings()->pickingSettings()->setPickMethod(Qt3DRender::QPickingSettings::TrianglePicking);  
        // Initiate the root entity (all the other entities of the scene should
        // inherit it to be part of the 3D scene
        rootEntity = new Qt3DCore::QEntity;
        input = new Qt3DInput::QInputAspect;
        view.setRootEntity(rootEntity);
        view.registerAspect(input);

        // Get the default camera entity from view
        cameraEntity = view.camera();
        // Set Z the be the vertical axis
        cameraEntity->setUpVector(QVector3D(0, 0, 1));
        // Initiate the camera controller
        MyOrbitCameraController *camController = new MyOrbitCameraController(rootEntity);
        camController->setCamera(cameraEntity);
        camController->setLookSpeed(-300);
        camController->setLinearSpeed(12);

        // Initiate the light entity with its components below
        lightEntity = new Qt3DCore::QEntity(rootEntity);

        Qt3DRender::QPointLight *lightPoint = new Qt3DRender::QPointLight(lightEntity);
        lightPoint->setColor("white");
        lightPoint->setIntensity(1);

        Qt3DCore::QTransform *lightTransform = new Qt3DCore::QTransform(lightEntity);
        lightTransform->setTranslation(QVector3D(20, 20, 20));

        lightEntity->addComponent(lightPoint);
        lightEntity->addComponent(lightTransform);

        // Initiate the modifier of the scene
        modifier = new SceneModifier(rootEntity, cameraEntity);
        modifier->pb_sl_reset();

        view3d->widget->setMinimumSize(QSize(200, 100));
        QSizePolicy view3d_siz(QSizePolicy::Expanding, QSizePolicy::Expanding);
        widget->setSizePolicy(view3d_siz);

        // Add the widget to a layout attached to the UI
        ui.verticalLayout_2->addWidget(widget);
        modifier->pb_sl_loadModel("simple");
        connect(ui.Reload, SIGNAL(clicked(bool)),this, SLOT(reload_clicked()));
        connect(ui.btn_CubeMiddle, SIGNAL(clicked(bool)),this, SLOT(cubeMiddle_clicked()));
        connect(ui.btn_ObjUp, SIGNAL(clicked(bool)),this, SLOT(objUp_clicked()));
        connect(ui.btn_ObjLeft, SIGNAL(clicked(bool)),this, SLOT(objLeft_clicked()));
        connect(ui.btn_ObjRight, SIGNAL(clicked(bool)),this, SLOT(objRight_clicked()));
        connect(ui.btn_ShowAxis, SIGNAL(clicked(bool)),this, SLOT(showAxis_clicked()));}  
SUB_WIN_3D_VIEW::~SUB_WIN_3D_VIEW()
{

}


void SUB_WIN_3D_VIEW::reload_clicked()
{
    // Reload's button simply load the same model again
    modifier->pb_sl_loadModel("simple");
}

void SUB_WIN_3D_VIEW::cubeMiddle_clicked()
{
    modifier->pb_sl_cameraMiddle();
}

void SUB_WIN_3D_VIEW::objUp_clicked()
{
    modifier->pb_sl_cameraUp();
}

void SUB_WIN_3D_VIEW::objLeft_clicked()
{
    modifier->pb_sl_cameraLeft();
}

void SUB_WIN_3D_VIEW::objRight_clicked()
{
    modifier->pb_sl_cameraRight();
}

void SUB_WIN_3D_VIEW::showAxis_clicked()
{
    modifier->pb_sl_enableRef(ui.btn_ShowAxis->isChecked());
}

#include "moc_sub_win_3dview.cpp"

Errors:

In file ....\include/QtCore/../../src/corelib/global/qglobal.h, line 770: Out of memory Invalid parameter passed to C runtime function. Invalid parameter passed to C runtime function. QWidget::repaint: Recursive repaint detected

createDIB: CreateDIBSection failed. Invalid parameter passed to C runtime function. Invalid parameter passed to C runtime function. QWaitCondition: Destroyed while threads are still waiting

1
Welcome to Stack Overflow! You should have a look at the site guidelines on how to post answers. First of all, you must post a Minimal Complete Verifiable Example. Please have a look here - Sergio Monteleone
@SergioMonteleone thank you for the explanations, i updated my publication. - oufleure
Welcome to Stack Overflow! Please edit your question to show us what kind of debugging you've done. I expect you to have run your minimal reproducible example within Valgrind or a similar checker, and to have investigated with a debugger such as GDB, for example. Ensure you've enabled a full set of compiler warnings, too. What did the tools tell you, and what information are they missing? And read Eric Lippert's How to debug small programs. - Toby Speight
@TobySpeight thank you for these explanations. - oufleure

1 Answers

0
votes

I solved the problem by modifying the qml code, before it was like that :

file.h
 QQuickWidget *m_quickWidget_gauge_2;
    QObject *object_gauge_2 ;
    QQuickWidget *m_quickWidget_gauge_3;
    QObject *object_gauge_3 ;
    QQuickWidget *m_quickWidget_gauge_4;
    QObject *object_gauge_4 ;
file.cpp
//QQuickWidget : actuator number 1
    m_quickWidget_gauge_1 = new QQuickWidget(this) ;
    m_quickWidget_gauge_1->setSource(QUrl("qrc:/Resources/res/gauge.qml"));
    m_quickWidget_gauge_1->setResizeMode(QQuickWidget::SizeRootObjectToView);
    m_quickWidget_gauge_1->setMinimumHeight(30);
    m_quickWidget_gauge_1->setMinimumWidth(150);
    m_quickWidget_gauge_1->setAttribute(Qt::WA_AlwaysStackOnTop);
    m_quickWidget_gauge_1->setClearColor(Qt::transparent);
    ui.horizontalLayout_al_1->addWidget(m_quickWidget_gauge_1, 1, Qt::AlignTop);
    //QQuickWidget : actuator number 2
    m_quickWidget_gauge_2 = new QQuickWidget(this) ;
    m_quickWidget_gauge_2->setSource(QUrl("qrc:/Resources/res/gauge.qml"));
    m_quickWidget_gauge_2->setResizeMode(QQuickWidget::SizeRootObjectToView);
    m_quickWidget_gauge_2->setMinimumHeight(30);
    m_quickWidget_gauge_2->setMinimumWidth(150);
    m_quickWidget_gauge_2->setAttribute(Qt::WA_AlwaysStackOnTop);
    m_quickWidget_gauge_2->setClearColor(Qt::transparent);
    ui.horizontalLayout_al_2->addWidget(m_quickWidget_gauge_2, 1, Qt::AlignTop);
    //QQuickWidget : actuator number 3
[....]

I made these changes and it works!!

file.h 
 QQuickView *m_qmlview_gauge_1;
 QQuickView *m_qmlview_gauge_2;
 QQuickView *m_qmlview_gauge_3;
file.cpp
  m_qmlview_gauge_1 = new QQuickView(QUrl("qrc:/Resources/res/qml/actuator_gauge.qml"));
    m_qmlview_gauge_1->setColor(QColor(Qt::white));
    QWidget *container = QWidget::createWindowContainer(m_qmlview_gauge_1);
    container->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding);
    ui.verticalLayout_11->addWidget(container);

    m_qmlview_gauge_2 = new QQuickView(QUrl("qrc:/Resources/res/qml/actuator_gauge.qml"));
    m_qmlview_gauge_2->setColor(QColor(Qt::white));
    QWidget *container_1 = QWidget::createWindowContainer(m_qmlview_gauge_2);
    container_1->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding);
    ui.verticalLayout_12->addWidget(container_1);

    m_qmlview_gauge_3 = new QQuickView(QUrl("qrc:/Resources/res/qml/actuator_gauge.qml"));
    m_qmlview_gauge_3->setColor(QColor(Qt::white));
    QWidget *container_2 = QWidget::createWindowContainer(m_qmlview_gauge_3);
    container_2->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding);
    ui.verticalLayout_13->addWidget(container_2);

i still not understand why the old code cause this crash, it worked well before !!