Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: Write access is allowed from event dispatch thread only #102

Open
hacker-cb opened this issue Sep 30, 2019 · 14 comments
Open

Exception: Write access is allowed from event dispatch thread only #102

hacker-cb opened this issue Sep 30, 2019 · 14 comments
Assignees
Labels

Comments

@hacker-cb
Copy link

There is Exception in 1.1.1.192:

Write access is allowed from event dispatch thread only

com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: EventQueue.isDispatchThread()=false Toolkit.getEventQueue()=com.intellij.ide.IdeEventQueue@4499352e
Current thread: Thread[Timer-3,6,Idea Thread Group] 1535808483
SystemEventQueueThread: Thread[AWT-EventQueue-0 2019.2.3#IU-192.6817.14 IDEA, eap:false, os:Mac OS X 10.14.6, java-version:JetBrains s.r.o 11.0.4+10-b304.69 2019.2.3#IU-192.6817.14 IDEA, eap:false, os:Mac OS X 10.14.6, java-version:JetBrains s.r.o 11.0.4+10-b304.69,6,Idea Thread Group] 1266730927
	at com.intellij.openapi.application.impl.ApplicationImpl.assertIsDispatchThread(ApplicationImpl.java:1068)
	at com.intellij.openapi.application.impl.ApplicationImpl.startWrite(ApplicationImpl.java:1150)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:992)
	at eu.long1.flutter.i18n.files.FileHelpers.getI18nFile(FileHelpers.kt:51)
	at eu.long1.flutter.i18n.workers.I18nFileGenerator.generate(I18nFileGenerator.kt:67)
	at eu.long1.flutter.i18n.workers.Initializer$runActivity$$inlined$scheduleAtFixedRate$1$lambda$1.compute(actions.kt:74)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:922)
	at eu.long1.flutter.i18n.workers.Initializer$runActivity$$inlined$scheduleAtFixedRate$1.run(Timer.kt:150)
	at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
	at java.base/java.util.TimerThread.run(Timer.java:506)
@hacker-cb
Copy link
Author

hacker-cb commented Sep 30, 2019

I'm using IDEA with multi module layout and seems that plugin tries to create res/values folder in the root project and after fails with Exception.

My root project does not has pubspec.yaml file.

Folder structure:

./ - main project - NO pubspec.yaml
app - flutter app
packages/my_package_1 - dart package

Each folder added to IDEA as separate module.

@noordawod noordawod self-assigned this Oct 1, 2019
@noordawod noordawod added the bug label Oct 1, 2019
@noordawod
Copy link
Contributor

Plugin v1.1.2 has been published to JetBrains, awaiting approval. Could you install and check it and report back if the error still persists?

@hacker-cb
Copy link
Author

Thank you. I will check as soon as it will be approved by Jetbrains.

What about plugin behavior with such directory structure, where root directory does not contains any flutter or dart project but plugin still tries to create res/values folder in it?

@noordawod
Copy link
Contributor

This is yet unsupported, but I think I will add an option to select both the name of the generated folder and also where to find Arb files. Then you can easily point the plugin to the right directories.

@hacker-cb
Copy link
Author

I think that It will be better if plugin will detect generated folder name relative to the pubspec.yaml.

@noordawod
Copy link
Contributor

Yeah, by default it will follow where the pubspec file is located -- but it may be specified by the user as well (when this is implemented).

@hacker-cb
Copy link
Author

Yeah, by default it will follow where the pubspec file is located

Is it current behavior or future behavior?
In my project structure there is NO pubspec.yaml file in the root folder, but plugin still creates res/values folder in the root.

@noordawod
Copy link
Contributor

Yeah, I understand that.

However, for the plugin to configure itself, it will try to load the pubspec.yaml file from the project's root folder, even if it just contains the following:

flutter_i18n:
  enable-flutter-i18n: false

Do you have a better idea on how the plugin can be configured otherwise? (without showing a dialog or a settings box.)

@hacker-cb
Copy link
Author

In pseudo-code logic should be like this:

foreach (pubspec_file in ...){
   if (has(dependencies.flutter) && (has(dependencies.flutter_localizations))){
     plugin_enabled = true
   } else {
     plugin_enabled = false
   }
   if (has(flutter_i18n.enable-flutter-i18n)){
   	 plugin_enabled=${flutter_i18n.enable-flutter-i18n}
   }
   res_values_folder=dirname(pubspec_file)+'/res/values'
   src_folder=dirname(pubspec_file)+'/lib'
}

Don't forget that IDEA can have multi-module project.

@noordawod
Copy link
Contributor

Multi-module is not yet supported, unsure what's the best approach right now.
About the pseudo-code: that's how it works now ;)

@hacker-cb
Copy link
Author

So, what about multi-module project support? Actually, in my case I moved flutter app to the app dir of the root project and plugin does not work :(

@noordawod
Copy link
Contributor

As expected. Plugin searches for pubspec.yaml in the root folder only.

@hacker-cb
Copy link
Author

Do you have any plans to add subfolder/submodule support?

@noordawod
Copy link
Contributor

noordawod commented Oct 2, 2019

Multi-module is not yet supported, unsure what's the best approach right now.
If you have an idea on how this can be accomplished, please share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants