r23958 by jghali - Fix double free caused by ScribusMainWindow's emergencySave()
scribus-commit
scribus-commit at lists.scribus.net
Tue Jul 28 23:12:39 UTC 2020
Author: jghali
Date: Tue Jul 28 23:12:38 2020
New Revision: 23958
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23958
Log:
Fix double free caused by ScribusMainWindow's emergencySave()
Modified:
branches/Version14x/Scribus/scribus/scribus.cpp
Modified: branches/Version14x/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23958&path=/branches/Version14x/Scribus/scribus/scribus.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scribus.cpp (original)
+++ branches/Version14x/Scribus/scribus/scribus.cpp Tue Jul 28 23:12:38 2020
@@ -9260,32 +9260,29 @@
void ScribusMainWindow::emergencySave()
{
- emergencyActivated=true;
+ emergencyActivated = true;
std::cout << "Calling Emergency Save" << std::endl;
QWidgetList windows = wsp->windowList();
- if (!windows.isEmpty())
- {
- uint windowCount=windows.count();
- for (uint i=0; i<windowCount ; ++i)
- {
- ActWin = (ScribusWin*)windows.at(i);
- doc = ActWin->doc();
- view = ActWin->view();
- doc->setModified(false);
- if (doc->hasName)
- {
- std::cout << "Saving: " << doc->DocName.toStdString() << ".emergency" << std::endl;
- doc->autoSaveTimer->stop();
- FileLoader fl(doc->DocName+".emergency");
- fl.saveFile(doc->DocName+".emergency", doc, 0);
- }
- view->close();
- uint numPages=doc->Pages->count();
- for (uint a=0; a<numPages; ++a)
- delete doc->Pages->at(a);
- delete doc;
- ActWin->close();
- }
+ if (windows.isEmpty())
+ return;
+
+ uint windowCount = windows.count();
+ for (uint i = 0; i < windowCount ; ++i)
+ {
+ ActWin = (ScribusWin*) windows.at(i);
+ doc = ActWin->doc();
+ view = ActWin->view();
+ doc->setModified(false);
+ if (doc->hasName)
+ {
+ std::cout << "Saving: " << doc->DocName.toStdString() << ".emergency" << std::endl;
+ doc->autoSaveTimer->stop();
+ FileLoader fl(doc->DocName+".emergency");
+ fl.saveFile(doc->DocName+".emergency", doc, 0);
+ }
+ // ActWin->close() will trigger ScribusWin::closeEvent()
+ // so no need to manually close view or delete doc
+ ActWin->close();
}
}
More information about the scribus-commit
mailing list