Skip to content

Commit 3befec5

Browse files
committed
Fix malloc crash by restricting Flameshot gui instances
1 parent b61b047 commit 3befec5

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/core/flameshot.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,12 @@ CaptureWidget* Flameshot::gui(const CaptureRequest& req)
126126
m_captureWindow->showFullScreen();
127127
// m_captureWindow->show(); // For CaptureWidget Debugging under Linux
128128
#endif
129+
130+
isRequested = false;
129131
return m_captureWindow;
130132
} else {
131133
emit captureFailed();
134+
isRequested = false;
132135
return nullptr;
133136
}
134137
}
@@ -170,8 +173,10 @@ void Flameshot::screen(CaptureRequest req, const int screenNumber)
170173
req.addPinTask(region);
171174
}
172175
exportCapture(p, geometry, req);
176+
isRequested = false;
173177
} else {
174178
emit captureFailed();
179+
isRequested = false;
175180
}
176181
}
177182

@@ -190,8 +195,10 @@ void Flameshot::full(const CaptureRequest& req)
190195
if (ok) {
191196
QRect selection; // `flameshot full` does not support --selection
192197
exportCapture(p, selection, req);
198+
isRequested = false;
193199
} else {
194200
emit captureFailed();
201+
isRequested = false;
195202
}
196203
}
197204

@@ -305,12 +312,21 @@ bool Flameshot::resolveAnyConfigErrors()
305312
return resolved;
306313
}
307314

315+
bool Flameshot::isRequested = false;
316+
308317
void Flameshot::requestCapture(const CaptureRequest& request)
309318
{
310319
if (!resolveAnyConfigErrors()) {
311320
return;
312321
}
313322

323+
if(isRequested) {
324+
AbstractLogger::info() << "Another capture request is already in progress. Will not start another capture instance until it's complete.";
325+
return;
326+
}
327+
328+
isRequested = true;
329+
314330
switch (request.captureMode()) {
315331
case CaptureRequest::FULLSCREEN_MODE:
316332
QTimer::singleShot(request.delay(),

src/core/flameshot.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Flameshot : public QObject
2323
Q_OBJECT
2424

2525
public:
26+
static bool isRequested;
2627
enum Origin
2728
{
2829
CLI,

0 commit comments

Comments
 (0)