mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2025-02-08 23:01:51 +00:00
Fix warning about object being leaked from update installer thread due to a missing autorelease pool
Allocate an NSAutoreleasePool in the updater thread and release it just before the thread exits.
This commit is contained in:
parent
ff21b77ec1
commit
214f2273b9
3 changed files with 23 additions and 0 deletions
|
@ -19,6 +19,9 @@ class UpdateDialogCocoa : public UpdateObserver
|
||||||
virtual void updateProgress(int percentage);
|
virtual void updateProgress(int percentage);
|
||||||
virtual void updateFinished();
|
virtual void updateFinished();
|
||||||
|
|
||||||
|
static void* createAutoreleasePool();
|
||||||
|
static void releaseAutoreleasePool(void* data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UpdateDialogPrivate* d;
|
UpdateDialogPrivate* d;
|
||||||
};
|
};
|
||||||
|
|
|
@ -137,4 +137,14 @@ void UpdateDialogCocoa::updateFinished()
|
||||||
waitUntilDone:false];
|
waitUntilDone:false];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* UpdateDialogCocoa::createAutoreleasePool()
|
||||||
|
{
|
||||||
|
return [[NSAutoreleasePool alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateDialogCocoa::releaseAutoreleasePool(void* arg)
|
||||||
|
{
|
||||||
|
[(id)arg release];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -20,6 +20,12 @@ void runWithUi(int argc, char** argv, UpdateInstaller* installer);
|
||||||
|
|
||||||
void runUpdaterThread(void* arg)
|
void runUpdaterThread(void* arg)
|
||||||
{
|
{
|
||||||
|
#ifdef PLATFORM_MAC
|
||||||
|
// create an autorelease pool to free any temporary objects
|
||||||
|
// created by Cocoa whilst handling notifications from the UpdateInstaller
|
||||||
|
void* pool = UpdateDialogCocoa::createAutoreleasePool();
|
||||||
|
#endif
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
UpdateInstaller* installer = static_cast<UpdateInstaller*>(arg);
|
UpdateInstaller* installer = static_cast<UpdateInstaller*>(arg);
|
||||||
|
@ -29,6 +35,10 @@ void runUpdaterThread(void* arg)
|
||||||
{
|
{
|
||||||
LOG(Error,"Unexpected exception " + std::string(ex.what()));
|
LOG(Error,"Unexpected exception " + std::string(ex.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PLATFORM_MAC
|
||||||
|
UpdateDialogCocoa::releaseAutoreleasePool(pool);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
|
Loading…
Reference in a new issue