@@ -177,8 +177,8 @@ bool ExportDataDialog::exportQueryCsv(const std::string& sQuery, const QString&
177177 if (counter % 1000 == 0 )
178178 qApp->processEvents ();
179179 counter++;
180+ writeError = stream.status () != QTextStream::Ok;
180181 }
181- writeError = stream.status () != QTextStream::Ok;
182182 }
183183 sqlite3_finalize (stmt);
184184
@@ -283,14 +283,15 @@ bool ExportDataDialog::exportQueryJson(const std::string& sQuery, const QString&
283283
284284 // Create JSON document
285285 file.write (json_table.dump (ui->checkPrettyPrint ->isChecked () ? 4 : -1 ).c_str ());
286+ bool writeError = file.error () != QFileDevice::NoError;
286287
287288 QApplication::restoreOverrideCursor ();
288289 qApp->processEvents ();
289290
290291 // Done writing the file
291292 file.close ();
292293
293- if (file.error () != QFileDevice::NoError) {
294+ if (writeError || file.error () != QFileDevice::NoError) {
294295 QMessageBox::warning (this , QApplication::applicationName (),
295296 tr (" Error while writing the file '%1': %2" )
296297 .arg (sFilename , file.errorString ()));
@@ -328,6 +329,8 @@ void ExportDataDialog::accept()
328329 break ;
329330 }
330331
332+ bool success = true ;
333+
331334 if (!m_sQuery.empty ())
332335 {
333336 // called from sqlexecute query tab
@@ -342,7 +345,7 @@ void ExportDataDialog::accept()
342345 return ;
343346 }
344347
345- exportQuery (m_sQuery, sFilename );
348+ success = exportQuery (m_sQuery, sFilename );
346349 } else {
347350 // called from the File export menu
348351 const QList<QListWidgetItem*> selectedItems = ui->listTables ->selectedItems ();
@@ -395,7 +398,7 @@ void ExportDataDialog::accept()
395398 // if we are called from execute sql tab, query is already set
396399 // and we only export 1 select
397400 std::string sQuery = " SELECT * FROM " + sqlb::ObjectIdentifier (selectedItems.at (i)->data (Qt::UserRole).toString ().toStdString ()).toString () + " ;" ;
398- exportQuery (sQuery , filenames.at (i));
401+ success = exportQuery (sQuery , filenames.at (i)) && success ;
399402 }
400403 }
401404
@@ -407,7 +410,11 @@ void ExportDataDialog::accept()
407410 Settings::setValue (" exportcsv" , " newlinecharacters" , currentNewLineString ());
408411
409412 // Notify the user the export has completed
410- QMessageBox::information (this , QApplication::applicationName (), tr (" Export completed." ));
413+ if (success) {
414+ QMessageBox::information (this , QApplication::applicationName (), tr (" Export completed." ));
415+ } else {
416+ QMessageBox::warning (this , QApplication::applicationName (), tr (" Export finished with errors." ));
417+ }
411418 QDialog::accept ();
412419}
413420
0 commit comments