Mercurial > projects > dwt-linux
changeset 124:11b0a1324732
Fix various stack access from anon-class
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 20 Jan 2008 23:09:45 +0100 |
parents | 93492b9cae31 |
children | 1feb02b24d1c |
files | dwt/custom/CLabel.d dwt/custom/CTabFolder.d dwt/custom/StyledText.d dwt/dnd/ClipboardProxy.d dwt/widgets/Display.d dwt/widgets/Menu.d dwt/widgets/ScrollBar.d dwt/widgets/Scrollable.d dwt/widgets/Shell.d dwt/widgets/Table.d |
diffstat | 10 files changed, 53 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/custom/CLabel.d Sun Jan 20 22:21:53 2008 +0100 +++ b/dwt/custom/CLabel.d Sun Jan 20 23:09:45 2008 +0100 @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0
--- a/dwt/custom/CTabFolder.d Sun Jan 20 22:21:53 2008 +0100 +++ b/dwt/custom/CTabFolder.d Sun Jan 20 23:09:45 2008 +0100 @@ -1815,24 +1815,28 @@ } }); - addListener(DWT.Selection, new class() Listener { + addListener(DWT.Selection, new class(accessible) Listener { + Accessible acc; + this( Accessible acc ){ this.acc = acc; } public void handleEvent(Event event) { if (isFocusControl()) { if (selectedIndex is -1) { - accessible.setFocus(ACC.CHILDID_SELF); + acc.setFocus(ACC.CHILDID_SELF); } else { - accessible.setFocus(selectedIndex); + acc.setFocus(selectedIndex); } } } }); - addListener(DWT.FocusIn, new class() Listener { + addListener(DWT.FocusIn, new class(accessible) Listener { + Accessible acc; + this( Accessible acc ){ this.acc = acc; } public void handleEvent(Event event) { if (selectedIndex is -1) { - accessible.setFocus(ACC.CHILDID_SELF); + acc.setFocus(ACC.CHILDID_SELF); } else { - accessible.setFocus(selectedIndex); + acc.setFocus(selectedIndex); } } }); @@ -3865,7 +3869,7 @@ items[i].dispose(); } } - final char[] id = "CTabFolder_showList_Index"; //$NON-NLS-1$ + static const char[] id = "CTabFolder_showList_Index"; //$NON-NLS-1$ for (int i = 0; i < items.length; i++) { CTabItem tab = items[i]; if (tab.showing) continue;
--- a/dwt/custom/StyledText.d Sun Jan 20 22:21:53 2008 +0100 +++ b/dwt/custom/StyledText.d Sun Jan 20 23:09:45 2008 +0100 @@ -2130,11 +2130,13 @@ } Runnable timer = null; - final Display display = getDisplay(); + final Display disp = getDisplay(); // Set a timer that will simulate the user pressing and holding // down a cursor key (i.e., arrowUp, arrowDown). if (direction is DWT.UP) { - timer = new class() Runnable { + timer = new class(disp) Runnable { + Display display; + this( Display d ){ this.display = d; } public void run() { if (autoScrollDirection is DWT.UP) { doSelectionPageUp(autoScrollDistance); @@ -2145,7 +2147,9 @@ autoScrollDirection = direction; display.timerExec(V_SCROLL_RATE, timer); } else if (direction is DWT.DOWN) { - timer = new class() Runnable { + timer = new class(disp) Runnable { + Display display; + this( Display d ){ this.display = d; } public void run() { if (autoScrollDirection is DWT.DOWN) { doSelectionPageDown(autoScrollDistance); @@ -2156,7 +2160,9 @@ autoScrollDirection = direction; display.timerExec(V_SCROLL_RATE, timer); } else if (direction is ST.COLUMN_NEXT) { - timer = new class() Runnable { + timer = new class(disp) Runnable { + Display display; + this( Display d ){ this.display = d; } public void run() { if (autoScrollDirection is ST.COLUMN_NEXT) { doVisualNext(); @@ -2169,7 +2175,9 @@ autoScrollDirection = direction; display.timerExec(H_SCROLL_RATE, timer); } else if (direction is ST.COLUMN_PREVIOUS) { - timer = new class() Runnable { + timer = new class(disp) Runnable { + Display display; + this( Display d ){ this.display = d; } public void run() { if (autoScrollDirection is ST.COLUMN_PREVIOUS) { doVisualPrevious(); @@ -5562,9 +5570,11 @@ e.result = this.outer.getText(); } }); - addListener(DWT.FocusIn, new class() Listener { + addListener(DWT.FocusIn, new class(accessible) Listener { + Accessible acc; + this( Accessible acc ){ this.acc = acc; } public void handleEvent(Event event) { - accessible.setFocus(ACC.CHILDID_SELF); + acc.setFocus(ACC.CHILDID_SELF); } }); }
--- a/dwt/dnd/ClipboardProxy.d Sun Jan 20 22:21:53 2008 +0100 +++ b/dwt/dnd/ClipboardProxy.d Sun Jan 20 23:09:45 2008 +0100 @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -54,7 +54,7 @@ public void handleEvent(Event event) { ClipboardProxy clipbordProxy = cast(ClipboardProxy)disp.getData(ID); if (clipbordProxy is null) return; - display.setData(ID, null); + disp.setData(ID, null); clipbordProxy.dispose(); } });
--- a/dwt/widgets/Display.d Sun Jan 20 22:21:53 2008 +0100 +++ b/dwt/widgets/Display.d Sun Jan 20 23:09:45 2008 +0100 @@ -3605,8 +3605,8 @@ OS.gtk_label_set_text (preeditLabel, preeditString); Point point = control.toDisplay (control.getIMCaretPos ()); OS.gtk_window_move (preeditWindow, point.x, point.y); - GtkRequisition* requisition = new GtkRequisition (); - OS.gtk_widget_size_request (cast(GtkWidget*)preeditLabel, requisition); + GtkRequisition requisition; + OS.gtk_widget_size_request (cast(GtkWidget*)preeditLabel, &requisition); OS.gtk_window_resize (preeditWindow, requisition.width, requisition.height); OS.gtk_widget_show (cast(GtkWidget*)preeditWindow); } else {
--- a/dwt/widgets/Menu.d Sun Jan 20 22:21:53 2008 +0100 +++ b/dwt/widgets/Menu.d Sun Jan 20 23:09:45 2008 +0100 @@ -705,8 +705,8 @@ * * NOTE: This code doesn't work for multiple monitors. */ - GtkRequisition* requisition = new GtkRequisition (); - OS.gtk_widget_size_request (cast(GtkWidget*)menu, requisition); + GtkRequisition requisition; + OS.gtk_widget_size_request (cast(GtkWidget*)menu, &requisition); int screenHeight = OS.gdk_screen_height (); int reqy = this.y; if (reqy + requisition.height > screenHeight && reqy - requisition.height >= 0) {
--- a/dwt/widgets/ScrollBar.d Sun Jan 20 22:21:53 2008 +0100 +++ b/dwt/widgets/ScrollBar.d Sun Jan 20 23:09:45 2008 +0100 @@ -287,8 +287,8 @@ public Point getSize () { checkWidget (); if (handle is null) return new Point (0,0); - GtkRequisition* requisition = new GtkRequisition (); - OS.gtk_widget_size_request (handle, requisition); + GtkRequisition requisition; + OS.gtk_widget_size_request (handle, &requisition); return new Point (requisition.width, requisition.height); }
--- a/dwt/widgets/Scrollable.d Sun Jan 20 22:21:53 2008 +0100 +++ b/dwt/widgets/Scrollable.d Sun Jan 20 23:09:45 2008 +0100 @@ -251,8 +251,7 @@ scrollBar = horizontalBar; } if (scrollBar !is null && !OS.GTK_WIDGET_VISIBLE (scrollBar.handle) && scrollBar.getEnabled()) { - GtkAdjustment* adjustment = new GtkAdjustment (); - memmove (adjustment, scrollBar.adjustmentHandle, GtkAdjustment.sizeof ); + GtkAdjustment* adjustment = scrollBar.adjustmentHandle; /* Calculate wheel delta to match GTK+ 2.4 and higher */ int wheel_delta = cast(int) Math.pow(adjustment.page_size, 2.0 / 3.0); if (gdkEvent.direction is OS.GDK_SCROLL_UP || gdkEvent.direction is OS.GDK_SCROLL_LEFT) @@ -270,8 +269,8 @@ if (horizontalBar is null) return 0; auto hBarHandle = OS.GTK_SCROLLED_WINDOW_HSCROLLBAR(cast(GtkScrolledWindow*)scrolledHandle); if (hBarHandle is null) return 0; - GtkRequisition* requisition = new GtkRequisition(); - OS.gtk_widget_size_request(cast(GtkWidget*)hBarHandle, requisition); + GtkRequisition requisition; + OS.gtk_widget_size_request(cast(GtkWidget*)hBarHandle, &requisition); int spacing = OS.GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(cast(GtkScrolledWindow*)scrolledHandle); return requisition.height + spacing; } @@ -378,8 +377,8 @@ if (verticalBar is null) return 0; auto vBarHandle = OS.GTK_SCROLLED_WINDOW_VSCROLLBAR(cast(GtkScrolledWindow*)scrolledHandle); if (vBarHandle is null) return 0; - GtkRequisition* requisition = new GtkRequisition(); - OS.gtk_widget_size_request (cast(GtkWidget*)vBarHandle, requisition); + GtkRequisition requisition; + OS.gtk_widget_size_request (cast(GtkWidget*)vBarHandle, &requisition); int spacing = OS.GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(cast(GtkScrolledWindow*)scrolledHandle); return requisition.width + spacing; }
--- a/dwt/widgets/Shell.d Sun Jan 20 22:21:53 2008 +0100 +++ b/dwt/widgets/Shell.d Sun Jan 20 23:09:45 2008 +0100 @@ -804,15 +804,15 @@ } void forceResize (int width, int height) { - GtkRequisition* requisition = new GtkRequisition (); - OS.gtk_widget_size_request (vboxHandle, requisition); - GtkAllocation* allocation = new GtkAllocation (); + GtkRequisition requisition; + OS.gtk_widget_size_request (vboxHandle, &requisition); + GtkAllocation allocation; int border = OS.gtk_container_get_border_width (cast(GtkContainer*)shellHandle); allocation.x = border; allocation.y = border; allocation.width = width; allocation.height = height; - OS.gtk_widget_size_allocate (cast(GtkWidget*)vboxHandle, allocation); + OS.gtk_widget_size_allocate (cast(GtkWidget*)vboxHandle, &allocation); } override public Point getLocation () {
--- a/dwt/widgets/Table.d Sun Jan 20 22:21:53 2008 +0100 +++ b/dwt/widgets/Table.d Sun Jan 20 23:09:45 2008 +0100 @@ -545,7 +545,8 @@ if (newModel is null) error (DWT.ERROR_NO_HANDLES); void* ptr; for (int i=0; i<itemCount; i++) { - GtkTreeIter* newItem = new GtkTreeIter; + GtkTreeIter* newItem = cast(GtkTreeIter*)OS.g_malloc( GtkTreeIter.sizeof ); + if (newItem is null) error (DWT.ERROR_NO_HANDLES); OS.gtk_list_store_append (newModel, newItem); TableItem item = items [i]; if (item !is null) { @@ -559,7 +560,7 @@ OS.g_free (oldItem); item.handle = cast(GtkWidget*)newItem; } else { - delete (newItem); + OS.g_free (newItem); } } OS.gtk_tree_view_set_model (handle, newModel); @@ -987,7 +988,7 @@ if (newModel is null) error (DWT.ERROR_NO_HANDLES); void* ptr; for (int i=0; i<itemCount; i++) { - GtkTreeIter* newItem = new GtkTreeIter; + GtkTreeIter* newItem = cast(GtkTreeIter*) OS.g_malloc( GtkTreeIter.sizeof ); if (newItem is null) error (DWT.ERROR_NO_HANDLES); OS.gtk_list_store_append (newModel, newItem); TableItem item = items [i]; @@ -1012,7 +1013,7 @@ OS.g_free (oldItem); item.handle = cast(GtkWidget*) newItem; } else { - delete newItem; + OS.g_free( newItem ); } } OS.gtk_tree_view_set_model (handle, newModel); @@ -1488,7 +1489,7 @@ return h; } else { int height = 0; - GtkTreeIter* iter = new GtkTreeIter; + GtkTreeIter* iter = cast(GtkTreeIter*) OS.g_malloc( GtkTreeIter.sizeof ); OS.gtk_tree_model_get_iter_first (modelHandle, iter); int columnCount = Math.max (1, this.columnCount); for (int i=0; i<columnCount; i++) { @@ -1498,7 +1499,7 @@ OS.gtk_tree_view_column_cell_get_size (column, null, null, null, &w, &h); height = Math.max (height, h ); } - delete iter; + OS.g_free(iter); return height; } }