Note that there are some explanatory texts on larger screens.

plurals
  1. POShadowed Variable Issue Qt
    primarykey
    data
    text
    <p>I'm running into a problem with a break being thrown in my Qt5 application, when I'm trying to implement a DBSCAN.</p> <p>So I cracked open the debugger to try to figure out what might be causing the issue, and it says I have two copies of the same variable in scope, one called <code>index</code> and another called <code>index &lt;shadowed 1&gt;</code>. I don't understand how I could have another copy of the <code>index</code> variable in scope? They both hold 2 different values, and the one that doesn't have the <code>&lt;shadowed 1&gt;</code> part in it has members that point to memory access error locations, so I assume this is the one being used.</p> <pre><code>QMap&lt;int, Point*&gt; kDistPlot; for (int i = 0; i &lt; points-&gt;size(); i++) { Point *point = points-&gt;at(i); QMap&lt;int, Point*&gt; pointDistanceList; for (int j = 0; j &lt; points-&gt;size(); j++) { if (i == j) continue; Point *distPoint = points-&gt;at(j); int dist = distance(point, distPoint); Q_ASSERT_X(dist &gt;= 0, __FUNCTION__, "Distance can't be negative..."); pointDistanceList.insert(dist, distPoint); } QMap&lt;int, Point*&gt;::const_iterator index = pointDistanceList.begin(); index += k - 1; Point* kPoint = (*index); //this is where the error is int kDist = index.key(); kDistPlot.insert(kDist, kPoint); } </code></pre> <p>It triggers this exception, inside the QMap class:</p> <pre><code> Stopped in thread 1 by: Exception at 0x581c79e8, code: 0xc0000005: read access violation at: 0x0, flags=0x0(first chance) </code></pre> <p>Can anyone explain this? I'm thoroughly confused.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload