[solved]problem with variable member value and signals and slots connection
-
Hello, I have these two slots
@void AjoutDefaut::beginProcess(QImage image)
{
m_currentAnomaly = ℑ
auto n = m_currentAnomaly->width();
m_btn_cont->setEnabled(true);
//QImage currentImage = *(m_dragWidgetCible->m_currentAnomaly);
connect(m_btn_cont, &QPushButton::clicked, this, &AjoutDefaut::startBorderDetect);
}@m_currentAnomaly is a member variable of AjoutDefaut.
m_currentNnomaly = &image works good (m_currentAnomaly is not NULL), but in the following slot, after connection with button click signal, compilater says that m_currentAnomaly points to NULL. I don't know what is the reason@void AjoutDefaut::startBorderDetect()
{
auto n = m_currentAnomaly->width(); CRASH HERE
//m_dragWidgetCible->border_detect(*m_currentAnomaly);
}@Thank you.
-
Hi,
m_currentAnomaly points to an invalid memory location. You are giving it the address of "image" which is only valid the time of beginProcess.
Just use a QImage, it's an implicitly shared class.
-
Since your problem is solved, please update the thread title prepending [solved] so other forum users may know a solution has been found :)