openframeworks / openframeworks/openFrameworks
Maybe a bug of no corresponding ofRemoveListener for ofURLFileLoaderImpl::start()
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
Hi,
I noticed an runtime exception that raised in ofURLFileLoaderImpl::update(), after I finished a correct downloading process and deleted the ofURLFileLoader instance in my object.
It seems that the framework was trying to callback the handler(ofURLFileLoaderImpl::update) which has already gone.
So I checked the source code of ofURLFileLoader.cpp, and noticed there is:
void ofURLFileLoaderImpl::start() {
if (!isThreadRunning()) {
ofAddListener(ofEvents().update, this, &ofURLFileLoaderImpl::update);
startThread();
}
}
But there isn't corresponding ofRemoveListener() anywhere.
And it seems a bug? So I've tried using ofURLFileLoader as singleton, and no error occurs, and it can also explains the above source code, the callback does always exist.
Sorry for no call stack info and I have no proper environment for testing the above guess, but if the info helps, it might be fixed after the thread ends?
Thanks a lot!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ofURLFileLoader.cpp by tracing ofURLFileLoaderImpl::start(), its update callback, and the object shutdown path. Verify whether the update listener can outlive a deleted ofURLFileLoaderImpl; done means a completed download can be destroyed without a callback into the removed object, with a reproducible test or call sequence confirming the fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100