PDA

View Full Version : QMediaPlaylist keeps building playlist larger



budda
18th July 2015, 11:14
Trying to load playlist after playlist into a QMediaPlayer in a QVideoWidget, the QMediaPlaylist just keeps adding to the previous playlist however.
even after calling

playlist->~QMediaPlayList();
videoWidget->~QVideoWidget();

after playlist is done, and before starting a new one.


playlist and videoWidget are in my header like this:

QVideoWidget *videoWidget;
QMediaPlaylist *playlist;

I even disconnect all the QMediaPlayer connections and the QMediaPlaylist connection...

any tips on this? I thought a deconstructor got rid of the class object instance so that a new one can be dynamically created.

anda_skoa
18th July 2015, 11:36
The destructor runs object cleanup code, just like the constructor running the object's initialization code.
Neither is involved in deallocating or allocating an object.
That's what the delete and new operators do for heap allocated objects and what the compiler generated code does for stack allocated objects.

Cheers,
_

budda
18th July 2015, 11:43
god damn. was forgetting to empty my QList<Type> before appending to it & creating a new playlist. tnank god for QTextStream. can an admin delete this thread? thinking I should get a solid 8 hours sleep....

d_stranz
20th July 2015, 23:17
playlist->~QMediaPlayList();
videoWidget->~QVideoWidget();

This is a pretty bizarre coding convention. If you want to get rid of something, just use the delete operator, don't call the destructor directly.


delete playlist;
delete videoWidget;

All your code is doing is telling the object instance to clean itself up, it isn't actually getting rid of the memory allocated to hold the instance. So if this is the way you think you've been freeing objects created on the heap, it isn't doing that. The instances are still there, they are just invalid because they've been destructed but not deallocated.