mirror of https://github.com/axmolengine/axmol.git
DelegateProtocol is weak-referenced again
This commit is contained in:
parent
31a3fd65c1
commit
eda9846e6f
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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],
|
||||
|
|
Loading…
Reference in New Issue