<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/117394/">https://git.reviewboard.kde.org/r/117394/</a>
     </td>
    </tr>
   </table>
   <br />




<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for KDevelop.</div>
<div>By Pavel Petrushkov.</div>










<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kdevelop
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Explanation of bug:
After CMake settings were changed file watcher starts reloading project via CMakeManager::reload. At the same time settings dialog(CMakePreferences.cpp) starts reloading same project via Project::reloadModel() after running cmakejob. Problem is that CMakeManager doesn't set project's private loading variable so reloadModel starts working and deletes project's root ProjectFolderItem(topItem). First reload still has a pointer to that deleted ProjectFolderItem and it crashes while trying to access it. These bugs: 332934, 328699, 312314 have very similar backtraces -- they all have two threads running CMakeImportJob::initialize(which are hidden in kdevcmakemanager.so) and one of them is crashing while trying to reference ProjectBaseItem::url(::path in newer versions). Also, bug happens only sometimes, that's probably because first reload manages to finish before second one starts. On faster PCs and bigger projects bug may not be detectable. Changing CMAKE_BUILD_TYPE almost always crashes my KDevelop. 

Solution suggestion:
I haven't come up with solution that doesn't look ugly so I'll just post one. Since I haven't found a public method to set project's loading var I just call Project::reloadModel() instead of creating import job manually. Project is going to be reloaded anyway so it should not break anything except it reloads 2 times now. Also doing that kind of makes CMakeManager::reload useless. Perhaps I should call reloadModel from cmakemanager only when CMakeCache.txt was changed and manual job in other cases? Anyway I need your advice on how to properly fix the problem.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Manual, KDevelop doesn't seem to crash anymore.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>projectmanagers/cmake/cmakemanager.cpp <span style="color: grey">(7a34b37)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/117394/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>




  </div>
 </body>
</html>