{"record":{"id":"530443ea8d8f8016","repo":"Yalantis/uCrop","slug":"select-empty-instance","errorCode":null,"errorMessage":"select(): Empty instance.","messagePattern":"select\\(\\): Empty instance\\.","errorType":"exception","errorClass":"CImgInstanceException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":66319,"sourceCode":"       \\param feature_type Can be \\c false to select a single image, or \\c true to select a sublist.\n       \\param axis Axis along whom images are appended for visualization.\n       \\param align Alignment setting when images have not all the same size.\n       \\param exit_on_anykey Exit function when any key is pressed.\n       \\return A one-column vector containing the selected image indexes.\n    **/\n    CImg<intT> get_select(const char *const title, const bool feature_type=true,\n                          const char axis='x', const float align=0,\n                          const bool exit_on_anykey=false) const {\n      CImgDisplay disp;\n      return _select(disp,title,feature_type,axis,align,exit_on_anykey,0,false,false,false);\n    }\n\n    CImg<intT> _select(CImgDisplay &disp, const char *const title, const bool feature_type,\n                       const char axis, const float align, const bool exit_on_anykey,\n                       const unsigned int orig, const bool resize_disp,\n                       const bool exit_on_rightbutton, const bool exit_on_wheel) const {\n      if (is_empty())\n        throw CImgInstanceException(_cimglist_instance\n                                    \"select(): Empty instance.\",\n                                    cimglist_instance);\n\n      // Create image correspondence table and get list dimensions for visualization.\n      CImgList<uintT> _indices;\n      unsigned int max_width = 0, max_height = 0, sum_width = 0, sum_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        if (w>max_width) max_width = w;\n        if (h>max_height) max_height = h;\n        sum_width+=w; sum_height+=h;\n        if (axis=='x') CImg<uintT>(w,1,1,1,(unsigned int)l).move_to(_indices);\n        else CImg<uintT>(h,1,1,1,(unsigned int)l).move_to(_indices);\n      }\n      const CImg<uintT> indices0 = _indices>'x';","sourceCodeStart":66301,"sourceCodeEnd":66337,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L66301-L66337","documentation":"CImgList::_select() (backing select() family for interactive feature selection in a display) throws CImgInstanceException when the list is empty — there are no images to visualize or pick from. It is an instance-state error, not an argument error.","triggerScenarios":"Calling list.select(disp) (or the feature/axis variants) on a CImgList whose size is 0, typically after a failed or skipped load.","commonSituations":"Load returned an empty list (missing file) and the interactive selection was started anyway; a filter step removed all images before selection; wrong variable passed to select().","solutions":["Check list.is_empty() / list.size() > 0 before calling select() and bail out with a message","Ensure the list was actually loaded/populated (verify the load call succeeded)","Initialize the CImgDisplay and list from a valid data source before interaction"],"exampleFix":"// before\ndisp.select(list); // throws on empty list\n// after\nif (!list.is_empty()) {\n  CImg<int> sel = disp.select(list);\n} else {\n  std::fprintf(stderr, \"nothing to select from\\n\");\n}","handlingStrategy":"validation","validationCode":"if (list.is_empty()) { /* report and skip interactive selection */ }","typeGuard":null,"tryCatchPattern":"try { sel = disp.select(list); } catch (const CImgInstanceException& e) { std::fprintf(stderr, \"empty list\\n\"); }","preventionTips":["Verify the load pipeline populated the list before opening UI","Check is_empty() after filtering steps","Fail early with a clear message when input data is missing"],"tags":["cimg","empty-instance","interactive-selection","state-error"],"backgroundTag":"empty-required-field","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"}