Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, March 2002
QArray problem with QString


Message 1 in thread

Hi all,

I have a class called message that I have overloaded
the assignment
operator:
const message& operator = (const message& m )
 {
  if( &m != this )
  {
   msg = m.msg; // QString *seg faulting*
   }
  return *this;
 }

In my main program, I have something like this:
Array<message> lstMessage;
lstMessage.resize(10);
lstMessage[ID] = newMsg;

Upon the assignment operator, it's getting a seg fault
at the QString
assignment line. I know the assignment operator is
working properly because
I have tried this:
    message msg;
    msg = newMsg;
All the proper values get copied.

Why is it seg faulting?

Liming
MSVC 6, SP 5
QT 2.3.0



__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/


Message 2 in thread

Am Dienstag, 12. März 2002 20:00 schrieb Liming Tsai:
> Hi all,
>
> I have a class called message that I have overloaded
> the assignment
> operator:
> const message& operator = (const message& m )
>  {
>   if( &m != this )
>   {
>    msg = m.msg; // QString *seg faulting*
>    }
>   return *this;
>  }
>
> In my main program, I have something like this:
> Array<message> lstMessage;

Hi,

what is Array? Could it be that the resize method of the template class Array 
does only resize the array when growing and does not call the default 
constructor for the new elements? 

greetings

P.J.

> lstMessage.resize(10);
> lstMessage[ID] = newMsg;
>
> Upon the assignment operator, it's getting a seg fault
> at the QString
> assignment line. I know the assignment operator is
> working properly because
> I have tried this:
>     message msg;
>     msg = newMsg;
> All the proper values get copied.
>
> Why is it seg faulting?
>
> Liming
> MSVC 6, SP 5
> QT 2.3.0
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Try FREE Yahoo! Mail - the world's greatest free email!
> http://mail.yahoo.com/

-- 
 [ signature omitted ] 

Message 3 in thread

Opps. It's a QArray<message> lstMessage. 
When I do an assignment lstMessage[0]=newMsg, it's
segfaulting on the assignment statment for a QString.

Liming

--- "P.J. Meisch" <pjmeisch@web.de> wrote:
> Am Dienstag, 12. März 2002 20:00 schrieb Liming
> Tsai:
> > Hi all,
> >
> > I have a class called message that I have
> overloaded
> > the assignment
> > operator:
> > const message& operator = (const message& m )
> >  {
> >   if( &m != this )
> >   {
> >    msg = m.msg; // QString *seg faulting*
> >    }
> >   return *this;
> >  }
> >
> > In my main program, I have something like this:
> > Array<message> lstMessage;
> 
> Hi,
> 
> what is Array? Could it be that the resize method of
> the template class Array 
> does only resize the array when growing and does not
> call the default 
> constructor for the new elements? 
> 
> greetings
> 
> P.J.
> 
> > lstMessage.resize(10);
> > lstMessage[ID] = newMsg;
> >
> > Upon the assignment operator, it's getting a seg
> fault
> > at the QString
> > assignment line. I know the assignment operator is
> > working properly because
> > I have tried this:
> >     message msg;
> >     msg = newMsg;
> > All the proper values get copied.
> >
> > Why is it seg faulting?
> >
> > Liming
> > MSVC 6, SP 5
> > QT 2.3.0
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Try FREE Yahoo! Mail - the world's greatest free
> email!
> > http://mail.yahoo.com/
> 
> -- 
> ------------------------------------------
> P.J. Meisch
> pjmeisch@web.de
> ------------------------------------------
> 
> --
> List archive and information:
http://qt-interest.trolltech.com


__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/