......ApplicationImpl.assertReadAccessAllowed Exception Resolving
In my plugin when I use the API call
ModuleRootManager mrm = ModuleRootManager.getInstance( moduleManager.findModuleByName( project.getName() ) );
it gives me the following exceotion,
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:51)
at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:85)
at com.intellij.openapi.module.impl.ModuleManagerImpl.findModuleByName(ModuleManagerImpl.java:21)
not only when using this method but also in few other similar methods gives this error. Im calling this within an thread which is started by
ApplicationManager.getApplication().runProcessWithProgressSynchronously( th,....);
the plugin runs and do the task, but its a pain whn this is alway throown.. can any body guide me to resolve this
thanks
Ruwan
请先登录再写评论。
Wrap those calls into ApplicationManager.getApplicaiton().runReadAction().
thanks, but I runthis this is in a thread to keep the progress bar, hence cant move in to a new one. it needed to be called through
ApplicationManager.getApplication().runProcessWithProgressSynchronously
if I remove the progress bar and do as above this works, can you give me a solution while keeping the progress bar
Hello Sanjeewa,
SR> thanks, but I runthis this is in a thread to keep the progress bar,
SR> hence cant move in to a new one. it needed to be called through
SR>
SR> ApplicationManager.getApplication().runProcessWithProgressSynchronou
SR> sly
SR>
SR> if I remove the progress bar and do as above this works, can you
SR> give me a solution while keeping the progress bar
runReadAction() does not start any threads. It's simply a wrapper that grabs
a lock, executes your runnable and releases the lock.
--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"
I didn't mean to put everything into one single read action, but to wrap only the problematic calls into several small read actions. Something like this:
() { public ModuleRootManager compute() { return ModuleRootManager.getInstance(moduleManager.findModuleByName(project.getName())); } }); // do something with ModuleRootManager, still in runProcessWithProgressSynchronously ]]>yeh.. this works, thanks ...
when I send the runnable in to the method.. only thing I got in to mind is this will be run on a new thread... was causing the confusion...
Guys.... please provide some more details on the API