Results 1 to 5 of 5

Thread: QList<myObject*> myObjectList count() error

  1. #1
    Join Date
    May 2006
    Posts
    9
    Thanks
    1

    Default QList<myObject*> myObjectList count() error

    I have a problem with a QList of object pointers.

    If I use the function count() before I have inserted any myObject* pointers then I get the following error:

    Program received signal SIGSEGV, Segmentation fault.

    0x0044866a in QListData::size() const (this=0x18)

    at C:/cpp/qt4.2.1/include/QtCore/../../src/corelib/tools/qlist.h:66


    When debugging I can see the fails at the following statement:
    inline int size() const { return d->end - d->begin; }
    in qlist.h

    Have anyone got any suggestions to a work around?

    Morty

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QList<myObject*> myObjectList count() error

    Can you post your code which leads to such error?

  3. #3
    Join Date
    May 2006
    Posts
    9
    Thanks
    1

    Default Re: QList<myObject*> myObjectList count() error

    Hi,

    I made a very simple test program that has a QList of pointers to QImage objects. When testing it by calling QList::count() before adding any objects, then I did not have any problems!!!

    So now I'm debugging and debugging and debugging...

    Morty

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QList<myObject*> myObjectList count() error

    Quote Originally Posted by morty View Post
    0x0044866a in QListData::size() const (this=0x18)
    "this" has a quite low value, so you might have a null pointer somewhere.

  5. #5
    Join Date
    Sep 2006
    Posts
    46
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QList<myObject*> myObjectList count() error

    Quote Originally Posted by morty View Post
    I have a problem with a QList of object pointers.

    If I use the function count() before I have inserted any myObject* pointers then I get the following error:

    Program received signal SIGSEGV, Segmentation fault.

    0x0044866a in QListData::size() const (this=0x18)

    at C:/cpp/qt4.2.1/include/QtCore/../../src/corelib/tools/qlist.h:66


    When debugging I can see the fails at the following statement:
    inline int size() const { return d->end - d->begin; }
    in qlist.h

    Have anyone got any suggestions to a work around?

    Morty
    It would add an extra check but you could just use a QList::isEmpty call before you made the call to count on an emtpy list and return 0 yourself.

    Edit: Overlooked the didn't produce the same results in a trivial test post
    Last edited by merlvingian; 20th October 2006 at 15:11. Reason: :D

Similar Threads

  1. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 24th August 2006, 23:31
  2. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  3. Problems
    By euthymos in forum Installation and Deployment
    Replies: 2
    Last Post: 13th June 2006, 19:11
  4. Fed up with M$ Window$ !!! Why is Tux leaving me alone???
    By fullmetalcoder in forum General Discussion
    Replies: 35
    Last Post: 18th March 2006, 12:57
  5. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 12:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.