[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kbibtex] src/program/docklets: Fixing crash when open file got modified externally
From: Thomas Fischer <fischer () unix-ag ! uni-kl ! de>
Date: 2016-11-26 21:53:09
Message-ID: E1cAkuD-0006O8-Sn () code ! kde ! org
[Download RAW message or body]
Git commit b157797684f800f13f7bd4d451629007941ee471 by Thomas Fischer.
Committed on 26/11/2016 at 21:37.
Pushed by thomasfischer into branch 'master'.
Fixing crash when open file got modified externally
Fixing a crash that would happen when closing a file or KBibTeX
or when changing the filter criteria (depending on bug reporter),
but only if file was modified externally (e.g. in KWrite/Kate)
and the file monitor in KBibTeX detected this modification and
the user confirmed to reload the affected file.
This commit refactors the FileSettings dock/panel to not use a
potentially stale File object, but to retrieve an always(?)
current File object from the currently shown central FileView.
Forward-porting commit 9b1476c20421db6 from branch kbibtex/0.6
M +12 -10 src/program/docklets/filesettings.cpp
M +2 -2 src/program/docklets/filesettings.h
https://commits.kde.org/kbibtex/b157797684f800f13f7bd4d451629007941ee471
diff --git a/src/program/docklets/filesettings.cpp \
b/src/program/docklets/filesettings.cpp index 0a1e52b..f871990 100644
--- a/src/program/docklets/filesettings.cpp
+++ b/src/program/docklets/filesettings.cpp
@@ -35,12 +35,13 @@
#include "openfileinfo.h"
FileSettings::FileSettings(QWidget *parent)
- : FileSettingsWidget(parent), m_currentFile(NULL), m_fileView(NULL)
+ : FileSettingsWidget(parent), m_fileView(NULL)
{
setEnabled(false);
connect(this, &FileSettings::widgetsChanged, this, \
&FileSettings::widgetsChangedSlot);
+ connect(OpenFileInfoManager::instance(), &OpenFileInfoManager::currentChanged, \
this, &FileSettings::currentFileChangedSlot); /// Monitoring file flag changes to \
get notified of /// "Save As" operations where the file settings
/// may get changed (requires a reload of properties)
@@ -49,21 +50,22 @@ FileSettings::FileSettings(QWidget *parent)
void FileSettings::setFileView(FileView *fileView)
{
- m_currentFile = NULL;
m_fileView = fileView;
-
- if (m_fileView != NULL && m_fileView->fileModel() != NULL)
- m_currentFile = m_fileView->fileModel()->bibliographyFile();
-
- loadProperties(m_currentFile);
- setEnabled(m_currentFile != NULL);
+ currentFileChangedSlot();
}
void FileSettings::widgetsChangedSlot()
{
- if (m_currentFile != NULL) {
- saveProperties(m_currentFile);
+ File *file = m_fileView != NULL && m_fileView->fileModel() != NULL ? \
m_fileView->fileModel()->bibliographyFile() : NULL; + if (file != NULL) {
+ saveProperties(file);
/// Notify main view about change it its data
m_fileView->externalModification();
}
}
+
+void FileSettings::currentFileChangedSlot() {
+ File *file = m_fileView != NULL && m_fileView->fileModel() != NULL ? \
m_fileView->fileModel()->bibliographyFile() : NULL; + loadProperties(file);
+ setEnabled(file != NULL);
+}
diff --git a/src/program/docklets/filesettings.h \
b/src/program/docklets/filesettings.h index ab3176b..d84223f 100644
--- a/src/program/docklets/filesettings.h
+++ b/src/program/docklets/filesettings.h
@@ -23,7 +23,7 @@
class FileView;
class File;
-
+class OpenFileInfoManager;
/**
* @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
@@ -39,9 +39,9 @@ public:
private slots:
void widgetsChangedSlot();
+ void currentFileChangedSlot();
private:
- File *m_currentFile;
FileView *m_fileView;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic