From 82023570a9b5880629a5f7ce477479ffcb7af930 Mon Sep 17 00:00:00 2001 From: eilers Date: Sat, 06 Nov 2004 19:41:22 +0000 Subject: Avoid crash if app was unable to open the file --- (limited to 'noncore') diff --git a/noncore/apps/opie-sheet/Excel.cpp b/noncore/apps/opie-sheet/Excel.cpp index 57aef20..338bc30 100644 --- a/noncore/apps/opie-sheet/Excel.cpp +++ b/noncore/apps/opie-sheet/Excel.cpp @@ -589,7 +589,8 @@ bool ExcelBook::ParseBook(char *file) { dateformat=QString(""); DetectEndian(); - OpenFile(file); + if ( !OpenFile( file ) ) + return false; SeekBOF(); ParseSheets(); GetSheets(); diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index 7394623..3095142 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp @@ -877,7 +877,10 @@ void MainWindow::slotFileSaveAs() void MainWindow::slotImportExcel(const DocLnk &lnkDoc) { ExcelBook file1; - file1.ParseBook((char *)lnkDoc.file().ascii()); + if ( !file1.ParseBook((char *)lnkDoc.file().ascii()) ){ + QMessageBox::critical(this, tr("Error"), tr("Unable to open or parse file!")); + return; + } int NumOfSheets=file1.Sheets.count(); printf("OpieSheet::NumberOfSheets:%d\r\n",NumOfSheets); if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; @@ -893,7 +896,7 @@ void MainWindow::slotImportExcel(const DocLnk &lnkDoc) for(w1=1;w1<=NumOfSheets;w1++) { sh1=file1.Sheets[w1-1]; - printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1,sh1->rows,sh1->cols); + // printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1, sh1->rows,sh1->cols); newSheet=new typeSheet; newSheet->data.setAutoDelete(TRUE); newSheet->name=sh1->name; -- cgit v0.9.0.2