{"action":"created","issue":{"url":"https://api.github.com/repos/vcmi/vcmi/issues/199","repository_url":"https://api.github.com/repos/vcmi/vcmi","labels_url":"https://api.github.com/repos/vcmi/vcmi/issues/199/labels{/name}","comments_url":"https://api.github.com/repos/vcmi/vcmi/issues/199/comments","events_url":"https://api.github.com/repos/vcmi/vcmi/issues/199/events","html_url":"https://github.com/vcmi/vcmi/pull/199","id":139327181,"number":199,"title":"Fixed segmentation fault when right-clicking on artefact on the \"Black Market\" window.","user":{"login":"argarak","id":13645600,"avatar_url":"https://avatars.githubusercontent.com/u/13645600?v=3","gravatar_id":"","url":"https://api.github.com/users/argarak","html_url":"https://github.com/argarak","followers_url":"https://api.github.com/users/argarak/followers","following_url":"https://api.github.com/users/argarak/following{/other_user}","gists_url":"https://api.github.com/users/argarak/gists{/gist_id}","starred_url":"https://api.github.com/users/argarak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/argarak/subscriptions","organizations_url":"https://api.github.com/users/argarak/orgs","repos_url":"https://api.github.com/users/argarak/repos","events_url":"https://api.github.com/users/argarak/events{/privacy}","received_events_url":"https://api.github.com/users/argarak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-08T16:41:34Z","updated_at":"2016-03-08T17:49:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/vcmi/vcmi/pulls/199","html_url":"https://github.com/vcmi/vcmi/pull/199","diff_url":"https://github.com/vcmi/vcmi/pull/199.diff","patch_url":"https://github.com/vcmi/vcmi/pull/199.patch"},"body":"In file `client/windows/CTradeWindow.cpp`, which initialises the \"Black Market\" window, in the function `clickRight`, the pointer \"hlp\" was null. Later on in your code you referenced the function `getEffectiveDescription`, and inside it you assigned a *null* pointer to a string and caused the segmentation fault. (I think...)\r\n\r\nTherefore, I looked into your code and found a way of initialising the message using the variable `CGI`.\r\n\r\nEventhough it way seem like I changed a lot, I only really added this code (inside if statement):\r\n\r\n```\r\nif(id >= 0)  {\r\n\t    //adventureInt->handleRightClick(hlp->getEffectiveDescription(), down);\r\n\t\r\n\t    const CArtifact &artifact = *CGI->arth->artifacts[id];\r\n\t    std::string desc = artifact.Description();\r\n\t    \r\n\t    adventureInt->handleRightClick(desc, down);\r\n}\r\n```\r\n\r\nThe rest of the code is Emacs \"fixing\" indentation, but source code always ends up looking weird after you indent it in Emacs. (To fix this just indent everything in your favourite editor)\r\n\r\nAnd since there was already a variable named `id`, I can use this method. If you would like to make this even smaller, remove the comment and the variable `desc` and just put in into `handleRightClick`.\r\n\r\nAfter this modification, right-clicking on the artefact worked perfectly well."},"comment":{"url":"https://api.github.com/repos/vcmi/vcmi/issues/comments/193888307","html_url":"https://github.com/vcmi/vcmi/pull/199#issuecomment-193888307","issue_url":"https://api.github.com/repos/vcmi/vcmi/issues/199","id":193888307,"user":{"login":"ArseniyShestakov","id":9513350,"avatar_url":"https://avatars.githubusercontent.com/u/9513350?v=3","gravatar_id":"","url":"https://api.github.com/users/ArseniyShestakov","html_url":"https://github.com/ArseniyShestakov","followers_url":"https://api.github.com/users/ArseniyShestakov/followers","following_url":"https://api.github.com/users/ArseniyShestakov/following{/other_user}","gists_url":"https://api.github.com/users/ArseniyShestakov/gists{/gist_id}","starred_url":"https://api.github.com/users/ArseniyShestakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArseniyShestakov/subscriptions","organizations_url":"https://api.github.com/users/ArseniyShestakov/orgs","repos_url":"https://api.github.com/users/ArseniyShestakov/repos","events_url":"https://api.github.com/users/ArseniyShestakov/events{/privacy}","received_events_url":"https://api.github.com/users/ArseniyShestakov/received_events","type":"User","site_admin":false},"created_at":"2016-03-08T17:49:51Z","updated_at":"2016-03-08T17:49:51Z","body":"What I mean is to use \"git rebase --interactive\" and keep only needed changes in one file dropping all other commits. This is of course if you want us to merge your pull request and not just apply fix. Of course if you want your pull request merged it's shouldn't change code formatting as well.\r\n\r\nIf you work on Linux I strongly recommend to use Qt Creator if you don't want to spend much time on configuration. But if you only want one single fix applied I may commit it separately."}}