Question
Strange ASSERT with kShowLayerCmdBoss
I wrote some code for a CS3 plugin to make a document layer visible or invisible. That part works, but I get the following ASSERT whenever I change the visibility:<br /><br /> ShowLayerCmd::Do - docLayer->IsVisible() != showLayer<br /><br /> ..\..\..\source\components\pageitems\layer\ShowLayerCmd.cpp (96)<br /> <br />The ASSERT is raised before the layer visibility changes, i.e., I'll get the ASSERT dialog, hit the "Skip" button, and then the layer visibility will change. So it seems to me that "docLayer->IsVisible() != showLayer" shouldn't be an error condition. Or maybe I'm misinterpreting the message.<br /><br />In any event, I can prevent the ASSERT by explicitly setting the layer visibility to what it supposedly already is, which doesn't make any sense to me. Can someone explain this? See the code below.<br /><br />FYI, "layer" is an IDocumentLayer* and "visible" is a bool16 representing the state we want to set. (I've removed all ASSERTS and error-checking here for simplicity. In the actual code, the errors never occur.)<br /><br /> // Break if layer is already at desired visibility state<br /> if (visible == layer->IsVisible()) {<br /> break;<br /> }<br /><br /> // This prevents the ASSERT, even though we're setting visibility<br /> // to what it already is!<br /> layer->SetVisible(!visible);<br /><br /> InterfacePtr<ICommand><br /> showLayerCmd(CmdUtils::CreateCommand(kShowLayerCmdBoss));<br /><br /> InterfacePtr<IBoolData> boolData(showLayerCmd, UseDefaultIID());<br /> boolData->Set(visible);<br /><br /> showLayerCmd->SetItemList(UIDList(::GetUIDRef(layer)));<br /><br /> CmdUtils::ProcessCommand(showLayerCmd);