mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
IDEA-319117 call menuNeedsUpdate from menuWillOpen if necessary
and also remove unnecessary fillMenu() from menuWillOpen GitOrigin-RevId: f7bf20c03fb629c08f66da2d21eb200cfdf728ad
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ed9122224d
commit
1d4e3aa898
Binary file not shown.
@@ -73,6 +73,19 @@ static bool sUpdateInProgress = false; // used only in AppKit
|
||||
JNI_COCOA_EXIT();
|
||||
}
|
||||
|
||||
- (void)menuWillOpen:(NSMenu *)menu {
|
||||
if (javaPeer == nil)
|
||||
return;
|
||||
|
||||
JNIEnv *env = getAppKitEnv();
|
||||
JNI_COCOA_ENTER();
|
||||
GET_MENU_CLASS();
|
||||
DECLARE_METHOD(jm_Menu_menuWillOpen, sjc_Menu, "menuWillOpen", "()V");
|
||||
(*env)->CallVoidMethod(env, javaPeer, jm_Menu_menuWillOpen);
|
||||
CHECK_EXCEPTION(env);
|
||||
JNI_COCOA_EXIT();
|
||||
}
|
||||
|
||||
- (void)menuDidClose:(NSMenu *)menu {
|
||||
if (javaPeer == nil)
|
||||
return;
|
||||
|
||||
@@ -95,6 +95,9 @@ public class Menu extends MenuItem {
|
||||
|
||||
public void setTitle(String label) {
|
||||
ensureNativePeer();
|
||||
if (label == null)
|
||||
label = "";
|
||||
myTitle = label;
|
||||
nativeSetTitle(nativePeer, label, isInHierarchy);
|
||||
}
|
||||
|
||||
@@ -243,6 +246,18 @@ public class Menu extends MenuItem {
|
||||
}
|
||||
}
|
||||
|
||||
public void menuWillOpen() {
|
||||
// Called on AppKit when menu opening
|
||||
if (!myIsOpened) {
|
||||
// When user opens some menu at second time (without focus lost) apple doesn't call menuNeedsUpdate for
|
||||
// this menu (but always calls menuWillOpen) and for all submenus. It causes problems like IDEA-319117.
|
||||
// So detect this case and call menuNeedsUpdate() "manually".
|
||||
// NOTE: unfortunately modifying menu here can cause unstable behaviour, see IDEA-315910.
|
||||
Logger.getInstance(Menu.class).debug("menuNeedsUpdate wasn't called for '" + myTitle + "', will do it now");
|
||||
menuNeedsUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public void invokeMenuClosing() {
|
||||
// Called on AppKit when menu closed
|
||||
myIsOpened = false;
|
||||
|
||||
@@ -23,6 +23,7 @@ public class MenuItem implements Disposable, PropertyChangeListener {
|
||||
Runnable actionDelegate;
|
||||
boolean isInHierarchy = false;
|
||||
Presentation presentation;
|
||||
String myTitle; // used for logging and debug
|
||||
|
||||
public MenuItem() {}
|
||||
|
||||
@@ -80,12 +81,14 @@ public class MenuItem implements Disposable, PropertyChangeListener {
|
||||
keyChar = 0;
|
||||
}
|
||||
|
||||
myTitle = label;
|
||||
nativeSetTitleAndAccelerator(nativePeer, label, keyChar, keyCode, modifiers, isInHierarchy);
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
ensureNativePeer();
|
||||
if (label == null) label = "";
|
||||
myTitle = label;
|
||||
nativeSetTitle(nativePeer, label, isInHierarchy);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,8 @@ public final class ActionMenu extends JBMenu {
|
||||
if (Menu.isJbScreenMenuEnabled() && ActionPlaces.MAIN_MENU.equals(myPlace)) {
|
||||
myScreenMenuPeer = new Menu(myPresentation.getText(enableMnemonics));
|
||||
myScreenMenuPeer.setOnOpen(() -> {
|
||||
// NOTE: setSelected(true) calls fillMenu internally
|
||||
setSelected(true);
|
||||
fillMenu();
|
||||
}, this);
|
||||
myScreenMenuPeer.setOnClose(() -> setSelected(false), this);
|
||||
myScreenMenuPeer.listenPresentationChanges(myPresentation);
|
||||
|
||||
Reference in New Issue
Block a user