<blockquote>
<p><a href="https://github.com/codebrainz" class="user-mention">@codebrainz</a> the file_name can be null for unnamed docs, or am I wrong ?</p>
</blockquote>
<p>Yeah, I thought it was always either the filename or "untitled" (the API docs don't mention it can be <code>NULL</code>), but rather what I was thinking of was usage of <code>DOC_FILENAME()</code> macro, which gives "untitled" if <code>file_name</code> is <code>NULL</code>. This macro should probably be used in this PR, else navqueue won't work for files that aren't saved yet (or is this an existing bug?).</p>
<blockquote>
<p>NULL doc is only prevented from something hidden in the context, in this case UI sensitivity.</p>
</blockquote>
<p>That's just using different words to say "code". There's a contract established in the code that says whether a document can be <code>NULL</code> or not at a particular point in a program (for example, upon entrance to a function). If that contract is violated, a programming error has been inserted into the code, and this is exactly what an assert is meant to catch. The contract is local to this particular function, it's irrelevant where the programming error came from ultimately, the assert is just meant to catch the error quickly in this one location.</p>
<p>The error should never reach the user in a release build because any PR changing behaviour needs to check all the places affected (ex. something messing with action sensitively needs to test all of the features that rely on it). IMO, it's bad style to just make the program behave wrongly or carry on like nothing is wrong and crash later, far away from the error.</p>
<blockquote>
<p>Right, but so does simply dereferencing doc in the very next line.</p>
</blockquote>
<p>If you're lucky, that will have the same effect as an assert (except silently, without any diagnostic info, like file/line/expression) and just crash. If you're unlucky, it will do anything else. What happens is completely undefined behaviour.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/pull/1537#issuecomment-315540374">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ10nrFI6DMpyOcKibznqqfJcrsb2ks5sONXlgaJpZM4OR0zM">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJxK8ZyjFl4axiN5_Jx3o-vQhGhlLks5sONXlgaJpZM4OR0zM.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/pull/1537#issuecomment-315540374"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@codebrainz in #1537: \u003e @codebrainz the file_name can be null for unnamed docs, or am I wrong ?\r\n\r\nYeah, I thought it was always either the filename or \"untitled\" (the API docs don't mention it can be `NULL`), but rather what I was thinking of was usage of `DOC_FILENAME()` macro, which gives \"untitled\" if `file_name` is `NULL`. This macro should probably be used in this PR, else navqueue won't work for files that aren't saved yet (or is this an existing bug?).\r\n\r\n\u003e  NULL doc is only prevented from something hidden in the context, in this case UI sensitivity.\r\n\r\nThat's just using different words to say \"code\". There's a contract established in the code that says whether a document can be `NULL` or not at a particular point in a program (for example, upon entrance to a function). If that contract is violated, a programming error has been inserted into the code, and this is exactly what an assert is meant to catch. The contract is local to this particular function, it's irrelevant where the programming error came from ultimately, the assert is just meant to catch the error quickly in this one location.\r\n\r\nThe error should never reach the user in a release build because any PR changing behaviour needs to check all the places affected (ex. something messing with action sensitively needs to test all of the features that rely on it). IMO, it's bad style to just make the program behave wrongly or carry on like nothing is wrong and crash later, far away from the error.\r\n\r\n\u003e Right, but so does simply dereferencing doc in the very next line.\r\n\r\nIf you're lucky, that will have the same effect as an assert (except silently, without any diagnostic info, like file/line/expression) and just crash. If you're unlucky, it will do anything else. What happens is completely undefined behaviour."}],"action":{"name":"View Pull Request","url":"https://github.com/geany/geany/pull/1537#issuecomment-315540374"}}}</script>