---
name: "SoContextHandler"
section: "3"
platform: "linux"
package: "coin"
version: "1:4.0.10-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/SoContextHandler"
---

# SoContextHandler(3)

The SoContextHandler class is for now to be treated as an internal class.

## NAME

SoContextHandler - The **SoContextHandler** class is for now to be treated as an internal class.

## SYNOPSIS

\#include \<Inventor/misc/SoContextHandler.h\>

### Public Types

typedef void **ContextDestructionCB**(uint32\_t contextid, void \*userdata)\

### Static Public Member Functions

static void **destructingContext** (uint32\_t contextid)\
 static void **addContextDestructionCallback** (ContextDestructionCB \*func, void \*closure)\
 static void **removeContextDestructionCallback** (ContextDestructionCB \*func, void \*closure)\

## Detailed Description

The **SoContextHandler** class is for now to be treated as an internal class.

**Since**

Coin 2.0

## Member Function Documentation

### void SoContextHandler::destructingContext (uint32\_t contextid) \[static\]

This method *must* be called by client code which destructs a context, to guarantee that there are no memory leaks upon context destruction.

This will take care of correctly freeing context-bound resources, like OpenGL texture objects and display lists.

Before calling this function, the context *must* be made current.

Note that if you are using one of the standard GUI-binding libraries from Kongsberg Oil & Gas Technologies, this is taken care of automatically for contexts for canvases set up by SoQt, SoWin, etc.

### void SoContextHandler::addContextDestructionCallback (ContextDestructionCB \* func, void \* closure) \[static\]

Add a callback which will be called every time a GL context is destructed. The callback should delete all GL resources tied to that context.

All nodes/classes that allocate GL resources should set up a callback like this. Add the callback in the constructor of the node/class, and remove it in the destructor.

**See also**

**removeContextDestructionCallback()**

### void SoContextHandler::removeContextDestructionCallback (ContextDestructionCB \* func, void \* closure) \[static\]

Remove a context destruction callback.

**See also**

**addContextDestructionCallback()**

## Author

Generated automatically by Doxygen for Coin from the source code.
