{"record":{"id":"2856e03abd12a0dc","repo":"Yalantis/uCrop","slug":"display-empty-instance","errorCode":null,"errorMessage":"display(): Empty instance.","messagePattern":"display\\(\\): Empty instance\\.","errorType":"exception","errorClass":"CImgInstanceException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":67782,"sourceCode":"      \\param axis Appending axis. Can be <tt>{ 'x' | 'y' | 'z' | 'c' }</tt>.\n      \\param align Appending alignment.\n      \\param[in,out] XYZ Contains the XYZ coordinates at start / exit of the function.\n      \\param exit_on_anykey Exit function when any key is pressed.\n    **/\n    const CImgList<T>& display(const char *const title=0, const bool display_info=true,\n                               const char axis='x', const float align=0,\n                               unsigned int *const XYZ=0, const bool exit_on_anykey=false) const {\n      CImgDisplay disp;\n      bool is_exit = false;\n      return _display(disp,title,0,display_info,axis,align,XYZ,exit_on_anykey,0,true,is_exit);\n    }\n\n    const CImgList<T>& _display(CImgDisplay &disp, const char *const title, const CImgList<charT> *const titles,\n                                const bool display_info, const char axis, const float align, unsigned int *const XYZ,\n                                const bool exit_on_anykey, const unsigned int orig, const bool is_first_call,\n                                bool &is_exit) const {\n      if (is_empty())\n        throw CImgInstanceException(_cimglist_instance\n                                    \"display(): Empty instance.\",\n                                    cimglist_instance);\n      if (!disp) {\n        if (axis=='x') {\n          unsigned int sum_width = 0, max_height = 0;\n          cimglist_for(*this,l) {\n            const CImg<T> &img = _data[l];\n            const unsigned int\n              w = CImgDisplay::_fitscreen(img._width,img._height,img._depth,128,-85,false),\n              h = CImgDisplay::_fitscreen(img._width,img._height,img._depth,128,-85,true);\n            sum_width+=w;\n            if (h>max_height) max_height = h;\n          }\n          disp.assign(cimg_fitscreen(sum_width,max_height,1),title?title:titles?titles->__display()._data:0,1);\n        } else {\n          unsigned int max_width = 0, sum_height = 0;\n          cimglist_for(*this,l) {\n            const CImg<T> &img = _data[l];","sourceCodeStart":67764,"sourceCodeEnd":67800,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L67764-L67800","documentation":"CImgList::_display() throws CImgInstanceException when the list is empty (is_empty()); there are no images to render in the display window. It is an instance-state check, raised only when display windows are enabled (cimg_display != 0).","triggerScenarios":"Calling .display() or .display_graph() etc. on a default-constructed CImgList, on a list after .clear()/.assign(), or on a list whose load() failed silently and left 0 images.","commonSituations":"Displaying results of a failed/optional file load in headless-deployed code path; iterating files where some produce empty lists; forgetting that a filtered/extracted list can be empty.","solutions":["Check list.size() (or !list.is_empty()) before calling display().","Ensure the preceding load/assignment actually populated the list.","Guard display calls in headless environments where loads may be skipped."],"exampleFix":"// before\nlist.display(\"result\"); // throws if empty\n// after\nif (!list.is_empty()) list.display(\"result\");","handlingStrategy":"validation","validationCode":"if (list.is_empty()) {\n  fprintf(stderr, \"Nothing to display\\n\");\n  return false;\n}","typeGuard":null,"tryCatchPattern":"try { list.display(\"result\"); }\ncatch (CImgInstanceException &e) { fprintf(stderr, \"Display skipped: %s\\n\", e.what()); }","preventionTips":["Check size()/is_empty() before display.","Verify loads populated the list before rendering.","Skip GUI calls in headless contexts."],"tags":["display","state","gui"],"backgroundTag":"empty-instance","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}