title: Segmentation fault when using graph function (vtk 6.1, Qt5.3, Ubuntu)
body: <p><strong>Update: Debug info</strong></p>
  
  <p>I am working on a Qt 5.3 project and need to plot data in 2D and 3D coordinate systems. I've been looking into vtk 6.1 because it seems very powerful overall and I will also need to visualize image data at a later point. I have using Qvtkwidget smoothly with this example</p>
  
  <p><a href="http://postimg.org/image/9p0zohfxd/" rel="nofollow">Qvtkwidget example</a> </p>
  
  <pre><code>#include "mainwindow.h"
  #include &lt;QApplication&gt;
  #include &lt;vtkAutoInit.h&gt;
  VTK_MODULE_INIT(vtkRenderingOpenGL);
  
  #include &lt;vtkSmartPointer.h&gt;
  #include &lt;vtkSphereSource.h&gt;
  #include &lt;vtkPolyDataMapper.h&gt;
  #include &lt;vtkActor.h&gt;
  #include &lt;vtkImageViewer.h&gt;
  #include &lt;vtkRenderWindowInteractor.h&gt;
  #include &lt;vtkInteractorStyleImage.h&gt;
  #include &lt;vtkRenderer.h&gt;
  #include &lt;vtkJPEGReader.h&gt;
  
  #include &lt;QVTKWidget.h&gt;
  
  int main(int argc, char** argv)
  {
    QApplication app(argc, argv);
  
    QVTKWidget widget;
    widget.resize(256,256);
  
    // Setup sphere
    vtkSmartPointer&lt;vtkSphereSource&gt; sphereSource =
        vtkSmartPointer&lt;vtkSphereSource&gt;::New();
    sphereSource-&gt;Update();
    vtkSmartPointer&lt;vtkPolyDataMapper&gt; sphereMapper =
        vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();
    sphereMapper-&gt;SetInputConnection(sphereSource-&gt;GetOutputPort());
    vtkSmartPointer&lt;vtkActor&gt; sphereActor =
        vtkSmartPointer&lt;vtkActor&gt;::New();
    sphereActor-&gt;SetMapper(sphereMapper);
  
    // Setup window
    vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow =
        vtkSmartPointer&lt;vtkRenderWindow&gt;::New();
  
    // Setup renderer
    vtkSmartPointer&lt;vtkRenderer&gt; renderer =
        vtkSmartPointer&lt;vtkRenderer&gt;::New();
    renderWindow-&gt;AddRenderer(renderer);
  
    renderer-&gt;AddActor(sphereActor);
    renderer-&gt;ResetCamera();
  
    widget.SetRenderWindow(renderWindow);
    widget.show();
  
    app.exec();
  
    return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>But when I tried to implement the graph example (/Examples/Charts/Cxx/QChartTable.cxx ), the program show Segmentation Fault errors.</p>
  
  <pre><code>#include &lt;vtkAutoInit.h&gt;
  VTK_MODULE_INIT(vtkRenderingOpenGL)
  #include "vtkFloatArray.h"
  #include "vtkMath.h"
  #include "vtkRenderer.h"
  #include "vtkRenderWindow.h"
  #include "vtkRenderWindowInteractor.h"
  
  #include "vtkSmartPointer.h"
  
  #include "vtkContextView.h"
  #include "vtkContextScene.h"
  #include "vtkChartXY.h"
  #include "vtkPlot.h"
  #include "vtkTable.h"
  
  #include "vtkTimerLog.h"
  
  #include &lt;QApplication&gt;
  #include &lt;QWidget&gt;
  #include &lt;QMainWindow&gt;
  #include &lt;QHBoxLayout&gt;
  
  #include "QVTKWidget.h"
  #include "vtkQtTableView.h"
  
  #define VTK_CREATE(type, name) \
    vtkSmartPointer&lt;type&gt; name = vtkSmartPointer&lt;type&gt;::New()
  
  int main(int argc, char** argv)
  {
  
  
    // Qt initialization
    QApplication app(argc, argv);
    QMainWindow mainWindow;
    mainWindow.setGeometry(0, 0, 1150, 600);
  
    // QVTK set up and initialization
    QVTKWidget *qvtkWidget = new QVTKWidget(&amp;mainWindow);
  
    // Set up my 2D world...
    VTK_CREATE(vtkContextView, view); // This contains a chart object
    view-&gt;SetInteractor(qvtkWidget-&gt;GetInteractor());
    qvtkWidget-&gt;SetRenderWindow(view-&gt;GetRenderWindow());
  
    // Create a table with some points in it...
    VTK_CREATE(vtkTable, table);
    VTK_CREATE(vtkFloatArray, arrX);
    arrX-&gt;SetName("X Axis");
    table-&gt;AddColumn(arrX);
    VTK_CREATE(vtkFloatArray, arrC);
    arrC-&gt;SetName("Cosine");
    table-&gt;AddColumn(arrC);
    VTK_CREATE(vtkFloatArray, arrS);
    arrS-&gt;SetName("Sine");
    table-&gt;AddColumn(arrS);
  
    // Make a timer object - need to get some frame rates/render times
    VTK_CREATE(vtkTimerLog, timer);
  
    // Test charting with a few more points...
    int numPoints = 29;
    float inc = 7.0 / (numPoints-1);
    table-&gt;SetNumberOfRows(numPoints);
    for (int i = 0; i &lt; numPoints; ++i)
      {
      table-&gt;SetValue(i, 0, i * inc);
      table-&gt;SetValue(i, 1, cos(i * inc) + 0.0);
      table-&gt;SetValue(i, 2, sin(i * inc) + 0.0);
      }
  
  //   table-&gt;Update();
  
    // Add multiple line plots, setting the colors etc
    vtkSmartPointer&lt;vtkChartXY&gt; chart = vtkSmartPointer&lt;vtkChartXY&gt;::New();
    view-&gt;GetScene()-&gt;AddItem(chart);
    vtkPlot *line = chart-&gt;AddPlot(vtkChart::LINE);
    line-&gt;SetInputData(table, 0, 1);
    line-&gt;SetColor(255, 0, 0, 255);
    line = chart-&gt;AddPlot(vtkChart::LINE);
    line-&gt;SetInputData(table, 0, 2);
    line-&gt;SetColor(0, 255, 0, 255);
    line-&gt;SetWidth(2.0);
  
    // Instantiate a vtkQtChart and use that too
  /*  vtkQtChart *qtChart = new vtkQtChart;
    chart = qtChart-&gt;chart();
    line = chart-&gt;AddPlot(vtkChart::LINE);
    line-&gt;SetTable(table, 0, 1);
    line-&gt;SetColor(255, 0, 0, 255);
    line = chart-&gt;AddPlot(vtkChart::LINE);
    line-&gt;SetTable(table, 0, 2);
    line-&gt;SetColor(0, 255, 0, 255);
    line-&gt;SetWidth(2.0);
  */
    // Now lets try to add a table view
    QWidget *widget = new QWidget(&amp;mainWindow);
    QHBoxLayout *layout = new QHBoxLayout(widget);
    VTK_CREATE(vtkQtTableView, tableView);
    tableView-&gt;SetSplitMultiComponentColumns(true);
    tableView-&gt;AddRepresentationFromInput(table);
    tableView-&gt;Update();
    layout-&gt;addWidget(qvtkWidget, 2);
    //layout-&gt;addWidget(qtChart, 2);
    layout-&gt;addWidget(tableView-&gt;GetWidget());
    mainWindow.setCentralWidget(widget);
  
    // Now show the application and start the event loop
    mainWindow.show();
  
    return app.exec();
  }
  </code></pre>
  
  <p>I have no idea how this error occurs. </p>
  
  <p>I have recompiled VTK in debug mode and get more debug info. This is the backtrace for this program. In this screenshot show that problem could come form "this" pointer "this" should be vtkTextRenderer * but "this" point to null pointer. I think this could be a bug in VTK 6.1 but have no idea how to fix it.Please give me some suggestion. Thanks</p>
  
  <p>I am newbie and still can not post picture so I upload it to this link</p>
  
  <p><a href="http://postimg.org/image/9p0zohfxd/" rel="nofollow">Debug Screenshot</a></p>
  
  <pre><code>0   vtkTextRenderer::GetBoundingBox vtkTextRenderer.h   136 0x7ffff0fbda58  
  1   vtkTextRendererStringToImage::GetBounds vtkTextRendererStringToImage.cxx    62  0x7ffff0fbd68b  
  2   vtkOpenGLContextDevice2D::ComputeStringBounds   vtkOpenGLContextDevice2D.cxx    885 0x7ffff650d338  
  3   vtkOpenGLContextDevice2D::ComputeStringBounds   vtkOpenGLContextDevice2D.cxx    809 0x7ffff650cab4  
  4   vtkContext2D::ComputeStringBounds   vtkContext2D.cxx    619 0x7ffff64f24dd  
  5   vtkAxis::GetBoundingRect    vtkAxis.cxx 871 0x7ffff7a9d66d  
  6   vtkChartXY::UpdateLayout    vtkChartXY.cxx  762 0x7ffff7ac6064  
  7   vtkChartXY::Paint   vtkChartXY.cxx  325 0x7ffff7ac4450  
  8   vtkContextScenePrivate::PaintItems  vtkContextScenePrivate.h    80  0x7ffff64ea83a  
  9   vtkContextScene::Paint  vtkContextScene.cxx 120 0x7ffff64fc2f2  
  10  vtkContextActor::RenderOverlay  vtkContextActor.cxx 239 0x7ffff64f5787  
  11  vtkRenderer::UpdateGeometry vtkRenderer.cxx 585 0x7ffff3518bc3  
  12  vtkOpenGLRenderer::DeviceRender vtkOpenGLRenderer.cxx   270 0x7ffff61102c0  
  13  vtkRenderer::Render vtkRenderer.cxx 292 0x7ffff3517dfb  
  14  vtkRendererCollection::Render   vtkRendererCollection.cxx   51  0x7ffff35164d3  
  15  vtkRenderWindow::DoStereoRender vtkRenderWindow.cxx 759 0x7ffff352bc36  
  16  vtkRenderWindow::DoFDRender vtkRenderWindow.cxx 728 0x7ffff352bb46  
  17  vtkRenderWindow::DoAARender vtkRenderWindow.cxx 607 0x7ffff352b4f2  
  18  vtkRenderWindow::Render vtkRenderWindow.cxx 423 0x7ffff352aac2  
  19  vtkXOpenGLRenderWindow::Render  vtkXOpenGLRenderWindow.cxx  1831    0x7ffff61abc51  
  20  vtkRenderWindowInteractor::Render   vtkRenderWindowInteractor.cxx   168 0x7ffff3537751  
  ... &lt;More&gt;              
  </code></pre>