Commit 25575707 authored by twanvl's avatar twanvl

Fixed thumbnails for choices without images

parent 70b48d72
......@@ -43,7 +43,9 @@ Image ChoiceThumbnailRequest::generate() {
ChoiceValueEditor& cve = *(ChoiceValueEditor*)owner;
String name = cannocial_name_form(cve.field().choices->choiceName(id));
ScriptableImage& img = cve.style().choice_images[name];
return img.generate(GeneratedImage::Options(16,16, stylesheet.get(), &cve.getSet(), ASPECT_BORDER, true), false);
return img.isReady()
? img.generate(GeneratedImage::Options(16,16, stylesheet.get(), &cve.getSet(), ASPECT_BORDER, true), false)
: wxImage();
}
void ChoiceThumbnailRequest::store(const Image& img) {
......
......@@ -33,21 +33,20 @@ Image ScriptableImage::generate(const GeneratedImage::Options& options, bool cac
// cached, so we are done
return cached;
}
// generate blank image
Image image(1,1);
image.InitAlpha();
image.SetAlpha(0,0,0);
// generate
Image image;
if (isReady()) {
try {
image = value->generate(options);
}
catch (FileNotFoundError e) {
handle_error (e);
return image;
}
}
else {
return image;
// note: Don't catch exceptions here, we don't want to return an invalid image.
// We could return a blank one, but the thumbnail code does want an invalid
// image in case of errors.
// This allows the caller to catch errors.
image = value->generate(options);
} else {
// error, return blank image
Image i(1,1);
i.InitAlpha();
i.SetAlpha(0,0,0);
image = i;
}
// resize?
int iw = image.GetWidth(), ih = image.GetHeight();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment