Never mind.
When uploading the textures there must be a current GL context, e.g. the viewport can be passed here to call makeCurrent() on it, so glGenTextures() can return valid texture ids, which wasn't the case.