From 0a366d75646cb4f49853f0318b050f33c0e6757a Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 4 Apr 2015 14:03:22 +0200 Subject: [PATCH] Fix #67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Workaround the two remaining issues, mostly fixing the “load deck” screen in tab_game: * Only preload up to the first 300 cards of a deck; * don’t even bother trying to load card images if they’ll be shown with width <= 10 Trying a 17k cards deck like the one proposed in #67 is still a no go, mostly due to the cpu time used to create all the objects. Anyway, i tested decks up to 8k cards and they works fine now (if you like to wait while trice is loading them).. --- cockatrice/src/abstractcarditem.cpp | 5 ++++- cockatrice/src/carddatabase.cpp | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/abstractcarditem.cpp b/cockatrice/src/abstractcarditem.cpp index 9167cb0e..e9c1b55f 100644 --- a/cockatrice/src/abstractcarditem.cpp +++ b/cockatrice/src/abstractcarditem.cpp @@ -91,7 +91,10 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS CardInfo *imageSource = facedown ? db->getCard() : info; QPixmap translatedPixmap; - imageSource->getPixmap(translatedSize.toSize(), translatedPixmap); + // don't even spend time trying to load the picture if our size is too small + if(translatedSize.width() > 10) + imageSource->getPixmap(translatedSize.toSize(), translatedPixmap); + painter->save(); QColor bgColor = Qt::transparent; if (translatedPixmap.isNull()) { diff --git a/cockatrice/src/carddatabase.cpp b/cockatrice/src/carddatabase.cpp index 8c0617d6..c6bcd188 100644 --- a/cockatrice/src/carddatabase.cpp +++ b/cockatrice/src/carddatabase.cpp @@ -970,7 +970,9 @@ QStringList CardDatabase::getAllMainCardTypes() const void CardDatabase::cacheCardPixmaps(const QStringList &cardNames) { QPixmap tmp; - for (int i = 0; i < cardNames.size(); ++i) + // never cache more than 300 cards at once for a single deck + int max = qMin(cardNames.size(), 300); + for (int i = 0; i < max; ++i) getCard(cardNames[i])->loadPixmap(tmp); }