{"id":69,"date":"2008-03-15T17:57:14","date_gmt":"2008-03-15T15:57:14","guid":{"rendered":"http:\/\/katastrophos.net\/andre\/blog\/2008\/03\/15\/qfree-bug-in-qprocess-writetostdin\/"},"modified":"2008-12-30T18:11:45","modified_gmt":"2008-12-30T17:11:45","slug":"qfree-bug-in-qprocess-writetostdin","status":"publish","type":"post","link":"https:\/\/katastrophos.net\/andre\/blog\/2008\/03\/15\/qfree-bug-in-qprocess-writetostdin\/","title":{"rendered":"Q&#8230;\/Free: Bug in QProcess writeToStdin"},"content":{"rendered":"<p>All right, this post is just to stop somebody else&#8217;s suffering in figuring out why writing to stdin in QProcess on <a href=\"http:\/\/sourceforge.net\/project\/showfiles.php?group_id=49109&#038;package_id=42335\" target=\"_blank\">Version 3.3.x-8<\/a> of <a href=\"http:\/\/qtwin.sourceforge.net\" target=\"_blank\">Q&#8230;\/Free<\/a> doesn&#8217;t work on Windows. Well, actually it works but just for the first line you write to stdin. There is a bug in qprocess.cpp at line 730:<\/p>\n<pre name=\"code\" class=\"c++:nocontrols:firstline[727]\">\r\nvoid QProcess::writeToStdin( const QString& buf )\r\n{\r\n    QByteArray tmp = buf.local8Bit();\r\n    tmp.resize( tmp.size() - 1 ); \/\/ drop the implicit \\0\r\n    writeToStdin( tmp );\r\n}\r\n<\/pre>\n<p>should be:<\/p>\n<pre name=\"code\" class=\"c++:nocontrols:firstline[727]\">\r\nvoid QProcess::writeToStdin( const QString& buf )\r\n{\r\n    QByteArray tmp = buf.local8Bit();\r\n    tmp.resize( buf.length() );\r\n    writeToStdin( tmp );\r\n}\r\n<\/pre>\n<p>Verision 3.3.7-7 includes the latter method, same as the latest Qt 4.3 sources. So, it&#8217;s actually a regression in 3.3.x-8. If you require the latest Qt 3 \/ Q&#8230;\/Free for your open source application and need to write to some other processes&#8217; stdin, you can just use a wrapper workaround that uses the latter method and directly uses writeToStdin( const QByteArray&#038; buf ) instead of the QString variant.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>All right, this post is just to stop somebody else&#8217;s suffering in figuring out why writing to stdin in QProcess on Version 3.3.x-8 of Q&#8230;\/Free doesn&#8217;t work on Windows. Well, actually it works but just for the first line you write to stdin. There is a bug in qprocess.cpp at line 730: void QProcess::writeToStdin( const [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[20,17,19,24,15,9],"class_list":["post-69","post","type-post","status-publish","format-standard","hentry","tag-development","tag-findings","tag-hack","tag-quasar","tag-random","tag-windows"],"_links":{"self":[{"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/posts\/69"}],"collection":[{"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/comments?post=69"}],"version-history":[{"count":5,"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/posts\/69\/revisions"}],"predecessor-version":[{"id":99,"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/posts\/69\/revisions\/99"}],"wp:attachment":[{"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/media?parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/categories?post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/katastrophos.net\/andre\/blog\/wp-json\/wp\/v2\/tags?post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}