VirtualBox

Changeset 56669 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 28, 2015 11:01:01 PM (9 years ago)
Author:
vboxsync
Message:

glue/vboxapi.py: Hacked the MSCOM version of setArray() so that we can modify the BSTR safearray IGuestSession::environmentChanges on windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/vboxapi.py

    r55589 r56669  
    565565
    566566    def setArray(self, oInterface, sAttrib, aoArray):
    567         return oInterface.__setattr__(sAttrib, aoArray)
     567        #
     568        # HACK ALERT!
     569        #
     570        # With pywin32 build 218, we're seeing type mismatch errors here for
     571        # IGuestSession::environmentChanges (safearray of BSTRs). The Dispatch
     572        # object (_oleobj_) seems to get some type conversion wrong and COM
     573        # gets upset.  So, we redo some of the dispatcher work here, picking
     574        # the missing type information from the getter.
     575        #
     576        oOleObj     = getattr(oInterface, '_oleobj_');
     577        aPropMapGet = getattr(oInterface, '_prop_map_get_');
     578        aPropMapPut = getattr(oInterface, '_prop_map_put_');
     579        sComAttrib  = sAttrib if sAttrib in aPropMapGet else ComifyName(sAttrib);
     580        try:
     581            aArgs, aDefaultArgs = aPropMapPut[sComAttrib];
     582            aGetArgs            = aPropMapGet[sComAttrib];
     583        except KeyError: # fallback.
     584            return oInterface.__setattr__(sAttrib, aoArray);
     585
     586        import pythoncom;
     587        oOleObj.InvokeTypes(aArgs[0],                   # dispid
     588                            aArgs[1],                   # LCID
     589                            aArgs[2],                   # DISPATCH_PROPERTYPUT
     590                            (pythoncom.VT_HRESULT, 0),  # retType - or void?
     591                            (aGetArgs[2],),             # argTypes - trick: we get the type from the getter.
     592                            aoArray,);                  # The array
    568593
    569594    def initPerThread(self):
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette