author | erik <erik> | 2007-01-26 20:22:50 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-26 20:22:50 (UTC) |
commit | 53d630c9c4813142ee13e6843c30476a5db26e78 (patch) (unidiff) | |
tree | 50a77a94cfeaccbb3d993bced8b7d0f498f74c7c /core/apps/textedit/textedit.cpp | |
parent | 152a8fe978851aea8dac6ae5cb11f73540746b83 (diff) | |
download | opie-53d630c9c4813142ee13e6843c30476a5db26e78.zip opie-53d630c9c4813142ee13e6843c30476a5db26e78.tar.gz opie-53d630c9c4813142ee13e6843c30476a5db26e78.tar.bz2 |
Each file in this commit exhibit an example of what prevent calls
'reverse inull'. All that means is that a pointer gets dereferenced. Then
a pointer gets checked for validity before being dereferenced again. This
almost always points to shenanigans.
For example, the konsole.cpp file has this konsoleInit() call which passes
in a const char** shell variable. Since it is a double pointer the programmer
who wrote the code made the mistake of mixing the checking of the pointer
and the pointer that points to the pointer. This commit attempts to correct
that.
Of course there are other instances of the same thing. But they all boil
down to a small mistake which might have produced strange side effects.
Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/apps/textedit/textedit.cpp | 56 |
1 files changed, 17 insertions, 39 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 61beac5..4bbc62b 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -852,13 +852,2 @@ bool TextEdit::saveAs() { | |||
852 | odebug << "saveAsFile " + currentFileName << oendl; | 852 | odebug << "saveAsFile " + currentFileName << oendl; |
853 | // case of nothing to save... | ||
854 | // if ( !doc && !currentFileName.isEmpty()) { | ||
855 | // //|| !bFromDocView) | ||
856 | // odebug << "no doc" << oendl; | ||
857 | // return true; | ||
858 | // } | ||
859 | // if ( !editor->edited() ) { | ||
860 | // delete doc; | ||
861 | // doc = 0; | ||
862 | // return true; | ||
863 | // } | ||
864 | 853 | ||
@@ -869,5 +858,5 @@ bool TextEdit::saveAs() { | |||
869 | || currentFileName == tr("Unnamed") | 858 | || currentFileName == tr("Unnamed") |
870 | || currentFileName == tr("Text Editor")) { | 859 | || currentFileName == tr("Text Editor")) |
860 | { | ||
871 | odebug << "do silly TT filename thing" << oendl; | 861 | odebug << "do silly TT filename thing" << oendl; |
872 | // if ( doc && doc->name().isEmpty() ) { | ||
873 | QString pt = rt.simplifyWhiteSpace(); | 862 | QString pt = rt.simplifyWhiteSpace(); |
@@ -875,5 +864,4 @@ bool TextEdit::saveAs() { | |||
875 | QString docname = pt; | 864 | QString docname = pt; |
876 | if ( i > 0 ) | 865 | if ( i > 0 ) docname = pt.left( i ); |
877 | docname = pt.left( i ); | 866 | |
878 | // remove "." at the beginning | ||
879 | while( docname.startsWith( "." ) ) | 867 | while( docname.startsWith( "." ) ) |
@@ -881,13 +869,11 @@ bool TextEdit::saveAs() { | |||
881 | docname.replace( QRegExp("/"), "_" ); | 869 | docname.replace( QRegExp("/"), "_" ); |
882 | // cut the length. filenames longer than that | 870 | // Cut the length. Filenames longer than 40 are not helpful |
883 | //don't make sense and something goes wrong when they get too long. | 871 | // and something goes wrong when they get too long. |
884 | if ( docname.length() > 40 ) | 872 | if ( docname.length() > 40 ) docname = docname.left(40); |
885 | docname = docname.left(40); | 873 | |
886 | if ( docname.isEmpty() ) | 874 | if ( docname.isEmpty() ) docname = tr("Unnamed"); |
887 | docname = tr("Unnamed"); | 875 | |
888 | if(doc) doc->setName(docname); | 876 | if(doc) doc->setName(docname); |
877 | |||
889 | currentFileName=docname; | 878 | currentFileName=docname; |
890 | // } | ||
891 | // else | ||
892 | // odebug << "hmmmmmm" << oendl; | ||
893 | } | 879 | } |
@@ -908,7 +894,6 @@ bool TextEdit::saveAs() { | |||
908 | dire = QPEApplication::documentDir(); | 894 | dire = QPEApplication::documentDir(); |
895 | |||
909 | QString str; | 896 | QString str; |
910 | if( !featureAutoSave) { | 897 | if( !featureAutoSave) { |
911 | str = OFileDialog::getSaveFileName( 2, | 898 | str = OFileDialog::getSaveFileName( 2, dire, filee, map); |
912 | dire, | ||
913 | filee, map); | ||
914 | } else | 899 | } else |
@@ -923,5 +908,4 @@ bool TextEdit::saveAs() { | |||
923 | if(doc) | 908 | if(doc) |
924 | // QString file = doc->file(); | ||
925 | // doc->removeFiles(); | ||
926 | delete doc; | 909 | delete doc; |
910 | |||
927 | DocLnk nf; | 911 | DocLnk nf; |
@@ -930,5 +914,4 @@ bool TextEdit::saveAs() { | |||
930 | doc = new DocLnk(nf); | 914 | doc = new DocLnk(nf); |
931 | // editor->setText(rt); | ||
932 | odebug << "Saving file as "+currentFileName << oendl; | 915 | odebug << "Saving file as "+currentFileName << oendl; |
933 | doc->setName( fi.baseName() /*currentFileName*/); | 916 | doc->setName( fi.baseName() ); |
934 | updateCaption( currentFileName); | 917 | updateCaption( currentFileName); |
@@ -943,11 +926,8 @@ bool TextEdit::saveAs() { | |||
943 | filePermissions *filePerm; | 926 | filePermissions *filePerm; |
944 | filePerm = new filePermissions(this, | 927 | filePerm = new filePermissions(this, tr("Permissions"),true, 0, |
945 | tr("Permissions"),true, | 928 | (const QString &)fileNm); |
946 | 0,(const QString &)fileNm); | ||
947 | QPEApplication::execDialog( filePerm ); | 929 | QPEApplication::execDialog( filePerm ); |
948 | 930 | ||
949 | if( filePerm) | ||
950 | delete filePerm; | 931 | delete filePerm; |
951 | } | 932 | } |
952 | // } | ||
953 | editor->setEdited( false); | 933 | editor->setEdited( false); |
@@ -1199,6 +1179,4 @@ void TextEdit::doGoto() { | |||
1199 | 1179 | ||
1200 | if(gotoEdit) { | ||
1201 | delete gotoEdit; | 1180 | delete gotoEdit; |
1202 | gotoEdit = 0; | 1181 | gotoEdit = 0; |
1203 | } | ||
1204 | 1182 | ||