mavak / trucov

True coverage tool for C / C++
1 stars 1 forks source link

Gui using a dangling pointer #167

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I get the following warning in gcc.

trucov/gui/mainwindow.cpp|296| warning: taking address of temporary

The code looks like this
{{{
cursor = &(editor3->textCursor());
cursor->movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, line_no + 1);
cursor->movePosition(QTextCursor::Up, QTextCursor::KeepAnchor, 1);
}}}

it should look like this:
{{{
QTextCursor cursor = editor3->textCursor();
cursor->movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, line_no + 1);
cursor->movePosition(QTextCursor::Up, QTextCursor::KeepAnchor, 1);
editor3->setTextCursor(cursor);
}}}

I'm afraid to make the update as the old code besides being dangerous didn't 
actually update the cursor.

Should the code be removed, or updated to work?

Original issue reported on code.google.com by j.nick.terry@gmail.com on 16 Jun 2010 at 4:35