About "FIXUP_VTABLE" in CS4
starnight1981 May 7, 2009 7:20 AMIn Cs4 sdk,there is a VTableSupport.hpp :
// If your plugin has a C++ object attached to it's globals, and if
// the class of that object has virtual functions, those functions
// will not work after the plugin is unloaded and then reloaded.
//
// The following macro (FIXUP_VTABLE) can be used to provide a means
// of restoring the virtual function table of a globally-persistent
// C++ object by calling FixupVTable() prior to the use of any of
// the object's virtual functions after a reload.
//
// Here is how you might use the macro:
I found there is some bug about (FIXUP_VTABLE). now ,let 't see samplecode "ADMNonModalDialog":
ADMNonModalDialog::ADMNonModalDialog(SPPluginRef pluginRef) : BaseADMDialog()
{
fAccessRef = NULL;
int options = 0;
this->pluginRef=pluginRef;
// Create the Non-modal dialog. This does not necessarily show the dialog on
// the screen. If the dialog was hidden at last shutdown, it will not be shown
// until sADMDialog->Show() is called.
// Note: the init proc - Init, will be called immediately following Create()
this->Create(pluginRef, "ADMNonModalDialog", kADMNonModalDialogID, kADMTabbedFloatingDialogStyle, options);
}
ASErr ADMNonModalDialogPlugin::GoMenuItem(AIMenuMessage* message)
{
ASErr error = kNoErr;
if (message->menuItem == this->fShowADMNonModalDialog) {
if (this->fADMNonModalDialog) {
ASBoolean visible = this->fADMNonModalDialog->IsVisible();
this->fADMNonModalDialog->Show(!visible);
}
}
else if (message->menuItem == this->fAboutPluginMenu) {
// Pop this plug-in's about box.
SDKAboutPluginsHelper aboutPluginsHelper;
aboutPluginsHelper.PopAboutBox(message, "About ADMNonModalDialog", kSDKDefAboutSDKCompanyPluginsAlertString);
}
if (error)
goto error;
error:
return error;
}
I change these two function to:
ADMNonModalDialog::ADMNonModalDialog(SPPluginRef pluginRef) : BaseADMDialog()
{
fAccessRef = NULL;
int options = 0;
this->pluginRef=pluginRef;
// Create the Non-modal dialog. This does not necessarily show the dialog on
// the screen. If the dialog was hidden at last shutdown, it will not be shown
// until sADMDialog->Show() is called.
// Note: the init proc - Init, will be called immediately following Create()
//this->Create(pluginRef, "ADMNonModalDialog", kADMNonModalDialogID, kADMTabbedFloatingDialogStyle, options);
// I want to create a modal dialog
}
ASErr ADMNonModalDialogPlugin::GoMenuItem(AIMenuMessage* message)
{
ASErr error = kNoErr;
if (message->menuItem == this->fShowADMNonModalDialog) {
if (this->fADMNonModalDialog) {
//ASBoolean visible = this->fADMNonModalDialog->IsVisible();
//this->fADMNonModalDialog->Show(!visible);
this->fADMNonModalDialog->Modal(this->fPluginRef,"ADMModalDialog",kADMNonModalDialogID);
//when debug to here,program dead.
//int BaseADMDialog::Modal(SPPluginRef pluginRef, char* name, int dialogID, ADMDialogStyle style, int options)
//is a virtual function
}
}
else if (message->menuItem == this->fAboutPluginMenu) {
// Pop this plug-in's about box.
SDKAboutPluginsHelper aboutPluginsHelper;
aboutPluginsHelper.PopAboutBox(message, "About ADMNonModalDialog", kSDKDefAboutSDKCompanyPluginsAlertString);
}
if (error)
goto error;
error:
return error;
}


