{"action":"created","issue":{"url":"https://api.github.com/repos/LaurentGomila/SFML/issues/864","labels_url":"https://api.github.com/repos/LaurentGomila/SFML/issues/864/labels{/name}","comments_url":"https://api.github.com/repos/LaurentGomila/SFML/issues/864/comments","events_url":"https://api.github.com/repos/LaurentGomila/SFML/issues/864/events","html_url":"https://github.com/LaurentGomila/SFML/pull/864","id":68036052,"number":864,"title":"Added an assignment operator to SoundSource","user":{"login":"mantognini","id":693483,"avatar_url":"https://avatars.githubusercontent.com/u/693483?v=3","gravatar_id":"","url":"https://api.github.com/users/mantognini","html_url":"https://github.com/mantognini","followers_url":"https://api.github.com/users/mantognini/followers","following_url":"https://api.github.com/users/mantognini/following{/other_user}","gists_url":"https://api.github.com/users/mantognini/gists{/gist_id}","starred_url":"https://api.github.com/users/mantognini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mantognini/subscriptions","organizations_url":"https://api.github.com/users/mantognini/orgs","repos_url":"https://api.github.com/users/mantognini/repos","events_url":"https://api.github.com/users/mantognini/events{/privacy}","received_events_url":"https://api.github.com/users/mantognini/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/LaurentGomila/SFML/labels/bug","name":"bug","color":"ff4242"},{"url":"https://api.github.com/repos/LaurentGomila/SFML/labels/m:sfml-audio","name":"m:sfml-audio","color":"cccccc"},{"url":"https://api.github.com/repos/LaurentGomila/SFML/labels/s:undecided","name":"s:undecided","color":"FFA90A"}],"state":"open","locked":false,"assignee":{"login":"mantognini","id":693483,"avatar_url":"https://avatars.githubusercontent.com/u/693483?v=3","gravatar_id":"","url":"https://api.github.com/users/mantognini","html_url":"https://github.com/mantognini","followers_url":"https://api.github.com/users/mantognini/followers","following_url":"https://api.github.com/users/mantognini/following{/other_user}","gists_url":"https://api.github.com/users/mantognini/gists{/gist_id}","starred_url":"https://api.github.com/users/mantognini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mantognini/subscriptions","organizations_url":"https://api.github.com/users/mantognini/orgs","repos_url":"https://api.github.com/users/mantognini/repos","events_url":"https://api.github.com/users/mantognini/events{/privacy}","received_events_url":"https://api.github.com/users/mantognini/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/LaurentGomila/SFML/milestones/9","html_url":"https://github.com/LaurentGomila/SFML/milestones/2.3","labels_url":"https://api.github.com/repos/LaurentGomila/SFML/milestones/9/labels","id":821119,"number":9,"title":"2.3","description":"","creator":{"login":"Bromeon","id":708488,"avatar_url":"https://avatars.githubusercontent.com/u/708488?v=3","gravatar_id":"","url":"https://api.github.com/users/Bromeon","html_url":"https://github.com/Bromeon","followers_url":"https://api.github.com/users/Bromeon/followers","following_url":"https://api.github.com/users/Bromeon/following{/other_user}","gists_url":"https://api.github.com/users/Bromeon/gists{/gist_id}","starred_url":"https://api.github.com/users/Bromeon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bromeon/subscriptions","organizations_url":"https://api.github.com/users/Bromeon/orgs","repos_url":"https://api.github.com/users/Bromeon/repos","events_url":"https://api.github.com/users/Bromeon/events{/privacy}","received_events_url":"https://api.github.com/users/Bromeon/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":84,"state":"open","created_at":"2014-10-10T13:20:14Z","updated_at":"2015-04-14T10:26:20Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2015-04-13T08:06:58Z","updated_at":"2015-04-14T18:15:15Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/LaurentGomila/SFML/pulls/864","html_url":"https://github.com/LaurentGomila/SFML/pull/864","diff_url":"https://github.com/LaurentGomila/SFML/pull/864.diff","patch_url":"https://github.com/LaurentGomila/SFML/pull/864.patch"},"body":"Added an assignment operator to SoundSource.\r\n\r\nSee @minirop's [PVS-Studio report](http://en.sfml-dev.org/forums/index.php?topic=17906.msg128549#msg128549)\r\n\r\nRegarding the implementation, I didn't write the \"SFML standard\" code, that is:\r\n```cpp\r\nSoundSource& SoundSource::operator =(const SoundSource& right)\r\n{\r\n    SoundSource temp(right);\r\n\r\n    std::swap(m_source, temp.m_source);\r\n\r\n    return *this;\r\n}\r\n```\r\n\r\nBecause this would have implied editing the destructor too so that temp would be properly deallocated. I wanted to keep this PR as minimal as possible but let me know if you prefer something different."},"comment":{"url":"https://api.github.com/repos/LaurentGomila/SFML/issues/comments/93005422","html_url":"https://github.com/LaurentGomila/SFML/pull/864#issuecomment-93005422","issue_url":"https://api.github.com/repos/LaurentGomila/SFML/issues/864","id":93005422,"user":{"login":"Bromeon","id":708488,"avatar_url":"https://avatars.githubusercontent.com/u/708488?v=3","gravatar_id":"","url":"https://api.github.com/users/Bromeon","html_url":"https://github.com/Bromeon","followers_url":"https://api.github.com/users/Bromeon/followers","following_url":"https://api.github.com/users/Bromeon/following{/other_user}","gists_url":"https://api.github.com/users/Bromeon/gists{/gist_id}","starred_url":"https://api.github.com/users/Bromeon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bromeon/subscriptions","organizations_url":"https://api.github.com/users/Bromeon/orgs","repos_url":"https://api.github.com/users/Bromeon/repos","events_url":"https://api.github.com/users/Bromeon/events{/privacy}","received_events_url":"https://api.github.com/users/Bromeon/received_events","type":"User","site_admin":false},"created_at":"2015-04-14T18:15:15Z","updated_at":"2015-04-14T18:15:15Z","body":"Here is the implementation of `sf::Sound::operator=`. Note the comment in the beginning:\r\n```cpp\r\nSound& Sound::operator =(const Sound& right)\r\n{\r\n    // Here we don't use the copy-and-swap idiom, because it would mess up\r\n    // the list of sound instances contained in the buffers\r\n\r\n    // Detach the sound instance from the previous buffer (if any)\r\n    if (m_buffer)\r\n    {\r\n        stop();\r\n        m_buffer->detachSound(this);\r\n        m_buffer = NULL;\r\n    }\r\n\r\n    // Copy the sound attributes\r\n    if (right.m_buffer)\r\n        setBuffer(*right.m_buffer);\r\n    setLoop(right.getLoop());\r\n    setPitch(right.getPitch());\r\n    setVolume(right.getVolume());\r\n    setPosition(right.getPosition());\r\n    setRelativeToListener(right.isRelativeToListener());\r\n    setMinDistance(right.getMinDistance());\r\n    setAttenuation(right.getAttenuation());\r\n\r\n    return *this;\r\n}\r\n```\r\nAll the assigned attributes except *loop* and *sound buffer* are inherited from `sf::SoundSource`. I think we should move the corresponding code to `sf::SoundSource::operator=` and invoke it in the derived class. "}}