<?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[In QDBus example, new QDBusAbstractAdaptor without keeping pointer, why?]]></title><description><![CDATA[<p dir="auto">I am reading QDBus example code here, <a href="http://doc.qt.io/qt-5/qtdbus-chat-chat-cpp.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qtdbus-chat-chat-cpp.html</a>,  and I have a question.</p>
<p dir="auto">At line 71:</p>
<pre><code>// add our D-Bus interface and connect to D-Bus
new ChatAdaptor(this);
QDBusConnection::sessionBus().registerObject("/", this);
</code></pre>
<p dir="auto">In this code, this example new a ChatAdaptor but not use lvalue to keep the pointer. In my opinion, this object will be "new" into memory heap, and if we don't keep the pointer, we will never know where is the object we "new".</p>
<p dir="auto">My question is that how QDBusAbstractAdaptor do in our code, and why we don't need to keep the pointer of this object.</p>
]]></description><link>https://forum.qt.io/topic/84569/in-qdbus-example-new-qdbusabstractadaptor-without-keeping-pointer-why</link><generator>RSS for Node</generator><lastBuildDate>Wed, 07 Oct 2026 00:44:29 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/84569.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 29 Oct 2017 11:43:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to In QDBus example, new QDBusAbstractAdaptor without keeping pointer, why? on Sun, 29 Oct 2017 20:07:33 GMT]]></title><description><![CDATA[<p dir="auto">It's a custom class that you doesn't need after creating the actual obejct. That's why there's no assignment of the result from the <code>new</code> anywhere. It's parented so it won't leak memory, and it probably does all the needed <code>QObject::connect</code> calls (or similar initializations) in its constructor.</p>
]]></description><link>https://forum.qt.io/post/423215</link><guid isPermaLink="true">https://forum.qt.io/post/423215</guid><dc:creator><![CDATA[kshegunov]]></dc:creator><pubDate>Sun, 29 Oct 2017 20:07:33 GMT</pubDate></item></channel></rss>