Issue 1472: fix so multi-open brings up tabs in same order as in file browser
This commit is contained in:
@@ -175,6 +175,14 @@ bool FilePanel::fileSelected (Thumbnail* thm) {
|
|||||||
bool loading = thm->imageLoad( true );
|
bool loading = thm->imageLoad( true );
|
||||||
if( !loading ) return false;
|
if( !loading ) return false;
|
||||||
|
|
||||||
|
pendingLoadMutex.lock();
|
||||||
|
pendingLoad *pl = new pendingLoad();
|
||||||
|
pl->complete = false;
|
||||||
|
pl->pc = 0;
|
||||||
|
pl->thm = thm;
|
||||||
|
pendingLoads.push_back(pl);
|
||||||
|
pendingLoadMutex.unlock();
|
||||||
|
|
||||||
ProgressConnector<rtengine::InitialImage*> *ld = new ProgressConnector<rtengine::InitialImage*>();
|
ProgressConnector<rtengine::InitialImage*> *ld = new ProgressConnector<rtengine::InitialImage*>();
|
||||||
ld->startFunc (sigc::bind(sigc::ptr_fun(&rtengine::InitialImage::load), thm->getFileName (), thm->getType()==FT_Raw, &error, parent->getProgressListener()),
|
ld->startFunc (sigc::bind(sigc::ptr_fun(&rtengine::InitialImage::load), thm->getFileName (), thm->getType()==FT_Raw, &error, parent->getProgressListener()),
|
||||||
sigc::bind(sigc::mem_fun(*this,&FilePanel::imageLoaded), thm, ld) );
|
sigc::bind(sigc::mem_fun(*this,&FilePanel::imageLoaded), thm, ld) );
|
||||||
@@ -182,38 +190,55 @@ bool FilePanel::fileSelected (Thumbnail* thm) {
|
|||||||
}
|
}
|
||||||
bool FilePanel::imageLoaded( Thumbnail* thm, ProgressConnector<rtengine::InitialImage*> *pc ){
|
bool FilePanel::imageLoaded( Thumbnail* thm, ProgressConnector<rtengine::InitialImage*> *pc ){
|
||||||
|
|
||||||
if (pc->returnValue() && thm) {
|
pendingLoadMutex.lock();
|
||||||
|
// find our place in the array and mark the entry as complete
|
||||||
|
for (unsigned int i = 0; i < pendingLoads.size(); i++) {
|
||||||
|
if (pendingLoads[i]->thm == thm) {
|
||||||
|
pendingLoads[i]->pc = pc;
|
||||||
|
pendingLoads[i]->complete = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The purpose of the pendingLoads vector is to open tabs in the same order as the loads where initiated. It has no effect on single editor mode.
|
||||||
|
while (pendingLoads.size() > 0 && pendingLoads.front()->complete) {
|
||||||
|
pendingLoad *pl = pendingLoads.front();
|
||||||
|
if (pl->pc->returnValue()) {
|
||||||
if (options.tabbedUI) {
|
if (options.tabbedUI) {
|
||||||
EditorPanel* epanel;
|
EditorPanel* epanel;
|
||||||
{
|
{
|
||||||
GThreadLock lock; // Acquiring the GUI... not sure that it's necessary, but it shouldn't harm
|
GThreadLock lock; // Acquiring the GUI... not sure that it's necessary, but it shouldn't harm
|
||||||
epanel = Gtk::manage (new EditorPanel ());
|
epanel = Gtk::manage (new EditorPanel ());
|
||||||
parent->addEditorPanel (epanel,thm->getFileName());
|
parent->addEditorPanel (epanel,pl->thm->getFileName());
|
||||||
}
|
}
|
||||||
epanel->open(thm, pc->returnValue() );
|
epanel->open(pl->thm, pl->pc->returnValue() );
|
||||||
if (!EditWindow::isMultiDisplayEnabled())
|
if (!EditWindow::isMultiDisplayEnabled())
|
||||||
parent->set_title_decorated(thm->getFileName());
|
parent->set_title_decorated(pl->thm->getFileName());
|
||||||
} else {
|
} else {
|
||||||
{
|
{
|
||||||
GThreadLock lock; // Acquiring the GUI... not sure that it's necessary, but it shouldn't harm
|
GThreadLock lock; // Acquiring the GUI... not sure that it's necessary, but it shouldn't harm
|
||||||
parent->SetEditorCurrent();
|
parent->SetEditorCurrent();
|
||||||
}
|
}
|
||||||
parent->epanel->open(thm, pc->returnValue() );
|
parent->epanel->open(pl->thm, pl->pc->returnValue() );
|
||||||
parent->set_title_decorated(thm->getFileName());
|
parent->set_title_decorated(pl->thm->getFileName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Glib::ustring msg_ = Glib::ustring("<b>") + M("MAIN_MSG_CANNOTLOAD") + " \"" + thm->getFileName() + "\" .\n</b>";
|
Glib::ustring msg_ = Glib::ustring("<b>") + M("MAIN_MSG_CANNOTLOAD") + " \"" + thm->getFileName() + "\" .\n</b>";
|
||||||
Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
||||||
msgd.run ();
|
msgd.run ();
|
||||||
}
|
}
|
||||||
delete pc;
|
delete pl->pc;
|
||||||
|
|
||||||
{
|
{
|
||||||
GThreadLock lock; // Acquiring the GUI... not sure that it's necessary, but it shouldn't harm
|
GThreadLock lock; // Acquiring the GUI... not sure that it's necessary, but it shouldn't harm
|
||||||
parent->setProgress(0.);
|
parent->setProgress(0.);
|
||||||
parent->setProgressStr("");
|
parent->setProgressStr("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pendingLoads.erase(pendingLoads.begin());
|
||||||
|
delete pl;
|
||||||
|
}
|
||||||
|
pendingLoadMutex.unlock();
|
||||||
|
|
||||||
thm->imageLoad( false );
|
thm->imageLoad( false );
|
||||||
|
|
||||||
return false; // MUST return false from idle function
|
return false; // MUST return false from idle function
|
||||||
|
8
rtgui/filepanel.h
Normal file → Executable file
8
rtgui/filepanel.h
Normal file → Executable file
@@ -51,6 +51,14 @@ class FilePanel : public Gtk::HPaned,
|
|||||||
RTWindow* parent;
|
RTWindow* parent;
|
||||||
Gtk::Notebook* rightNotebook;
|
Gtk::Notebook* rightNotebook;
|
||||||
|
|
||||||
|
struct pendingLoad {
|
||||||
|
bool complete;
|
||||||
|
ProgressConnector<rtengine::InitialImage*> *pc;
|
||||||
|
Thumbnail *thm;
|
||||||
|
};
|
||||||
|
MyMutex pendingLoadMutex;
|
||||||
|
std::vector<struct pendingLoad*> pendingLoads;
|
||||||
|
|
||||||
int error;
|
int error;
|
||||||
public:
|
public:
|
||||||
FilePanel ();
|
FilePanel ();
|
||||||
|
Reference in New Issue
Block a user