Problem with thread



  • 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!



  • 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.



  • 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



  • Many thanks for your, help!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.