VirtualBox

Changeset 85286 in vbox for trunk/src/VBox/Main/src-all


Ignore:
Timestamp:
Jul 12, 2020 11:08:50 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139263
Message:

Main: Refactored the generated event code implementation as Clang 11 claims va_start() on an VBoxEventType_T may trigger undefined behaviour due to type promotion (or something to that effect), but also because that variadict approach was horrible from the start. Refactored code as a dedicated factory method for each event, removing a dependency on VBoxEventDesc in veto cases. The fireXxxxEvent functions now return a HRESULT are no longer DECLINLINE (no need to compile all of them all the time). Reusable events got a ReinitXxxxxEvent function for helping with that. The VirtualBox::CallbackEvent stuff was a horrid misdesign from the start, it could've been done with a single class carrying a VBoxEventDesc member that the i_onXxxx methods would init() with all the event specific parameters and stuff. Refactored code passes a IEvent around, as that's even easier. I've left much of the old code in place for reference, but will remove once I've had a chance to test it a bit more (still struggling building VBox on the mac). bugref:9790

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-all/EventImpl.cpp

    r85239 r85286  
    5858#include "AutoCaller.h"
    5959#include "LoggingNew.h"
     60#include "VBoxEvents.h"
    6061
    6162#include <iprt/asm.h>
     
    10731074    m->mListeners.insert(Listeners::value_type((IEventListener *)aListener, lrh));
    10741075
    1075     VBoxEventDesc evDesc;
    1076     evDesc.init(this, VBoxEventType_OnEventSourceChanged, (IEventListener *)aListener, TRUE);
    1077     evDesc.fire(0);
     1076    fireEventSourceChangedEvent(this, (IEventListener *)aListener, TRUE /*add*/);
    10781077
    10791078    return S_OK;
     
    10931092        m->mListeners.erase(it);
    10941093        // destructor removes refs from the event map
     1094        fireEventSourceChangedEvent(this, (IEventListener *)aListener, FALSE /*add*/);
    10951095        rc = S_OK;
    10961096    }
    10971097    else
    1098     {
    10991098        rc = setError(VBOX_E_OBJECT_NOT_FOUND,
    11001099                      tr("Listener was never registered"));
    1101     }
    1102 
    1103     if (SUCCEEDED(rc))
    1104     {
    1105         VBoxEventDesc evDesc;
    1106         evDesc.init(this, VBoxEventType_OnEventSourceChanged, (IEventListener *)aListener, FALSE);
    1107         evDesc.fire(0);
    1108     }
    11091100
    11101101    return rc;
Note: See TracChangeset for help on using the changeset viewer.

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