Fixed sf::Window::Create on OS X (Closes #86)
This commit is contained in:
parent
95a0126371
commit
ecaafa9a18
@ -41,3 +41,11 @@ void RetainPool(void);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void ReleasePool(void);
|
void ReleasePool(void);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Drain the pool.
|
||||||
|
///
|
||||||
|
/// ReleasePool must be called at least once before DrainPool.
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void DrainPool();
|
||||||
|
|
||||||
|
@ -84,6 +84,12 @@ public :
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Drain the pool
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void Drain();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -149,8 +155,7 @@ void PoolWrapper::Release()
|
|||||||
|
|
||||||
// Drain pool if required.
|
// Drain pool if required.
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
[pool drain];
|
Drain();
|
||||||
pool = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SFML_DEBUG
|
#ifdef SFML_DEBUG
|
||||||
@ -160,6 +165,16 @@ void PoolWrapper::Release()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PoolWrapper::Drain()
|
||||||
|
{
|
||||||
|
[pool drain];
|
||||||
|
pool = 0;
|
||||||
|
|
||||||
|
if (count != 0) {
|
||||||
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
|
||||||
@ -207,3 +222,18 @@ void ReleasePool(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void DrainPool()
|
||||||
|
{
|
||||||
|
if (localPool != NULL) {
|
||||||
|
localPool->Drain();
|
||||||
|
}
|
||||||
|
#ifdef SFML_DEBUG
|
||||||
|
else {
|
||||||
|
sf::Err() << "ReleasePool must be called at least one before DrainPool"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -39,20 +39,22 @@ namespace priv
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
SFContext::SFContext(SFContext* shared)
|
SFContext::SFContext(SFContext* shared)
|
||||||
: myView(0), myWindow(0)
|
: myView(0), myWindow(0)
|
||||||
{
|
{
|
||||||
// Ask for a pool.
|
// Ask for a pool.
|
||||||
RetainPool();
|
RetainPool();
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, ContextSettings(0, 0, 0));
|
CreateContext(shared,
|
||||||
|
VideoMode::GetDesktopMode().BitsPerPixel,
|
||||||
|
ContextSettings(0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
||||||
const WindowImpl* owner, unsigned int bitsPerPixel)
|
const WindowImpl* owner, unsigned int bitsPerPixel)
|
||||||
: myView(0), myWindow(0)
|
: myView(0), myWindow(0)
|
||||||
{
|
{
|
||||||
// Ask for a pool.
|
// Ask for a pool.
|
||||||
RetainPool();
|
RetainPool();
|
||||||
@ -68,7 +70,7 @@ SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
|||||||
|
|
||||||
SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
SFContext::SFContext(SFContext* shared, const ContextSettings& settings,
|
||||||
unsigned int width, unsigned int height)
|
unsigned int width, unsigned int height)
|
||||||
: myView(0), myWindow(0)
|
: myView(0), myWindow(0)
|
||||||
{
|
{
|
||||||
// Ensure the process is setup in order to create a valid window.
|
// Ensure the process is setup in order to create a valid window.
|
||||||
WindowImplCocoa::SetUpProcess();
|
WindowImplCocoa::SetUpProcess();
|
||||||
|
@ -45,7 +45,7 @@ namespace priv
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowImplCocoa::WindowImplCocoa(WindowHandle handle)
|
WindowImplCocoa::WindowImplCocoa(WindowHandle handle)
|
||||||
: myShowCursor(true)
|
: myShowCursor(true)
|
||||||
{
|
{
|
||||||
// Ask for a pool.
|
// Ask for a pool.
|
||||||
RetainPool();
|
RetainPool();
|
||||||
|
|
||||||
@ -118,6 +118,10 @@ WindowImplCocoa::~WindowImplCocoa()
|
|||||||
[myDelegate release];
|
[myDelegate release];
|
||||||
|
|
||||||
ReleasePool();
|
ReleasePool();
|
||||||
|
|
||||||
|
DrainPool(); // Make sure everything was freed
|
||||||
|
// This solve some issue when sf::Window::Create is called for the
|
||||||
|
// second time (nothing was render until the function was called again)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user