Well if your plugin crashes don't submit a bug to the tracker, fix your plugin If your plugin has a bug in its serialization code, though, it can cause other parts of Construct to crash after your plugin code has finished running, which is probably what's happening here.
You can't recompile an edittime plugin while Construct is open (the compiler can't write to the CSX file because construct has loaded it). However, you can recompile a runtime plugin, as long as the loaded serialize data is backwards compatible. If it's not, it will crash on preview, and as above, it might not crash in your plugin, but your plugin will have caused it. It can be very tricky to debug these problems.
If you change your edittime plugin's serialize data while Construct is closed, it must be backwards compatible. If it's not, all .cap files using that plugin that already exist become invalid and will not load with your new plugin. Have a look at some other plugins to see how they do this. Here's a quick example:
Say your plugin initially uses this data to save:
void EditExt::Serialize(bin& ar)
{
int Version = 1;
SerializeVersion(ar, Version);
if (ar.loading) {
ar >> myint;
}
else {
ar << myint;
}
}[/code:2etwz5zu]
Suppose you want to add a new value, 'myfloat', to the saved data. Increase the 'version' number to 2. The loading code must still support version 1 (to still be able to load old .caps with the plugin's old format). The saving code only needs to save the current version. So you'd change it like so:
[code:2etwz5zu]void EditExt::Serialize(bin& ar)
{
int Version = 1;
SerializeVersion(ar, Version);
if (ar.loading) {
ar >> myint; // both versions 1 and 2 load a myint first
if (Version >= 2) // version 1 doesn't have this
ar >> myfloat;
}
else {
// Save the current version
ar << myint << myfloat;
}
}[/code:2etwz5zu]
If you don't do it fully backwards compatible like that, all old .caps using your plugin break and will fail to load. Again, lots of plugins and behaviors use versioning, so check out some on CVS.
Two important points:
[ul]
[li]In this case, you must initialise 'myfloat' to a default value in the edittime constructor. If you are loading an old .cap (using Version 1), 'myfloat' will contain undefined data unless it has a default in the constructor, because otherwise nothing is ever written to it.[/li]
[li]The runtime loading code [b]must support all versions[/b] of the edittime serialize data. If you open an old .cap using Version 1, and immediately hit Run, the runtime is passed the Version 1 data ([i]without[/i] 'myfloat'). Again, it will crash on preview if you don't support the old version. So you basically need the same loading code in OnCreate() as you have in the EditExt :: Serialize() loading code.[/li]
[/ul]