From 99aa0ed909fa65781cc53aeb0673dafc1f78b5e6 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Fri, 12 Sep 2014 12:11:28 +0300 Subject: [PATCH] Fix #10 Added a bool flag to main. calendarLoaded. @liranbg - you method did not work (at least on linux)... now user will be prompted with an error message dialog. No Crash. Closing bug #10 --- main/CalendarTab/CalendarManager.cpp | 4 ++-- main/mainscreen.cpp | 11 ++++++++++- main/mainscreen.h | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/main/CalendarTab/CalendarManager.cpp b/main/CalendarTab/CalendarManager.cpp index 865a67d..c19a6fa 100644 --- a/main/CalendarTab/CalendarManager.cpp +++ b/main/CalendarTab/CalendarManager.cpp @@ -12,8 +12,8 @@ void CalendarManager::setCalendar(std::string html) } void CalendarManager::exportCalendarCSV() //need to add fix to the null pointer bug { - if (caliSchedPtr->getCourses() == NULL) - return; +// if (caliSchedPtr->getCourses()->empty()) +// return; QMessageBox msgBox; int buttonClicked = caliDialog->exec(); if (buttonClicked == 0) //cancel? diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index 1d86a70..4f33871 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -49,6 +49,9 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr //Local Check and ui setting. checkLocale(); + //calendar bug fix + calendarLoaded = false; + } MainScreen::~MainScreen() @@ -264,6 +267,7 @@ void MainScreen::on_getCalendarBtn_clicked() //ui->plainTextEdit->setPlainText(loginHandel->getCurrentPageContect()); calendar->resetTable(); calendar->setCalendar(loginHandel->getCurrentPageContect().toStdString()); + calendarLoaded = true; } else if (status == jceLogin::JCE_NOT_CONNECTED) @@ -276,7 +280,12 @@ void MainScreen::on_exportToCVSBtn_clicked() { if (loginHandel->isLoggedInFlag()) { - this->calendar->exportCalendarCSV(); + if(calendarLoaded) + this->calendar->exportCalendarCSV(); + else + { + QMessageBox::critical(this,tr("Error"),"No Calendar was loaded."); //Need Translation + } } } diff --git a/main/mainscreen.h b/main/mainscreen.h index 7460c8f..192f698 100644 --- a/main/mainscreen.h +++ b/main/mainscreen.h @@ -86,6 +86,8 @@ private: coursesTableManager *courseTableMgr; loginHandler *loginHandel; + bool calendarLoaded; + }; #endif // MAINSCREEN_H