Assertion Error '_is_open'

The code looks like this (the code isn’t that, but the logic is):

void initialize() {
    PandaFramework framework;


    this->p_framework = &framework;

    this->window = this->p_framework->open_window();

void run() {

void main() {

And i’m getting assertion error:

Assertion failed: _is_open at line 749 of c:\buildslave\sdk-windows-amd64\build\panda\src\framework\pandaFramework.cxx

I’m not sure that such an interpretation of “this” will work. This is usually achieved like this.

#include "pandaFramework.h"
#include "pandaSystem.h"

void initialize(PandaFramework& framework) {
    WindowFramework *window = framework.open_window();

void run(PandaFramework& framework) {

void main() {
    PandaFramework framework;
1 Like

Actually the problem was that I created p_framework as nullptr in Window.h, and in Window.cpp / void initialization() I initialized PandaFramework and set p_framework as link to new initialized PandaFramework. The solution was to initialize PandaFramework in Window.h, and in Window.cpp using this->p_framework just open the framework (.open_framework).

The problem is solved, but I have another problem :sweat_smile:
Could you help please? TexturePool is empty

I just want to highlight that this:

is a cardinal sin in C++: you’re creating a PandaFramework that has a local scope in the function, and then storing a reference to that local framework that exceeds the lifetime of that function.

But that PandaFramework will destroy when the initialize() function finishes! So that reference you stored is now pointing to some random place in the stack that probably contains some completely other object by that point, and you’re getting extremely undefined behaviour.

You need to allocate the PandaFramework on the heap (using new) or give it some other lifetime outside the function such as by declaring it in main() or putting it in global scope.