Skip to content

Commit

Permalink
Исправил граничные ситуации, приводившие к падению программы.
Browse files Browse the repository at this point in the history
  • Loading branch information
readysloth committed Aug 7, 2019
1 parent 72665e6 commit ca5d172
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
28 changes: 23 additions & 5 deletions resources/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ Window{
y: 244
text: qsTr("Выбрать файл")
onClicked: {
progressBar.value = 0
fileDialog_for_load.open()
if(libController.ready){
progressBar.value = 0
fileDialog_for_load.open()
}
else{
fileNotReady.open()
}
}
}

Expand All @@ -106,9 +111,14 @@ Window{
y: 244
text: qsTr("Сортировать")
onClicked: {
progressBar.value = 0
updateProgress.start()
libController.sortFile()
if(libController.ready){
progressBar.value = 0
updateProgress.start()
libController.sortFile()
}
else{
fileNotReady.open()
}
}
}

Expand Down Expand Up @@ -196,6 +206,14 @@ Window{
text: qsTr("Пожалуйста, дождитесь окончания процесса сортировки.")
}

MessageDialog {
id: fileInconsistent
visible: false
icon: StandardIcon.Warning
title: qsTr("Уведомление")
text: qsTr("Пожалуйста, выберите файл заново")
}

MessageDialog {
id: fileReady
visible: false
Expand Down
9 changes: 7 additions & 2 deletions src/lib_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ bool LibController::isReady(){
*/
double LibController::getProgress(){

double processed_chunks = this->file_manager->getProcessedChunks();
double all_chunks = this->file_manager->getAllChunks();
double processed_chunks;
double all_chunks;

if(this->file_manager != nullptr){
processed_chunks = this->file_manager->getProcessedChunks();
all_chunks = this->file_manager->getAllChunks();
}

if(all_chunks != 0){
this->current_progress = 1;
Expand Down

0 comments on commit ca5d172

Please sign in to comment.