Skip to content
This repository was archived by the owner on Sep 7, 2021. It is now read-only.

Commit 4d6ed72

Browse files
committed
Merge branch 'release-6.0.2'
2 parents cb2d2d2 + 8e5ce9e commit 4d6ed72

7 files changed

Lines changed: 94 additions & 37 deletions

File tree

engine/src/fields.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -755,12 +755,14 @@ void MCField::getlinkdata(MCRectangle &lrect, MCBlock *&sb, MCBlock *&eb)
755755

756756
// MW-2011-02-26: [[ Bug 9416 ]] Make sure the linkrect and block extends to the
757757
// extremities of the link.
758+
// MW-2013-05-21: [[ Bug 10794 ]] Make sure we update sb/eb with the actual blocks
759+
// the indices are within.
758760
uint2 t_index;
759761
t_index = (uint2)si;
760-
sptr -> extendup(sb, t_index);
762+
sb = sptr -> extendup(sb, t_index);
761763
si = t_index;
762764
t_index = (uint2)(ei - 1);
763-
sptr -> extenddown(eb, t_index);
765+
eb = sptr -> extenddown(eb, t_index);
764766
ei = t_index;
765767

766768
linksi += si;
@@ -1014,8 +1016,9 @@ Exec_stat MCField::gettextatts(uint4 parid, Properties which, MCExecPoint &ep, M
10141016
// making sure the ranges are adjusted to the start of the range.
10151017
sptr -> getflaggedranges(parid, ep, si, ei, t_index_offset);
10161018

1017-
// Increment the offset by the size of the paragraph.
1018-
t_index_offset += sptr -> gettextsizecr();
1019+
// MW-2013-05-22: [[ Bug 10908 ]] Increment the offset by the size of the
1020+
// paragraph in codepoints not bytes.
1021+
t_index_offset += sptr -> gettextlength() + 1;
10191022

10201023
// Reduce ei until we get to zero, advancing through the paras.
10211024
si = 0;

engine/src/imagebitmap.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,17 @@ static bool check_bounds(MCImageBitmap *p_bitmap, int32_t x, int32_t y, uint32_t
4242

4343
static void clamp_region(MCImageBitmap *p_bitmap, int32_t &x, int32_t &y, uint32_t &width, uint32_t &height)
4444
{
45-
x = MCMax(0, x);
46-
y = MCMax(0, y);
45+
int32_t t_x1, t_y1, t_x2, t_y2;
4746

48-
width = MCMin((int32_t)p_bitmap->width - x, (int32_t)width);
49-
height = MCMin((int32_t)p_bitmap->height - y, (int32_t)height);
47+
t_x1 = MCMax(0, MCMin((int32_t)p_bitmap->width, x));
48+
t_y1 = MCMax(0, MCMin((int32_t)p_bitmap->height, y));
49+
t_x2 = MCMax(0, MCMin((int32_t)p_bitmap->width, x + (int32_t)width));
50+
t_y2 = MCMax(0, MCMin((int32_t)p_bitmap->height, y + (int32_t)height));
51+
52+
x = t_x1;
53+
y = t_y1;
54+
width = t_x2 - t_x1;
55+
height = t_y2 - t_y1;
5056
}
5157

5258
bool MCImageBitmapCreate(uindex_t p_width, uindex_t p_height, MCImageBitmap *&r_bitmap)
@@ -173,17 +179,20 @@ void MCImageBitmapCopyRegionToBitmap(MCImageBitmap *p_dst, MCImageBitmap *p_src,
173179
int32_t t_dst_x, t_dst_y;
174180
uint32_t t_width, t_height;
175181

176-
t_src_x = MCMax(0, p_src_rect.x);
177-
t_src_y = MCMax(0, p_src_rect.y);
182+
t_src_x = p_src_rect.x;
183+
t_src_y = p_src_rect.y;
184+
185+
t_width = p_src_rect.width;
186+
t_height = p_src_rect.height;
178187

179-
t_dst_x = MCMax(0, p_dst_offset.x);
180-
t_dst_y = MCMax(0, p_dst_offset.y);
188+
t_dst_x = p_dst_offset.x;
189+
t_dst_y = p_dst_offset.y;
181190

182-
t_width = MCMin((int32_t)p_src->width - t_src_x, (int32_t)p_src_rect.width);
183-
t_height = MCMin((int32_t)p_src->height - t_src_y, (int32_t)p_src_rect.height);
191+
clamp_region(p_src, t_src_x, t_src_y, t_width, t_height);
192+
clamp_region(p_dst, t_dst_x, t_dst_y, t_width, t_height);
184193

185-
t_width = MCMin((int32_t)p_dst->width - t_dst_x, (int32_t)t_width);
186-
t_height = MCMin((int32_t)p_dst->height - t_dst_y, (int32_t)t_height);
194+
if (t_width == 0 || t_height == 0)
195+
return;
187196

188197
copy_bitmap_data((uint8_t*)p_dst->data + p_dst->stride * t_dst_y + t_dst_x * sizeof(uint32_t), p_dst->stride, (uint8_t*)p_src->data + p_src->stride * t_src_y + t_src_x * sizeof(uint32_t), p_src->stride, t_width, t_height);
189198

engine/src/mbliphoneextra.mm

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@
5353

5454
#include "mblstore.h"
5555

56+
#import <objc/message.h>
57+
5658
////////////////////////////////////////////////////////////////////////////////
5759

5860
// global counter for the iPhone idle timer
5961
uint g_idle_timer = 0;
6062

61-
id objc_lookUpClass(const char *name);
62-
6363
bool MCParseParameters(MCParameter*& p_parameters, const char *p_format, ...)
6464
{
6565
MCExecPoint ep(nil, nil, nil);
@@ -949,12 +949,30 @@ static Exec_stat MCHandleClearTouches(void *context, MCParameter *p_parameters)
949949

950950
////////////////////////////////////////////////////////////////////////////////
951951

952-
static Exec_stat MCHandeSystemIdentifier(void *context, MCParameter *p_parameters)
952+
static Exec_stat MCHandleSystemIdentifier(void *context, MCParameter *p_parameters)
953953
{
954-
NSString *t_identifier = nil;
955-
t_identifier = [[UIDevice currentDevice] uniqueIdentifier];
956-
MCresult -> copysvalue([t_identifier cStringUsingEncoding: NSMacOSRomanStringEncoding]);
957-
return ES_NORMAL;
954+
// MM-2013-05-21: [[ Bug 10895 ]] The method uniqueIdentifier of UIDevice is now deprecated (as of May 2013).
955+
// Calling the method dynamically prevents apps from being rejected by the app store
956+
// but preserves functionality for testing and backwards compatibility.
957+
NSString *t_identifier;
958+
t_identifier = objc_msgSend([UIDevice currentDevice], sel_getUid("uniqueIdentifier"));
959+
MCresult -> copysvalue([t_identifier cStringUsingEncoding: NSMacOSRomanStringEncoding]);
960+
return ES_NORMAL;
961+
}
962+
963+
// MM-2013-05-21: [[ Bug 10895 ]] Added iphoneIdentifierForVendor as an initial replacement for iphoneSystemIdentifier.
964+
// identifierForVendor was only added to UIDevice in iOS 6.1 so make sure we weakly link.
965+
static Exec_stat MCHandleIdentifierForVendor(void *context, MCParameter *p_parameters)
966+
{
967+
if ([UIDevice instancesRespondToSelector:@selector(identifierForVendor)])
968+
{
969+
NSString *t_identifier;
970+
t_identifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
971+
MCresult -> copysvalue([t_identifier cStringUsingEncoding: NSMacOSRomanStringEncoding]);
972+
}
973+
else
974+
MCresult -> clear();
975+
return ES_NORMAL;
958976
}
959977

960978
static Exec_stat MCHandleApplicationIdentifier(void *context, MCParameter *p_parameters)
@@ -1380,8 +1398,12 @@ static Exec_stat MCHandleSetAnimateAutorotation(void *context, MCParameter *p_pa
13801398
{false, "iphoneClearTouches", MCHandleClearTouches, nil},
13811399
{false, "mobileClearTouches", MCHandleClearTouches, nil},
13821400

1383-
{false, "iphoneSystemIdentifier", MCHandeSystemIdentifier, nil},
1401+
{false, "iphoneSystemIdentifier", MCHandleSystemIdentifier, nil},
13841402
{false, "iphoneApplicationIdentifier", MCHandleApplicationIdentifier, nil},
1403+
1404+
// MM-2013-05-21: [[ Bug 10895 ]] Added iphoneIdentifierForVendor as an initial replacement for iphoneSystemIdentifier.
1405+
{false, "mobileIdentifierForVendor", MCHandleIdentifierForVendor, nil},
1406+
{false, "iphoneIdentifierForVendor", MCHandleIdentifierForVendor, nil},
13851407

13861408
{false, "iphoneSetReachabilityTarget", MCHandleSetReachabilityTarget, nil},
13871409
{false, "iphoneReachabilityTarget", MCHandleReachabilityTarget, nil},

engine/src/mbliphoneinput.mm

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,13 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
630630
void MCNativeInputFieldControl::DeleteView(UIView *p_view)
631631
{
632632
[p_view setDelegate: nil];
633-
[p_view release];
634633

634+
// MW-2013-05-22: [[ Bug 10880 ]] Make sure we release the delegate here as
635+
// it might need to refer to the view to deregister itself.
635636
[m_delegate release];
636637
m_delegate = nil;
638+
639+
[p_view release];
637640
}
638641

639642
////////////////////////////////////////////////////////////////////////////////
@@ -882,10 +885,13 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
882885
void MCNativeMultiLineControl::DeleteView(UIView *p_view)
883886
{
884887
[p_view setDelegate: nil];
885-
[p_view release];
886888

889+
// MW-2013-05-22: [[ Bug 10880 ]] Make sure we release the delegate here as
890+
// it might need to refer to the view to deregister itself.
887891
[m_delegate release];
888892
m_delegate = nil;
893+
894+
[p_view release];
889895
}
890896

891897
////////////////////////////////////////////////////////////////////////////////
@@ -1133,6 +1139,15 @@ - (id)initWithInstance:(MCNativeInputControl *)instance view:(UIView *)view
11331139
return self;
11341140
}
11351141

1142+
// MW-2013-05-22: [[ Bug 10880 ]] Make sure we have a 'dealloc' method so observers
1143+
// can be removed that reference this object.
1144+
- (void)dealloc
1145+
{
1146+
[m_instance -> GetView() removeObserver: self forKeyPath:@"contentSize"];
1147+
[super dealloc];
1148+
}
1149+
1150+
11361151
- (void)scrollViewWillBeginDragging: (UIScrollView*)scrollView
11371152
{
11381153
MCCustomEvent *t_event;

engine/src/objectprops.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ Exec_stat MCObject::setscriptprop(MCExecPoint& ep)
850850
else
851851
{
852852
char *oldscript = script;
853+
bool t_old_script_encrypted = m_script_encrypted;
853854
if (data.getstring()[length - 1] != '\n')
854855
{
855856
script = new char[length + 2];
@@ -860,6 +861,8 @@ Exec_stat MCObject::setscriptprop(MCExecPoint& ep)
860861
else
861862
script = data.clone();
862863

864+
// IM-2013-05-29: [[ BZ 10916 ]] flag new script as unencrypted
865+
m_script_encrypted = false;
863866
getstack() -> securescript(this);
864867

865868
flags |= F_SCRIPT;
@@ -873,6 +876,7 @@ Exec_stat MCObject::setscriptprop(MCExecPoint& ep)
873876
hlist = NULL;
874877
delete script;
875878
script = oldscript;
879+
m_script_encrypted = t_old_script_encrypted;
876880
oldscript = NULL;
877881
if (script == NULL)
878882
flags &= ~F_SCRIPT;

engine/src/paragraf.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3021,7 +3021,9 @@ void MCParagraph::getxextents(int4 &si, int4 &ei, int2 &minx, int2 &maxx)
30213021
ei -= gettextsizecr();
30223022
}
30233023

3024-
Boolean MCParagraph::extendup(MCBlock *bptr, uint2 &si)
3024+
// MW-2013-05-21: [[ Bug 10794 ]] Changed signature to return the block the search
3025+
// ends up in.
3026+
MCBlock *MCParagraph::extendup(MCBlock *bptr, uint2 &si)
30253027
{
30263028
Boolean isgroup = True;
30273029
Boolean found = False;
@@ -3046,10 +3048,12 @@ Boolean MCParagraph::extendup(MCBlock *bptr, uint2 &si)
30463048
bptr = bptr->next();
30473049
uint2 l;
30483050
bptr->getindex(si, l);
3049-
return found;
3051+
return bptr;
30503052
}
30513053

3052-
Boolean MCParagraph::extenddown(MCBlock *bptr, uint2 &ei)
3054+
// MW-2013-05-21: [[ Bug 10794 ]] Changed signature to return the block the search
3055+
// ends up in.
3056+
MCBlock *MCParagraph::extenddown(MCBlock *bptr, uint2 &ei)
30533057
{
30543058
Boolean isgroup = True;
30553059
Boolean found = False;
@@ -3075,7 +3079,7 @@ Boolean MCParagraph::extenddown(MCBlock *bptr, uint2 &ei)
30753079
uint2 l;
30763080
bptr->getindex(ei, l);
30773081
ei += l;
3078-
return found;
3082+
return bptr;
30793083
}
30803084

30813085
void MCParagraph::getclickindex(int2 x, int2 y,

engine/src/paragraf.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -739,13 +739,13 @@ class MCParagraph : public MCDLlist
739739

740740
MCLine *indextoline(uint2 tindex);
741741

742-
// Returns true if the given block is part of a link, in which case si is
743-
// the start index of the link.
744-
Boolean extendup(MCBlock *bptr, uint2 &si);
745-
746-
// Returns true if the given block is part of a link, in which case ei is
747-
// the end index of the link.
748-
Boolean extenddown(MCBlock *bptr, uint2 &ei);
742+
// Searches forward for the end of a link, returning the last index in si
743+
// and returning the block containing it.
744+
MCBlock *extendup(MCBlock *bptr, uint2 &si);
745+
746+
// Searches backward for the start of a link, returning the first index in ei
747+
// and returning the block containing it.
748+
MCBlock *extenddown(MCBlock *bptr, uint2 &ei);
749749

750750
int2 getx(uint2 tindex, MCLine *lptr);
751751

0 commit comments

Comments
 (0)