[DEV] correction some internal memory leek

This commit is contained in:
Edouard DUPIN 2014-05-26 21:42:51 +02:00
parent 2157099f0a
commit 9b21e5c769
17 changed files with 74 additions and 62 deletions

View File

@ -72,12 +72,13 @@ void appl::BufferManager::setBufferSelected(ewol::object::Shared<appl::Buffer> _
sendMultiCast(appl::MsgSelectChange, ""); sendMultiCast(appl::MsgSelectChange, "");
} }
void appl::BufferManager::onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject) { void appl::BufferManager::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) {
if (m_bufferSelected == _removeObject) { ewol::Resource::onObjectRemove(_object);
if (m_bufferSelected == _object) {
setBufferSelected(NULL); setBufferSelected(NULL);
} }
for (auto it(m_list.begin()); it!=m_list.end(); ++it) { for (auto it(m_list.begin()); it!=m_list.end(); ++it) {
if (*it != _removeObject) { if (*it != _object) {
continue; continue;
} }
m_list.erase(it); m_list.erase(it);

View File

@ -218,18 +218,21 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) {
} }
} }
void BufferView::onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject) { void BufferView::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) {
ewol::widget::List::onObjectRemove(_removeObject); ewol::widget::List::onObjectRemove(_object);
for (int32_t iii=0; iii<m_list.size(); iii++) { auto it(m_list.begin());
if (m_list[iii] == NULL) { while (it != m_list.end()) {
continue; if ( *it != nullptr
&& (*it)->m_buffer == _object) {
m_list.erase(it);
markToRedraw();
it = m_list.begin();
} else {
++it;
} }
if (m_list[iii]->m_buffer != _removeObject) { }
continue; if (m_bufferManager == _object) {
} m_bufferManager.reset();
m_list.erase(m_list.begin()+iii);
markToRedraw();
return;
} }
} }

View File

@ -54,7 +54,7 @@ class BufferView : public ewol::widget::List {
~BufferView(); ~BufferView();
// Derived function // Derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject); virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object);
private: private:
bool m_openOrderMode; //!< true if the order is the opening order mode, otherwise, Alphabetic order bool m_openOrderMode; //!< true if the order is the opening order mode, otherwise, Alphabetic order
protected: protected:

View File

@ -133,18 +133,21 @@ MainWindows::MainWindows() {
m_bufferManager = appl::BufferManager::keep(); m_bufferManager = appl::BufferManager::keep();
mySizerVert = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeVert)); mySizerVert = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeVert));
mySizerVert->setName("plop 1111111");
setSubWidget(mySizerVert); setSubWidget(mySizerVert);
mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori));
mySizerHori->setName("plop 222222222");
mySizerVert->subWidgetAdd(mySizerHori); mySizerVert->subWidgetAdd(mySizerHori);
myBufferView = ewol::object::makeShared(new BufferView()); myBufferView = ewol::object::makeShared(new BufferView());
myBufferView->setName("plop 3333333");
myBufferView->setExpand(bvec2(false,true)); myBufferView->setExpand(bvec2(false,true));
myBufferView->setFill(bvec2(true,true)); myBufferView->setFill(bvec2(true,true));
mySizerHori->subWidgetAdd(myBufferView); mySizerHori->subWidgetAdd(myBufferView);
mySizerVert2 = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeVert)); mySizerVert2 = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeVert));
mySizerHori->subWidgetAdd(mySizerVert2); mySizerHori->subWidgetAdd(mySizerVert2);
mySizerVert2->setName("plop 4444444");
// main buffer Area : // main buffer Area :
#if defined(__TARGET_OS__Android) #if defined(__TARGET_OS__Android)
myTextView = ewol::object::makeShared(new appl::TextViewer("FreeMono;DejaVuSansMono;FreeSerif", 16)); myTextView = ewol::object::makeShared(new appl::TextViewer("FreeMono;DejaVuSansMono;FreeSerif", 16));
@ -166,6 +169,7 @@ MainWindows::MainWindows() {
mySizerVert2->subWidgetAdd(mySearch); mySizerVert2->subWidgetAdd(mySearch);
mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori));
mySizerHori->setName("plop 555555");
mySizerVert->subWidgetAdd(mySizerHori); mySizerVert->subWidgetAdd(mySizerHori);
myMenu = ewol::object::makeShared(new ewol::widget::Menu()); myMenu = ewol::object::makeShared(new ewol::widget::Menu());

View File

@ -162,15 +162,15 @@ void Search::onReceiveMessage(const ewol::object::Message& _msg) {
} }
} }
void Search::onObjectRemove(const ewol::object::Shared<ewol::Object> _removeObject) { void Search::onObjectRemove(const ewol::object::Shared<ewol::Object> _object) {
ewol::widget::Composer::onObjectRemove(_removeObject); ewol::widget::Composer::onObjectRemove(_object);
if (_removeObject == m_searchEntry) { if (_object == m_searchEntry) {
m_searchEntry.reset(); m_searchEntry.reset();
} }
if (_removeObject == m_replaceEntry) { if (_object == m_replaceEntry) {
m_replaceEntry.reset(); m_replaceEntry.reset();
} }
if (_removeObject == m_viewerManager) { if (_object == m_viewerManager) {
m_viewerManager.reset(); m_viewerManager.reset();
} }
} }

View File

@ -38,6 +38,7 @@ void appl::Highlight::parseRules(exml::Element* _child,
appl::Highlight::Highlight(const std::string& _xmlFilename, const std::string& _colorFile) : appl::Highlight::Highlight(const std::string& _xmlFilename, const std::string& _colorFile) :
ewol::Resource(_xmlFilename), ewol::Resource(_xmlFilename),
m_typeName("") { m_typeName("") {
addObjectType("appl::Highlight");
// keep color propertiy file : // keep color propertiy file :
m_paintingProperties = appl::GlyphPainting::keep(_colorFile); m_paintingProperties = appl::GlyphPainting::keep(_colorFile);

View File

@ -23,7 +23,7 @@ appl::TextViewerPlugin::TextViewerPlugin() :
m_activateOnRemove(false), m_activateOnRemove(false),
m_activateOnReceiveMessage(false), m_activateOnReceiveMessage(false),
m_activateOnCursorMove(false) { m_activateOnCursorMove(false) {
addObjectType("appl::TextViewerPlugin");
} }
appl::TextViewerPlugin::~TextViewerPlugin() { appl::TextViewerPlugin::~TextViewerPlugin() {

View File

@ -17,6 +17,7 @@
appl::TextPluginAutoIndent::TextPluginAutoIndent() { appl::TextPluginAutoIndent::TextPluginAutoIndent() {
m_activateOnEventEntry = true; m_activateOnEventEntry = true;
addObjectType("appl::TextPluginAutoIndent");
} }
bool appl::TextPluginAutoIndent::onEventEntry(appl::TextViewer& _textDrawer, bool appl::TextPluginAutoIndent::onEventEntry(appl::TextViewer& _textDrawer,

View File

@ -17,6 +17,7 @@
appl::TextPluginCopy::TextPluginCopy() { appl::TextPluginCopy::TextPluginCopy() {
m_activateOnReceiveMessage = true; m_activateOnReceiveMessage = true;
addObjectType("appl::TextPluginCopy");
} }
void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) { void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) {

View File

@ -25,6 +25,7 @@ appl::TextPluginCtags::TextPluginCtags() :
m_activateOnReceiveMessage = true; m_activateOnReceiveMessage = true;
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::keep(); m_bufferManager = appl::BufferManager::keep();
addObjectType("appl::TextPluginCtags");
} }
appl::TextPluginCtags::~TextPluginCtags() { appl::TextPluginCtags::~TextPluginCtags() {

View File

@ -20,6 +20,7 @@ namespace appl {
public: public:
TextViewerPluginData() { TextViewerPluginData() {
// nothing to do ... // nothing to do ...
addObjectType("appl::TextViewerPluginData");
} }
virtual ~TextViewerPluginData() { virtual ~TextViewerPluginData() {
for (size_t iii = 0; iii < m_specificData.size() ; ++iii) { for (size_t iii = 0; iii < m_specificData.size() ; ++iii) {
@ -115,9 +116,10 @@ namespace appl {
return; return;
}; };
public: public:
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject) { virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) {
appl::TextViewerPlugin::onObjectRemove(_object);
for (auto it(m_specificData.begin()); it != m_specificData.end(); ++it) { for (auto it(m_specificData.begin()); it != m_specificData.end(); ++it) {
if (it->first == _removeObject) { if (it->first == _object) {
m_specificData.erase(it); m_specificData.erase(it);
it = m_specificData.begin(); it = m_specificData.begin();
} }

View File

@ -20,6 +20,7 @@ appl::TextPluginHistory::TextPluginHistory() {
m_activateOnWrite = true; m_activateOnWrite = true;
m_activateOnReplace = true; m_activateOnReplace = true;
m_activateOnRemove = true; m_activateOnRemove = true;
addObjectType("appl::TextPluginHistory");
} }
void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) { void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) {
@ -176,7 +177,8 @@ bool appl::TextPluginHistory::onRemove(appl::TextViewer& _textDrawer,
} }
void appl::TextPluginHistory::onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject) { void appl::TextPluginHistory::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) {
appl::TextViewerPluginData<appl::PluginHistoryData>::onObjectRemove(_object);
// TODO : Dependence with buffer removing ... // TODO : Dependence with buffer removing ...
} }

View File

@ -67,7 +67,7 @@ namespace appl {
void clearRedo(appl::PluginHistoryData& _data); void clearRedo(appl::PluginHistoryData& _data);
void clearUndo(appl::PluginHistoryData& _data); void clearUndo(appl::PluginHistoryData& _data);
public: public:
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject); virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object);
}; };
}; };

View File

@ -19,8 +19,8 @@
#undef __class__ #undef __class__
#define __class__ "textPluginManager" #define __class__ "textPluginManager"
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getList() { static std::list<ewol::object::Owner<appl::TextViewerPlugin>>& getList() {
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>> s_list; static std::list<ewol::object::Owner<appl::TextViewerPlugin>> s_list;
return s_list; return s_list;
} }
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getListOnEventEntry() { static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getListOnEventEntry() {
@ -107,31 +107,30 @@ void appl::textPluginManager::addPlugin(const ewol::object::Shared<appl::TextVie
} }
void appl::textPluginManager::connect(appl::TextViewer& _widget) { void appl::textPluginManager::connect(appl::TextViewer& _widget) {
for (int32_t iii=0; iii<getList().size(); ++iii) { for (auto &it : getList()) {
if (getList()[iii] == NULL) { if (it == NULL) {
continue; continue;
} }
getList()[iii]->onPluginEnable(_widget); it->onPluginEnable(_widget);
} }
} }
void appl::textPluginManager::disconnect(appl::TextViewer& _widget) { void appl::textPluginManager::disconnect(appl::TextViewer& _widget) {
for (int32_t iii=0; iii<getList().size(); ++iii) { for (auto &it : getList()) {
if (getList()[iii] == NULL) { if (it == NULL) {
continue; continue;
} }
getList()[iii]->onPluginDisable(_widget); it->onPluginDisable(_widget);
} }
} }
bool appl::textPluginManager::onEventEntry(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onEventEntry(appl::TextViewer& _textDrawer,
const ewol::event::Entry& _event) { const ewol::event::Entry& _event) {
std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& list = getListOnEventEntry(); for (auto &it : getListOnEventEntry()) {
for (int32_t iii=0; iii<list.size(); ++iii) { if (it == NULL) {
if (list[iii] == NULL) {
continue; continue;
} }
if (list[iii]->onEventEntry(_textDrawer, _event) == true ) { if (it->onEventEntry(_textDrawer, _event) == true ) {
return true; return true;
} }
} }
@ -140,12 +139,11 @@ bool appl::textPluginManager::onEventEntry(appl::TextViewer& _textDrawer,
bool appl::textPluginManager::onEventInput(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onEventInput(appl::TextViewer& _textDrawer,
const ewol::event::Input& _event) { const ewol::event::Input& _event) {
std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& list = getListOnEventInput(); for (auto &it : getListOnEventInput()) {
for (int32_t iii=0; iii<list.size(); ++iii) { if (it == NULL) {
if (list[iii] == NULL) {
continue; continue;
} }
if (list[iii]->onEventInput(_textDrawer, _event) == true ) { if (it->onEventInput(_textDrawer, _event) == true ) {
return true; return true;
} }
} }
@ -155,12 +153,11 @@ bool appl::textPluginManager::onEventInput(appl::TextViewer& _textDrawer,
bool appl::textPluginManager::onWrite(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onWrite(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const std::string& _data) { const std::string& _data) {
std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& list = getListOnWrite(); for (auto &it : getListOnWrite()) {
for (int32_t iii=0; iii<list.size(); ++iii) { if (it == NULL) {
if (list[iii] == NULL) {
continue; continue;
} }
if (list[iii]->onWrite(_textDrawer, _pos, _data) == true ) { if (it->onWrite(_textDrawer, _pos, _data) == true ) {
return true; return true;
} }
} }
@ -171,12 +168,11 @@ bool appl::textPluginManager::onReplace(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const std::string& _data, const std::string& _data,
const appl::Buffer::Iterator& _posEnd) { const appl::Buffer::Iterator& _posEnd) {
std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& list = getListOnReplace(); for (auto &it : getListOnReplace()) {
for (int32_t iii=0; iii<list.size(); ++iii) { if (it == NULL) {
if (list[iii] == NULL) {
continue; continue;
} }
if (list[iii]->onReplace(_textDrawer, _pos, _data, _posEnd) == true ) { if (it->onReplace(_textDrawer, _pos, _data, _posEnd) == true ) {
return true; return true;
} }
} }
@ -186,12 +182,11 @@ bool appl::textPluginManager::onReplace(appl::TextViewer& _textDrawer,
bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const appl::Buffer::Iterator& _posEnd) { const appl::Buffer::Iterator& _posEnd) {
std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& list = getListOnRemove(); for (auto &it : getListOnRemove()) {
for (int32_t iii=0; iii<list.size(); ++iii) { if (it == NULL) {
if (list[iii] == NULL) {
continue; continue;
} }
if (list[iii]->onRemove(_textDrawer, _pos, _posEnd) == true ) { if (it->onRemove(_textDrawer, _pos, _posEnd) == true ) {
return true; return true;
} }
} }
@ -200,12 +195,11 @@ bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer,
bool appl::textPluginManager::onReceiveMessage(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) { const ewol::object::Message& _msg) {
std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& list = getListOnReceiveMessage(); for (auto &it : getListOnReceiveMessage()) {
for (int32_t iii=0; iii<list.size(); ++iii) { if (it == NULL) {
if (list[iii] == NULL) {
continue; continue;
} }
if (list[iii]->onReceiveMessage(_textDrawer, _msg) == true ) { if (it->onReceiveMessage(_textDrawer, _msg) == true ) {
return true; return true;
} }
} }
@ -214,12 +208,11 @@ bool appl::textPluginManager::onReceiveMessage(appl::TextViewer& _textDrawer,
bool appl::textPluginManager::onCursorMove(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onCursorMove(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos) { const appl::Buffer::Iterator& _pos) {
std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& list = getListOnCursorMove(); for (auto &it : getListOnCursorMove()) {
for (int32_t iii=0; iii<list.size(); ++iii) { if (it == NULL) {
if (list[iii] == NULL) {
continue; continue;
} }
if (list[iii]->onCursorMove(_textDrawer, _pos) == true ) { if (it->onCursorMove(_textDrawer, _pos) == true ) {
return true; return true;
} }
} }

View File

@ -16,6 +16,7 @@
appl::TextPluginMultiLineTab::TextPluginMultiLineTab() { appl::TextPluginMultiLineTab::TextPluginMultiLineTab() {
m_activateOnEventEntry = true; m_activateOnEventEntry = true;
addObjectType("appl::TextPluginMultiLineTab");
} }
bool appl::TextPluginMultiLineTab::onEventEntry(appl::TextViewer& _textDrawer, bool appl::TextPluginMultiLineTab::onEventEntry(appl::TextViewer& _textDrawer,

View File

@ -17,6 +17,7 @@
appl::TextPluginRmLine::TextPluginRmLine() { appl::TextPluginRmLine::TextPluginRmLine() {
m_activateOnReceiveMessage = true; m_activateOnReceiveMessage = true;
addObjectType("appl::TextPluginRmLine");
} }
void appl::TextPluginRmLine::onPluginEnable(appl::TextViewer& _textDrawer) { void appl::TextPluginRmLine::onPluginEnable(appl::TextViewer& _textDrawer) {

View File

@ -17,6 +17,7 @@
appl::TextPluginSelectAll::TextPluginSelectAll() { appl::TextPluginSelectAll::TextPluginSelectAll() {
m_activateOnReceiveMessage = true; m_activateOnReceiveMessage = true;
addObjectType("appl::TextPluginSelectAll");
} }
static const char* eventSelectAll = "plugin-select-all"; static const char* eventSelectAll = "plugin-select-all";