Skip to content

Commit c59b84b

Browse files
Therzokalanmcgovern
authored andcommitted
[Gtk] Add missing main thread assertions to tree/list store custom code
1 parent cfd64f9 commit c59b84b

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

gtk/ListStore.custom

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
static extern bool gtk_tree_model_iter_children (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent);
3232
public bool IterChildren (out Gtk.TreeIter iter)
3333
{
34+
Gtk.Application.AssertMainThread();
3435
bool raw_ret = gtk_tree_model_iter_children (Handle, out iter, IntPtr.Zero);
3536
bool ret = raw_ret;
3637
return ret;
@@ -41,6 +42,7 @@
4142

4243
public int IterNChildren ()
4344
{
45+
Gtk.Application.AssertMainThread();
4446
int raw_ret = gtk_tree_model_iter_n_children_ptr (Handle, IntPtr.Zero);
4547
int ret = raw_ret;
4648
return ret;
@@ -50,6 +52,7 @@
5052
static extern bool gtk_tree_model_iter_nth_child (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent, int n);
5153
public bool IterNthChild (out Gtk.TreeIter iter, int n)
5254
{
55+
Gtk.Application.AssertMainThread();
5356
bool raw_ret = gtk_tree_model_iter_nth_child (Handle, out iter, IntPtr.Zero, n);
5457
bool ret = raw_ret;
5558
return ret;
@@ -127,6 +130,7 @@
127130

128131
public TreeIter InsertWithValues (int position, params object[] values)
129132
{
133+
Gtk.Application.AssertMainThread();
130134
unsafe {
131135
int* columns = stackalloc int[values.Length];
132136
GLib.Value* vals = stackalloc GLib.Value[values.Length];
@@ -155,6 +159,7 @@
155159

156160
public void SetValues (TreeIter iter, params object[] values)
157161
{
162+
Gtk.Application.AssertMainThread();
158163
unsafe {
159164
int* columns = stackalloc int[values.Length];
160165
GLib.Value* vals = stackalloc GLib.Value[values.Length];
@@ -177,12 +182,14 @@
177182

178183
public ListStore (params GLib.GType[] types) : base (IntPtr.Zero)
179184
{
185+
Gtk.Application.AssertMainThread();
180186
CreateNativeObject (Array.Empty<IntPtr> (), Array.Empty<GLib.Value> (), 0);
181187
ColumnTypes = types;
182188
}
183189

184190
public ListStore (params Type[] types) : base (IntPtr.Zero)
185191
{
192+
Gtk.Application.AssertMainThread();
186193
GLib.GType[] gtypes = new GLib.GType[types.Length];
187194
int i = 0;
188195
foreach (Type type in types) {

gtk/TreeStore.custom

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
[Obsolete ("Replaced by AppendNode")]
3333
public TreeIter Append (TreeIter parent)
3434
{
35+
Gtk.Application.AssertMainThread();
3536
TreeIter iter;
3637
gtk_tree_store_append (Handle, out iter, ref parent);
3738
return iter;
@@ -40,18 +41,21 @@
4041
[Obsolete ("Replaced by AppendNode")]
4142
public void Append (out TreeIter iter)
4243
{
44+
Gtk.Application.AssertMainThread();
4345
gtk_tree_store_append (Handle, out iter, IntPtr.Zero);
4446
}
4547

4648
public TreeIter AppendNode ()
4749
{
50+
Gtk.Application.AssertMainThread();
4851
TreeIter iter;
4952
gtk_tree_store_append (Handle, out iter, IntPtr.Zero);
5053
return iter;
5154
}
5255

5356
public TreeIter AppendNode (TreeIter parent)
5457
{
58+
Gtk.Application.AssertMainThread();
5559
TreeIter iter;
5660
gtk_tree_store_append (Handle, out iter, ref parent);
5761
return iter;
@@ -66,6 +70,7 @@
6670
[Obsolete ("Replaced by InsertNode")]
6771
public TreeIter Insert (TreeIter parent, int position)
6872
{
73+
Gtk.Application.AssertMainThread();
6974
TreeIter iter;
7075
gtk_tree_store_insert (Handle, out iter, ref parent, position);
7176
return iter;
@@ -74,18 +79,21 @@
7479
[Obsolete ("Replaced by InsertNode")]
7580
public void Insert (out TreeIter iter, int position)
7681
{
82+
Gtk.Application.AssertMainThread();
7783
gtk_tree_store_insert (Handle, out iter, IntPtr.Zero, position);
7884
}
7985

8086
public TreeIter InsertNode (TreeIter parent, int position)
8187
{
88+
Gtk.Application.AssertMainThread();
8289
TreeIter iter;
8390
gtk_tree_store_insert (Handle, out iter, ref parent, position);
8491
return iter;
8592
}
8693

8794
public TreeIter InsertNode (int position)
8895
{
96+
Gtk.Application.AssertMainThread();
8997
TreeIter iter;
9098
gtk_tree_store_insert (Handle, out iter, IntPtr.Zero, position);
9199
return iter;
@@ -100,6 +108,7 @@
100108
[Obsolete ("Replaced by PrependNode")]
101109
public TreeIter Prepend(TreeIter parent)
102110
{
111+
Gtk.Application.AssertMainThread();
103112
TreeIter iter;
104113
gtk_tree_store_prepend (Handle, out iter, ref parent);
105114
return iter;
@@ -108,18 +117,21 @@
108117
[Obsolete ("Replaced by PrependNode")]
109118
public void Prepend (out TreeIter iter)
110119
{
120+
Gtk.Application.AssertMainThread();
111121
gtk_tree_store_append (Handle, out iter, IntPtr.Zero);
112122
}
113123

114124
public TreeIter PrependNode (TreeIter parent)
115125
{
126+
Gtk.Application.AssertMainThread();
116127
TreeIter iter;
117128
gtk_tree_store_prepend (Handle, out iter, ref parent);
118129
return iter;
119130
}
120131

121132
public TreeIter PrependNode ()
122133
{
134+
Gtk.Application.AssertMainThread();
123135
TreeIter iter;
124136
gtk_tree_store_prepend (Handle, out iter, IntPtr.Zero);
125137
return iter;
@@ -134,6 +146,7 @@
134146
[Obsolete ("Replaced by InsertNodeBefore")]
135147
public TreeIter InsertBefore (TreeIter parent, TreeIter sibling)
136148
{
149+
Gtk.Application.AssertMainThread();
137150
TreeIter iter;
138151
gtk_tree_store_insert_before (Handle, out iter, ref parent, ref sibling);
139152
return iter;
@@ -142,18 +155,21 @@
142155
[Obsolete ("Replaced by InsertNodeBefore")]
143156
public void InsertBefore (out TreeIter iter, TreeIter sibling)
144157
{
158+
Gtk.Application.AssertMainThread();
145159
gtk_tree_store_insert_before (Handle, out iter, IntPtr.Zero, ref sibling);
146160
}
147161

148162
public TreeIter InsertNodeBefore (TreeIter sibling)
149163
{
164+
Gtk.Application.AssertMainThread();
150165
TreeIter iter;
151166
gtk_tree_store_insert_before (Handle, out iter, IntPtr.Zero, ref sibling);
152167
return iter;
153168
}
154169

155170
public TreeIter InsertNodeBefore (TreeIter parent, TreeIter sibling)
156171
{
172+
Gtk.Application.AssertMainThread();
157173
TreeIter iter;
158174
gtk_tree_store_insert_before (Handle, out iter, ref parent, ref sibling);
159175
return iter;
@@ -168,6 +184,7 @@
168184
[Obsolete ("Replaced by InsertNodeAfter")]
169185
public TreeIter InsertAfter (TreeIter parent, TreeIter sibling)
170186
{
187+
Gtk.Application.AssertMainThread();
171188
TreeIter iter;
172189
gtk_tree_store_insert_after (Handle, out iter, ref parent, ref sibling);
173190
return iter;
@@ -176,18 +193,21 @@
176193
[Obsolete ("Replaced by InsertNodeAfter")]
177194
public void InsertAfter (out TreeIter iter, TreeIter sibling)
178195
{
196+
Gtk.Application.AssertMainThread();
179197
gtk_tree_store_insert_after (Handle, out iter, IntPtr.Zero, ref sibling);
180198
}
181199

182200
public TreeIter InsertNodeAfter (TreeIter sibling)
183201
{
202+
Gtk.Application.AssertMainThread();
184203
TreeIter iter;
185204
gtk_tree_store_insert_after (Handle, out iter, IntPtr.Zero, ref sibling);
186205
return iter;
187206
}
188207

189208
public TreeIter InsertNodeAfter (TreeIter parent, TreeIter sibling)
190209
{
210+
Gtk.Application.AssertMainThread();
191211
TreeIter iter;
192212
gtk_tree_store_insert_after (Handle, out iter, ref parent, ref sibling);
193213
return iter;
@@ -196,6 +216,7 @@
196216
[DllImport("libgtk-win32-2.0-0.dll", CallingConvention=CallingConvention.Cdecl)]
197217
static extern bool gtk_tree_model_iter_children (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent);
198218
public bool IterChildren (out Gtk.TreeIter iter) {
219+
Gtk.Application.AssertMainThread();
199220
bool raw_ret = gtk_tree_model_iter_children (Handle, out iter, IntPtr.Zero);
200221
bool ret = raw_ret;
201222
return ret;
@@ -206,6 +227,7 @@
206227

207228
public int IterNChildren ()
208229
{
230+
Gtk.Application.AssertMainThread();
209231
int raw_ret = gtk_tree_model_iter_n_children_ptr (Handle, IntPtr.Zero);
210232
int ret = raw_ret;
211233
return ret;
@@ -214,6 +236,7 @@
214236
[DllImport("libgtk-win32-2.0-0.dll", CallingConvention=CallingConvention.Cdecl)]
215237
static extern bool gtk_tree_model_iter_nth_child (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent, int n);
216238
public bool IterNthChild (out Gtk.TreeIter iter, int n) {
239+
Gtk.Application.AssertMainThread();
217240
bool raw_ret = gtk_tree_model_iter_nth_child (Handle, out iter, IntPtr.Zero, n);
218241
bool ret = raw_ret;
219242
return ret;
@@ -310,6 +333,7 @@
310333

311334
private TreeIter InsertWithValues (bool hasParent, TreeIter parent, int position, params object[] values)
312335
{
336+
Gtk.Application.AssertMainThread();
313337
unsafe {
314338
int* columns = stackalloc int[values.Length];
315339
GLib.Value* vals = stackalloc GLib.Value[values.Length];
@@ -341,6 +365,7 @@
341365

342366
public void SetValues (TreeIter iter, params object[] values)
343367
{
368+
Gtk.Application.AssertMainThread();
344369
unsafe {
345370
int *columns = stackalloc int[values.Length];
346371
GLib.Value *vals = stackalloc GLib.Value[values.Length];
@@ -363,12 +388,14 @@
363388

364389
public TreeStore (params GLib.GType[] types) : base (IntPtr.Zero)
365390
{
391+
Gtk.Application.AssertMainThread();
366392
CreateNativeObject (Array.Empty<IntPtr> (), Array.Empty<GLib.Value> (), 0);
367393
ColumnTypes = types;
368394
}
369395

370396
public TreeStore (params Type[] types) : base (IntPtr.Zero)
371397
{
398+
Gtk.Application.AssertMainThread();
372399
GLib.GType[] gtypes = new GLib.GType[types.Length];
373400
int i = 0;
374401
foreach (Type type in types) {

0 commit comments

Comments
 (0)