GillesDebunne / libQGLViewer

libQGLViewer is an open source C++ library based on Qt that eases the creation of OpenGL 3D viewers.
Other
241 stars 94 forks source link

setBackgroundColor assert crash #33

Closed luntik2012 closed 7 years ago

luntik2012 commented 7 years ago

QColor c(Qt::red);

viewer->setBackgroundColor(c);

ASSERT: "false" in file qgl.cpp, line 128

GillesDebunne commented 7 years ago

Thanks for this feedback.

setBackgroundColor(color) simply calls qglClearColor(color). This crash hence seems to be Qt-related. You can confirm this by instantiating a plain QGLWidget and calling qglClearColor(Qt::red). This should crash too, and you may want to check your OpenGl configuration.

luntik2012 commented 7 years ago

I had this issue on win7, now I've tested it on linux. I think you cannot just call QGLWidget::qglClearColor(QColor(Qt::red));

So there is my code:

// mainwindow.h
#pragma once

#include <QMainWindow>
#include <QGL>

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    QGLWidget *m_viewer;
};

// mainwindow.cpp
#include "mainwindow.h"
#include <qgl.h>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    setMinimumHeight(480);
    setMinimumWidth(640);
    m_viewer = new QGLWidget(this);
//    m_viewer->qglClearColor(QColor(Qt::red));

    this->setCentralWidget(m_viewer);
}

MainWindow::~MainWindow()
{
    delete m_viewer;
}

It crashes only with uncommented 'm_viewer->qglClearColor(QColor(Qt::red));' I cannot debug it, because I don't have qt sources compiled right now. Just segfault

~$ qmake --version
QMake version 3.0
Using Qt version 5.5.1 in /usr/lib/x86_64-linux-gnu

PS: sorry for editing, ctrl+enter... PPS: I really don't think it's related to my graphics setup. Two different OS, two different PC, two different qt versions

GillesDebunne commented 7 years ago

Thanks a lot for this feedback.

I'll close this since it is not a QGLViewer specific issue.

I wonder if this could be a problem with your configuration, since I could not find other similar issues reported on the web.