| 57 | } |
| 58 | |
| 59 | void DebuggerTracingDialog::accept() |
| 60 | { |
| 61 | // Check that if we use format string, |
| 62 | // the number of expressions is not greater than the number of |
| 63 | // format specifiers |
| 64 | bool ok = true; |
| 65 | |
| 66 | if (enableCustomFormat->isChecked()) |
| 67 | { |
| 68 | QString s = customFormat->text(); |
| 69 | int percent_count = 0; |
| 70 | for (int i = 0; i < s.length(); ++i) |
| 71 | if (s[i] == '%') |
| 72 | { |
| 73 | if (i+1 < s.length()) |
| 74 | { |
| 75 | if (s[i+1] != '%') |
| 76 | { |
| 77 | ++percent_count; |
| 78 | } |
| 79 | else |
| 80 | { |
| 81 | // Double % |
| 82 | ++i; |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | if (percent_count < expressions->items().count()) |
| 88 | { |
| 89 | ok = false; |
| 90 | |
| 91 | KMessageBox::error( |
| 92 | this, |
| 93 | "<b>Not enough format specifiers</b>" |
| 94 | "<p>The number of format specifiers in the custom format " |
| 95 | "string is less than the number of expressions. Either remove " |
| 96 | "some expressions or edit the format string.", |
| 97 | "Not enough format specifiers"); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | if (ok) |
| 102 | { |
| 103 | bp_->setTracingEnabled(enable->isChecked()); |
| 104 | bp_->setTracedExpressions(expressions->items()); |
| 105 | bp_->setTraceFormatStringEnabled(enableCustomFormat->isChecked()); |
| 106 | bp_->setTraceFormatString(customFormat->text()); |
| 107 | QDialog::accept(); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | #include "moc_debuggertracingdialog.cpp" |
no test coverage detected