mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-19 09:57:49 +00:00
6480547: REG: bug 4118621 which got Integrated in 1.1.8 fails in mustang from b25 onwards
6808185: test/closed/java/awt/Menu/NullMenuLabelTest crashes Reviewed-by: dcherepanov
This commit is contained in:
parent
28253f9cb3
commit
41e1560d14
@ -794,6 +794,11 @@ BOOL AwtMenuItem::IsSeparator() {
|
||||
jobject jitem = GetTarget(env);
|
||||
jstring label =
|
||||
(jstring)(env)->GetObjectField(jitem, AwtMenuItem::labelID);
|
||||
if (label == NULL) {
|
||||
env->DeleteLocalRef(label);
|
||||
env->DeleteLocalRef(jitem);
|
||||
return FALSE; //separator must has '-' as label.
|
||||
}
|
||||
LPCWSTR labelW = JNU_GetStringPlatformChars(env, label, NULL);
|
||||
BOOL isSeparator = (labelW && (wcscmp(labelW, L"-") == 0));
|
||||
JNU_ReleaseStringPlatformChars(env, label, labelW);
|
||||
|
||||
@ -113,8 +113,6 @@ public:
|
||||
// Used to prevent untrusted code from synthesizing a WM_PASTE message
|
||||
// by posting a <CTRL>-V KeyEvent
|
||||
BOOL m_synthetic;
|
||||
virtual void EditSetSel(CHARRANGE &cr) = 0;
|
||||
virtual void EditGetSel(CHARRANGE &cr) = 0;
|
||||
virtual LONG EditGetCharFromPos(POINT& pt) = 0;
|
||||
|
||||
private:
|
||||
|
||||
@ -41,7 +41,9 @@ struct SetEchoCharStruct {
|
||||
* AwtTextField methods
|
||||
*/
|
||||
|
||||
AwtTextField::AwtTextField() {
|
||||
AwtTextField::AwtTextField()
|
||||
: m_initialRescrollFlag( true )
|
||||
{
|
||||
}
|
||||
|
||||
/* Create a new AwtTextField object and window. */
|
||||
@ -116,10 +118,6 @@ void AwtTextField::EditSetSel(CHARRANGE &cr) {
|
||||
SendMessage(EM_SETSEL, cr.cpMin, cr.cpMax);
|
||||
}
|
||||
|
||||
void AwtTextField::EditGetSel(CHARRANGE &cr) {
|
||||
SendMessage(EM_SETSEL, reinterpret_cast<WPARAM>(&cr.cpMin), reinterpret_cast<LPARAM>(&cr.cpMax));
|
||||
}
|
||||
|
||||
LONG AwtTextField::EditGetCharFromPos(POINT& pt) {
|
||||
return static_cast<LONG>(SendMessage(EM_CHARFROMPOS, 0, MAKELPARAM(pt.x, pt.y)));
|
||||
}
|
||||
@ -153,11 +151,9 @@ AwtTextField::HandleEvent(MSG *msg, BOOL synthetic)
|
||||
* The workaround also allows us to implement synthetic focus mechanism.
|
||||
*/
|
||||
if (IsFocusingMouseMessage(msg)) {
|
||||
CHARRANGE cr;
|
||||
|
||||
LONG lCurPos = EditGetCharFromPos(msg->pt);
|
||||
|
||||
EditGetSel(cr);
|
||||
/*
|
||||
* NOTE: Plain EDIT control always clears selection on mouse
|
||||
* button press. We are clearing the current selection only if
|
||||
@ -174,6 +170,7 @@ AwtTextField::HandleEvent(MSG *msg, BOOL synthetic)
|
||||
SetStartSelectionPos(lCurPos);
|
||||
SetEndSelectionPos(lCurPos);
|
||||
}
|
||||
CHARRANGE cr;
|
||||
cr.cpMin = GetStartSelectionPos();
|
||||
cr.cpMax = GetEndSelectionPos();
|
||||
EditSetSel(cr);
|
||||
@ -310,6 +307,47 @@ ret:
|
||||
delete secs;
|
||||
}
|
||||
|
||||
void AwtTextField::Reshape(int x, int y, int w, int h)
|
||||
{
|
||||
AwtTextComponent::Reshape( x, y, w, h );
|
||||
|
||||
// Another option would be to call this
|
||||
// after WM_SIZE notification is handled
|
||||
initialRescroll();
|
||||
}
|
||||
|
||||
|
||||
// Windows' Edit control features:
|
||||
// (i) if text selection is set while control's width or height is 0,
|
||||
// text is scrolled oddly.
|
||||
// (ii) if control's size is changed, text seems never be automatically
|
||||
// rescrolled.
|
||||
//
|
||||
// This method is designed for the following scenario: AWT spawns Edit
|
||||
// control with 0x0 dimensions, then sets text selection, then resizes the
|
||||
// control (couple of times). This might cause text appear undesirably scrolled.
|
||||
// So we reset/set selection again to rescroll text. (see also CR 6480547)
|
||||
void AwtTextField::initialRescroll()
|
||||
{
|
||||
if( ! m_initialRescrollFlag ) {
|
||||
return;
|
||||
}
|
||||
|
||||
::RECT r;
|
||||
BOOL ok = ::GetClientRect( GetHWnd(), &r );
|
||||
if( ! ok || r.right==0 || r.bottom==0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_initialRescrollFlag = false;
|
||||
|
||||
DWORD start, end;
|
||||
SendMessage( EM_GETSEL, (WPARAM)&start, (LPARAM)&end );
|
||||
SendMessage( EM_SETSEL, (WPARAM)0, (LPARAM)0 );
|
||||
SendMessage( EM_SETSEL, (WPARAM)start, (LPARAM)end );
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* WTextFieldPeer native methods
|
||||
*/
|
||||
|
||||
@ -55,9 +55,14 @@ public:
|
||||
static void _SetEchoChar(void *param);
|
||||
|
||||
protected:
|
||||
void EditSetSel(CHARRANGE &cr);
|
||||
void EditGetSel(CHARRANGE &cr);
|
||||
LONG EditGetCharFromPos(POINT& pt);
|
||||
virtual void Reshape(int x, int y, int w, int h);
|
||||
|
||||
private:
|
||||
void EditSetSel(CHARRANGE &cr);
|
||||
void initialRescroll();
|
||||
|
||||
bool m_initialRescrollFlag;
|
||||
};
|
||||
|
||||
#endif /* AWT_TEXTFIELD_H */
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
/* @test 1.5 98/07/23
|
||||
@bug 4064202 4253466
|
||||
@summary Test for Win32 NPE when MenuItem with null label added.
|
||||
@author fred.ecks
|
||||
@run main/othervm NullMenuLabelTest
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class NullMenuLabelTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Frame frame = new Frame("Test Frame");
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
MenuBar menuBar = new MenuBar();
|
||||
frame.setMenuBar(menuBar);
|
||||
Menu menu = new Menu(null);
|
||||
menuBar.add(menu);
|
||||
menu.add(new MenuItem(null));
|
||||
// If we got this far, the test succeeded
|
||||
frame.setVisible(false);
|
||||
frame.dispose();
|
||||
}
|
||||
|
||||
} // class NullMenuLabelTest
|
||||
@ -53,13 +53,14 @@ public class ScrollSelectionTest extends Applet
|
||||
frame.add(tf);
|
||||
tf.select(0, 20);
|
||||
|
||||
String[] instructions =
|
||||
{
|
||||
String[] instructions = {
|
||||
"INSTRUCTIONS:",
|
||||
"This is a test for a win32 specific problem",
|
||||
"If you see all the letters from 'a' to 'z' and",
|
||||
"letters from 'a' to 't' are selected then test passes"
|
||||
};
|
||||
"If you see all the letters from 'a' to 'z' and",
|
||||
"letters from 'a' to 't' are selected then test passes.",
|
||||
"You may have to activate the frame to see the selection"
|
||||
+ " highlighted (e.g. by clicking on frame's title)."
|
||||
};
|
||||
Sysout.createDialogWithInstructions( instructions );
|
||||
|
||||
}// init()
|
||||
|
||||
@ -114,6 +114,7 @@ public class SpuriousExitEnter_3 {
|
||||
checkEvents(frameAdapter, 1, 1);
|
||||
checkEvents(buttonAdapter, 0, 0);
|
||||
w.setVisible(false);
|
||||
Util.waitForIdle(r);
|
||||
}
|
||||
|
||||
public static void main(String []s)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user