diff options
| author | Jan Djärv | 2012-07-22 18:35:15 +0200 |
|---|---|---|
| committer | Jan Djärv | 2012-07-22 18:35:15 +0200 |
| commit | 9d7fa573c7231360c9b083734d1894ddfe6596f9 (patch) | |
| tree | 15bf46ca85a832bfa521b37467f2d68a6244c126 /src | |
| parent | 0dd6d66d56e7133818db361cc853fd1d00f2714b (diff) | |
| download | emacs-9d7fa573c7231360c9b083734d1894ddfe6596f9.tar.gz emacs-9d7fa573c7231360c9b083734d1894ddfe6596f9.zip | |
* nsmenu.m (Popdown_data): New struct.
(pop_down_menu): p->pointer is Popdown_data. Release the pool and
free Popdown_data.
(ns_popup_dialog): Use NSAutoreleasePool and pass it to pop_down_menu.
(initWithContentRect): Make imgView and contentView non-static
and autorelease them. Also autorelease img and matrix.
(dealloc): Remove (Bug#1995-05-29T20:16:10Z!kwzh@gnu.org).
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/nsmenu.m | 76 |
2 files changed, 56 insertions, 30 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f689cc20ee0..b89bfc41298 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2012-07-22 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * nsmenu.m (Popdown_data): New struct. | ||
| 4 | (pop_down_menu): p->pointer is Popdown_data. Release the pool and | ||
| 5 | free Popdown_data. | ||
| 6 | (ns_popup_dialog): Use NSAutoreleasePool and pass it to pop_down_menu. | ||
| 7 | (initWithContentRect): Make imgView and contentView non-static | ||
| 8 | and autorelease them. Also autorelease img and matrix (Bug#12005). | ||
| 9 | (dealloc): Remove (Bug#12005). | ||
| 10 | |||
| 1 | 2012-07-22 Dmitry Antipov <dmantipov@yandex.ru> | 11 | 2012-07-22 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 12 | ||
| 3 | Adjust consing_since_gc when objects are explicitly freed. | 13 | Adjust consing_since_gc when objects are explicitly freed. |
diff --git a/src/nsmenu.m b/src/nsmenu.m index c919f350c6c..d5b5f4b7526 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -1349,20 +1349,33 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1349 | 1349 | ||
| 1350 | ========================================================================== */ | 1350 | ========================================================================== */ |
| 1351 | 1351 | ||
| 1352 | struct Popdown_data | ||
| 1353 | { | ||
| 1354 | NSAutoreleasePool *pool; | ||
| 1355 | EmacsDialogPanel *dialog; | ||
| 1356 | }; | ||
| 1352 | 1357 | ||
| 1353 | static Lisp_Object | 1358 | static Lisp_Object |
| 1354 | pop_down_menu (Lisp_Object arg) | 1359 | pop_down_menu (Lisp_Object arg) |
| 1355 | { | 1360 | { |
| 1356 | struct Lisp_Save_Value *p = XSAVE_VALUE (arg); | 1361 | struct Lisp_Save_Value *p = XSAVE_VALUE (arg); |
| 1362 | struct Popdown_data *unwind_data = (struct Popdown_data *) p->pointer; | ||
| 1363 | |||
| 1364 | BLOCK_INPUT; | ||
| 1357 | if (popup_activated_flag) | 1365 | if (popup_activated_flag) |
| 1358 | { | 1366 | { |
| 1367 | EmacsDialogPanel *panel = unwind_data->dialog; | ||
| 1359 | popup_activated_flag = 0; | 1368 | popup_activated_flag = 0; |
| 1360 | BLOCK_INPUT; | ||
| 1361 | [NSApp endModalSession: popupSession]; | 1369 | [NSApp endModalSession: popupSession]; |
| 1362 | [((EmacsDialogPanel *) (p->pointer)) close]; | 1370 | |
| 1371 | [panel close]; | ||
| 1372 | [unwind_data->pool release]; | ||
| 1363 | [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; | 1373 | [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; |
| 1364 | UNBLOCK_INPUT; | ||
| 1365 | } | 1374 | } |
| 1375 | |||
| 1376 | xfree (unwind_data); | ||
| 1377 | UNBLOCK_INPUT; | ||
| 1378 | |||
| 1366 | return Qnil; | 1379 | return Qnil; |
| 1367 | } | 1380 | } |
| 1368 | 1381 | ||
| @@ -1375,6 +1388,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) | |||
| 1375 | struct frame *f; | 1388 | struct frame *f; |
| 1376 | NSPoint p; | 1389 | NSPoint p; |
| 1377 | BOOL isQ; | 1390 | BOOL isQ; |
| 1391 | NSAutoreleasePool *pool; | ||
| 1378 | 1392 | ||
| 1379 | NSTRACE (x-popup-dialog); | 1393 | NSTRACE (x-popup-dialog); |
| 1380 | 1394 | ||
| @@ -1429,15 +1443,23 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) | |||
| 1429 | contents = Fcons (title, Fcons (Fcons (build_string ("Ok"), Qt), Qnil)); | 1443 | contents = Fcons (title, Fcons (Fcons (build_string ("Ok"), Qt), Qnil)); |
| 1430 | 1444 | ||
| 1431 | BLOCK_INPUT; | 1445 | BLOCK_INPUT; |
| 1446 | pool = [[NSAutoreleasePool alloc] init]; | ||
| 1432 | dialog = [[EmacsDialogPanel alloc] initFromContents: contents | 1447 | dialog = [[EmacsDialogPanel alloc] initFromContents: contents |
| 1433 | isQuestion: isQ]; | 1448 | isQuestion: isQ]; |
| 1449 | |||
| 1434 | { | 1450 | { |
| 1435 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); | 1451 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); |
| 1436 | record_unwind_protect (pop_down_menu, make_save_value (dialog, 0)); | 1452 | struct Popdown_data *unwind_data = xmalloc (sizeof (*unwind_data)); |
| 1453 | |||
| 1454 | unwind_data->pool = pool; | ||
| 1455 | unwind_data->dialog = dialog; | ||
| 1456 | |||
| 1457 | record_unwind_protect (pop_down_menu, make_save_value (unwind_data, 0)); | ||
| 1437 | popup_activated_flag = 1; | 1458 | popup_activated_flag = 1; |
| 1438 | tem = [dialog runDialogAt: p]; | 1459 | tem = [dialog runDialogAt: p]; |
| 1439 | unbind_to (specpdl_count, Qnil); /* calls pop_down_menu */ | 1460 | unbind_to (specpdl_count, Qnil); /* calls pop_down_menu */ |
| 1440 | } | 1461 | } |
| 1462 | |||
| 1441 | UNBLOCK_INPUT; | 1463 | UNBLOCK_INPUT; |
| 1442 | 1464 | ||
| 1443 | return tem; | 1465 | return tem; |
| @@ -1475,24 +1497,22 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) | |||
| 1475 | NSSize spacing = {SPACER, SPACER}; | 1497 | NSSize spacing = {SPACER, SPACER}; |
| 1476 | NSRect area; | 1498 | NSRect area; |
| 1477 | id cell; | 1499 | id cell; |
| 1478 | static NSImageView *imgView; | 1500 | NSImageView *imgView; |
| 1479 | static FlippedView *contentView; | 1501 | FlippedView *contentView; |
| 1480 | 1502 | NSImage *img; | |
| 1481 | if (imgView == nil) | 1503 | |
| 1482 | { | 1504 | area.origin.x = 3*SPACER; |
| 1483 | NSImage *img; | 1505 | area.origin.y = 2*SPACER; |
| 1484 | area.origin.x = 3*SPACER; | 1506 | area.size.width = ICONSIZE; |
| 1485 | area.origin.y = 2*SPACER; | 1507 | area.size.height= ICONSIZE; |
| 1486 | area.size.width = ICONSIZE; | 1508 | img = [[NSImage imageNamed: @"NSApplicationIcon"] copy]; |
| 1487 | area.size.height= ICONSIZE; | 1509 | [img setScalesWhenResized: YES]; |
| 1488 | img = [[NSImage imageNamed: @"NSApplicationIcon"] copy]; | 1510 | [img setSize: NSMakeSize (ICONSIZE, ICONSIZE)]; |
| 1489 | [img setScalesWhenResized: YES]; | 1511 | imgView = [[NSImageView alloc] initWithFrame: area]; |
| 1490 | [img setSize: NSMakeSize (ICONSIZE, ICONSIZE)]; | 1512 | [imgView setImage: img]; |
| 1491 | imgView = [[NSImageView alloc] initWithFrame: area]; | 1513 | [imgView setEditable: NO]; |
| 1492 | [imgView setImage: img]; | 1514 | [img autorelease]; |
| 1493 | [imgView setEditable: NO]; | 1515 | [imgView autorelease]; |
| 1494 | [img release]; | ||
| 1495 | } | ||
| 1496 | 1516 | ||
| 1497 | aStyle = NSTitledWindowMask; | 1517 | aStyle = NSTitledWindowMask; |
| 1498 | flag = YES; | 1518 | flag = YES; |
| @@ -1501,6 +1521,8 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) | |||
| 1501 | [super initWithContentRect: contentRect styleMask: aStyle | 1521 | [super initWithContentRect: contentRect styleMask: aStyle |
| 1502 | backing: backingType defer: flag]; | 1522 | backing: backingType defer: flag]; |
| 1503 | contentView = [[FlippedView alloc] initWithFrame: [[self contentView] frame]]; | 1523 | contentView = [[FlippedView alloc] initWithFrame: [[self contentView] frame]]; |
| 1524 | [contentView autorelease]; | ||
| 1525 | |||
| 1504 | [self setContentView: contentView]; | 1526 | [self setContentView: contentView]; |
| 1505 | 1527 | ||
| 1506 | [[self contentView] setAutoresizesSubviews: YES]; | 1528 | [[self contentView] setAutoresizesSubviews: YES]; |
| @@ -1551,12 +1573,12 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) | |||
| 1551 | prototype: cell | 1573 | prototype: cell |
| 1552 | numberOfRows: 0 | 1574 | numberOfRows: 0 |
| 1553 | numberOfColumns: 1]; | 1575 | numberOfColumns: 1]; |
| 1554 | [[self contentView] addSubview: matrix]; | ||
| 1555 | [matrix release]; | ||
| 1556 | [matrix setFrameOrigin: NSMakePoint (area.origin.x, | 1576 | [matrix setFrameOrigin: NSMakePoint (area.origin.x, |
| 1557 | area.origin.y + (TEXTHEIGHT+3*SPACER))]; | 1577 | area.origin.y + (TEXTHEIGHT+3*SPACER))]; |
| 1558 | [matrix setIntercellSpacing: spacing]; | 1578 | [matrix setIntercellSpacing: spacing]; |
| 1579 | [matrix autorelease]; | ||
| 1559 | 1580 | ||
| 1581 | [[self contentView] addSubview: matrix]; | ||
| 1560 | [self setOneShot: YES]; | 1582 | [self setOneShot: YES]; |
| 1561 | [self setReleasedWhenClosed: YES]; | 1583 | [self setReleasedWhenClosed: YES]; |
| 1562 | [self setHidesOnDeactivate: YES]; | 1584 | [self setHidesOnDeactivate: YES]; |
| @@ -1735,12 +1757,6 @@ void process_dialog (id window, Lisp_Object list) | |||
| 1735 | } | 1757 | } |
| 1736 | 1758 | ||
| 1737 | 1759 | ||
| 1738 | - (void)dealloc | ||
| 1739 | { | ||
| 1740 | { [super dealloc]; return; }; | ||
| 1741 | } | ||
| 1742 | |||
| 1743 | |||
| 1744 | - (Lisp_Object)runDialogAt: (NSPoint)p | 1760 | - (Lisp_Object)runDialogAt: (NSPoint)p |
| 1745 | { | 1761 | { |
| 1746 | NSInteger ret; | 1762 | NSInteger ret; |