78 lines
2.1 KiB
C++
78 lines
2.1 KiB
C++
/** @file
|
|
* @author Edouard DUPIN
|
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
|
* @license GPL v3 (see license file)
|
|
*/
|
|
#include <ewol/context/Context.hpp>
|
|
#include <appl/debug.hpp>
|
|
#include <appl/Gui/WorkerCloseAllFile.hpp>
|
|
|
|
appl::WorkerCloseAllFile::WorkerCloseAllFile() {
|
|
addObjectType("appl::WorkerCloseAllFile");
|
|
// load buffer manager:
|
|
m_bufferManager = appl::BufferManager::create();
|
|
}
|
|
|
|
void appl::WorkerCloseAllFile::init() {
|
|
ewol::object::Worker::init();
|
|
if (m_bufferManager == null) {
|
|
APPL_ERROR("can not call unexistant buffer manager ... ");
|
|
destroy();
|
|
return;
|
|
}
|
|
// List all current open file :
|
|
for (int64_t iii=m_bufferManager->size()-1; iii>=0; --iii) {
|
|
ememory::SharedPtr<appl::Buffer> tmpBuffer = m_bufferManager->get(iii);
|
|
if (tmpBuffer == null) {
|
|
continue;
|
|
}
|
|
if (tmpBuffer->isModify() == false) {
|
|
APPL_TODO("destroy object");
|
|
tmpBuffer->destroy();
|
|
continue;
|
|
}
|
|
m_bufferNameList.pushBack(tmpBuffer->getFileName());
|
|
}
|
|
// checkif an element has something to do in the queue
|
|
if (m_bufferNameList.size() == 0) {
|
|
destroy();
|
|
return;
|
|
}
|
|
// create the worker :
|
|
m_worker = appl::WorkerCloseFile::create();
|
|
m_worker->signalCloseDone.connect(sharedFromThis(), &appl::WorkerCloseAllFile::onCallbackCloseDone);
|
|
m_worker->startAction(m_bufferNameList.front());
|
|
// remove first element :
|
|
m_bufferNameList.erase(m_bufferNameList.begin());
|
|
if (m_bufferNameList.size() == 0) {
|
|
destroy();
|
|
return;
|
|
}
|
|
}
|
|
|
|
appl::WorkerCloseAllFile::~WorkerCloseAllFile() {
|
|
APPL_ERROR("Remove Worker");
|
|
}
|
|
|
|
void appl::WorkerCloseAllFile::onCallbackCloseDone() {
|
|
if (m_bufferManager == null) {
|
|
// nothing to do in this case ==> can do nothing ...
|
|
return;
|
|
}
|
|
if (m_bufferNameList.size() == 0) {
|
|
destroy();
|
|
return;
|
|
}
|
|
// create the worker :
|
|
m_worker = appl::WorkerCloseFile::create();
|
|
m_worker->signalCloseDone.connect(sharedFromThis(), &appl::WorkerCloseAllFile::onCallbackCloseDone);
|
|
m_worker->startAction(m_bufferNameList.front());
|
|
// remove first element :
|
|
m_bufferNameList.erase(m_bufferNameList.begin());
|
|
if (m_bufferNameList.size() == 0) {
|
|
destroy();
|
|
return;
|
|
}
|
|
}
|
|
|