Code:
if((key_r)&&(panel))

Change it to this:
Code:
if((key_r)&&(panel != NULL))


Now it should work!