[haiku-commits] haiku: hrev44303 - src/kits/support

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 11 Jul 2012 00:42:52 +0200 (CEST)

hrev44303 adds 1 changeset to branch 'master'
old head: 0962132cc60f7f93c696c16776f50ee66e4c65f7
new head: 36c85ca8df5a43d6e716579099c25018e41bedf8

----------------------------------------------------------------------------

36c85ca: Fix add-on image unloading for shelf replicants (ticket #8708).
  
  - The version of instantiate_object() that returns the image id from which
    the object was reinstantiated was not correctly returning it in all
    circumstances, only if it had to find/load the add-on itself. This caused
    problems for BShelf since the latter relies on that image id in order to
    determine what image to unload when replicants are removed. To remedy this,
    introduce an additional version of find_instantiation_func() that returns
    the image id in which the instantiation function was found, and make use
    of it in instantiate_object() in order to also be able to return the image
    id in that case.

                                      [ Rene Gollent <anevilyak@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev44303
Commit:      36c85ca8df5a43d6e716579099c25018e41bedf8
URL:         http://cgit.haiku-os.org/haiku/commit/?id=36c85ca
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Tue Jul 10 22:35:28 2012 UTC

Ticket:      https://dev.haiku-os.org/ticket/8708

----------------------------------------------------------------------------

1 file changed, 66 insertions(+), 45 deletions(-)
src/kits/support/Archivable.cpp |  111 +++++++++++++++++++++--------------

----------------------------------------------------------------------------

diff --git a/src/kits/support/Archivable.cpp b/src/kits/support/Archivable.cpp
index 2bcb515..3761040 100644
--- a/src/kits/support/Archivable.cpp
+++ b/src/kits/support/Archivable.cpp
@@ -1,8 +1,9 @@
 /*
- * Copyright (c) 2001-2010, Haiku, Inc.
+ * Copyright (c) 2001-2012, Haiku, Inc.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
+ *             Rene Gollent (rene@xxxxxxxxxxx)
  *             Erik Jaesler (erik@xxxxxxxxxxxxxx)
  *             Alex Wilson (yourpalal2@xxxxxxxxx)
  */
@@ -236,6 +237,67 @@ check_signature(const char* signature, image_info& info)
 }
 
 
+namespace BPrivate
+{
+
+
+instantiation_func
+find_instantiation_func(const char* className, const char* signature,
+       image_id* id)
+{
+       if (className == NULL) {
+               errno = B_BAD_VALUE;
+               return NULL;
+       }
+
+       thread_info threadInfo;
+       status_t err = get_thread_info(find_thread(NULL), &threadInfo);
+       if (err != B_OK) {
+               errno = err;
+               return NULL;
+       }
+
+       instantiation_func instantiationFunc = NULL;
+       image_info imageInfo;
+
+       BString name = className;
+       for (int32 pass = 0; pass < 2; pass++) {
+               BString funcName;
+               build_function_name(name, funcName);
+
+               // for each image_id in team_id
+               int32 cookie = 0;
+               while (instantiationFunc == NULL
+                       && get_next_image_info(threadInfo.team, &cookie, 
&imageInfo)
+                               == B_OK) {
+                       instantiationFunc = find_function_in_image(funcName, 
imageInfo.id,
+                               err);
+               }
+               if (instantiationFunc != NULL) {
+                       // if requested, save the image id in
+                       // which the function was found
+                       if (id != NULL)
+                               *id = imageInfo.id;
+                       break;
+               }
+
+               // Check if we have a private class, and add the BPrivate 
namespace
+               // (for backwards compatibility)
+               if (!add_private_namespace(name))
+                       break;
+       }
+
+       if (instantiationFunc != NULL
+               && check_signature(signature, imageInfo) != B_OK)
+               return NULL;
+
+       return instantiationFunc;
+}
+
+
+}
+
+
 //     #pragma mark -
 
 
@@ -597,8 +659,8 @@ instantiate_object(BMessage* archive, image_id* _id)
        const char* signature = NULL;
        bool hasSignature = archive->FindString(B_ADD_ON_FIELD, &signature) == 
B_OK;
 
-       instantiation_func instantiationFunc = 
find_instantiation_func(className,
-               signature);
+       instantiation_func instantiationFunc = 
BPrivate::find_instantiation_func(
+               className, signature, _id);
 
        // if find_instantiation_func() can't locate Class::Instantiate()
        // and a signature was specified
@@ -714,48 +776,7 @@ validate_instantiation(BMessage* from, const char* 
className)
 instantiation_func
 find_instantiation_func(const char* className, const char* signature)
 {
-       if (className == NULL) {
-               errno = B_BAD_VALUE;
-               return NULL;
-       }
-
-       thread_info threadInfo;
-       status_t err = get_thread_info(find_thread(NULL), &threadInfo);
-       if (err != B_OK) {
-               errno = err;
-               return NULL;
-       }
-
-       instantiation_func instantiationFunc = NULL;
-       image_info imageInfo;
-
-       BString name = className;
-       for (int32 pass = 0; pass < 2; pass++) {
-               BString funcName;
-               build_function_name(name, funcName);
-
-               // for each image_id in team_id
-               int32 cookie = 0;
-               while (instantiationFunc == NULL
-                       && get_next_image_info(threadInfo.team, &cookie, 
&imageInfo)
-                               == B_OK) {
-                       instantiationFunc = find_function_in_image(funcName, 
imageInfo.id,
-                               err);
-               }
-               if (instantiationFunc != NULL)
-                       break;
-
-               // Check if we have a private class, and add the BPrivate 
namespace
-               // (for backwards compatibility)
-               if (!add_private_namespace(name))
-                       break;
-       }
-
-       if (instantiationFunc != NULL
-               && check_signature(signature, imageInfo) != B_OK)
-               return NULL;
-
-       return instantiationFunc;
+       return BPrivate::find_instantiation_func(className, signature, NULL);
 }
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev44303 - src/kits/support - anevilyak