1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
|
From 70ed30f9e6b47fbfb3151078ca61a2bb419feccb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= <peterix@gmail.com>
Date: Sun, 7 Apr 2019 23:59:04 +0200
Subject: [PATCH] GH-2591 less std::shared_ptr and more shared_qobject_ptr
This eliminates some weird crashes.
---
api/gui/icons/IconList.h | 2 +-
api/logic/BaseInstance.cpp | 7 +---
api/logic/BaseInstance.h | 12 +++---
api/logic/NullInstance.h | 23 ++++++------
api/logic/java/JavaChecker.cpp | 4 +-
api/logic/java/JavaChecker.h | 6 ++-
api/logic/java/JavaCheckerJob.h | 2 +-
api/logic/java/JavaInstallList.cpp | 2 +-
api/logic/java/JavaInstallList.h | 4 +-
api/logic/java/launch/CheckJava.cpp | 2 +-
api/logic/launch/LaunchTask.cpp | 8 ++--
api/logic/launch/LaunchTask.h | 8 ++--
api/logic/minecraft/MinecraftInstance.cpp | 41 +++++++++------------
api/logic/minecraft/MinecraftInstance.h | 2 +-
api/logic/minecraft/legacy/LegacyInstance.h | 3 +-
api/logic/tools/BaseProfiler.cpp | 3 +-
api/logic/tools/BaseProfiler.h | 5 ++-
api/logic/tools/JProfiler.cpp | 4 +-
api/logic/tools/JVisualVM.cpp | 4 +-
application/InstanceWindow.cpp | 2 +-
application/InstanceWindow.h | 4 +-
application/LaunchController.cpp | 2 +-
application/LaunchController.h | 2 +-
application/pages/instance/LogPage.cpp | 4 +-
application/pages/instance/LogPage.h | 6 +--
25 files changed, 79 insertions(+), 83 deletions(-)
diff --git a/api/gui/icons/IconList.h b/api/gui/icons/IconList.h
index 2bacdac3b..274a9f022 100644
--- a/api/gui/icons/IconList.h
+++ b/api/gui/icons/IconList.h
@@ -80,7 +80,7 @@ protected slots:
void fileChanged(const QString &path);
void SettingChanged(const Setting & setting, QVariant value);
private:
- std::shared_ptr<QFileSystemWatcher> m_watcher;
+ shared_qobject_ptr<QFileSystemWatcher> m_watcher;
bool is_watching;
QMap<QString, int> name_index;
QVector<MMCIcon> icons;
diff --git a/api/logic/BaseInstance.cpp b/api/logic/BaseInstance.cpp
index 469d0d9ff..7a95e2559 100644
--- a/api/logic/BaseInstance.cpp
+++ b/api/logic/BaseInstance.cpp
@@ -175,11 +175,6 @@ QString BaseInstance::instanceRoot() const
return m_rootDir;
}
-InstancePtr BaseInstance::getSharedPtr()
-{
- return shared_from_this();
-}
-
SettingsObjectPtr BaseInstance::settings() const
{
return m_settings;
@@ -253,7 +248,7 @@ QStringList BaseInstance::extraArguments() const
return Commandline::splitArgs(settings()->get("JvmArgs").toString());
}
-std::shared_ptr<LaunchTask> BaseInstance::getLaunchTask()
+shared_qobject_ptr<LaunchTask> BaseInstance::getLaunchTask()
{
return m_launchProcess;
}
diff --git a/api/logic/BaseInstance.h b/api/logic/BaseInstance.h
index 73500b1a9..3c342cb3f 100644
--- a/api/logic/BaseInstance.h
+++ b/api/logic/BaseInstance.h
@@ -134,8 +134,6 @@ class MULTIMC_LOGIC_EXPORT BaseInstance : public QObject, public std::enable_sha
/// Sets the last launched time to 'val' milliseconds since epoch
void setLastLaunch(qint64 val = QDateTime::currentMSecsSinceEpoch());
- InstancePtr getSharedPtr();
-
/*!
* \brief Gets this instance's settings object.
* This settings object stores instance-specific settings.
@@ -147,10 +145,10 @@ class MULTIMC_LOGIC_EXPORT BaseInstance : public QObject, public std::enable_sha
virtual shared_qobject_ptr<Task> createUpdateTask(Net::Mode mode) = 0;
/// returns a valid launcher (task container)
- virtual std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) = 0;
+ virtual shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) = 0;
/// returns the current launch task (if any)
- std::shared_ptr<LaunchTask> getLaunchTask();
+ shared_qobject_ptr<LaunchTask> getLaunchTask();
/*!
* Create envrironment variables for running the instance
@@ -241,7 +239,7 @@ class MULTIMC_LOGIC_EXPORT BaseInstance : public QObject, public std::enable_sha
*/
void propertiesChanged(BaseInstance *inst);
- void launchTaskChanged(std::shared_ptr<LaunchTask>);
+ void launchTaskChanged(shared_qobject_ptr<LaunchTask>);
void runningStatusChanged(bool running);
@@ -255,7 +253,7 @@ protected slots:
SettingsObjectPtr m_settings;
// InstanceFlags m_flags;
bool m_isRunning = false;
- std::shared_ptr<LaunchTask> m_launchProcess;
+ shared_qobject_ptr<LaunchTask> m_launchProcess;
QDateTime m_timeStarted;
private: /* data */
@@ -265,6 +263,6 @@ protected slots:
bool m_hasBrokenVersion = false;
};
-Q_DECLARE_METATYPE(std::shared_ptr<BaseInstance>)
+Q_DECLARE_METATYPE(shared_qobject_ptr<BaseInstance>)
//Q_DECLARE_METATYPE(BaseInstance::InstanceFlag)
//Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags)
diff --git a/api/logic/NullInstance.h b/api/logic/NullInstance.h
index ff3551c5f..e9ba1a13c 100644
--- a/api/logic/NullInstance.h
+++ b/api/logic/NullInstance.h
@@ -1,5 +1,6 @@
#pragma once
#include "BaseInstance.h"
+#include "launch/LaunchTask.h"
class NullInstance: public BaseInstance
{
@@ -11,46 +12,46 @@ class NullInstance: public BaseInstance
setVersionBroken(true);
}
virtual ~NullInstance() {};
- virtual void saveNow() override
+ void saveNow() override
{
}
- virtual QString getStatusbarDescription() override
+ QString getStatusbarDescription() override
{
return tr("Unknown instance type");
};
- virtual QSet< QString > traits() const override
+ QSet< QString > traits() const override
{
return {};
};
- virtual QString instanceConfigFolder() const override
+ QString instanceConfigFolder() const override
{
return instanceRoot();
};
- virtual std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr) override
+ shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr) override
{
return nullptr;
}
- virtual shared_qobject_ptr< Task > createUpdateTask(Net::Mode mode) override
+ shared_qobject_ptr< Task > createUpdateTask(Net::Mode mode) override
{
return nullptr;
}
- virtual QProcessEnvironment createEnvironment() override
+ QProcessEnvironment createEnvironment() override
{
return QProcessEnvironment();
}
- virtual QMap<QString, QString> getVariables() const override
+ QMap<QString, QString> getVariables() const override
{
return QMap<QString, QString>();
}
- virtual IPathMatcher::Ptr getLogFileMatcher() override
+ IPathMatcher::Ptr getLogFileMatcher() override
{
return nullptr;
}
- virtual QString getLogFileRoot() override
+ QString getLogFileRoot() override
{
return instanceRoot();
}
- virtual QString typeName() const override
+ QString typeName() const override
{
return "Null";
}
diff --git a/api/logic/java/JavaChecker.cpp b/api/logic/java/JavaChecker.cpp
index 9ba3933f2..ca0f4bde7 100644
--- a/api/logic/java/JavaChecker.cpp
+++ b/api/logic/java/JavaChecker.cpp
@@ -75,8 +75,8 @@ void JavaChecker::stderrReady()
void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
{
killTimer.stop();
- QProcessPtr _process;
- _process.swap(process);
+ QProcessPtr _process = process;
+ process.reset();
JavaCheckResult result;
{
diff --git a/api/logic/java/JavaChecker.h b/api/logic/java/JavaChecker.h
index d5d4b0de6..af0dcb90c 100644
--- a/api/logic/java/JavaChecker.h
+++ b/api/logic/java/JavaChecker.h
@@ -3,6 +3,8 @@
#include <QTimer>
#include <memory>
+#include "QObjectPtr.h"
+
#include "multimc_logic_export.h"
#include "JavaVersion.h"
@@ -27,8 +29,8 @@ struct MULTIMC_LOGIC_EXPORT JavaCheckResult
} validity = Validity::Errored;
};
-typedef std::shared_ptr<QProcess> QProcessPtr;
-typedef std::shared_ptr<JavaChecker> JavaCheckerPtr;
+typedef shared_qobject_ptr<QProcess> QProcessPtr;
+typedef shared_qobject_ptr<JavaChecker> JavaCheckerPtr;
class MULTIMC_LOGIC_EXPORT JavaChecker : public QObject
{
Q_OBJECT
diff --git a/api/logic/java/JavaCheckerJob.h b/api/logic/java/JavaCheckerJob.h
index ab8a4bbcd..24d0d1b8f 100644
--- a/api/logic/java/JavaCheckerJob.h
+++ b/api/logic/java/JavaCheckerJob.h
@@ -20,7 +20,7 @@
#include "tasks/Task.h"
class JavaCheckerJob;
-typedef std::shared_ptr<JavaCheckerJob> JavaCheckerJobPtr;
+typedef shared_qobject_ptr<JavaCheckerJob> JavaCheckerJobPtr;
// FIXME: this just seems horribly redundant
class JavaCheckerJob : public Task
diff --git a/api/logic/java/JavaInstallList.cpp b/api/logic/java/JavaInstallList.cpp
index a80ee2dac..a71a7dbea 100644
--- a/api/logic/java/JavaInstallList.cpp
+++ b/api/logic/java/JavaInstallList.cpp
@@ -149,7 +149,7 @@ void JavaListLoadTask::executeTask()
JavaUtils ju;
QList<QString> candidate_paths = ju.FindJavaPaths();
- m_job = std::shared_ptr<JavaCheckerJob>(new JavaCheckerJob("Java detection"));
+ m_job = new JavaCheckerJob("Java detection");
connect(m_job.get(), &Task::finished, this, &JavaListLoadTask::javaCheckerFinished);
connect(m_job.get(), &Task::progress, this, &Task::setProgress);
diff --git a/api/logic/java/JavaInstallList.h b/api/logic/java/JavaInstallList.h
index fc7e7a921..b98908f38 100644
--- a/api/logic/java/JavaInstallList.h
+++ b/api/logic/java/JavaInstallList.h
@@ -24,6 +24,8 @@
#include "JavaCheckerJob.h"
#include "JavaInstall.h"
+#include "QObjectPtr.h"
+
#include "multimc_logic_export.h"
class JavaListLoadTask;
@@ -75,7 +77,7 @@ public slots:
void javaCheckerFinished();
protected:
- std::shared_ptr<JavaCheckerJob> m_job;
+ shared_qobject_ptr<JavaCheckerJob> m_job;
JavaInstallList *m_list;
JavaInstall *m_currentRecommended;
};
diff --git a/api/logic/java/launch/CheckJava.cpp b/api/logic/java/launch/CheckJava.cpp
index f4c852456..b75c6dc62 100644
--- a/api/logic/java/launch/CheckJava.cpp
+++ b/api/logic/java/launch/CheckJava.cpp
@@ -60,7 +60,7 @@ void CheckJava::executeTask()
// if timestamps are not the same, or something is missing, check!
if (javaUnixTime != storedUnixTime || storedVersion.size() == 0 || storedArchitecture.size() == 0)
{
- m_JavaChecker = std::make_shared<JavaChecker>();
+ m_JavaChecker = new JavaChecker();
emit logLine(tr("Checking Java version..."), MessageLevel::MultiMC);
connect(m_JavaChecker.get(), &JavaChecker::checkFinished, this, &CheckJava::checkJavaFinished);
m_JavaChecker->m_path = realJavaPath;
diff --git a/api/logic/launch/LaunchTask.cpp b/api/logic/launch/LaunchTask.cpp
index d39a92083..841b83633 100644
--- a/api/logic/launch/LaunchTask.cpp
+++ b/api/logic/launch/LaunchTask.cpp
@@ -33,9 +33,9 @@ void LaunchTask::init()
m_instance->setRunning(true);
}
-std::shared_ptr<LaunchTask> LaunchTask::create(InstancePtr inst)
+shared_qobject_ptr<LaunchTask> LaunchTask::create(InstancePtr inst)
{
- std::shared_ptr<LaunchTask> proc(new LaunchTask(inst));
+ shared_qobject_ptr<LaunchTask> proc(new LaunchTask(inst));
proc->init();
return proc;
}
@@ -44,12 +44,12 @@ LaunchTask::LaunchTask(InstancePtr instance): m_instance(instance)
{
}
-void LaunchTask::appendStep(std::shared_ptr<LaunchStep> step)
+void LaunchTask::appendStep(shared_qobject_ptr<LaunchStep> step)
{
m_steps.append(step);
}
-void LaunchTask::prependStep(std::shared_ptr<LaunchStep> step)
+void LaunchTask::prependStep(shared_qobject_ptr<LaunchStep> step)
{
m_steps.prepend(step);
}
diff --git a/api/logic/launch/LaunchTask.h b/api/logic/launch/LaunchTask.h
index 4f6efe0a1..ee04bd9af 100644
--- a/api/logic/launch/LaunchTask.h
+++ b/api/logic/launch/LaunchTask.h
@@ -45,11 +45,11 @@ class MULTIMC_LOGIC_EXPORT LaunchTask: public Task
};
public: /* methods */
- static std::shared_ptr<LaunchTask> create(InstancePtr inst);
+ static shared_qobject_ptr<LaunchTask> create(InstancePtr inst);
virtual ~LaunchTask() {};
- void appendStep(std::shared_ptr<LaunchStep> step);
- void prependStep(std::shared_ptr<LaunchStep> step);
+ void appendStep(shared_qobject_ptr<LaunchStep> step);
+ void prependStep(shared_qobject_ptr<LaunchStep> step);
void setCensorFilter(QMap<QString, QString> filter);
InstancePtr instance()
@@ -117,7 +117,7 @@ public slots:
protected: /* data */
InstancePtr m_instance;
shared_qobject_ptr<LogModel> m_logModel;
- QList <std::shared_ptr<LaunchStep>> m_steps;
+ QList <shared_qobject_ptr<LaunchStep>> m_steps;
QMap<QString, QString> m_censorFilter;
int currentStep = -1;
State state = NotStarted;
diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp
index 449a2ed5b..0d97e4aff 100644
--- a/api/logic/minecraft/MinecraftInstance.cpp
+++ b/api/logic/minecraft/MinecraftInstance.cpp
@@ -777,22 +777,22 @@ shared_qobject_ptr<Task> MinecraftInstance::createUpdateTask(Net::Mode mode)
return nullptr;
}
-std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session)
+shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session)
{
- auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr()));
+ // FIXME: get rid of shared_from_this ...
+ auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this()));
auto pptr = process.get();
ENV.icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG");
// print a header
{
- process->appendStep(std::make_shared<TextPrint>(pptr, "Minecraft folder is:\n" + gameRoot() + "\n\n", MessageLevel::MultiMC));
+ process->appendStep(new TextPrint(pptr, "Minecraft folder is:\n" + gameRoot() + "\n\n", MessageLevel::MultiMC));
}
// check java
{
- auto step = std::make_shared<CheckJava>(pptr);
- process->appendStep(step);
+ process->appendStep(new CheckJava(pptr));
}
// check launch method
@@ -800,14 +800,14 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s
QString method = launchMethod();
if(!validMethods.contains(method))
{
- process->appendStep(std::make_shared<TextPrint>(pptr, "Selected launch method \"" + method + "\" is not valid.\n", MessageLevel::Fatal));
+ process->appendStep(new TextPrint(pptr, "Selected launch method \"" + method + "\" is not valid.\n", MessageLevel::Fatal));
return process;
}
// run pre-launch command if that's needed
if(getPreLaunchCommand().size())
{
- auto step = std::make_shared<PreLaunchCommand>(pptr);
+ auto step = new PreLaunchCommand(pptr);
step->setWorkingDirectory(gameRoot());
process->appendStep(step);
}
@@ -815,42 +815,37 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s
// if we aren't in offline mode,.
if(session->status != AuthSession::PlayableOffline)
{
- process->appendStep(std::make_shared<ClaimAccount>(pptr, session));
- process->appendStep(std::make_shared<Update>(pptr, Net::Mode::Online));
+ process->appendStep(new ClaimAccount(pptr, session));
+ process->appendStep(new Update(pptr, Net::Mode::Online));
}
else
{
- process->appendStep(std::make_shared<Update>(pptr, Net::Mode::Offline));
+ process->appendStep(new Update(pptr, Net::Mode::Offline));
}
// if there are any jar mods
{
- auto step = std::make_shared<ModMinecraftJar>(pptr);
- process->appendStep(step);
+ process->appendStep(new ModMinecraftJar(pptr));
}
// print some instance info here...
{
- auto step = std::make_shared<PrintInstanceInfo>(pptr, session);
- process->appendStep(step);
+ process->appendStep(new PrintInstanceInfo(pptr, session));
}
// create the server-resource-packs folder (workaround for Minecraft bug MCL-3732)
{
- auto step = std::make_shared<CreateServerResourcePacksFolder>(pptr);
- process->appendStep(step);
+ process->appendStep(new CreateServerResourcePacksFolder(pptr));
}
// extract native jars if needed
{
- auto step = std::make_shared<ExtractNatives>(pptr);
- process->appendStep(step);
+ process->appendStep(new ExtractNatives(pptr));
}
// reconstruct assets if needed
{
- auto step = std::make_shared<ReconstructAssets>(pptr);
- process->appendStep(step);
+ process->appendStep(new ReconstructAssets(pptr));
}
{
@@ -858,14 +853,14 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s
auto method = launchMethod();
if(method == "LauncherPart")
{
- auto step = std::make_shared<LauncherPartLaunch>(pptr);
+ auto step = new LauncherPartLaunch(pptr);
step->setWorkingDirectory(gameRoot());
step->setAuthSession(session);
process->appendStep(step);
}
else if (method == "DirectJava")
{
- auto step = std::make_shared<DirectJavaLaunch>(pptr);
+ auto step = new DirectJavaLaunch(pptr);
step->setWorkingDirectory(gameRoot());
step->setAuthSession(session);
process->appendStep(step);
@@ -875,7 +870,7 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s
// run post-exit command if that's needed
if(getPostExitCommand().size())
{
- auto step = std::make_shared<PostLaunchCommand>(pptr);
+ auto step = new PostLaunchCommand(pptr);
step->setWorkingDirectory(gameRoot());
process->appendStep(step);
}
diff --git a/api/logic/minecraft/MinecraftInstance.h b/api/logic/minecraft/MinecraftInstance.h
index d9fffe576..fac309c25 100644
--- a/api/logic/minecraft/MinecraftInstance.h
+++ b/api/logic/minecraft/MinecraftInstance.h
@@ -78,7 +78,7 @@ class MULTIMC_LOGIC_EXPORT MinecraftInstance: public BaseInstance
////// Launch stuff //////
shared_qobject_ptr<Task> createUpdateTask(Net::Mode mode) override;
- std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override;
+ shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override;
QStringList extraArguments() const override;
QStringList verboseDescription(AuthSessionPtr session) override;
QList<Mod> getJarMods() const;
diff --git a/api/logic/minecraft/legacy/LegacyInstance.h b/api/logic/minecraft/legacy/LegacyInstance.h
index 56602a1e5..8bbc2d887 100644
--- a/api/logic/minecraft/legacy/LegacyInstance.h
+++ b/api/logic/minecraft/legacy/LegacyInstance.h
@@ -17,6 +17,7 @@
#include "BaseInstance.h"
#include "minecraft/Mod.h"
+#include "launch/LaunchTask.h"
#include "multimc_logic_export.h"
@@ -112,7 +113,7 @@ class MULTIMC_LOGIC_EXPORT LegacyInstance : public BaseInstance
{
return false;
}
- std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override
+ shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override
{
return nullptr;
}
diff --git a/api/logic/tools/BaseProfiler.cpp b/api/logic/tools/BaseProfiler.cpp
index c7d83549d..300d1a736 100644
--- a/api/logic/tools/BaseProfiler.cpp
+++ b/api/logic/tools/BaseProfiler.cpp
@@ -1,4 +1,5 @@
#include "BaseProfiler.h"
+#include "QObjectPtr.h"
#include <QProcess>
@@ -7,7 +8,7 @@ BaseProfiler::BaseProfiler(SettingsObjectPtr settings, InstancePtr instance, QOb
{
}
-void BaseProfiler::beginProfiling(std::shared_ptr<LaunchTask> process)
+void BaseProfiler::beginProfiling(shared_qobject_ptr<LaunchTask> process)
{
beginProfilingImpl(process);
}
diff --git a/api/logic/tools/BaseProfiler.h b/api/logic/tools/BaseProfiler.h
index f3e1ce3d9..da817f523 100644
--- a/api/logic/tools/BaseProfiler.h
+++ b/api/logic/tools/BaseProfiler.h
@@ -1,6 +1,7 @@
#pragma once
#include "BaseExternalTool.h"
+#include "QObjectPtr.h"
#include "multimc_logic_export.h"
@@ -17,13 +18,13 @@ class MULTIMC_LOGIC_EXPORT BaseProfiler : public BaseExternalTool
public
slots:
- void beginProfiling(std::shared_ptr<LaunchTask> process);
+ void beginProfiling(shared_qobject_ptr<LaunchTask> process);
void abortProfiling();
protected:
QProcess *m_profilerProcess;
- virtual void beginProfilingImpl(std::shared_ptr<LaunchTask> process) = 0;
+ virtual void beginProfilingImpl(shared_qobject_ptr<LaunchTask> process) = 0;
virtual void abortProfilingImpl();
signals:
diff --git a/api/logic/tools/JProfiler.cpp b/api/logic/tools/JProfiler.cpp
index b50322fe9..1dc0d109f 100644
--- a/api/logic/tools/JProfiler.cpp
+++ b/api/logic/tools/JProfiler.cpp
@@ -17,7 +17,7 @@ private slots:
void profilerFinished(int exit, QProcess::ExitStatus status);
protected:
- void beginProfilingImpl(std::shared_ptr<LaunchTask> process);
+ void beginProfilingImpl(shared_qobject_ptr<LaunchTask> process);
private:
int listeningPort = 0;
@@ -47,7 +47,7 @@ void JProfiler::profilerFinished(int exit, QProcess::ExitStatus status)
}
}
-void JProfiler::beginProfilingImpl(std::shared_ptr<LaunchTask> process)
+void JProfiler::beginProfilingImpl(shared_qobject_ptr<LaunchTask> process)
{
listeningPort = globalSettings->get("JProfilerPort").toInt();
QProcess *profiler = new QProcess(this);
diff --git a/api/logic/tools/JVisualVM.cpp b/api/logic/tools/JVisualVM.cpp
index 108868570..b1acc3c0a 100644
--- a/api/logic/tools/JVisualVM.cpp
+++ b/api/logic/tools/JVisualVM.cpp
@@ -18,7 +18,7 @@ private slots:
void profilerFinished(int exit, QProcess::ExitStatus status);
protected:
- void beginProfilingImpl(std::shared_ptr<LaunchTask> process);
+ void beginProfilingImpl(shared_qobject_ptr<LaunchTask> process);
};
@@ -45,7 +45,7 @@ void JVisualVM::profilerFinished(int exit, QProcess::ExitStatus status)
}
}
-void JVisualVM::beginProfilingImpl(std::shared_ptr<LaunchTask> process)
+void JVisualVM::beginProfilingImpl(shared_qobject_ptr<LaunchTask> process)
{
QProcess *profiler = new QProcess(this);
QStringList profilerArgs =
diff --git a/application/InstanceWindow.cpp b/application/InstanceWindow.cpp
index 8a9c3bdf4..cf445f121 100644
--- a/application/InstanceWindow.cpp
+++ b/application/InstanceWindow.cpp
@@ -144,7 +144,7 @@ void InstanceWindow::on_btnLaunchMinecraftOffline_clicked()
MMC->launch(m_instance, false, nullptr);
}
-void InstanceWindow::on_InstanceLaunchTask_changed(std::shared_ptr<LaunchTask> proc)
+void InstanceWindow::on_InstanceLaunchTask_changed(shared_qobject_ptr<LaunchTask> proc)
{
m_proc = proc;
}
diff --git a/application/InstanceWindow.h b/application/InstanceWindow.h
index 792624e2c..e5bd4464f 100644
--- a/application/InstanceWindow.h
+++ b/application/InstanceWindow.h
@@ -52,7 +52,7 @@ private
void on_btnKillMinecraft_clicked();
void on_btnLaunchMinecraftOffline_clicked();
- void on_InstanceLaunchTask_changed(std::shared_ptr<LaunchTask> proc);
+ void on_InstanceLaunchTask_changed(shared_qobject_ptr<LaunchTask> proc);
void on_RunningState_changed(bool running);
void on_instanceStatusChanged(BaseInstance::Status, BaseInstance::Status newStatus);
@@ -63,7 +63,7 @@ private
void updateLaunchButtons();
private:
- std::shared_ptr<LaunchTask> m_proc;
+ shared_qobject_ptr<LaunchTask> m_proc;
InstancePtr m_instance;
bool m_doNotSave = false;
PageContainer *m_container = nullptr;
diff --git a/application/LaunchController.cpp b/application/LaunchController.cpp
index 0115bba46..8f3e6596f 100644
--- a/application/LaunchController.cpp
+++ b/application/LaunchController.cpp
@@ -218,7 +218,7 @@ void LaunchController::launchInstance()
connect(m_launcher.get(), &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested);
- m_launcher->prependStep(std::make_shared<TextPrint>(m_launcher.get(), "MultiMC version: " + BuildConfig.printableVersionString() + "\n\n", MessageLevel::MultiMC));
+ m_launcher->prependStep(new TextPrint(m_launcher.get(), "MultiMC version: " + BuildConfig.printableVersionString() + "\n\n", MessageLevel::MultiMC));
m_launcher->start();
}
diff --git a/application/LaunchController.h b/application/LaunchController.h
index 1434dec9b..1d879028d 100644
--- a/application/LaunchController.h
+++ b/application/LaunchController.h
@@ -57,5 +57,5 @@ private slots:
QWidget * m_parentWidget = nullptr;
InstanceWindow *m_console = nullptr;
AuthSessionPtr m_session;
- std::shared_ptr <LaunchTask> m_launcher;
+ shared_qobject_ptr<LaunchTask> m_launcher;
};
diff --git a/application/pages/instance/LogPage.cpp b/application/pages/instance/LogPage.cpp
index 0e480a3a6..94ada4248 100644
--- a/application/pages/instance/LogPage.cpp
+++ b/application/pages/instance/LogPage.cpp
@@ -192,7 +192,7 @@ void LogPage::UIToModelState()
m_model->suspend(ui->trackLogCheckbox->checkState() != Qt::Checked);
}
-void LogPage::setInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc, bool initial)
+void LogPage::setInstanceLaunchTaskChanged(shared_qobject_ptr<LaunchTask> proc, bool initial)
{
m_process = proc;
if(m_process)
@@ -215,7 +215,7 @@ void LogPage::setInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc, boo
}
}
-void LogPage::onInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc)
+void LogPage::onInstanceLaunchTaskChanged(shared_qobject_ptr<LaunchTask> proc)
{
setInstanceLaunchTaskChanged(proc, false);
}
diff --git a/application/pages/instance/LogPage.h b/application/pages/instance/LogPage.h
index 34ed210a0..9c3b56a9a 100644
--- a/application/pages/instance/LogPage.h
+++ b/application/pages/instance/LogPage.h
@@ -69,17 +69,17 @@ private slots:
void findNextActivated();
void findPreviousActivated();
- void onInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc);
+ void onInstanceLaunchTaskChanged(shared_qobject_ptr<LaunchTask> proc);
private:
void modelStateToUI();
void UIToModelState();
- void setInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc, bool initial);
+ void setInstanceLaunchTaskChanged(shared_qobject_ptr<LaunchTask> proc, bool initial);
private:
Ui::LogPage *ui;
InstancePtr m_instance;
- std::shared_ptr<LaunchTask> m_process;
+ shared_qobject_ptr<LaunchTask> m_process;
LogFormatProxyModel * m_proxy;
shared_qobject_ptr <LogModel> m_model;
|