add: if(!KTMainWindow::memberList) return;
context: static void ungrabPtrKb(void){  QWidget* widg = KTMainWindow::memberList->first();  Display* dpy;  if (!widg) return;  dpy = widg->x11Display();  XUngrabKeyboard(dpy, CurrentTime);  XUngrabPointer(dpy, CurrentTime);}