[Uml-devel] kdesdk/umbrello/umbrello
Sebastian Stein
seb.kde at hpfsc.de
Tue Jul 13 03:59:01 UTC 2004
CVS commit by sstein:
apply patches by Achim Spangler:
- fix saving/loading to uncompressed file on KDE 3.2
- files are saved to a temp file first and thereafter moved to the destination file; this should prevent data loss when Umbrello crashes while saving
and a leaf fix by myself:
==16320== 4 bytes in 1 blocks are definitely lost in loss record 13 of 248
==16320== at 0x3C01D54C: operator new(unsigned) (vg_replace_malloc.c:107)
==16320== by 0x81609CF: UMLDoc::UMLDoc(QWidget*, char const*) (umldoc.cpp:79)
==16320== by 0x81585B2: UMLApp::initDocument() (uml.cpp:357)
==16320== by 0x81557E2: UMLApp::UMLApp(QWidget*, char const*) (uml.cpp:80)
M +20 -13 umldoc.cpp 1.162
--- kdesdk/umbrello/umbrello/umldoc.cpp #1.161:1.162
@@ -49,4 +49,5 @@
#include <kdeversion.h>
#include <kdebug.h>
+#include <kio/job.h>
#include <kio/netaccess.h>
#include <klocale.h>
@@ -97,4 +98,5 @@ UMLDoc::UMLDoc(QWidget *parent, const ch
UMLDoc::~UMLDoc() {
delete m_pChangeLog;
+ delete m_codeGenerationXMIParamMap;
m_pChangeLog = 0;
}
@@ -532,5 +534,8 @@ bool UMLDoc::saveDocument(const KURL& ur
} else
-#else
+// stop HERE with the special handling of the KDE_IS_VERSION(3,2,0)
+// as otherwise, the _DEFAULT!!!_ case of saving uncompressed XMI
+// isn't handled anymore!!
+#endif
{
// save as normal uncompressed XMI
@@ -538,11 +543,11 @@ bool UMLDoc::saveDocument(const KURL& ur
KTempFile tmpfile; // we need this tmp file if we are writing to a remote file
- // now check if we are writing to a local file
- if ( url.isLocalFile() )
- {
- file.setName( d.path() );
- } else {
+ // save in _any_ case to a temp file
+ // -> if something goes wrong during saveToXmi, the
+ // original content is preserved
+ // ( e.g. if umbrello dies in the middle of the document model parsing
+ // for saveToXMI due to some problems )
+ /// @TODO insert some checks in saveToXMI to detect a failed save attempt
file.setName( tmpfile.name() );
- }
// lets open the file for writing
@@ -553,4 +558,5 @@ bool UMLDoc::saveDocument(const KURL& ur
saveToXMI( file ); // save the xmi stuff to it
file.close();
+ tmpfile.close();
// if it is a remote file, we have to upload the tmp file
@@ -561,10 +567,11 @@ bool UMLDoc::saveDocument(const KURL& ur
# endif
);
+ } else {
+ // now remove the original file
+ if ( KIO::file_move( tmpfile.name(), d.path(), -1, true ) == false ) {
+ KMessageBox::error(0, i18n("There was a problem saving file: %1").arg(d.path()), i18n("Save Error"));
+ }
}
-
- tmpfile.close();
- tmpfile.unlink();
}
-#endif
if( !uploaded )
{
More information about the umbrello-devel
mailing list