diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-05-24 12:47:48 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-05-24 12:49:30 +0300 |
commit | a7c3ec4febf2450551f4663b78f0562c0e886923 (patch) | |
tree | cf8461caf50cbe62581c930a3773e9500c631d1e /intern/ghost | |
parent | 0b588f0905c7fa17c61e612e4457c96be176145c (diff) |
GHOST cleanup (null check before delete, and 0 -> NULL for pointers).
Based on patch from Lawrence D'Oliveiro (ldo) in T48499.
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/intern/GHOST_ContextSDL.cpp | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_DropTargetWin32.cpp | 5 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ISystem.cpp | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_ISystemPaths.cpp | 9 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.cpp | 37 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCocoa.mm | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.cpp | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.cpp | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_Window.h | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowCocoa.mm | 2 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowManager.cpp | 8 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowWin32.cpp | 3 |
12 files changed, 42 insertions, 46 deletions
diff --git a/intern/ghost/intern/GHOST_ContextSDL.cpp b/intern/ghost/intern/GHOST_ContextSDL.cpp index d80a638818c..39627fac899 100644 --- a/intern/ghost/intern/GHOST_ContextSDL.cpp +++ b/intern/ghost/intern/GHOST_ContextSDL.cpp @@ -69,7 +69,7 @@ GHOST_ContextSDL::GHOST_ContextSDL( GHOST_ContextSDL::~GHOST_ContextSDL() { if (m_context != NULL) { - if (m_window != 0 && m_context == SDL_GL_GetCurrentContext()) + if (m_window != NULL && m_context == SDL_GL_GetCurrentContext()) SDL_GL_MakeCurrent(m_window, m_context); if (m_context != s_sharedContext || s_sharedCount == 1) { diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.cpp b/intern/ghost/intern/GHOST_DropTargetWin32.cpp index fd9abce96b7..96ff79aa65a 100644 --- a/intern/ghost/intern/GHOST_DropTargetWin32.cpp +++ b/intern/ghost/intern/GHOST_DropTargetWin32.cpp @@ -75,7 +75,7 @@ HRESULT __stdcall GHOST_DropTargetWin32::QueryInterface(REFIID riid, void **ppvO return S_OK; } else { - *ppvObj = 0; + *ppvObj = NULL; return E_NOINTERFACE; } } @@ -97,8 +97,7 @@ ULONG __stdcall GHOST_DropTargetWin32::Release(void) { ULONG refs = ::InterlockedDecrement(&m_cRef); - if (refs == 0) - { + if (refs == 0) { delete this; return 0; } diff --git a/intern/ghost/intern/GHOST_ISystem.cpp b/intern/ghost/intern/GHOST_ISystem.cpp index d7dd2b1cde1..37d5926ffc2 100644 --- a/intern/ghost/intern/GHOST_ISystem.cpp +++ b/intern/ghost/intern/GHOST_ISystem.cpp @@ -54,7 +54,7 @@ # endif #endif -GHOST_ISystem *GHOST_ISystem::m_system = 0; +GHOST_ISystem *GHOST_ISystem::m_system = NULL; GHOST_TSuccess GHOST_ISystem::createSystem() @@ -76,7 +76,7 @@ GHOST_TSuccess GHOST_ISystem::createSystem() # endif # endif #endif - success = m_system != 0 ? GHOST_kSuccess : GHOST_kFailure; + success = m_system != NULL ? GHOST_kSuccess : GHOST_kFailure; } else { success = GHOST_kFailure; @@ -92,7 +92,7 @@ GHOST_TSuccess GHOST_ISystem::disposeSystem() GHOST_TSuccess success = GHOST_kSuccess; if (m_system) { delete m_system; - m_system = 0; + m_system = NULL; } else { success = GHOST_kFailure; diff --git a/intern/ghost/intern/GHOST_ISystemPaths.cpp b/intern/ghost/intern/GHOST_ISystemPaths.cpp index 6ebcb37ba06..93ca0bc3880 100644 --- a/intern/ghost/intern/GHOST_ISystemPaths.cpp +++ b/intern/ghost/intern/GHOST_ISystemPaths.cpp @@ -36,6 +36,9 @@ * \date May 7, 2001 */ + +#include <stdio.h> /* just for NULL */ + #include "GHOST_ISystemPaths.h" #ifdef WIN32 @@ -49,7 +52,7 @@ #endif -GHOST_ISystemPaths *GHOST_ISystemPaths::m_systemPaths = 0; +GHOST_ISystemPaths *GHOST_ISystemPaths::m_systemPaths = NULL; GHOST_TSuccess GHOST_ISystemPaths::create() @@ -65,7 +68,7 @@ GHOST_TSuccess GHOST_ISystemPaths::create() m_systemPaths = new GHOST_SystemPathsUnix(); # endif #endif - success = m_systemPaths != 0 ? GHOST_kSuccess : GHOST_kFailure; + success = m_systemPaths != NULL ? GHOST_kSuccess : GHOST_kFailure; } else { success = GHOST_kFailure; @@ -78,7 +81,7 @@ GHOST_TSuccess GHOST_ISystemPaths::dispose() GHOST_TSuccess success = GHOST_kSuccess; if (m_systemPaths) { delete m_systemPaths; - m_systemPaths = 0; + m_systemPaths = NULL; } else { success = GHOST_kFailure; diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 0f5c822f4b6..639ce451d23 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -88,7 +88,7 @@ GHOST_ITimerTask *GHOST_System::installTimer(GHOST_TUns64 delay, } else { delete timer; - timer = 0; + timer = NULL; } } return timer; @@ -328,27 +328,22 @@ GHOST_TSuccess GHOST_System::exit() if (getFullScreen()) { endFullScreen(); } - if (m_displayManager) { - delete m_displayManager; - m_displayManager = NULL; - } - if (m_windowManager) { - delete m_windowManager; - m_windowManager = NULL; - } - if (m_timerManager) { - delete m_timerManager; - m_timerManager = NULL; - } - if (m_eventManager) { - delete m_eventManager; - m_eventManager = NULL; - } + + delete m_displayManager; + m_displayManager = NULL; + + delete m_windowManager; + m_windowManager = NULL; + + delete m_timerManager; + m_timerManager = NULL; + + delete m_eventManager; + m_eventManager = NULL; + #ifdef WITH_INPUT_NDOF - if (m_ndofManager) { - delete m_ndofManager; - m_ndofManager = 0; - } + delete m_ndofManager; + m_ndofManager = NULL; #endif return GHOST_kSuccess; } diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index bf44d938a47..c9855cfdf7e 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -539,7 +539,7 @@ GHOST_IWindow* GHOST_SystemCocoa::createWindow( ) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - GHOST_IWindow* window = 0; + GHOST_IWindow* window = NULL; //Get the available rect for including window contents NSRect frame = [[NSScreen mainScreen] visibleFrame]; @@ -567,7 +567,7 @@ GHOST_IWindow* GHOST_SystemCocoa::createWindow( else { GHOST_PRINT("GHOST_SystemCocoa::createWindow(): window invalid\n"); delete window; - window = 0; + window = NULL; } [pool drain]; diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index d8ec827a946..43fb5dc4205 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -253,7 +253,7 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow( else { GHOST_PRINT("GHOST_SystemWin32::createWindow(): window invalid\n"); delete window; - window = 0; + window = NULL; } return window; @@ -766,7 +766,7 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA // GHOST_PRINTF("%c\n", ascii); // we already get this info via EventPrinter } else { - event = 0; + event = NULL; } return event; } @@ -900,7 +900,7 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const &raw) LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - GHOST_Event *event = 0; + GHOST_Event *event = NULL; bool eventHandled = false; LRESULT lResult = 0; diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 95dea38c70a..c9946c13122 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -302,7 +302,7 @@ createWindow(const STR_String& title, const bool exclusive, const GHOST_TEmbedderWindowID parentWindow) { - GHOST_WindowX11 *window = 0; + GHOST_WindowX11 *window = NULL; if (!m_display) return 0; @@ -324,7 +324,7 @@ createWindow(const STR_String& title, } else { delete window; - window = 0; + window = NULL; } } return window; diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h index 52cb9cbf54b..d778628ea37 100644 --- a/intern/ghost/intern/GHOST_Window.h +++ b/intern/ghost/intern/GHOST_Window.h @@ -106,7 +106,7 @@ public: * \return The validity of the window. */ virtual bool getValid() const { - return m_context != 0; + return m_context != NULL; } /** diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index b3fc8efbab1..00e00b6a1ea 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -663,7 +663,7 @@ GHOST_WindowCocoa::~GHOST_WindowCocoa() bool GHOST_WindowCocoa::getValid() const { - return GHOST_Window::getValid() && m_window != 0 && m_openGLView != 0; + return GHOST_Window::getValid() && m_window != NULL && m_openGLView != NULL; } void* GHOST_WindowCocoa::getOSWindow() const diff --git a/intern/ghost/intern/GHOST_WindowManager.cpp b/intern/ghost/intern/GHOST_WindowManager.cpp index 83490cecce5..790c73deca5 100644 --- a/intern/ghost/intern/GHOST_WindowManager.cpp +++ b/intern/ghost/intern/GHOST_WindowManager.cpp @@ -110,7 +110,7 @@ bool GHOST_WindowManager::getWindowFound(const GHOST_IWindow *window) const bool GHOST_WindowManager::getFullScreen(void) const { - return m_fullScreenWindow != 0; + return m_fullScreenWindow != NULL; } @@ -140,13 +140,13 @@ GHOST_TSuccess GHOST_WindowManager::endFullScreen(void) { GHOST_TSuccess success = GHOST_kFailure; if (getFullScreen()) { - if (m_fullScreenWindow != 0) { + if (m_fullScreenWindow != NULL) { //GHOST_PRINT("GHOST_WindowManager::endFullScreen(): deleting full-screen window\n"); setWindowInactive(m_fullScreenWindow); m_fullScreenWindow->endFullScreen(); delete m_fullScreenWindow; //GHOST_PRINT("GHOST_WindowManager::endFullScreen(): done\n"); - m_fullScreenWindow = 0; + m_fullScreenWindow = NULL; if (m_activeWindowBeforeFullScreen) { setActiveWindow(m_activeWindowBeforeFullScreen); } @@ -181,7 +181,7 @@ GHOST_IWindow *GHOST_WindowManager::getActiveWindow(void) const void GHOST_WindowManager::setWindowInactive(const GHOST_IWindow *window) { if (window == m_activeWindow) { - m_activeWindow = 0; + m_activeWindow = NULL; } } diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 7247753c655..81c08f4fc06 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -339,8 +339,7 @@ GHOST_WindowWin32::~GHOST_WindowWin32() if (fpWTClose) { if (m_tablet) fpWTClose(m_tablet); - if (m_tabletData) - delete m_tabletData; + delete m_tabletData; m_tabletData = NULL; } } |