Results 1 to 3 of 3

Thread: Do I have to release the resource when using Phonon::createPlayer()?

  1. #1
    Join Date
    Sep 2011
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Question Do I have to release the resource when using Phonon::createPlayer()?

    I am not familiar with the phonon.And following the advice of Qt documents,I use it in a function like this:

    Phonon::MediaObject *music ;
    music = Phonon::createPlayer(Phonon::MusicCategory,Phonon: :MediaSource(pathName));
    music->play();

    I will call this function with different pathName to play different music.I am afraid that maybe everytime I call Phonon::createPlayer(),it will create something in the memory,and it need to be deleted manually.
    Am I right?Or what's the right way to use it?Thanks very much!

  2. #2
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Do I have to release the resource when using Phonon::createPlayer()?

    I've never used Phonon...but according to the code You posted -> Yes, you need to do
    Qt Code:
    1. delete music;
    2. music = 0;
    To copy to clipboard, switch view to plain text mode 

    because this, I believe static method, Phonon::createPlayer(Phonon::MusicCategory,Phonon: :MediaSource(pathName));
    returns a pointer which You assign to music ptr, therefore I believe that You have to delete it manually and not rely on Phonon's internal objects manipulations
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

  3. The following user says thank you to kornicameister for this useful post:

    furskytl (18th September 2011)

  4. #3
    Join Date
    Sep 2011
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Do I have to release the resource when using Phonon::createPlayer()?

    Yes,at last I make "music" a variable declared outside the function,and i manually call function stop() and clear().

Similar Threads

  1. Resource Problem?
    By poporacer in forum Newbie
    Replies: 2
    Last Post: 25th September 2010, 17:58
  2. Resource dispose in Qt4
    By tpieciak in forum Qt Programming
    Replies: 4
    Last Post: 12th September 2010, 23:51
  3. XML resource is garbled?
    By space_otter in forum Qt Programming
    Replies: 8
    Last Post: 22nd June 2010, 01:09
  4. Release build fails to find some resource images
    By MrGarbage in forum Installation and Deployment
    Replies: 3
    Last Post: 8th December 2007, 16:04
  5. QLocale/Resource
    By coderbob in forum Newbie
    Replies: 4
    Last Post: 21st November 2007, 20:51

Tags for this Thread

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.