Results 1 to 4 of 4

Thread: QMediaPlaylist keeps building playlist larger

  1. #1
    Join Date
    Mar 2010
    Posts
    86
    Thanks
    11
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QMediaPlaylist keeps building playlist larger

    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
    Qt Code:
    1. playlist->~QMediaPlayList();
    2. videoWidget->~QVideoWidget();
    To copy to clipboard, switch view to plain text mode 

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


    playlist and videoWidget are in my header like this:
    Qt Code:
    1. QVideoWidget *videoWidget;
    2. QMediaPlaylist *playlist;
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QMediaPlaylist keeps building playlist larger

    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,
    _

  3. #3
    Join Date
    Mar 2010
    Posts
    86
    Thanks
    11
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMediaPlaylist keeps building playlist larger

    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....

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QMediaPlaylist keeps building playlist larger

    Qt Code:
    1. playlist->~QMediaPlayList();
    2. videoWidget->~QVideoWidget();
    To copy to clipboard, switch view to plain text mode 

    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.

    Qt Code:
    1. delete playlist;
    2. delete videoWidget;
    To copy to clipboard, switch view to plain text mode 

    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.

Similar Threads

  1. HowTo read playlist pls file
    By KeineAhnung in forum Newbie
    Replies: 4
    Last Post: 19th August 2014, 20:45
  2. Load pls file with QMediaPlaylist
    By KeineAhnung in forum Newbie
    Replies: 1
    Last Post: 19th August 2014, 12:43
  3. Replies: 2
    Last Post: 12th May 2014, 14:06
  4. How to add QMediaPlaylist to a layout
    By adutzu89 in forum Newbie
    Replies: 2
    Last Post: 2nd December 2013, 08:06
  5. QMediaPlaylist view
    By Festus Hagen in forum Qt Programming
    Replies: 0
    Last Post: 6th September 2013, 07:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.