diff options
| author | Remko Tronçon <git@el-tramo.be> | 2014-05-18 08:48:07 (GMT) |
|---|---|---|
| committer | Remko Tronçon <git@el-tramo.be> | 2014-05-18 08:48:07 (GMT) |
| commit | 13bcb579fe1ead0a5dca3defdef73023463c51e4 (patch) | |
| tree | df975b9693ad426718f483f35dd32d776f0bf518 /Swift/QtUI/QtTextEdit.cpp | |
| parent | a2bd9984a31e426e2ba263e68e6dc0733970026c (diff) | |
| download | swift-contrib-13bcb579fe1ead0a5dca3defdef73023463c51e4.zip swift-contrib-13bcb579fe1ead0a5dca3defdef73023463c51e4.tar.bz2 | |
Fix spell check leaks and errors
Change-Id: Ied0ac4abb21ef1720411fdbc61e7a687eee3afd1
Diffstat (limited to 'Swift/QtUI/QtTextEdit.cpp')
| -rw-r--r-- | Swift/QtUI/QtTextEdit.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp index cac8bb4..8551f3d 100644 --- a/Swift/QtUI/QtTextEdit.cpp +++ b/Swift/QtUI/QtTextEdit.cpp @@ -170,74 +170,70 @@ void QtTextEdit::contextMenuEvent(QContextMenuEvent* event) { void QtTextEdit::addSuggestions(QMenu* menu, QContextMenuEvent* event) { replaceWordActions_.clear(); QAction* insertPoint = menu->actions().first(); QTextCursor cursor = cursorForPosition(event->pos()); PositionPair wordPosition = getWordFromCursor(cursor.position()); if (boost::get<0>(wordPosition) < 0) { // The click was executed outside a spellable word so no // suggestions are necessary return; } cursor.setPosition(boost::get<0>(wordPosition), QTextCursor::MoveAnchor); cursor.setPosition(boost::get<1>(wordPosition), QTextCursor::KeepAnchor); std::vector<std::string> wordList; checker_->getSuggestions(Q2PSTRING(cursor.selectedText()), wordList); if (wordList.size() == 0) { QAction* noSuggestions = new QAction(tr("No Suggestions"), menu); noSuggestions->setDisabled(true); menu->insertAction(insertPoint, noSuggestions); } else { for (std::vector<std::string>::iterator it = wordList.begin(); it != wordList.end(); ++it) { QAction* wordAction = new QAction(it->c_str(), menu); menu->insertAction(insertPoint, wordAction); replaceWordActions_.push_back(wordAction); } } menu->insertAction(insertPoint, menu->addSeparator()); } #ifdef HAVE_SPELLCHECKER void QtTextEdit::setUpSpellChecker() { - SpellCheckerFactory* checkerFactory = new SpellCheckerFactory(); delete checker_; + checker_ = NULL; if (settings_->getSetting(SettingConstants::SPELL_CHECKER)) { std::string dictPath = settings_->getSetting(SettingConstants::DICT_PATH); std::string dictFile = settings_->getSetting(SettingConstants::DICT_FILE); - checker_ = checkerFactory->createSpellChecker(dictPath + dictFile); - delete checkerFactory; - } - else { - checker_ = NULL; + checker_ = SpellCheckerFactory().createSpellChecker(dictPath + dictFile); } } #endif void QtTextEdit::spellCheckerSettingsWindow() { if (!spellCheckerWindow_) { spellCheckerWindow_ = new QtSpellCheckerWindow(settings_); settings_->onSettingChanged.connect(boost::bind(&QtTextEdit::handleSettingChanged, this, _1)); spellCheckerWindow_->show(); } else { spellCheckerWindow_->show(); spellCheckerWindow_->raise(); spellCheckerWindow_->activateWindow(); } } void QtTextEdit::handleSettingChanged(const std::string& settings) { if (settings == SettingConstants::SPELL_CHECKER.getKey() || settings == SettingConstants::DICT_PATH.getKey() || settings == SettingConstants::DICT_FILE.getKey()) { #ifdef HAVE_SPELLCHECKER setUpSpellChecker(); underlineMisspells(); #endif } } } |
Swift