Allocate the default UrlContext as a BReferenceable
BUrlContext now inherits BReferenceable to make it easier to handle the context lifespan. Make the default context an always-retained reference to match this. No functional change in normal conditions, however this avoids an assert when BReferenceable is built in debug mode.
This commit is contained in:
parent
1a6ec00140
commit
807bd20a8f
@ -18,7 +18,7 @@
|
||||
#include <UrlRequest.h>
|
||||
|
||||
|
||||
static BUrlContext gDefaultContext;
|
||||
static BReference<BUrlContext> gDefaultContext = new(std::nothrow) BUrlContext();
|
||||
|
||||
|
||||
/* static */ BUrlRequest*
|
||||
@ -26,7 +26,13 @@ BUrlProtocolRoster::MakeRequest(const BUrl& url,
|
||||
BUrlProtocolListener* listener, BUrlContext* context)
|
||||
{
|
||||
if (context == NULL)
|
||||
context = &gDefaultContext;
|
||||
context = gDefaultContext;
|
||||
|
||||
if (context == NULL) {
|
||||
// Allocation of the gDefaultContext failed. Don't allow creating
|
||||
// requests without a context.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// TODO: instanciate the correct BUrlProtocol using add-on interface
|
||||
if (url.Protocol() == "http") {
|
||||
|
Loading…
Reference in New Issue
Block a user