Skip to main content
Participant
August 16, 2007
Question

Strange ASSERT with kShowLayerCmdBoss

  • August 16, 2007
  • 1 reply
  • 290 views
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);
This topic has been closed for replies.

1 reply

Inspiring
August 16, 2007
A wild guess: Check that your "visible" value is true=1 or false=0 ...

Besides, do not assume that the layer is immediately *drawn* to the window as soon it is turned visible. Probably the layout window is only invalidated and the update event is still in the queue when the Assert fires, maybe it is just stuck in the offscreen cache.

Please would you be so kind to add your further findings to our growing collection of Asserts ?

http://www.niemannross.com/developer/wiki/index.php?title=InDesign_Asserts

Dirk