From e49f2eebcbe717f28dcfda5c1a35cd907635b588 Mon Sep 17 00:00:00 2001 From: twanvl Date: Sat, 29 Dec 2007 21:12:11 +0000 Subject: [PATCH] fixed: errors in templates could cause program to hang/crash git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@796 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/gui/set/style_panel.cpp | 3 +++ src/render/value/image.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/set/style_panel.cpp b/src/gui/set/style_panel.cpp index 27d5ea99..cd1446fd 100644 --- a/src/gui/set/style_panel.cpp +++ b/src/gui/set/style_panel.cpp @@ -108,6 +108,9 @@ void StylePanel::selectCard(const CardP& card) { void StylePanel::onStyleSelect(wxCommandEvent&) { if (list->hasSelection() && card) { StyleSheetP stylesheet = list->getSelection(); + if (stylesheet->game != set->game) { + throw PackageError(_("Stylesheet made for the wrong game")); + } if (stylesheet == set->stylesheet) { // select no special style when selecting the same style as the set default stylesheet = StyleSheetP(); diff --git a/src/render/value/image.cpp b/src/render/value/image.cpp index 86843c36..051e6542 100644 --- a/src/render/value/image.cpp +++ b/src/render/value/image.cpp @@ -21,7 +21,7 @@ IMPLEMENT_VALUE_VIEWER(Image); void ImageValueViewer::draw(RotatedDC& dc) { // reset? - int w = (int)dc.trX(style().width), h = (int)dc.trY(style().height); + int w = max(0,(int)dc.trX(style().width)), h = max(0,(int)dc.trY(style().height)); int a = dc.trAngle(0); //% TODO : Add getAngle()? if (bitmap.Ok() && (a != angle || size.width != w || size.height != h)) { bitmap = Bitmap();