<html><head><title>Qt-interest Archive - Problem with QString <-> std::string with Qt 3.1.0</title>
<style type="text/css">
<!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
-->
</style>
</head><body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="http://www.trolltech.com/">
<font color="#004faf">Trolltech Home</font></a> |
<a href="http://lists.trolltech.com/qt-interest/"> 
<font color="#004faf">Qt-interest Home</font></a> |
<a href="recent-index-0.html">
<font color="#004faf">Recent Threads</font></a> |
<a href="thread-index-0.html">
<font color="#004faf">All Threads</font></a> |
<a href="author.html">
<font color="#004faf">Author</font></a> |
<a href="date.html">
<font color="#004faf">Date</font></a>
</td>
<td align="right" valign="center"><img src="/logo32.png" align="right" width="64" height="32" border="0"></td></tr>
<tr bgcolor="#E5E5E5">
<td valign=center colspan="2">
<a href="thread-index-1.html">All threads index page 2</a>
</tr>
</table><h1 align="center">Qt-interest Archive, January 2003<br>Problem with QString <-> std::string with Qt 3.1.0</h1>

<center>Pages:  Prev | 1 | <a href="thread00220-1.html">2</a>  | <b><a href="thread00220-1.html">Next</a></b> </center>
<hr>
<a name="msg00220">Message</a> 1 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: =?vfb-8859-1?C?D=S9zl_Pnhqrg?= <onhqrgNbaqvz.se> -->
<!--X-Date: Wed, 8 Jan 2003 12:50:04 +0100 -->
<!--X-Message-Id: 003601c2b70b$e65d1b60$1e00a8c0@LORIE -->
<!--X-Content-Type: text/plain -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Rémy Baudet <<A HREF="mailto:baudet@DOMAIN.HIDDEN">baudet@xxxxxxxx</A>></li>
<li><em>Date</em>: Wed, 8 Jan 2003 12:48:45 +0100</li>
<li><em>Importance</em>: Normal</li>
<li><em>Organization</em>: Ondim</li>
<li><em>To</em>: "Qt Mailing List" <<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
Hi all,

When doing this, which is an example of the QT Quaterly Issue 4 "Qt 3.1 -- A
Better Qt" :

        QString nord = "World";
        std::string stroustrup = nord;

my app crash when deleting the std string...
I use version 3.1.0 with STL option activated.

Thanks for your help!

Rémy Baudet
ONDIM - Signal | Image | Multimédia
Email : baudet@ondim.fr
Tél. : +33.1.40.33.88.08
Fax : +33.1.40.33.65.54
Adresse : 14, rue du Soleillet - 75020 Paris

</pre>
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00280">Message</a> 2 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: Re: Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: Sevp [rgubefg <r.zrgubefgNfabj.ay> -->
<!--X-Date: Thu, 9 Jan 2003 09:26:59 +0100 -->
<!--X-Message-Id: 200301090926.49998.e.methorst@snow.nl -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 003601c2b70b$e65d1b60$1e00a8c0@LORIE -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: Re: Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Eric Methorst <<A HREF="mailto:e.methorst@DOMAIN.HIDDEN">e.methorst@xxxxxxx</A>></li>
<li><em>Date</em>: Thu, 9 Jan 2003 09:26:49 +0100</li>
<li><em>To</em>: <A HREF="mailto:baudet@DOMAIN.HIDDEN">baudet@xxxxxxxx</A>, "Qt Mailing List" <<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
On Wednesday 08 January 2003 12:48, Rémy Baudet wrote:
> Hi all,
>
> When doing this, which is an example of the QT Quaterly Issue 4 "Qt 3.1 --
> A Better Qt" :
>
>    QString nord = "World";
>    std::string stroustrup = nord;
>
> my app crash when deleting the std string...
of course it does; it's not been allocated on the heap.

should have used:
std::string* stroustrup = new std::string(nord);

> I use version 3.1.0 with STL option activated.
>
> Thanks for your help!
>
> Rémy Baudet
> ONDIM - Signal | Image | Multimédia
> Email : baudet@ondim.fr
> Tél. : +33.1.40.33.88.08
> Fax : +33.1.40.33.65.54
> Adresse : 14, rue du Soleillet - 75020 Paris
Happy coding,
Eric

</pre>
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00281">Message</a> 3 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: Re: Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: Oyrknaqre Rnebifxl <n.qnebifxvxuNpbzcnffcyhf.eh> -->
<!--X-Date: Thu, 9 Jan 2003 09:39:37 +0100 -->
<!--X-Message-Id: 1042101611.26200.7.camel@a-darovskikh -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 003601c2b70b$e65d1b60$1e00a8c0@LORIE -->
<!--X-Reference: 200301090926.49998.e.methorst@snow.nl -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: Re: Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Alexander Darovsky <<A HREF="mailto:a.darovskikh@DOMAIN.HIDDEN">a.darovskikh@xxxxxxxxxxxxxx</A>></li>
<li><em>Date</em>: 09 Jan 2003 13:40:11 +0500</li>
<li><em>To</em>: Qt Mailing List <<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
On Thu, 2003-01-09 at 13:26, Eric Methorst wrote:
> >       QString nord = "World";
> >       std::string stroustrup = nord;
> >
> > my app crash when deleting the std string...
> of course it does; it's not been allocated on the heap.

> should have used:
> std::string* stroustrup = new std::string(nord);
Hi.
But it is not true. In your example stroustrup still resides in memory
when the app is destroyed. The question is why is the string is not
copied? (As far as I see, string is deleted twice, which leads to
segfault)

</pre>
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00287">Message</a> 4 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: Re: Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: Sevp [rgubefg <r.zrgubefgNfabj.ay> -->
<!--X-Date: Thu, 9 Jan 2003 10:20:10 +0100 -->
<!--X-Message-Id: 200301091020.05677.e.methorst@snow.nl -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 003601c2b70b$e65d1b60$1e00a8c0@LORIE -->
<!--X-Reference: 200301090926.49998.e.methorst@snow.nl -->
<!--X-Reference: 1042101611.26200.7.camel@a-darovskikh -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: Re: Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Eric Methorst <<A HREF="mailto:e.methorst@DOMAIN.HIDDEN">e.methorst@xxxxxxx</A>></li>
<li><em>Date</em>: Thu, 9 Jan 2003 10:20:05 +0100</li>
<li><em>Cc</em>: "<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>" <<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>></li>
<li><em>To</em>: <A HREF="mailto:a.darovskikh@DOMAIN.HIDDEN">a.darovskikh@xxxxxxxxxxxxxx</A></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
On Thursday 09 January 2003 09:40, Alexander Darovsky wrote:
> On Thu, 2003-01-09 at 13:26, Eric Methorst wrote:
> > >  QString nord = "World";
> > >  std::string stroustrup = nord;
> > >
> > > my app crash when deleting the std string...
> >
> > of course it does; it's not been allocated on the heap.
> >
> > should have used:
> > std::string* stroustrup = new std::string(nord);
>
> Hi.
> But it is not true. In your example stroustrup still resides in memory
> when the app is destroyed. The question is why is the string is not
> copied? (As far as I see, string is deleted twice, which leads to
> segfault)
No, the question was why there is a segfault when the std::string is deleted.
Anything is deleted by using the 'delete' keyword.
Thus, the actual question stated was I do this:

QString nord = "World";
std::string stroustrup = nord
...
...
...
delete &stroustrup; // Big No-No

That is the question I answered.

As for leaving the function and then getting a crash, that happenes ones the 
std::string *leaves scope*. It is NOT deleted!

In either case, the original string "World" may not be deleted either; it's 
const char*, so each type of string should either make an internal copy, or 
mark the string as being const char*, and not owned by the string type.


Happy coding,
Eric

</pre>
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00307">Message</a> 5 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: Re: Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: Oyrknaqre Rnebifxl <n.qnebifxvxuNpbzcnffcyhf.eh> -->
<!--X-Date: Thu, 9 Jan 2003 15:26:09 +0100 -->
<!--X-Message-Id: 1042122404.26200.15.camel@a-darovskikh -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 003601c2b70b$e65d1b60$1e00a8c0@LORIE -->
<!--X-Reference: 200301090926.49998.e.methorst@snow.nl -->
<!--X-Reference: 1042101611.26200.7.camel@a-darovskikh -->
<!--X-Reference: 200301091020.05677.e.methorst@snow.nl -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: Re: Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Alexander Darovsky <<A HREF="mailto:a.darovskikh@DOMAIN.HIDDEN">a.darovskikh@xxxxxxxxxxxxxx</A>></li>
<li><em>Date</em>: 09 Jan 2003 19:26:43 +0500</li>
<li><em>To</em>: "<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>" <<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
On Thu, 2003-01-09 at 14:20, Eric Methorst wrote:
> No, the question was why there is a segfault when the std::string is
deleted.
> Anything is deleted by using the 'delete' keyword.
> Thus, the actual question stated was I do this:

> QString nord = "World";
> std::string stroustrup = nord
> ...
> ...
> ...
> delete &stroustrup; // Big No-No

> That is the question I answered.

> As for leaving the function and then getting a crash, that happenes
ones the 
> std::string *leaves scope*. It is NOT deleted!

> In either case, the original string "World" may not be deleted either;
it's 
> const char*, so each type of string should either make an internal
copy, or 
> mark the string as being const char*, and not owned by the string
type.


> Happy coding,
> Eric
Hi.
I'm afraid, I haven't spelled my thoughts correctly...
English is not my primary language...

As far as I understand the problem, program had a crash in string
destructor, whiile delete happens automatically, because it is automatic
variable and resides in the stack. The problem is, if the buffer wasn't
copied from QString to std::string with deep copy, it (buffer) is
deleted twice, leading to the segfault.

With best regards, Alex Darovsky Jr.

</pre>
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00318">Message</a> 6 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: Re: Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: Sevp [rgubefg <r.zrgubefgNfabj.ay> -->
<!--X-Date: Thu, 9 Jan 2003 20:37:14 +0100 -->
<!--X-Message-Id: 200301092037.16159.e.methorst@snow.nl -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 003601c2b70b$e65d1b60$1e00a8c0@LORIE -->
<!--X-Reference: 200301091020.05677.e.methorst@snow.nl -->
<!--X-Reference: 1042122404.26200.15.camel@a-darovskikh -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: Re: Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Eric Methorst <<A HREF="mailto:e.methorst@DOMAIN.HIDDEN">e.methorst@xxxxxxx</A>></li>
<li><em>Date</em>: Thu, 9 Jan 2003 20:37:16 +0100</li>
<li><em>To</em>: <A HREF="mailto:a.darovskikh@DOMAIN.HIDDEN">a.darovskikh@xxxxxxxxxxxxxx</A>, "<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>" <<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
On Thursday 09 January 2003 15:26, Alexander Darovsky wrote:
> On Thu, 2003-01-09 at 14:20, Eric Methorst wrote:
> > No, the question was why there is a segfault when the std::string is
>
> deleted.
>
> > Anything is deleted by using the 'delete' keyword.
> > Thus, the actual question stated was I do this:
> >
> > QString nord = "World";
> > std::string stroustrup = nord
> > ...
> > ...
> > ...
> > delete &stroustrup; // Big No-No
> >
> > That is the question I answered.
> >
> > As for leaving the function and then getting a crash, that happenes
>
> ones the
>
> > std::string *leaves scope*. It is NOT deleted!
> >
> > In either case, the original string "World" may not be deleted either;
>
> it's
>
> > const char*, so each type of string should either make an internal
>
> copy, or
>
> > mark the string as being const char*, and not owned by the string
>
> type.
>
> > Happy coding,
> > Eric
>
> Hi.
> I'm afraid, I haven't spelled my thoughts correctly...
> English is not my primary language...
>
> As far as I understand the problem, program had a crash in string
> destructor, whiile delete happens automatically, because it is automatic
> variable and resides in the stack. The problem is, if the buffer wasn't
> copied from QString to std::string with deep copy, it (buffer) is
> deleted twice, leading to the segfault.
>
> With best regards, Alex Darovsky Jr.
Alex,

Not the case;

just tested this, having QString copy-constructed with const char and the 
std::string copy-constructed with the QString.
Both on stack.

Do a cout to prove both contain same data.
Function leaves scope, no segfault.

System is SuSE 8.0, g++ 2.95.3, Qt 3.1.0
Everything works fine.

Did you try it?
Does this crash on your system?

Remy, can you show me call/stack, minimal code example that still crashes?

Happy coding,
Eric

</pre>
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00291">Message</a> 7 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: RE : Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: =?vfb-8859-1?C?D=S9zl_Pnhqrg?= <onhqrgNbaqvz.se> -->
<!--X-Date: Thu, 9 Jan 2003 10:35:00 +0100 -->
<!--X-Message-Id: 001401c2b7c2$6054bde0$1e00a8c0@LORIE -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 200301090926.49998.e.methorst@snow.nl -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: RE : Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Rémy Baudet <<A HREF="mailto:baudet@DOMAIN.HIDDEN">baudet@xxxxxxxx</A>></li>
<li><em>Date</em>: Thu, 9 Jan 2003 10:34:58 +0100</li>
<li><em>Importance</em>: Normal</li>
<li><em>Organization</em>: Ondim</li>
<li><em>To</em>: <<A HREF="mailto:e.methorst@DOMAIN.HIDDEN">e.methorst@xxxxxxx</A>>, "'Qt Mailing List'" <<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
According to the Qt documentation, and since version 3.1, when construction
a QString from a std::string, a deep copy is perform, so there is no memory
sharing and it should not have segfault... And it's working.
But from QString to std::string, I think I have to do myself the deep copy
because the std::string operator of QString doesn't do it (the method is
const => QString::operator std::string () const)?
 
Rémy
 


-----Message d'origine-----
De : owner-qt-interest@trolltech.com
[<A  HREF="mailto:owner-qt-interest@trolltech.com">mailto:owner-qt-interest@trolltech.com</A>] De la part de Eric Methorst
Envoyé : jeudi 9 janvier 2003 09:27
À : baudet@ondim.fr; Qt Mailing List
Objet : Re: Problem with QString <-> std::string with Qt 3.1.0


On Wednesday 08 January 2003 12:48, Rémy Baudet wrote:
> Hi all,
>
> When doing this, which is an example of the QT Quaterly Issue 4 "Qt 3.1 --
> A Better Qt" :
>
>    QString nord = "World";
>    std::string stroustrup = nord;
>
> my app crash when deleting the std string...
of course it does; it's not been allocated on the heap.

should have used:
std::string* stroustrup = new std::string(nord);

> I use version 3.1.0 with STL option activated.
>
> Thanks for your help!
>
> Rémy Baudet
> ONDIM - Signal | Image | Multimédia
> Email : baudet@ondim.fr
> Tél. : +33.1.40.33.88.08
> Fax : +33.1.40.33.65.54
> Adresse : 14, rue du Soleillet - 75020 Paris
Happy coding,
Eric

--
 [ signature omitted ] 
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00319">Message</a> 8 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: Re: RE : Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: Sevp [rgubefg <r.zrgubefgNfabj.ay> -->
<!--X-Date: Thu, 9 Jan 2003 20:39:46 +0100 -->
<!--X-Message-Id: 200301092039.42945.e.methorst@snow.nl -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 001401c2b7c2$6054bde0$1e00a8c0@LORIE -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: Re: RE : Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Eric Methorst <<A HREF="mailto:e.methorst@DOMAIN.HIDDEN">e.methorst@xxxxxxx</A>></li>
<li><em>Date</em>: Thu, 9 Jan 2003 20:39:42 +0100</li>
<li><em>To</em>: Rémy Baudet <<A HREF="mailto:baudet@DOMAIN.HIDDEN">baudet@xxxxxxxx</A>>, "'Qt Mailing List'" <<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
On Thursday 09 January 2003 10:34, Rémy Baudet wrote:
> According to the Qt documentation, and since version 3.1, when construction
> a QString from a std::string, a deep copy is perform, so there is no memory
> sharing and it should not have segfault... And it's working.
> But from QString to std::string, I think I have to do myself the deep copy
> because the std::string operator of QString doesn't do it (the method is
> const => QString::operator std::string () const)?
>
> Rémy
Sorry, missed this mail from you when replying to the previous one.
So again, send us a code snippet of minimal problem. I too use Qt 3.1.0, and 
it works fine for me. 
What system are you using?
Which compiler?
You have a call stack of the crash?

Happy coding,
Eric

>
>
>
> -----Message d'origine-----
> De : owner-qt-interest@trolltech.com
> [<A  HREF="mailto:owner-qt-interest@trolltech.com">mailto:owner-qt-interest@trolltech.com</A>] De la part de Eric Methorst
> Envoyé : jeudi 9 janvier 2003 09:27
> À : baudet@ondim.fr; Qt Mailing List
> Objet : Re: Problem with QString <-> std::string with Qt 3.1.0
>
> On Wednesday 08 January 2003 12:48, Rémy Baudet wrote:
> > Hi all,
> >
> > When doing this, which is an example of the QT Quaterly Issue 4 "Qt 3.1
> > -- A Better Qt" :
> >
> >       QString nord = "World";
> >       std::string stroustrup = nord;
> >
> > my app crash when deleting the std string...
>
> of course it does; it's not been allocated on the heap.
>
> should have used:
> std::string* stroustrup = new std::string(nord);
>
> > I use version 3.1.0 with STL option activated.
> >
> > Thanks for your help!
> >
> > Rémy Baudet
> > ONDIM - Signal | Image | Multimédia
> > Email : baudet@ondim.fr
> > Tél. : +33.1.40.33.88.08
> > Fax : +33.1.40.33.65.54
> > Adresse : 14, rue du Soleillet - 75020 Paris
>
> Happy coding,
> Eric

-- 
 [ signature omitted ] 
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00339">Message</a> 9 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: RE : RE : Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: =?vfb-8859-1?C?D=S9zl_Pnhqrg?= <onhqrgNbaqvz.se> -->
<!--X-Date: Fri, 10 Jan 2003 10:51:21 +0100 -->
<!--X-Message-Id: 000c01c2b88d$cfb17bd0$1e00a8c0@LORIE -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 200301092039.42945.e.methorst@snow.nl -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: RE : RE : Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Rémy Baudet <<A HREF="mailto:baudet@DOMAIN.HIDDEN">baudet@xxxxxxxx</A>></li>
<li><em>Date</em>: Fri, 10 Jan 2003 10:51:13 +0100</li>
<li><em>Importance</em>: Normal</li>
<li><em>Organization</em>: Ondim</li>
<li><em>To</em>: <<A HREF="mailto:e.methorst@DOMAIN.HIDDEN">e.methorst@xxxxxxx</A>>, "'Qt Mailing List'" <<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
Hi,

I'm using Windows XP SP1, Visual Studio 6 SP5 and Qt 3.1.0.

Here is a snippet to illustrate my problem:

#include <string>
#include <qstring.h>

int main(int argc, char* argv[])
{
        // std::string to QString
        {
                std::string stroustrup = "Hello";
                QString eng = stroustrup;
        } // No problem here

        // QString to std::string
        {
                QString nord = "World";
                std::string stroustrup = nord;
        } // Crash here...

        return 0;
}

Here is the error message:
HEAP[TestString.exe]: Invalid Address specified to RtlValidateHeap(
009D0000, 009981F0 )

And here is the call stack:
NTDLL! 77f667cd()
NTDLL! 77f5a6a0()
KERNEL32! 77e4c75a()
_CrtIsValidHeapPointer(const void * 0x00998210) line 1697
_free_dbg(void * 0x00998210, int 1) line 1044 + 9 bytes
free(void * 0x00998210) line 956 + 11 bytes
operator delete(void * 0x00998210) line 7 + 9 bytes
std::allocator<char>::deallocate(void * 0x00998210, unsigned int 33) line 64
+ 38 bytes
std::basic_string<char,std::char_traits<char>,std::allocator<char>
>::_Tidy(unsigned char 1) line 592
std::basic_string<char,std::char_traits<char>,std::allocator<char>
>::~basic_string<char,std::char_traits<char>,std::allocator<char> >() line
59 + 39 bytes
main(int 1, char * * 0x009d1140) line 20 + 12 bytes
mainCRTStartup() line 206 + 25 bytes
KERNEL32! 77e614c7()
 

Both vars contains same data.

Rémy
 


-----Message d'origine-----
De : owner-qt-interest@trolltech.com
[<A  HREF="mailto:owner-qt-interest@trolltech.com">mailto:owner-qt-interest@trolltech.com</A>] De la part de Eric Methorst
Envoyé : jeudi 9 janvier 2003 20:40
À : Rémy Baudet; 'Qt Mailing List'
Objet : Re: RE : Problem with QString <-> std::string with Qt 3.1.0


On Thursday 09 January 2003 10:34, Rémy Baudet wrote:
> According to the Qt documentation, and since version 3.1, when
construction
> a QString from a std::string, a deep copy is perform, so there is no
memory
> sharing and it should not have segfault... And it's working.
> But from QString to std::string, I think I have to do myself the deep copy
> because the std::string operator of QString doesn't do it (the method is
> const => QString::operator std::string () const)?
>
> Rémy
Sorry, missed this mail from you when replying to the previous one.
So again, send us a code snippet of minimal problem. I too use Qt 3.1.0, and

it works fine for me. 
What system are you using?
Which compiler?
You have a call stack of the crash?

Happy coding,
Eric

>
>
>
> -----Message d'origine-----
> De : owner-qt-interest@trolltech.com
> [<A  HREF="mailto:owner-qt-interest@trolltech.com">mailto:owner-qt-interest@trolltech.com</A>] De la part de Eric Methorst
> Envoyé : jeudi 9 janvier 2003 09:27
> À : baudet@ondim.fr; Qt Mailing List
> Objet : Re: Problem with QString <-> std::string with Qt 3.1.0
>
> On Wednesday 08 January 2003 12:48, Rémy Baudet wrote:
> > Hi all,
> >
> > When doing this, which is an example of the QT Quaterly Issue 4 "Qt 3.1
> > -- A Better Qt" :
> >
> >       QString nord = "World";
> >       std::string stroustrup = nord;
> >
> > my app crash when deleting the std string...
>
> of course it does; it's not been allocated on the heap.
>
> should have used:
> std::string* stroustrup = new std::string(nord);
>
> > I use version 3.1.0 with STL option activated.
> >
> > Thanks for your help!
> >
> > Rémy Baudet
> > ONDIM - Signal | Image | Multimédia
> > Email : baudet@ondim.fr
> > Tél. : +33.1.40.33.88.08
> > Fax : +33.1.40.33.65.54
> > Adresse : 14, rue du Soleillet - 75020 Paris
>
> Happy coding,
> Eric

-- 
 [ signature omitted ] 
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00342">Message</a> 10 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: Re: RE : RE : Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: Sevp [rgubefg <r.zrgubefgNfabj.ay> -->
<!--X-Date: Fri, 10 Jan 2003 11:49:55 +0100 -->
<!--X-Message-Id: 200301101149.49890.e.methorst@snow.nl -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 000c01c2b88d$cfb17bd0$1e00a8c0@LORIE -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: Re: RE : RE : Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Eric Methorst <<A HREF="mailto:e.methorst@DOMAIN.HIDDEN">e.methorst@xxxxxxx</A>></li>
<li><em>Date</em>: Fri, 10 Jan 2003 11:49:49 +0100</li>
<li><em>To</em>: Rémy Baudet <<A HREF="mailto:baudet@DOMAIN.HIDDEN">baudet@xxxxxxxx</A>>, "'Qt Mailing List'" <<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
On Friday 10 January 2003 10:51, Rémy Baudet wrote:
> Hi,
>
> I'm using Windows XP SP1, Visual Studio 6 SP5 and Qt 3.1.0.
>
> Here is a snippet to illustrate my problem:
>
> #include <string>
> #include <qstring.h>
>
> int main(int argc, char* argv[])
> {
>    // std::string to QString
>    {
>            std::string stroustrup = "Hello";
>            QString eng = stroustrup;
>    } // No problem here
>
>    // QString to std::string
>    {
>            QString nord = "World";
>            std::string stroustrup = nord;
>    } // Crash here...
>
>    return 0;
> }
This works perfectly on Linux.
You can simply check whether your QT version has been compiled with stl 
support by adding the following lines just above main:

#ifdef QT_NO_STL
#error
#endif

This should compile without errors.

Since -by the looks of the sources- Qt has no seperate implementations for 
different platforms for QString, this looks to me to be a bug in the version 
of std::string that you are using.
I think a bugreport to M$ is in order here.

Happy coding,
Eric

P.S. You might give the const char operator a chance here:
std::string stroustrup = (const char*) nord;
which may be archieved also by using the latin1() or ascii() functions in the 
QString.

>
> Here is the error message:
> HEAP[TestString.exe]: Invalid Address specified to RtlValidateHeap(
> 009D0000, 009981F0 )
>
> And here is the call stack:
> NTDLL! 77f667cd()
> NTDLL! 77f5a6a0()
> KERNEL32! 77e4c75a()
> _CrtIsValidHeapPointer(const void * 0x00998210) line 1697
> _free_dbg(void * 0x00998210, int 1) line 1044 + 9 bytes
> free(void * 0x00998210) line 956 + 11 bytes
> operator delete(void * 0x00998210) line 7 + 9 bytes
> std::allocator<char>::deallocate(void * 0x00998210, unsigned int 33) line
> 64 + 38 bytes
> std::basic_string<char,std::char_traits<char>,std::allocator<char>
>
> >::_Tidy(unsigned char 1) line 592
>
> std::basic_string<char,std::char_traits<char>,std::allocator<char>
>
> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >() line
>
> 59 + 39 bytes
> main(int 1, char * * 0x009d1140) line 20 + 12 bytes
> mainCRTStartup() line 206 + 25 bytes
> KERNEL32! 77e614c7()
>
>
> Both vars contains same data.
>
> Rémy
>
>
>
> -----Message d'origine-----
> De : owner-qt-interest@trolltech.com
> [<A  HREF="mailto:owner-qt-interest@trolltech.com">mailto:owner-qt-interest@trolltech.com</A>] De la part de Eric Methorst
> Envoyé : jeudi 9 janvier 2003 20:40
> À : Rémy Baudet; 'Qt Mailing List'
> Objet : Re: RE : Problem with QString <-> std::string with Qt 3.1.0
>
> On Thursday 09 January 2003 10:34, Rémy Baudet wrote:
> > According to the Qt documentation, and since version 3.1, when
>
> construction
>
> > a QString from a std::string, a deep copy is perform, so there is no
>
> memory
>
> > sharing and it should not have segfault... And it's working.
> > But from QString to std::string, I think I have to do myself the deep
> > copy because the std::string operator of QString doesn't do it (the
> > method is const => QString::operator std::string () const)?
> >
> > Rémy
>
> Sorry, missed this mail from you when replying to the previous one.
> So again, send us a code snippet of minimal problem. I too use Qt 3.1.0,
> and
>
> it works fine for me.
> What system are you using?
> Which compiler?
> You have a call stack of the crash?
>
> Happy coding,
> Eric
>
> > -----Message d'origine-----
> > De : owner-qt-interest@trolltech.com
> > [<A  HREF="mailto:owner-qt-interest@trolltech.com">mailto:owner-qt-interest@trolltech.com</A>] De la part de Eric Methorst
> > Envoyé : jeudi 9 janvier 2003 09:27
> > À : baudet@ondim.fr; Qt Mailing List
> > Objet : Re: Problem with QString <-> std::string with Qt 3.1.0
> >
> > On Wednesday 08 January 2003 12:48, Rémy Baudet wrote:
> > > Hi all,
> > >
> > > When doing this, which is an example of the QT Quaterly Issue 4 "Qt 3.1
> > > -- A Better Qt" :
> > >
> > >  QString nord = "World";
> > >  std::string stroustrup = nord;
> > >
> > > my app crash when deleting the std string...
> >
> > of course it does; it's not been allocated on the heap.
> >
> > should have used:
> > std::string* stroustrup = new std::string(nord);
> >
> > > I use version 3.1.0 with STL option activated.
> > >
> > > Thanks for your help!
> > >
> > > Rémy Baudet
> > > ONDIM - Signal | Image | Multimédia
> > > Email : baudet@ondim.fr
> > > Tél. : +33.1.40.33.88.08
> > > Fax : +33.1.40.33.65.54
> > > Adresse : 14, rue du Soleillet - 75020 Paris
> >
> > Happy coding,
> > Eric

-- 
 [ signature omitted ] 
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00345">Message</a> 11 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: RE : RE : RE : Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: =?vfb-8859-1?C?D=S9zl_Pnhqrg?= <onhqrgNbaqvz.se> -->
<!--X-Date: Fri, 10 Jan 2003 11:59:49 +0100 -->
<!--X-Message-Id: 002901c2b897$66ab4cb0$1e00a8c0@LORIE -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 200301101149.49890.e.methorst@snow.nl -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: RE : RE : RE : Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Rémy Baudet <<A HREF="mailto:baudet@DOMAIN.HIDDEN">baudet@xxxxxxxx</A>></li>
<li><em>Date</em>: Fri, 10 Jan 2003 11:59:48 +0100</li>
<li><em>Importance</em>: Normal</li>
<li><em>Organization</em>: Ondim</li>
<li><em>To</em>: "'Eric Methorst'" <<A HREF="mailto:e.methorst@DOMAIN.HIDDEN">e.methorst@xxxxxxx</A>>, "'Qt Mailing List'" <<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
It's working fine with the const char* operator and with latin1() or ascii()
too in this little example but crashed in my app, I'll investigate more with
your suggestions.
Thanks a lot for your help.
 
Rémy
 


-----Message d'origine-----
De : Eric Methorst [<A  HREF="mailto:e.methorst@snow.nl">mailto:e.methorst@snow.nl</A>] 
Envoyé : vendredi 10 janvier 2003 11:50
À : Rémy Baudet; 'Qt Mailing List'
Objet : Re: RE : RE : Problem with QString <-> std::string with Qt 3.1.0


On Friday 10 January 2003 10:51, Rémy Baudet wrote:
> Hi,
>
> I'm using Windows XP SP1, Visual Studio 6 SP5 and Qt 3.1.0.
>
> Here is a snippet to illustrate my problem:
>
> #include <string>
> #include <qstring.h>
>
> int main(int argc, char* argv[])
> {
>    // std::string to QString
>    {
>            std::string stroustrup = "Hello";
>            QString eng = stroustrup;
>    } // No problem here
>
>    // QString to std::string
>    {
>            QString nord = "World";
>            std::string stroustrup = nord;
>    } // Crash here...
>
>    return 0;
> }
This works perfectly on Linux.
You can simply check whether your QT version has been compiled with stl 
support by adding the following lines just above main:

#ifdef QT_NO_STL
#error
#endif

This should compile without errors.

Since -by the looks of the sources- Qt has no seperate implementations for 
different platforms for QString, this looks to me to be a bug in the version

of std::string that you are using.
I think a bugreport to M$ is in order here.

Happy coding,
Eric

P.S. You might give the const char operator a chance here:
std::string stroustrup = (const char*) nord;
which may be archieved also by using the latin1() or ascii() functions in
the 
QString.

>
> Here is the error message:
> HEAP[TestString.exe]: Invalid Address specified to RtlValidateHeap(
> 009D0000, 009981F0 )
>
> And here is the call stack:
> NTDLL! 77f667cd()
> NTDLL! 77f5a6a0()
> KERNEL32! 77e4c75a()
> _CrtIsValidHeapPointer(const void * 0x00998210) line 1697
> _free_dbg(void * 0x00998210, int 1) line 1044 + 9 bytes
> free(void * 0x00998210) line 956 + 11 bytes
> operator delete(void * 0x00998210) line 7 + 9 bytes
> std::allocator<char>::deallocate(void * 0x00998210, unsigned int 33) line
> 64 + 38 bytes
> std::basic_string<char,std::char_traits<char>,std::allocator<char>
>
> >::_Tidy(unsigned char 1) line 592
>
> std::basic_string<char,std::char_traits<char>,std::allocator<char>
>
> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >() line
>
> 59 + 39 bytes
> main(int 1, char * * 0x009d1140) line 20 + 12 bytes
> mainCRTStartup() line 206 + 25 bytes
> KERNEL32! 77e614c7()
>
>
> Both vars contains same data.
>
> Rémy
>
>
>
> -----Message d'origine-----
> De : owner-qt-interest@trolltech.com
> [<A  HREF="mailto:owner-qt-interest@trolltech.com">mailto:owner-qt-interest@trolltech.com</A>] De la part de Eric Methorst
> Envoyé : jeudi 9 janvier 2003 20:40
> À : Rémy Baudet; 'Qt Mailing List'
> Objet : Re: RE : Problem with QString <-> std::string with Qt 3.1.0
>
> On Thursday 09 January 2003 10:34, Rémy Baudet wrote:
> > According to the Qt documentation, and since version 3.1, when
>
> construction
>
> > a QString from a std::string, a deep copy is perform, so there is no
>
> memory
>
> > sharing and it should not have segfault... And it's working.
> > But from QString to std::string, I think I have to do myself the deep
> > copy because the std::string operator of QString doesn't do it (the
> > method is const => QString::operator std::string () const)?
> >
> > Rémy
>
> Sorry, missed this mail from you when replying to the previous one.
> So again, send us a code snippet of minimal problem. I too use Qt 3.1.0,
> and
>
> it works fine for me.
> What system are you using?
> Which compiler?
> You have a call stack of the crash?
>
> Happy coding,
> Eric
>
> > -----Message d'origine-----
> > De : owner-qt-interest@trolltech.com
> > [<A  HREF="mailto:owner-qt-interest@trolltech.com">mailto:owner-qt-interest@trolltech.com</A>] De la part de Eric Methorst
> > Envoyé : jeudi 9 janvier 2003 09:27
> > À : baudet@ondim.fr; Qt Mailing List
> > Objet : Re: Problem with QString <-> std::string with Qt 3.1.0
> >
> > On Wednesday 08 January 2003 12:48, Rémy Baudet wrote:
> > > Hi all,
> > >
> > > When doing this, which is an example of the QT Quaterly Issue 4 "Qt
3.1
> > > -- A Better Qt" :
> > >
> > >  QString nord = "World";
> > >  std::string stroustrup = nord;
> > >
> > > my app crash when deleting the std string...
> >
> > of course it does; it's not been allocated on the heap.
> >
> > should have used:
> > std::string* stroustrup = new std::string(nord);
> >
> > > I use version 3.1.0 with STL option activated.
> > >
> > > Thanks for your help!
> > >
> > > Rémy Baudet
> > > ONDIM - Signal | Image | Multimédia
> > > Email : baudet@ondim.fr
> > > Tél. : +33.1.40.33.88.08
> > > Fax : +33.1.40.33.65.54
> > > Adresse : 14, rue du Soleillet - 75020 Paris
> >
> > Happy coding,
> > Eric

-- 
 [ signature omitted ] 
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00340">Message</a> 12 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: Re: RE : Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: "Hbyxre Vvyfurvzre" <ibuvNgebyygrpu.pbz> -->
<!--X-Date: Fri, 10 Jan 2003 11:26:27 +0100 -->
<!--X-Message-Id: avm74i$gce$1@motorkatt.troll.no -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 200301092039.42945.e.methorst@snow.nl -->
<!--X-Reference: avm535$89j$1@motorkatt.troll.no -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: Re: RE : Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: "Volker Hilsheimer" <<A HREF="mailto:vohi@DOMAIN.HIDDEN">vohi@xxxxxxxxxxxxx</A>></li>
<li><em>Date</em>: Fri, 10 Jan 2003 11:27:27 +0100</li>
<li><em>Organization</em>: Trolltech</li>
<li><em>To</em>: <A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
Are you using different C runtime libraries in Qt and your applications (ie.
do you get a linker warning?) This would explain the heap exception. Make
sure that you don't mix up C runtime libraries (ie. use a debug Qt build
when you use a debug application build).

--
 [ signature omitted ] 
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00341">Message</a> 13 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: RE : RE : Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: =?vfb-8859-1?C?D=S9zl_Pnhqrg?= <onhqrgNbaqvz.se> -->
<!--X-Date: Fri, 10 Jan 2003 11:40:22 +0100 -->
<!--X-Message-Id: 002801c2b894$b011eab0$1e00a8c0@LORIE -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: avm74i$gce$1@motorkatt.troll.no -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: RE : RE : Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Rémy Baudet <<A HREF="mailto:baudet@DOMAIN.HIDDEN">baudet@xxxxxxxx</A>></li>
<li><em>Date</em>: Fri, 10 Jan 2003 11:40:26 +0100</li>
<li><em>Importance</em>: Normal</li>
<li><em>Organization</em>: Ondim</li>
<li><em>To</em>: <<A HREF="mailto:vohi@DOMAIN.HIDDEN">vohi@xxxxxxxxxxxxx</A>>, <<A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A>></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
I see what you mean, there is no warning at link time but actually I'm using
a Release version of Qt in both the Debug and Release version of my app.
The problem still appear when both Qt and my app are in Release build...
 
Rémy
 


-----Message d'origine-----
De : owner-qt-interest@trolltech.com
[<A  HREF="mailto:owner-qt-interest@trolltech.com">mailto:owner-qt-interest@trolltech.com</A>] De la part de Volker Hilsheimer
Envoyé : vendredi 10 janvier 2003 11:27
À : qt-interest@trolltech.com
Objet : Re: RE : Problem with QString <-> std::string with Qt 3.1.0


Are you using different C runtime libraries in Qt and your applications (ie.
do you get a linker warning?) This would explain the heap exception. Make
sure that you don't mix up C runtime libraries (ie. use a debug Qt build
when you use a debug application build).

--
 [ signature omitted ] 
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00344">Message</a> 14 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: Re: RE : Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: Sevp [rgubefg <r.zrgubefgNfabj.ay> -->
<!--X-Date: Fri, 10 Jan 2003 11:53:47 +0100 -->
<!--X-Message-Id: 200301101153.44290.e.methorst@snow.nl -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 200301092039.42945.e.methorst@snow.nl -->
<!--X-Reference: avm535$89j$1@motorkatt.troll.no -->
<!--X-Reference: avm74i$gce$1@motorkatt.troll.no -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: Re: RE : Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: Eric Methorst <<A HREF="mailto:e.methorst@DOMAIN.HIDDEN">e.methorst@xxxxxxx</A>></li>
<li><em>Date</em>: Fri, 10 Jan 2003 11:53:44 +0100</li>
<li><em>To</em>: <A HREF="mailto:vohi@DOMAIN.HIDDEN">vohi@xxxxxxxxxxxxx</A>, <A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
On Friday 10 January 2003 11:27, Volker Hilsheimer wrote:
> Are you using different C runtime libraries in Qt and your applications
> (ie. do you get a linker warning?) This would explain the heap exception.
> Make sure that you don't mix up C runtime libraries (ie. use a debug Qt
> build when you use a debug application build).

Why would that cause a problem on windows?
You mean to say one can't mix libs that are compiled with and without debug 
support on M$ platform?

Happy coding,
Eric

</pre>
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<a name="msg00350">Message</a> 15 in thread<p>
<!-- MHonArc v2.5.2 -->
<!--X-Subject: Re: RE : Problem with QString <-> std::string with Qt 3.1.0 -->
<!--X-From-R13: "Hbyxre Vvyfurvzre" <ibuvNgebyygrpu.pbz> -->
<!--X-Date: Fri, 10 Jan 2003 13:13:45 +0100 -->
<!--X-Message-Id: avmddp$3kk$1@motorkatt.troll.no -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: 200301092039.42945.e.methorst@snow.nl -->
<!--X-Reference: avm535$89j$1@motorkatt.troll.no -->
<!--X-Reference: avm74i$gce$1@motorkatt.troll.no -->
<!--X-Reference: 200301101153.44290.e.methorst@snow.nl -->
<!--X-Head-End-->

<!--X-Body-Begin-->
<!--X-User-Header-->

<!--X-User-Header-End-->
<!--X-TopPNI-->


<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->

<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<ul>
<li><em>Subject</em>: Re: RE : Problem with QString <-> std::string with Qt 3.1.0</li>
<li><em>From</em>: "Volker Hilsheimer" <<A HREF="mailto:vohi@DOMAIN.HIDDEN">vohi@xxxxxxxxxxxxx</A>></li>
<li><em>Date</em>: Fri, 10 Jan 2003 13:14:46 +0100</li>
<li><em>Organization</em>: Trolltech</li>
<li><em>To</em>: <A HREF="mailto:qt-interest@DOMAIN.HIDDEN">qt-interest@xxxxxxxxxxxxx</A></li>
</ul>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<p>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<pre>
Linking against different C runtimes will pull in different C runtime
instances into the process (ie. the release C runtime from Qt, and the debug
C runtime from the application). Every C runtime instance manages it's own
heap, and can only delete objects on the same heap that they have been
allocated on. If you delete an object from a different heap (ie. that has
been allocated using operator new of a different C runtime instance) you
will get the exception (if you have the CRT code installed, see the comments
in the function the assert fails in).

--
 [ signature omitted ] 
</pre>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->


<!--X-BotPNI-End-->
<!--X-User-Footer-->

<!--X-User-Footer-End-->

<center>Pages:  Prev | 1 | <a href="thread00220-1.html">2</a>  | <b><a href="thread00220-1.html">Next</a></b> </center>
</body></html>