Author: gert
Date: 2007-05-19 15:15:15 -0400 (Sat, 19 May 2007)
New Revision: 77695

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/object.c
   trunk/mono/mono/metadata/threads.c
Log:
* threads.c: In "start_wrapper", set apartment_state to MTA if
apartment_state is Unknown and we're running on 2.0 profile or
higher.
* object.c: In "mono_runtime_exec_main", if STAThread is not applied
to main method, then set apartment_state to Unknown on 1.0 profile,
and MTA on 2.0 profile.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2007-05-19 19:11:22 UTC (rev 77694)
+++ trunk/mono/mono/metadata/ChangeLog  2007-05-19 19:15:15 UTC (rev 77695)
@@ -1,3 +1,12 @@
+2007-05-19  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * threads.c: In "start_wrapper", set apartment_state to MTA if
+       apartment_state is Unknown and we're running on 2.0 profile or
+       higher.
+       * object.c: In "mono_runtime_exec_main", if STAThread is not applied
+       to main method, then set apartment_state to Unknown on 1.0 profile,
+       and MTA on 2.0 profile.
+
 2007-05-16  Jb Evain  <[EMAIL PROTECTED]>
 
        * class-internals.h (MonoDefaults): Add an attribute_class and

Modified: trunk/mono/mono/metadata/object.c
===================================================================
--- trunk/mono/mono/metadata/object.c   2007-05-19 19:11:22 UTC (rev 77694)
+++ trunk/mono/mono/metadata/object.c   2007-05-19 19:15:15 UTC (rev 77695)
@@ -2393,6 +2393,8 @@
        gpointer pa [1];
        int rval;
        MonoCustomAttrInfo* cinfo;
+       gboolean has_stathread_attribute;
+       MonoThread* thread = mono_thread_current ();
 
        g_assert (args);
 
@@ -2415,15 +2417,20 @@
        cinfo = mono_custom_attrs_from_method (method);
        if (cinfo) {
                static MonoClass *stathread_attribute = NULL;
-               MonoThread* thread = mono_thread_current ();
-               gboolean has_stathread_attribute;
                if (!stathread_attribute)
                        stathread_attribute = mono_class_from_name 
(mono_defaults.corlib, "System", "STAThreadAttribute");
                has_stathread_attribute = mono_custom_attrs_has_attr (cinfo, 
stathread_attribute);
                if (!cinfo->cached)
                        mono_custom_attrs_free (cinfo);
-
-               thread->apartment_state = has_stathread_attribute ? 
ThreadApartmentState_STA : ThreadApartmentState_MTA;
+       } else {
+               has_stathread_attribute = FALSE;
+       }
+       if (has_stathread_attribute) {
+               thread->apartment_state = ThreadApartmentState_STA;
+       } else if (mono_get_runtime_info ()->framework_version [0] == '1') {
+               thread->apartment_state = ThreadApartmentState_Unknown;
+       } else {
+               thread->apartment_state = ThreadApartmentState_MTA;
        }
        mono_thread_init_apartment_state ();
 

Modified: trunk/mono/mono/metadata/threads.c
===================================================================
--- trunk/mono/mono/metadata/threads.c  2007-05-19 19:11:22 UTC (rev 77694)
+++ trunk/mono/mono/metadata/threads.c  2007-05-19 19:15:15 UTC (rev 77695)
@@ -289,6 +289,13 @@
 
        mono_profiler_thread_start (tid);
 
+       /* On 2.0 profile (and higher), set explicitly since state might have 
been
+          Unknown */
+       if (mono_get_runtime_info ()->framework_version [0] != '1') {
+               if (thread->apartment_state == ThreadApartmentState_Unknown)
+                       thread->apartment_state = ThreadApartmentState_MTA;
+       }
+
        mono_thread_init_apartment_state ();
 
        if(thread->start_notify!=NULL) {
@@ -2939,10 +2946,6 @@
        MonoThread* thread;
        thread = mono_thread_current ();
 
-       /* Set explicitly since state might have been Unknown */
-       if (thread->apartment_state != ThreadApartmentState_STA)
-               thread->apartment_state = ThreadApartmentState_MTA;
-
 #ifdef PLATFORM_WIN32
        /* Positive return value indicates success, either
         * S_OK if this is first CoInitialize call, or

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to