Changeset 1705
- Timestamp:
- 03/06/07 00:05:42
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libtinymailui-gtk/tny-gtk-header-list-iterator.c
r941 r1705 43 43 44 44 if (lock) 45 g_ mutex_lock (self->model->iterator_lock);45 g_static_rec_mutex_lock (self->model->iterator_lock); 46 46 47 47 self->current = model->first; 48 48 49 49 if (lock) 50 g_ mutex_unlock (self->model->iterator_lock);50 g_static_rec_mutex_unlock (self->model->iterator_lock); 51 51 52 52 return; … … 103 103 /* Move the iterator to the next node */ 104 104 105 g_ mutex_lock (me->model->iterator_lock);105 g_static_rec_mutex_lock (me->model->iterator_lock); 106 106 me->current = g_list_next (me->current); 107 g_ mutex_unlock (me->model->iterator_lock);107 g_static_rec_mutex_unlock (me->model->iterator_lock); 108 108 109 109 return; … … 128 128 /* Move the iterator to the previous node */ 129 129 130 g_ mutex_lock (me->model->iterator_lock);130 g_static_rec_mutex_lock (me->model->iterator_lock); 131 131 me->current = g_list_previous (me->current); 132 g_ mutex_unlock (me->model->iterator_lock);132 g_static_rec_mutex_unlock (me->model->iterator_lock); 133 133 134 134 return; … … 149 149 TnyGtkHeaderListIterator *me = (TnyGtkHeaderListIterator*) self; 150 150 gboolean retval = FALSE; 151 152 g_mutex_lock (me->model->iterator_lock); 153 154 if (G_UNLIKELY (!me || !me->model)) 151 152 g_static_rec_mutex_lock (me->model->iterator_lock); 153 154 if (G_UNLIKELY (!me || !me->model)) { 155 g_static_rec_mutex_unlock (me->model->iterator_lock); 155 156 return TRUE; 157 } 156 158 157 159 retval = (me->current == NULL); 158 g_ mutex_unlock (me->model->iterator_lock);159 160 g_static_rec_mutex_unlock (me->model->iterator_lock); 161 160 162 return retval; 161 163 } … … 182 184 using that one. */ 183 185 184 g_ mutex_lock (me->model->iterator_lock);186 g_static_rec_mutex_lock (me->model->iterator_lock); 185 187 me->current = me->model->first; 186 g_ mutex_unlock (me->model->iterator_lock);188 g_static_rec_mutex_unlock (me->model->iterator_lock); 187 189 188 190 return; … … 210 212 stored a reference. */ 211 213 212 g_ mutex_lock (me->model->iterator_lock);214 g_static_rec_mutex_lock (me->model->iterator_lock); 213 215 me->current = g_list_nth (me->model->first, nth); 214 g_ mutex_unlock (me->model->iterator_lock);216 g_static_rec_mutex_unlock (me->model->iterator_lock); 215 217 216 218 return; … … 235 237 /* Give the data of the current node */ 236 238 237 g_ mutex_lock (me->model->iterator_lock);239 g_static_rec_mutex_lock (me->model->iterator_lock); 238 240 retval = (G_UNLIKELY (me->current)) ? me->current->data : NULL; 239 g_ mutex_unlock (me->model->iterator_lock);241 g_static_rec_mutex_unlock (me->model->iterator_lock); 240 242 241 243 if (retval) 242 g_object_ref (G_OBJECT(retval)); 244 g_object_ref (G_OBJECT(retval)); 245 243 246 return (GObject*)retval; 244 247 } … … 255 258 return NULL; 256 259 257 g_object_ref (G_OBJECT (me->model));260 g_object_ref (G_OBJECT (me->model)); 258 261 259 262 return TNY_LIST (me->model); … … 270 273 klass->get_list_func = tny_gtk_header_list_iterator_get_list; 271 274 klass->is_done = tny_gtk_header_list_iterator_is_done; 272 275 273 276 return; 274 277 } trunk/libtinymailui-gtk/tny-gtk-header-list-model.c
r1704 r1705 186 186 /* Fill an GtkTreeIter (this is not a TnyIterator!) using a path */ 187 187 188 g_ mutex_lock (list_model->iterator_lock);188 g_static_rec_mutex_lock (list_model->iterator_lock); 189 189 190 190 i = gtk_tree_path_get_indices (path)[0]; … … 192 192 if (G_UNLIKELY (i >= list_model->length)) 193 193 { 194 g_ mutex_unlock (list_model->iterator_lock);194 g_static_rec_mutex_unlock (list_model->iterator_lock); 195 195 g_mutex_unlock (list_model->folder_lock); 196 196 return FALSE; … … 209 209 iter->user_data = ptr; 210 210 retval = (iter->user_data != NULL); 211 212 g_mutex_unlock (list_model->iterator_lock); 213 214 211 212 g_static_rec_mutex_unlock (list_model->iterator_lock); 215 213 g_mutex_unlock (list_model->folder_lock); 216 214 … … 231 229 232 230 g_mutex_lock (list_model->folder_lock); 233 g_ mutex_lock (list_model->iterator_lock);231 g_static_rec_mutex_lock (list_model->iterator_lock); 234 232 235 233 while (!_tny_gtk_header_list_iterator_is_done_nl ((TnyGtkHeaderListIterator*)list_model->iterator)) … … 251 249 gtk_tree_path_append_index (tree_path, i); 252 250 253 g_ mutex_unlock (list_model->iterator_lock);251 g_static_rec_mutex_unlock (list_model->iterator_lock); 254 252 255 253 g_mutex_unlock (list_model->folder_lock); … … 341 339 342 340 g_mutex_lock (list_model->folder_lock); 343 g_ mutex_lock (list_model->iterator_lock);341 g_static_rec_mutex_lock (list_model->iterator_lock); 344 342 345 343 /* Remember the ptr we've set above? Get the header instance out of the … … 350 348 if (((GObject*)header)->ref_count <= 0) 351 349 { 352 g_ mutex_unlock (list_model->iterator_lock);350 g_static_rec_mutex_unlock (list_model->iterator_lock); 353 351 g_mutex_unlock (list_model->folder_lock); 354 352 return; … … 424 422 } 425 423 426 g_ mutex_unlock (list_model->iterator_lock);424 g_static_rec_mutex_unlock (list_model->iterator_lock); 427 425 g_mutex_unlock (list_model->folder_lock); 428 426 … … 443 441 444 442 g_mutex_lock (list_model->folder_lock); 445 g_ mutex_lock (list_model->iterator_lock);443 g_static_rec_mutex_lock (list_model->iterator_lock); 446 444 447 445 /* We simply move the iterator and get the value */ … … 453 451 retval = (iter->user_data != NULL); 454 452 455 g_ mutex_unlock (list_model->iterator_lock);453 g_static_rec_mutex_unlock (list_model->iterator_lock); 456 454 g_mutex_unlock (list_model->folder_lock); 457 455 … … 476 474 477 475 g_mutex_lock (list_model->folder_lock); 478 g_ mutex_lock (list_model->iterator_lock);476 g_static_rec_mutex_lock (list_model->iterator_lock); 479 477 480 478 if (G_LIKELY (!iter)) 481 479 retval = list_model->length; 482 480 483 g_ mutex_unlock (list_model->iterator_lock);481 g_static_rec_mutex_unlock (list_model->iterator_lock); 484 482 g_mutex_unlock (list_model->folder_lock); 485 483 … … 498 496 499 497 g_mutex_lock (list_model->folder_lock); 500 g_ mutex_lock (list_model->iterator_lock);498 g_static_rec_mutex_lock (list_model->iterator_lock); 501 499 502 500 restore = ((TnyGtkHeaderListIterator*)list_model->iterator)->current; … … 512 510 iter->user_data = child; 513 511 514 g_ mutex_unlock (list_model->iterator_lock);512 g_static_rec_mutex_unlock (list_model->iterator_lock); 515 513 g_mutex_unlock (list_model->folder_lock); 516 514 … … 520 518 ((TnyGtkHeaderListIterator*)list_model->iterator)->current = restore; 521 519 522 g_ mutex_unlock (list_model->iterator_lock);520 g_static_rec_mutex_unlock (list_model->iterator_lock); 523 521 g_mutex_unlock (list_model->folder_lock); 524 522 … … 552 550 GtkTreeIter iter; 553 551 552 g_static_rec_mutex_lock (me->iterator_lock); 553 554 554 path = gtk_tree_path_new (); 555 555 gtk_tree_path_append_index (path, 0); … … 559 559 /* Prepend something to the list */ 560 560 561 g_mutex_lock (me->iterator_lock);562 561 g_object_ref (G_OBJECT (item)); 563 562 me->first = g_list_prepend (me->first, item); … … 573 572 ((TnyGtkHeaderListIterator*)me->iterator)->current = me->first; 574 573 me->last_nth = 0; 575 g_mutex_unlock (me->iterator_lock);576 574 577 575 /* Letting the observers know about this (the GtkTreeView) */ 578 576 gtk_tree_model_row_inserted (GTK_TREE_MODEL (me), path, &iter); 579 577 gtk_tree_path_free (path); 578 579 g_static_rec_mutex_unlock (me->iterator_lock); 580 580 581 } 581 582 … … 587 588 GtkTreeIter iter; 588 589 590 g_static_rec_mutex_lock (me->iterator_lock); 591 589 592 path = gtk_tree_path_new (); 590 593 iter.stamp = me->stamp; … … 593 596 /* Append something to the list */ 594 597 595 g_mutex_lock (me->iterator_lock);596 598 g_object_ref (G_OBJECT (item)); 597 599 me->first = g_list_append (me->first, item); … … 606 608 ((TnyGtkHeaderListIterator*)me->iterator)->current = me->first; 607 609 me->last_nth = 0; 608 g_mutex_unlock (me->iterator_lock);609 610 610 611 /* Letting the observers know about this (the GtkTreeView) */ … … 613 614 gtk_tree_path_free (path); 614 615 616 g_static_rec_mutex_unlock (me->iterator_lock); 617 615 618 } 616 619 … … 621 624 guint retval = 0; 622 625 623 g_ mutex_lock (me->iterator_lock);626 g_static_rec_mutex_lock (me->iterator_lock); 624 627 retval = me->first?g_list_length (me->first):0; 625 g_ mutex_unlock (me->iterator_lock);628 g_static_rec_mutex_unlock (me->iterator_lock); 626 629 627 630 return retval; … … 638 641 g_return_if_fail (G_IS_OBJECT (me)); 639 642 643 g_static_rec_mutex_lock (me->iterator_lock); 644 640 645 iter.stamp = me->stamp; 641 646 iter.user_data = item; … … 644 649 /* Remove something from the list */ 645 650 646 g_mutex_lock (me->iterator_lock);647 651 me->first = g_list_remove (me->first, (gconstpointer)item); 648 652 me->length--; … … 651 655 g_list_free (me->index); 652 656 me->index = NULL; 653 g_object_unref (G_OBJECT (item));654 657 655 658 /* Reset the internal iterator */ 656 659 ((TnyGtkHeaderListIterator*)me->iterator)->current = me->first; 657 660 me->last_nth = 0; 658 g_mutex_unlock (me->iterator_lock);659 661 660 662 /* Letting the observers know about this (the GtkTreeView) */ 661 663 gtk_tree_model_row_deleted (GTK_TREE_MODEL (me), path); 662 664 gtk_tree_path_free (path); 665 666 g_object_unref (G_OBJECT (item)); 667 668 g_static_rec_mutex_unlock (me->iterator_lock); 663 669 664 670 } … … 688 694 only a copy of the list-nodes of course. */ 689 695 690 g_mutex_lock (me->iterator_lock); 696 g_static_rec_mutex_lock (me->iterator_lock); 697 691 698 GList *list_copy = g_list_copy (me->first); 692 699 g_list_foreach (list_copy, (GFunc)g_object_ref, NULL); 693 700 copy->first = list_copy; 694 701 copy->usable_index = FALSE; 695 g_mutex_unlock (me->iterator_lock); 702 703 g_static_rec_mutex_unlock (me->iterator_lock); 696 704 697 705 return TNY_LIST (copy); … … 705 713 /* Foreach item in the list (without using a slower iterator) */ 706 714 707 g_mutex_lock (me->iterator_lock); 715 g_static_rec_mutex_lock (me->iterator_lock); 716 708 717 g_list_foreach (me->first, func, user_data); 709 g_mutex_unlock (me->iterator_lock); 718 719 g_static_rec_mutex_unlock (me->iterator_lock); 710 720 711 721 return; … … 857 867 858 868 g_mutex_lock (self->folder_lock); 859 g_ mutex_lock (self->iterator_lock);869 g_static_rec_mutex_lock (self->iterator_lock); 860 870 861 871 if (self->folder) … … 899 909 900 910 901 902 g_mutex_unlock (self->iterator_lock); 911 g_static_rec_mutex_unlock (self->iterator_lock); 903 912 g_mutex_unlock (self->folder_lock); 904 913 905 914 g_mutex_free (self->folder_lock); 906 915 self->folder_lock = NULL; 907 g_mutex_free (self->iterator_lock); 916 917 g_static_rec_mutex_free (self->iterator_lock); 908 918 self->iterator_lock = NULL; 909 919 … … 932 942 self->folder = NULL; 933 943 self->folder_lock = g_mutex_new (); 934 self->iterator_lock = g_mutex_new (); 944 self->iterator_lock = g_new0 (GStaticRecMutex, 1); 945 g_static_rec_mutex_init (self->iterator_lock); 935 946 self->first = NULL; 936 947 self->length = 0; … … 964 975 965 976 g_mutex_lock (self->folder_lock); 966 g_mutex_lock (self->iterator_lock); 967 977 g_static_rec_mutex_lock (self->iterator_lock); 968 978 969 979 /* Unreference the previous headers */ … … 989 999 self->last_nth = 0; 990 1000 991 g_ mutex_unlock (self->iterator_lock);1001 g_static_rec_mutex_unlock (self->iterator_lock); 992 1002 g_mutex_unlock (self->folder_lock); 993 1003 … … 997 1007 998 1008 g_mutex_lock (self->folder_lock); 999 g_ mutex_lock (self->iterator_lock);1009 g_static_rec_mutex_lock (self->iterator_lock); 1000 1010 1001 1011 /* Reset the internal iterator */ … … 1019 1029 self->folder = folder; 1020 1030 1021 g_mutex_unlock (self->iterator_lock);1022 g_mutex_unlock (self->folder_lock);1023 1024 1031 /* Notify the observers (the GtkTreeView) */ 1025 1032 gtk_tree_path_append_index (path, 0); 1026 1033 gtk_tree_model_row_inserted (GTK_TREE_MODEL (self), path, &iter); 1027 1034 gtk_tree_path_free (path); 1035 1036 g_static_rec_mutex_unlock (self->iterator_lock); 1037 g_mutex_unlock (self->folder_lock); 1028 1038 1029 1039 return; trunk/libtinymailui-gtk/tny-gtk-header-list-model.h
r1419 r1705 64 64 GObject parent; 65 65 66 GMutex *folder_lock, *iterator_lock; 66 GMutex *folder_lock; 67 GStaticRecMutex *iterator_lock; 67 68 TnyFolder *folder; 68 69 gint length;
