annotate gui/src/backend/OctaveLink.cpp @ 13677:f27573828e92

Properly implemented shutdown of callback thread.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Sun, 25 Sep 2011 18:29:24 +0200
parents c0e66d6e3dc8
children ee7f4294d162
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13674
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
1 /* OctaveGUI - A graphical user interface for Octave
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
2 * Copyright (C) 2011 John P. Swensen, Jacob Dawid (jacob.dawid@googlemail.com)
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
3 *
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
4 * This program is free software: you can redistribute it and/or modify
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
5 * it under the terms of the GNU Affero General Public License as
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
6 * published by the Free Software Foundation, either version 3 of the
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
7 * License, or (at your option) any later version.
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
8 *
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
9 * This program is distributed in the hope that it will be useful,
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
12 * GNU Affero General Public License for more details.
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
13 *
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
14 * You should have received a copy of the GNU Affero General Public License
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13601
diff changeset
16 */
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
17
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
18 #include "OctaveLink.h"
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
19
13520
17bb8974577b Repaired history list.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13519
diff changeset
20 OctaveLink OctaveLink::m_singleton;
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
21
13519
35ecb6063c7b Made the view connect with the history model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
22 OctaveLink::OctaveLink ():QObject ()
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
23 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
24 m_symbolTableSemaphore = new QSemaphore (1);
13518
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
25 m_historyModel = new QStringListModel (this);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
26 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
27
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
28 OctaveLink::~OctaveLink ()
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
29 {
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
30 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
31
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
32 QString
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
33 OctaveLink::octaveValueAsQString (OctaveValue octaveValue)
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
34 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
35 // Convert single qouted string.
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
36 if (octaveValue.is_sq_string ())
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
37 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
38 return QString ("\'%1\'").arg (octaveValue.string_value ().c_str ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
39
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
40 // Convert double qouted string.
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
41 }
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
42 else if (octaveValue.is_dq_string ())
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
43 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
44 return QString ("\"%1\"").arg (octaveValue.string_value ().c_str ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
45
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
46 // Convert real scalar.
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
47 }
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
48 else if (octaveValue.is_real_scalar ())
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
49 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
50 return QString ("%1").arg (octaveValue.scalar_value ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
51
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
52 // Convert complex scalar.
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
53 }
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
54 else if (octaveValue.is_complex_scalar ())
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
55 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
56 return QString ("%1 + %2i").arg (octaveValue.scalar_value ()).
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
57 arg (octaveValue.complex_value ().imag ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
58
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
59 // Convert range.
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
60 }
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
61 else if (octaveValue.is_range ())
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
62 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
63 return QString ("%1 : %2 : %3").arg (octaveValue.range_value ().
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
64 base ()).arg (octaveValue.
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
65 range_value ().
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
66 inc ()).
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
67 arg (octaveValue.range_value ().limit ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
68
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
69 // Convert real matrix.
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
70 }
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
71 else if (octaveValue.is_real_matrix ())
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
72 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
73 // TODO: Convert real matrix into a string.
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
74 return QString ("{matrix}");
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
75
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
76 // Convert complex matrix.
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
77 }
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
78 else if (octaveValue.is_complex_matrix ())
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
79 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
80 // TODO: Convert complex matrix into a string.
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
81 return QString ("{complex matrix}");
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
82
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
83 // If everything else does not fit, we could not recognize the type.
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
84 }
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
85 else
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
86 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
87 return QString ("<Type not recognized>");
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
88 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
89 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
90
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
91 void
13541
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
92 OctaveLink::launchOctave ()
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
93 {
13677
f27573828e92 Properly implemented shutdown of callback thread.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13674
diff changeset
94 // Create both threads.
13541
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
95 m_octaveMainThread = new OctaveMainThread (this);
13677
f27573828e92 Properly implemented shutdown of callback thread.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13674
diff changeset
96 m_octaveCallbackThread = new OctaveCallbackThread (this);
13541
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
97
13677
f27573828e92 Properly implemented shutdown of callback thread.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13674
diff changeset
98 // Launch the second as soon as the first ist ready.
13541
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
99 connect (m_octaveMainThread, SIGNAL(ready()), m_octaveCallbackThread, SLOT(start()));
13677
f27573828e92 Properly implemented shutdown of callback thread.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13674
diff changeset
100
f27573828e92 Properly implemented shutdown of callback thread.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13674
diff changeset
101 // Start the first one.
f27573828e92 Properly implemented shutdown of callback thread.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13674
diff changeset
102 m_octaveMainThread->start ();
13541
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
103 }
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
104
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
105 void
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
106 OctaveLink::terminateOctave ()
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
107 {
13677
f27573828e92 Properly implemented shutdown of callback thread.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13674
diff changeset
108 m_octaveCallbackThread->halt();
13541
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
109 m_octaveCallbackThread->wait ();
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
110
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
111 m_octaveMainThread->terminate ();
13601
26956bb3c927 Terminating octave main thread instantly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13543
diff changeset
112 //m_octaveMainThread->wait();
13541
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
113 }
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
114
b48ac9ad8de0 Highly improved separation of model and view classes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13528
diff changeset
115 void
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
116 OctaveLink::fetchSymbolTable ()
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
117 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
118 m_symbolTableSemaphore->acquire ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
119 m_symbolTableBuffer.clear ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
120 std::list < SymbolRecord > allVariables = symbol_table::all_variables ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
121 std::list < SymbolRecord >::iterator iterator;
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
122 for (iterator = allVariables.begin (); iterator != allVariables.end ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
123 iterator++)
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
124 m_symbolTableBuffer.append (iterator->dup ());
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
125 m_symbolTableSemaphore->release ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
126 emit symbolTableChanged ();
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
127 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
128
13521
16b33b7ef1b3 Raised update interval to 500ms.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13520
diff changeset
129 QList < SymbolRecord > OctaveLink::copyCurrentSymbolTable ()
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
130 {
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
131 QList < SymbolRecord > m_symbolTableCopy;
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
132
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
133 // Generate a deep copy of the current symbol table.
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
134 m_symbolTableSemaphore->acquire ();
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
135 foreach (SymbolRecord symbolRecord, m_symbolTableBuffer)
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
136 m_symbolTableCopy.append (symbolRecord.dup ());
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
137 m_symbolTableSemaphore->release ();
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
138
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
139 return m_symbolTableCopy;
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
140 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
141
13518
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
142
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
143 void
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
144 OctaveLink::updateHistoryModel ()
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
145 {
13519
35ecb6063c7b Made the view connect with the history model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
146 // Determine the client's (our) history length and the one of the server.
13520
17bb8974577b Repaired history list.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13519
diff changeset
147 int clientHistoryLength = m_historyModel->rowCount ();
13519
35ecb6063c7b Made the view connect with the history model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
148 int serverHistoryLength = command_history::length ();
35ecb6063c7b Made the view connect with the history model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
149
35ecb6063c7b Made the view connect with the history model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
150 // If were behind the server, iterate through all new entries and add them to our history.
35ecb6063c7b Made the view connect with the history model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
151 if (clientHistoryLength < serverHistoryLength)
13518
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
152 {
13519
35ecb6063c7b Made the view connect with the history model.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13518
diff changeset
153 for (int i = clientHistoryLength; i < serverHistoryLength; i++)
13518
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
154 {
13520
17bb8974577b Repaired history list.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13519
diff changeset
155 m_historyModel->insertRow (0);
17bb8974577b Repaired history list.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13519
diff changeset
156 m_historyModel->setData (m_historyModel->index (0), QString (command_history::get_entry (i).c_str ()));
13518
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
157 }
13528
8b116446a904 Fixed race condition.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13527
diff changeset
158 }
13518
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
159 }
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
160
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
161 QStringListModel *
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
162 OctaveLink::historyModel ()
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
163 {
bace956a3724 Put history model part into OctaveLink.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13517
diff changeset
164 return m_historyModel;
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
165 }