Results 1 to 8 of 8

Thread: QWidget::update() qeustion

  1. #1
    Join Date
    Mar 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy QWidget::update() qeustion

    Hi,

    I have a question about QWidget::update() function.
    I was told that when I call update(), paintEvent() will be called automatically.
    Yes, it works.

    But, sometime, segment fault proglem happens and core contents are following.
    What is the problem with calling update()?

    Do you have any idea??

    Please, help me.

    #0 miRegionOp (dest=@0x2a9c35fb70, reg1=Variable "reg1" is not available.
    ) at ../..include/QtCore../../src/corelib/tools/qrect.h:221
    #1 0x0000002a9632c5a7 in UnionRegion (reg1=0x177aa00, reg2=0x2a9cbe6d70, dest=@0x2a9c35fb70) at painting/qregion_unix.cpp:1109
    #2 0x0000002a9632c925 in QRegion::unite (this=0xc0b978, r=@0x4b40f500) at painting/qregion_unix.cpp:2678
    #3 0x0000002a962feab9 in QRegion::operator+ (this=Variable "this" is not available.
    ) at painting/qregion.h:78
    #4 0x0000002a962feb82 in QRegion::operator+= (this=0xc0b978, r=Variable "r" is not available.
    ) at painting/qregion.cpp:439
    #5 0x0000002a9632dca7 in QWidgetBackingStore::dirtyRegion (this=0xc0b970, rgn=Variable "rgn" is not available.
    ) at painting/qbackingstore.cpp:499
    #6 0x0000002a9632f1c5 in QWidget::update (this=0xbe4d40, rgn=@0x4b40f5e0) at painting/qbackingstore.cpp:904
    #7 0x0000002a9632f239 in QWidget::update (this=0xbe4d40, r=Variable "r" is not available.
    ) at painting/qbackingstore.cpp:888
    #8 0x0000002a9632f2c6 in QWidget::update (this=Variable "this" is not available.
    ) at ../..include/QtGui../../src/gui/kernel/qwidget.h:883
    #9 0x000000000046c5b2 in CUIGOCIImgStatus::UpdateValue (this=0xbe4d40, _szImgRef=0x4b410550 "2000-09-13.03-00-00", _iSlotNum=5, _enBand=ENI_GOCI_B6_BAND) at UIGOCIImgStatus.cpp:317
    Last edited by jpn; 13th March 2008 at 07:18. Reason: missing [quote] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QWidget::update() qeustion

    Are you by any chance using multiple threads in your application?
    J-P Nurmi

  3. #3
    Join Date
    Mar 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Smile Re: QWidget::update() qeustion

    Yes.

    Actually many dialogs are updated by threads.

    Is there any thing to consider to update GUI for the multiple threads?

    Thanks.

  4. #4
    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: QWidget::update() qeustion

    You can't access GUI objects (dialogs included) from within worker threads.

  5. #5
    Join Date
    Mar 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Wink Re: QWidget::update() qeustion

    I cannot understand I can't access GUIs in worker thread.

    CUIGOCIImgStatus is a class which inherits QWidget. It also includes <ui_gociimgstatus.h> generated by qmake.

    I updates by using a thread which check status of other system.
    If status is changed,
    I set values in member variables in CUIGOCIImgStatus to update , then I call updates().
    Then paintEvent() is called.
    CUIGOCIImgStatus objects is a global variable to share.
    It is created by main thread but is updated by only one other threads.

    Usually, this works well.

    but 1 out of 10, segment fault happens.

    anything wrong??

  6. #6
    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: QWidget::update() qeustion

    Quote Originally Posted by tanki95 View Post
    I cannot understand I can't access GUIs in worker thread.
    Well... you just can't.

    I updates by using a thread which check status of other system.
    If status is changed,
    I set values in member variables in CUIGOCIImgStatus to update , then I call updates().
    Sorry, that's forbidden.

    Usually, this works well.
    Yes... usually That's the key word here.

  7. #7
    Join Date
    Mar 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Smile Re: QWidget::update() qeustion

    Ok... I think I understand what you meant.

    You mean I should call 'update()' in the main GUI thread?

    But how do I call update() in the main GUI thread if the content of the GUI is changed from the other thread?

    If I use timer thread by using QTimer, it is also forbidden. right?

    Do you have any suggestion for the current my situation??

    Thank you very much for your reply.

  8. #8
    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: QWidget::update() qeustion

    Quote Originally Posted by tanki95 View Post
    You mean I should call 'update()' in the main GUI thread?
    Yes, that too.

    But how do I call update() in the main GUI thread if the content of the GUI is changed from the other thread?
    Use signals and slots or custom events.

    If I use timer thread by using QTimer, it is also forbidden. right?
    I'm not sure I understand what you mean. You can use timers in other threads.

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.