bool EditObjectDialog::saveObject() { if (!object()) { qDebug() << "no object from save"; return false; } if (object()->readOnly()) { qDebug() << "object is readonly"; return false; } if (!object()->canSave() || !object()->save()) { QMessageBox::critical(this,tr("Can Save"),objectError()); return false; } return true; }
void EditObjectDialog::showEvent( QShowEvent *e ) { if (!object() || !objectWidget()) { qDebug() << "some object is not accepted" << object() << objectWidget(); e->ignore(); } objectWidget()->setEditObject(object()); setupUi(); loadSettings(); if (!object()->isLoaded() && !object()->load()) { QMessageBox::critical(this,tr("Load"),objectError()); e->ignore(); return; } objectWidget()->updateData(); e->accept(); }
refVoid makeHunk(int size) { refHunk leftHunk; refHunk newHunk; refHunk rightHunk; int space; // Try to satisfy the request from SIZED HUNKS. This works most of the time. newHunk = sizedHunks[size]; if (newHunk != nil) { sizedHunks[size] = next(newHunk); return toRefVoid(newHunk); } // But if it didn't work, try to satisfy the request from UNSIZED HUNKS, using // a first-fit strategy. See: // // E. Horowitz and S. Sahni. Fundamentals of Data Structures. Computer Science // Press, 1976, pp. 140-155. leftHunk = r(unsizedHunks); rightHunk = unsizedHunks.next; while (rightHunk != nil) { space = space(rightHunk); if (space == size) { next(leftHunk) = next(rightHunk); return toRefVoid(rightHunk); } else if (space >= size + hunkSize) { newHunk = rightHunk; rightHunk = toRefHunk(toRefChar(rightHunk) + size); space(rightHunk) = space - size; state(rightHunk) = 0; tag(rightHunk) = hunkTag; next(rightHunk) = next(newHunk); next(leftHunk) = rightHunk; return toRefVoid(newHunk); } else { leftHunk = rightHunk; rightHunk = next(rightHunk); }} // If that didn't work, then collect garbage and try SIZED HUNKS again. reclaimSizedHunks(); newHunk = sizedHunks[size]; if (newHunk != nil) { sizedHunks[size] = next(newHunk); return toRefVoid(newHunk); } // If that didn't work, maybe the SIZED HUNKs are too fragmented. Compress all // small hunks into a few larger ones. Try to satisfy the request from UNSIZED // HUNKS again. reclaimUnsizedHunks(); leftHunk = r(unsizedHunks); rightHunk = unsizedHunks.next; while (rightHunk != nil) { space = space(rightHunk); if (space == size) { next(leftHunk) = next(rightHunk); return toRefVoid(rightHunk); } else if (space >= size + hunkSize) { newHunk = rightHunk; rightHunk = toRefHunk(toRefChar(rightHunk) + size); space(rightHunk) = space - size; state(rightHunk) = 0; tag(rightHunk) = hunkTag; next(rightHunk) = next(newHunk); next(leftHunk) = rightHunk; return toRefVoid(newHunk); } else { leftHunk = rightHunk; rightHunk = next(rightHunk); }} // And if that didn't work, then the heap is exhausted, and we HALT Orson (see // ORSON/MAIN). If FORM CALL is NIL, then we're compiling a program too big to // fit in memory. If it isn't NIL, then we're transforming that program. if (formCall == nil) { sourceError(haltErr); sourceError(outOfMemoryErr); } else { objectError(formCall, haltErr); objectError(formCall, outOfMemoryErr); } longjmp(halt, true); }