[DiscordArchive] <@160857905879449600> <@100246412050075648> do you guys know if QT handles stuff created on heap aut
[DiscordArchive] <@160857905879449600> <@100246412050075648> do you guys know if QT handles stuff created on heap aut
Archived author: Skarn • Posted: 2019-06-06T17:36:47.573000+00:00
Original source
<@160857905879449600> <@100246412050075648> do you guys know if QT handles stuff created on heap automatically or I have to manually remove it?
Archived author: Skarn • Posted: 2019-06-06T17:36:52.776000+00:00
Original source
I don't see it being removed anywhere
Archived author: Skarn • Posted: 2019-06-06T17:37:02.649000+00:00
Original source
but from what I know you need to explicitly delete that stuff to avoid memory leaks
Archived author: schlumpf • Posted: 2019-06-06T17:38:37.382000+00:00
Original source
That’s what I told you about earlier with the QObject memory model where parents delete all their children when they are deleted
tartDragDistance())
tring filename = index.data(Qt:
isplayRole).toString().prepend("tileset/").toStdString();Archived author: Skarn • Posted: 2019-06-06T17:38:38.381000+00:00
Original source
```cpp
void TextureList::mousePressEvent(QMouseEvent* event)
{
QListView::mousePressEvent(event);
if (event->buttons() & Qt::LeftButton) {
int distance = (event->pos() - _start_pos).manhattanLength();
if (distance >= QApplication:
tartDragDistance())
{
QModelIndex index = currentIndex();
const std:
tring filename = index.data(Qt:
isplayRole).toString().prepend("tileset/").toStdString();
QMimeData* mimeData = new QMimeData;
mimeData->setText(QString(filename.c_str()));
QDrag* drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->exec();
}
}
}
```
Archived author: Skarn • Posted: 2019-06-06T17:38:49.899000+00:00
Original source
e.g. is this code leaking or not?
Archived author: Skarn • Posted: 2019-06-06T17:39:25.333000+00:00
Original source
<@160857905879449600> I undertstand the parent - children part. But what about non-widget types?
Archived author: schlumpf • Posted: 2019-06-06T17:40:55.559000+00:00
Original source
Event: owned by qt.
Mimedata: no parent set until added to drag which takes ownership as documented, so may leak when an exception is thrown between those two lines
Drag: the object passed into the ctor is awkwardly documented but takes ownership.
Archived author: schlumpf • Posted: 2019-06-06T17:41:12.098000+00:00
Original source
In an exceptionless world that code does not leak.
Archived author: schlumpf • Posted: 2019-06-06T17:41:23.851000+00:00
Original source
QObject is not just widgets