[DEV] work corectly with refcounting object (and remove some memory leek at close)

This commit is contained in:
Edouard DUPIN 2014-05-27 21:43:02 +02:00
parent 9b21e5c769
commit 3ec3fa00d9
33 changed files with 112 additions and 123 deletions

View File

@ -68,7 +68,7 @@ namespace appl {
/**
* @brief Basic destructor
*/
~Iterator() {
virtual ~Iterator() {
m_current = 0;
m_data = NULL;
m_value = u32char::Null;
@ -294,7 +294,7 @@ namespace appl {
static const char* const eventChangeName;
public:
Buffer();
~Buffer();
virtual ~Buffer();
private:
bool m_hasFileName; //!< when new file, the buffer has no name ==> but it might be reference with a single name ...
std::string m_fileName; //!< name of the file (with his path)

View File

@ -20,7 +20,7 @@ namespace appl {
protected:
BufferManager();
public:
~BufferManager();
virtual ~BufferManager();
private:
std::list<ewol::object::Owner<appl::Buffer>> m_list; // list of all buffer curently open
public:

View File

@ -17,7 +17,7 @@ namespace appl {
public:
// Constructeur
GlyphDecoration(const std::string& _newColorName = "no_name");
~GlyphDecoration() {
virtual ~GlyphDecoration() {
// nothing to do ...
};
private:

View File

@ -25,7 +25,7 @@ namespace appl {
m_buffer(_buffer) {
};
~dataBufferStruct() { };
virtual ~dataBufferStruct() { };
};
};
@ -51,7 +51,7 @@ class BufferView : public ewol::widget::List {
public:
// Constructeur
BufferView();
~BufferView();
virtual ~BufferView();
// Derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object);

View File

@ -165,7 +165,7 @@ MainWindows::MainWindows() {
mySizerVert2->subWidgetAdd(myTextView);
*/
// search area :
ewol::object::Shared<Search> mySearch = ewol::object::makeShared(new Search());
ewol::object::Shared<appl::widget::Search> mySearch = ewol::object::makeShared(new appl::widget::Search());
mySizerVert2->subWidgetAdd(mySearch);
mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori));

View File

@ -23,7 +23,7 @@ class MainWindows : public ewol::widget::Windows {
public:
// Constructeur
MainWindows();
~MainWindows();
virtual ~MainWindows();
private:
ewol::object::Shared<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
/**

View File

@ -28,7 +28,7 @@ const char* const l_eventWrapCb = "appl-wrap-CheckBox";
const char* const l_eventForwardCb = "appl-forward-CheckBox";
const char* const l_eventHideBt = "appl-hide-button";
Search::Search() :
appl::widget::Search::Search() :
ewol::widget::Composer(ewol::widget::Composer::file, "DATA:GUI-Search.xml"),
m_viewerManager(NULL),
m_forward(true),
@ -36,8 +36,8 @@ Search::Search() :
m_wrap(true),
m_searchEntry(NULL),
m_replaceEntry(NULL) {
addObjectType("appl::Search");
// load buffer manager:
addObjectType("appl::widget::Search");
// load buffer manager:onObjectRemove
m_viewerManager = appl::ViewerManager::keep();
// link event
registerOnEventNameWidget(this, "SEARCH:close", "pressed", l_eventHideBt);
@ -63,11 +63,11 @@ Search::Search() :
hide();
}
Search::~Search() {
appl::widget::Search::~Search() {
}
void Search::find() {
void appl::widget::Search::find() {
if (m_viewerManager == NULL) {
APPL_WARNING("No viewer manager selected!!!");
return;
@ -103,7 +103,7 @@ void Search::find() {
}
}
void Search::replace() {
void appl::widget::Search::replace() {
if (m_viewerManager == NULL) {
APPL_WARNING("No viewer manager selected!!!");
return;
@ -121,7 +121,7 @@ void Search::replace() {
}
void Search::onReceiveMessage(const ewol::object::Message& _msg) {
void appl::widget::Search::onReceiveMessage(const ewol::object::Message& _msg) {
ewol::widget::Composer::onReceiveMessage(_msg);
APPL_INFO("Search receive message : " << _msg);
if ( _msg.getMessage() == l_eventSearchEntry) {
@ -162,7 +162,7 @@ void Search::onReceiveMessage(const ewol::object::Message& _msg) {
}
}
void Search::onObjectRemove(const ewol::object::Shared<ewol::Object> _object) {
void appl::widget::Search::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) {
ewol::widget::Composer::onObjectRemove(_object);
if (_object == m_searchEntry) {
m_searchEntry.reset();

View File

@ -14,35 +14,37 @@
#include <ewol/widget/Entry.h>
#include <appl/Buffer.h>
#include <appl/Gui/ViewerManager.h>
class Search : public ewol::widget::Composer {
private:
ewol::object::Shared<appl::ViewerManager> m_viewerManager; //!< handle on the buffer manager
bool m_forward;
bool m_caseSensitive;
bool m_wrap;
ewol::object::Shared<ewol::widget::Entry> m_searchEntry;
ewol::object::Shared<ewol::widget::Entry> m_replaceEntry;
std::u32string m_searchData;
std::u32string m_replaceData;
public:
// Constructeur
Search();
~Search();
private:
/**
* @brief Find the next element that corespond at the search
*/
void find();
/**
* @brief Replace the current selected text.
*/
void replace();
public: // derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object> _removeObject);
namespace appl {
namespace widget {
class Search : public ewol::widget::Composer {
private:
ewol::object::Shared<appl::ViewerManager> m_viewerManager; //!< handle on the buffer manager
bool m_forward;
bool m_caseSensitive;
bool m_wrap;
ewol::object::Shared<ewol::widget::Entry> m_searchEntry;
ewol::object::Shared<ewol::widget::Entry> m_replaceEntry;
std::u32string m_searchData;
std::u32string m_replaceData;
public:
// Constructeur
Search();
virtual ~Search();
private:
/**
* @brief Find the next element that corespond at the search
*/
void find();
/**
* @brief Replace the current selected text.
*/
void replace();
public: // derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object);
};
};
};
#endif

View File

@ -28,7 +28,7 @@ namespace appl {
fileLine(_line) {
};
~TagListElement() {
virtual ~TagListElement() {
};
};
@ -44,7 +44,7 @@ namespace appl {
int32_t m_colorIdBackgroundSelected; //!< Color of line selected.
public:
TagFileList();
~TagFileList();
virtual ~TagFileList();
// display API :
virtual etk::Color<> getBasicBG();
uint32_t getNuberOfColomn();

View File

@ -623,7 +623,7 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) {
ewol::widget::WidgetScrolled::onReceiveMessage(_msg);
APPL_VERBOSE("receive msg: " << _msg);
// First call plugin
if (appl::textPluginManager::onReceiveMessage(*this, _msg) == true) {
if (appl::textPluginManager::onReceiveMessageViewer(*this, _msg) == true) {
markToRedraw();
return;
}

View File

@ -21,7 +21,7 @@ namespace appl {
protected:
ViewerManager();
public:
~ViewerManager();
virtual ~ViewerManager();
private:
ewol::object::Shared<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
ewol::object::Shared<appl::TextViewer> m_viewer;

View File

@ -25,14 +25,14 @@
#define HL2_DEBUG APPL_VERBOSE
void appl::Highlight::parseRules(exml::Element* _child,
std::vector<HighlightPattern*>& _mListPatern,
std::vector<std::unique_ptr<HighlightPattern>>& _mListPatern,
int32_t _level) {
// Create the patern ...
HighlightPattern *myPattern = new HighlightPattern(m_paintingProperties);
// parse under Element
myPattern->parseRules(_child, _level);
// add element in the list
_mListPatern.push_back(myPattern);
_mListPatern.push_back(std::unique_ptr<HighlightPattern>(myPattern));
}
appl::Highlight::Highlight(const std::string& _xmlFilename, const std::string& _colorFile) :
@ -101,16 +101,11 @@ appl::Highlight::Highlight(const std::string& _xmlFilename, const std::string& _
}
appl::Highlight::~Highlight() {
// clean all Element
for (int32_t iii = 0; iii < m_listHighlightPass1.size(); ++iii) {
if (m_listHighlightPass1[iii] != NULL) {
delete(m_listHighlightPass1[iii]);
m_listHighlightPass1[iii] = NULL;
}
}
// clear the compleate list
m_listHighlightPass1.clear();
// clear the compleate list
m_listHighlightPass2.clear();
// clear the compleate list
m_listExtentions.clear();
}

View File

@ -25,6 +25,7 @@ namespace appl {
};
};
#include <memory>
#include <etk/os/FSNode.h>
#include <appl/HighlightPattern.h>
#include <appl/GlyphPainting.h>
@ -39,7 +40,7 @@ namespace appl {
// Constructeur
Highlight(const std::string& _xmlFilename, const std::string& _colorFile);
public:
~Highlight();
virtual ~Highlight();
private:
std::string m_typeName; //!< descriptive string type like "C/C++"
public:
@ -61,12 +62,12 @@ namespace appl {
etk::Buffer &_buffer);
private:
void parseRules(exml::Element* _child,
std::vector<HighlightPattern*> &_mListPatern,
std::vector<std::unique_ptr<HighlightPattern>> &_mListPatern,
int32_t _level);
std::string m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
std::vector<std::string> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
std::vector<HighlightPattern*> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer)
std::vector<HighlightPattern*> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 == > When we display the buffer( only the display area (100 lines)) )
std::vector<std::unique_ptr<HighlightPattern>> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer)
std::vector<std::unique_ptr<HighlightPattern>> m_listHighlightPass2; //!< List of ALL hightlight modules (pass 2 == > When we display the buffer( only the display area (100 lines)) )
public:
/**
* @brief keep the resource pointer.

View File

@ -16,24 +16,17 @@
appl::HighlightPattern::HighlightPattern(const ewol::object::Shared<appl::GlyphPainting>& _glyphPainting) :
m_glyphPainting(_glyphPainting),
m_paternName(""),
m_regExpStart(NULL),
m_regExpStop(NULL),
m_regExpStart(nullptr),
m_regExpStop(nullptr),
m_colorName(""),
m_escapeChar(u32char::Null),
m_multiline(false),
m_level(0) {
m_regExpStart = new etk::RegExp<etk::Buffer>();
m_regExpStart = std::unique_ptr<etk::RegExp<etk::Buffer>>(new etk::RegExp<etk::Buffer>());
}
appl::HighlightPattern::~HighlightPattern() {
if (m_regExpStart != NULL) {
delete(m_regExpStart);
m_regExpStart = NULL;
}
if (m_regExpStop != NULL) {
delete(m_regExpStop);
m_regExpStop = NULL;
}
}
void appl::HighlightPattern::setPaternStart(std::string& _regExp) {
@ -44,12 +37,9 @@ void appl::HighlightPattern::setPaternStart(std::string& _regExp) {
}
void appl::HighlightPattern::setPaternStop(std::string& _regExp) {
if (m_regExpStop != NULL) {
delete(m_regExpStop);
m_regExpStop = NULL;
}
m_regExpStop.reset();
if (_regExp.size() != 0) {
m_regExpStop = new etk::RegExp<etk::Buffer>();
m_regExpStop = std::unique_ptr<etk::RegExp<etk::Buffer>>(new etk::RegExp<etk::Buffer>());
if (m_regExpStop != NULL) {
m_regExpStop->compile(_regExp);
} else {

View File

@ -33,7 +33,7 @@ namespace appl {
public:
// Constructeur
HighlightPattern(const ewol::object::Shared<appl::GlyphPainting>& _glyphPainting);
~HighlightPattern();
virtual ~HighlightPattern();
private:
std::string m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
public:
@ -44,11 +44,11 @@ namespace appl {
return m_paternName;
};
private:
etk::RegExp<etk::Buffer>* m_regExpStart; //!< Start of Regular expression
std::unique_ptr<etk::RegExp<etk::Buffer>> m_regExpStart; //!< Start of Regular expression
public:
void setPaternStart(std::string& _regExp);
private:
etk::RegExp<etk::Buffer>* m_regExpStop; //!< Stop of Regular Expression
std::unique_ptr<etk::RegExp<etk::Buffer>> m_regExpStop; //!< Stop of Regular Expression
public:
void setPaternStop(std::string& _regExp);
private:

View File

@ -186,8 +186,8 @@ namespace appl {
* @param[in] _msg Generic message.
* @return true if the event might not propagate anymore
*/
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
return false;
}
protected:

View File

@ -19,7 +19,7 @@ namespace appl {
class TextPluginAutoIndent : public appl::TextViewerPlugin {
public:
TextPluginAutoIndent();
~TextPluginAutoIndent() {
virtual ~TextPluginAutoIndent() {
// nothing to do ...
};
public:

View File

@ -34,8 +34,8 @@ void appl::TextPluginCopy::onPluginDisable(appl::TextViewer& _textDrawer) {
// TODO : unknow function ...
}
bool appl::TextPluginCopy::onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
bool appl::TextPluginCopy::onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
if (isEnable() == false) {
return false;
}

View File

@ -19,13 +19,13 @@ namespace appl {
class TextPluginCopy : public appl::TextViewerPlugin {
public:
TextPluginCopy();
~TextPluginCopy() {
virtual ~TextPluginCopy() {
// nothing to do ...
};
public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer);
virtual void onPluginDisable(appl::TextViewer& _textDrawer);
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg);
virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg);
};
};

View File

@ -168,8 +168,8 @@ void appl::TextPluginCtags::onReceiveMessage(const ewol::object::Message& _msg)
jumpFile(tmp, lineID - 1);
}
}
bool appl::TextPluginCtags::onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
if (isEnable() == false) {
return false;
}

View File

@ -36,12 +36,12 @@ namespace appl {
ewol::object::Shared<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public:
TextPluginCtags();
~TextPluginCtags();
virtual ~TextPluginCtags();
public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer);
virtual void onPluginDisable(appl::TextViewer& _textDrawer);
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg);
virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg);
// internal message :
virtual void onReceiveMessage(const ewol::object::Message& _msg);
};

View File

@ -50,13 +50,13 @@ namespace appl {
return data;
}
protected: // Wrap all element with their internal data: (do not use theses function)
bool onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
bool onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
TYPE* data = getDataRef(_textDrawer);
if (data == NULL) {
return false;
}
return onReceiveMessage(_textDrawer, _msg, *data);
return onReceiveMessageViewer(_textDrawer, _msg, *data);
}
bool onWrite(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos,
@ -88,9 +88,9 @@ namespace appl {
}
public:
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg,
TYPE& _data) {
virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg,
TYPE& _data) {
return false;
}
virtual bool onWrite(appl::TextViewer& _textDrawer,

View File

@ -35,9 +35,9 @@ void appl::TextPluginHistory::onPluginDisable(appl::TextViewer& _textDrawer) {
// TODO : unknow function ...
}
bool appl::TextPluginHistory::onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg,
appl::PluginHistoryData& _data) {
bool appl::TextPluginHistory::onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg,
appl::PluginHistoryData& _data) {
if (isEnable() == false) {
return false;
}

View File

@ -43,9 +43,9 @@ namespace appl {
public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer);
virtual void onPluginDisable(appl::TextViewer& _textDrawer);
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg,
appl::PluginHistoryData& _data);
virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg,
appl::PluginHistoryData& _data);
virtual bool onWrite(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos,
const std::string& _strData,

View File

@ -43,7 +43,7 @@ static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getListOnRemov
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>> s_list;
return s_list;
}
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getListOnReceiveMessage() {
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>>& getListonReceiveMessageViewer() {
static std::vector<ewol::object::Shared<appl::TextViewerPlugin>> s_list;
return s_list;
}
@ -63,7 +63,7 @@ void appl::textPluginManager::unInit() {
getListOnWrite().clear();
getListOnReplace().clear();
getListOnRemove().clear();
getListOnReceiveMessage().clear();
getListonReceiveMessageViewer().clear();
getListOnCursorMove().clear();
getList().clear();
}
@ -99,7 +99,7 @@ void appl::textPluginManager::addPlugin(const ewol::object::Shared<appl::TextVie
getListOnRemove().push_back(_plugin);
}
if (_plugin->isAvaillableOnReceiveMessage() == true) {
getListOnReceiveMessage().push_back(_plugin);
getListonReceiveMessageViewer().push_back(_plugin);
}
if (_plugin->isAvaillableOnCursorMove() == true) {
getListOnCursorMove().push_back(_plugin);
@ -193,13 +193,13 @@ bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer,
return false;
}
bool appl::textPluginManager::onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
for (auto &it : getListOnReceiveMessage()) {
bool appl::textPluginManager::onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
for (auto &it : getListonReceiveMessageViewer()) {
if (it == NULL) {
continue;
}
if (it->onReceiveMessage(_textDrawer, _msg) == true ) {
if (it->onReceiveMessageViewer(_textDrawer, _msg) == true ) {
return true;
}
}

View File

@ -98,8 +98,8 @@ namespace appl {
* @param[in] _msg Generic message.
* @return true if the event might not propagate anymore
*/
bool onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg);
bool onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg);
/**
* @brief Called when Cursor move of position.
* @param[in] _widget Reference on the widget caller.

View File

@ -19,7 +19,7 @@ namespace appl {
class TextPluginMultiLineTab : public appl::TextViewerPlugin {
public:
TextPluginMultiLineTab();
~TextPluginMultiLineTab() {
virtual ~TextPluginMultiLineTab() {
// nothing to do ...
};
public:

View File

@ -30,8 +30,8 @@ void appl::TextPluginRmLine::onPluginDisable(appl::TextViewer& _textDrawer) {
// TODO : unknow function ...
}
bool appl::TextPluginRmLine::onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
bool appl::TextPluginRmLine::onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
if (isEnable() == false) {
return false;
}

View File

@ -19,13 +19,13 @@ namespace appl {
class TextPluginRmLine : public appl::TextViewerPlugin {
public:
TextPluginRmLine();
~TextPluginRmLine() {
virtual ~TextPluginRmLine() {
// nothing to do ...
};
public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer);
virtual void onPluginDisable(appl::TextViewer& _textDrawer);
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg);
virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg);
};
};

View File

@ -32,8 +32,8 @@ void appl::TextPluginSelectAll::onPluginDisable(appl::TextViewer& _textDrawer) {
// TODO : unknow function ...
}
bool appl::TextPluginSelectAll::onReceiveMessage(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
bool appl::TextPluginSelectAll::onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) {
if (isEnable() == false) {
return false;
}

View File

@ -19,13 +19,13 @@ namespace appl {
class TextPluginSelectAll : public appl::TextViewerPlugin {
public:
TextPluginSelectAll();
~TextPluginSelectAll() {
virtual ~TextPluginSelectAll() {
// nothing to do ...
};
public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer);
virtual void onPluginDisable(appl::TextViewer& _textDrawer);
virtual bool onReceiveMessage(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg);
virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg);
};
};

View File

@ -39,7 +39,7 @@ namespace globals
class ParameterGlobalsGui : public ewol::widget::Sizer {
public :
ParameterGlobalsGui();
~ParameterGlobalsGui();
virtual ~ParameterGlobalsGui();
// herited function
virtual void onReceiveMessage(const ewol::object::Message& _msg);
};

View File

@ -12,6 +12,7 @@ def create(target):
# module name is 'edn' and type binary.
myModule = module.Module(__file__, 'edn', 'PACKAGE')
myModule.add_extra_compile_flags()
# add the file to compile:
myModule.add_src_file([
'appl/ctags/readtags.cpp'])