Replace g_idle_add_full()
with IdleRegister
(#3767)
This commit is contained in:
parent
91f8e46029
commit
6e1f7df2fb
@ -24,14 +24,6 @@
|
||||
#include "soundman.h"
|
||||
#include "rtimage.h"
|
||||
|
||||
int processLoadedBatchQueueUIThread (void* data)
|
||||
{
|
||||
|
||||
BatchQueue* bq = static_cast<BatchQueue*>(data);
|
||||
bq->resizeLoadedQueue();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Glib::ustring makeFolderLabel(Glib::ustring path)
|
||||
{
|
||||
if (!Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) {
|
||||
@ -185,11 +177,22 @@ BatchQueuePanel::BatchQueuePanel (FileCatalog* aFileCatalog)
|
||||
|
||||
show_all ();
|
||||
|
||||
if (batchQueue->loadBatchQueue ()) {
|
||||
g_idle_add_full (G_PRIORITY_LOW, processLoadedBatchQueueUIThread, batchQueue, nullptr);
|
||||
if (batchQueue->loadBatchQueue()) {
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
static_cast<BatchQueue*>(data)->resizeLoadedQueue();
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, batchQueue, G_PRIORITY_LOW);
|
||||
}
|
||||
}
|
||||
|
||||
BatchQueuePanel::~BatchQueuePanel()
|
||||
{
|
||||
idle_register.destroy();
|
||||
}
|
||||
|
||||
void BatchQueuePanel::init (RTWindow *parent)
|
||||
{
|
||||
this->parent = parent;
|
||||
|
@ -53,9 +53,11 @@ class BatchQueuePanel : public Gtk::VBox,
|
||||
Gtk::HBox* bottomBox;
|
||||
Gtk::HBox* topBox;
|
||||
|
||||
public:
|
||||
IdleRegister idle_register;
|
||||
|
||||
public:
|
||||
explicit BatchQueuePanel (FileCatalog* aFileCatalog);
|
||||
~BatchQueuePanel();
|
||||
|
||||
void init (RTWindow* parent);
|
||||
|
||||
|
@ -67,6 +67,7 @@ FileBrowserEntry::FileBrowserEntry (Thumbnail* thm, const Glib::ustring& fname)
|
||||
|
||||
FileBrowserEntry::~FileBrowserEntry ()
|
||||
{
|
||||
idle_register.destroy();
|
||||
|
||||
// so jobs arriving now do nothing
|
||||
if (feih->pending) {
|
||||
@ -176,39 +177,6 @@ void FileBrowserEntry::procParamsChanged (Thumbnail* thm, int whoChangedIt)
|
||||
}
|
||||
}
|
||||
|
||||
struct tiupdate {
|
||||
FileBrowserEntryIdleHelper* feih;
|
||||
rtengine::IImage8* img;
|
||||
double scale;
|
||||
rtengine::procparams::CropParams cropParams;
|
||||
};
|
||||
|
||||
int updateImageUI (void* data)
|
||||
{
|
||||
|
||||
tiupdate* params = static_cast<tiupdate*>(data);
|
||||
FileBrowserEntryIdleHelper* feih = params->feih;
|
||||
|
||||
if (feih->destroyed) {
|
||||
if (feih->pending == 1) {
|
||||
delete feih;
|
||||
} else {
|
||||
feih->pending--;
|
||||
}
|
||||
|
||||
params->img->free ();
|
||||
delete params;
|
||||
return 0;
|
||||
}
|
||||
|
||||
feih->fbentry->_updateImage (params->img, params->scale, params->cropParams);
|
||||
feih->pending--;
|
||||
|
||||
delete params;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FileBrowserEntry::updateImage (rtengine::IImage8* img, double scale, rtengine::procparams::CropParams cropParams)
|
||||
{
|
||||
|
||||
@ -225,16 +193,51 @@ void FileBrowserEntry::updateImage (rtengine::IImage8* img, double scale, rtengi
|
||||
feih->pending++;
|
||||
}
|
||||
|
||||
tiupdate* param = new tiupdate ();
|
||||
param->feih = feih;
|
||||
param->img = img;
|
||||
param->scale = scale;
|
||||
param->cropParams = cropParams;
|
||||
struct tiupdate {
|
||||
FileBrowserEntryIdleHelper* feih;
|
||||
rtengine::IImage8* img;
|
||||
double scale;
|
||||
rtengine::procparams::CropParams cropParams;
|
||||
};
|
||||
|
||||
tiupdate* param = new tiupdate{
|
||||
feih,
|
||||
img,
|
||||
scale,
|
||||
cropParams
|
||||
};
|
||||
|
||||
#if __GNUC__ == 4 && __GNUC_MINOR__ == 8 && defined( WIN32 ) && defined(__x86_64__)
|
||||
g_idle_add_full (G_PRIORITY_DEFAULT, updateImageUI, param, NULL);
|
||||
const gint priority = G_PRIORITY_DEFAULT;
|
||||
#else
|
||||
g_idle_add_full (G_PRIORITY_LOW, updateImageUI, param, nullptr);
|
||||
const gint priority = G_PRIORITY_LOW;
|
||||
#endif
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
tiupdate* const params = static_cast<tiupdate*>(data);
|
||||
FileBrowserEntryIdleHelper* const feih = params->feih;
|
||||
|
||||
if (feih->destroyed) {
|
||||
if (feih->pending == 1) {
|
||||
delete feih;
|
||||
} else {
|
||||
feih->pending--;
|
||||
}
|
||||
|
||||
params->img->free ();
|
||||
delete params;
|
||||
return 0;
|
||||
}
|
||||
|
||||
feih->fbentry->_updateImage (params->img, params->scale, params->cropParams);
|
||||
feih->pending--;
|
||||
|
||||
delete params;
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, param, priority);
|
||||
}
|
||||
|
||||
void FileBrowserEntry::_updateImage (rtengine::IImage8* img, double s, rtengine::procparams::CropParams cropParams)
|
||||
|
@ -57,6 +57,8 @@ class FileBrowserEntry : public ThumbBrowserEntryBase,
|
||||
|
||||
ImgEditState state;
|
||||
|
||||
IdleRegister idle_register;
|
||||
|
||||
bool onArea (CursorArea a, int x, int y);
|
||||
void updateCursor (int x, int y);
|
||||
void drawStraightenGuide (Cairo::RefPtr<Cairo::Context> c);
|
||||
|
@ -38,18 +38,12 @@ Glib::RefPtr<Gdk::Pixbuf> MyExpander::disabledPBuf;
|
||||
Glib::RefPtr<Gdk::Pixbuf> MyExpander::openedPBuf;
|
||||
Glib::RefPtr<Gdk::Pixbuf> MyExpander::closedPBuf;
|
||||
|
||||
guint add_idle (GSourceFunc function, gpointer data)
|
||||
{
|
||||
return gdk_threads_add_idle(function, data);
|
||||
//gtk_main_iteration_do(false);
|
||||
}
|
||||
|
||||
IdleRegister::~IdleRegister()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void IdleRegister::add(GSourceFunc function, gpointer data)
|
||||
void IdleRegister::add(GSourceFunc function, gpointer data, gint priority)
|
||||
{
|
||||
struct DataWrapper {
|
||||
IdleRegister* const self;
|
||||
@ -79,7 +73,7 @@ void IdleRegister::add(GSourceFunc function, gpointer data)
|
||||
};
|
||||
|
||||
mutex.lock();
|
||||
ids[data_wrapper] = add_idle(dispatch, data_wrapper);
|
||||
ids[data_wrapper] = gdk_threads_add_idle_full(priority, dispatch, data_wrapper, nullptr);
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
|
@ -44,15 +44,13 @@ void drawCrop (Cairo::RefPtr<Cairo::Context> cr, int imx, int imy, int imw, int
|
||||
gboolean acquireGUI(void* data);
|
||||
void setExpandAlignProperties(Gtk::Widget *widget, bool hExpand, bool vExpand, enum Gtk::Align hAlign, enum Gtk::Align vAlign);
|
||||
|
||||
guint add_idle (GSourceFunc function, gpointer data);
|
||||
|
||||
class IdleRegister final :
|
||||
public rtengine::NonCopyable
|
||||
{
|
||||
public:
|
||||
~IdleRegister();
|
||||
|
||||
void add(GSourceFunc function, gpointer data);
|
||||
void add(GSourceFunc function, gpointer data, gint priority = G_PRIORITY_DEFAULT_IDLE);
|
||||
void destroy();
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user