{"action":"created","comment":{"url":"https://api.github.com/repos/mixxxdj/mixxx/pulls/comments/37150531","id":37150531,"diff_hunk":"@@ -452,6 +482,66 @@ void LibraryScanner::addNewTrack(TrackPointer pTrack) {\n         emit(trackAdded(pTrack));\n         emit(progressLoading(pTrack->getLocation()));\n     } else {\n-        qWarning() << \"Track (\"+pTrack->getLocation()+\") could not be added\";\n+        qWarning()\n+                << \"Track (\" + pTrack->getLocation() + \") could not be added\";\n+    }\n+}\n+\n+bool LibraryScanner::changeScannerState(ScannerState newState) {\n+    // Allowed State transitions:\n+    // IDLE -> STARTING\n+    // STARTING -> IDLE\n+    // STARTING -> SCANNING\n+    // SCANNING -> FINISHED\n+    // FINISHED -> IDLE\n+    // every state can change to CANCELING\n+    // CANCELING -> IDLE\n+    switch (newState) {\n+    case IDLE:\n+        // we are leaving STARTING  or CANCELING state\n+        // m_state is already IDLE if a scan was canceled\n+        m_state = IDLE;\n+        m_stateMutex.unlock();\n+        return true;\n+    case STARTING:\n+        // we need to lock the mutex during the STARTING state\n+        // to prevent loosing cancel commands or start the scanner\n+        // twice\n+        if (m_stateMutex.tryLock()) {\n+            if (m_state != IDLE) {\n+                qDebug() << \"LibraryScanner: Scan already in progress.\";\n+                m_stateMutex.unlock();\n+                return false;\n+            }\n+            m_state = STARTING;\n+            return true;\n+        } else {\n+            qDebug() << \"LibraryScanner: mutex locked, state =\" << m_state;\n+            return false;\n+        }\n+    case SCANNING:\n+        DEBUG_ASSERT(m_state == STARTING);","path":"src/library/scanner/libraryscanner.cpp","position":310,"original_position":310,"commit_id":"6ec1a29b4322b510701b16bc7b697bbc9c24e7ff","original_commit_id":"6ec1a29b4322b510701b16bc7b697bbc9c24e7ff","user":{"login":"ywwg","id":888940,"avatar_url":"https://avatars.githubusercontent.com/u/888940?v=3","gravatar_id":"","url":"https://api.github.com/users/ywwg","html_url":"https://github.com/ywwg","followers_url":"https://api.github.com/users/ywwg/followers","following_url":"https://api.github.com/users/ywwg/following{/other_user}","gists_url":"https://api.github.com/users/ywwg/gists{/gist_id}","starred_url":"https://api.github.com/users/ywwg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ywwg/subscriptions","organizations_url":"https://api.github.com/users/ywwg/orgs","repos_url":"https://api.github.com/users/ywwg/repos","events_url":"https://api.github.com/users/ywwg/events{/privacy}","received_events_url":"https://api.github.com/users/ywwg/received_events","type":"User","site_admin":false},"body":"> Look at this like unit-tests\r\n\r\nruntime checks are not at all like unit tests.  I understand how this could catch regressions, but it's the least-desirable way to test for regressions.","created_at":"2015-08-16T21:17:18Z","updated_at":"2015-08-16T21:17:18Z","html_url":"https://github.com/mixxxdj/mixxx/pull/655#discussion_r37150531","pull_request_url":"https://api.github.com/repos/mixxxdj/mixxx/pulls/655","_links":{"self":{"href":"https://api.github.com/repos/mixxxdj/mixxx/pulls/comments/37150531"},"html":{"href":"https://github.com/mixxxdj/mixxx/pull/655#discussion_r37150531"},"pull_request":{"href":"https://api.github.com/repos/mixxxdj/mixxx/pulls/655"}}},"pull_request":{"url":"https://api.github.com/repos/mixxxdj/mixxx/pulls/655","id":40316647,"html_url":"https://github.com/mixxxdj/mixxx/pull/655","diff_url":"https://github.com/mixxxdj/mixxx/pull/655.diff","patch_url":"https://github.com/mixxxdj/mixxx/pull/655.patch","issue_url":"https://api.github.com/repos/mixxxdj/mixxx/issues/655","number":655,"state":"open","locked":false,"title":"Scannerlock","user":{"login":"daschuer","id":1777442,"avatar_url":"https://avatars.githubusercontent.com/u/1777442?v=3","gravatar_id":"","url":"https://api.github.com/users/daschuer","html_url":"https://github.com/daschuer","followers_url":"https://api.github.com/users/daschuer/followers","following_url":"https://api.github.com/users/daschuer/following{/other_user}","gists_url":"https://api.github.com/users/daschuer/gists{/gist_id}","starred_url":"https://api.github.com/users/daschuer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daschuer/subscriptions","organizations_url":"https://api.github.com/users/daschuer/orgs","repos_url":"https://api.github.com/users/daschuer/repos","events_url":"https://api.github.com/users/daschuer/events{/privacy}","received_events_url":"https://api.github.com/users/daschuer/received_events","type":"User","site_admin":false},"body":"I experience a hard to reproduce deadlock in LibraryScanner destructor by starting Mixxx and closing it just after \r\n\r\nThis fixes some race condition in that code part and hopefully fixes the deadlock. \r\n\r\nBefore this patch It could happen that a scan request is on the LibraryScanner event queue when the destructor is called. \r\nIn this state cancel() is not called. But we will have a running scan later.  ","created_at":"2015-07-19T22:52:45Z","updated_at":"2015-08-16T21:17:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4217be46e98e42e1e5302a0fae1721aad6279de3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mixxxdj/mixxx/pulls/655/commits","review_comments_url":"https://api.github.com/repos/mixxxdj/mixxx/pulls/655/comments","review_comment_url":"https://api.github.com/repos/mixxxdj/mixxx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mixxxdj/mixxx/issues/655/comments","statuses_url":"https://api.github.com/repos/mixxxdj/mixxx/statuses/6ec1a29b4322b510701b16bc7b697bbc9c24e7ff","head":{"label":"daschuer:scannerlock","ref":"scannerlock","sha":"6ec1a29b4322b510701b16bc7b697bbc9c24e7ff","user":{"login":"daschuer","id":1777442,"avatar_url":"https://avatars.githubusercontent.com/u/1777442?v=3","gravatar_id":"","url":"https://api.github.com/users/daschuer","html_url":"https://github.com/daschuer","followers_url":"https://api.github.com/users/daschuer/followers","following_url":"https://api.github.com/users/daschuer/following{/other_user}","gists_url":"https://api.github.com/users/daschuer/gists{/gist_id}","starred_url":"https://api.github.com/users/daschuer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daschuer/subscriptions","organizations_url":"https://api.github.com/users/daschuer/orgs","repos_url":"https://api.github.com/users/daschuer/repos","events_url":"https://api.github.com/users/daschuer/events{/privacy}","received_events_url":"https://api.github.com/users/daschuer/received_events","type":"User","site_admin":false},"repo":{"id":10669071,"name":"mixxx","full_name":"daschuer/mixxx","owner":{"login":"daschuer","id":1777442,"avatar_url":"https://avatars.githubusercontent.com/u/1777442?v=3","gravatar_id":"","url":"https://api.github.com/users/daschuer","html_url":"https://github.com/daschuer","followers_url":"https://api.github.com/users/daschuer/followers","following_url":"https://api.github.com/users/daschuer/following{/other_user}","gists_url":"https://api.github.com/users/daschuer/gists{/gist_id}","starred_url":"https://api.github.com/users/daschuer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daschuer/subscriptions","organizations_url":"https://api.github.com/users/daschuer/orgs","repos_url":"https://api.github.com/users/daschuer/repos","events_url":"https://api.github.com/users/daschuer/events{/privacy}","received_events_url":"https://api.github.com/users/daschuer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/daschuer/mixxx","description":"Mixxx is Free DJ software that gives you everything you need to perform live mixes.","fork":true,"url":"https://api.github.com/repos/daschuer/mixxx","forks_url":"https://api.github.com/repos/daschuer/mixxx/forks","keys_url":"https://api.github.com/repos/daschuer/mixxx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/daschuer/mixxx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/daschuer/mixxx/teams","hooks_url":"https://api.github.com/repos/daschuer/mixxx/hooks","issue_events_url":"https://api.github.com/repos/daschuer/mixxx/issues/events{/number}","events_url":"https://api.github.com/repos/daschuer/mixxx/events","assignees_url":"https://api.github.com/repos/daschuer/mixxx/assignees{/user}","branches_url":"https://api.github.com/repos/daschuer/mixxx/branches{/branch}","tags_url":"https://api.github.com/repos/daschuer/mixxx/tags","blobs_url":"https://api.github.com/repos/daschuer/mixxx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/daschuer/mixxx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/daschuer/mixxx/git/refs{/sha}","trees_url":"https://api.github.com/repos/daschuer/mixxx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/daschuer/mixxx/statuses/{sha}","languages_url":"https://api.github.com/repos/daschuer/mixxx/languages","stargazers_url":"https://api.github.com/repos/daschuer/mixxx/stargazers","contributors_url":"https://api.github.com/repos/daschuer/mixxx/contributors","subscribers_url":"https://api.github.com/repos/daschuer/mixxx/subscribers","subscription_url":"https://api.github.com/repos/daschuer/mixxx/subscription","commits_url":"https://api.github.com/repos/daschuer/mixxx/commits{/sha}","git_commits_url":"https://api.github.com/repos/daschuer/mixxx/git/commits{/sha}","comments_url":"https://api.github.com/repos/daschuer/mixxx/comments{/number}","issue_comment_url":"https://api.github.com/repos/daschuer/mixxx/issues/comments{/number}","contents_url":"https://api.github.com/repos/daschuer/mixxx/contents/{+path}","compare_url":"https://api.github.com/repos/daschuer/mixxx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/daschuer/mixxx/merges","archive_url":"https://api.github.com/repos/daschuer/mixxx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/daschuer/mixxx/downloads","issues_url":"https://api.github.com/repos/daschuer/mixxx/issues{/number}","pulls_url":"https://api.github.com/repos/daschuer/mixxx/pulls{/number}","milestones_url":"https://api.github.com/repos/daschuer/mixxx/milestones{/number}","notifications_url":"https://api.github.com/repos/daschuer/mixxx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/daschuer/mixxx/labels{/name}","releases_url":"https://api.github.com/repos/daschuer/mixxx/releases{/id}","created_at":"2013-06-13T15:21:23Z","updated_at":"2015-04-23T06:18:48Z","pushed_at":"2015-08-13T20:18:49Z","git_url":"git://github.com/daschuer/mixxx.git","ssh_url":"git@github.com:daschuer/mixxx.git","clone_url":"https://github.com/daschuer/mixxx.git","svn_url":"https://github.com/daschuer/mixxx","homepage":null,"size":299755,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"mixxxdj:1.12","ref":"1.12","sha":"379acea976418d6ca0652b70cbfac0e8edb0d56a","user":{"login":"mixxxdj","id":1743769,"avatar_url":"https://avatars.githubusercontent.com/u/1743769?v=3","gravatar_id":"","url":"https://api.github.com/users/mixxxdj","html_url":"https://github.com/mixxxdj","followers_url":"https://api.github.com/users/mixxxdj/followers","following_url":"https://api.github.com/users/mixxxdj/following{/other_user}","gists_url":"https://api.github.com/users/mixxxdj/gists{/gist_id}","starred_url":"https://api.github.com/users/mixxxdj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mixxxdj/subscriptions","organizations_url":"https://api.github.com/users/mixxxdj/orgs","repos_url":"https://api.github.com/users/mixxxdj/repos","events_url":"https://api.github.com/users/mixxxdj/events{/privacy}","received_events_url":"https://api.github.com/users/mixxxdj/received_events","type":"Organization","site_admin":false},"repo":{"id":10126031,"name":"mixxx","full_name":"mixxxdj/mixxx","owner":{"login":"mixxxdj","id":1743769,"avatar_url":"https://avatars.githubusercontent.com/u/1743769?v=3","gravatar_id":"","url":"https://api.github.com/users/mixxxdj","html_url":"https://github.com/mixxxdj","followers_url":"https://api.github.com/users/mixxxdj/followers","following_url":"https://api.github.com/users/mixxxdj/following{/other_user}","gists_url":"https://api.github.com/users/mixxxdj/gists{/gist_id}","starred_url":"https://api.github.com/users/mixxxdj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mixxxdj/subscriptions","organizations_url":"https://api.github.com/users/mixxxdj/orgs","repos_url":"https://api.github.com/users/mixxxdj/repos","events_url":"https://api.github.com/users/mixxxdj/events{/privacy}","received_events_url":"https://api.github.com/users/mixxxdj/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mixxxdj/mixxx","description":"Mixxx is Free DJ software that gives you everything you need to perform live mixes.","fork":false,"url":"https://api.github.com/repos/mixxxdj/mixxx","forks_url":"https://api.github.com/repos/mixxxdj/mixxx/forks","keys_url":"https://api.github.com/repos/mixxxdj/mixxx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mixxxdj/mixxx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mixxxdj/mixxx/teams","hooks_url":"https://api.github.com/repos/mixxxdj/mixxx/hooks","issue_events_url":"https://api.github.com/repos/mixxxdj/mixxx/issues/events{/number}","events_url":"https://api.github.com/repos/mixxxdj/mixxx/events","assignees_url":"https://api.github.com/repos/mixxxdj/mixxx/assignees{/user}","branches_url":"https://api.github.com/repos/mixxxdj/mixxx/branches{/branch}","tags_url":"https://api.github.com/repos/mixxxdj/mixxx/tags","blobs_url":"https://api.github.com/repos/mixxxdj/mixxx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mixxxdj/mixxx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mixxxdj/mixxx/git/refs{/sha}","trees_url":"https://api.github.com/repos/mixxxdj/mixxx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mixxxdj/mixxx/statuses/{sha}","languages_url":"https://api.github.com/repos/mixxxdj/mixxx/languages","stargazers_url":"https://api.github.com/repos/mixxxdj/mixxx/stargazers","contributors_url":"https://api.github.com/repos/mixxxdj/mixxx/contributors","subscribers_url":"https://api.github.com/repos/mixxxdj/mixxx/subscribers","subscription_url":"https://api.github.com/repos/mixxxdj/mixxx/subscription","commits_url":"https://api.github.com/repos/mixxxdj/mixxx/commits{/sha}","git_commits_url":"https://api.github.com/repos/mixxxdj/mixxx/git/commits{/sha}","comments_url":"https://api.github.com/repos/mixxxdj/mixxx/comments{/number}","issue_comment_url":"https://api.github.com/repos/mixxxdj/mixxx/issues/comments{/number}","contents_url":"https://api.github.com/repos/mixxxdj/mixxx/contents/{+path}","compare_url":"https://api.github.com/repos/mixxxdj/mixxx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mixxxdj/mixxx/merges","archive_url":"https://api.github.com/repos/mixxxdj/mixxx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mixxxdj/mixxx/downloads","issues_url":"https://api.github.com/repos/mixxxdj/mixxx/issues{/number}","pulls_url":"https://api.github.com/repos/mixxxdj/mixxx/pulls{/number}","milestones_url":"https://api.github.com/repos/mixxxdj/mixxx/milestones{/number}","notifications_url":"https://api.github.com/repos/mixxxdj/mixxx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mixxxdj/mixxx/labels{/name}","releases_url":"https://api.github.com/repos/mixxxdj/mixxx/releases{/id}","created_at":"2013-05-17T15:14:38Z","updated_at":"2015-08-13T13:56:17Z","pushed_at":"2015-08-16T17:06:40Z","git_url":"git://github.com/mixxxdj/mixxx.git","ssh_url":"git@github.com:mixxxdj/mixxx.git","clone_url":"https://github.com/mixxxdj/mixxx.git","svn_url":"https://github.com/mixxxdj/mixxx","homepage":"http://mixxx.org","size":328349,"stargazers_count":341,"watchers_count":341,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":232,"mirror_url":null,"open_issues_count":58,"forks":232,"open_issues":58,"watchers":341,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mixxxdj/mixxx/pulls/655"},"html":{"href":"https://github.com/mixxxdj/mixxx/pull/655"},"issue":{"href":"https://api.github.com/repos/mixxxdj/mixxx/issues/655"},"comments":{"href":"https://api.github.com/repos/mixxxdj/mixxx/issues/655/comments"},"review_comments":{"href":"https://api.github.com/repos/mixxxdj/mixxx/pulls/655/comments"},"review_comment":{"href":"https://api.github.com/repos/mixxxdj/mixxx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mixxxdj/mixxx/pulls/655/commits"},"statuses":{"href":"https://api.github.com/repos/mixxxdj/mixxx/statuses/6ec1a29b4322b510701b16bc7b697bbc9c24e7ff"}}}}