Results 1 to 9 of 9

Thread: Weird problem with translate()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: Weird problem with translate()

    This might be total unrelated observation - Storing QModelIndex is not a good idea, check the note from documentation, also hope you are not using QModelIndex _currentPatternIndex; (or any other pointer) before setting it up.

    Quote Originally Posted by Qt 4.7 Documentation
    Note: Model indexes should be used immediately and then discarded. You should not rely on indexes to remain valid after calling model functions that change the structure of the model or delete items. If you need to keep a model index over time use a QPersistentModelIndex.

  2. #2
    Join Date
    Jul 2011
    Location
    Brazil
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Weird problem with translate()

    Quote Originally Posted by Santosh Reddy View Post
    This might be total unrelated observation - Storing QModelIndex is not a good idea, check the note from documentation,
    QPersistentModelIndex was giving me some weird bugs that vanished when I started to use QModelIndex.

    Quote Originally Posted by Santosh Reddy View Post
    also hope you are not using QModelIndex _currentPatternIndex; (or any other pointer) before setting it up.
    I'm pretty sure I'm not.

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: Weird problem with translate()

    the second backtrace posted is same as first one

  4. #4
    Join Date
    Nov 2010
    Posts
    315
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanked 53 Times in 51 Posts

    Default Re: Weird problem with translate()

    1. title of topic is strange, it is almost not related to your problem. I would say proper title should be: "Class crushes when any new field is added"
    2. this kind of problems usually are result of errors in other parts of code. Problem just manifest it self in this place. There can be couple reasons: dangling pointer, wrong type cast, binary compability break (when using dlls), or some compiler cached data not updated correctly (here point 4 will help).
    3. I'm afraid that finding problem without having whole project will be quite hard
    4. did you clean project (call "make clean" or rebuild project), sometimes it helps in such cases.
    Last edited by MarekR22; 20th July 2011 at 10:35.

  5. #5
    Join Date
    Jul 2011
    Location
    Brazil
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Weird problem with translate()

    Quote Originally Posted by MarekR22 View Post
    1. title of topic is strange, it is almost not related to your problem. I would say proper title should be: "Class crushes when any new field is added"
    2. this kind of problems usually are result of errors in other parts of code. Problem just manifest it self in this place. Problem just manifest it self in this place. There can be couple reasons: dangling pointer, wrong type cast, binary compability break (when using dlls), or some compiler cached data not updated correctly (here point 4 will help).
    3. I'm afraid that finding problem without having whole project will be quite hard
    4. did you clean project (call "make clean" or rebuild project), sometimes it helps in such cases.
    1 - Noted, sorry about that. It is related to translate(), though.
    2 - Well, it never happened before and how can it be in another part of the code if I don't even use the new field?
    Still in 2, about the reasons:
    - Dangling pointer: You mean, the newly added one? If that's so, it happens with any type, even with an int, so I don't know how that can be the problem.
    - Wrong type cast: Again, if you mean the new field, it happens with any type.
    - Binary compability break (when using dlls): I was on Windows before, but it also happens on Linux.
    - Compiler cached data: I don't believe so and I'll tell you why in 4.
    3 - As I am, as well
    4 - It was one of the first things I tried, but it didn't help at all.

    Quote Originally Posted by Santosh Reddy View Post
    the second backtrace posted is same as first one
    D'oh!

    Here they are:
    When I create the new field before _ui: http://pastebin.com/1jQF8X4u
    When I create the new field after _ui and then use it somewhere in the code: http://pastebin.com/hJrG5CFf

  6. #6
    Join Date
    Jul 2011
    Location
    Brazil
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Weird problem with translate()

    Well, just reporting again to say that the cause of the problem.

    Some time ago, I changed the name of mainwindow.hpp to stimulatormainwindow.hpp, but I forgot to change the name of the #include in main.cpp and - I don't know why - to remove the old mainwindow.hpp. So, while I didn't change StimulatorMainWindow, it was fine, because the old mainwindow.hpp still remained valid.

    But when I needed to change it for real - that is, now - the problem blew up in my face.

    I feel dumb.

    Anyway, thanks to everyone that tried to help.

Similar Threads

  1. Problem with translate one element
    By Hostel in forum Newbie
    Replies: 0
    Last Post: 19th November 2010, 00:00
  2. Weird text input problem
    By zeldaknight in forum Qt Programming
    Replies: 6
    Last Post: 10th July 2010, 21:19
  3. Weird problem with QTableView::setResizeMode
    By winkle99 in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2010, 04:16
  4. weird problem in QGraphicsView / QGraphicsScene
    By Mrdata in forum Qt Programming
    Replies: 3
    Last Post: 24th November 2009, 19:26
  5. Weird problem while porting from Qt3 to Qt4
    By vermarajeev in forum Qt Programming
    Replies: 4
    Last Post: 8th August 2007, 07:51

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.