diff --git a/sources/ewol/renderer/EObject.cpp b/sources/ewol/renderer/EObject.cpp index 5029807e..cd3d1bb3 100644 --- a/sources/ewol/renderer/EObject.cpp +++ b/sources/ewol/renderer/EObject.cpp @@ -144,6 +144,27 @@ void ewol::EObject::registerOnEvent(ewol::EObject * _destinationObject, m_externEvent.pushBack(tmpEvent); } +void ewol::EObject::unRegisterOnEvent(ewol::EObject * _destinationObject, + const char * _eventId) { + if (NULL == _destinationObject) { + EWOL_ERROR("Input ERROR NULL pointer EObject ..."); + return; + } + // check if event existed : + for(int64_t iii = m_externEvent.size()-1; iii >= 0; --iii) { + if (m_externEvent[iii] == NULL) { + continue; + } + if (m_externEvent[iii]->destEObject != _destinationObject) { + continue; + } + if (_eventId == NULL) { + m_externEvent.remove(iii); + } else if (m_externEvent[iii]->localEventId == _eventId) { + m_externEvent.remove(iii); + } + } +} void ewol::EObject::onObjectRemove(ewol::EObject * _removeObject) { for(int32_t iii=m_externEvent.size()-1; iii >= 0; iii--) { diff --git a/sources/ewol/renderer/EObject.h b/sources/ewol/renderer/EObject.h index b8563d05..3df30cf7 100644 --- a/sources/ewol/renderer/EObject.h +++ b/sources/ewol/renderer/EObject.h @@ -118,6 +118,13 @@ namespace ewol { const char * _eventId, const char * _eventIdgenerated = NULL, const etk::UString& _overloadData=""); + /** + * @brief Un-Register an EObject over an other. + * @param[in] _destinationObject pointer on the object that might be call when an event is generated + * @param[in] _eventId Event generate inside the object (NULL to remove all event on this object) + */ + void unRegisterOnEvent(ewol::EObject * _destinationObject, + const char * _eventId = NULL); /** * @brief Inform object that an other object is removed ... * @param[in] _removeObject Pointer on the EObject remeved == > the user must remove all reference on this EObject diff --git a/sources/ewol/resources/ResourceManager.cpp b/sources/ewol/resources/ResourceManager.cpp index c2fdc542..c3279930 100644 --- a/sources/ewol/resources/ResourceManager.cpp +++ b/sources/ewol/resources/ResourceManager.cpp @@ -189,19 +189,22 @@ bool ewol::ResourceManager::release(ewol::Resource*& _object) { } EWOL_VERBOSE("RELEASE (default) : file : \"" << _object->getName() << "\""); for (int32_t iii=m_resourceList.size()-1; iii >= 0; iii--) { - if (m_resourceList[iii] != NULL) { - if(m_resourceList[iii] == _object) { - if (true == m_resourceList[iii]->decrement()) { - // delete element - delete(m_resourceList[iii]); - // remove element from the list : - m_resourceList[iii] = NULL; - } - // insidiously remove the pointer for the caller ... - _object = NULL; - return true; - } + if (m_resourceList[iii] == NULL) { + continue; } + if(m_resourceList[iii] != _object) { + continue; + } + // insidiously remove the pointer for the caller ... + _object = NULL; + if (true == m_resourceList[iii]->decrement()) { + // delete element + delete(m_resourceList[iii]); + // remove element from the list : + m_resourceList[iii] = NULL; + return true; // object really removed + } + return false; // just decrement ... } EWOL_ERROR("Can not find the resources in the list : " << (int64_t)_object); // insidiously remove the pointer for the caller ... diff --git a/sources/ewol/resources/TexturedFont.cpp b/sources/ewol/resources/TexturedFont.cpp index 3e17ee68..d3e99b46 100644 --- a/sources/ewol/resources/TexturedFont.cpp +++ b/sources/ewol/resources/TexturedFont.cpp @@ -42,8 +42,8 @@ etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::font::mode_te& _obj) #undef __class__ #define __class__ "TexturedFont" -ewol::TexturedFont::TexturedFont(etk::UString fontName) : - ewol::Texture(fontName) { +ewol::TexturedFont::TexturedFont(const etk::UString& _fontName) : + ewol::Texture(_fontName) { m_font[0] = NULL; m_font[1] = NULL; m_font[2] = NULL; @@ -66,22 +66,22 @@ ewol::TexturedFont::TexturedFont(etk::UString fontName) : int32_t tmpSize = 0; // extarct name and size : - etk::Char tmpChar = fontName.c_str(); + etk::Char tmpChar = _fontName.c_str(); const char * tmpData = tmpChar; const char * tmpPos = strchr(tmpData, ':'); if (tmpPos == NULL) { m_size = 1; - EWOL_CRITICAL("Can not parse the font name : \"" << fontName << "\" ??? ':' " ); + EWOL_CRITICAL("Can not parse the font name : \"" << _fontName << "\" ??? ':' " ); return; } else { if (sscanf(tmpPos+1, "%d", &tmpSize)!=1) { m_size = 1; - EWOL_CRITICAL("Can not parse the font name : \"" << fontName << "\" == > size ???"); + EWOL_CRITICAL("Can not parse the font name : \"" << _fontName << "\" == > size ???"); return; } } - etk::UString localName = fontName.extract(0, (tmpPos - tmpData)); + etk::UString localName = _fontName.extract(0, (tmpPos - tmpData)); m_size = tmpSize; etk::Vector folderList; @@ -297,15 +297,6 @@ bool ewol::TexturedFont::addGlyph(const etk::UChar& _val) { return hasChange; } -bool ewol::TexturedFont::hasName(const etk::UString& _fileName) { - etk::UString tmpName = m_name; - tmpName += ":"; - tmpName += m_size; - EWOL_VERBOSE("S : check : " << _fileName << " ?= " << tmpName << " = " << (_fileName == tmpName) ); - return (_fileName == tmpName); -} - - int32_t ewol::TexturedFont::getIndex(const etk::UChar& _charcode, const ewol::font::mode_te _displayMode) { if (_charcode.get() < 0x20) { return 0; @@ -352,7 +343,7 @@ ewol::GlyphProperty* ewol::TexturedFont::getGlyphPointer(const etk::UChar& _char } ewol::TexturedFont* ewol::TexturedFont::keep(const etk::UString& _filename) { - EWOL_DEBUG("KEEP : TexturedFont : file : '" << _filename << "'"); + EWOL_VERBOSE("KEEP : TexturedFont : file : '" << _filename << "'"); ewol::TexturedFont* object = static_cast(getManager().localKeep(_filename)); if (NULL != object) { return object; @@ -373,10 +364,11 @@ void ewol::TexturedFont::release(ewol::TexturedFont*& _object) { return; } etk::UString name = _object->getName(); + int32_t count = _object->m_counter - 1; ewol::Resource* object2 = static_cast(_object); if (getManager().release(object2) == true) { - EWOL_DEBUG("REMOVE: TexturedFont : file : '" << name << "'"); - etk::displayBacktrace(false); + EWOL_DEBUG("REMOVE: TexturedFont : file : '" << name << "' count=" << count); + //etk::displayBacktrace(false); } _object = NULL; } diff --git a/sources/ewol/resources/TexturedFont.h b/sources/ewol/resources/TexturedFont.h index 76f3b2d2..517a5ff0 100644 --- a/sources/ewol/resources/TexturedFont.h +++ b/sources/ewol/resources/TexturedFont.h @@ -41,10 +41,9 @@ namespace ewol { ivec2 m_lastGlyphPos[4]; int32_t m_lastRawHeigh[4]; protected: - TexturedFont(etk::UString _fontName); + TexturedFont(const etk::UString& _fontName); ~TexturedFont(void); public: - virtual bool hasName(const etk::UString& _fileName); const char* getType(void) { return "ewol::TexturedFont"; };