Fix a crash (#3011)
This commit is contained in:
parent
7a150c558d
commit
dcc632e0d4
4 changed files with 46 additions and 28 deletions
|
@ -10,8 +10,7 @@
|
|||
#include <QSplitter>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
CardFrame::CardFrame(const QString &cardName, QWidget *parent)
|
||||
: QTabWidget(parent), info(nullptr), cardTextOnly(false)
|
||||
CardFrame::CardFrame(const QString &cardName, QWidget *parent) : QTabWidget(parent), info(nullptr), cardTextOnly(false)
|
||||
{
|
||||
setContentsMargins(3, 3, 3, 3);
|
||||
pic = new CardInfoPicture();
|
||||
|
@ -72,7 +71,7 @@ void CardFrame::setViewMode(int mode)
|
|||
if(currentIndex() != mode)
|
||||
setCurrentIndex(mode);
|
||||
|
||||
switch(mode)
|
||||
switch (mode)
|
||||
{
|
||||
case ImageOnlyView:
|
||||
case TextOnlyView:
|
||||
|
@ -83,6 +82,8 @@ void CardFrame::setViewMode(int mode)
|
|||
splitter->addWidget(pic);
|
||||
splitter->addWidget(text);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
settingsCache->setCardInfoViewMode(mode);
|
||||
|
@ -91,10 +92,16 @@ void CardFrame::setViewMode(int mode)
|
|||
void CardFrame::setCard(CardInfo *card)
|
||||
{
|
||||
if (info)
|
||||
{
|
||||
disconnect(info, nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
info = card;
|
||||
if(info)
|
||||
|
||||
if (info)
|
||||
{
|
||||
connect(info, SIGNAL(destroyed()), this, SLOT(clear()));
|
||||
}
|
||||
|
||||
text->setCard(info);
|
||||
pic->setCard(info);
|
||||
|
@ -107,7 +114,10 @@ void CardFrame::setCard(const QString &cardName)
|
|||
|
||||
void CardFrame::setCard(AbstractCardItem *card)
|
||||
{
|
||||
if (card)
|
||||
{
|
||||
setCard(card->getInfo());
|
||||
}
|
||||
}
|
||||
|
||||
void CardFrame::clear()
|
||||
|
|
|
@ -10,10 +10,10 @@ class CardInfoText;
|
|||
class QVBoxLayout;
|
||||
class QSplitter;
|
||||
|
||||
class CardFrame : public QTabWidget {
|
||||
class CardFrame : public QTabWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
private:
|
||||
CardInfo *info;
|
||||
CardInfoPicture *pic;
|
||||
CardInfoText *text;
|
||||
|
@ -21,13 +21,13 @@ private:
|
|||
QWidget *tab1, *tab2, *tab3;
|
||||
QVBoxLayout *tab1Layout, *tab2Layout, *tab3Layout;
|
||||
QSplitter *splitter;
|
||||
public:
|
||||
enum ViewMode { ImageOnlyView, TextOnlyView, ImageAndTextView };
|
||||
|
||||
CardFrame(const QString &cardName = QString(),
|
||||
QWidget *parent = 0);
|
||||
public:
|
||||
enum ViewMode { ImageOnlyView, TextOnlyView, ImageAndTextView };
|
||||
explicit CardFrame(const QString &cardName = QString(), QWidget *parent = nullptr);
|
||||
void retranslateUi();
|
||||
public slots:
|
||||
|
||||
public slots:
|
||||
void setCard(CardInfo *card);
|
||||
void setCard(const QString &cardName);
|
||||
void setCard(AbstractCardItem *card);
|
||||
|
|
|
@ -20,10 +20,16 @@ CardInfoPicture::CardInfoPicture(QWidget *parent)
|
|||
void CardInfoPicture::setCard(CardInfo *card)
|
||||
{
|
||||
if (info)
|
||||
{
|
||||
disconnect(info, nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
info = card;
|
||||
if(info)
|
||||
|
||||
if (info)
|
||||
{
|
||||
connect(info, SIGNAL(pixmapUpdated()), this, SLOT(updatePixmap()));
|
||||
}
|
||||
|
||||
updatePixmap();
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ CardInfoText::CardInfoText(QWidget *parent)
|
|||
|
||||
void CardInfoText::setCard(CardInfo *card)
|
||||
{
|
||||
if(card)
|
||||
if (card)
|
||||
{
|
||||
nameLabel2->setText(card->getName());
|
||||
manacostLabel2->setText(card->getManaCost());
|
||||
|
@ -68,7 +68,9 @@ void CardInfoText::setCard(CardInfo *card)
|
|||
powtoughLabel2->setText(card->getPowTough());
|
||||
loyaltyLabel2->setText(card->getLoyalty() > 0 ? QString::number(card->getLoyalty()) : QString());
|
||||
textLabel->setText(card->getText());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
nameLabel2->setText("");
|
||||
manacostLabel2->setText("");
|
||||
colorLabel2->setText("");
|
||||
|
|
Loading…
Reference in a new issue