Assertion error when using runWriteAction method of Application class

Hi,

I have a refresh method which is called whenever some contents of the file change.
The method is :
public void refreshResourceStatuses(VirtualFile resource)
{
if (resource ==null) return;
if(project == null)
{
project = (Project)DataManager.getInstance().getDataContext().getData(DataConstants.PROJECT);
}
boolean dir = false;
if (resource.isDirectory())
{
dir = true;
}
if (dir)
{
VirtualFileManager.getInstance().refresh(true, new Runnable()
{
public void run()
{
FileStatusManager.getInstance(project)
.fileStatusesChanged();
}
});
} else
{
final VirtualFile vFile = resource;
ApplicationManager.getApplication().runWriteAction(
new Runnable()
{
public void run()
{
vFile.refresh(false, false);
}
});

FileStatusManager.getInstance(project)
.fileStatusChanged(vFile);
}
}

I have extended the VirtualFileAdapter class and overridden the contentsChanged method, so whenever the file is modifed in the editor, my contents changed method is called which calls the super method and then the above refresh method.

In my VCS plugin when I try to perform some action (e.g checkout) , in which my files contents are changed by the VCS api, I get the Assertion error as "Assertion failed: Event cannot be raised when dispatching another event is in progress. Dispatching contentsChanged ."

Can someone provide me with pointers as to how can I prevent by executing one thread at a time?

Thanks in advance for the help.

~Priya

1 comment

This will supposedly be fixed in 5.1.1 and also 6.0. You can try the
latest EAP for either, to confirm.

Priya Kothari wrote:

Hi,

I have a refresh method which is called whenever some contents of the file change.
The method is :
public void refreshResourceStatuses(VirtualFile resource)
{
if (resource ==null) return;
if(project == null)
{
project = (Project)DataManager.getInstance().getDataContext().getData(DataConstants.PROJECT);
}
boolean dir = false;
if (resource.isDirectory())
{
dir = true;
}
if (dir)
{
VirtualFileManager.getInstance().refresh(true, new Runnable()
{
public void run()
{
FileStatusManager.getInstance(project)
.fileStatusesChanged();
}
});
} else
{
final VirtualFile vFile = resource;
ApplicationManager.getApplication().runWriteAction(
new Runnable()
{
public void run()
{
vFile.refresh(false, false);
}
});

FileStatusManager.getInstance(project)
.fileStatusChanged(vFile);
}
}

I have extended the VirtualFileAdapter class and overridden the contentsChanged method, so whenever the file is modifed in the editor, my contents changed method is called which calls the super method and then the above refresh method.

In my VCS plugin when I try to perform some action (e.g checkout) , in which my files contents are changed by the VCS api, I get the Assertion error as "Assertion failed: Event cannot be raised when dispatching another event is in progress. Dispatching contentsChanged ."

Can someone provide me with pointers as to how can I prevent by executing one thread at a time?

Thanks in advance for the help.

~Priya

0

Please sign in to leave a comment.