From eea53b309171934e891fe23f6da9aba609666970 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 23 Feb 2018 23:04:21 +0100 Subject: [PATCH] Fixed #79 (Macro Editor: Replace function enabled also for read-only macros) --- src/lay/lay/layMacroEditorDialog.cc | 2 ++ src/lay/lay/layMacroEditorPage.cc | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/lay/lay/layMacroEditorDialog.cc b/src/lay/lay/layMacroEditorDialog.cc index 9f0f408c6..a866660f0 100644 --- a/src/lay/lay/layMacroEditorDialog.cc +++ b/src/lay/lay/layMacroEditorDialog.cc @@ -1621,6 +1621,8 @@ MacroEditorDialog::current_tab_changed (int index) // clear the search searchEditBox->clear (); + replaceFrame->setEnabled (page && page->macro () && !page->macro ()->is_readonly ()); + apply_search (); do_update_ui_to_run_mode (); diff --git a/src/lay/lay/layMacroEditorPage.cc b/src/lay/lay/layMacroEditorPage.cc index 804c98741..f82350c44 100644 --- a/src/lay/lay/layMacroEditorPage.cc +++ b/src/lay/lay/layMacroEditorPage.cc @@ -971,6 +971,10 @@ static QString interpolate_string (const QString &replace, const QRegExp &re) void MacroEditorPage::replace_and_find_next (const QString &replace) { + if (! mp_macro || mp_macro->is_readonly ()) { + return; + } + QTextCursor c = mp_text->textCursor (); if (c.hasSelection ()) { c.insertText (interpolate_string (replace, m_current_search)); @@ -982,6 +986,10 @@ MacroEditorPage::replace_and_find_next (const QString &replace) void MacroEditorPage::replace_all (const QString &replace) { + if (! mp_macro || mp_macro->is_readonly ()) { + return; + } + const QTextDocument *doc = mp_text->document (); QTextCursor c = mp_text->textCursor ();