<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Delete QGraphicsItem-Object in mainwindow.cpp causes program crash at &quot;std::__atomic_base&lt;int&gt;::load&quot; in a file &quot;atomic_base.h&quot;]]></title><description><![CDATA[<p dir="auto">Hi!<br />
I try to delete an object of a QGraphicsItem derived class in my mainWindow (after I clicked on a delete button).<br />
The program crashes. I tried in debug mode and after my slot function (which gets executed, when I click on the delete button)</p>
<pre><code>void MainWindow::on_delete_pushButton_clicked()
{
    if(selectedItemSet){ //bool attribute
        allItems.removeOne(selectedItem); //allItems = QVector&lt;item*&gt;
        delete selectedItem;
        selectedItemSet = false;
        setUpItems();
        update();
        qDebug() &lt;&lt; "test";
    }
}
</code></pre>
<p dir="auto">ran completely through (I added a breakpoint at the last line in the function and I had to continue it), the program stops and gives me this line in a file "atomic_base.h" (not a file by me, by the framework itself):</p>
<pre><code>	return __atomic_load_n(&amp;_M_i, __m);
</code></pre>
<p dir="auto">Is this just a little classic mistake, or a bigger thing?<br />
Thanks for answers</p>
]]></description><link>https://forum.qt.io/topic/82373/delete-qgraphicsitem-object-in-mainwindow-cpp-causes-program-crash-at-std-__atomic_base-int-load-in-a-file-atomic_base-h</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Apr 2026 14:32:15 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/82373.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 14 Aug 2017 18:03:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Delete QGraphicsItem-Object in mainwindow.cpp causes program crash at &quot;std::__atomic_base&lt;int&gt;::load&quot; in a file &quot;atomic_base.h&quot; on Tue, 15 Aug 2017 08:15:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a><br />
Ok, thanks.<br />
Yes I did not call removeItem.<br />
I was focused on my vectors, because I only set up the QGraphicsView with the vectors of the items, but yep, I forgot to remove them manually.<br />
I was just a bit confused cus of the weird debug error position (atomic_base.h ...).<br />
Thanks for your help!</p>
]]></description><link>https://forum.qt.io/post/410402</link><guid isPermaLink="true">https://forum.qt.io/post/410402</guid><dc:creator><![CDATA[Niagarer]]></dc:creator><pubDate>Tue, 15 Aug 2017 08:15:52 GMT</pubDate></item><item><title><![CDATA[Reply to Delete QGraphicsItem-Object in mainwindow.cpp causes program crash at &quot;std::__atomic_base&lt;int&gt;::load&quot; in a file &quot;atomic_base.h&quot; on Tue, 15 Aug 2017 07:57:41 GMT]]></title><description><![CDATA[<p dir="auto">Also<br />
You are using<br />
QGraphicsScene::removeItem(QGraphicsItem * item);</p>
<p dir="auto">to remove them?</p>
<p dir="auto">If you just put in list while adding to scene and then later ONLY delete via list, you<br />
will have issue with the scene as it still owns them.</p>
]]></description><link>https://forum.qt.io/post/410391</link><guid isPermaLink="true">https://forum.qt.io/post/410391</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Tue, 15 Aug 2017 07:57:41 GMT</pubDate></item><item><title><![CDATA[Reply to Delete QGraphicsItem-Object in mainwindow.cpp causes program crash at &quot;std::__atomic_base&lt;int&gt;::load&quot; in a file &quot;atomic_base.h&quot; on Tue, 15 Aug 2017 07:43:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/niagarer">@<bdi>Niagarer</bdi></a> But you said that your app crashes after the slot was executed, so not in the code you shown.</p>
]]></description><link>https://forum.qt.io/post/410385</link><guid isPermaLink="true">https://forum.qt.io/post/410385</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Tue, 15 Aug 2017 07:43:07 GMT</pubDate></item><item><title><![CDATA[Reply to Delete QGraphicsItem-Object in mainwindow.cpp causes program crash at &quot;std::__atomic_base&lt;int&gt;::load&quot; in a file &quot;atomic_base.h&quot; on Tue, 15 Aug 2017 07:02:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a><br />
I did...?<br />
The code I have shown in the question is actually everything. I have a button in my window named delete_pushButton and once I click on it, it should remove an item and delete it (I stored it in selectedItem), and this is the slot that gets executed then. I don't do anything else when I click on the delete_pushButton. And this std::__atomic_base&lt;int&gt;::load is not by me, it is a framework file and the debugger stops there.<br />
What else code do you need?</p>
]]></description><link>https://forum.qt.io/post/410374</link><guid isPermaLink="true">https://forum.qt.io/post/410374</guid><dc:creator><![CDATA[Niagarer]]></dc:creator><pubDate>Tue, 15 Aug 2017 07:02:09 GMT</pubDate></item><item><title><![CDATA[Reply to Delete QGraphicsItem-Object in mainwindow.cpp causes program crash at &quot;std::__atomic_base&lt;int&gt;::load&quot; in a file &quot;atomic_base.h&quot; on Mon, 14 Aug 2017 21:17:20 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Can you share the code you use that triggers that ?</p>
]]></description><link>https://forum.qt.io/post/410316</link><guid isPermaLink="true">https://forum.qt.io/post/410316</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 14 Aug 2017 21:17:20 GMT</pubDate></item></channel></rss>