Segmentation Fault (Core Dumped)



  • I have got VTK 5.6.1 and Qt 4.6.2 installed on my opensolaris system. I wrote a code which has basic function of showing the VTk viewPort and rendering an image on it. The Class code is as given below.

    @MainWindow::MainWindow(QWidget *parent):QDialog(parent)
    {
    //qvtkWidget= new QVTKWidget;
    button = new QPushButton("Do Something");
    label = new QLabel("Garbage Value");

    connect(button, SIGNAL(clicked()),new helper(label, this), SLOT(onclicked()));
    qvtkWidget->resize(256,256);
    
    vtkPNGReader* reader = vtkPNGReader::New();
    char fname[] ="/export/home/sol/Downloads/vtk/vtk.png";
    reader->SetFileName(fname);
    
    vtkImageViewer* image_view = vtkImageViewer::New();
    image_view->SetInputConnection(reader->GetOutputPort());
    
    qvtkWidget->SetRenderWindow(image_view->GetRenderWindow());
    image_view->SetupInteractor(qvtkWidget->GetRenderWindow()->GetInteractor());
    
    image_view->SetColorLevel(138.5);
    image_view->SetColorWindow(233);*/
    
    //label->setText("My Value");
    
    QGridLayout *layout = new QGridLayout;
    

    // layout->addWidget(qvtkWidget);
    layout->addWidget(button);
    layout->addWidget(label);
    setLayout(layout);
    }

    void MainWindow::MyEventHandler()
    {
    //Label setting
    label->setText("Dude It works");

    //VTK Widget interaction
    vtkPNGReader* reader = vtkPNGReader::New();
    char fname[] ="/export/home/sol/Downloads/vtk/Earth-icon.png";
    reader->SetFileName(fname);
    
    vtkImageViewer* image_view = vtkImageViewer::New();
    image_view->SetInputConnection(reader->GetOutputPort());
    
    qvtkWidget->SetRenderWindow(image_view->GetRenderWindow());
    image_view->SetupInteractor(qvtkWidget->GetRenderWindow()->GetInteractor());
    
    image_view->SetColorLevel(138.5);
    image_view->SetColorWindow(233);
    

    }

    helper::helper(QLabel *label, MainWindow *reciever)
    {
    mylabel= label;
    this->reciever=reciever;
    }

    void helper:: onclicked()
    {
    //reciever->changetext(mylabel);
    reciever->MyEventHandler();

    }

    void MainWindow::changetext(QLabel *label)
    {
    label->setText("changed");
    } @

    But when I run the application file It says segmentation fault(Core Dumped) . But I don see anything wrong with the pointers or anything that I have used.
    Also when I include the (LIBS += -L/usr/local/lib/vtk-5.6 -lQVTK -lvtkRendering -lvtkIO -lvtkFiltering) …. in the .pro file I have this problem. Though I am not using any of its classes(QVTKWidget etc..,) But if I comment that line it works fine.

    Its a run time error and is related to the Shared Libraries.

    I have also set the LD_LIBRARY_PATH!!!

    What Might have gone wrong.

    I am totally stuck, Please Hel



  • Run into valgrind using the memcheck tool.



  • I ll do that., But might there be a chance of the VTK library built wrongly?? What might be the other possibilities why it failing?



  • @ //qvtkWidget= new QVTKWidget;
    button = new QPushButton("Do Something");
    label = new QLabel("Garbage Value");

    connect(button, SIGNAL(clicked()),new helper(label, this), SLOT(onclicked()));
    qvtkWidget->resize(256,256);@
    

    Why is the QVTKWidget instance creation commented? You are using it as a pointer when resizing it, but its creation is commented in the constructor
    @//qvtkWidget= new QVTKWidget;@

    Maybe uncommenting that line, :) , can solve the problem. Just a guess...



  • Thanks.., but the problem i m getting stuck is different!! :-) May be I have gone wrong in the building process.



  • I am sorry I can't help

    bq. I ll do that., But might there be a chance of the VTK library built wrongly?? What might be the other possibilities why it failing?

    Look, I don't want to alarm you, but my colleagues experience setting vtk up is not good...


Log in to reply
 

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