<br><br><div class="gmail_quote">On Fri, Feb 26, 2010 at 9:35 PM, Deepayan Sarkar <span dir="ltr">&lt;<a href="mailto:deepayan.sarkar@gmail.com">deepayan.sarkar@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
This used to work before:<br>
<br>
&gt; qfile &lt;- Qt$QFile(&quot;/tmp/foo.R&quot;)<br>
&gt; stream &lt;- Qt$QTextStream(qfile)<br>
Error in qinvokeStatic(cl, name, ...) :<br>
  Unable to disambiguate method QTextStream::QTextStream<br>
<br>
but no longer. A workaround is<br>
<br>
&gt; stream &lt;- Qt$QTextStream()<br>
&gt; stream$setDevice(qfile)<br>
<br>
Similarly,<br>
<br>
&gt; Qt$QPen(Qt$QColor())<br>
Error in qinvokeStatic(cl, name, ...) :<br>
  Unable to disambiguate method QPen::QPen<br>
<br>
Any idea what might be going on?<br>
<br>
<br>
Even worse, segfaults with<br>
<br>
&gt; stream$string()<br>
<br>
 *** caught segfault ***<br>
address 0x8, cause &#39;memory not mapped&#39;<br>
<br>
Traceback:<br>
 1: .Call(qt_qinvoke, x, method, FALSE, list(...))<br>
 2: qinvoke(&lt;environment&gt;, &quot;string&quot;, ...)<br>
 3: stream$string()<br>
<br>
<br>
and with<br>
<br>
&gt; foo &lt;- &quot;foobar&quot;<br>
&gt; stream &lt;- Qt$QTextStream(foo)<br>
<br>
 *** caught segfault ***<br>
address 0x8, cause &#39;memory not mapped&#39;<br>
<br>
Traceback:<br>
 1: .Call(qt_qinvokeStatic, x, method, list(...))<br>
 2: qinvokeStatic(cl, name, ...)<br>
 3: Qt$QTextStream(foo)<br>
<br>
(But I guess this usage doesn&#39;t make sense for us.)<br>
<br></blockquote><div><br>I&#39;ve fixed most of these issues. stream$string() returns NULL, as I think it should here. Calling setString() or using the constructor above is going to be a problem. It wants a QString pointer, so it that it can make changes, which means we need to allocate a new QString on the heap. Normally, when we see a pointer like that, we (usually correctly) assume that it is a return-by-reference parameter. Allocating on the heap would be a special case, and a difficult one at that, since we would need to free the memory upon destruction of QTextStream. <br>
<br>And you&#39;re right that it does not make a lot of sense to write into a persistent string like that. Better to use QBuffer as the QIODevice.<br><br>Thus, I need to tweak the argument scoring code so that the const QByteArray&amp; constructor is chosen when given a character vector (creating a read-only stream).<br>
 <br>You can check the svn logs to see what I changed. There were 2 main problems here. The first was that the argument scoring of classes was broken. We need to score arguments in methods that are overloaded, in certain cases. There is an attempt to mimic the behavior of the compiler. This is all done via the scoreArg function template. The second problem was that I had forgotten to handle the &#39;QString*&#39; type. Smoke is configured so that QString is treated as a &quot;void pointer&quot; type, instead of a class, because most language bindings want to convert QString to a native string type. The other voidps are things like primitive pointers and template types (e.g. QList). All of these voidp&#39;s need to be handled special-cased via the typeHandlers hash.<br>
<br>Michael<br><br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
-Deepayan<br>
_______________________________________________<br>
Qtinterfaces-devel mailing list<br>
<a href="mailto:Qtinterfaces-devel@lists.r-forge.r-project.org">Qtinterfaces-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel</a><br>
</blockquote></div><br>