In the Main GUI, I create an instance of DoThis GUI and pass a pointer to each tab that is created.
Each tab then passes that pointer to its QThread
PSUEDOCODE:
Each Tab's QThread Run Method:
run{
// create new objects
object_1 = new object1;
object_2 = new object2;
//each of these signals is called once per request
connect(object2,signal,object1,slot)
connect(object1,signal,object2,slot)
connect(DoThis,signal,object1,slot)
connect(object1,signal,DoThis,slot)
object2->startTCPListener();
object2->startUDPListener();
exec();
//disconnect and delete everything
}
PSUEDOCODE:
Each Tab's QThread Run Method:
run{
// create new objects
object_1 = new object1;
object_2 = new object2;
//each of these signals is called once per request
connect(object2,signal,object1,slot)
connect(object1,signal,object2,slot)
connect(DoThis,signal,object1,slot)
connect(object1,signal,DoThis,slot)
object2->startTCPListener();
object2->startUDPListener();
exec();
//disconnect and delete everything
}
To copy to clipboard, switch view to plain text mode
Object1 then has a slot like the following:
readwriteLocker.lockforWrite();
listofObjects->add(new File_Thread);
uniqueID = // a new unique ID
listofObjects->at(listofObjects->count()-1)->setUniqueID(uniqueID);
readwriteLocker.unlock()
readwriteLocker.lockforRead()
for(int i=0; listofObjects->count()>i ; i++)
{
if(listofObjects->at(i)->uniqueID == uniqueID)
{
listofObjects->at(i)->start();
}
}
readwriteLocker.unlock()
readwriteLocker.lockforWrite();
listofObjects->add(new File_Thread);
uniqueID = // a new unique ID
listofObjects->at(listofObjects->count()-1)->setUniqueID(uniqueID);
readwriteLocker.unlock()
readwriteLocker.lockforRead()
for(int i=0; listofObjects->count()>i ; i++)
{
if(listofObjects->at(i)->uniqueID == uniqueID)
{
listofObjects->at(i)->start();
}
}
readwriteLocker.unlock()
To copy to clipboard, switch view to plain text mode
The File_Thread finished signal is connected to a similar function that deletes the object.
Here is what the File_Thread run method looks like:
run{
booleanRunning = true;
find_File(); //This is where everything is done, emits, io accesses, everything
//This is also where the gui slows down and becomes unresponsive
booleanRunning = false;
}
run{
booleanRunning = true;
find_File(); //This is where everything is done, emits, io accesses, everything
//This is also where the gui slows down and becomes unresponsive
booleanRunning = false;
}
To copy to clipboard, switch view to plain text mode
Thank You all for your interest and help.
I hope this makes the problem more clear.
Bookmarks