Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bug between addText3D and QVTKWidget #5054

Merged
merged 6 commits into from
Dec 27, 2021

Conversation

booksuper
Copy link
Contributor

When using addtext3d to display 3D text in qvtkwidget, an error "access conflict occurs when reading position 0x000000000000008" will be reported. The reason is that "render - > render()" has been used in addtext3d once, but to send 3D text to qvtkwidget window, execute "UI - > qvtkwidget - > setrenderwindow (viewer - > getrenderwindow());Viewer - > setupinteractor (UI - > qvtkwidget - > getinteractor()); ", which is equivalent to repeated rendering, resulting in pointer out of bounds.
After experiments, it is OK to delete "render - > render()" and it works normally when it does not interact with qvtkwidget

When using addtext3d to display 3D text in qvtkwidget, an error "access conflict occurs when reading position 0x000000000000008" will be reported. The reason is that "render - > render()" has been used in addtext3d once, but to send 3D text to qvtkwidget window, execute "UI - > qvtkwidget - > setrenderwindow (viewer - > getrenderwindow());Viewer - > setupinteractor (UI - > qvtkwidget - > getinteractor()); ", which is equivalent to repeated rendering, resulting in pointer out of bounds.
After experiments, it is OK to delete "render - > render()" and it works normally when it does not interact with qvtkwidget
@larshg
Copy link
Contributor

larshg commented Dec 3, 2021

Instead of commenting the line, just remove it.

Which version of VTK have you tested with?

I can reproduce it with VTK 9.0.1, so unless you have tested VTK 6,7,8 I'd suggest to wrap it in:

      #if VTK_MAJOR_VERSION < 9
      renderer->Render ();
      #endif

@booksuper
Copy link
Contributor Author

Instead of commenting the line, just remove it.

Which version of VTK have you tested with?

I can reproduce it with VTK 9.0.1, so unless you have tested VTK 6,7,8 I'd suggest to wrap it in:

      #if VTK_MAJOR_VERSION < 9
      renderer->Render ();
      #endif

@booksuper booksuper closed this Dec 3, 2021
@booksuper booksuper reopened this Dec 3, 2021
@booksuper
Copy link
Contributor Author

Instead of commenting the line, just remove it.
Which version of VTK have you tested with?
I can reproduce it with VTK 9.0.1, so unless you have tested VTK 6,7,8 I'd suggest to wrap it in:

      #if VTK_MAJOR_VERSION < 9
      renderer->Render ();
      #endif

I have tested with vtk8.0.0, but vtk6 and 7 have not been tested

@larshg
Copy link
Contributor

larshg commented Dec 3, 2021

Eventually someone could test it on linux, but for now, since its the only place its called, I'll be fine with just removing it.
A render call will eventually be called later, so the text will definitely appear at some point 😄

@larshg
Copy link
Contributor

larshg commented Dec 3, 2021

FYI. You can just commit to your branch and push it again with new changes - you don't have to create a new pull request.

@booksuper
Copy link
Contributor Author

FYI. You can just commit to your branch and push it again with new changes - you don't have to create a new pull request.

Thanks for your suggestion
Thanks for your advice. This is my first pull request, and your suggestion has helped me a lot. I'm going to change it like this. Do you think it's feasible
#if VTK_MAJOR_VERSION < 8
renderer->Render ();
#endif

When using addtext3d to display 3D text in qvtkwidget, an error "access conflict occurs when reading position 0x000000000000008" will be reported. The reason is that "render - > render()" has been used in addtext3d once, but to send 3D text to qvtkwidget window, execute "UI - > qvtkwidget - > setrenderwindow (viewer - > getrenderwindow());Viewer - > setupinteractor (UI - > qvtkwidget - > getinteractor()); ", which is equivalent to repeated rendering, resulting in pointer out of bounds.
To solve this problem it is OK to delete "render - > render()". I have passed the test on vtk8.0.0, Larshg has tested on vtk9.0.1, and vtk6 and 7 have not been tested. Therefore, the judgment statement of VTK version is added.
Error between addtext3d and qvtkwidget
@booksuper booksuper changed the title Error between addtext3d and qvtkwidget Fix Bug between addText3D and QVTKWidget Dec 3, 2021
@larshg
Copy link
Contributor

larshg commented Dec 3, 2021

I got time to test it with vtk 6.3 and it seg faults as well so let's just remove the line entirely.

@booksuper
Copy link
Contributor Author

I got time to test it with vtk 6.3 and it seg faults as well so let's just remove the line entirely.

Thanks for your great work. That is great!

After successfully testing vtk6,7,just remove “Render->render()” entirely
Fix Bug between addText3D and QVTKWidget
@larshg larshg added changelog: fix Meta-information for changelog generation module: visualization labels Dec 4, 2021
@larshg larshg added this to the pcl-1.13.0 milestone Dec 4, 2021
@booksuper booksuper requested a review from larshg December 5, 2021 06:32
@booksuper
Copy link
Contributor Author

I've been thinking about the essential reason for this bug recently, but I'm not a computer major. This problem is a little difficult for me. After consulting a lot of blogs and books, I guess the reason for the error is that the memory access is out of bounds. I'm not sure, so I'd like to consult you. I look forward to your reply. Thank you

Copy link
Member

@mvieth mvieth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested (with VTK 9.0.1) and found:

  • In connection with Qt/QVTKWidget, addText3D segfaults without the fix, but works with the fix
  • if PCLVisualizer is used without Qt/QVTKWidget, addText3D works fine with and without this fix

So looks good to me

@mvieth mvieth merged commit 40bf6c0 into PointCloudLibrary:master Dec 27, 2021
@booksuper
Copy link
Contributor Author

I tested (with VTK 9.0.1) and found:

  • In connection with Qt/QVTKWidget, addText3D segfaults without the fix, but works with the fix
  • if PCLVisualizer is used without Qt/QVTKWidget, addText3D works fine with and without this fix

So looks good to me

In the VTK 8.0.0,my test is the same as yours

themightyoarfish pushed a commit to themightyoarfish/pcl that referenced this pull request Jan 5, 2022
* Error  between addtext3d and qvtkwidget

When using addtext3d to display 3D text in qvtkwidget, an error "access conflict occurs when reading position 0x000000000000008" will be reported. The reason is that "render - > render()" has been used in addtext3d once, but to send 3D text to qvtkwidget window, execute "UI - > qvtkwidget - > setrenderwindow (viewer - > getrenderwindow());Viewer - > setupinteractor (UI - > qvtkwidget - > getinteractor()); ", which is equivalent to repeated rendering, resulting in pointer out of bounds.
After experiments, it is OK to delete "render - > render()" and it works normally when it does not interact with qvtkwidget

* Error between addtext3d and qvtkwidget

When using addtext3d to display 3D text in qvtkwidget, an error "access conflict occurs when reading position 0x000000000000008" will be reported. The reason is that "render - > render()" has been used in addtext3d once, but to send 3D text to qvtkwidget window, execute "UI - > qvtkwidget - > setrenderwindow (viewer - > getrenderwindow());Viewer - > setupinteractor (UI - > qvtkwidget - > getinteractor()); ", which is equivalent to repeated rendering, resulting in pointer out of bounds.
To solve this problem it is OK to delete "render - > render()". I have passed the test on vtk8.0.0, Larshg has tested on vtk9.0.1, and vtk6 and 7 have not been tested. Therefore, the judgment statement of VTK version is added.

* Fix Bug between addText3D and QVTKWidget

After successfully testing vtk6,7,just remove “Render->render()” entirely

* Apply suggestions from code review

Co-authored-by: Lars Glud <[email protected]>

Co-authored-by: Lars Glud <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: fix Meta-information for changelog generation module: visualization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants