From: hama Date: Tue, 21 Apr 2015 21:44:06 +0000 (+0200) Subject: text search works X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=622c37afef44a963d33f95efd27f2d0d4d7b89ca;p=reqt text search works --- diff --git a/appl/refind/mainwindow.cpp b/appl/refind/mainwindow.cpp index 781260c..7036ff4 100644 --- a/appl/refind/mainwindow.cpp +++ b/appl/refind/mainwindow.cpp @@ -282,8 +282,8 @@ QDir::Filters MainWindow::buildFileTypes(){ */ void MainWindow::prepareTextFind(){ m_textFinder.setSearchParameter(ui->comboBoxTextPattern->currentText(), - ui->checkBoxTextIgnoreCase->isChecked(), ui->checkBoxRegExpr, - !ui->checkBoxBinaryFiles); + ui->checkBoxTextIgnoreCase->isChecked(), ui->checkBoxRegExpr->isChecked(), + !ui->checkBoxBinaryFiles->isChecked()); QString error = m_textFinder.regExprError(); if (!error.isEmpty()){ guiError(ui->comboBoxTextPattern, error); diff --git a/appl/refind/textfinder.cpp b/appl/refind/textfinder.cpp index e655791..06431ec 100644 --- a/appl/refind/textfinder.cpp +++ b/appl/refind/textfinder.cpp @@ -43,6 +43,10 @@ TextFinder::TextFinder(const QString& fullName, int64_t length) : * Destructor. */ TextFinder::~TextFinder(){ + if (m_ownsRegExpr){ + delete m_regExpr; + m_regExpr = NULL; + } } /** @@ -94,6 +98,7 @@ void TextFinder::getSearchParameter(const TextFinder& source){ m_regExpr = source.m_regExpr; m_isRegExpr = source.m_isRegExpr; m_ignoreCase = source.m_ignoreCase; + m_text = source.m_text; } /** @@ -106,11 +111,7 @@ bool TextFinder::isBinary(){ int length = data.length(); const char* ptr = reinterpret_cast (memchr(data.constData(), '\0', length)); - bool rc = int(ptr - data.constData()) != length; - - if (!rc) - rc = !isText(data); - + bool rc = ptr != NULL; return rc; } @@ -218,7 +219,10 @@ void TextFinder::setSearchParameter(const QString& text, bool ignoreCase, m_ignoreCase = ignoreCase; m_isRegExpr = isRegExpr; m_ignoreBinary = ignoreBinary; - if (isRegExpr && !text.isEmpty()){ + if (! isRegExpr || text.isEmpty()){ + delete m_regExpr; + m_regExpr = NULL; + } else { QRegularExpression::PatternOption option = ignoreCase ? QRegularExpression::CaseInsensitiveOption : @@ -236,7 +240,7 @@ void TextFinder::setSearchParameter(const QString& text, bool ignoreCase, */ QString TextFinder::regExprError(){ QString rc; - if (m_regExpr != NULL && m_regExpr->isValid()) + if (m_regExpr != NULL && ! m_regExpr->isValid()) rc = m_regExpr->errorString(); return rc; }