@wysota:
thnx alot man, the first part of ur last post was the info i needed and in regard to the second part: i didnt wanted you to come up with a hundrets-of-lines example
, the point that made me suspicous about manipulating gui beyond threads was just made clear by the first part of ur comment
, thnx alot.
i ll try that.
cheers.
Added after 59 minutes:
i am still missing something i think:
my current relevant code parts in regard to the worker-thread declaration are:
// //////////////////////////////////////////
// //////////////////////////////////////////
{
Q_OBJECT
// //////////////////////////////
public:
// //////////////////////////////
~FileLoader();
signals:
protected:
void run();
// //////////////////////////////
private:
// //////////////////////////////
CLogFile logfile;
};
// //////////////////////////////////////////
class FileLoader : public QThread
// //////////////////////////////////////////
{
Q_OBJECT
// //////////////////////////////
public:
// //////////////////////////////
FileLoader(QObject *parent);
~FileLoader();
signals:
void WorkDone(QTextDocument *);
protected:
void run();
// //////////////////////////////
private:
// //////////////////////////////
CLogFile logfile;
QTextDocument *doc;
};
To copy to clipboard, switch view to plain text mode
(everytime before workerthread manipulates QTextDocument member its calling moveToThread(this) within its running method):
// //////////////////////////////////
void FileLoader::run()
// //////////////////////////////////
{
...
string content;
doc->moveToThread(this);
// manipulate doc here ...
emit WorkDone(doc);
}
// //////////////////////////////////
void FileLoader::run()
// //////////////////////////////////
{
...
string content;
doc->moveToThread(this);
QTextCursor cursor(doc);
// manipulate doc here ...
emit WorkDone(doc);
}
To copy to clipboard, switch view to plain text mode
the workerthread emits once the WorkDone(QTextDocument *) signal when work is done wich is caught by the main-threads slot
{
ui->textEdit->setDocument(doc);
}
void PutDoc(QTextDocument *doc)
{
doc->moveToThread(QApplication::instance()->thread());
ui->textEdit->setDocument(doc);
}
To copy to clipboard, switch view to plain text mode
the last line here (setDocument) fails and throws a segmentation fault which crashes my application, what am i doing wrong now !?!?
here is the trace:
http://img132.imageshack.us/f/11178576.gif/
Bookmarks