mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Mod raw Pointer to QScopedPointer
Clang-Tidy and Clazy said "drag" leaks memory
This commit is contained in:
parent
87845ef0ee
commit
24c930d727
@ -69,10 +69,9 @@ void ElementsTreeView::startDrag(Qt::DropActions supportedActions)
|
|||||||
*/
|
*/
|
||||||
void ElementsTreeView::startElementDrag(const ElementsLocation &location)
|
void ElementsTreeView::startElementDrag(const ElementsLocation &location)
|
||||||
{
|
{
|
||||||
if (!location.exist())
|
if (! location.exist()) return;
|
||||||
return;
|
|
||||||
|
|
||||||
QDrag *drag = new QDrag(this);
|
QScopedPointer<QDrag> drag(new QDrag(this));
|
||||||
|
|
||||||
QString location_str = location.toString();
|
QString location_str = location.toString();
|
||||||
QMimeData *mime_data = new QMimeData();
|
QMimeData *mime_data = new QMimeData();
|
||||||
@ -91,14 +90,12 @@ void ElementsTreeView::startElementDrag(const ElementsLocation &location)
|
|||||||
|
|
||||||
//Build the element for set the pixmap of the QDrag
|
//Build the element for set the pixmap of the QDrag
|
||||||
int elmt_creation_state;
|
int elmt_creation_state;
|
||||||
Element *temp_elmt = ElementFactory::Instance()->createElement(
|
QScopedPointer<Element> temp_elmt(
|
||||||
location, nullptr,
|
ElementFactory::Instance()->createElement(
|
||||||
&elmt_creation_state);
|
location,
|
||||||
if (elmt_creation_state)
|
nullptr,
|
||||||
{
|
&elmt_creation_state));
|
||||||
delete temp_elmt;
|
if (elmt_creation_state) { return; }
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap elmt_pixmap(temp_elmt->pixmap());
|
QPixmap elmt_pixmap(temp_elmt->pixmap());
|
||||||
QPoint elmt_hotspot(temp_elmt->hotspot());
|
QPoint elmt_hotspot(temp_elmt->hotspot());
|
||||||
@ -123,9 +120,6 @@ void ElementsTreeView::startElementDrag(const ElementsLocation &location)
|
|||||||
|
|
||||||
drag->setPixmap(elmt_pixmap);
|
drag->setPixmap(elmt_pixmap);
|
||||||
drag->setHotSpot(elmt_hotspot);
|
drag->setHotSpot(elmt_hotspot);
|
||||||
|
|
||||||
|
|
||||||
delete temp_elmt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drag->setMimeData(mime_data);
|
drag->setMimeData(mime_data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user