w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Using the same instance of an object as the argument and as the calling object in calling a function
This will not be a problem functionally, but logically if the function must take an object as an argument, you should make this function static. In addition, since you are not modifying the incoming object, you should make the argument const. Finally, since copying the object may be more expensive than copying a reference, you may want to change the argument to be passed by reference. static void Complex::magnitude(const Complex &c); ... Complex myComplex(...); Complex::magnitude(myComplex);

Categories : C++

C# Calling C function crash when using LoadLibrary/GetProcAddress
Shouldn't this line: Normalize = (CallNormalize)Marshal.GetDelegateForFunctionPointer( pDll, typeof(CallNormalize)); be Normalize = (CallNormalize)Marshal.GetDelegateForFunctionPointer( pAddressOfNormalize, typeof(CallNormalize));

Categories : C#

Why does my program crash immediately after calling delegate?
#define SDLCALL __cdecl You have a calling convention mismatch. Your native code requires a __cdecl function but your C# code declares a delegate that will be mapped to a an __stdcall callback. The default for unmanaged code interop. You must declare it like this: [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate int EventFilter(IntPtr userData, IntPtr type);

Categories : C#

Crash when calling optional protocol method
All the @optional directive does is suppresses compiler warnings if the optional methods are not implemented. However, if you call a method that the class does not implement, the app will still crash, as the selector (method) you tried to call is not recognised by the class, since it's not implemented. You can work around this by checking whether the delegate implements a method before calling it: // Check that the object that is set as the delegate implements the method you are about to call if ([self.photoDropDownDelegate respondsToSelector:@selector(dismissPhotoDropDown)]) { // The object does implement the method, so you can safely call it. [self.photoDropDownDelegate dismissPhotoDropDown]; } This way, if the delegate object implements an optional method, it will be called.

Categories : Iphone

App crash when running on iPhone 4.3 simulator after calling initWithNibName
FavoritesActivityViewController *favorites = [[FavoritesActivityViewController alloc]initWithNibName:@"FavoritesActivityViewController" bundle:nil]; [self.view addSubview:favorites.view]; Try this code...

Categories : Iphone

Native Crash in Android 4.3 when calling Picture.writeToStream()
I would have added this as a comment but I lack the reputation... The breaking change in Skia appears to be the change to SkImageRef_ashmem.cpp: https://code.google.com/p/skia/source/detail?r=4980 The flatten method used to check for a null URI and would write 0 to the output stream if the uri was null. Passing null to SkFlattenableWriteBuffer::writeString() results in the crash in strlen().

Categories : Android

Gradient Color to CGPath
This answer shows you how to fill a path with a gradient using both Core Graphics and using layers. In short what you need to do for your layers is to mask the gradient layer with a shape layer. If you are using strokes or shadows you also need an outer shape layer (not masked).

Categories : IOS

Getting issue in CGPath Scale
The problem is that you're used to UIView transformation, which is done from the center of the view. CGPath transformation is done on the points (imagine CGPointZero as the center of the path). My solution: translate to CGPointZero , scale , and then back to your original coordinates. CGPathRef CGPath_NGCreateCopyByScalingPathAroundCentre(CGPathRef path, const float scale) { CGRect bounding = CGPathGetPathBoundingBox(path); CGPoint pathCenterPoint = CGPointMake(CGRectGetMidX(bounding), CGRectGetMidY(bounding)); CGAffineTransform translateAndScale = CGAffineTransformTranslate( CGAffineTransformMakeScale(scale, scale), - pathCenterPoint.x, -pathCenterPoint.y) ; CGAffineTransform translateBack = CGAffineTransformMakeTranslation(path

Categories : IOS

Get the UIBezierPath or CGPath from CGContextRef
You can copy the context's current path using CGContextCopyPath. There is no function that copies the clipping path. Indeed, the clipping region won't be defined by a path if you've used CGContextClipToMask.

Categories : IOS

Reposition CGPath/UIBezierPath in View
From your question it sounds like you are drawing the path using Core Graphics inside drawRect: (as compared to using a CAShapeLayer) so I'll explain the version first. Moving a CGPath You can create a new path by transforming another path. A translation transform moves the transformed object a certain distance in x and y. So using a translation transform you can move your existing path a certain number of points in both x and y. CGAffineTransform translation = CGAffineTransformMakeTranslation(xPixelsToMove, yPixelsToMove); CGPathRef movedPath = CGPathCreateCopyByTransformingPath(originalCGPath, &translation); Then you could use the movedPath to draw the same w

Categories : IOS

CGPath does not recognize a click inside of it
Use this CGContextPathContainsPoint(context, point, mode) //the names of the parameters are explanatory use mode=kCGPathStroke; call a function inside it make a path in loop and call the above method on the path first make a path.

Categories : Iphone

CGPath adding a curve between points
CGPathAddCurveToPoint adds a cubic curve to the bezier path. In the case you don't know it, it's made in a way that the shape of the curve is determined by two control points (uses a third grade equation for the curve). If you want the curve to have a particular shape, then you need to calculate two intermediate points, biased on the value of the path current point, and the curve end point. If instead you don't care about having a curve with a particular shape, you can just pick some random points. This is an implementation example: for (int i=1; i < coordinates.count; i++) { point = [[coordinates objectAtIndex:i] CGPointValue]; CGPathAddCurveToPoint(path, 0, randomX(), randomY(), randomX(), randomY(), point.x, point.y); } I see the you used CGPath, but you can also use OOP

Categories : Objective C

Benefits of calling hasOwnProperty as a direct static reference with the call method, as opposed to calling it as an object instance method
Because you can make an object that looks like this: var obj = { hasOwnProperty: function () { throw new Error("you are ugly"); } }; ie. you can accidentally, or intentionally redefine the function. Source on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty#hasOwnProperty_as_a_property

Categories : Javascript

Adding Bezier path to CGPath: ObjectiveC
Try: CGPathAddPath(aPath, nil, path.CGPath); Where aPath is your mutable CGPath and path is your UIBezierPath.

Categories : Objective C

CGPath stroke lineWidth is inconsistent with CAShapeLayer
I ran into the same problem myself. Later I found out that the problem was this line of code: shapeLayer.lineCap = kCALineCapSquare; it caused the width of the line became doubled in every directions, left, right, top and bottom. If it was set as lineWidth = 2, its width will be +1 to its left and right. +1 to its top and bottom. The way to fix this is to leave the lineCap be. Use the default value: kCALineCapButt.

Categories : Objective C

How can I exactly know which object caused my crash?
You can figure out where the crash happens by setting exception breakpoint in your breakpoint navigator. Now enable the breakpoints and run your code. Now It stops at the step where the crash happens.

Categories : IOS

Ember.js & QUnit : "TypeError: Object # has no method 'getHandler'" when calling visit
You should go read http://emberjs.com/guides/testing/integration/ With the newest Ember you don't need to run App.advanceReadiness, only the App.reset in the teardown, and before defining any test suite, you need to call: App.rootElement = '#qunit-fixtures'; App.setupForTesting(); App.injectTestHelpers(); And all should work fine. Lemme know if following this is not working, and if so give a jsbin I could work on ;-) EDIT Also I'm not sure that would change anything but in their exemples they're using andThen instead of then: visit('/'); andThen(function(){ ... });

Categories : Javascript

Crash when removing an object from NSMutableArray
It seems that titlesTagArrays list not an NSMutableArray because removeObject can not be called. Maybe you passed an NSArray earlier in the code to titlesTagArreys. try to init your Array with self.titlesTagArreys = [NSMutableArray arrayWithArray:@[@"...",@"...",...]]; @property(nonatomic, copy) makes a not mutable copy of you NSMutableArray. try @property(nonatomic, retain) instead of copy

Categories : Objective C

iOS Facebook Login "object nil" crash
While there appear to be no references in your code to setting values in an NSMutableDictionary, the terminating message is probably referring to the fact you cannot pass nil as a key to the setObject:forKey: method. It would help to post a stack trace but in that absence, look for calls to setObject:forKey and verify that the forKey argument is non-nil.

Categories : IOS

Adding an object to NSMutableArray causing crash
It looks like [dateAndTimeFormatter dateFromString:@"2013-07-08 20:26:00 +0000"] is returning nil because your date string "2013-07-08 20:26:00 +0000" does not match your dateFormat: @"dd-MM-yyyy HH:mm" ... try running after replacing: [dateAndTimeFormatter setDateFormat:@"dd-MM-yyyy HH:mm"] with [dateAndTimeFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss ZZZ"] // you really want this to match: 2013-07-08 20:26:00 +0000 // yyyy: 2013, four digit year // MM: two digit numerical month // dd: day of month // HH: 24 hour hour // mm: two digit minute // ss: two digit second, zero padded // ZZZ: time zone, {Z,Z,Z} -> RFC 822 GMT format Format strings for Date Formats given here: http://www.unicode.org/reports/tr35/tr35-25.html#Date_Field_Symbol_Table Timezone string acquired from: ht

Categories : Objective C

How to konw where crash for postNotificationName:object:userInfo
Almost certainly an object registered with the notification centre to receive that notification and then failed to deregister before deallocation. The easiest way to catch the problem would be to enable NSZombies — see e.g. this tutorial. If you run with zombies enabled then objects that should have been deallocated remain in memory but raise an exception if anyone attempts to call them. So you can figure out exactly what type of object the notification centre is attempting to call and therefore which object is probably making the mistake. Given the name of the origin of the notification — _handleApplicationSuspend:eventInfo: — you might also want to have a quick check of anyone registering for UIApplicationWillResignActiveNotification, UIApplicationDidEnterBackgroundNotification a

Categories : Iphone

SSE Access Violation crash on object creation
Error code 0xC0000005 is an access violation. When SSE is involved that invariably means that you are attempting misaligned memory access. You'll need to work out which operation uses operands that are not aligned.

Categories : C++

Not releasing filter com object causing a crash
Leaked COM references are a sort of hard to nail down. Assuming that COM client - in your case VLC - is doing everything right (which might be not the case, but it's okay to start with this assumption), the problem is on your code. It is typically one of the two: You are dealing with raw pointers and there is somewhere no matching Release for AddRef done earlier There are circular references and object keep each other alive As you already see you have two objects floating around, a good strategy would be to identify what classes are they exactly, and trace reference counter changes to see where is the lost IUnknown::Release.

Categories : C++

App gets gets crash on release on array object in xcode
First you initialize the array variable NSMutableArray * array = [[NSMutableArray alloc] init]; And correctly at this point, you should release this variable at some point. But, when you write array= [[dbSingleton sharedInstance] getAll_Players]; You overwrite the array variable you just allocated, and array is now not something you should release here, unless you also call retain on the array you get from getAll_Players. To fix the issue you should do it like this: -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{ NSMutableArray * array = [[dbSingleton sharedInstance] getAll_Players]; NSMutableDictionary * dict = [array objectAtIndex:row]; NSString * autoID = [dict objectForKey:@"autoId"]; NSLog(@"%@",[NSString stringWit

Categories : Iphone

iOS OpenGL ES Crash loading same object multiple times
What i needed to do, was to delete the GLKView drawables. In the ViewDidDisappear method (might not be the proper place, but it works) add the following: GLKView *view = (GLKView*) self.view; [view deleteDrawable];

Categories : IOS

Crash when object deallocated while running a background thread
That block has a strong reference to self. The only way self could be deallocated is if you are over-releasing it elsewhere (as @Catfish_Man indicated). if you have a crash, post the backtrace of the crash if you have an over-release crash, use Instruments to track all retain/release events on the object. run the analyzer and fix any problems it indicates.

Categories : Iphone

Is it possible to redraw (change fill color or apply transformation) a single CGPath or everything must be redrawn?
Luis, It is not possible to do that. You need to redraw the entire region that has been exposed. If there was a single item that you expect will change a lot, but the rest will remain static, you could use two different views or layers. One would contain the static context and the other would contain the updated context. The one with the updated context would have a transparent background, and you would position this on top of the other. That way, you would only redraw that view/layer.

Categories : IOS

set variable in calling object from object being called
Pass in a reference to the object. public class Another{ void someFunc(Example ob){ ob.setThisInt(5); ob.setThatInt(2); } } If you're using nested classes(one class inside the other with an implied parent-child relationship), use: OuterClass.this.setThisInt(5); and so on.

Categories : Java

Calling object function through object pointers
The type of an element in your array is Units*. You declared it that way: Units* Detector[fullwidth][fullheight] - a two-dimensional array of Units*. The address of a Units* is type Units**.

Categories : C++

How can I fix an app crash which is irreproducible? Crash report and console log attached
You error message said: [__NSArrayM objectAtIndex:]: index 0 beyond bounds . The reason probably is that using an NSMUtableArray (__NSArrayM) is not thread safe, see here. Without any code provided, I suggest that you read the Threading Programming Guide cited very carefully, and correct your code accordingly.

Categories : IOS

C# Application does not crash in VS BUT CRASH on system running
Your program is likely throwing an exception, and it's getting written to the console, but you don't have anything from stopping the console from closing immediately after the message is written. Add a Console.ReadKey(); after your try/catch block.

Categories : C#

Calling multiple methods on a CSV object
The reason you're experiencing this problem is because when you apply each to the result of CSV.open you're moving the file pointer each time. When you get to the end of the file with one of your methods, there is nothing for anyone else to read. An alternative is to read the contents of the file into an instance variable at initialization with readlines. You'll get an array of arrays which you can operate on with each just as easily.

Categories : Ruby

Calling function in C++ without creating an object
The call should be Controller::AlbumOps::SayHey(); // ^^ // double-colon You should put static on the in-class function declaration, not the out-of-class function definition (where it means something completely different, "internal linkage"). That is: in the header (AlbumOps.hpp): // ... namespace Controller { class AlbumOps { public: // ... static void SayHey(); // Note: 'static' here }; } // ... and in the implementation file (AlbumOps.cpp): either: // ... void Controller::AlbumOps::SayHey() // Note: no 'static' { cout << "Hey "; } // ... or: // ... namespace Controller { // ... void AlbumOps::SayHey() // Note: no 'static', no repeated 'Controller::' { cout <&

Categories : C++

How do I calling an object's method using strings?
You should store the object in a hashmap with key = name and value = object, then use b (name) to retrieve the right object from the hashmap. I'm still not sure what do you want to do with the second input, by my guess is that this answer covers that as well. h = Hash.new() h["trance x3"] = trance h["giro"] = giro ... puts "Which bike do you want information on?" b = gets() b.chomp! user_bike = h[b] puts "What information are you looking for?" i = gets() i.chomp! user_bike.send(i)

Categories : Ruby

using std::transform for calling object's function
std::transform is fine for this: std::vector<std::string> string_vec; const int magic_number = 42; std::transform(std::begin(vec), std::end(vec), std::back_inserter(string_vec), [magic_number](std::shared_ptr<A> a){ return a->foo(magic_number); } ); Obviously, you need to figure out which int you want to pass to A::foo(int). In C++03, you can replace the lambda by a functor or function: struct get_foo { get_foo(int n) : n_(n) {} bool operator() (std::shared_ptr<A> a) const { return a->foo(n); } private: int n_; }; const int magic_number = 42; std::vector<std::string> string_vec; std::transform(std::begin(vec), std::end(vec), std::back_inserter(string_vec), get_foo(m

Categories : C++

error calling the object from jquery plugin
You should use .find() method as your selector is invalid: $(self.elem).find('dd').hide(); When you use $(self.elem + ' dd') you basically want: $($(self.elem).selector + ' dd') but this is just wrong as you wrap twice element in jquery object and BTW, selector property of jquery object is deprecated. So simplest solution here is to search for descendants of self.element, you can then use .find() method or other method as .children() for direct descendants.

Categories : Jquery

Calling functions of a static member object in C++
Simple way to do this: Make a class called "AutoInitRNG", which seeds the default_random_engine in its constructor. And make that class a static member variable of Particle. Something like this: class AutoInitRNG { public: std::default_random_engine pRNG; AutoInitRNG() { pRNG.seed(time(NULL)); } }; class Particle { //... private: static AutoInitRNG RNG; };

Categories : C++

Calling Multiple Object/Variables "Name" with Looping
Instead of storing the values in individual variables, you can store them in an array: Public MyPasses As String() = New String() { "John", "Andrew", "Stewart", "Meiny", "Franco", "Hanks", "Buzz", "Timmy", "George", "Sanders" } You can then access via: Items.Add(MyPasses(c))

Categories : Vb.Net

The calling thread cannot access this object error
as the error says, you can't access the this object because a different thread owns it, so you can invoke that thread using Invoke(Delegate Method) you can check if invoke required using tempTab.InvokeRequired

Categories : C#

Dynamically calling an object's private functions
add is not a part of this. Therefore you cannot use this[testMethodFunction]. If you want to keep privacy, then you can use something like this: function test() { var actionCollection = []; var private_methods = { add: function( int1, int2 ) { return int1 + int2; } } this.callFunc = function( testMethodFunction, methodArguments ) { // note the change here! return private_methods[testMethodFunction].apply(null, methodArguments); } } var t = new test(); alert( t.callFunc( 'add', [1,2] ) );

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.