comparison libgui/graphics/annotation-dialog.cc @ 31619:ad014fc78bd6

use individual local gui_settings objects Previously, we created a single gui_settings object (derived from QSettings) and accessed it from the resource_manager object. That design is not necessary and is not the way QSettings was designed to be used. Instead of managing a single object, we should be using individual QSettings objects where needed. Each individual QSettings object manages thread-safe access to a single global collection of settings. The Qt docs say that operations on QSettings are not thread safe, but that means that you can't create a QSettings object in one thread and use it in another without some locking. I'm not sure whether we were doing that correctly, but with this change it no longer matters. Each QSettings object does perform locking when reading or writing the underlying global data. * resource-manager.h, resource-manager.cc (resource_manager::m_settings): Delete data member. (resource_manager::get_settings): Delete. * annotation-dialog.cc, QTerminal.cc, QTerminal.h, command-widget.cc, command-widget.h, community-news.cc, dialog.cc, documentation-bookmarks.cc, documentation-bookmarks.h, documentation-dock-widget.cc, documentation-dock-widget.h, documentation.cc, documentation.h, dw-main-window.cc, dw-main-window.h, external-editor-interface.cc, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, history-dock-widget.cc, history-dock-widget.h, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, octave-qscintilla.cc, main-window.cc, main-window.h, news-reader.cc, octave-dock-widget.cc, octave-dock-widget.h, qt-interpreter-events.cc, qt-interpreter-events.h, release-notes.cc, resource-manager.cc, resource-manager.h, set-path-dialog.cc, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, terminal-dock-widget.cc, terminal-dock-widget.h, variable-editor.cc, variable-editor.h, welcome-wizard.cc, workspace-model.cc, workspace-model.h, workspace-view.cc: Use local gui_settings objects instead of accessing a pointer to a single gui_settings object owned by the resource_manager object.
author John W. Eaton <jwe@octave.org>
date Fri, 02 Dec 2022 14:23:53 -0500
parents 796f54d4ddbf
children ca7d58406f82
comparison
equal deleted inserted replaced
31618:cd833a9baaa7 31619:ad014fc78bd6
31 #include <QPushButton> 31 #include <QPushButton>
32 #include <QPalette> 32 #include <QPalette>
33 33
34 #include "gui-settings.h" 34 #include "gui-settings.h"
35 #include "gui-preferences-gp.h" 35 #include "gui-preferences-gp.h"
36 #include "gui-settings.h"
36 #include "octave-qobject.h" 37 #include "octave-qobject.h"
37 38
38 #include "QtHandlesUtils.h" 39 #include "QtHandlesUtils.h"
39 #include "annotation-dialog.h" 40 #include "annotation-dialog.h"
40 #include "ui-annotation-dialog.h" 41 #include "ui-annotation-dialog.h"
53 void 54 void
54 annotation_dialog::init () 55 annotation_dialog::init ()
55 { 56 {
56 ui->setupUi (this); 57 ui->setupUi (this);
57 58
58 octave::resource_manager& rmgr = m_octave_qobj.get_resource_manager (); 59 octave::gui_settings settings;
59
60 octave::gui_settings *settings = rmgr.get_settings ();
61 60
62 // restore last geometry 61 // restore last geometry
63 if (settings && settings->contains (gp_annotation_geometry.key)) 62 if (settings.contains (gp_annotation_geometry.key))
64 restoreGeometry (settings->value (gp_annotation_geometry).toByteArray ()); 63 restoreGeometry (settings.value (gp_annotation_geometry).toByteArray ());
65 64
66 // connect signals 65 // connect signals
67 connect (ui->button_box, &QDialogButtonBox::clicked, 66 connect (ui->button_box, &QDialogButtonBox::clicked,
68 this, &annotation_dialog::button_clicked); 67 this, &annotation_dialog::button_clicked);
69 68
99 annotation_dialog::button_clicked (QAbstractButton *button) 98 annotation_dialog::button_clicked (QAbstractButton *button)
100 { 99 {
101 QDialogButtonBox::ButtonRole button_role 100 QDialogButtonBox::ButtonRole button_role
102 = ui->button_box->buttonRole (button); 101 = ui->button_box->buttonRole (button);
103 102
104 octave::resource_manager& rmgr = m_octave_qobj.get_resource_manager (); 103 octave::gui_settings settings;
105
106 octave::gui_settings *settings = rmgr.get_settings ();
107 104
108 // save position 105 // save position
109 if (settings) 106 settings.setValue (gp_annotation_geometry.key, saveGeometry ());
110 settings->setValue (gp_annotation_geometry.key, saveGeometry ());
111 107
112 if (button_role == QDialogButtonBox::ApplyRole 108 if (button_role == QDialogButtonBox::ApplyRole
113 || button_role == QDialogButtonBox::AcceptRole) 109 || button_role == QDialogButtonBox::AcceptRole)
114 { 110 {
115 get_gui_props (); 111 get_gui_props ();