annotate libgui/graphics/Object.cc @ 25044:b6aea95a7bf9 stable

store graphics object in Qt backend to avoid crash (bug #53487, #53500) * Figure.cc (Figure::update): Return early if window doesn't exist. * Object.h, Object.cc (Object::m_go): New data member. (Object::object): Return m_go instead of using gh_manager to find it.
author John W. Eaton <jwe@octave.org>
date Wed, 28 Mar 2018 17:36:40 -0400
parents 194eb4bd202b
children 6652d3823428
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 2011-2017 Michael Goffioul
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
5 This file is part of Octave.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
8 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
10 (at your option) any later version.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22417
diff changeset
15 GNU General Public License for more details.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
18500
49877d3be064 update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
18 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
diff changeset
19 <https://www.gnu.org/licenses/>.
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
24 # include "config.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #endif
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
27 #include <QString>
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #include <QVariant>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include "Backend.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include "Object.h"
18505
fb96b7f55242 rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents: 18501
diff changeset
32 #include "QtHandlesUtils.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 namespace QtHandles
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
37 Object::Object (const graphics_object& go, QObject *obj)
25044
b6aea95a7bf9 store graphics object in Qt backend to avoid crash (bug #53487, #53500)
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
38 : QObject (), m_go (go), m_handle (go.get_handle ()), m_qobject (nullptr)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
39 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
40 gh_manager::auto_lock lock (false);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
42 if (! lock)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
43 qCritical ("QtHandles::Object::Object: "
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
44 "creating Object (h=%g) without a valid lock!!!",
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
45 m_handle.value ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
47 init (obj);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
48 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
50 void
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
51 Object::init (QObject *obj, bool)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
52 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
53 if (m_qobject)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
54 qCritical ("QtHandles::Object::init: "
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
55 "resetting QObject while in invalid state");
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
57 m_qobject = obj;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
59 if (m_qobject)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
60 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
61 m_qobject->setProperty ("QtHandles::Object",
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
62 qVariantFromValue<void*> (this));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
63 connect (m_qobject, SIGNAL (destroyed (QObject*)),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
64 SLOT (objectDestroyed (QObject*)));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
65 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
66 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
68 Object::~Object (void)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22413
diff changeset
69 { }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
71 graphics_object
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
72 Object::object (void) const
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
73 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
74 gh_manager::auto_lock lock (false);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
76 if (! lock)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
77 qCritical ("QtHandles::Object::object: "
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
78 "accessing graphics object (h=%g) without a valid lock!!!",
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
79 m_handle.value ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80
25044
b6aea95a7bf9 store graphics object in Qt backend to avoid crash (bug #53487, #53500)
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
81 return m_go;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
82 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
84 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
85 Object::slotUpdate (int pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
86 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
87 gh_manager::auto_lock lock;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
89 switch (pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
90 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
91 // Special case for objects being deleted, as it's very likely
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
92 // that the graphics_object already has been destroyed when this
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
93 // is executed (because of the async behavior).
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
94 case base_properties::ID_BEINGDELETED:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
95 beingDeleted ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
96 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19954
diff changeset
97
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
98 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
99 if (object ().valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
100 update (pId);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
101 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
102 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
103 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
105 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
106 Object::slotFinalize (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
107 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
108 gh_manager::auto_lock lock;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
110 finalize ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
111 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
113 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
114 Object::slotRedraw (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
115 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
116 gh_manager::auto_lock lock;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
118 if (object ().valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
119 redraw ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
120 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
122 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
123 Object::slotPrint (const QString& file_cmd, const QString& term)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
124 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
125 gh_manager::auto_lock lock;
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
126
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
127 if (object ().valid_object ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
128 print (file_cmd, term);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
129 }
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
130
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
131 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
132 Object::update (int /* pId */)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22413
diff changeset
133 { }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
135 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
136 Object::finalize (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
137 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
138 if (m_qobject)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
139 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
140 delete m_qobject;
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23449
diff changeset
141 m_qobject = nullptr;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
142 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
143 deleteLater ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
144 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
145
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
146 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
147 Object::redraw (void)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22413
diff changeset
148 { }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
150 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
151 Object::print (const QString& /* file_cmd */, const QString& /* term */)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22413
diff changeset
152 { }
19681
35bca657d74d printing for Qt plot widget (bug #42537)
John W. Eaton <jwe@octave.org>
parents: 18692
diff changeset
153
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
154 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
155 Object::beingDeleted (void)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22413
diff changeset
156 { }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
158 void Object::objectDestroyed (QObject *obj)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
159 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
160 if (obj && obj == m_qobject)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23449
diff changeset
161 m_qobject = nullptr;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
162 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
164 Object*
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
165 Object::parentObject (const graphics_object& go)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
166 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
167 gh_manager::auto_lock lock;
19954
b6061813a693 always obtain gh_manager lock before accessing graphics objects
John W. Eaton <jwe@octave.org>
parents: 19755
diff changeset
168
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
169 Object *parent = Backend::toolkitObject
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
170 (gh_manager::get_object (go.get_parent ()));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
172 return parent;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
173 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
175 Object*
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
176 Object::fromQObject (QObject *obj)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
177 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
178 QVariant v = obj->property ("QtHandles::Object");
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
179
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
180 if (v.isValid ())
23447
db1fdf4384dd maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
181 return reinterpret_cast<Object *> (qvariant_cast<void*> (v));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
182
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23449
diff changeset
183 return nullptr;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
184 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
185
22413
8758addcf265 maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents: 22411
diff changeset
186 }