Questions tagged [destruction]
75 questions
2
votes
2 answers
How to safely destroy an object, that is frequently accessed by two different threads?
I currently ran into the Problem that an Object (Instance), that is frequently accessed by two different threads, has to be freed. For me it does not really matter which of the two threads is destructing the instance but i would prefer the one, that…

Jonas Eschmann
- 457
- 3
- 9
2
votes
2 answers
Initializing const objcts in a namespace
I'm running into a problem with initializing some const objects in my namespace. I have a namespace like the following:
namespace myNamespace{
const std::string HI = "Hi";
const std::string BYE = "Bye";
inline std::vector…

Wagan8r
- 468
- 5
- 18
2
votes
1 answer
explicitly call managed destructor from unmanaged c++
I have a native C++ project that makes use of .NET charting utilities through a wrapper class. A cut-down version of the wrapper class is something like this;
class ChartWrapper
{
private:
gcroot*…

Steztric
- 2,832
- 2
- 24
- 43
1
vote
2 answers
Storing pixel based world data
I am making a 2d game with destructable terrain. It will be on iOS but I am looking for ideas or pseudocode, not actual code. I'm wondering how to store a large amount of data. (It will be a large world, approximately 64000 pixels wide and 9600…

Joshua Walsh
- 1,915
- 5
- 25
- 50
1
vote
3 answers
Does a C++ object's destructor get called if there is an outstanding shared_ptr to one of its member functions?
Let's say we have the following class:
Class MyClass
{
void func();
std::shared_ptr> getFuncPointer(); // returns pointer to func()
};
Let's say there is an object of some other class (let's call it objectB) that owns…

Fuad
- 1,419
- 1
- 16
- 31
1
vote
2 answers
Correct destruction process for async code running in a thread
Below is (working) code for a generic websocket streamer.
It creates a daemon thread from which performs asyncio.run(...).
The asyncio code spawns 2 tasks, which never complete.
How to correctly destroy this object?
One of the tasks is executing a…

P i
- 29,020
- 36
- 159
- 267
1
vote
1 answer
QProcess on the loose
I have created two programs A and B. B is designed to be as a 32-bits QProcess started within a 64-bits A. These programs communicate nicely via stdin, stdout and QSharedMemory.
A:A() {
QProcess *p = new QProcess(this);
…

Magnus
- 13
- 3
1
vote
1 answer
We initialize our main object, and it creates a new object in its constructor. When we destroy the main object, what happens to its creation?
I think the title is very specific, but here's some code to exemplify the question. Also, I realize that aggregation would be the right choice for this particular example, and maybe the question itself poses an OOP smell; however, while I am…

KeepAtIt
- 163
- 12
1
vote
2 answers
What happen when a lvalue assigned to a rvalue reference? No destruction of the temporary object?
#include
using namespace std;
#include
class Word{
private:
char* ptr = nullptr;
public:
Word(){
cout << "default constructor" << endl;
}
Word(const char* sentence):ptr{new…

Billy Cheung
- 11
- 1
1
vote
0 answers
Main function looping based on file called in a different class
Rookie here so please be nice!! I have had so much fun learning to program and gotten some great help along the way when google failed me. But alas, I'm stuck again.
I have a C# program that looks like this (It's MWS if anyone is familiar)
I've…
1
vote
2 answers
Cannot create class in AHK after destruction
I'm trying to wrap my head around classes in AHK. I'm C++ dev, so would like to make use of RAII (__New, __Delete), but it looks like I miss some concepts since things look very contra-intuitive for me.
After some tries I came up with this simple…

Werolik
- 923
- 1
- 9
- 23
1
vote
3 answers
Destructuring declaration bug with the value
I can not understand why after destructuring assignment, items prop does not equal Gorilla.
It will be used after deleting the main prop items: "Piggi" in the origin object options. I do not understand why...
'use strict';
let…

Sviat Kuzhelev
- 1,758
- 10
- 28
1
vote
1 answer
static local variable destruction in plugin
I saw several questions about static local variable and static member of a class. From one comment in this and probably the most clear one link
C++ Primer says:
Each local static variable is initialized before the
first time execution passes…

user1073719
- 83
- 8
1
vote
1 answer
Destructive operations in scheme environments
I'm confused about destructive operations in Scheme. Let's say I have a list and some destructive procedures defined in the global environment:
(define a '(a b c))
(define (mutate-obj x)
(set! x '(mutated)))
(define (mutate-car! x)
(set-car!…
user1019830
1
vote
1 answer
vector does not erase content correctly (infite amount run of copy asignment operator untill crash [BEX])?
Well my problem is that after I want to "unload" loaded DLL's the copy assignmnent operator is called an unlimited amount of times until crash.
The code from which I remove the vector data looks like this:
void UnloadPlugins()
{
…
user1182183