Hello there,
thanks for advice, I changed my approach so i'm keeping shapes into a binary files like that QVector< QVector< Shape *> > i'm serializing as like that. ContentManager is a QThread class.
bool ContentManager
::load(const QString &fileName
) {
s_mutex.lock();
m_shapesFile->setFileName("c:/shapes.txt");
if (!m_shapesFile
->open
( QIODevice::ReadOnly )) { return false;
}
int boardCount;
int shapeCount;
int type;
dsFile >> sceneCount;
for (int i = 0; i < sceneCount; ++i)
{
dsFile >> shapeCount;
for (int j = 0; j < shapeCount; ++j)
{
dsFile >> type;
Shape *_s = new StrokeItem(); // TEST
dsFile >> _s; // TEST
delete _s; // TEST
}
}
qDebug() << "done";
m_shapesFile->close()
s_mutex.unlock();
return true;
}
bool ContentManager::load(const QString &fileName)
{
s_mutex.lock();
m_shapesFile->setFileName("c:/shapes.txt");
if (!m_shapesFile->open( QIODevice::ReadOnly )) {
return false;
}
QDataStream dsFile( m_shapesFile );
int boardCount;
int shapeCount;
int type;
dsFile >> sceneCount;
for (int i = 0; i < sceneCount; ++i)
{
dsFile >> shapeCount;
for (int j = 0; j < shapeCount; ++j)
{
dsFile >> type;
Shape *_s = new StrokeItem(); // TEST
dsFile >> _s; // TEST
delete _s; // TEST
}
}
qDebug() << "done";
m_shapesFile->close()
s_mutex.unlock();
return true;
}
To copy to clipboard, switch view to plain text mode
Thus, I can read whole file correct as like that. So this is the question. What i must to do in TEST step. I can send binary data through signal to GUI thread and then de-serialize that QDataStream and then add that item into Scene or i can create new Shape *_s = new ... then Sending through that item into GUI thread then directl i can add this item into scene , What do you suggest for that, or do you have another an idea ?
Bookmarks