[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kbibtex/kbibtex/0.6] src: Fixing crash when open file got modified externally
From:       Thomas Fischer <fischer () unix-ag ! uni-kl ! de>
Date:       2016-11-26 21:53:36
Message-ID: E1cAkue-0006dL-Hv () code ! kde ! org
[Download RAW message or body]

Git commit 90a55671b0e5f7b4d186367871c20cf3b902129f by Thomas Fischer.
Committed on 24/11/2016 at 21:04.
Pushed by thomasfischer into branch 'kbibtex/0.6'.

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.

BUG: 367925

M  +0    -10   src/gui/widgets/filesettingswidget.cpp
M  +0    -2    src/gui/widgets/filesettingswidget.h
M  +13   -15   src/program/docklets/filesettings.cpp
M  +2    -3    src/program/docklets/filesettings.h

https://commits.kde.org/kbibtex/90a55671b0e5f7b4d186367871c20cf3b902129f

diff --git a/src/gui/widgets/filesettingswidget.cpp \
b/src/gui/widgets/filesettingswidget.cpp index 5f93102..36fe03c 100644
--- a/src/gui/widgets/filesettingswidget.cpp
+++ b/src/gui/widgets/filesettingswidget.cpp
@@ -38,11 +38,6 @@ FileSettingsWidget::FileSettingsWidget(QWidget *parent)
     setupGUI();
 }
 
-void FileSettingsWidget::loadProperties()
-{
-    loadProperties(m_file);
-}
-
 void FileSettingsWidget::loadProperties(File *file)
 {
     m_file = file;
@@ -92,11 +87,6 @@ void FileSettingsWidget::loadProperties(File *file)
     }
 }
 
-void FileSettingsWidget::saveProperties()
-{
-    saveProperties(m_file);
-}
-
 void FileSettingsWidget::saveProperties(File *file)
 {
     m_file = file;
diff --git a/src/gui/widgets/filesettingswidget.h \
b/src/gui/widgets/filesettingswidget.h index 3dd3857..3b68a03 100644
--- a/src/gui/widgets/filesettingswidget.h
+++ b/src/gui/widgets/filesettingswidget.h
@@ -45,8 +45,6 @@ public:
     void saveProperties(File *file);
 
 public slots:
-    void loadProperties();
-    void saveProperties();
     void resetToDefaults();
 
 signals:
diff --git a/src/program/docklets/filesettings.cpp \
b/src/program/docklets/filesettings.cpp index 2b069e3..d753794 100644
--- a/src/program/docklets/filesettings.cpp
+++ b/src/program/docklets/filesettings.cpp
@@ -32,37 +32,35 @@
 #include "value.h"
 #include "iconvlatex.h"
 #include "file.h"
+#include "openfileinfo.h"
 
 FileSettings::FileSettings(OpenFileInfoManager *ofim, QWidget *parent)
-        : FileSettingsWidget(parent), m_currentFile(NULL), m_fileView(NULL)
+        : FileSettingsWidget(parent), m_fileView(NULL)
 {
     setEnabled(false);
 
     connect(this, SIGNAL(widgetsChanged()), this, SLOT(widgetsChangedSlot()));
-
-    /// Monitoring file flag changes to get notified of
-    /// "Save As" operations where the file settings
-    /// may get changed (requires a reload of properties)
-    connect(ofim, SIGNAL(flagsChanged(OpenFileInfo::StatusFlags)), this, \
SLOT(loadProperties())); +    connect(ofim, \
SIGNAL(currentChanged(OpenFileInfo*,KService::Ptr)), this, \
SLOT(currentFileChangedSlot()));  }
 
 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 3b5089c..ccc68e8 100644
--- a/src/program/docklets/filesettings.h
+++ b/src/program/docklets/filesettings.h
@@ -23,8 +23,7 @@
 
 class FileView;
 class File;
-
-#include "openfileinfo.h"
+class OpenFileInfoManager;
 
 /**
  * @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
@@ -40,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