Results 1 to 3 of 3

Thread: design question about MVC with multithreading

  1. #1
    Join Date
    Oct 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default design question about MVC with multithreading

    This Qt application I am working on has model view controller in main thread, while the data structure under dataModel and the data model are modified by a network working thread (basically it is getting data from server). The application crashes ramdonly. Based on my triage, it shows it crashes at some Qt deep model functions triggered by my data model modification. So I put lock on those data model functions. But now it still crashes.

    What is right design for this case? I also tried to promote data model modification to main thread, which means once data structure is changed, it emits a signal to controller, then the slot function in controller modifies the data model. This crashes too. plus this design looks weird. data structure changes model directly seems a better design, but it will keep model in working thread. I looked at a lot of model/view examples, all of them model contains data and model is not in worker thread. So none of them is my case.

    Thanks,

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: design question about MVC with multithreading

    We cannot help you with crashes. We cannot see what you are doing. Suffice to say it is likely to be null or invalid pointers or, if you are accessing data cross-thread, then locking or thread ownership issues. Run back through the backtrace and find what in your code precipitates the crash.

    Why did you feel the need to use a threaded approach at all? Qt networking doesn't require it.

  3. #3
    Join Date
    Oct 2012
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: design question about MVC with multithreading

    Sorry, I didn't make my question clear enough. my question is more about design, not my crash.
    The reason to use another thread for network communication is that the thread is also doing some other task.

    My question about design is should changed underneath data container inform controller and let controller change data model? or should changed data container inform data model directly? personally i prefer the latter. but the problem of the latter one is that the size of data model is controlled by the config setting in the gui, so data container has to get the info from controller if it controls data model, which against data containers' real functionality..

    Thanks,

Similar Threads

  1. multithreading simple question
    By qtlearner123 in forum Newbie
    Replies: 6
    Last Post: 3rd February 2012, 03:11
  2. App Design Question
    By MarkoSan in forum Newbie
    Replies: 2
    Last Post: 22nd June 2011, 08:45
  3. Design question.
    By RurouniJones in forum Newbie
    Replies: 2
    Last Post: 14th March 2010, 15:16
  4. A multithreading question
    By sepehr in forum Qt Programming
    Replies: 6
    Last Post: 2nd February 2009, 09:06
  5. Replies: 2
    Last Post: 21st February 2008, 22:35

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.