Note that there are some explanatory texts on larger screens.

plurals
  1. POFeed a QList with another
    primarykey
    data
    text
    <p>hi i'm trying to send a QList as a parameter to another class but for some reason i got a read access violation...</p> <p><strong>CompareTimeChannel.h</strong></p> <pre><code> class CompareTimeChannel : public IDataChannel public: // @brief The method used to receive the list void setData(const QList&lt; QSharedPointer&lt;core::ITrackSection&gt; &gt; &amp; sections); // @brief The list QList&lt; QSharedPointer&lt;core::ITrackSection&gt; &gt; _sections; }; </code></pre> <p><strong>CompareTimeChannel.cpp</strong></p> <pre><code> // @brief Empty constructor CompareTimeChannel::CompareTimeChannel() { } void CompareTimeChannel::setData(const QList&lt; QSharedPointer&lt;core::ITrackSection&gt; &gt; &amp; sections) { //_sections = *new QList&lt; QSharedPointer&lt;core::ITrackSection&gt; &gt; (); _sections.clear(); _sections.append(sections); } </code></pre> <p>Running this code will throw <code>Exception at 0x31cc78d, code: 0xc0000005: read access violation at: 0x4, flags=0x0</code> on <code>_sections.clear();</code></p> <p>I tried to initialize the list before (the commented line <code>_sections = *new QList&lt;...&gt;</code>) but the exception is thrown the same.</p> <p>An answer would be very appreciated...</p> <p><strong>EDIT</strong></p> <p>Ok it's fixed!</p> <p>First, like @AndreasT said, i had to initialize the default QList constructor.</p> <p>Then, according to @10WaRRioR01 's answer, the issue comes from <code>CompareTimeChannel</code> which wasn't initialized the first time the method was called. Fixed using :</p> <pre><code> CompareTimeChannel* chan = static_cast&lt;CompareTimeChannel*&gt;(channel); Q_ASSERT(chan); if (chan) { chan-&gt;setData(sections); } else { qDebug() &lt;&lt; "Dynamic cast failure"; } </code></pre> <p>Thank you all, guys!</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.
    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