fix segfault when image from file was loaded

This commit is contained in:
Stefan Bühler 2012-04-09 12:47:50 +02:00
parent 7a5f0ed60f
commit 54e363d50c
3 changed files with 10 additions and 2 deletions

View File

@ -184,7 +184,7 @@ namespace qcross {
delete m_Highscore; delete m_Highscore;
m_Highscore = dialog.takeHighscore(); m_Highscore = dialog.takeHighscore();
m_PackageName = dialog.selectedPackage()->name(); m_PackageName = dialog.selectedPackageName();
m_PictureIndex = m_Highscore ? dialog.nonogramIndex() : -1; m_PictureIndex = m_Highscore ? dialog.nonogramIndex() : -1;
CNonogram * newPicture = dialog.takeNonogram(); CNonogram * newPicture = dialog.takeNonogram();

View File

@ -94,10 +94,17 @@ namespace qcross {
} }
libqnono::CCrossPackage * CNewGameDialog::selectedPackage() const { libqnono::CCrossPackage * CNewGameDialog::selectedPackage() const {
if (m_Nonogram) return NULL;
QModelIndex selected = ui.packageList->selectionModel()->selectedIndexes()[0]; QModelIndex selected = ui.packageList->selectionModel()->selectedIndexes()[0];
return static_cast<CCrossPackage *>(selected.internalPointer()); return static_cast<CCrossPackage *>(selected.internalPointer());
} }
QString CNewGameDialog::selectedPackageName() const {
if (m_Nonogram) return QString();
libqnono::CCrossPackage *p = selectedPackage();
return p ? p->name() : QString();
}
libqnono::CNonogram * CNewGameDialog::takeNonogram() { libqnono::CNonogram * CNewGameDialog::takeNonogram() {
libqnono::CNonogram * result; libqnono::CNonogram * result;

View File

@ -44,6 +44,7 @@ namespace qcross {
int nonogramIndex() const; int nonogramIndex() const;
libqnono::CCrossPackage * selectedPackage() const; libqnono::CCrossPackage * selectedPackage() const;
QString selectedPackageName() const;
libqnono::CNonogram * takeNonogram(); libqnono::CNonogram * takeNonogram();
CHighscore * takeHighscore(); CHighscore * takeHighscore();
@ -53,7 +54,7 @@ namespace qcross {
private: private:
Ui::picselect ui; Ui::picselect ui;
CHighscore * m_Highscore; CHighscore * m_Highscore;
libqnono::CNonogram * m_Nonogram; libqnono::CNonogram * m_Nonogram; /* if != NULL package wasn't used */
CMaskedCrossPackageModel * m_PicModel; CMaskedCrossPackageModel * m_PicModel;
CMaskedCrossPackageProxyModel * m_PicProxyModel; CMaskedCrossPackageProxyModel * m_PicProxyModel;
private slots: private slots: