57 questions
0
votes
0
answers
164
views
How to reproduce C++ deleting destructor for a custom allocator?
I am aware that calling delete this in a member function is not UB in itself. In fact, compiler is doing the very same thing when one calls delete ptr, ptr being a pointer to a polymorphic object (...
1
vote
1
answer
70
views
Does selfdestruct in Solidity provide enough gas to execute a receive function?
I'm trying to understand how the receive function behaves when it's triggered by a selfdestruct call in Solidity. I've read that selfdestruct only provides 5000 gas for executing any fallback or ...
1
vote
1
answer
210
views
Releasing memory of std::function inside the function body
I need to pass a std::function as a void* pointer to be executed asynchronously, so I create a std::function on the heap. Is it safe to delete the std::function object from inside the function body?
...
1
vote
0
answers
140
views
Best practises for remotely self-destructing docker containers & volumes?
We have selections of docker containers that run as a client on a host remotely.
This then communicates with a single server that has a front-end and is in charge of multiple of these clusters.
We'd ...
0
votes
1
answer
371
views
How can I create an app which deletes itself?
How can i write a function that can remotely self-destruct it, ie delete that application from the phone?
Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:com....
2
votes
1
answer
582
views
How to update a value in destructing and loop
What I try to achieve:
I want to update a value in an obj, which is part of the element of array. See the code below will give you better idea.
There is an issue that I update the value of object, via ...
1
vote
2
answers
2k
views
Self-deleting PowerShell script deletes all contents but not the containing/parent folder
I'm trying to have the PowerShell 5.1 script self-delete itself, along with the entire folder contents (including subfolders). I'm using the below code, which works to a point. It does delete all of ...
7
votes
2
answers
772
views
When should a service worker self destruct?
I found this repo describing HOW to destroy a service worker. But I didn't find any resources describing WHEN a worker should destroy/uninstall/unregister itself.
When I develop websites, I often use ...
0
votes
0
answers
369
views
Can I send disappearing SMS on android device?
Is there anyway send a message which is not saved in the receivers message box and is removed after reading once?
I searched on google and find something like self-destructing message.
https://www....
3
votes
4
answers
917
views
Why does the destructor call itself endlessly (causing a stack overflow)?
I am confused on why the destructor calls itself an endless amount of times, when I try to construct an object say LeakySingleton on the heap through a static function call create_instance() and then ...
1
vote
0
answers
809
views
Self-destroying Python script [duplicate]
For no particular reason (mainly just the joy of experimentation), I'm looking for a way to write a python script, that self-destroys after execution. One simple approach would be to determine the ...
0
votes
0
answers
178
views
Is there a way to setup an self destructing value on Firebase real time database or firestore? [duplicate]
I'm working on a web app with firebase as backend and reactjs, and i want to create an self destructing value or at least an boolean value that changes after 24h. Is there a way to do it with firebase ...
2
votes
0
answers
2k
views
Error: Returned values aren't valid, did it run Out of Gas? on selfdestruct()
the code works fine, cause i'm following an online crash course. my problem is when i enter selfdestruct() it says something about an error, that i am unsure of what. please have a look, and see what ...
0
votes
1
answer
1k
views
Is there a way for an Excel workbook to self-destruct after user has entered wrong password 3x?
I know that an Excel workbook can be password protected. Is there a way to configure an Excel workbook to self-destruct or lock-out further attempts after a password has been entered incorrectly 3x?
1
vote
1
answer
2k
views
Self Delete Folder with scripts powershell
I have been trying to have powershell or batch scripts delete a folder that contains all my scripts when I am finished.
Originally I tried Remove-Item -Path "C:\Tool" -Recurse -Force which worked no ...
1
vote
2
answers
409
views
c++ returning into method of deleted object [duplicate]
This is a variation on the delete this debate, to do with what happens with intermediate method calls.
Basically, if method A calls method B, and method B destroys the object, does anything ...
1
vote
1
answer
129
views
Is a member function allowed to explicitly call its class destructor
Does the following code have a defined behavior ?
If not, what part of the code is UB and what section(s) of the standard states it is UB ?
If this code is UB, is there any [minor] change that can fix ...
-1
votes
2
answers
926
views
Can this reference in run() refer to Thread object when implementing Runnable?
Sorry if the question is unclear
I am making a simple multithread program that has a linked list to store all thread created except the main thread. Then I want to send some signal to terminate the ...
1
vote
2
answers
746
views
Self Modification of .exe c file after execution
I have a c code with a character array initialized to "hello world".
I would like to know if there is a possibility to re-initialize this character array upon each execution of the code, to some ...
1
vote
0
answers
140
views
Destroying object in member function C++ [duplicate]
class Base{
virtual void sth() =0;
virtual void destroy_me(){}
};
class Derived : public Base{
void sth(){}
void destroy_me(){
delete this;
}
};
Is this safe behavior if I am absolutely ...
2
votes
3
answers
688
views
How are self-destructing type erasure classes like std::function implemented?
I want to understand how the implementation of std::function works. For simplicity, let's consider move-only functions with no arguments.
I understand that std::function erases the type of its target ...
0
votes
0
answers
74
views
array key self destruct
I'm working on a game (sorta) where you can give numeric answers based on what your hear. As soon as a number gets called this number gets saved.
I require the score mechanism to allow the user to ...
0
votes
2
answers
63
views
Self deleting checklist not deleting items
I'm building a self-deleting checklist with Ruby on Rails that is supposed to automatically delete an item once it's expired after 7 days.
But the item just remains and goes into the negative ( -1, -2,...
-1
votes
1
answer
4k
views
How to make a object delete itself from a list. [closed]
So I have some objects in a list. I want to make my object to have a method that when called will delete itself from the list. How could I do that?
2
votes
2
answers
93
views
QObject selfdestruction aware container
Is there a Qt container, that is aware of the destroyed signal of QObject and removes the element if an element was destroyed?
I.e. like this:
QObject *obj1 = new MyObject();
QObject *obj2 = new ...
0
votes
1
answer
615
views
VB.Net Self Deletion after 5 days
Im have to execute the following code.
Dim Info As ProcessStartInfo = New ProcessStartInfo()
Info.Arguments = "/C ping 1.1.1.1 -n 1 -w 3000 > Nul & Del """ & Application.ExecutablePath....
2
votes
1
answer
2k
views
How can I remove an attribute from an element in angular?
How can I remove an attribute (or at least its value) using Angular? In specific, lets say I have an ng-click event. I want this even to only fire once and I think the easiest way to do this would be ...
0
votes
1
answer
1k
views
Java How to self destruct pdf and epub files?
Can I programatically add a meta data to set the timer for self destruction of pdf and epub documents ? Do I have to pay for that if I do it programatcially ?
3
votes
7
answers
2k
views
What will happen if a std::vector element 'commits suicide' (using delete this;)?
Suppose there's a vector of Items
vector<Item*> items; //{item1, item2, item3}
Then, in other part of the code,
items[1]->suicide();
where the suicide function is:
void Item::suicide()
{
...
0
votes
1
answer
693
views
Calling delete this from OnOk in MFC [duplicate]
Possible Duplicate:
Should “delete this” be called from within a member method?
Is is correct to call delete from OnOk event handler function, as in the code below.
void CTestDlg::OnOK()
{
...
34
votes
6
answers
43k
views
How to make scripts auto-delete at the end of execution?
Is it possible to make a python script that will delete the .py file at the end of its execution (self-delete) in windows?
14
votes
4
answers
12k
views
Self-destructing application
Along the lines of "This tape will self-destruct in five seconds. Good luck, Jim"...
Would it be possible for an application to delete itself (or it's executable wrapper form) once a preset time of ...
11
votes
5
answers
7k
views
Is it possible to write a self-destructive program in C?
Is it possible to write a program in C that upon execution deletes itself (the binary) and then terminates successfully. If so, what's the easiest way of doing this?
1
vote
4
answers
6k
views
Optimal way to self-delete QObjects
I have two classes Node and NodeContainer:
class Node: public QObject
{
NodeContainer* parent;
}
class NodeContainer : QObject
{
bool deleteChild(Node*child)
{
if(childNodes->...
14
votes
2
answers
10k
views
Self deleting bash script
How can a bash script execute even after encountering a statement to delete itself?
For eg when I ran test.sh script which conains:
<--some commands-->
rm test.sh
<--some more commands-->
...
2
votes
3
answers
2k
views
My code crashes on delete this
I get a segmentation fault when attempting to delete this.
I know what you think about delete this, but it has been left over by my predecessor. I am aware of some precautions I should take, which ...
3
votes
6
answers
2k
views
Lack of virtual destructor when doing "delete this"
Section 16.15 of the C++ FAQ Lite discusses delete this and then mentions:
Naturally the usual caveats apply in cases where your this pointer is
a pointer to a base class when you don't have a ...
2
votes
5
answers
897
views
delete this ? what does it do?
Given the following :
#include <iostream>
using namespace std;
class A
{
public:
void func() {delete this;}
A() : x(5) {cout << "ctor A" << endl;}
~A() {cout << "...
6
votes
2
answers
8k
views
Self-Deleting Script for both Linux Bash and Windows Batch
I have an uninstall script that cleans up an add-on tool used with an application.
Versions of the script run on both Windows and Linux.
I'd like to be able to delete the uninstall script file and ...
8
votes
3
answers
4k
views
Is it valid to directly call a (virtual) destructor?
In this answer, Ryan directly calls the virtual destructor. I've tested the code in VS2010, and it correctly calls all destructors (tested with logging statements). Is it actually valid to do so? What ...
31
votes
3
answers
12k
views
"delete this" in constructor
What actually happen when I execute this code?
class MyClass
{
MyClass()
{
//do something
delete this;
}
}
7
votes
3
answers
3k
views
Object-Oriented Suicide or delete this;
The following code compiled with MSVC9.0 runs and outputs Destructor four times, which is logical.
#include <iostream>
class SomeClass
{
public:
void CommitSuicide()
{
delete this;
...
1
vote
2
answers
847
views
Suicide: Objective-C objects calling their own -dealloc methods on themselves
Is it good practice for an object in Objective-C to commit suicide? That is, for an object to declare [self dealloc] where -dealloc permits an orderly wind down as usual? What are the principal risks?
...
0
votes
0
answers
198
views
Designing a self Recallable/Destructible email program
The title says it all. This is one of my assignments and I need some help in getting started. The basic idea behind the assignment is that I have to design a self destructible email program that is ...
293
votes
10
answers
144k
views
Is "delete this" allowed in C++?
Is it allowed to delete this; if the delete-statement is the last statement that will be executed on that instance of the class? Of course I'm sure that the object represented by the this-pointer is ...
3
votes
8
answers
1k
views
How could one design a secure and "self-destructing" email?
As most of you know, email is very insecure. Even with a SSL-secured connection between the client and the server that sends an email, the message itself will be in plaintext while it hops around ...
28
votes
4
answers
15k
views
PHP file that should run once and delete itself. Is it possible?
Is it possible to create a PHP file that runs once with no errors and deletes itself?
25
votes
11
answers
16k
views
How can I make my .NET application erase itself?
How can I make my C# app erase itself (self-destruct)? Here's two ways that I think might work:
Supply another program that deletes the main program. How is this deleter program deleted then, though?
...
21
votes
12
answers
3k
views
Should "delete this" be called from within a member method?
I was just reading this article and wanted SO folks advice:
Q: Should delete this; be called from within a member method?
2
votes
4
answers
1k
views
Can I delete a dynamically allocated class using a function within that class?
I'm writing a state manager for a game. I've got most of the logic down for how I want to do this.
I want states, which will be classes, to be handled in a stack in the StateManager class. Each state ...