summaryrefslogtreecommitdiff
path: root/noncore
authoralwin <alwin>2004-08-01 14:13:14 (UTC)
committer alwin <alwin>2004-08-01 14:13:14 (UTC)
commit67e2e98457418bc491efd2d4567f851e77a0441a (patch) (side-by-side diff)
tree44a579f9ee06ec5a703825c1738d3e1a6155a282 /noncore
parent4fbd0218b71432444214cf124c45e3d03185324f (diff)
downloadopie-67e2e98457418bc491efd2d4567f851e77a0441a.zip
opie-67e2e98457418bc491efd2d4567f851e77a0441a.tar.gz
opie-67e2e98457418bc491efd2d4567f851e77a0441a.tar.bz2
fixed a crasher when configfile isn't writeable
empty labels will replaced by filename
Diffstat (limited to 'noncore') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/keyz-cfg/cfgfile.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/noncore/apps/keyz-cfg/cfgfile.cpp b/noncore/apps/keyz-cfg/cfgfile.cpp
index 81d1ee1..be7150e 100644
--- a/noncore/apps/keyz-cfg/cfgfile.cpp
+++ b/noncore/apps/keyz-cfg/cfgfile.cpp
@@ -131,28 +131,33 @@ bool CfgParser::load(QString file, CfgFile& cfg) {
return true;
}
bool CfgParser::save(QString file, CfgFile& cfg) {
FILE* f = fopen((const char*) file.local8Bit(), "w");
+ if (!f) {
+ oerr << "Could not write config file!" << oendl;
+ return false;
+ }
fprintf(f, "<keymap autorepeat-delay=\"%d\" autorepeat-period=\"%d\" "
"author=\"keyzcfg\">\n", cfg.getAutorepeatDelay(),
cfg.getAutorepeatPeriod());
QList<CfgEntry>& entries = cfg.getEntries();
int n;
for(n=0; n < (int) entries.count(); n++) {
CfgEntry* entry = entries.at(n);
QString l = entry->getLabel();
- if (!l.isEmpty()) {
+ if (l.isEmpty()) {
+ l = entry->getFile();
+ }
fprintf(f, "\t<label name=\"%s\" state=\"km%d:*\"/>\n",
(const char*) l.utf8(), n);
}
- }
for(n=0; n < (int) entries.count(); n++) {
CfgEntry* entry = entries.at(n);
fprintf(f, "\t<include file=\"%s\" prefix=\"km%d\"/>\n",
(const char*) entry->getFile().utf8(), n);
}