mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
desktop: take an std::string in MainWindow::setCurrentFile()
This fixes a crash condition when opening the cloud from desktop: The old code passed a NULL pointer that was then assigned to an std::string, which is not supported. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
6aca76c342
commit
2c490fcbbb
2 changed files with 7 additions and 7 deletions
|
@ -416,7 +416,7 @@ void MainWindow::on_actionCloudstorageopen_triggered()
|
||||||
showProgressBar();
|
showProgressBar();
|
||||||
QByteArray fileNamePtr = QFile::encodeName(filename);
|
QByteArray fileNamePtr = QFile::encodeName(filename);
|
||||||
if (!parse_file(fileNamePtr.data(), &divelog))
|
if (!parse_file(fileNamePtr.data(), &divelog))
|
||||||
setCurrentFile(fileNamePtr.data());
|
setCurrentFile(fileNamePtr.toStdString());
|
||||||
process_loaded_dives();
|
process_loaded_dives();
|
||||||
hideProgressBar();
|
hideProgressBar();
|
||||||
refreshDisplay();
|
refreshDisplay();
|
||||||
|
@ -451,7 +451,7 @@ void MainWindow::on_actionCloudstoragesave_triggered()
|
||||||
if (error)
|
if (error)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setCurrentFile(qPrintable(filename));
|
setCurrentFile(filename.toStdString());
|
||||||
Command::setClean();
|
Command::setClean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ void MainWindow::closeCurrentFile()
|
||||||
/* free the dives and trips */
|
/* free the dives and trips */
|
||||||
clear_git_id();
|
clear_git_id();
|
||||||
clear_dive_file_data(); // this clears all the core data structures and resets the models
|
clear_dive_file_data(); // this clears all the core data structures and resets the models
|
||||||
setCurrentFile(nullptr);
|
setCurrentFile(std::string());
|
||||||
diveList->setSortOrder(DiveTripModelBase::NR, Qt::DescendingOrder);
|
diveList->setSortOrder(DiveTripModelBase::NR, Qt::DescendingOrder);
|
||||||
if (existing_filename.empty())
|
if (existing_filename.empty())
|
||||||
setTitle();
|
setTitle();
|
||||||
|
@ -525,7 +525,7 @@ void MainWindow::updateCloudOnlineStatus()
|
||||||
ui.actionCloudOnline->setChecked(is_cloud && !git_local_only);
|
ui.actionCloudOnline->setChecked(is_cloud && !git_local_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setCurrentFile(const char *f)
|
void MainWindow::setCurrentFile(const std::string &f)
|
||||||
{
|
{
|
||||||
existing_filename = f;
|
existing_filename = f;
|
||||||
setTitle();
|
setTitle();
|
||||||
|
@ -1201,7 +1201,7 @@ int MainWindow::file_save_as(void)
|
||||||
if (save_dives(qPrintable(filename)))
|
if (save_dives(qPrintable(filename)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
setCurrentFile(qPrintable(filename));
|
setCurrentFile(filename.toStdString());
|
||||||
Command::setClean();
|
Command::setClean();
|
||||||
addRecentFile(filename, true);
|
addRecentFile(filename, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1308,7 +1308,7 @@ void MainWindow::loadFiles(const QStringList &fileNames)
|
||||||
for (int i = 0; i < fileNames.size(); ++i) {
|
for (int i = 0; i < fileNames.size(); ++i) {
|
||||||
fileNamePtr = QFile::encodeName(fileNames.at(i));
|
fileNamePtr = QFile::encodeName(fileNames.at(i));
|
||||||
if (!parse_file(fileNamePtr.data(), &divelog)) {
|
if (!parse_file(fileNamePtr.data(), &divelog)) {
|
||||||
setCurrentFile(fileNamePtr.data());
|
setCurrentFile(fileNamePtr.toStdString());
|
||||||
addRecentFile(fileNamePtr, false);
|
addRecentFile(fileNamePtr, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ private:
|
||||||
bool askSaveChanges();
|
bool askSaveChanges();
|
||||||
bool okToClose(QString message);
|
bool okToClose(QString message);
|
||||||
void closeCurrentFile();
|
void closeCurrentFile();
|
||||||
void setCurrentFile(const char *f);
|
void setCurrentFile(const std::string &f);
|
||||||
void updateCloudOnlineStatus();
|
void updateCloudOnlineStatus();
|
||||||
void showProgressBar();
|
void showProgressBar();
|
||||||
void hideProgressBar();
|
void hideProgressBar();
|
||||||
|
|
Loading…
Add table
Reference in a new issue