-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix to 62336 #396
Fix to 62336 #396
Conversation
Codecov Report
@@ Coverage Diff @@
## trunk #396 +/- ##
============================================
- Coverage 58.62% 58.61% -0.01%
Complexity 10602 10602
============================================
Files 1193 1193
Lines 75837 75842 +5
Branches 7330 7331 +1
============================================
Hits 44457 44457
- Misses 28869 28874 +5
Partials 2511 2511
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patch.
I have one question and a few minor notes about code formatting.
@@ -680,7 +683,15 @@ private void addQuickComponentHotkeys(JTree treevar) { | |||
|
|||
@Override | |||
public void actionPerformed(ActionEvent actionEvent) { | |||
String propname = "gui.quick_" + actionEvent.getActionCommand(); | |||
//Bug 62336 | |||
AWTEvent current_event = EventQueue.getCurrentEvent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you checked what actionEvent
is here? If I read the Swing-API correctly, it should be the same object as current_event
. If actionEvent
is really null
here, is it only sometimes null
and the NPE stops the AWT thread?
As a minor note: current_event
should be written in camel case as currentEvent
to match the other names.
//Bug 62336 | ||
AWTEvent current_event = EventQueue.getCurrentEvent(); | ||
String key_text = ""; | ||
if(current_event instanceof KeyEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would place a space between if
and the opening parenthesis as if
is not a function call.
String key_text = ""; | ||
if(current_event instanceof KeyEvent) { | ||
KeyEvent key_event = (KeyEvent)current_event; | ||
key_text = KeyEvent.getKeyText( key_event.getKeyCode() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again a minor nit: No space needed after the opening and before the closing parenthesis as this is a function call.
And as above variable names should be written in camel case: keyEvent
instead of key_event
.
AWTEvent current_event = EventQueue.getCurrentEvent(); | ||
String key_text = ""; | ||
if(current_event instanceof KeyEvent) { | ||
KeyEvent key_event = (KeyEvent)current_event; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I would put a space after the closing parenthesis as this is a cast.
current_event is KeyEvent. action_event is ActionEvent. KeyEvent and
ActonEvent two different types, but both from AWTEvent. Line: String
propname = "gui.quick_" + actionEvent.getActionCommand(); tries to prepare
property name where last part it is pressed key with digit, and not working
with CTRL-6. I just replaced, with code, which take key text directly from
KeyEvent.
Your recommendations about code style is done.
…On Sun, Aug 26, 2018 at 3:30 PM Felix Schumacher ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Thanks for your patch.
I have one question and a few minor notes about code formatting.
------------------------------
In src/core/org/apache/jmeter/gui/MainFrame.java
<#396 (comment)>:
> @@ -680,7 +683,15 @@ private void addQuickComponentHotkeys(JTree treevar) {
@OverRide
public void actionPerformed(ActionEvent actionEvent) {
- String propname = "gui.quick_" + actionEvent.getActionCommand();
+ //Bug 62336
+ AWTEvent current_event = EventQueue.getCurrentEvent();
Have you checked what actionEvent is here? If I read the Swing-API
correctly, it should be the same object as current_event. If actionEvent
is really null here, is it only sometimes null and the NPE stops the AWT
thread?
As a minor note: current_event should be written in camel case as
currentEvent to match the other names.
------------------------------
In src/core/org/apache/jmeter/gui/MainFrame.java
<#396 (comment)>:
> @@ -680,7 +683,15 @@ private void addQuickComponentHotkeys(JTree treevar) {
@OverRide
public void actionPerformed(ActionEvent actionEvent) {
- String propname = "gui.quick_" + actionEvent.getActionCommand();
+ //Bug 62336
+ AWTEvent current_event = EventQueue.getCurrentEvent();
+ String key_text = "";
+ if(current_event instanceof KeyEvent) {
I would place a space between if and the opening parenthesis as if is not
a function call.
------------------------------
In src/core/org/apache/jmeter/gui/MainFrame.java
<#396 (comment)>:
> @@ -680,7 +683,15 @@ private void addQuickComponentHotkeys(JTree treevar) {
@OverRide
public void actionPerformed(ActionEvent actionEvent) {
- String propname = "gui.quick_" + actionEvent.getActionCommand();
+ //Bug 62336
+ AWTEvent current_event = EventQueue.getCurrentEvent();
+ String key_text = "";
+ if(current_event instanceof KeyEvent) {
+ KeyEvent key_event = (KeyEvent)current_event;
+ key_text = KeyEvent.getKeyText( key_event.getKeyCode() );
Again a minor nit: No space needed after the opening and before the
closing parenthesis as this is a function call.
And as above variable names should be written in camel case: keyEvent
instead of key_event.
------------------------------
In src/core/org/apache/jmeter/gui/MainFrame.java
<#396 (comment)>:
> @@ -680,7 +683,15 @@ private void addQuickComponentHotkeys(JTree treevar) {
@OverRide
public void actionPerformed(ActionEvent actionEvent) {
- String propname = "gui.quick_" + actionEvent.getActionCommand();
+ //Bug 62336
+ AWTEvent current_event = EventQueue.getCurrentEvent();
+ String key_text = "";
+ if(current_event instanceof KeyEvent) {
+ KeyEvent key_event = (KeyEvent)current_event;
Here I would put a space after the closing parenthesis as this is a cast.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#396 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AglOptrf5wGhMvsxG1TeD4dhKPCM5dU3ks5uUvdcgaJpZM4WM0kk>
.
|
Implemented few code style recommendations from Felix Schumacher.
Right, the events will never be the same, but still... I wonder why |
I based my solution on discussion: https://stackoverflow.com/questions/32978936/why-actionevent-getactioncommand-returns-null |
Just wanted to let you know, that you are not forgotten. I have now access to a windows 10 system and can reproduce the issue. But before I implement your fix, I would like to understand why |
Thanks for your contribution. I still don't know, why we get |
With the changes for the original bug report, the inner class got too big, so refactor it out into a nested static class. Some shortcuts are not working correctly on windows Contributed by Michael Pavlov (michael.paulau at gmail.com) Followup to r1845017 Bugzilla Id: 62336 Relates to #396 on github git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1845021 13f79535-47bb-0310-9956-ffa450edef68
Contributed by Michael Pavlov (michael.paulau at gmail.com) Bugzilla Id: 62336 Closes apache#396 on github git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1845017 13f79535-47bb-0310-9956-ffa450edef68
With the changes for the original bug report, the inner class got too big, so refactor it out into a nested static class. Some shortcuts are not working correctly on windows Contributed by Michael Pavlov (michael.paulau at gmail.com) Followup to r1845017 Bugzilla Id: 62336 Relates to apache#396 on github git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1845021 13f79535-47bb-0310-9956-ffa450edef68
Contributed by Michael Pavlov (michael.paulau at gmail.com) Bugzilla Id: 62336 Closes apache#396 on github git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1845017 13f79535-47bb-0310-9956-ffa450edef68 Former-commit-id: 4970be0
With the changes for the original bug report, the inner class got too big, so refactor it out into a nested static class. Some shortcuts are not working correctly on windows Contributed by Michael Pavlov (michael.paulau at gmail.com) Followup to r1845017 Bugzilla Id: 62336 Relates to apache#396 on github git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1845021 13f79535-47bb-0310-9956-ffa450edef68 Former-commit-id: c9fc78c
Description
Keyboard shortcut Ctrl +6 is not working.
Was reproduced for Java 8 on Windows 10.
actionEvent.getActionCommand() in MainFrame unexpected returning null only for CTRL-6. getActionCommand was replaced with alternative code. New version working stable.
Motivation and Context
All CTRL-{N} working stable, after fix.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62336
How Has This Been Tested?
Tested on Java 8 and Java 9 on Windows 10. Issue was reproduced. New code working fine.
Screenshots (if appropriate):
Types of changes
Checklist:
Path Filename Extension Status Lines added Lines removed Last Modified Size
src/core/org/apache/jmeter/gui/MainFrame.java MainFrame.java .java Modified 12 1