Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with thread

Problem with thread

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ruzik
    wrote on last edited by
    #1

    I want to do simple mistake search for my redactor, it is work good, but very slonly, and i set it in the separete thread
    I am programme on the VS 2008, in release search work in 70 % alright, in 30% get error(this is due to chance), and if i want to end program when search is work programm get me error
    I want to set code of thread and thread call in exceptions, but it is dont work
    When i try to complile program in debug and start of search mistake, and it is get me error
    http://hostingkartinok.com/image/01201107/23a0d9664662b4f5a9c9dd812a4f4929.png
    Here the call stack:
    http://hostingkartinok.com/image/01201107/f0429b2ad2664213931f4973a56b6432.png
    the following statement, which should be executed
    qglobal.cpp
    @template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelper(const Wrapper &p) { return p.data(); }@
    This is code of QDockWidget, where call mistake search
    @#include "searchMistakes.h"
    #include "QString"
    #include "searchMistakeThread/searchMistakeThread.h"
    #include "rizekqsseditor.h"

    #include "QDebug"

    searchMistakes::searchMistakes(QWidget *parent, Qt::WFlags flags)
    : QDockWidget(parent, flags)
    {
    thread = new searchMistakesThread;
    }

    searchMistakes::~searchMistakes()
    {
    thread->quit();
    }
    void searchMistakes::findMistakes()
    {
    try
    {
    thread->quit();
    thread->setObjects(plainTextEdit,listWidget,rqe->getOutputWindow());
    thread->setKindOfSearch(2);
    thread->start();
    connect(thread, SIGNAL(finished()), thread, SLOT(quit()));
    }
    catch(...)
    {
    qDebug() << "Error";
    }
    }@
    But the code of the thread is too big, but is it need i try reduce it and lay out it
    Advance many thanks for your help!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      It looks very much like this call:
      @
      thread->setObjects(plainTextEdit,listWidget,rqe->getOutputWindow());
      @

      points to the root of your problem: you are trying to manipulate GUI elements from your thread. You are not allowed to do that. Furtheremore, the fact that you subclassed QThread could point to you using QThread in the wrong way. Please read "this wiki article":http://developer.qt.nokia.com/wiki/Threads_Events_QObjects and see if you made any of the mistakes that were outlined there.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Ruzik
        wrote on last edited by
        #3

        I know enlish very know, but as far as I could understand this possible occur because i use direct appeal objects from main thread:
        output->addItem(tr("Start of search mistakes"));
        If i will replace this to signals and slots, is it could work write?
        As i understand it will be

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Ruzik
          wrote on last edited by
          #4

          Many thanks for your, help!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved