Can't close PCL visualizer - point-cloud-library

I am writing a program to record and store pointclouds. Part of the programs function to observe the recorded clouds, for this I use the PCL visualizer. The problem is that if I close the visualizers window the window just stops, but won't close. I tried calling the close() method, but nothing. I read that this was a problem before VTK 8.0, but I use 8.1 and the problem is still there. I also use PCL 1.9.1 and Ubuntu 18.04.
Anyone has a solution for this? Thanks in advance.

You can try wasStopped() instead of close();
After creating your viewer object:
while (!viewer.wasStopped ())
{
viewer.spinOnce ();
}

Related

How to correctly use next() of tinyxml in QT? My project can be debugged but not released

I am using the tinyxml library to make a QT interface project. The problem now is that it can only be debugged and cannot be released. According to my positioning, there should be a problem with the “Next()” method in TiXmlAttribute. When I use this function, it will appear seg error. And it can be run without using it.Is there any solution, because I have to use this function.
TiXmlAttribute *pAttr;
pAttr = pEle->FirstAttribute();// the first attribute
while(nullptr != pAttr){
pAttr = pAttr->Next();
}

emit signal if cell of QTableView is clicked [duplicate]

I have a QTableView in a PyQt application, and I want to keep track of when the selection changes. I've tried connecting the signal to a slot as follows (using the advice on this page:
self.view.selectionModel().selectionChanged.connect(self.selChanged)
where the slot it is connected to is defined as:
def selChanged(self, selected, deselected):
print "Sel changed"
However, whenever I load the QMainWindow on which the QTableView resides, I get an immediate segmentation fault.
Am I doing something silly here?
I was having a similar problem and the fix was here:
PySide: Segfault(?) when using QItemSelectionModel with QListView
Namely, replace:
self.view.selectionModel().selectionChanged.connect(self.selChanged)
with two commands:
selectionModel = self.view.selectionModel()
selectionModel.selectionChanged.connect(self.selChanged)
Not sure why this works, frankly.
This has been fixed now, it turned out that I was using an old version of Qt on that machine - which seemed to cause the crash.
The moral of the story is: if your code is crashing for no sensible reason, check all of your dependencies (in this case Qt and PyQt) are up-to-date.

PCL viewer->spinOnce() makes QT application quit

I have a QT C++ application that calls a non-QT function that runs a PCL code base on this example http://pointclouds.org/documentation/tutorials/interactive_icp.php. Everything works OK, but when the PCL code finishes (PCLVisualizer closes and returns to the QT code), the QT application automatically quits.
I have checked what instruction causes this error, and turns out it is the call to PCLVisualizer::spineOnce(). If I comment such line, the PCL visualizer does not show correctly but the point cloud operations do run OK, and when the computation is completed QT does not crash.
I was wondering why the call to PCLVisualizer::spineOnce() is causing such behavior? Why is my QT application crashing if I call such function in my PCL code?
This is the call the PCL function from a QT SLOT function
void face_processing_GUI::runAlignment()
{
icp::run_icp(target, source);
}
And the PCL icp::run_icp(string, string) function could be as simple as
int icp::run_icp(std::string in_target, std::string in_source)
{
pcl::visualization::PCLVisualizer * viewer = new pcl::visualization::PCLVisualizer("ICP stage");
viewer->spinOnce(); // If I comment this time it does NOT crash
viewer->close();
delete viewer;
}
The problem might be the viewer->close() after the viewer->spinOnce() I don't think it's supposed to run like that, the spinOnce() method should run in a loop; otherwise you should use spin(). Could you try this? I don't have enough reputation to leave a comment.
//Main loop
while ( !viewer->wasStopped())
{
viewer->spinOnce(100);
// Comment this line if you don't use another thread to run the visualizer.
boost::this_thread::sleep (boost::posix_time::microseconds (100000));
}
It also might be better if you created the viewer using a shared pointer form the boost library
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));

EXC_BAD_ACCESS on iOS 8.1 with Dictionary

I have an object accessible via a static var in a struct (workaround for the lack of class variable support in swift right now), structured like this:
struct Constants{
static var myObj = MyObject()
}
MyObject has a dictionary in it like so:
class MyObject{
private var params = Dictionary<String,AnyObject>()
func addParam(key:String, value:AnyObject){
params[key] = value
}
}
Now on the first call to this object for Contants.myObj.addParam("param", value:123) all is well and params has contents ["param":123]. On the second call for Contants.myObj.addParam("param", value:456), I get a EXC_BAD_ACCESS.
Here's the kicker though, this only occurs in iOS 8.1. Also, if I add the line let stupidHack = self.params as the first line of my addParam method, it works fine. My assumption is that it deals with mutability of dictionaries. The let may somehow trigger the dictionary to be mutable again after initialization.
Has anyone else run into this issue before? Any idea on how to fix it?
Thanks!
Looks like a compiler bug.
Have you tried switching between Release and Debug then rebuilding? If debug works but not release it can be an indication of a compiler/optimizer bug.
Does it happen in the simulator also?
Your code works for me on iOS 8.1 with XCode 6.1.
By chance, do you have an iPhone 6 with 64Gb ?
I have one and I had the same issue using Dictionaries twice.
In the news (well the tech news ...), I read that the defective memory modules delivered by Toshiba for precisely this iPhone model could cause incorrect allocations in memory.
Try adjusting the Swift compiler optimization level to "None" (Build Settings).
I had a similar issue with a class being deallocated for no apparent reason, it is mostly a compiler bug like Lee said.
Faced similar kind of issues with swift code and fixed such issues by disabling swift compiler optimisation in the build settings of the application target.

Qt connect slot with signal from boost::shared_ptr

I have a mainwindow app, when shortcut is triggered, a dialog will popup to show some information, the user may do some configuration in this dialog, then a signal is sent back to the mainwindow, the mainwindow will do some further work. the pseudo code looks like this:
void MainWindow::actionConfigure_triggered()
{
configureDialog = boost::shared_ptr<configure>(new configure(this));
configureDialog->show();
connect(configureDialog.get(), SIGNAL(reload()), this, SLOT(clean_reload()));
}
but when I triggered this function several times, segmentation fault happens. I use debugger to trace the execution, SIGSEGV received when executing boost::checked_delete function.
Any help will be highly appreciated! Thanks in advance.
I just want the configure dialog to be created and deleted dynamically, or there are other better ways to implement this?
According to your backtrace the bug seems somewhere in destructor of configure and has little to do with the shared_ptr (except that it is the shared_ptr that calls the destructor)
Check if there are double deletes of your object, if yes there is probably some other reference to it which is not a shared_ptr deleteing the object.

Resources