diff --git a/src/plugins/editing/RawTextView/src/rawtextviewplugin.cpp b/src/plugins/editing/RawTextView/src/rawtextviewplugin.cpp index 02c8bfb933..62d6e823e5 100644 --- a/src/plugins/editing/RawTextView/src/rawtextviewplugin.cpp +++ b/src/plugins/editing/RawTextView/src/rawtextviewplugin.cpp @@ -312,9 +312,9 @@ QString RawTextViewPlugin::viewDefaultFileExtension() const QWidget * RawTextViewPlugin::viewWidget(const QString &pFileName) { - // Make sure that we are dealing with a text file (be it new or not) + // Make sure that we are dealing with a valid file - if (!Core::isTextFile(pFileName)) + if (!mViewWidget->isValid(pFileName)) return nullptr; // Update and return our Raw Text view widget using the given file diff --git a/src/plugins/editing/RawTextView/src/rawtextviewwidget.cpp b/src/plugins/editing/RawTextView/src/rawtextviewwidget.cpp index d38c6b3cbb..6e379b649b 100644 --- a/src/plugins/editing/RawTextView/src/rawtextviewwidget.cpp +++ b/src/plugins/editing/RawTextView/src/rawtextviewwidget.cpp @@ -81,6 +81,15 @@ void RawTextViewWidget::retranslateUi() //============================================================================== +bool RawTextViewWidget::isValid(const QString &pFileName) const +{ + // Return whether we are dealing with a text file (be it new or not) + + return Core::isTextFile(pFileName); +} + +//============================================================================== + void RawTextViewWidget::initialize(const QString &pFileName, bool pUpdate) { // Retrieve the editor associated with the given file, if any @@ -190,14 +199,15 @@ void RawTextViewWidget::fileSaved(const QString &pFileName) void RawTextViewWidget::fileReloaded(const QString &pFileName) { - // The given file has been reloaded, so reload it, should it be managed + // The given file has been reloaded, so reload it, should it be managed and + // still valid // Note: if the view for the given file is not the active view, then to call // finalize() and then initialize() would activate the contents of the // view (but the file tab would still point to the previously active // file). However, we want to the 'old' file to remain the active one, // hence the extra argument we pass to initialize()... - if (mEditors.contains(pFileName)) { + if (mEditors.contains(pFileName) && isValid(pFileName)) { bool update = mEditor == mEditors.value(pFileName); finalize(pFileName); diff --git a/src/plugins/editing/RawTextView/src/rawtextviewwidget.h b/src/plugins/editing/RawTextView/src/rawtextviewwidget.h index 85a47ab076..882cddd289 100644 --- a/src/plugins/editing/RawTextView/src/rawtextviewwidget.h +++ b/src/plugins/editing/RawTextView/src/rawtextviewwidget.h @@ -59,6 +59,8 @@ class RawTextViewWidget : public Core::ViewWidget void retranslateUi() override; + bool isValid(const QString &pFileName) const; + void initialize(const QString &pFileName, bool pUpdate = true); void finalize(const QString &pFileName);