From dec70e84b6a375b6a41b3a8a7ded9cb7ec813bdf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Aug 2023 21:20:44 +1000 Subject: [PATCH] Cleanup: use nullptr in intern/ghost --- intern/ghost/GHOST_C-api.h | 14 +-- intern/ghost/GHOST_IEvent.hh | 2 +- intern/ghost/GHOST_ISystem.hh | 6 +- intern/ghost/GHOST_Types.h | 2 +- intern/ghost/intern/GHOST_Context.hh | 4 +- intern/ghost/intern/GHOST_ContextD3D.cc | 30 +++--- intern/ghost/intern/GHOST_ContextVK.cc | 91 ++++++++++--------- intern/ghost/intern/GHOST_ContextWGL.cc | 62 ++++++------- .../ghost/intern/GHOST_DisplayManagerCocoa.mm | 2 +- .../ghost/intern/GHOST_DisplayManagerWin32.cc | 2 +- intern/ghost/intern/GHOST_DropTargetWin32.cc | 36 ++++---- intern/ghost/intern/GHOST_DropTargetWin32.hh | 2 +- intern/ghost/intern/GHOST_Event.hh | 4 +- intern/ghost/intern/GHOST_EventDragnDrop.hh | 2 +- intern/ghost/intern/GHOST_EventManager.hh | 2 +- intern/ghost/intern/GHOST_EventString.hh | 2 +- intern/ghost/intern/GHOST_ImeWin32.cc | 16 ++-- intern/ghost/intern/GHOST_NDOFManagerCocoa.mm | 16 ++-- intern/ghost/intern/GHOST_SystemCocoa.hh | 2 +- intern/ghost/intern/GHOST_SystemCocoa.mm | 56 ++++++------ intern/ghost/intern/GHOST_SystemPathsCocoa.mm | 8 +- intern/ghost/intern/GHOST_SystemPathsWin32.cc | 26 +++--- intern/ghost/intern/GHOST_SystemWayland.cc | 14 +-- intern/ghost/intern/GHOST_SystemWayland.hh | 2 +- intern/ghost/intern/GHOST_SystemWin32.cc | 76 ++++++++-------- intern/ghost/intern/GHOST_SystemX11.cc | 2 +- intern/ghost/intern/GHOST_TrackpadWin32.cc | 12 +-- intern/ghost/intern/GHOST_WindowCocoa.mm | 10 +- intern/ghost/intern/GHOST_WindowManager.hh | 4 +- intern/ghost/intern/GHOST_WindowWayland.cc | 2 +- intern/ghost/intern/GHOST_WindowWin32.cc | 72 +++++++-------- intern/ghost/intern/GHOST_WindowX11.cc | 4 +- intern/ghost/intern/GHOST_XrContext.cc | 4 +- intern/ghost/intern/GHOST_XrSession.cc | 3 +- intern/ghost/intern/GHOST_XrSwapchain.cc | 2 +- 35 files changed, 300 insertions(+), 294 deletions(-) diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index e59a9ac65ad..412a6d961f3 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -154,7 +154,7 @@ extern void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle, * The new window is added to the list of windows managed. * Never explicitly delete the window, use disposeWindow() instead. * \param systemhandle: The handle to the system. - * \param parent_windowhandle: Handle of parent (or owner) window, or NULL + * \param parent_windowhandle: Handle of parent (or owner) window, or nullptr * \param title: The name of the window. * (displayed in the title bar of the window if the OS supports it). * \param left: The coordinate of the left edge of the window. @@ -164,7 +164,7 @@ extern void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle, * \param state: The state of the window when opened. * \param is_dialog: Stay on top of parent window, no icon in taskbar, can't be minimized. * \param gpuSettings: Misc GPU options. - * \return A handle to the new window ( == NULL if creation failed). + * \return A handle to the new window ( == nullptr if creation failed). */ extern GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandle parent_windowhandle, @@ -182,7 +182,7 @@ extern GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle, * Never explicitly delete the context, use #disposeContext() instead. * \param systemhandle: The handle to the system. * \param gpuSettings: Misc GPU options. - * \return A handle to the new context ( == NULL if creation failed). + * \return A handle to the new context ( == nullptr if creation failed). */ extern GHOST_ContextHandle GHOST_CreateGPUContext(GHOST_SystemHandle systemhandle, GHOST_GPUSettings gpuSettings); @@ -495,7 +495,7 @@ extern uint64_t GHOST_GetEventTime(GHOST_EventHandle eventhandle); /** * Returns the window this event was generated on, - * or NULL if it is a 'system' event. + * or nullptr if it is a 'system' event. * \param eventhandle: The handle to the event. * \return The generating window. */ @@ -951,7 +951,7 @@ extern bool GHOST_UseNativePixels(void); extern GHOST_TCapabilityFlag GHOST_GetCapabilities(void); /** - * Assign the callback which generates a back-trace (may be NULL). + * Assign the callback which generates a back-trace (may be nullptr). */ extern void GHOST_SetBacktraceHandler(GHOST_TBacktraceFn backtrace_fn); @@ -1081,7 +1081,7 @@ int GHOST_XrSessionNeedsUpsideDownDrawing(const GHOST_XrContextHandle xr_context /* events */ /** * Invoke handling of all OpenXR events for \a xr_context. Should be called on every main-loop - * iteration and will early-exit if \a xr_context is NULL (so caller doesn't have to check). + * iteration and will early-exit if \a xr_context is nullptr (so caller doesn't have to check). * * \returns GHOST_kSuccess if any event was handled, otherwise GHOST_kFailure. */ @@ -1139,7 +1139,7 @@ int GHOST_XrAttachActionSets(GHOST_XrContextHandle xr_context); /** * Update button/tracking states for OpenXR actions. * - * \param action_set_name: The name of the action set to sync. If NULL, all action sets + * \param action_set_name: The name of the action set to sync. If nullptr, all action sets * attached to the session will be synced. */ int GHOST_XrSyncActions(GHOST_XrContextHandle xr_context, const char *action_set_name); diff --git a/intern/ghost/GHOST_IEvent.hh b/intern/ghost/GHOST_IEvent.hh index b9a7e29fbcf..3391079f4a0 100644 --- a/intern/ghost/GHOST_IEvent.hh +++ b/intern/ghost/GHOST_IEvent.hh @@ -45,7 +45,7 @@ class GHOST_IEvent { /** * Returns the window this event was generated on, - * or NULL if it is a 'system' event. + * or nullptr if it is a 'system' event. * \return The generating window. */ virtual GHOST_IWindow *getWindow() = 0; diff --git a/intern/ghost/GHOST_ISystem.hh b/intern/ghost/GHOST_ISystem.hh index 7a2d0afb7f4..a29dbc0f21b 100644 --- a/intern/ghost/GHOST_ISystem.hh +++ b/intern/ghost/GHOST_ISystem.hh @@ -61,7 +61,7 @@ class GHOST_IEventConsumer; * - Windows. * - X11. * - SDL2 (experimental). - * - NULL (headless mode). + * - null (headless mode). * * \section Building GHOST * @@ -189,7 +189,7 @@ class GHOST_ISystem { virtual GHOST_ITimerTask *installTimer(uint64_t delay, uint64_t interval, GHOST_TimerProcPtr timerProc, - GHOST_TUserDataPtr userData = NULL) = 0; + GHOST_TUserDataPtr userData = nullptr) = 0; /** * Removes a timer. @@ -246,7 +246,7 @@ class GHOST_ISystem { GHOST_GPUSettings gpuSettings, const bool exclusive = false, const bool is_dialog = false, - const GHOST_IWindow *parentWindow = NULL) = 0; + const GHOST_IWindow *parentWindow = nullptr) = 0; /** * Dispose a window. diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 0bd7c72749a..356ff0674b2 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -647,7 +647,7 @@ typedef struct { /** The key code. */ GHOST_TKey key; - /** The unicode character. if the length is 6, not NULL terminated if all 6 are set. */ + /** The unicode character. if the length is 6, not nullptr terminated if all 6 are set. */ char utf8_buf[6]; /** diff --git a/intern/ghost/intern/GHOST_Context.hh b/intern/ghost/intern/GHOST_Context.hh index c9b4ee1660e..232a6247958 100644 --- a/intern/ghost/intern/GHOST_Context.hh +++ b/intern/ghost/intern/GHOST_Context.hh @@ -12,7 +12,7 @@ #include "GHOST_IContext.hh" #include "GHOST_Types.h" -#include // for NULL +#include // for nullptr class GHOST_Context : public GHOST_IContext { public: @@ -232,7 +232,7 @@ class GHOST_Context : public GHOST_IContext { }; #ifdef _WIN32 -bool win32_chk(bool result, const char *file = NULL, int line = 0, const char *text = NULL); +bool win32_chk(bool result, const char *file = nullptr, int line = 0, const char *text = nullptr); bool win32_silent_chk(bool result); # ifndef NDEBUG diff --git a/intern/ghost/intern/GHOST_ContextD3D.cc b/intern/ghost/intern/GHOST_ContextD3D.cc index c7eb2a93027..c67406a27c0 100644 --- a/intern/ghost/intern/GHOST_ContextD3D.cc +++ b/intern/ghost/intern/GHOST_ContextD3D.cc @@ -17,8 +17,8 @@ #include "GHOST_ContextD3D.hh" #include "GHOST_ContextWGL.hh" /* For shared drawing */ -HMODULE GHOST_ContextD3D::s_d3d_lib = NULL; -PFN_D3D11_CREATE_DEVICE GHOST_ContextD3D::s_D3D11CreateDeviceFn = NULL; +HMODULE GHOST_ContextD3D::s_d3d_lib = nullptr; +PFN_D3D11_CREATE_DEVICE GHOST_ContextD3D::s_D3D11CreateDeviceFn = nullptr; GHOST_ContextD3D::GHOST_ContextD3D(bool stereoVisual, HWND hWnd) : GHOST_Context(stereoVisual), m_hWnd(hWnd) @@ -49,24 +49,24 @@ GHOST_TSuccess GHOST_ContextD3D::releaseDrawingContext() GHOST_TSuccess GHOST_ContextD3D::setupD3DLib() { - if (s_d3d_lib == NULL) { + if (s_d3d_lib == nullptr) { s_d3d_lib = LoadLibraryA("d3d11.dll"); - WIN32_CHK(s_d3d_lib != NULL); + WIN32_CHK(s_d3d_lib != nullptr); - if (s_d3d_lib == NULL) { + if (s_d3d_lib == nullptr) { fprintf(stderr, "LoadLibrary(\"d3d11.dll\") failed!\n"); return GHOST_kFailure; } } - if (s_D3D11CreateDeviceFn == NULL) { + if (s_D3D11CreateDeviceFn == nullptr) { s_D3D11CreateDeviceFn = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(s_d3d_lib, "D3D11CreateDevice"); - WIN32_CHK(s_D3D11CreateDeviceFn != NULL); + WIN32_CHK(s_D3D11CreateDeviceFn != nullptr); - if (s_D3D11CreateDeviceFn == NULL) { + if (s_D3D11CreateDeviceFn == nullptr) { fprintf(stderr, "GetProcAddress(s_d3d_lib, \"D3D11CreateDevice\") failed!\n"); return GHOST_kFailure; } @@ -82,19 +82,19 @@ GHOST_TSuccess GHOST_ContextD3D::initializeDrawingContext() } HRESULT hres = s_D3D11CreateDeviceFn( - NULL, + nullptr, D3D_DRIVER_TYPE_HARDWARE, - NULL, + nullptr, /* For debugging you may want to pass D3D11_CREATE_DEVICE_DEBUG here, but that requires * additional setup, see * https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-devices-layers#debug-layer. */ 0, - NULL, + nullptr, 0, D3D11_SDK_VERSION, &m_device, - NULL, + nullptr, &m_device_ctx); WIN32_CHK(hres == S_OK); @@ -138,10 +138,10 @@ class GHOST_SharedOpenGLResource { texDesc.MipLevels = 1; texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; - device->CreateTexture2D(&texDesc, NULL, &tex); + device->CreateTexture2D(&texDesc, nullptr, &tex); if (!tex) { /* If texture creation fails, we just return and leave the render target unset. So it needs - * to be NULL-checked before use. */ + * to be nullptr-checked before use. */ fprintf(stderr, "Error creating texture for shared DirectX-OpenGL resource\n"); return; } @@ -251,7 +251,7 @@ class GHOST_SharedOpenGLResource { GHOST_TSuccess initialize() { m_shared.device = wglDXOpenDeviceNV(m_device); - if (m_shared.device == NULL) { + if (m_shared.device == nullptr) { fprintf(stderr, "Error opening shared device using wglDXOpenDeviceNV()\n"); return GHOST_kFailure; } diff --git a/intern/ghost/intern/GHOST_ContextVK.cc b/intern/ghost/intern/GHOST_ContextVK.cc index 6f1e3767c06..ab97d823392 100644 --- a/intern/ghost/intern/GHOST_ContextVK.cc +++ b/intern/ghost/intern/GHOST_ContextVK.cc @@ -161,7 +161,7 @@ class GHOST_DeviceVK { ~GHOST_DeviceVK() { if (device != VK_NULL_HANDLE) { - vkDestroyDevice(device, NULL); + vkDestroyDevice(device, nullptr); } } @@ -175,10 +175,11 @@ class GHOST_DeviceVK { bool extensions_support(const vector &required_extensions) { uint32_t ext_count; - vkEnumerateDeviceExtensionProperties(physical_device, NULL, &ext_count, NULL); + vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &ext_count, nullptr); vector available_exts(ext_count); - vkEnumerateDeviceExtensionProperties(physical_device, NULL, &ext_count, available_exts.data()); + vkEnumerateDeviceExtensionProperties( + physical_device, nullptr, &ext_count, available_exts.data()); for (const auto &extension_needed : required_extensions) { bool found = false; @@ -232,13 +233,13 @@ class GHOST_DeviceVK { device_create_info.ppEnabledExtensionNames = extensions_device.data(); device_create_info.pEnabledFeatures = &device_features; - vkCreateDevice(physical_device, &device_create_info, NULL, &device); + vkCreateDevice(physical_device, &device_create_info, nullptr, &device); } void init_generic_queue_family() { uint32_t queue_family_count = 0; - vkGetPhysicalDeviceQueueFamilyProperties(physical_device, &queue_family_count, NULL); + vkGetPhysicalDeviceQueueFamilyProperties(physical_device, &queue_family_count, nullptr); vector queue_families(queue_family_count); vkGetPhysicalDeviceQueueFamilyProperties( @@ -282,7 +283,7 @@ static GHOST_TSuccess ensure_vulkan_device(VkInstance vk_instance, VkPhysicalDevice best_physical_device = VK_NULL_HANDLE; uint32_t device_count = 0; - vkEnumeratePhysicalDevices(vk_instance, &device_count, NULL); + vkEnumeratePhysicalDevices(vk_instance, &device_count, nullptr); vector physical_devices(device_count); vkEnumeratePhysicalDevices(vk_instance, &device_count, physical_devices.data()); @@ -298,11 +299,11 @@ static GHOST_TSuccess ensure_vulkan_device(VkInstance vk_instance, if (vk_surface != VK_NULL_HANDLE) { uint32_t format_count; vkGetPhysicalDeviceSurfaceFormatsKHR( - device_vk.physical_device, vk_surface, &format_count, NULL); + device_vk.physical_device, vk_surface, &format_count, nullptr); uint32_t present_count; vkGetPhysicalDeviceSurfacePresentModesKHR( - device_vk.physical_device, vk_surface, &present_count, NULL); + device_vk.physical_device, vk_surface, &present_count, nullptr); /* For now anything will do. */ if (format_count == 0 || present_count == 0) { @@ -403,10 +404,10 @@ GHOST_ContextVK::~GHOST_ContextVK() destroySwapchain(); if (m_command_pool != VK_NULL_HANDLE) { - vkDestroyCommandPool(device_vk.device, m_command_pool, NULL); + vkDestroyCommandPool(device_vk.device, m_command_pool, nullptr); } if (m_surface != VK_NULL_HANDLE) { - vkDestroySurfaceKHR(device_vk.instance, m_surface, NULL); + vkDestroySurfaceKHR(device_vk.instance, m_surface, nullptr); } device_vk.users--; @@ -422,28 +423,28 @@ GHOST_TSuccess GHOST_ContextVK::destroySwapchain() VkDevice device = vulkan_device->device; for (auto semaphore : m_image_available_semaphores) { - vkDestroySemaphore(device, semaphore, NULL); + vkDestroySemaphore(device, semaphore, nullptr); } for (auto semaphore : m_render_finished_semaphores) { - vkDestroySemaphore(device, semaphore, NULL); + vkDestroySemaphore(device, semaphore, nullptr); } for (auto fence : m_in_flight_fences) { - vkDestroyFence(device, fence, NULL); + vkDestroyFence(device, fence, nullptr); } for (auto framebuffer : m_swapchain_framebuffers) { - vkDestroyFramebuffer(device, framebuffer, NULL); + vkDestroyFramebuffer(device, framebuffer, nullptr); } if (m_render_pass != VK_NULL_HANDLE) { - vkDestroyRenderPass(device, m_render_pass, NULL); + vkDestroyRenderPass(device, m_render_pass, nullptr); } for (auto command_buffer : m_command_buffers) { vkFreeCommandBuffers(device, m_command_pool, 1, &command_buffer); } for (auto imageView : m_swapchain_image_views) { - vkDestroyImageView(device, imageView, NULL); + vkDestroyImageView(device, imageView, nullptr); } if (m_swapchain != VK_NULL_HANDLE) { - vkDestroySwapchainKHR(device, m_swapchain, NULL); + vkDestroySwapchainKHR(device, m_swapchain, nullptr); } return GHOST_kSuccess; } @@ -509,7 +510,7 @@ GHOST_TSuccess GHOST_ContextVK::swapBuffers() present_info.swapchainCount = 1; present_info.pSwapchains = &m_swapchain; present_info.pImageIndices = &m_currentImage; - present_info.pResults = NULL; + present_info.pResults = nullptr; result = vkQueuePresentKHR(m_present_queue, &present_info); @@ -612,10 +613,10 @@ GHOST_TSuccess GHOST_ContextVK::releaseDrawingContext() static vector getExtensionsAvailable() { uint32_t extension_count = 0; - vkEnumerateInstanceExtensionProperties(NULL, &extension_count, NULL); + vkEnumerateInstanceExtensionProperties(nullptr, &extension_count, nullptr); vector extensions(extension_count); - vkEnumerateInstanceExtensionProperties(NULL, &extension_count, extensions.data()); + vkEnumerateInstanceExtensionProperties(nullptr, &extension_count, extensions.data()); return extensions; } @@ -646,7 +647,7 @@ static void requireExtension(vector &extensions_available static vector getLayersAvailable() { uint32_t layer_count = 0; - vkEnumerateInstanceLayerProperties(&layer_count, NULL); + vkEnumerateInstanceLayerProperties(&layer_count, nullptr); vector layers(layer_count); vkEnumerateInstanceLayerProperties(&layer_count, layers.data()); @@ -731,7 +732,7 @@ static GHOST_TSuccess create_render_pass(VkDevice device, renderPassInfo.subpassCount = 1; renderPassInfo.pSubpasses = &subpass; - VK_CHECK(vkCreateRenderPass(device, &renderPassInfo, NULL, r_renderPass)); + VK_CHECK(vkCreateRenderPass(device, &renderPassInfo, nullptr, r_renderPass)); return GHOST_kSuccess; } @@ -742,7 +743,7 @@ static GHOST_TSuccess selectPresentMode(VkPhysicalDevice device, { // TODO cleanup: we are not going to use MAILBOX as it isn't supported by renderdoc. uint32_t present_count; - vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface, &present_count, NULL); + vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface, &present_count, nullptr); vector presents(present_count); vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface, &present_count, presents.data()); /* MAILBOX is the lowest latency V-Sync enabled mode so use it if available */ @@ -773,7 +774,7 @@ GHOST_TSuccess GHOST_ContextVK::createCommandPools() poolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; poolInfo.queueFamilyIndex = vulkan_device->generic_queue_family; - VK_CHECK(vkCreateCommandPool(vulkan_device->device, &poolInfo, NULL, &m_command_pool)); + VK_CHECK(vkCreateCommandPool(vulkan_device->device, &poolInfo, nullptr, &m_command_pool)); return GHOST_kSuccess; } @@ -834,7 +835,7 @@ static bool selectSurfaceFormat(const VkPhysicalDevice physical_device, VkSurfaceFormatKHR &r_surfaceFormat) { uint32_t format_count; - vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &format_count, NULL); + vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &format_count, nullptr); vector formats(format_count); vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &format_count, formats.data()); @@ -913,15 +914,15 @@ GHOST_TSuccess GHOST_ContextVK::createSwapchain() create_info.oldSwapchain = VK_NULL_HANDLE; /* TODO Window resize */ create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; create_info.queueFamilyIndexCount = 0; - create_info.pQueueFamilyIndices = NULL; + create_info.pQueueFamilyIndices = nullptr; VkDevice device = vulkan_device->device; - VK_CHECK(vkCreateSwapchainKHR(device, &create_info, NULL, &m_swapchain)); + VK_CHECK(vkCreateSwapchainKHR(device, &create_info, nullptr, &m_swapchain)); create_render_pass(device, format.format, &m_render_pass); /* image_count may not be what we requested! Getter for final value. */ - vkGetSwapchainImagesKHR(device, m_swapchain, &image_count, NULL); + vkGetSwapchainImagesKHR(device, m_swapchain, &image_count, nullptr); m_swapchain_images.resize(image_count); vkGetSwapchainImagesKHR(device, m_swapchain, &image_count, m_swapchain_images.data()); @@ -945,7 +946,7 @@ GHOST_TSuccess GHOST_ContextVK::createSwapchain() view_create_info.subresourceRange.baseArrayLayer = 0; view_create_info.subresourceRange.layerCount = 1; - VK_CHECK(vkCreateImageView(device, &view_create_info, NULL, &m_swapchain_image_views[i])); + VK_CHECK(vkCreateImageView(device, &view_create_info, nullptr, &m_swapchain_image_views[i])); VkImageView attachments[] = {m_swapchain_image_views[i]}; @@ -958,7 +959,7 @@ GHOST_TSuccess GHOST_ContextVK::createSwapchain() fb_create_info.height = m_render_extent.height; fb_create_info.layers = 1; - VK_CHECK(vkCreateFramebuffer(device, &fb_create_info, NULL, &m_swapchain_framebuffers[i])); + VK_CHECK(vkCreateFramebuffer(device, &fb_create_info, nullptr, &m_swapchain_framebuffers[i])); } m_image_available_semaphores.resize(MAX_FRAMES_IN_FLIGHT); @@ -973,10 +974,12 @@ GHOST_TSuccess GHOST_ContextVK::createSwapchain() for (int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) { - VK_CHECK(vkCreateSemaphore(device, &semaphore_info, NULL, &m_image_available_semaphores[i])); - VK_CHECK(vkCreateSemaphore(device, &semaphore_info, NULL, &m_render_finished_semaphores[i])); + VK_CHECK( + vkCreateSemaphore(device, &semaphore_info, nullptr, &m_image_available_semaphores[i])); + VK_CHECK( + vkCreateSemaphore(device, &semaphore_info, nullptr, &m_render_finished_semaphores[i])); - VK_CHECK(vkCreateFence(device, &fence_info, NULL, &m_in_flight_fences[i])); + VK_CHECK(vkCreateFence(device, &fence_info, nullptr, &m_in_flight_fences[i])); } createGraphicsCommandBuffers(); @@ -1002,24 +1005,24 @@ const char *GHOST_ContextVK::getPlatformSpecificSurfaceExtension() const # endif } #endif - return NULL; + return nullptr; } GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext() { #ifdef _WIN32 - const bool use_window_surface = (m_hwnd != NULL); + const bool use_window_surface = (m_hwnd != nullptr); #elif defined(__APPLE__) - const bool use_window_surface = (m_metal_layer != NULL); + const bool use_window_surface = (m_metal_layer != nullptr); #else /* UNIX/Linux */ bool use_window_surface = false; switch (m_platform) { case GHOST_kVulkanPlatformX11: - use_window_surface = (m_display != NULL) && (m_window != (Window)NULL); + use_window_surface = (m_display != nullptr) && (m_window != (Window) nullptr); break; # ifdef WITH_GHOST_WAYLAND case GHOST_kVulkanPlatformWayland: - use_window_surface = (m_wayland_display != NULL) && (m_wayland_surface != NULL); + use_window_surface = (m_wayland_display != nullptr) && (m_wayland_surface != nullptr); break; # endif } @@ -1070,7 +1073,7 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext() create_info.ppEnabledLayerNames = layers_enabled.data(); create_info.enabledExtensionCount = static_cast(extensions_enabled.size()); create_info.ppEnabledExtensionNames = extensions_enabled.data(); - VK_CHECK(vkCreateInstance(&create_info, NULL, &instance)); + VK_CHECK(vkCreateInstance(&create_info, nullptr, &instance)); } else { instance = vulkan_device->instance; @@ -1080,13 +1083,13 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext() #ifdef _WIN32 VkWin32SurfaceCreateInfoKHR surface_create_info = {}; surface_create_info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; - surface_create_info.hinstance = GetModuleHandle(NULL); + surface_create_info.hinstance = GetModuleHandle(nullptr); surface_create_info.hwnd = m_hwnd; - VK_CHECK(vkCreateWin32SurfaceKHR(instance, &surface_create_info, NULL, &m_surface)); + VK_CHECK(vkCreateWin32SurfaceKHR(instance, &surface_create_info, nullptr, &m_surface)); #elif defined(__APPLE__) VkMetalSurfaceCreateInfoEXT info = {}; info.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; - info.pNext = NULL; + info.pNext = nullptr; info.flags = 0; info.pLayer = m_metal_layer; VK_CHECK(vkCreateMetalSurfaceEXT(instance, &info, nullptr, &m_surface)); @@ -1097,7 +1100,7 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext() surface_create_info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; surface_create_info.dpy = m_display; surface_create_info.window = m_window; - VK_CHECK(vkCreateXlibSurfaceKHR(instance, &surface_create_info, NULL, &m_surface)); + VK_CHECK(vkCreateXlibSurfaceKHR(instance, &surface_create_info, nullptr, &m_surface)); break; } # ifdef WITH_GHOST_WAYLAND @@ -1106,7 +1109,7 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext() surface_create_info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR; surface_create_info.display = m_wayland_display; surface_create_info.surface = m_wayland_surface; - VK_CHECK(vkCreateWaylandSurfaceKHR(instance, &surface_create_info, NULL, &m_surface)); + VK_CHECK(vkCreateWaylandSurfaceKHR(instance, &surface_create_info, nullptr, &m_surface)); break; } # endif diff --git a/intern/ghost/intern/GHOST_ContextWGL.cc b/intern/ghost/intern/GHOST_ContextWGL.cc index 63ea43e452f..a8fc5abaae0 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.cc +++ b/intern/ghost/intern/GHOST_ContextWGL.cc @@ -16,13 +16,13 @@ #include #include -HGLRC GHOST_ContextWGL::s_sharedHGLRC = NULL; +HGLRC GHOST_ContextWGL::s_sharedHGLRC = nullptr; int GHOST_ContextWGL::s_sharedCount = 0; /* Some third-generation Intel video-cards are constantly bring problems */ static bool is_crappy_intel_card() { - return strstr((const char *)glGetString(GL_VENDOR), "Intel") != NULL; + return strstr((const char *)glGetString(GL_VENDOR), "Intel") != nullptr; } GHOST_ContextWGL::GHOST_ContextWGL(bool stereoVisual, @@ -43,22 +43,22 @@ GHOST_ContextWGL::GHOST_ContextWGL(bool stereoVisual, m_contextFlags(contextFlags), m_alphaBackground(alphaBackground), m_contextResetNotificationStrategy(contextResetNotificationStrategy), - m_hGLRC(NULL) + m_hGLRC(nullptr) #ifndef NDEBUG , - m_dummyVendor(NULL), - m_dummyRenderer(NULL), - m_dummyVersion(NULL) + m_dummyVendor(nullptr), + m_dummyRenderer(nullptr), + m_dummyVersion(nullptr) #endif { - assert(m_hDC != NULL); + assert(m_hDC != nullptr); } GHOST_ContextWGL::~GHOST_ContextWGL() { - if (m_hGLRC != NULL) { + if (m_hGLRC != nullptr) { if (m_hGLRC == ::wglGetCurrentContext()) - WIN32_CHK(::wglMakeCurrent(NULL, NULL)); + WIN32_CHK(::wglMakeCurrent(nullptr, nullptr)); if (m_hGLRC != s_sharedHGLRC || s_sharedCount == 1) { assert(s_sharedCount > 0); @@ -66,7 +66,7 @@ GHOST_ContextWGL::~GHOST_ContextWGL() s_sharedCount--; if (s_sharedCount == 0) - s_sharedHGLRC = NULL; + s_sharedHGLRC = nullptr; WIN32_CHK(::wglDeleteContext(m_hGLRC)); } @@ -117,7 +117,7 @@ GHOST_TSuccess GHOST_ContextWGL::activateDrawingContext() GHOST_TSuccess GHOST_ContextWGL::releaseDrawingContext() { - if (WIN32_CHK(::wglMakeCurrent(NULL, NULL))) { + if (WIN32_CHK(::wglMakeCurrent(nullptr, nullptr))) { return GHOST_kSuccess; } else { @@ -176,7 +176,7 @@ static int choose_pixel_format_legacy(HDC hDC, PIXELFORMATDESCRIPTOR &preferredP WIN32_CHK(iLastResortPixelFormat != 0); - int lastPFD = ::DescribePixelFormat(hDC, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL); + int lastPFD = ::DescribePixelFormat(hDC, 1, sizeof(PIXELFORMATDESCRIPTOR), nullptr); WIN32_CHK(lastPFD != 0); @@ -262,7 +262,7 @@ static HWND clone_window(HWND hWnd, LPVOID lpParam) hInstance, lpParam); - WIN32_CHK(hwndCloned != NULL); + WIN32_CHK(hwndCloned != nullptr); return hwndCloned; } @@ -306,13 +306,13 @@ static void makeAttribList(std::vector &out, bool stereoVisual, bool needAl /* Temporary context used to create the actual context. We need ARB pixel format * and context extensions, which are only available within a context. */ struct DummyContextWGL { - HWND dummyHWND = NULL; + HWND dummyHWND = nullptr; - HDC dummyHDC = NULL; - HGLRC dummyHGLRC = NULL; + HDC dummyHDC = nullptr; + HGLRC dummyHGLRC = nullptr; - HDC prevHDC = NULL; - HGLRC prevHGLRC = NULL; + HDC prevHDC = nullptr; + HGLRC prevHGLRC = nullptr; int dummyPixelFormat = 0; @@ -381,15 +381,15 @@ struct DummyContextWGL { return; if (hWnd) { - dummyHWND = clone_window(hWnd, NULL); + dummyHWND = clone_window(hWnd, nullptr); - if (dummyHWND == NULL) + if (dummyHWND == nullptr) return; dummyHDC = GetDC(dummyHWND); } - if (!WIN32_CHK(dummyHDC != NULL)) + if (!WIN32_CHK(dummyHDC != nullptr)) return; if (!WIN32_CHK(::SetPixelFormat(dummyHDC, dummyPixelFormat, &chosenPFD))) @@ -397,7 +397,7 @@ struct DummyContextWGL { dummyHGLRC = ::wglCreateContext(dummyHDC); - if (!WIN32_CHK(dummyHGLRC != NULL)) + if (!WIN32_CHK(dummyHGLRC != nullptr)) return; if (!WIN32_CHK(::wglMakeCurrent(dummyHDC, dummyHGLRC))) @@ -415,11 +415,11 @@ struct DummyContextWGL { { WIN32_CHK(::wglMakeCurrent(prevHDC, prevHGLRC)); - if (dummyHGLRC != NULL) + if (dummyHGLRC != nullptr) WIN32_CHK(::wglDeleteContext(dummyHGLRC)); - if (dummyHWND != NULL) { - if (dummyHDC != NULL) + if (dummyHWND != nullptr) { + if (dummyHDC != nullptr) WIN32_CHK(::ReleaseDC(dummyHWND, dummyHDC)); WIN32_CHK(::DestroyWindow(dummyHWND)); @@ -440,7 +440,7 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_1(bool stereoVisual, bool needAlp uint nNumFormats; WIN32_CHK(wglChoosePixelFormatARB( - m_hDC, &(iAttributes[0]), NULL, _MAX_PIXEL_FORMATS, iPixelFormats, &nNumFormats)); + m_hDC, &(iAttributes[0]), nullptr, _MAX_PIXEL_FORMATS, iPixelFormats, &nNumFormats)); if (nNumFormats > 0) { iPixelFormat = iPixelFormats[0]; @@ -604,7 +604,7 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext() iAttributes.push_back(0); - m_hGLRC = ::wglCreateContextAttribsARB(m_hDC, NULL, &(iAttributes[0])); + m_hGLRC = ::wglCreateContextAttribsARB(m_hDC, nullptr, &(iAttributes[0])); } } @@ -612,14 +612,14 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext() * a context with version higher than 3.3 Core. */ { const bool silent = m_contextMajorVersion > 3; - if (!WIN32_CHK_SILENT(m_hGLRC != NULL, silent)) { + if (!WIN32_CHK_SILENT(m_hGLRC != nullptr, silent)) { goto error; } } s_sharedCount++; - if (s_sharedHGLRC == NULL) { + if (s_sharedHGLRC == nullptr) { s_sharedHGLRC = m_hGLRC; } else if (!WIN32_CHK(::wglShareLists(s_sharedHGLRC, m_hGLRC))) { @@ -667,8 +667,8 @@ GHOST_TSuccess GHOST_ContextWGL::releaseNativeHandles() GHOST_TSuccess success = m_hGLRC != s_sharedHGLRC || s_sharedCount == 1 ? GHOST_kSuccess : GHOST_kFailure; - m_hWnd = NULL; - m_hDC = NULL; + m_hWnd = nullptr; + m_hDC = nullptr; return success; } diff --git a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm index 66131a0f70e..d92e77dbad0 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm +++ b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm @@ -133,7 +133,7 @@ GHOST_TSuccess GHOST_DisplayManagerCocoa::setCurrentDisplaySetting( (size_t)setting.xPixels, (size_t)setting.yPixels, (CGRefreshRate)setting.frequency, - NULL); + nullptr); #endif #ifdef GHOST_DEBUG diff --git a/intern/ghost/intern/GHOST_DisplayManagerWin32.cc b/intern/ghost/intern/GHOST_DisplayManagerWin32.cc index 5ca63a27323..77b0e2f3af9 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerWin32.cc +++ b/intern/ghost/intern/GHOST_DisplayManagerWin32.cc @@ -28,7 +28,7 @@ GHOST_TSuccess GHOST_DisplayManagerWin32::getNumDisplays(uint8_t &numDisplays) c static BOOL get_dd(DWORD d, DISPLAY_DEVICE *dd) { dd->cb = sizeof(DISPLAY_DEVICE); - return ::EnumDisplayDevices(NULL, d, dd, 0); + return ::EnumDisplayDevices(nullptr, d, dd, 0); } GHOST_TSuccess GHOST_DisplayManagerWin32::getNumDisplaySettings(uint8_t display, diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.cc b/intern/ghost/intern/GHOST_DropTargetWin32.cc index 513f61b0b55..e44be902779 100644 --- a/intern/ghost/intern/GHOST_DropTargetWin32.cc +++ b/intern/ghost/intern/GHOST_DropTargetWin32.cc @@ -37,14 +37,14 @@ HRESULT __stdcall GHOST_DropTargetWin32::QueryInterface(REFIID riid, void **ppv_ if (!ppv_obj) { return E_INVALIDARG; } - *ppv_obj = NULL; + *ppv_obj = nullptr; if (riid == IID_IUnknown || riid == IID_IDropTarget) { AddRef(); *ppv_obj = (void *)this; return S_OK; } - *ppv_obj = NULL; + *ppv_obj = nullptr; return E_NOINTERFACE; } @@ -87,7 +87,7 @@ HRESULT __stdcall GHOST_DropTargetWin32::DragEnter(IDataObject *p_data_object, m_draggedObjectType = getGhostType(p_data_object); m_system->pushDragDropEvent( - GHOST_kEventDraggingEntered, m_draggedObjectType, m_window, pt.x, pt.y, NULL); + GHOST_kEventDraggingEntered, m_draggedObjectType, m_window, pt.x, pt.y, nullptr); return S_OK; } @@ -107,7 +107,7 @@ HRESULT __stdcall GHOST_DropTargetWin32::DragOver(DWORD /*grf_key_state*/, // *pdw_effect = DROPEFFECT_COPY; } m_system->pushDragDropEvent( - GHOST_kEventDraggingUpdated, m_draggedObjectType, m_window, pt.x, pt.y, NULL); + GHOST_kEventDraggingUpdated, m_draggedObjectType, m_window, pt.x, pt.y, nullptr); return S_OK; } @@ -117,7 +117,7 @@ HRESULT __stdcall GHOST_DropTargetWin32::DragOver(DWORD /*grf_key_state*/, HRESULT __stdcall GHOST_DropTargetWin32::DragLeave(void) { m_system->pushDragDropEvent( - GHOST_kEventDraggingExited, m_draggedObjectType, m_window, 0, 0, NULL); + GHOST_kEventDraggingExited, m_draggedObjectType, m_window, 0, 0, nullptr); m_draggedObjectType = GHOST_kDragnDropTypeUnknown; return S_OK; } @@ -194,14 +194,14 @@ void *GHOST_DropTargetWin32::getGhostData(IDataObject *p_data_object) #ifdef WITH_GHOST_DEBUG ::printf("\nGHOST_kDragnDropTypeUnknown"); #endif /* WITH_GHOST_DEBUG */ - return NULL; + return nullptr; } - return NULL; + return nullptr; } void *GHOST_DropTargetWin32::getDropDataAsFilenames(IDataObject *p_data_object) { - GHOST_TStringArray *str_array = NULL; + GHOST_TStringArray *str_array = nullptr; FORMATETC fmtetc = {CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; /* Check if data-object supplies the format we want. @@ -211,7 +211,7 @@ void *GHOST_DropTargetWin32::getDropDataAsFilenames(IDataObject *p_data_object) if (p_data_object->GetData(&fmtetc, &stgmed) == S_OK) { const HDROP hdrop = (HDROP)::GlobalLock(stgmed.hGlobal); - const uint totfiles = ::DragQueryFileW(hdrop, -1, NULL, 0); + const uint totfiles = ::DragQueryFileW(hdrop, -1, nullptr, 0); if (totfiles) { str_array = (GHOST_TStringArray *)::malloc(sizeof(GHOST_TStringArray)); str_array->count = 0; @@ -284,23 +284,23 @@ void *GHOST_DropTargetWin32::getDropDataAsString(IDataObject *p_data_object) } } - return NULL; + return nullptr; } int GHOST_DropTargetWin32::WideCharToANSI(LPCWSTR in, char *&out) { int size; - out = NULL; /* caller should free if != NULL */ + out = nullptr; /* caller should free if != nullptr */ /* Get the required size. */ size = ::WideCharToMultiByte(CP_ACP, /* System Default Codepage */ 0x00000400, /* WC_NO_BEST_FIT_CHARS */ in, -1, /* -1 null terminated, makes output null terminated too. */ - NULL, + nullptr, 0, - NULL, - NULL); + nullptr, + nullptr); if (!size) { #ifdef WITH_GHOST_DEBUG @@ -315,14 +315,14 @@ int GHOST_DropTargetWin32::WideCharToANSI(LPCWSTR in, char *&out) return 0; } - size = ::WideCharToMultiByte(CP_ACP, 0x00000400, in, -1, (LPSTR)out, size, NULL, NULL); + size = ::WideCharToMultiByte(CP_ACP, 0x00000400, in, -1, (LPSTR)out, size, nullptr, nullptr); if (!size) { #ifdef WITH_GHOST_DEBUG ::printLastError(); #endif /* WITH_GHOST_DEBUG */ ::free(out); - out = NULL; + out = nullptr; } return size; } @@ -335,12 +335,12 @@ void printLastError(void) err = GetLastError(); if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, err, 0, (LPTSTR)&s, 0, - NULL)) + nullptr)) { printf("\nLastError: (%d) %s\n", int(err), s); LocalFree(s); diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.hh b/intern/ghost/intern/GHOST_DropTargetWin32.hh index 9e14af17da6..5596144c465 100644 --- a/intern/ghost/intern/GHOST_DropTargetWin32.hh +++ b/intern/ghost/intern/GHOST_DropTargetWin32.hh @@ -116,7 +116,7 @@ class GHOST_DropTargetWin32 : public IDropTarget { * The ANSI codepage is the system default codepage, * and can change from system to system. * \param in: LPCWSTR. - * \param out: char *. Is set to NULL on failure. + * \param out: char *. Is set to nullptr on failure. * \return 0 on failure. Else the size of the string including '\0'. */ int WideCharToANSI(LPCWSTR in, char *&out); diff --git a/intern/ghost/intern/GHOST_Event.hh b/intern/ghost/intern/GHOST_Event.hh index a0b77edc3cb..81d37181ea4 100644 --- a/intern/ghost/intern/GHOST_Event.hh +++ b/intern/ghost/intern/GHOST_Event.hh @@ -20,7 +20,7 @@ class GHOST_Event : public GHOST_IEvent { * Constructor. * \param msec: The time this event was generated. * \param type: The type of this event. - * \param window: The generating window (or NULL if system event). + * \param window: The generating window (or nullptr if system event). */ GHOST_Event(uint64_t msec, GHOST_TEventType type, GHOST_IWindow *window) : m_type(type), m_time(msec), m_window(window), m_data(nullptr) @@ -47,7 +47,7 @@ class GHOST_Event : public GHOST_IEvent { /** * Returns the window this event was generated on, - * or NULL if it is a 'system' event. + * or nullptr if it is a 'system' event. * \return The generating window. */ GHOST_IWindow *getWindow() diff --git a/intern/ghost/intern/GHOST_EventDragnDrop.hh b/intern/ghost/intern/GHOST_EventDragnDrop.hh index 8f20175769c..dcab7c817d7 100644 --- a/intern/ghost/intern/GHOST_EventDragnDrop.hh +++ b/intern/ghost/intern/GHOST_EventDragnDrop.hh @@ -74,7 +74,7 @@ class GHOST_EventDragnDrop : public GHOST_Event { ~GHOST_EventDragnDrop() { /* Free the dropped object data. */ - if (m_dragnDropEventData.data == NULL) + if (m_dragnDropEventData.data == nullptr) return; switch (m_dragnDropEventData.dataType) { diff --git a/intern/ghost/intern/GHOST_EventManager.hh b/intern/ghost/intern/GHOST_EventManager.hh index 43aeb837297..93f99a161d2 100644 --- a/intern/ghost/intern/GHOST_EventManager.hh +++ b/intern/ghost/intern/GHOST_EventManager.hh @@ -99,7 +99,7 @@ class GHOST_EventManager { * \param type: The type of events to be removed. * \param window: The window to remove the events for. */ - void removeTypeEvents(GHOST_TEventType type, GHOST_IWindow *window = NULL); + void removeTypeEvents(GHOST_TEventType type, GHOST_IWindow *window = nullptr); protected: /** diff --git a/intern/ghost/intern/GHOST_EventString.hh b/intern/ghost/intern/GHOST_EventString.hh index 6c5ad491fb9..36ebac74f94 100644 --- a/intern/ghost/intern/GHOST_EventString.hh +++ b/intern/ghost/intern/GHOST_EventString.hh @@ -20,7 +20,7 @@ class GHOST_EventString : public GHOST_Event { * Constructor. * \param msec: The time this event was generated. * \param type: The type of this event. - * \param window: The generating window (or NULL if system event). + * \param window: The generating window (or nullptr if system event). * \param data_ptr: Pointer to the (un-formatted) data associated with the event. */ GHOST_EventString(uint64_t msec, diff --git a/intern/ghost/intern/GHOST_ImeWin32.cc b/intern/ghost/intern/GHOST_ImeWin32.cc index b126fe96577..9b11c73ebe6 100644 --- a/intern/ghost/intern/GHOST_ImeWin32.cc +++ b/intern/ghost/intern/GHOST_ImeWin32.cc @@ -44,7 +44,7 @@ void GHOST_ImeWin32::UpdateInputLanguage() GetLocaleInfoEx(locale, LOCALE_SISO639LANGNAME, language_u16, W32_ISO639_LEN); /* Store this as a UTF-8 string. */ WideCharToMultiByte( - CP_UTF8, 0, language_u16, W32_ISO639_LEN, language_, W32_ISO639_LEN, NULL, NULL); + CP_UTF8, 0, language_u16, W32_ISO639_LEN, language_, W32_ISO639_LEN, nullptr, nullptr); } BOOL GHOST_ImeWin32::IsLanguage(const char name[W32_ISO639_LEN]) @@ -115,7 +115,7 @@ void GHOST_ImeWin32::CreateImeWindow(HWND window_handle) * their window position, we also create a caret for Japanese IMEs. */ if (!system_caret_ && (IsLanguage(IMELANG_CHINESE) || IsLanguage(IMELANG_JAPANESE))) { - system_caret_ = ::CreateCaret(window_handle, NULL, 1, 1); + system_caret_ = ::CreateCaret(window_handle, nullptr, 1, 1); } /* Restore the positions of the IME windows. */ UpdateImeWindow(window_handle); @@ -267,7 +267,7 @@ void GHOST_ImeWin32::GetCaret(HIMC imm_context, LPARAM lparam, ImeComposition *c } } else if (IsLanguage(IMELANG_CHINESE)) { - int clause_size = ImmGetCompositionStringW(imm_context, GCS_COMPCLAUSE, NULL, 0); + int clause_size = ImmGetCompositionStringW(imm_context, GCS_COMPCLAUSE, nullptr, 0); if (clause_size) { static std::vector clauses; clause_size = clause_size / sizeof(clauses[0]); @@ -303,7 +303,7 @@ void GHOST_ImeWin32::GetCaret(HIMC imm_context, LPARAM lparam, ImeComposition *c * a clause being converted. */ if (lparam & GCS_COMPATTR) { - int attribute_size = ::ImmGetCompositionStringW(imm_context, GCS_COMPATTR, NULL, 0); + int attribute_size = ::ImmGetCompositionStringW(imm_context, GCS_COMPATTR, nullptr, 0); if (attribute_size > 0) { char *attribute_data = new char[attribute_size]; if (attribute_data) { @@ -346,7 +346,7 @@ bool GHOST_ImeWin32::GetString(HIMC imm_context, { bool result = false; if (lparam & type) { - int string_size = ::ImmGetCompositionStringW(imm_context, type, NULL, 0); + int string_size = ::ImmGetCompositionStringW(imm_context, type, nullptr, 0); if (string_size > 0) { int string_length = string_size / sizeof(wchar_t); wchar_t *string_data = new wchar_t[string_length + 1]; @@ -392,7 +392,7 @@ bool GHOST_ImeWin32::GetComposition(HWND window_handle, LPARAM lparam, ImeCompos result = GetString(imm_context, lparam, GCS_COMPSTR, composition); /* Retrieve the cursor position in the IME composition. */ - int cursor_position = ::ImmGetCompositionStringW(imm_context, GCS_CURSORPOS, NULL, 0); + int cursor_position = ::ImmGetCompositionStringW(imm_context, GCS_CURSORPOS, nullptr, 0); composition->cursor_position = cursor_position; composition->target_start = -1; composition->target_end = -1; @@ -421,7 +421,7 @@ void GHOST_ImeWin32::EndIME(HWND window_handle) return; is_enable = false; CleanupComposition(window_handle); - ::ImmAssociateContextEx(window_handle, NULL, 0); + ::ImmAssociateContextEx(window_handle, nullptr, 0); eventImeData.composite_len = 0; } @@ -436,7 +436,7 @@ void GHOST_ImeWin32::BeginIME(HWND window_handle, const GHOST_Rect &caret_rect, * IMM ignores this call if the IME context is loaded. Therefore, we do * not have to check whether or not the IME context is loaded. */ - ::ImmAssociateContextEx(window_handle, NULL, IACE_DEFAULT); + ::ImmAssociateContextEx(window_handle, nullptr, IACE_DEFAULT); /* Complete the ongoing composition and move the IME windows. */ HIMC imm_context = ::ImmGetContext(window_handle); if (imm_context) { diff --git a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm index 95b757776d7..4b9a632f010 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm +++ b/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm @@ -15,8 +15,8 @@ #endif // static callback functions need to talk to these objects: -static GHOST_SystemCocoa *ghost_system = NULL; -static GHOST_NDOFManager *ndof_manager = NULL; +static GHOST_SystemCocoa *ghost_system = nullptr; +static GHOST_NDOFManager *ndof_manager = nullptr; static uint16_t clientID = 0; @@ -73,7 +73,7 @@ typedef int16_t (*ConnexionClientControl_ptr)(uint16_t clientID, int32_t param, int32_t *result); -#define DECLARE_FUNC(name) name##_ptr name = NULL +#define DECLARE_FUNC(name) name##_ptr name = nullptr DECLARE_FUNC(SetConnexionHandlers); DECLARE_FUNC(InstallConnexionHandlers); @@ -115,14 +115,14 @@ static bool load_driver_functions() if (module) { LOAD_FUNC(SetConnexionHandlers); - if (SetConnexionHandlers != NULL) { + if (SetConnexionHandlers != nullptr) { driver_loaded = true; has_new_driver = true; } else { LOAD_FUNC(InstallConnexionHandlers); - driver_loaded = (InstallConnexionHandlers != NULL); + driver_loaded = (InstallConnexionHandlers != nullptr); } if (driver_loaded) { @@ -132,7 +132,7 @@ static bool load_driver_functions() LOAD_FUNC(UnregisterConnexionClient); LOAD_FUNC(ConnexionClientControl); - has_old_driver = (SetConnexionClientButtonMask == NULL); + has_old_driver = (SetConnexionClientButtonMask == nullptr); } } #if DEBUG_NDOF_DRIVER @@ -259,8 +259,8 @@ GHOST_NDOFManagerCocoa::~GHOST_NDOFManagerCocoa() CleanupConnexionHandlers(); unload_driver(); - ghost_system = NULL; - ndof_manager = NULL; + ghost_system = nullptr; + ndof_manager = nullptr; } } diff --git a/intern/ghost/intern/GHOST_SystemCocoa.hh b/intern/ghost/intern/GHOST_SystemCocoa.hh index b3e59a654fd..3e8975689b9 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.hh +++ b/intern/ghost/intern/GHOST_SystemCocoa.hh @@ -92,7 +92,7 @@ class GHOST_SystemCocoa : public GHOST_System { GHOST_GPUSettings gpuSettings, const bool exclusive = false, const bool is_dialog = false, - const GHOST_IWindow *parentWindow = NULL); + const GHOST_IWindow *parentWindow = nullptr); /** * Create a new off-screen context. diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index a77e1882408..a9d8fb4b52b 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -502,7 +502,7 @@ GHOST_SystemCocoa::GHOST_SystemCocoa() int mib[2]; struct timeval boottime; size_t len; - char *rstring = NULL; + char *rstring = nullptr; m_modifierMask = 0; m_outsideLoopEventProcessed = false; @@ -516,18 +516,18 @@ GHOST_SystemCocoa::GHOST_SystemCocoa() mib[1] = KERN_BOOTTIME; len = sizeof(struct timeval); - sysctl(mib, 2, &boottime, &len, NULL, 0); + sysctl(mib, 2, &boottime, &len, nullptr, 0); m_start_time = ((boottime.tv_sec * 1000) + (boottime.tv_usec / 1000)); /* Detect multi-touch track-pad. */ mib[0] = CTL_HW; mib[1] = HW_MODEL; - sysctl(mib, 2, NULL, &len, NULL, 0); + sysctl(mib, 2, nullptr, &len, nullptr, 0); rstring = (char *)malloc(len); - sysctl(mib, 2, rstring, &len, NULL, 0); + sysctl(mib, 2, rstring, &len, nullptr, 0); free(rstring); - rstring = NULL; + rstring = nullptr; m_ignoreWindowSizedMessages = false; m_ignoreMomentumScroll = false; @@ -657,7 +657,7 @@ uint64_t GHOST_SystemCocoa::getMilliSeconds() const // Cocoa equivalent exists in 10.6 ([[NSProcessInfo processInfo] systemUptime]) struct timeval currentTime; - gettimeofday(¤tTime, NULL); + gettimeofday(¤tTime, nullptr); // Return timestamp of system uptime @@ -707,7 +707,7 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const char *title, const bool is_dialog, const GHOST_IWindow *parentWindow) { - GHOST_IWindow *window = NULL; + GHOST_IWindow *window = nullptr; @autoreleasepool { // Get the available rect for including window contents @@ -750,7 +750,7 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const char *title, else { GHOST_PRINT("GHOST_SystemCocoa::createWindow(): window invalid\n"); delete window; - window = NULL; + window = nullptr; } } return window; @@ -768,7 +768,7 @@ GHOST_IContext *GHOST_SystemCocoa::createOffscreenContext(GHOST_GPUSettings gpuS switch (gpuSettings.context_type) { #ifdef WITH_VULKAN_BACKEND case GHOST_kDrawingContextTypeVulkan: { - GHOST_Context *context = new GHOST_ContextVK(false, NULL, 1, 2, debug_context); + GHOST_Context *context = new GHOST_ContextVK(false, nullptr, 1, 2, debug_context); if (context->initializeDrawingContext()) { return context; } @@ -780,7 +780,7 @@ GHOST_IContext *GHOST_SystemCocoa::createOffscreenContext(GHOST_GPUSettings gpuS #ifdef WITH_METAL_BACKEND case GHOST_kDrawingContextTypeMetal: { /* TODO(fclem): Remove OpenGL support and rename context to ContextMTL */ - GHOST_Context *context = new GHOST_ContextCGL(false, NULL, NULL, debug_context); + GHOST_Context *context = new GHOST_ContextCGL(false, nullptr, nullptr, debug_context); if (context->initializeDrawingContext()) { return context; } @@ -953,7 +953,7 @@ bool GHOST_SystemCocoa::processEvents(bool /*waitForEvent*/) timeOut = 0.0; } - ::ReceiveNextEvent(0, NULL, timeOut, false, &event); + ::ReceiveNextEvent(0, nullptr, timeOut, false, &event); } if (timerMgr->fireTimers(getMilliSeconds())) { @@ -1172,7 +1172,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType case GHOST_kEventDraggingExited: window->clientToScreenIntern(mouseX, mouseY, mouseX, mouseY); pushEvent(new GHOST_EventDragnDrop( - getMilliSeconds(), eventType, draggedObjectType, window, mouseX, mouseY, NULL)); + getMilliSeconds(), eventType, draggedObjectType, window, mouseX, mouseY, nullptr)); break; case GHOST_kEventDraggingDropDone: { @@ -1231,7 +1231,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType temp_buff = (uint8_t *)malloc(pastedTextSize + 1); - if (temp_buff == NULL) { + if (temp_buff == nullptr) { return GHOST_kFailure; } @@ -1247,10 +1247,10 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType case GHOST_kDragnDropTypeBitmap: { NSImage *droppedImg = (NSImage *)data; NSSize imgSize = [droppedImg size]; - ImBuf *ibuf = NULL; - uint8_t *rasterRGB = NULL; - uint8_t *rasterRGBA = NULL; - uint8_t *toIBuf = NULL; + ImBuf *ibuf = nullptr; + uint8_t *rasterRGB = nullptr; + uint8_t *rasterRGBA = nullptr; + uint8_t *toIBuf = nullptr; int x, y, to_i, from_i; NSBitmapImageRep *blBitmapFormatImageRGB, *blBitmapFormatImageRGBA, *bitmapImage = nil; NSEnumerator *enumerator; @@ -1296,7 +1296,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType /* First get RGB values w/o Alpha to avoid pre-multiplication, * 32bit but last byte is unused */ blBitmapFormatImageRGB = [[NSBitmapImageRep alloc] - initWithBitmapDataPlanes:NULL + initWithBitmapDataPlanes:nullptr pixelsWide:imgSize.width pixelsHigh:imgSize.height bitsPerSample:8 @@ -1316,7 +1316,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType [NSGraphicsContext restoreGraphicsState]; rasterRGB = (uint8_t *)[blBitmapFormatImageRGB bitmapData]; - if (rasterRGB == NULL) { + if (rasterRGB == nullptr) { [bitmapImage release]; [blBitmapFormatImageRGB release]; [droppedImg release]; @@ -1325,7 +1325,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType /* Then get Alpha values by getting the RGBA image (that is pre-multiplied BTW) */ blBitmapFormatImageRGBA = [[NSBitmapImageRep alloc] - initWithBitmapDataPlanes:NULL + initWithBitmapDataPlanes:nullptr pixelsWide:imgSize.width pixelsHigh:imgSize.height bitsPerSample:8 @@ -1345,7 +1345,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType [NSGraphicsContext restoreGraphicsState]; rasterRGBA = (uint8_t *)[blBitmapFormatImageRGBA bitmapData]; - if (rasterRGBA == NULL) { + if (rasterRGBA == nullptr) { [bitmapImage release]; [blBitmapFormatImageRGB release]; [blBitmapFormatImageRGBA release]; @@ -1422,7 +1422,7 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr) } GHOST_Window *window = m_windowManager->getWindows().empty() ? - NULL : + nullptr : (GHOST_Window *)m_windowManager->getWindows().front(); if (!window) { @@ -1438,7 +1438,7 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr) filenameTextSize = [filepath lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; temp_buff = (char *)malloc(filenameTextSize + 1); - if (temp_buff == NULL) { + if (temp_buff == nullptr) { return GHOST_kFailure; } @@ -1898,7 +1898,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr) } else { pushEvent(new GHOST_EventKey( - [event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, false, NULL)); + [event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, false, nullptr)); #if 0 printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u utf8=%s\n", [event keyCode], @@ -1976,15 +1976,15 @@ char *GHOST_SystemCocoa::getClipboard(bool /*selection*/) const NSString *textPasted = [pasteBoard stringForType:NSPasteboardTypeString]; if (textPasted == nil) { - return NULL; + return nullptr; } pastedTextSize = [textPasted lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; temp_buff = (char *)malloc(pastedTextSize + 1); - if (temp_buff == NULL) { - return NULL; + if (temp_buff == nullptr) { + return nullptr; } strncpy(temp_buff, [textPasted cStringUsingEncoding:NSUTF8StringEncoding], pastedTextSize); @@ -1995,7 +1995,7 @@ char *GHOST_SystemCocoa::getClipboard(bool /*selection*/) const return temp_buff; } else { - return NULL; + return nullptr; } } } diff --git a/intern/ghost/intern/GHOST_SystemPathsCocoa.mm b/intern/ghost/intern/GHOST_SystemPathsCocoa.mm index 28416ad960d..bb3a009e6df 100644 --- a/intern/ghost/intern/GHOST_SystemPathsCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemPathsCocoa.mm @@ -26,7 +26,7 @@ static const char *GetApplicationSupportDir(const char *versionstr, NSApplicationSupportDirectory, mask, YES); if ([paths count] == 0) { - return NULL; + return nullptr; } const NSString *const basePath = [paths objectAtIndex:0]; @@ -83,13 +83,13 @@ const char *GHOST_SystemPathsCocoa::getUserSpecialDir(GHOST_TUserSpecialDirTypes GHOST_ASSERT( false, "GHOST_SystemPathsCocoa::getUserSpecialDir(): Invalid enum value for type parameter"); - return NULL; + return nullptr; } const NSArray *const paths = NSSearchPathForDirectoriesInDomains( ns_directory, NSUserDomainMask, YES); if ([paths count] == 0) { - return NULL; + return nullptr; } const NSString *const basePath = [paths objectAtIndex:0]; @@ -106,7 +106,7 @@ const char *GHOST_SystemPathsCocoa::getBinaryDir() const const NSString *const basePath = [[NSBundle mainBundle] bundlePath]; if (basePath == nil) { - return NULL; + return nullptr; } strcpy(tempPath, [basePath cStringUsingEncoding:NSASCIIStringEncoding]); diff --git a/intern/ghost/intern/GHOST_SystemPathsWin32.cc b/intern/ghost/intern/GHOST_SystemPathsWin32.cc index a77d1b68fcf..bf233805abf 100644 --- a/intern/ghost/intern/GHOST_SystemPathsWin32.cc +++ b/intern/ghost/intern/GHOST_SystemPathsWin32.cc @@ -23,10 +23,10 @@ const char *GHOST_SystemPathsWin32::getSystemDir(int, const char *versionstr) co { /* 1 utf-16 might translate into 3 utf-8. 2 utf-16 translates into 4 utf-8. */ static char knownpath[MAX_PATH * 3 + 128] = {0}; - PWSTR knownpath_16 = NULL; + PWSTR knownpath_16 = nullptr; HRESULT hResult = SHGetKnownFolderPath( - FOLDERID_ProgramData, KF_FLAG_DEFAULT, NULL, &knownpath_16); + FOLDERID_ProgramData, KF_FLAG_DEFAULT, nullptr, &knownpath_16); if (hResult == S_OK) { conv_utf_16_to_8(knownpath_16, knownpath, MAX_PATH * 3); @@ -36,16 +36,16 @@ const char *GHOST_SystemPathsWin32::getSystemDir(int, const char *versionstr) co return knownpath; } - return NULL; + return nullptr; } const char *GHOST_SystemPathsWin32::getUserDir(int, const char *versionstr) const { static char knownpath[MAX_PATH * 3 + 128] = {0}; - PWSTR knownpath_16 = NULL; + PWSTR knownpath_16 = nullptr; HRESULT hResult = SHGetKnownFolderPath( - FOLDERID_RoamingAppData, KF_FLAG_DEFAULT, NULL, &knownpath_16); + FOLDERID_RoamingAppData, KF_FLAG_DEFAULT, nullptr, &knownpath_16); if (hResult == S_OK) { conv_utf_16_to_8(knownpath_16, knownpath, MAX_PATH * 3); @@ -55,7 +55,7 @@ const char *GHOST_SystemPathsWin32::getUserDir(int, const char *versionstr) cons return knownpath; } - return NULL; + return nullptr; } const char *GHOST_SystemPathsWin32::getUserSpecialDir(GHOST_TUserSpecialDirTypes type) const @@ -88,12 +88,12 @@ const char *GHOST_SystemPathsWin32::getUserSpecialDir(GHOST_TUserSpecialDirTypes GHOST_ASSERT( false, "GHOST_SystemPathsWin32::getUserSpecialDir(): Invalid enum value for type parameter"); - return NULL; + return nullptr; } static char knownpath[MAX_PATH * 3] = {0}; - PWSTR knownpath_16 = NULL; - HRESULT hResult = SHGetKnownFolderPath(folderid, KF_FLAG_DEFAULT, NULL, &knownpath_16); + PWSTR knownpath_16 = nullptr; + HRESULT hResult = SHGetKnownFolderPath(folderid, KF_FLAG_DEFAULT, nullptr, &knownpath_16); if (hResult == S_OK) { conv_utf_16_to_8(knownpath_16, knownpath, MAX_PATH * 3); @@ -102,7 +102,7 @@ const char *GHOST_SystemPathsWin32::getUserSpecialDir(GHOST_TUserSpecialDirTypes } CoTaskMemFree(knownpath_16); - return NULL; + return nullptr; } const char *GHOST_SystemPathsWin32::getBinaryDir() const @@ -115,7 +115,7 @@ const char *GHOST_SystemPathsWin32::getBinaryDir() const return fullname; } - return NULL; + return nullptr; } void GHOST_SystemPathsWin32::addToSystemRecentFiles(const char *filepath) const @@ -125,11 +125,11 @@ void GHOST_SystemPathsWin32::addToSystemRecentFiles(const char *filepath) const SHARDAPPIDINFO info; IShellItem *shell_item; - HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (!SUCCEEDED(hr)) return; - hr = SHCreateItemFromParsingName(filepath_16, NULL, IID_PPV_ARGS(&shell_item)); + hr = SHCreateItemFromParsingName(filepath_16, nullptr, IID_PPV_ARGS(&shell_item)); if (SUCCEEDED(hr)) { info.psi = shell_item; info.pszAppID = BLENDER_WIN_APPID_16; diff --git a/intern/ghost/intern/GHOST_SystemWayland.cc b/intern/ghost/intern/GHOST_SystemWayland.cc index dd86722b858..4947e2de12f 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cc +++ b/intern/ghost/intern/GHOST_SystemWayland.cc @@ -736,12 +736,12 @@ struct GWL_Seat { /** * Keep a state with shift enabled, use to access predictable number access for AZERTY keymaps. - * If shift is not supported by the key-map, this is set to NULL. + * If shift is not supported by the key-map, this is set to nullptr. */ struct xkb_state *xkb_state_empty_with_shift = nullptr; /** * Keep a state with number-lock enabled, use to access predictable key-pad symbols. - * If number-lock is not supported by the key-map, this is set to NULL. + * If number-lock is not supported by the key-map, this is set to nullptr. */ struct xkb_state *xkb_state_empty_with_numlock = nullptr; @@ -1789,7 +1789,7 @@ static size_t ghost_wl_shm_format_as_size(enum wl_shm_format format) } /** - * Return a #wl_buffer, ready to have it's data filled in or NULL in case of failure. + * Return a #wl_buffer, ready to have it's data filled in or nullptr in case of failure. * The caller is responsible for calling `unmap(buffer_data, buffer_size)`. * * \param r_buffer_data: The buffer to be filled. @@ -4993,7 +4993,7 @@ static void gwl_registry_wl_seat_remove(GWL_Display *display, void *user_data, c gwl_seat_capability_keyboard_disable(seat); gwl_seat_capability_touch_disable(seat); - /* Un-referencing checks for NULL case. */ + /* Un-referencing checks for nullptr case. */ xkb_state_unref(seat->xkb_state); xkb_state_unref(seat->xkb_state_empty); xkb_state_unref(seat->xkb_state_empty_with_shift); @@ -6270,7 +6270,7 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GPUSettings gp GHOST_Context *context = new GHOST_ContextVK(false, GHOST_kVulkanPlatformWayland, 0, - NULL, + nullptr, wl_surface, display_->wl_display, 1, @@ -6997,7 +6997,7 @@ GHOST_TimerManager *GHOST_SystemWayland::ghost_timer_manager() GWL_Output *ghost_wl_output_user_data(wl_output *wl_output) { - GHOST_ASSERT(wl_output, "output must not be NULL"); + GHOST_ASSERT(wl_output, "output must not be nullptr"); GHOST_ASSERT(ghost_wl_output_own(wl_output), "output is not owned by GHOST"); GWL_Output *output = static_cast(wl_output_get_user_data(wl_output)); return output; @@ -7005,7 +7005,7 @@ GWL_Output *ghost_wl_output_user_data(wl_output *wl_output) GHOST_WindowWayland *ghost_wl_surface_user_data(wl_surface *wl_surface) { - GHOST_ASSERT(wl_surface, "wl_surface must not be NULL"); + GHOST_ASSERT(wl_surface, "wl_surface must not be nullptr"); GHOST_ASSERT(ghost_wl_surface_own(wl_surface), "wl_surface is not owned by GHOST"); GHOST_WindowWayland *win = static_cast( wl_surface_get_user_data(wl_surface)); diff --git a/intern/ghost/intern/GHOST_SystemWayland.hh b/intern/ghost/intern/GHOST_SystemWayland.hh index 349cb34604a..3c30f03a8ee 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.hh +++ b/intern/ghost/intern/GHOST_SystemWayland.hh @@ -256,7 +256,7 @@ class GHOST_SystemWayland : public GHOST_System { void output_scale_update(GWL_Output *output); /** - * Clear all references to this surface to prevent accessing NULL pointers. + * Clear all references to this surface to prevent accessing nullptr pointers. * * \return true when any references were removed. */ diff --git a/intern/ghost/intern/GHOST_SystemWin32.cc b/intern/ghost/intern/GHOST_SystemWin32.cc index 6eaf9cf9d03..28600220c01 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cc +++ b/intern/ghost/intern/GHOST_SystemWin32.cc @@ -255,7 +255,7 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow(const char *title, else { GHOST_PRINT("GHOST_SystemWin32::createWindow(): window invalid\n"); delete window; - window = NULL; + window = nullptr; } return window; @@ -293,10 +293,10 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext(GHOST_GPUSettings gpuS 0, 64, 64, - NULL, - NULL, - GetModuleHandle(NULL), - NULL); + nullptr, + nullptr, + GetModuleHandle(nullptr), + nullptr); HDC mHDC = GetDC(wnd); HDC prev_hdc = wglGetCurrentDC(); @@ -356,10 +356,10 @@ GHOST_ContextD3D *GHOST_SystemWin32::createOffscreenContextD3D() 0, 64, 64, - NULL, - NULL, - GetModuleHandle(NULL), - NULL); + nullptr, + nullptr, + GetModuleHandle(nullptr), + nullptr); GHOST_ContextD3D *context = new GHOST_ContextD3D(false, wnd); if (context->initializeDrawingContext()) { @@ -384,7 +384,7 @@ bool GHOST_SystemWin32::processEvents(bool waitForEvent) do { GHOST_TimerManager *timerMgr = getTimerManager(); - if (waitForEvent && !::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + if (waitForEvent && !::PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) { #if 1 ::Sleep(1); #else @@ -395,9 +395,9 @@ bool GHOST_SystemWin32::processEvents(bool waitForEvent) ::WaitMessage(); } else if (maxSleep >= 0.0) { - ::SetTimer(NULL, 0, maxSleep, NULL); + ::SetTimer(nullptr, 0, maxSleep, nullptr); ::WaitMessage(); - ::KillTimer(NULL, 0); + ::KillTimer(nullptr, 0); } #endif } @@ -409,7 +409,7 @@ bool GHOST_SystemWin32::processEvents(bool waitForEvent) driveTrackpad(); /* Process all the events waiting for us. */ - while (::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE) != 0) { + while (::PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE) != 0) { /* #TranslateMessage doesn't alter the message, and doesn't change our raw keyboard data. * Needed for #MapVirtualKey or if we ever need to get chars from wm_ime_char or similar. */ ::TranslateMessage(&msg); @@ -532,7 +532,7 @@ GHOST_TSuccess GHOST_SystemWin32::init() wc.hIcon = ::LoadIcon(wc.hInstance, "APPICON"); if (!wc.hIcon) { - ::LoadIcon(NULL, IDI_APPLICATION); + ::LoadIcon(nullptr, IDI_APPLICATION); } wc.hCursor = ::LoadCursor(0, IDC_ARROW); wc.hbrBackground = @@ -1062,7 +1062,7 @@ GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind if (window->getTabletData().Active != GHOST_kTabletModeNone) { /* While pen devices are in range, cursor movement is handled by tablet input processing. */ - return NULL; + return nullptr; } int32_t x_screen = screen_co[0], y_screen = screen_co[1]; @@ -1138,7 +1138,7 @@ GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind /* When wrapping we don't need to add an event because the setCursorPosition call will cause * a new event after. */ - return NULL; + return nullptr; } is_warping_x = false; @@ -1247,7 +1247,7 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA if (key_down && ((utf8_char[0] & 0x80) == 0)) { const char ascii = utf8_char[0]; if (window->getImeInput()->IsImeKeyEvent(ascii, key)) { - return NULL; + return nullptr; } } #endif /* WITH_INPUT_IME */ @@ -1264,7 +1264,7 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA #endif } else { - event = NULL; + event = nullptr; } return event; @@ -1280,7 +1280,7 @@ GHOST_Event *GHOST_SystemWin32::processWindowSizeEvent(GHOST_WindowWin32 *window if (window->m_inLiveResize) { system->pushEvent(sizeEvent); system->dispatchEvents(); - return NULL; + return nullptr; } return sizeEvent; } @@ -1468,7 +1468,7 @@ void GHOST_SystemWin32::processTrackpad() LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, uint msg, WPARAM wParam, LPARAM lParam) { - GHOST_Event *event = NULL; + GHOST_Event *event = nullptr; bool eventHandled = false; LRESULT lResult = 0; @@ -2011,7 +2011,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, uint msg, WPARAM wParam, */ if (!window->m_inLiveResize) { event = processWindowEvent(GHOST_kEventWindowUpdate, window); - ::ValidateRect(hwnd, NULL); + ::ValidateRect(hwnd, nullptr); } else { eventHandled = true; @@ -2084,7 +2084,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, uint msg, WPARAM wParam, /* Then move and resize window. */ SetWindowPos(hwnd, - NULL, + nullptr, suggestedWindowRect->left, suggestedWindowRect->top, suggestedWindowRect->right - suggestedWindowRect->left, @@ -2111,8 +2111,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, uint msg, WPARAM wParam, break; } case WM_SETTINGCHANGE: { - /* Microsoft: "Note that some applications send this message with lParam set to NULL" */ - if ((lParam != NULL) && (wcscmp(LPCWSTR(lParam), L"ImmersiveColorSet") == 0)) { + /* Microsoft: "Note that some applications send this message with lParam set to nullptr" + */ + if (((void *)lParam != nullptr) && (wcscmp(LPCWSTR(lParam), L"ImmersiveColorSet") == 0)) + { window->ThemeRefresh(); } break; @@ -2228,17 +2230,17 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, uint msg, WPARAM wParam, char *GHOST_SystemWin32::getClipboard(bool /*selection*/) const { - if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL)) { + if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(nullptr)) { wchar_t *buffer; HANDLE hData = GetClipboardData(CF_UNICODETEXT); - if (hData == NULL) { + if (hData == nullptr) { CloseClipboard(); - return NULL; + return nullptr; } buffer = (wchar_t *)GlobalLock(hData); if (!buffer) { CloseClipboard(); - return NULL; + return nullptr; } char *temp_buff = alloc_utf_8_from_16(buffer, 0); @@ -2250,18 +2252,18 @@ char *GHOST_SystemWin32::getClipboard(bool /*selection*/) const return temp_buff; } - if (IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL)) { + if (IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(nullptr)) { char *buffer; size_t len = 0; HANDLE hData = GetClipboardData(CF_TEXT); - if (hData == NULL) { + if (hData == nullptr) { CloseClipboard(); - return NULL; + return nullptr; } buffer = (char *)GlobalLock(hData); if (!buffer) { CloseClipboard(); - return NULL; + return nullptr; } len = strlen(buffer); @@ -2285,7 +2287,7 @@ void GHOST_SystemWin32::putClipboard(const char *buffer, bool selection) const return; } /* For copying the selection, used on X11. */ - if (OpenClipboard(NULL)) { + if (OpenClipboard(nullptr)) { EmptyClipboard(); /* Get length of buffer including the terminating null. */ @@ -2589,10 +2591,10 @@ GHOST_TSuccess GHOST_SystemWin32::showMessageBox(const char *title, config.pButtons = (link) ? buttons : buttons + 1; config.cButtons = (link) ? 2 : 1; - TaskDialogIndirect(&config, &nButtonPressed, NULL, NULL); + TaskDialogIndirect(&config, &nButtonPressed, nullptr, nullptr); switch (nButtonPressed) { case IDOK: - ShellExecute(NULL, "open", link, NULL, NULL, SW_SHOWNORMAL); + ShellExecute(nullptr, "open", link, nullptr, nullptr, SW_SHOWNORMAL); break; case IDCONTINUE: break; @@ -2659,8 +2661,8 @@ static bool isStartedFromCommandPrompt() GetWindowThreadProcessId(hwnd, &pid); if (getProcessName(ppid, parent_name, sizeof(parent_name))) { char *filename = strrchr(parent_name, '\\'); - if (filename != NULL) { - start_from_launcher = strstr(filename, "blender.exe") != NULL; + if (filename != nullptr) { + start_from_launcher = strstr(filename, "blender.exe") != nullptr; } } diff --git a/intern/ghost/intern/GHOST_SystemX11.cc b/intern/ghost/intern/GHOST_SystemX11.cc index b5f01e812b2..edab92bf02c 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cc +++ b/intern/ghost/intern/GHOST_SystemX11.cc @@ -359,7 +359,7 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GPUSettings gpuSet #ifdef WITH_VULKAN_BACKEND case GHOST_kDrawingContextTypeVulkan: { GHOST_Context *context = new GHOST_ContextVK( - false, GHOST_kVulkanPlatformX11, 0, m_display, NULL, NULL, 1, 2, debug_context); + false, GHOST_kVulkanPlatformX11, 0, m_display, nullptr, nullptr, 1, 2, debug_context); if (context->initializeDrawingContext()) { return context; } diff --git a/intern/ghost/intern/GHOST_TrackpadWin32.cc b/intern/ghost/intern/GHOST_TrackpadWin32.cc index 3a1f3862878..db7b018e27c 100644 --- a/intern/ghost/intern/GHOST_TrackpadWin32.cc +++ b/intern/ghost/intern/GHOST_TrackpadWin32.cc @@ -21,8 +21,8 @@ GHOST_DirectManipulationHelper::GHOST_DirectManipulationHelper( DWORD directManipulationViewportHandlerCookie, bool isScrollDirectionInverted) : m_hWnd(hWnd), - m_scrollDirectionRegKey(NULL), - m_scrollDirectionChangeEvent(NULL), + m_scrollDirectionRegKey(nullptr), + m_scrollDirectionChangeEvent(nullptr), m_directManipulationManager(directManipulationManager), m_directManipulationUpdateManager(directManipulationUpdateManager), m_directManipulationViewport(directManipulationViewport), @@ -123,7 +123,7 @@ bool GHOST_DirectManipulationHelper::getScrollDirectionFromReg() L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\PrecisionTouchPad\\", L"ScrollDirection", RRF_RT_REG_DWORD, - NULL, + nullptr, &scrollDirectionRegValue, &pcbData)); if (!SUCCEEDED(hr)) { @@ -151,7 +151,7 @@ void GHOST_DirectManipulationHelper::registerScrollDirectionChangeListener() } if (!m_scrollDirectionChangeEvent) { - m_scrollDirectionChangeEvent = CreateEventW(NULL, true, false, NULL); + m_scrollDirectionChangeEvent = CreateEventW(nullptr, true, false, nullptr); } else { ResetEvent(m_scrollDirectionChangeEvent); @@ -219,11 +219,11 @@ GHOST_DirectManipulationHelper::~GHOST_DirectManipulationHelper() if (m_scrollDirectionChangeEvent) { CloseHandle(m_scrollDirectionChangeEvent); - m_scrollDirectionChangeEvent = NULL; + m_scrollDirectionChangeEvent = nullptr; } if (m_scrollDirectionRegKey) { RegCloseKey(m_scrollDirectionRegKey); - m_scrollDirectionRegKey = NULL; + m_scrollDirectionRegKey = nullptr; } } diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index 8e4f3b1fd6e..e01faa17dfa 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -458,7 +458,7 @@ GHOST_WindowCocoa::~GHOST_WindowCocoa() bool GHOST_WindowCocoa::getValid() const { NSView *view = (m_openGLView) ? m_openGLView : m_metalView; - return GHOST_Window::getValid() && m_window != NULL && view != NULL; + return GHOST_Window::getValid() && m_window != nullptr && view != nullptr; } void *GHOST_WindowCocoa::getOSWindow() const @@ -940,7 +940,7 @@ static NSCursor *getImageCursor(GHOST_TStandardCursor shape, NSString *name, NSP @autoreleasepool { /* clang-format on */ NSImage *image = [NSImage imageNamed:name]; - if (image != NULL) { + if (image != nullptr) { cursors[index] = [[NSCursor alloc] initWithImage:image hotSpot:hotspot]; } } @@ -959,7 +959,7 @@ NSCursor *GHOST_WindowCocoa::getStandardCursor(GHOST_TStandardCursor shape) cons return m_customCursor; } else { - return NULL; + return nullptr; } case GHOST_kStandardCursorDestroy: return [NSCursor disappearingItemCursor]; @@ -1024,7 +1024,7 @@ NSCursor *GHOST_WindowCocoa::getStandardCursor(GHOST_TStandardCursor shape) cons case GHOST_kStandardCursorCrosshairC: return getImageCursor(shape, @"crossc.pdf", NSMakePoint(16, 16)); default: - return NULL; + return nullptr; } } @@ -1043,7 +1043,7 @@ void GHOST_WindowCocoa::loadCursor(bool visible, GHOST_TStandardCursor shape) co } NSCursor *cursor = getStandardCursor(shape); - if (cursor == NULL) { + if (cursor == nullptr) { cursor = getStandardCursor(GHOST_kStandardCursorDefault); } diff --git a/intern/ghost/intern/GHOST_WindowManager.hh b/intern/ghost/intern/GHOST_WindowManager.hh index b411121faa3..90a6257f7ff 100644 --- a/intern/ghost/intern/GHOST_WindowManager.hh +++ b/intern/ghost/intern/GHOST_WindowManager.hh @@ -59,7 +59,7 @@ class GHOST_WindowManager { /** * Returns pointer to the full-screen window. - * \return The full-screen window (NULL if not in full-screen). + * \return The full-screen window (nullptr if not in full-screen). */ GHOST_IWindow *getFullScreenWindow() const; @@ -86,7 +86,7 @@ class GHOST_WindowManager { /** * Returns the active window (the window receiving events). * There can be only one window active which should be in the current window list. - * \return window The active window (or NULL if there is none). + * \return window The active window (or nullptr if there is none). */ GHOST_IWindow *getActiveWindow() const; diff --git a/intern/ghost/intern/GHOST_WindowWayland.cc b/intern/ghost/intern/GHOST_WindowWayland.cc index 30944aa9511..d54ac3e4977 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cc +++ b/intern/ghost/intern/GHOST_WindowWayland.cc @@ -1762,7 +1762,7 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType GHOST_Context *context = new GHOST_ContextVK(m_wantStereoVisual, GHOST_kVulkanPlatformWayland, 0, - NULL, + nullptr, window_->wl_surface, system_->wl_display(), 1, diff --git a/intern/ghost/intern/GHOST_WindowWin32.cc b/intern/ghost/intern/GHOST_WindowWin32.cc index b1cbf352de6..4bc46a71d49 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cc +++ b/intern/ghost/intern/GHOST_WindowWin32.cc @@ -62,7 +62,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, m_mousePresent(false), m_inLiveResize(false), m_system(system), - m_dropTarget(NULL), + m_dropTarget(nullptr), m_hWnd(0), m_hDC(0), m_isDialog(dialog), @@ -71,13 +71,13 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, m_nPressedButtons(0), m_customCursor(0), m_wantAlphaBackground(alphaBackground), - m_Bar(NULL), - m_wintab(NULL), + m_Bar(nullptr), + m_wintab(nullptr), m_lastPointerTabletData(GHOST_TABLET_DATA_NONE), m_normal_state(GHOST_kWindowStateNormal), m_user32(::LoadLibrary("user32.dll")), m_parentWindowHwnd(parentwindow ? parentwindow->m_hWnd : HWND_DESKTOP), - m_directManipulationHelper(NULL), + m_directManipulationHelper(nullptr), m_debug_context(is_debug) { DWORD style = parentwindow ? @@ -116,7 +116,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, 0); /* pointer to window-creation data */ free(title_16); - if (m_hWnd == NULL) { + if (m_hWnd == nullptr) { return; } @@ -140,7 +140,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, MessageBox(m_hWnd, text, title, MB_OK | MB_ICONERROR); ::ReleaseDC(m_hWnd, m_hDC); ::DestroyWindow(m_hWnd); - m_hWnd = NULL; + m_hWnd = nullptr; if (!parentwindow) { exit(0); } @@ -215,7 +215,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, /* Allow the showing of a progress bar on the taskbar. */ CoCreateInstance( - CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (LPVOID *)&m_Bar); + CLSID_TaskbarList, nullptr, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (LPVOID *)&m_Bar); /* Initialize Direct Manipulation. */ m_directManipulationHelper = GHOST_DirectManipulationHelper::create(m_hWnd, getDPIHint()); @@ -263,24 +263,24 @@ GHOST_WindowWin32::~GHOST_WindowWin32() if (m_Bar) { m_Bar->SetProgressState(m_hWnd, TBPF_NOPROGRESS); m_Bar->Release(); - m_Bar = NULL; + m_Bar = nullptr; } closeWintab(); if (m_user32) { FreeLibrary(m_user32); - m_user32 = NULL; + m_user32 = nullptr; } if (m_customCursor) { DestroyCursor(m_customCursor); - m_customCursor = NULL; + m_customCursor = nullptr; } - if (m_hWnd != NULL && m_hDC != NULL && releaseNativeHandles()) { + if (m_hWnd != nullptr && m_hDC != nullptr && releaseNativeHandles()) { ::ReleaseDC(m_hWnd, m_hDC); - m_hDC = NULL; + m_hDC = nullptr; } if (m_hWnd) { @@ -289,7 +289,7 @@ GHOST_WindowWin32::~GHOST_WindowWin32() for (GHOST_IWindow *iter_win : m_system->getWindowManager()->getWindows()) { GHOST_WindowWin32 *iter_winwin = (GHOST_WindowWin32 *)iter_win; if (iter_winwin->m_parentWindowHwnd == m_hWnd) { - ::SetWindowLongPtr(iter_winwin->m_hWnd, GWLP_HWNDPARENT, NULL); + ::SetWindowLongPtr(iter_winwin->m_hWnd, GWLP_HWNDPARENT, 0); iter_winwin->m_parentWindowHwnd = 0; } } @@ -299,15 +299,15 @@ GHOST_WindowWin32::~GHOST_WindowWin32() RevokeDragDrop(m_hWnd); /* Release our reference of the DropTarget and it will delete itself eventually. */ m_dropTarget->Release(); - m_dropTarget = NULL; + m_dropTarget = nullptr; } - ::SetWindowLongPtr(m_hWnd, GWLP_USERDATA, NULL); + ::SetWindowLongPtr(m_hWnd, GWLP_USERDATA, 0); ::DestroyWindow(m_hWnd); m_hWnd = 0; } delete m_directManipulationHelper; - m_directManipulationHelper = NULL; + m_directManipulationHelper = nullptr; } void GHOST_WindowWin32::adjustWindowRectForClosestMonitor(LPRECT win_rect, @@ -565,7 +565,7 @@ GHOST_TSuccess GHOST_WindowWin32::setOrder(GHOST_TWindowOrder order) setState(GHOST_kWindowStateNormal); } hWndInsertAfter = HWND_TOP; - hWndToRaise = NULL; + hWndToRaise = nullptr; } if (::SetWindowPos(m_hWnd, hWndInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) == FALSE) { @@ -690,7 +690,7 @@ void GHOST_WindowWin32::updateMouseCapture(GHOST_MouseCaptureEventWin32 event) HCURSOR GHOST_WindowWin32::getStandardCursor(GHOST_TStandardCursor shape) const { /* Convert GHOST cursor to Windows OEM cursor. */ - HANDLE cursor = NULL; + HANDLE cursor = nullptr; HMODULE module = ::GetModuleHandle(0); uint32_t flags = LR_SHARED | LR_DEFAULTSIZE; int cx = 0, cy = 0; @@ -701,7 +701,7 @@ HCURSOR GHOST_WindowWin32::getStandardCursor(GHOST_TStandardCursor shape) const return m_customCursor; } else { - return NULL; + return nullptr; } case GHOST_kStandardCursorRightArrow: cursor = ::LoadImage(module, "arrowright_cursor", IMAGE_CURSOR, cx, cy, flags); @@ -746,13 +746,13 @@ HCURSOR GHOST_WindowWin32::getStandardCursor(GHOST_TStandardCursor shape) const cursor = ::LoadImage(module, "scrollew_cursor", IMAGE_CURSOR, cx, cy, flags); break; case GHOST_kStandardCursorHelp: - cursor = ::LoadImage(NULL, IDC_HELP, IMAGE_CURSOR, cx, cy, flags); + cursor = ::LoadImage(nullptr, IDC_HELP, IMAGE_CURSOR, cx, cy, flags); break; /* Arrow and question mark */ case GHOST_kStandardCursorWait: - cursor = ::LoadImage(NULL, IDC_WAIT, IMAGE_CURSOR, cx, cy, flags); + cursor = ::LoadImage(nullptr, IDC_WAIT, IMAGE_CURSOR, cx, cy, flags); break; /* Hourglass */ case GHOST_kStandardCursorText: - cursor = ::LoadImage(NULL, IDC_IBEAM, IMAGE_CURSOR, cx, cy, flags); + cursor = ::LoadImage(nullptr, IDC_IBEAM, IMAGE_CURSOR, cx, cy, flags); break; /* I-beam */ case GHOST_kStandardCursorCrosshair: cursor = ::LoadImage(module, "cross_cursor", IMAGE_CURSOR, cx, cy, flags); @@ -775,19 +775,19 @@ HCURSOR GHOST_WindowWin32::getStandardCursor(GHOST_TStandardCursor shape) const cursor = ::LoadImage(module, "moveew_cursor", IMAGE_CURSOR, cx, cy, flags); break; /* Double-pointed arrow pointing west and east */ case GHOST_kStandardCursorTopSide: - cursor = ::LoadImage(NULL, IDC_UPARROW, IMAGE_CURSOR, cx, cy, flags); + cursor = ::LoadImage(nullptr, IDC_UPARROW, IMAGE_CURSOR, cx, cy, flags); break; /* Vertical arrow */ case GHOST_kStandardCursorTopLeftCorner: - cursor = ::LoadImage(NULL, IDC_SIZENWSE, IMAGE_CURSOR, cx, cy, flags); + cursor = ::LoadImage(nullptr, IDC_SIZENWSE, IMAGE_CURSOR, cx, cy, flags); break; case GHOST_kStandardCursorTopRightCorner: - cursor = ::LoadImage(NULL, IDC_SIZENESW, IMAGE_CURSOR, cx, cy, flags); + cursor = ::LoadImage(nullptr, IDC_SIZENESW, IMAGE_CURSOR, cx, cy, flags); break; case GHOST_kStandardCursorBottomRightCorner: - cursor = ::LoadImage(NULL, IDC_SIZENWSE, IMAGE_CURSOR, cx, cy, flags); + cursor = ::LoadImage(nullptr, IDC_SIZENWSE, IMAGE_CURSOR, cx, cy, flags); break; case GHOST_kStandardCursorBottomLeftCorner: - cursor = ::LoadImage(NULL, IDC_SIZENESW, IMAGE_CURSOR, cx, cy, flags); + cursor = ::LoadImage(nullptr, IDC_SIZENESW, IMAGE_CURSOR, cx, cy, flags); break; case GHOST_kStandardCursorPencil: cursor = ::LoadImage(module, "pencil_cursor", IMAGE_CURSOR, cx, cy, flags); @@ -800,14 +800,14 @@ HCURSOR GHOST_WindowWin32::getStandardCursor(GHOST_TStandardCursor shape) const cursor = ::LoadImage(module, "forbidden_cursor", IMAGE_CURSOR, cx, cy, flags); break; /* Slashed circle */ case GHOST_kStandardCursorDefault: - cursor = NULL; + cursor = nullptr; break; default: - return NULL; + return nullptr; } - if (cursor == NULL) { - cursor = ::LoadImage(NULL, IDC_ARROW, IMAGE_CURSOR, cx, cy, flags); + if (cursor == nullptr) { + cursor = ::LoadImage(nullptr, IDC_ARROW, IMAGE_CURSOR, cx, cy, flags); } return (HCURSOR)cursor; @@ -825,7 +825,7 @@ void GHOST_WindowWin32::loadCursor(bool visible, GHOST_TStandardCursor shape) co } HCURSOR cursor = getStandardCursor(shape); - if (cursor == NULL) { + if (cursor == nullptr) { cursor = getStandardCursor(GHOST_kStandardCursorDefault); } ::SetCursor(cursor); @@ -899,7 +899,7 @@ GHOST_TSuccess GHOST_WindowWin32::getPointerInfo( GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)GHOST_System::getSystem(); uint32_t outCount = 0; - if (!(GetPointerPenInfoHistory(pointerId, &outCount, NULL))) { + if (!(GetPointerPenInfoHistory(pointerId, &outCount, nullptr))) { return GHOST_kFailure; } @@ -1010,7 +1010,7 @@ void GHOST_WindowWin32::closeWintab() { WINTAB_PRINTF("Closing Wintab for window %p\n", m_hWnd); delete m_wintab; - m_wintab = NULL; + m_wintab = nullptr; } bool GHOST_WindowWin32::usingTabletAPI(GHOST_TTabletAPI api) const @@ -1049,7 +1049,7 @@ void GHOST_WindowWin32::ThemeRefresh() L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\\", L"AppsUseLightTheme", RRF_RT_REG_DWORD, - NULL, + nullptr, &lightMode, &pcbData) == ERROR_SUCCESS) { @@ -1124,7 +1124,7 @@ GHOST_TSuccess GHOST_WindowWin32::setWindowCustomCursorShape(uint8_t *bitmap, if (m_customCursor) { DestroyCursor(m_customCursor); - m_customCursor = NULL; + m_customCursor = nullptr; } memset(&andData, 0xFF, sizeof(andData)); diff --git a/intern/ghost/intern/GHOST_WindowX11.cc b/intern/ghost/intern/GHOST_WindowX11.cc index 143e61f127c..dea12dd1352 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cc +++ b/intern/ghost/intern/GHOST_WindowX11.cc @@ -1182,8 +1182,8 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type GHOST_kVulkanPlatformX11, m_window, m_display, - NULL, - NULL, + nullptr, + nullptr, 1, 2, m_is_debug_context); diff --git a/intern/ghost/intern/GHOST_XrContext.cc b/intern/ghost/intern/GHOST_XrContext.cc index 03dab19ab9e..003d4e27260 100644 --- a/intern/ghost/intern/GHOST_XrContext.cc +++ b/intern/ghost/intern/GHOST_XrContext.cc @@ -276,7 +276,7 @@ void GHOST_XrContext::setErrorHandler(GHOST_XrErrorHandlerFn handler_fn, void *c * \{ */ /** - * \param layer_name: May be NULL for extensions not belonging to a specific layer. + * \param layer_name: May be nullptr for extensions not belonging to a specific layer. */ void GHOST_XrContext::initExtensionsEx(std::vector &extensions, const char *layer_name) @@ -462,7 +462,7 @@ std::vector GHOST_XrContext::determineGraphicsBindingT const GHOST_XrContextCreateInfo *create_info) { std::vector result; - assert(create_info->gpu_binding_candidates != NULL); + assert(create_info->gpu_binding_candidates != nullptr); assert(create_info->gpu_binding_candidates_count > 0); for (uint32_t i = 0; i < create_info->gpu_binding_candidates_count; i++) { diff --git a/intern/ghost/intern/GHOST_XrSession.cc b/intern/ghost/intern/GHOST_XrSession.cc index fa882dc0efe..a2aacfac06a 100644 --- a/intern/ghost/intern/GHOST_XrSession.cc +++ b/intern/ghost/intern/GHOST_XrSession.cc @@ -277,7 +277,8 @@ GHOST_XrSession::LifeExpectancy GHOST_XrSession::handleStateChangeEvent( { m_oxr->session_state = lifecycle.state; - /* Runtime may send events for apparently destroyed session. Our handle should be NULL then. */ + /* Runtime may send events for apparently destroyed session. Our handle should be nullptr then. + */ assert(m_oxr->session == XR_NULL_HANDLE || m_oxr->session == lifecycle.session); switch (lifecycle.state) { diff --git a/intern/ghost/intern/GHOST_XrSwapchain.cc b/intern/ghost/intern/GHOST_XrSwapchain.cc index 54dd9be6535..0506482b13b 100644 --- a/intern/ghost/intern/GHOST_XrSwapchain.cc +++ b/intern/ghost/intern/GHOST_XrSwapchain.cc @@ -94,7 +94,7 @@ GHOST_XrSwapchain::GHOST_XrSwapchain(GHOST_XrSwapchain &&other) GHOST_XrSwapchain::~GHOST_XrSwapchain() { - /* m_oxr may be NULL after move. */ + /* m_oxr may be nullptr after move. */ if (m_oxr && m_oxr->swapchain != XR_NULL_HANDLE) { CHECK_XR_ASSERT(xrDestroySwapchain(m_oxr->swapchain)); }