DelegateProtocol is weak-referenced again

This commit is contained in:
성낙호 2013-08-08 18:36:56 +09:00
parent 31a3fd65c1
commit eda9846e6f
3 changed files with 9 additions and 16 deletions

View File

@ -83,6 +83,7 @@ AssetsManager::AssetsManager(const char* packageUrl/* =NULL */, const char* vers
, _connectionTimeout(0)
, _delegate(NULL)
, _isDownloading(false)
, _shouldDeleteDelegateWhenExit(false)
{
checkStoragePath();
_schedule = new Helper();
@ -90,14 +91,14 @@ AssetsManager::AssetsManager(const char* packageUrl/* =NULL */, const char* vers
AssetsManager::~AssetsManager()
{
if (_delegate)
{
_delegate->release();
}
if (_schedule)
{
_schedule->release();
}
if (_shouldDeleteDelegateWhenExit)
{
delete _delegate;
}
}
void AssetsManager::checkStoragePath()
@ -505,17 +506,7 @@ void AssetsManager::deleteVersion()
void AssetsManager::setDelegate(AssetsManagerDelegateProtocol *delegate)
{
if (_delegate)
{
_delegate->release();
}
_delegate = delegate;
if (_delegate)
{
_delegate->retain();
}
}
void AssetsManager::setConnectionTimeout(unsigned int timeout)
@ -661,8 +652,8 @@ AssetsManager* AssetsManager::create(const char* packageUrl, const char* version
auto* manager = new AssetsManager(packageUrl,versionFileUrl,storagePath);
auto* delegate = new DelegateProtocolImpl(errorCallback,progressCallback,successCallback);
delegate->autorelease();
manager->setDelegate(delegate);
manager->_shouldDeleteDelegateWhenExit = true;
return manager;
}

View File

@ -211,12 +211,13 @@ private:
AssetsManagerDelegateProtocol *_delegate;
bool _isDownloading;
bool _shouldDeleteDelegateWhenExit;
std::string key_of_version() const;
std::string key_of_downloaded_version() const;
};
class AssetsManagerDelegateProtocol : public Object
class AssetsManagerDelegateProtocol
{
public:
/* @brief Call back function for error

View File

@ -44,6 +44,7 @@ skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getC
EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler],
TableView::[create (g|s)etDataSource$ (g|s)etDelegate],
AssetsManager::[setDelegate],
AssetsManagerDelegateProtocol::[*],
Control::[removeHandleOfControlEvent addHandleOfControlEvent]
rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager],